@chainsys/sab-react-grid 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +234 -0
- package/dist/cjs/SabReactTable.js +1192 -0
- package/dist/cjs/SabReactTable.js.map +1 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/utils/exportUtils.js +85 -0
- package/dist/cjs/utils/exportUtils.js.map +1 -0
- package/dist/cjs/utils/tableColumnResizeUtils.js +153 -0
- package/dist/cjs/utils/tableColumnResizeUtils.js.map +1 -0
- package/dist/cjs/utils/tableFormatters.js +239 -0
- package/dist/cjs/utils/tableFormatters.js.map +1 -0
- package/dist/esm/SabReactTable.d.ts +46 -0
- package/dist/esm/SabReactTable.d.ts.map +1 -0
- package/dist/esm/SabReactTable.js +1163 -0
- package/dist/esm/SabReactTable.js.map +1 -0
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/utils/exportUtils.d.ts +17 -0
- package/dist/esm/utils/exportUtils.d.ts.map +1 -0
- package/dist/esm/utils/exportUtils.js +78 -0
- package/dist/esm/utils/exportUtils.js.map +1 -0
- package/dist/esm/utils/tableColumnResizeUtils.d.ts +21 -0
- package/dist/esm/utils/tableColumnResizeUtils.d.ts.map +1 -0
- package/dist/esm/utils/tableColumnResizeUtils.js +148 -0
- package/dist/esm/utils/tableColumnResizeUtils.js.map +1 -0
- package/dist/esm/utils/tableFormatters.d.ts +57 -0
- package/dist/esm/utils/tableFormatters.d.ts.map +1 -0
- package/dist/esm/utils/tableFormatters.js +231 -0
- package/dist/esm/utils/tableFormatters.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,1192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.SabReactTable = SabReactTable;
|
|
30
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
+
const react_table_1 = require("@tanstack/react-table");
|
|
32
|
+
const react_virtual_1 = require("@tanstack/react-virtual");
|
|
33
|
+
const react_1 = __importStar(require("react"));
|
|
34
|
+
const react_dom_1 = require("react-dom");
|
|
35
|
+
const tableFormatters_1 = require("./utils/tableFormatters");
|
|
36
|
+
const exportUtils_1 = require("./utils/exportUtils");
|
|
37
|
+
const tableColumnResizeUtils_1 = require("./utils/tableColumnResizeUtils");
|
|
38
|
+
const react_flatpickr_1 = __importDefault(require("react-flatpickr"));
|
|
39
|
+
require("flatpickr/dist/themes/material_green.css");
|
|
40
|
+
/** Resolve column header label at render time from table + columns so grouping zone and group rows always show header (Name, Email) not id (name, email). */
|
|
41
|
+
function resolveGroupingLabel(colId, table, columns, labelMap) {
|
|
42
|
+
if (colId == null || typeof colId !== 'string')
|
|
43
|
+
return String(colId ?? '');
|
|
44
|
+
const s = String(colId).trim();
|
|
45
|
+
if (!s)
|
|
46
|
+
return colId;
|
|
47
|
+
const fromMap = labelMap[s];
|
|
48
|
+
if (fromMap != null && fromMap !== '' && fromMap !== s)
|
|
49
|
+
return fromMap;
|
|
50
|
+
if (Array.isArray(columns)) {
|
|
51
|
+
const fromProp = columns.find((c) => String(c?.id ?? c?.accessorKey ?? '') === s);
|
|
52
|
+
const propHeader = fromProp && fromProp.header;
|
|
53
|
+
if (typeof propHeader === 'string')
|
|
54
|
+
return propHeader;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const col = table.getColumn(s);
|
|
58
|
+
if (col) {
|
|
59
|
+
const h = col.columnDef.header;
|
|
60
|
+
if (typeof h === 'string')
|
|
61
|
+
return h;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (_) { /* ignore */ }
|
|
65
|
+
return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Filter Operands Configuration
|
|
69
|
+
*/
|
|
70
|
+
const STRING_OPERANDS = [
|
|
71
|
+
{ label: 'Contains', value: 'contains', symbol: '*a*' },
|
|
72
|
+
{ label: 'Not Contains', value: 'notContains', symbol: '<>' },
|
|
73
|
+
{ label: 'Equals', value: 'equals', symbol: '=' },
|
|
74
|
+
{ label: 'Not Equal to', value: 'notEquals', symbol: '!=' },
|
|
75
|
+
{ label: 'Starts With', value: 'startsWith', symbol: 'a*' },
|
|
76
|
+
{ label: 'Ends With', value: 'endsWith', symbol: '*z' },
|
|
77
|
+
];
|
|
78
|
+
const NUMBER_OPERANDS = [
|
|
79
|
+
{ label: 'Equal to', value: 'equals', symbol: '=' },
|
|
80
|
+
{ label: 'LESS_THAN', value: 'lt', symbol: '<' },
|
|
81
|
+
{ label: 'Greater than', value: 'gt', symbol: '>' },
|
|
82
|
+
{ label: 'LESS_THAN_OR_EQUAL_TO', value: 'lte', symbol: '<=' },
|
|
83
|
+
{ label: 'GREATER_THAN_OR_EQUAL_TO', value: 'gte', symbol: '>=' },
|
|
84
|
+
{ label: 'NOT_EQUAL_TO', value: 'notEquals', symbol: '!=' },
|
|
85
|
+
];
|
|
86
|
+
/**
|
|
87
|
+
* Advanced Filter Function
|
|
88
|
+
* Handles both object payload {value, operand} and simple string payload
|
|
89
|
+
*/
|
|
90
|
+
const parseCustomDate = (val) => {
|
|
91
|
+
if (val === null || val === undefined || val === '')
|
|
92
|
+
return NaN;
|
|
93
|
+
if (typeof val === 'number')
|
|
94
|
+
return val;
|
|
95
|
+
const str = String(val).trim();
|
|
96
|
+
// Handle numbers with commas first to prevent "1,000" -> NaN
|
|
97
|
+
const cleanNum = str.replace(/,/g, '');
|
|
98
|
+
if (/^-?\d+(\.\d+)?$/.test(cleanNum))
|
|
99
|
+
return Number(cleanNum);
|
|
100
|
+
// Handle DD/MM/YYYY format
|
|
101
|
+
if (str.includes('/')) {
|
|
102
|
+
const parts = str.split(/[\s/:]/);
|
|
103
|
+
if (parts.length >= 3) {
|
|
104
|
+
const d = Number(parts[0]);
|
|
105
|
+
const m = Number(parts[1]);
|
|
106
|
+
const y = Number(parts[2]);
|
|
107
|
+
if (!isNaN(d) && !isNaN(m) && !isNaN(y)) {
|
|
108
|
+
let h = 0, min = 0;
|
|
109
|
+
if (parts.length >= 5) {
|
|
110
|
+
h = Number(parts[3]);
|
|
111
|
+
min = Number(parts[4]);
|
|
112
|
+
const ampm = str.toLowerCase();
|
|
113
|
+
if (ampm.includes('pm') && h < 12)
|
|
114
|
+
h += 12;
|
|
115
|
+
if (ampm.includes('am') && h === 12)
|
|
116
|
+
h = 0;
|
|
117
|
+
}
|
|
118
|
+
const date = new Date(y, m - 1, d, h, min);
|
|
119
|
+
if (!isNaN(date.getTime()))
|
|
120
|
+
return date.getTime();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const fallback = new Date(str).getTime();
|
|
125
|
+
return isNaN(fallback) ? Number(str) : fallback;
|
|
126
|
+
};
|
|
127
|
+
const advancedFilterFn = (row, columnId, filterValue) => {
|
|
128
|
+
// 1. Handle Array (MultiSelect / Checkbox)
|
|
129
|
+
if (Array.isArray(filterValue)) {
|
|
130
|
+
if (filterValue.length === 0)
|
|
131
|
+
return true;
|
|
132
|
+
const cellValue = row.getValue(columnId);
|
|
133
|
+
if (Array.isArray(cellValue))
|
|
134
|
+
return filterValue.some(v => cellValue.includes(v));
|
|
135
|
+
return filterValue.includes(cellValue);
|
|
136
|
+
}
|
|
137
|
+
// 2. Handle Object { value, operand }
|
|
138
|
+
let value = filterValue;
|
|
139
|
+
let operand = 'contains';
|
|
140
|
+
if (filterValue && typeof filterValue === 'object' && 'value' in filterValue) {
|
|
141
|
+
value = filterValue.value;
|
|
142
|
+
operand = filterValue.operand || 'contains';
|
|
143
|
+
}
|
|
144
|
+
if (value === undefined || value === null || value === '')
|
|
145
|
+
return true;
|
|
146
|
+
const cellValue = row.getValue(columnId);
|
|
147
|
+
// Boolean Check
|
|
148
|
+
if (typeof value === 'boolean') {
|
|
149
|
+
return cellValue === value;
|
|
150
|
+
}
|
|
151
|
+
if (cellValue === undefined || cellValue === null)
|
|
152
|
+
return false;
|
|
153
|
+
const sVal = String(cellValue).toLowerCase();
|
|
154
|
+
const fVal = String(value).toLowerCase();
|
|
155
|
+
// Date/Number Parsing
|
|
156
|
+
const nCell = parseCustomDate(cellValue);
|
|
157
|
+
const nFilt = parseCustomDate(value);
|
|
158
|
+
// Helper checks
|
|
159
|
+
const isDateCompare = !isNaN(nCell) && !isNaN(nFilt) && (String(cellValue).includes('/') || String(value).includes('/'));
|
|
160
|
+
switch (operand) {
|
|
161
|
+
case 'contains': return sVal.includes(fVal);
|
|
162
|
+
case 'notContains': return !sVal.includes(fVal);
|
|
163
|
+
case 'equals': return isNaN(nCell) || isNaN(nFilt) ? sVal === fVal : (isDateCompare ? Math.abs(nCell - nFilt) < 60000 : nCell === nFilt); // 1 min tolerance for dates? or exact.
|
|
164
|
+
case 'notEquals': return isNaN(nCell) || isNaN(nFilt) ? sVal !== fVal : nCell !== nFilt;
|
|
165
|
+
case 'startsWith': return sVal.startsWith(fVal);
|
|
166
|
+
case 'endsWith': return sVal.endsWith(fVal);
|
|
167
|
+
case 'gt': return (isDateCompare || !isNaN(nCell)) && nCell > nFilt;
|
|
168
|
+
case 'lt': return (isDateCompare || !isNaN(nCell)) && nCell < nFilt;
|
|
169
|
+
case 'lte': return (isDateCompare || !isNaN(nCell)) && nCell <= nFilt;
|
|
170
|
+
case 'gte': return (isDateCompare || !isNaN(nCell)) && nCell >= nFilt;
|
|
171
|
+
default: return sVal.includes(fVal);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
// --- OPTIMIZATION: Memoized Header Cell ---
|
|
175
|
+
const MemoizedHeaderCell = (0, react_1.memo)(({ header, draggedColumnId, onDragStart, onDragOver, onDragEnd, onDrop, layoutMode, totalSize }) => {
|
|
176
|
+
const [showMenu, setShowMenu] = (0, react_1.useState)(false);
|
|
177
|
+
const menuRef = (0, react_1.useRef)(null);
|
|
178
|
+
const isSorted = header.column.getIsSorted();
|
|
179
|
+
const handleSort = (e, dir) => {
|
|
180
|
+
e.stopPropagation();
|
|
181
|
+
if (dir === 'clear')
|
|
182
|
+
header.column.clearSorting();
|
|
183
|
+
else
|
|
184
|
+
header.column.toggleSorting(dir === 'desc', true);
|
|
185
|
+
setShowMenu(false);
|
|
186
|
+
};
|
|
187
|
+
const handleRemoveFilter = (e) => {
|
|
188
|
+
e.stopPropagation();
|
|
189
|
+
header.column.setFilterValue(undefined);
|
|
190
|
+
setShowMenu(false);
|
|
191
|
+
};
|
|
192
|
+
(0, react_1.useEffect)(() => {
|
|
193
|
+
const hide = (e) => {
|
|
194
|
+
if (menuRef.current && !menuRef.current.contains(e.target))
|
|
195
|
+
setShowMenu(false);
|
|
196
|
+
};
|
|
197
|
+
if (showMenu)
|
|
198
|
+
document.addEventListener('mousedown', hide);
|
|
199
|
+
return () => document.removeEventListener('mousedown', hide);
|
|
200
|
+
}, [showMenu]);
|
|
201
|
+
const widthStyle = (layoutMode === 'fit-window' && totalSize > 0)
|
|
202
|
+
? `${(header.getSize() / totalSize) * 100}%`
|
|
203
|
+
: header.getSize();
|
|
204
|
+
const [menuStyle, setMenuStyle] = (0, react_1.useState)({});
|
|
205
|
+
(0, react_1.useEffect)(() => {
|
|
206
|
+
if (showMenu && menuRef.current) {
|
|
207
|
+
const rect = menuRef.current.parentElement?.getBoundingClientRect();
|
|
208
|
+
if (rect) {
|
|
209
|
+
// If cell is near left edge, align menu to left
|
|
210
|
+
if (rect.left < 200) {
|
|
211
|
+
setMenuStyle({ left: 0, right: 'auto' });
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
setMenuStyle({ right: 0, left: 'auto' });
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}, [showMenu]);
|
|
219
|
+
return ((0, jsx_runtime_1.jsxs)("th", { colSpan: header.colSpan, onDragOver: (e) => onDragOver(e, header.column.id), onDrop: (e) => onDrop(e, header.column.id), className: `slick-header-th ${draggedColumnId === header.column.id ? 'dragging' : ''}`, style: {
|
|
220
|
+
width: widthStyle,
|
|
221
|
+
position: 'sticky',
|
|
222
|
+
top: 0,
|
|
223
|
+
zIndex: 35,
|
|
224
|
+
background: '#f1f5f9'
|
|
225
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { className: "slick-header-cell-inner", children: [(0, jsx_runtime_1.jsxs)("div", { className: "slick-header-label", draggable: true, onDragStart: (e) => {
|
|
226
|
+
if (e.dataTransfer) {
|
|
227
|
+
e.dataTransfer.setData('text/plain', header.column.id);
|
|
228
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
229
|
+
}
|
|
230
|
+
onDragStart(header.column.id);
|
|
231
|
+
}, onDragEnd: onDragEnd, onClick: header.column.getCanSort() ? header.column.getToggleSortingHandler() : undefined, style: { cursor: header.column.getCanSort() ? 'pointer' : 'default' }, title: typeof header.column.columnDef.header === 'string' ? header.column.columnDef.header : undefined, children: [(0, react_table_1.flexRender)(header.column.columnDef.header, header.getContext()), header.column.getCanSort() && (isSorted === 'asc' ? ' ▴' : isSorted === 'desc' ? ' ▾' : '')] }), !header.column.columnDef.meta?.hideMenu && ((0, jsx_runtime_1.jsx)("div", { className: `slick-header-actions ${showMenu ? 'visible' : ''}`, onClick: (e) => { e.stopPropagation(); setShowMenu(!showMenu); }, children: (0, jsx_runtime_1.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: (0, jsx_runtime_1.jsx)("polyline", { points: "6 9 12 15 18 9" }) }) })), showMenu && ((0, jsx_runtime_1.jsxs)("div", { ref: menuRef, className: "slick-header-dropdown-menu", style: menuStyle, children: [header.column.getCanSort() && isSorted !== 'asc' && ((0, jsx_runtime_1.jsxs)("div", { className: "dropdown-item", onClick: (e) => handleSort(e, 'asc'), children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon mini-icon", children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("path", { d: "M11 5h10" }), (0, jsx_runtime_1.jsx)("path", { d: "M11 9h7" }), (0, jsx_runtime_1.jsx)("path", { d: "M11 13h4" }), (0, jsx_runtime_1.jsx)("path", { d: "M3 17l3 3 3-3" }), (0, jsx_runtime_1.jsx)("path", { d: "M6 18V4" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Sort Ascending" })] })), header.column.getCanSort() && isSorted !== 'desc' && ((0, jsx_runtime_1.jsxs)("div", { className: "dropdown-item", onClick: (e) => handleSort(e, 'desc'), children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon mini-icon", children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("path", { d: "M11 5h10" }), (0, jsx_runtime_1.jsx)("path", { d: "M11 9h7" }), (0, jsx_runtime_1.jsx)("path", { d: "M11 13h4" }), (0, jsx_runtime_1.jsx)("path", { d: "M3 7l3-3 3 3" }), (0, jsx_runtime_1.jsx)("path", { d: "M6 20V6" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Sort Descending" })] })), (0, jsx_runtime_1.jsx)("div", { className: "dropdown-divider" }), (0, jsx_runtime_1.jsxs)("div", { className: "dropdown-item", onClick: handleRemoveFilter, children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon mini-icon", children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("path", { d: "M22 3H2l8 9.46V19l4 2v-8.54L22 3z" }), (0, jsx_runtime_1.jsx)("line", { x1: "3", y1: "3", x2: "21", y2: "21" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Remove Filter" })] }), header.column.getCanSort() && ((0, jsx_runtime_1.jsxs)("div", { className: "dropdown-item", onClick: (e) => handleSort(e, 'clear'), children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon mini-icon", children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("path", { d: "M7 15l5 5 5-5" }), (0, jsx_runtime_1.jsx)("path", { d: "M7 9l5-5 5 5" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Remove Sort" })] }))] }))] }), header.column.getCanResize() && layoutMode !== 'fit-window' && ((0, jsx_runtime_1.jsx)("div", { className: "slick-resizer", onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), onClick: (e) => e.stopPropagation() }))] }, header.id));
|
|
232
|
+
}, (prevProps, nextProps) => {
|
|
233
|
+
// Re-render when header changes (important for column reordering to work)
|
|
234
|
+
if (prevProps.header !== nextProps.header)
|
|
235
|
+
return false;
|
|
236
|
+
return (prevProps.draggedColumnId === nextProps.draggedColumnId &&
|
|
237
|
+
prevProps.layoutMode === nextProps.layoutMode &&
|
|
238
|
+
prevProps.totalSize === nextProps.totalSize &&
|
|
239
|
+
prevProps.onDragStart === nextProps.onDragStart &&
|
|
240
|
+
prevProps.onDragOver === nextProps.onDragOver &&
|
|
241
|
+
prevProps.onDragEnd === nextProps.onDragEnd &&
|
|
242
|
+
prevProps.onDrop === nextProps.onDrop);
|
|
243
|
+
});
|
|
244
|
+
// Placeholder for text/number and dropdown filter fields
|
|
245
|
+
const FILTER_PLACEHOLDER = '🔎︎';
|
|
246
|
+
// Placeholder for date, datetime, and time filter fields only (used as Flatpickr placeholder text)
|
|
247
|
+
// const FILTER_PLACEHOLDER_DATE = '📅'
|
|
248
|
+
// Calendar icon SVG for date/datetime/time filter placeholder (light gray, shown when empty)
|
|
249
|
+
const FilterCalendarIcon = () => ((0, jsx_runtime_1.jsx)("span", { className: "filter-date-placeholder-icon", "aria-hidden": true, children: (0, jsx_runtime_1.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [(0, jsx_runtime_1.jsx)("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2", ry: "2" }), (0, jsx_runtime_1.jsx)("line", { x1: "16", y1: "2", x2: "16", y2: "6" }), (0, jsx_runtime_1.jsx)("line", { x1: "8", y1: "2", x2: "8", y2: "6" }), (0, jsx_runtime_1.jsx)("line", { x1: "3", y1: "10", x2: "21", y2: "10" })] }) }));
|
|
250
|
+
// --- OPTIMIZATION: Memoized Filter Cell ---
|
|
251
|
+
const MemoizedFilterCell = (0, react_1.memo)(({ header, filterValue, draggedId, layoutMode, totalSize, columnMeta }) => {
|
|
252
|
+
const meta = (columnMeta ?? header.column.columnDef.meta);
|
|
253
|
+
const colId = String(header.column.id || header.column.columnDef?.accessorKey || '');
|
|
254
|
+
const inferredDateFromId = /^(created|updated|date|time|dob|birth)/i.test(colId);
|
|
255
|
+
const filterType = meta?.filterType || (inferredDateFromId ? 'date' : 'text');
|
|
256
|
+
const filterOptions = meta?.filterOptions || [];
|
|
257
|
+
// State for all types
|
|
258
|
+
const [showPopover, setShowPopover] = (0, react_1.useState)(false);
|
|
259
|
+
const [dropdownPosition, setDropdownPosition] = (0, react_1.useState)(null);
|
|
260
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
261
|
+
const operandSelectorRef = (0, react_1.useRef)(null);
|
|
262
|
+
const operandDropdownRef = (0, react_1.useRef)(null);
|
|
263
|
+
const textInputRef = (0, react_1.useRef)(null);
|
|
264
|
+
const flatpickrInstanceRef = (0, react_1.useRef)(null);
|
|
265
|
+
const isNumber = meta?.dataType === 'number' || meta?.dataType === 'decimal' || meta?.dataType === 'currency' || filterType === 'number';
|
|
266
|
+
const isDate = ['date', 'datetime', 'time'].includes(meta?.dataType || '') || ['date', 'datetime', 'time'].includes(filterType || '') || inferredDateFromId;
|
|
267
|
+
const operands = (isNumber || isDate) ? NUMBER_OPERANDS : STRING_OPERANDS;
|
|
268
|
+
// Stable options for Flatpickr to prevent re-init on re-render
|
|
269
|
+
const flatpickrOptions = (0, react_1.useMemo)(() => ({
|
|
270
|
+
enableTime: true,
|
|
271
|
+
dateFormat: "d/m/Y h:i K",
|
|
272
|
+
time_24hr: false,
|
|
273
|
+
closeOnSelect: false,
|
|
274
|
+
allowInput: true,
|
|
275
|
+
clickOpens: true,
|
|
276
|
+
position: 'auto',
|
|
277
|
+
static: false,
|
|
278
|
+
monthSelectorType: 'static',
|
|
279
|
+
onReady: (_d, _str, instance) => {
|
|
280
|
+
if (instance)
|
|
281
|
+
flatpickrInstanceRef.current = instance;
|
|
282
|
+
if (instance?.calendarContainer) {
|
|
283
|
+
instance.calendarContainer.addEventListener('mousedown', (e) => e.stopPropagation());
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}), []);
|
|
287
|
+
// Raw value from table state
|
|
288
|
+
const rawValue = filterValue;
|
|
289
|
+
// Derived external value based on type
|
|
290
|
+
const getSafeValue = () => {
|
|
291
|
+
if (['multiselect', 'checkbox'].includes(filterType)) {
|
|
292
|
+
return Array.isArray(rawValue) ? rawValue : [];
|
|
293
|
+
}
|
|
294
|
+
if (filterType === 'boolean') {
|
|
295
|
+
return rawValue; // boolean | undefined
|
|
296
|
+
}
|
|
297
|
+
// Text/Number: { value, operand }
|
|
298
|
+
if (typeof rawValue === 'object' && rawValue !== null && 'value' in rawValue) {
|
|
299
|
+
return rawValue;
|
|
300
|
+
}
|
|
301
|
+
return { value: rawValue || '', operand: (isNumber || isDate) ? (isDate ? 'equals' : 'equals') : 'contains' };
|
|
302
|
+
};
|
|
303
|
+
const extValue = getSafeValue();
|
|
304
|
+
// Local state for persistence (Text/Number uses object, others use direct value)
|
|
305
|
+
// We initialize from extValue.
|
|
306
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(extValue);
|
|
307
|
+
// SYNC LOGIC: Always sync to support external clear
|
|
308
|
+
(0, react_1.useEffect)(() => {
|
|
309
|
+
setLocalValue(getSafeValue());
|
|
310
|
+
}, [rawValue]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
311
|
+
// Compute dropdown position when opening (useLayoutEffect so portal has position in same frame - dropdown opens reliably)
|
|
312
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
313
|
+
if (showPopover && operandSelectorRef.current) {
|
|
314
|
+
const rect = operandSelectorRef.current.getBoundingClientRect();
|
|
315
|
+
setDropdownPosition({ left: rect.left, top: rect.bottom + 4 });
|
|
316
|
+
}
|
|
317
|
+
else if (!showPopover) {
|
|
318
|
+
setDropdownPosition(null);
|
|
319
|
+
}
|
|
320
|
+
}, [showPopover]);
|
|
321
|
+
// Close popover on outside click (ignore clicks inside filter wrapper and portaled operand dropdown). Use capture + slight delay so same mousedown that opened doesn't close.
|
|
322
|
+
(0, react_1.useEffect)(() => {
|
|
323
|
+
if (!showPopover)
|
|
324
|
+
return;
|
|
325
|
+
const hide = (e) => {
|
|
326
|
+
const target = e.target;
|
|
327
|
+
const inContainer = containerRef.current?.contains(target);
|
|
328
|
+
const inDropdown = operandDropdownRef.current?.contains(target);
|
|
329
|
+
if (!inContainer && !inDropdown)
|
|
330
|
+
setShowPopover(false);
|
|
331
|
+
};
|
|
332
|
+
const t = setTimeout(() => document.addEventListener('mousedown', hide), 0);
|
|
333
|
+
return () => { clearTimeout(t); document.removeEventListener('mousedown', hide); };
|
|
334
|
+
}, [showPopover]);
|
|
335
|
+
// Handlers
|
|
336
|
+
const handleClear = (e) => {
|
|
337
|
+
e?.stopPropagation();
|
|
338
|
+
if (['multiselect', 'checkbox'].includes(filterType)) {
|
|
339
|
+
setLocalValue([]);
|
|
340
|
+
header.column.setFilterValue(undefined);
|
|
341
|
+
}
|
|
342
|
+
else if (filterType === 'boolean') {
|
|
343
|
+
setLocalValue(undefined); // or null
|
|
344
|
+
header.column.setFilterValue(undefined);
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
// Text/Number
|
|
348
|
+
const resetVal = { ...localValue, value: '' };
|
|
349
|
+
setLocalValue(resetVal);
|
|
350
|
+
header.column.setFilterValue(undefined);
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
const updateTextNumber = (val) => {
|
|
354
|
+
const next = { ...localValue, value: val };
|
|
355
|
+
setLocalValue(next);
|
|
356
|
+
if (!val) {
|
|
357
|
+
// We don't clear local operand, just value
|
|
358
|
+
header.column.setFilterValue(undefined);
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
header.column.setFilterValue(next);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
const updateOperand = (op) => {
|
|
365
|
+
const next = { ...localValue, operand: op };
|
|
366
|
+
setLocalValue(next);
|
|
367
|
+
if (next.value)
|
|
368
|
+
header.column.setFilterValue(next);
|
|
369
|
+
};
|
|
370
|
+
// Render Helpers
|
|
371
|
+
const renderTextNumber = () => {
|
|
372
|
+
const currentOp = operands.find(o => o.value === localValue.operand);
|
|
373
|
+
const operandDropdownContent = showPopover && dropdownPosition && ((0, jsx_runtime_1.jsx)("div", { ref: operandDropdownRef, role: "listbox", className: "operand-dropdown operand-dropdown-portal", style: {
|
|
374
|
+
position: 'fixed',
|
|
375
|
+
left: dropdownPosition.left,
|
|
376
|
+
top: dropdownPosition.top,
|
|
377
|
+
zIndex: 10002,
|
|
378
|
+
}, children: operands.map(op => ((0, jsx_runtime_1.jsxs)("div", { role: "option", className: `operand-item ${localValue.operand === op.value ? 'active' : ''}`, onMouseDown: (e) => { e.preventDefault(); e.stopPropagation(); updateOperand(op.value); setShowPopover(false); }, children: [(0, jsx_runtime_1.jsx)("span", { className: "op-symbol", children: op.symbol }), (0, jsx_runtime_1.jsx)("span", { className: "op-label", children: op.label })] }, op.value))) }));
|
|
379
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "slick-premium-filter-container slick-premium-filter-container-operand-visible", children: [(0, jsx_runtime_1.jsxs)("div", { ref: operandSelectorRef, role: "button", tabIndex: 0, "aria-haspopup": "listbox", "aria-expanded": showPopover, className: "slick-filter-prefix operand-selector", onMouseDown: (e) => {
|
|
380
|
+
e.preventDefault();
|
|
381
|
+
e.stopPropagation();
|
|
382
|
+
setShowPopover(prev => !prev);
|
|
383
|
+
}, onClick: (e) => e.stopPropagation(), children: [currentOp?.symbol ? ((0, jsx_runtime_1.jsx)("span", { className: "prefix-operand-symbol", children: currentOp.symbol })) : (0, jsx_runtime_1.jsx)("span", { className: "prefix-operand-placeholder" }), (0, jsx_runtime_1.jsx)("span", { className: "operand-selector-chevron", "aria-hidden": true, children: (0, jsx_runtime_1.jsx)("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: (0, jsx_runtime_1.jsx)("path", { d: "M6 9l6 6 6-6" }) }) })] }), typeof document !== 'undefined' && operandDropdownContent && (0, react_dom_1.createPortal)(operandDropdownContent, document.body), (0, jsx_runtime_1.jsxs)("div", { className: "slick-filter-search-area", onClick: (e) => {
|
|
384
|
+
if (e.target !== e.currentTarget)
|
|
385
|
+
return;
|
|
386
|
+
if (isDate)
|
|
387
|
+
flatpickrInstanceRef.current?.open();
|
|
388
|
+
else
|
|
389
|
+
textInputRef.current?.focus();
|
|
390
|
+
}, children: [isDate ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [!localValue.value && (0, jsx_runtime_1.jsx)(FilterCalendarIcon, {}), (0, jsx_runtime_1.jsx)(react_flatpickr_1.default, { className: "slick-premium-filter-input", value: localValue.value || '', onChange: ([date]) => {
|
|
391
|
+
if (date) {
|
|
392
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
393
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
394
|
+
const year = date.getFullYear();
|
|
395
|
+
let hours = date.getHours();
|
|
396
|
+
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
397
|
+
const ampm = hours >= 12 ? 'PM' : 'AM';
|
|
398
|
+
hours = hours % 12;
|
|
399
|
+
hours = hours ? hours : 12;
|
|
400
|
+
const strHours = String(hours).padStart(2, '0');
|
|
401
|
+
const formatted = `${day}/${month}/${year} ${strHours}:${minutes} ${ampm}`;
|
|
402
|
+
updateTextNumber(formatted);
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
updateTextNumber('');
|
|
406
|
+
}
|
|
407
|
+
}, options: flatpickrOptions }, header.id + "_flatpickr")] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("input", { ref: textInputRef, className: "slick-premium-filter-input", value: localValue.value || '', onChange: e => updateTextNumber(e.target.value), placeholder: FILTER_PLACEHOLDER }), localValue.value && ((0, jsx_runtime_1.jsx)("div", { className: "filter-clear-btn", onClick: handleClear, title: "Clear filter", children: (0, jsx_runtime_1.jsxs)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", children: [(0, jsx_runtime_1.jsx)("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), (0, jsx_runtime_1.jsx)("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) }))] })), localValue.value && isDate && ((0, jsx_runtime_1.jsx)("div", { className: "filter-clear-btn", onClick: handleClear, children: (0, jsx_runtime_1.jsxs)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", children: [(0, jsx_runtime_1.jsx)("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), (0, jsx_runtime_1.jsx)("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) }))] }), (0, jsx_runtime_1.jsx)("style", { children: `
|
|
408
|
+
.slick-premium-filter-container .slick-filter-prefix.operand-selector,
|
|
409
|
+
.slick-premium-filter-container .slick-filter-prefix.search-selector { width: 36px; min-width: 36px; justify-content: center; background: #f1f5f9; border-right: 1px solid #e2e8f0; display: flex; align-items: center; border-radius: 6px 0 0 6px; }
|
|
410
|
+
.slick-premium-filter-container .operand-selector { width: 42px; min-width: 42px; }
|
|
411
|
+
.operand-selector-chevron { display: flex; align-items: center; margin-left: 1px; color: #64748b; flex-shrink: 0; }
|
|
412
|
+
.operand-selector:hover .operand-selector-chevron { color: #3b82f6; }
|
|
413
|
+
.slick-filter-dropdown-btn { flex: 1; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; overflow: hidden; }
|
|
414
|
+
.dropdown-text-container { flex: 1; overflow: hidden; display: flex; align-items: center; }
|
|
415
|
+
.dropdown-text { font-size: 12.5px; color: #334155; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
|
|
416
|
+
.slick-premium-filter-input { padding-right: 24px !important; }
|
|
417
|
+
.slick-premium-filter-input::placeholder { color: #94a3b8; opacity: 0.9; }
|
|
418
|
+
.filter-date-placeholder-icon { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: #94a3b8 !important; pointer-events: none; display: flex; align-items: center; z-index: 1; }
|
|
419
|
+
.filter-date-placeholder-icon svg { color: #94a3b8 !important; stroke: #94a3b8 !important; }
|
|
420
|
+
.slick-filter-search-area { position: relative; }
|
|
421
|
+
.flatpickr-input { width: 100%; min-width: 0; background: transparent; border: none; font-size: 12px; height: 100%; outline: none; color: #334155; font-weight: 500; font-family: inherit; overflow: hidden; text-overflow: ellipsis; padding-left: 28px !important; box-sizing: border-box; }
|
|
422
|
+
.flatpickr-wrapper { width: 100%; }
|
|
423
|
+
.filter-clear-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); color: #94a3b8; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 10; width: 16px; height: 16px; border-radius: 50%; transition: all 0.2s; background: rgba(255,255,255,0.8); }
|
|
424
|
+
.filter-clear-btn:hover { color: #ef4444; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
|
|
425
|
+
|
|
426
|
+
/* Flatpickr Overrides - Plain white/blue theme; hide dropdown arrow so only grey calendar placeholder shows in filter */
|
|
427
|
+
.flatpickr-calendar.arrowBottom:before,
|
|
428
|
+
.flatpickr-calendar.arrowBottom:after,
|
|
429
|
+
.flatpickr-calendar.arrowTop:before,
|
|
430
|
+
.flatpickr-calendar.arrowTop:after { display: none !important; }
|
|
431
|
+
.flatpickr-calendar { z-index: 10001 !important; box-shadow: 0 10px 40px rgba(0,0,0,0.2) !important; border: 1px solid #e2e8f0 !important; border-radius: 12px !important; font-family: 'Inter', sans-serif !important; }
|
|
432
|
+
.flatpickr-months { background: #fff !important; border-radius: 12px 12px 0 0 !important; }
|
|
433
|
+
.flatpickr-month { background: #fff !important; color: #334155 !important; }
|
|
434
|
+
.flatpickr-current-month { color: #334155 !important; }
|
|
435
|
+
.flatpickr-current-month .flatpickr-monthDropdown-months { background: #fff !important; color: #334155 !important; }
|
|
436
|
+
.flatpickr-weekdays { background: #fff !important; }
|
|
437
|
+
span.flatpickr-weekday { background: #fff !important; color: #64748b !important; font-weight: 600; }
|
|
438
|
+
.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange, .flatpickr-day.selected.inRange, .flatpickr-day.startRange.inRange, .flatpickr-day.endRange.inRange, .flatpickr-day.selected:focus, .flatpickr-day.startRange:focus, .flatpickr-day.endRange:focus, .flatpickr-day.selected:hover, .flatpickr-day.startRange:hover, .flatpickr-day.endRange:hover, .flatpickr-day.selected.prevMonthDay, .flatpickr-day.startRange.prevMonthDay, .flatpickr-day.endRange.prevMonthDay, .flatpickr-day.selected.nextMonthDay, .flatpickr-day.startRange.nextMonthDay, .flatpickr-day.endRange.nextMonthDay {
|
|
439
|
+
background: #3b82f6 !important;
|
|
440
|
+
border-color: #3b82f6 !important;
|
|
441
|
+
color: #fff !important;
|
|
442
|
+
}
|
|
443
|
+
.flatpickr-day:hover { background: #eff6ff !important; border-color: #eff6ff !important; color: #1e40af !important; }
|
|
444
|
+
.flatpickr-day.today { border-color: #3b82f6 !important; }
|
|
445
|
+
.flatpickr-day.today:hover { background: #eff6ff !important; }
|
|
446
|
+
.numInputWrapper:hover { background: #f8fafc !important; }
|
|
447
|
+
.flatpickr-time input:hover, .flatpickr-time .flatpickr-am-pm:hover, .flatpickr-time input:focus, .flatpickr-time .flatpickr-am-pm:focus { background: #f1f5f9 !important; }
|
|
448
|
+
.flatpickr-prev-month svg, .flatpickr-next-month svg { fill: #64748b !important; }
|
|
449
|
+
.flatpickr-prev-month:hover svg, .flatpickr-next-month:hover svg { fill: #3b82f6 !important; }
|
|
450
|
+
` })] }));
|
|
451
|
+
};
|
|
452
|
+
const renderCheckboxList = (isBoolean = false) => {
|
|
453
|
+
let options = filterOptions;
|
|
454
|
+
if (isBoolean) {
|
|
455
|
+
options = [{ label: 'True', value: true }, { label: 'False', value: false }];
|
|
456
|
+
if (filterOptions.length > 0)
|
|
457
|
+
options = filterOptions;
|
|
458
|
+
}
|
|
459
|
+
const selected = Array.isArray(localValue) ? localValue : [];
|
|
460
|
+
const count = selected.length;
|
|
461
|
+
const totalOpts = options.length;
|
|
462
|
+
// Display Text
|
|
463
|
+
const selectedLabels = options
|
|
464
|
+
.filter((o) => selected.includes(o.value))
|
|
465
|
+
.map((o) => o.label);
|
|
466
|
+
const displayText = selectedLabels.join(', ');
|
|
467
|
+
// Toggle Item
|
|
468
|
+
const toggleItem = (val) => {
|
|
469
|
+
const current = Array.isArray(localValue) ? localValue : [];
|
|
470
|
+
const exists = current.includes(val);
|
|
471
|
+
const next = exists ? current.filter(v => v !== val) : [...current, val];
|
|
472
|
+
setLocalValue(next);
|
|
473
|
+
header.column.setFilterValue(next.length ? next : undefined);
|
|
474
|
+
};
|
|
475
|
+
// Select All
|
|
476
|
+
const toggleAll = () => {
|
|
477
|
+
const current = Array.isArray(localValue) ? localValue : [];
|
|
478
|
+
if (current.length === totalOpts) {
|
|
479
|
+
setLocalValue([]);
|
|
480
|
+
header.column.setFilterValue(undefined);
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
const all = options.map((o) => o.value);
|
|
484
|
+
setLocalValue(all);
|
|
485
|
+
header.column.setFilterValue(all);
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `slick-premium-filter-container dropdown-trigger ${count > 0 ? 'has-selection' : ''}`, onClick: () => setShowPopover(!showPopover), children: [(0, jsx_runtime_1.jsx)("div", { className: "slick-filter-prefix search-selector", role: "button", tabIndex: 0, title: "Click to select value(s)", onClick: (e) => { e.stopPropagation(); setShowPopover(true); }, onKeyDown: (e) => { if (e.key === 'Enter' || e.key === ' ') {
|
|
489
|
+
e.preventDefault();
|
|
490
|
+
setShowPopover(true);
|
|
491
|
+
} }, children: (0, jsx_runtime_1.jsx)("span", { className: "filter-placeholder-char", "aria-hidden": true, children: FILTER_PLACEHOLDER }) }), (0, jsx_runtime_1.jsxs)("div", { className: "slick-filter-dropdown-btn", children: [(0, jsx_runtime_1.jsx)("div", { className: "dropdown-text-container", children: (0, jsx_runtime_1.jsx)("span", { className: "dropdown-text", title: displayText, children: displayText }) }), (0, jsx_runtime_1.jsx)("div", { className: "dropdown-icons", children: (0, jsx_runtime_1.jsx)("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: (0, jsx_runtime_1.jsx)("path", { d: "M6 9l6 6 6-6" }) }) })] }), showPopover && ((0, jsx_runtime_1.jsxs)("div", { className: "operand-dropdown check-list", children: [(0, jsx_runtime_1.jsxs)("div", { className: "operand-item select-all", onClick: (e) => { e.stopPropagation(); toggleAll(); }, children: [(0, jsx_runtime_1.jsx)("div", { className: `checkbox-box ${count === totalOpts ? 'checked' : ''}`, children: count === totalOpts && (0, jsx_runtime_1.jsx)("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", children: (0, jsx_runtime_1.jsx)("polyline", { points: "20 6 9 17 4 12" }) }) }), (0, jsx_runtime_1.jsx)("span", { className: "op-label", children: "Select All" })] }), (0, jsx_runtime_1.jsx)("div", { className: "list-scroll-area", children: options.map((opt) => {
|
|
492
|
+
const isSel = selected.includes(opt.value);
|
|
493
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `operand-item ${isSel ? 'active' : ''}`, onClick: (e) => { e.stopPropagation(); toggleItem(opt.value); }, children: [(0, jsx_runtime_1.jsx)("div", { className: `checkbox-box ${isSel ? 'checked' : ''}`, children: isSel && (0, jsx_runtime_1.jsx)("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", children: (0, jsx_runtime_1.jsx)("polyline", { points: "20 6 9 17 4 12" }) }) }), (0, jsx_runtime_1.jsx)("span", { className: "op-label", children: opt.label })] }, String(opt.value)));
|
|
494
|
+
}) }), (0, jsx_runtime_1.jsx)("div", { className: "filter-popup-footer", children: (0, jsx_runtime_1.jsx)("button", { className: "filter-ok-btn", onClick: (e) => { e.stopPropagation(); setShowPopover(false); }, children: "Ok" }) })] }))] }));
|
|
495
|
+
};
|
|
496
|
+
const widthStyle = (layoutMode === 'fit-window' && totalSize > 0)
|
|
497
|
+
? `${(header.getSize() / totalSize) * 100}%`
|
|
498
|
+
: header.getSize();
|
|
499
|
+
// Show filter for every column except Actions (by id or meta.actions)
|
|
500
|
+
const isActionColumn = header.column.id === 'actions' || !!(meta?.actions);
|
|
501
|
+
const canFilter = !isActionColumn;
|
|
502
|
+
return ((0, jsx_runtime_1.jsx)("td", { className: `slick-filter-td ${draggedId === header.column.id ? 'dragging' : ''}`, style: {
|
|
503
|
+
width: widthStyle,
|
|
504
|
+
minWidth: 0,
|
|
505
|
+
maxWidth: widthStyle,
|
|
506
|
+
position: 'sticky',
|
|
507
|
+
top: 32, // Height of the header row (min-height 36px + 8px top + 8px bottom padding)
|
|
508
|
+
zIndex: 33,
|
|
509
|
+
background: canFilter ? '#f8fafc' : 'transparent',
|
|
510
|
+
padding: canFilter ? '6px 12px' : '0',
|
|
511
|
+
borderRight: canFilter ? '1px solid #f1f5f9' : 'none',
|
|
512
|
+
borderBottom: '1px solid #e2e8f0',
|
|
513
|
+
cursor: 'default',
|
|
514
|
+
overflow: 'visible'
|
|
515
|
+
}, children: canFilter && ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, className: "filter-wrapper", style: { width: '100%', minWidth: 0, maxWidth: '100%', overflow: 'visible', boxSizing: 'border-box' }, children: [(filterType === 'text' || filterType === 'number' || filterType === 'date' || filterType === 'datetime' || filterType === 'time' || isDate) && renderTextNumber(), ['multiselect', 'checkbox'].includes(filterType) && renderCheckboxList(false), ['dropdown', 'select', 'radio', 'boolean'].includes(filterType) && renderCheckboxList(filterType === 'boolean'), !(filterType === 'text' || filterType === 'number' || filterType === 'date' || filterType === 'datetime' || filterType === 'time' || isDate) && !['multiselect', 'checkbox', 'dropdown', 'select', 'radio', 'boolean'].includes(filterType) && renderTextNumber()] })) }, `filter-${header.id}`));
|
|
516
|
+
}, (prevProps, nextProps) => {
|
|
517
|
+
// Re-render when header, filterValue, or columnMeta changes
|
|
518
|
+
if (prevProps.header !== nextProps.header || prevProps.filterValue !== nextProps.filterValue || prevProps.columnMeta !== nextProps.columnMeta)
|
|
519
|
+
return false;
|
|
520
|
+
return (prevProps.draggedId === nextProps.draggedId &&
|
|
521
|
+
prevProps.layoutMode === nextProps.layoutMode &&
|
|
522
|
+
prevProps.totalSize === nextProps.totalSize);
|
|
523
|
+
});
|
|
524
|
+
// --- OPTIMIZATION: Memoized Data Row ---
|
|
525
|
+
const MemoizedRow = (0, react_1.memo)(({ row, visibleCount, onRowClick, onActionClick, setContextMenu, getGroupingLabel, layoutMode, totalSize, columnMetaById }) => {
|
|
526
|
+
if (row.getIsGrouped()) {
|
|
527
|
+
const colId = row.groupingColumnId ?? '';
|
|
528
|
+
const colLabel = getGroupingLabel(colId);
|
|
529
|
+
const value = String(row.groupingValue);
|
|
530
|
+
return ((0, jsx_runtime_1.jsx)("tr", { className: "slick-group-row", children: (0, jsx_runtime_1.jsx)("td", { colSpan: visibleCount, children: (0, jsx_runtime_1.jsxs)("div", { className: `slick-group-header-row ${row.getIsExpanded() ? 'expanded' : ''}`, onClick: row.getToggleExpandedHandler(), style: { paddingLeft: `${row.depth * 20 + 16}px` }, children: [(0, jsx_runtime_1.jsx)("span", { className: "slick-group-chevron", children: (0, jsx_runtime_1.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", children: (0, jsx_runtime_1.jsx)("polyline", { points: "9 18 15 12 9 6" }) }) }), (0, jsx_runtime_1.jsxs)("span", { className: "slick-group-title", children: [(0, jsx_runtime_1.jsxs)("strong", { className: "group-col-label", children: [colLabel, ":"] }), " ", value === 'undefined' || value === 'null' ? 'NULL' : value] }), (0, jsx_runtime_1.jsxs)("span", { className: "slick-group-count", children: ["(", row.subRows.length, " items)"] })] }) }) }));
|
|
531
|
+
}
|
|
532
|
+
// Use table order: getVisibleCells() respects state.columnOrder and matches getHeaderGroups() order.
|
|
533
|
+
const cells = row.getVisibleCells();
|
|
534
|
+
return ((0, jsx_runtime_1.jsx)("tr", { className: "slick-data-row", onClick: () => onRowClick && onRowClick(row.original), style: { cursor: onRowClick ? 'pointer' : 'default' }, children: cells.map(cell => ((0, jsx_runtime_1.jsx)(MemoizedCell, { cell: cell, onActionClick: onActionClick, setContextMenu: setContextMenu, layoutMode: layoutMode, totalSize: totalSize, columnMetaById: columnMetaById }, cell.id))) }));
|
|
535
|
+
}, (prevProps, nextProps) => {
|
|
536
|
+
// Re-render when row or columnOrder changes (important for column reordering)
|
|
537
|
+
// columnOrder is accessed from props object, not destructured in component body
|
|
538
|
+
if (prevProps.row !== nextProps.row || prevProps.columnOrder !== nextProps.columnOrder)
|
|
539
|
+
return false;
|
|
540
|
+
return (prevProps.visibleCount === nextProps.visibleCount &&
|
|
541
|
+
prevProps.layoutMode === nextProps.layoutMode &&
|
|
542
|
+
prevProps.totalSize === nextProps.totalSize &&
|
|
543
|
+
prevProps.onRowClick === nextProps.onRowClick &&
|
|
544
|
+
prevProps.onActionClick === nextProps.onActionClick &&
|
|
545
|
+
prevProps.setContextMenu === nextProps.setContextMenu &&
|
|
546
|
+
prevProps.getGroupingLabel === nextProps.getGroupingLabel &&
|
|
547
|
+
prevProps.columnMetaById === nextProps.columnMetaById);
|
|
548
|
+
});
|
|
549
|
+
// Data types that should be right-aligned (numbers, dates); all others (text, textarea, email, etc.) left-aligned
|
|
550
|
+
const RIGHT_ALIGN_DATA_TYPES = ['number', 'decimal', 'currency', 'date', 'datetime', 'time', 'percentage'];
|
|
551
|
+
/** Infer dataType from column id/accessorKey when meta.dataType is not set (so alignment works without column meta) */
|
|
552
|
+
function inferDataTypeFromColumn(column) {
|
|
553
|
+
const def = column.columnDef;
|
|
554
|
+
const key = String(column.id || def?.accessorKey || '').toLowerCase();
|
|
555
|
+
if (!key)
|
|
556
|
+
return 'text';
|
|
557
|
+
if (key === 'id' || key === 'ids')
|
|
558
|
+
return 'number';
|
|
559
|
+
if (key === 'email')
|
|
560
|
+
return 'email';
|
|
561
|
+
const numericKeys = ['salary', 'amount', 'price', 'quantity', 'count', 'total', 'rate', 'number', 'num', 'qty', 'revenue', 'cost', 'balance'];
|
|
562
|
+
if (numericKeys.some(n => key.includes(n) || key === n))
|
|
563
|
+
return 'number';
|
|
564
|
+
const dateOnlyKeys = ['date', 'founded', 'dob', 'birth'];
|
|
565
|
+
if (dateOnlyKeys.some(d => key.includes(d) || key === d))
|
|
566
|
+
return 'date';
|
|
567
|
+
const dateTimeKeys = ['created', 'updated', 'time', 'open', 'close', 'willopen', 'willclose'];
|
|
568
|
+
if (dateTimeKeys.some(d => key.includes(d) || key === d))
|
|
569
|
+
return 'datetime';
|
|
570
|
+
return 'text';
|
|
571
|
+
}
|
|
572
|
+
// --- OPTIMIZATION: Memoized Cell Rendering ---
|
|
573
|
+
const MemoizedCell = (0, react_1.memo)(({ cell, onActionClick, setContextMenu, layoutMode, totalSize, columnMetaById }) => {
|
|
574
|
+
const widthStyle = (layoutMode === 'fit-window' && totalSize > 0)
|
|
575
|
+
? `${(cell.column.getSize() / totalSize) * 100}%`
|
|
576
|
+
: cell.column.getSize();
|
|
577
|
+
const colId = cell.column.id;
|
|
578
|
+
const accessorKey = cell.column.columnDef?.accessorKey;
|
|
579
|
+
const originalMeta = columnMetaById?.[colId] ?? (accessorKey ? columnMetaById?.[accessorKey] : undefined);
|
|
580
|
+
const meta = (originalMeta ?? cell.column.columnDef.meta);
|
|
581
|
+
const dataType = meta?.dataType ?? inferDataTypeFromColumn(cell.column);
|
|
582
|
+
const rawValue = cell.getValue();
|
|
583
|
+
const inferredDataType = inferDataTypeFromColumn(cell.column);
|
|
584
|
+
const isDateColumn = dataType === 'date' || dataType === 'datetime' || dataType === 'time';
|
|
585
|
+
const isInferredDateColumn = inferredDataType === 'date' || inferredDataType === 'datetime' || inferredDataType === 'time';
|
|
586
|
+
const valueLooksLikeIso = (0, tableFormatters_1.isIsoDateLike)(rawValue);
|
|
587
|
+
const dateMode = isDateColumn
|
|
588
|
+
? dataType
|
|
589
|
+
: valueLooksLikeIso && isInferredDateColumn
|
|
590
|
+
? inferredDataType
|
|
591
|
+
: null;
|
|
592
|
+
const dateFormatOpts = meta?.formatOptions ? { dateFormat: meta.formatOptions.dateFormat, datetimeFormat: meta.formatOptions.datetimeFormat, timeFormat: meta.formatOptions.timeFormat } : undefined;
|
|
593
|
+
const cellTitle = dateMode ? ((0, tableFormatters_1.formatDateValue)(rawValue, dateMode, dateFormatOpts) ?? String(rawValue ?? '')) : String(rawValue ?? '');
|
|
594
|
+
const formatterMeta = originalMeta ?? cell.column.columnDef.meta;
|
|
595
|
+
const useDateCell = dateMode !== null;
|
|
596
|
+
const textAlign = (RIGHT_ALIGN_DATA_TYPES.includes(dataType) || useDateCell) ? 'right' : 'left';
|
|
597
|
+
return ((0, jsx_runtime_1.jsx)("td", { onContextMenu: (e) => {
|
|
598
|
+
e.preventDefault();
|
|
599
|
+
setContextMenu({
|
|
600
|
+
x: e.clientX,
|
|
601
|
+
y: e.clientY,
|
|
602
|
+
content: String(cell.getValue() ?? ''),
|
|
603
|
+
colId: cell.column.id,
|
|
604
|
+
isGroupable: !!cell.column.columnDef.enableGrouping
|
|
605
|
+
});
|
|
606
|
+
}, style: {
|
|
607
|
+
width: widthStyle,
|
|
608
|
+
textAlign,
|
|
609
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: "slick-cell-content", title: cellTitle, style: { textAlign }, children: cell.column.columnDef.cell
|
|
610
|
+
? (0, react_table_1.flexRender)(cell.column.columnDef.cell, cell.getContext())
|
|
611
|
+
: (formatterMeta?.actions ?? cell.column.columnDef.meta?.actions)
|
|
612
|
+
? (0, tableFormatters_1.ActionFormatter)(cell.getContext(), onActionClick)
|
|
613
|
+
: useDateCell
|
|
614
|
+
? (0, tableFormatters_1.renderDateCell)(rawValue, dateMode, dateFormatOpts)
|
|
615
|
+
: (0, tableFormatters_1.DataFormatter)(cell.getContext(), formatterMeta) }) }));
|
|
616
|
+
});
|
|
617
|
+
function SabReactTable({ data, columns, title = 'Table_List', onSortedDataChange, defaultPageSize = 50, pageSizeOptions = [10, 20, 50, 100, 500, 1000], groupingLabels = {}, onRowClick, onActionClick, initialLayoutMode = 'fit-content' }) {
|
|
618
|
+
// UI States
|
|
619
|
+
const [sorting, setSorting] = (0, react_1.useState)([]);
|
|
620
|
+
const [columnSizing, setColumnSizing] = (0, react_1.useState)({});
|
|
621
|
+
const [grouping, setGrouping] = (0, react_1.useState)([]);
|
|
622
|
+
const [expanded, setExpanded] = (0, react_1.useState)({});
|
|
623
|
+
const [pagination, setPagination] = (0, react_1.useState)({ pageIndex: 0, pageSize: defaultPageSize });
|
|
624
|
+
const [columnFilters, setColumnFilters] = (0, react_1.useState)([]);
|
|
625
|
+
const [columnVisibility, setColumnVisibility] = (0, react_1.useState)(() => {
|
|
626
|
+
const initialMap = {};
|
|
627
|
+
columns.forEach(col => {
|
|
628
|
+
const id = (col.id || col.accessorKey);
|
|
629
|
+
if (id && col.meta?.initialHidden) {
|
|
630
|
+
initialMap[id] = false;
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
return initialMap;
|
|
634
|
+
});
|
|
635
|
+
// Initialize with column ids so header + filter + row cells all use same order from first render
|
|
636
|
+
const [columnOrder, setColumnOrder] = (0, react_1.useState)(() => columns.map(c => (c.id || c.accessorKey)).filter(Boolean));
|
|
637
|
+
// Sync column order when column set changes (add/remove) but preserve user reorder
|
|
638
|
+
(0, react_1.useEffect)(() => {
|
|
639
|
+
const currentIds = columns.map(c => (c.id || c.accessorKey)).filter(Boolean);
|
|
640
|
+
setColumnOrder(prev => {
|
|
641
|
+
const prevSet = new Set(prev);
|
|
642
|
+
if (prev.length !== currentIds.length || !currentIds.every(id => prevSet.has(id)))
|
|
643
|
+
return currentIds;
|
|
644
|
+
return prev;
|
|
645
|
+
});
|
|
646
|
+
}, [columns]);
|
|
647
|
+
const [layoutMode, setLayoutMode] = (0, react_1.useState)(initialLayoutMode);
|
|
648
|
+
// UI Feedback States
|
|
649
|
+
const [showCommands, setShowCommands] = (0, react_1.useState)(false);
|
|
650
|
+
const [commandMenuPos, setCommandMenuPos] = (0, react_1.useState)(null);
|
|
651
|
+
const [showFilters, setShowFilters] = (0, react_1.useState)(false);
|
|
652
|
+
const [showPaginationState] = (0, react_1.useState)(true);
|
|
653
|
+
const [showGroupingZone, setShowGroupingZone] = (0, react_1.useState)(false);
|
|
654
|
+
const [contextMenu, setContextMenu] = (0, react_1.useState)(null);
|
|
655
|
+
const [expandedSections, setExpandedSections] = (0, react_1.useState)({
|
|
656
|
+
quickActions: false, layoutMode: false, dataOptions: false, columns: false, groupingOptions: false, dataExport: false
|
|
657
|
+
});
|
|
658
|
+
const menuRef = (0, react_1.useRef)(null);
|
|
659
|
+
const triggerRef = (0, react_1.useRef)(null);
|
|
660
|
+
const contextMenuRef = (0, react_1.useRef)(null);
|
|
661
|
+
const tableContainerRef = (0, react_1.useRef)(null);
|
|
662
|
+
const tableRef = (0, react_1.useRef)(null);
|
|
663
|
+
const [containerWidth, setContainerWidth] = (0, react_1.useState)(0);
|
|
664
|
+
const table = (0, react_table_1.useReactTable)({
|
|
665
|
+
data, columns,
|
|
666
|
+
state: { sorting, columnSizing, grouping, expanded, pagination, columnFilters, columnVisibility, columnOrder },
|
|
667
|
+
onSortingChange: setSorting,
|
|
668
|
+
onColumnSizingChange: setColumnSizing,
|
|
669
|
+
onGroupingChange: setGrouping,
|
|
670
|
+
onExpandedChange: setExpanded,
|
|
671
|
+
onPaginationChange: setPagination,
|
|
672
|
+
onColumnFiltersChange: setColumnFilters,
|
|
673
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
674
|
+
onColumnOrderChange: setColumnOrder,
|
|
675
|
+
getCoreRowModel: (0, react_table_1.getCoreRowModel)(),
|
|
676
|
+
getFilteredRowModel: (0, react_table_1.getFilteredRowModel)(),
|
|
677
|
+
getSortedRowModel: (0, react_table_1.getSortedRowModel)(),
|
|
678
|
+
getGroupedRowModel: (0, react_table_1.getGroupedRowModel)(),
|
|
679
|
+
getExpandedRowModel: (0, react_table_1.getExpandedRowModel)(),
|
|
680
|
+
getPaginationRowModel: (0, react_table_1.getPaginationRowModel)(),
|
|
681
|
+
filterFns: { advanced: advancedFilterFn },
|
|
682
|
+
defaultColumn: {
|
|
683
|
+
filterFn: advancedFilterFn,
|
|
684
|
+
enableGrouping: true,
|
|
685
|
+
enableColumnFilter: true,
|
|
686
|
+
size: 80,
|
|
687
|
+
minSize: 40
|
|
688
|
+
},
|
|
689
|
+
columnResizeMode: 'onChange',
|
|
690
|
+
enableColumnResizing: true,
|
|
691
|
+
enableGrouping: true,
|
|
692
|
+
enableExpanding: true,
|
|
693
|
+
enableColumnFilters: true,
|
|
694
|
+
enableMultiSort: true,
|
|
695
|
+
isMultiSortEvent: () => true,
|
|
696
|
+
autoResetPageIndex: true,
|
|
697
|
+
});
|
|
698
|
+
tableRef.current = table;
|
|
699
|
+
const { rows } = table.getRowModel();
|
|
700
|
+
const totalSize = table.getTotalSize();
|
|
701
|
+
const filteredTotalCount = table.getFilteredRowModel().rows.length;
|
|
702
|
+
const pageCount = table.getPageCount();
|
|
703
|
+
// Use table as single source of truth. Filter to visible columns only so when user hides a column, entire column (header + filter + cells) hides.
|
|
704
|
+
const headerGroups = (0, react_1.useMemo)(() => table.getHeaderGroups(), [table, columnOrder, columnVisibility]);
|
|
705
|
+
const visibleHeaderGroups = (0, react_1.useMemo)(() => headerGroups.map(hg => ({
|
|
706
|
+
...hg,
|
|
707
|
+
headers: hg.headers.filter(h => h.column.getIsVisible())
|
|
708
|
+
})), [headerGroups]);
|
|
709
|
+
const visibleCount = visibleHeaderGroups[0]?.headers.length ?? 0;
|
|
710
|
+
// Resolve grouping labels so chips and group rows show column header name (e.g. "Name", "Email") not column id (e.g. "name", "email")
|
|
711
|
+
const resolvedGroupingLabels = (0, react_1.useMemo)(() => {
|
|
712
|
+
const map = {};
|
|
713
|
+
const idStr = (x) => (x != null ? String(x) : '');
|
|
714
|
+
// 1) Build from columns prop first (original header string before any table normalization)
|
|
715
|
+
columns.forEach((col) => {
|
|
716
|
+
const id = col.id ?? col.accessorKey;
|
|
717
|
+
if (id == null)
|
|
718
|
+
return;
|
|
719
|
+
const header = col.header;
|
|
720
|
+
const label = typeof header === 'string' ? header : idStr(id);
|
|
721
|
+
map[idStr(id)] = label;
|
|
722
|
+
const acc = col.accessorKey;
|
|
723
|
+
if (acc != null && idStr(acc) !== idStr(id))
|
|
724
|
+
map[idStr(acc)] = label;
|
|
725
|
+
});
|
|
726
|
+
// 2) Fill or overwrite from table columns (e.g. generated ids, or when prop gave fallback id)
|
|
727
|
+
table.getAllLeafColumns().forEach((col) => {
|
|
728
|
+
const id = col.id;
|
|
729
|
+
const sid = idStr(id);
|
|
730
|
+
const def = col.columnDef;
|
|
731
|
+
const header = def.header;
|
|
732
|
+
const tableLabel = typeof header === 'string' ? header : idStr(id);
|
|
733
|
+
const existing = map[sid];
|
|
734
|
+
if (existing != null && existing !== sid)
|
|
735
|
+
return;
|
|
736
|
+
map[sid] = tableLabel;
|
|
737
|
+
const acc = def.accessorKey;
|
|
738
|
+
if (acc != null && idStr(acc) !== sid)
|
|
739
|
+
map[idStr(acc)] = tableLabel;
|
|
740
|
+
});
|
|
741
|
+
return { ...map, ...groupingLabels };
|
|
742
|
+
}, [table, columns, groupingLabels]);
|
|
743
|
+
const getGroupingLabel = (0, react_1.useCallback)((colId) => resolveGroupingLabel(colId, table, columns, resolvedGroupingLabels), [table, columns, resolvedGroupingLabels]);
|
|
744
|
+
// Column meta from columns prop keyed by both id and accessorKey so date/datetime/time filter is always found
|
|
745
|
+
const columnMetaById = (0, react_1.useMemo)(() => {
|
|
746
|
+
const map = {};
|
|
747
|
+
columns.forEach((col) => {
|
|
748
|
+
if (!col.meta)
|
|
749
|
+
return;
|
|
750
|
+
const id = col.id ?? col.accessorKey;
|
|
751
|
+
const accessorKey = col.accessorKey;
|
|
752
|
+
if (id)
|
|
753
|
+
map[String(id)] = col.meta;
|
|
754
|
+
if (accessorKey && String(accessorKey) !== String(id))
|
|
755
|
+
map[String(accessorKey)] = col.meta;
|
|
756
|
+
});
|
|
757
|
+
return map;
|
|
758
|
+
}, [columns]);
|
|
759
|
+
// --- Virtualization ---
|
|
760
|
+
const rowVirtualizer = (0, react_virtual_1.useVirtualizer)({
|
|
761
|
+
count: rows.length,
|
|
762
|
+
getScrollElement: () => tableContainerRef.current,
|
|
763
|
+
estimateSize: (0, react_1.useCallback)(() => 40, []),
|
|
764
|
+
overscan: 10,
|
|
765
|
+
});
|
|
766
|
+
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
767
|
+
const rowTotalHeight = rowVirtualizer.getTotalSize();
|
|
768
|
+
const paddingTop = virtualRows.length > 0 ? virtualRows[0]?.start || 0 : 0;
|
|
769
|
+
const paddingBottom = virtualRows.length > 0 ? rowTotalHeight - (virtualRows[virtualRows.length - 1]?.end || 0) : 0;
|
|
770
|
+
// --- ResizeObserver: track container width for fit-to-content (debounced for large resize) ---
|
|
771
|
+
(0, react_1.useEffect)(() => {
|
|
772
|
+
const el = tableContainerRef.current;
|
|
773
|
+
if (!el)
|
|
774
|
+
return;
|
|
775
|
+
let rafId;
|
|
776
|
+
let timeoutId;
|
|
777
|
+
const scheduleUpdate = () => {
|
|
778
|
+
if (timeoutId)
|
|
779
|
+
clearTimeout(timeoutId);
|
|
780
|
+
timeoutId = setTimeout(() => {
|
|
781
|
+
rafId = requestAnimationFrame(() => {
|
|
782
|
+
setContainerWidth(el.clientWidth);
|
|
783
|
+
});
|
|
784
|
+
}, 100);
|
|
785
|
+
};
|
|
786
|
+
const ro = new ResizeObserver(scheduleUpdate);
|
|
787
|
+
ro.observe(el);
|
|
788
|
+
setContainerWidth(el.clientWidth);
|
|
789
|
+
return () => {
|
|
790
|
+
ro.disconnect();
|
|
791
|
+
clearTimeout(timeoutId);
|
|
792
|
+
if (rafId)
|
|
793
|
+
cancelAnimationFrame(rafId);
|
|
794
|
+
};
|
|
795
|
+
}, []);
|
|
796
|
+
// --- Shared helper: build resize defs and getCellDisplayText for layout effects (avoids duplication) ---
|
|
797
|
+
const getResizeParams = (0, react_1.useCallback)((t) => {
|
|
798
|
+
const visibleColumns = t.getVisibleLeafColumns();
|
|
799
|
+
const resizeDefs = visibleColumns.map(col => ({
|
|
800
|
+
id: col.id,
|
|
801
|
+
header: typeof col.columnDef.header === 'string' ? col.columnDef.header : col.id,
|
|
802
|
+
isCheckboxOrSelector: col.id === 'cspfm_assignment_checkbox' || String(col.id).endsWith('_checkbox_selector') || col.id === 'cspfm_sno',
|
|
803
|
+
isAction: col.id === 'cspfm_multi_line_action' || !!col.columnDef.meta?.actions
|
|
804
|
+
}));
|
|
805
|
+
const rowsForResize = t.getRowModel().rows
|
|
806
|
+
.filter(r => !r.getIsGrouped())
|
|
807
|
+
.map(r => r.original);
|
|
808
|
+
const getCellDisplayText = (row, columnId) => {
|
|
809
|
+
const col = columns.find(c => (c.id || c.accessorKey) === columnId);
|
|
810
|
+
if (!col)
|
|
811
|
+
return '';
|
|
812
|
+
const key = col.accessorKey ?? col.id;
|
|
813
|
+
return String((key ? row[key] : undefined) ?? '');
|
|
814
|
+
};
|
|
815
|
+
return { resizeDefs, rowsForResize, getCellDisplayText };
|
|
816
|
+
}, [columns]);
|
|
817
|
+
// --- Fit-to-content: compute column sizes from header + cell content (current page only for performance), then distribute extra space ---
|
|
818
|
+
(0, react_1.useEffect)(() => {
|
|
819
|
+
if (layoutMode !== 'fit-content' || containerWidth <= 0)
|
|
820
|
+
return;
|
|
821
|
+
const t = tableRef.current;
|
|
822
|
+
if (!t)
|
|
823
|
+
return;
|
|
824
|
+
const { resizeDefs, rowsForResize, getCellDisplayText } = getResizeParams(t);
|
|
825
|
+
const sizing = (0, tableColumnResizeUtils_1.resizeColumnsByCellContent)({
|
|
826
|
+
containerWidth,
|
|
827
|
+
columns: resizeDefs,
|
|
828
|
+
rows: rowsForResize,
|
|
829
|
+
getCellDisplayText,
|
|
830
|
+
distributeExtraSpace: true
|
|
831
|
+
});
|
|
832
|
+
setColumnSizing(sizing);
|
|
833
|
+
}, [layoutMode, containerWidth, data, columns, grouping, getResizeParams]);
|
|
834
|
+
// --- Fit-to-default: same as Angular - with data use content-based widths (no space distribution); with no data use default column widths ---
|
|
835
|
+
(0, react_1.useEffect)(() => {
|
|
836
|
+
if (layoutMode !== 'fit-default')
|
|
837
|
+
return;
|
|
838
|
+
const t = tableRef.current;
|
|
839
|
+
if (!t)
|
|
840
|
+
return;
|
|
841
|
+
const { resizeDefs, rowsForResize, getCellDisplayText } = getResizeParams(t);
|
|
842
|
+
if (rowsForResize.length > 0) {
|
|
843
|
+
const sizing = (0, tableColumnResizeUtils_1.resizeColumnsByCellContent)({
|
|
844
|
+
containerWidth: containerWidth || 1,
|
|
845
|
+
columns: resizeDefs,
|
|
846
|
+
rows: rowsForResize,
|
|
847
|
+
getCellDisplayText,
|
|
848
|
+
distributeExtraSpace: false
|
|
849
|
+
});
|
|
850
|
+
setColumnSizing(sizing);
|
|
851
|
+
}
|
|
852
|
+
else {
|
|
853
|
+
setColumnSizing({});
|
|
854
|
+
}
|
|
855
|
+
}, [layoutMode, containerWidth, data, columns, grouping, getResizeParams]);
|
|
856
|
+
// --- Handlers ---
|
|
857
|
+
(0, react_1.useEffect)(() => {
|
|
858
|
+
if (!onSortedDataChange)
|
|
859
|
+
return;
|
|
860
|
+
const sortedRows = table.getPrePaginationRowModel().rows.filter(r => !r.getIsGrouped()).map(r => r.original);
|
|
861
|
+
onSortedDataChange(sortedRows);
|
|
862
|
+
}, [data, sorting, grouping, expanded, columnFilters, onSortedDataChange, table]);
|
|
863
|
+
(0, react_1.useEffect)(() => {
|
|
864
|
+
const handleClickOutside = (e) => {
|
|
865
|
+
if (menuRef.current && !menuRef.current.contains(e.target) && triggerRef.current && !triggerRef.current.contains(e.target))
|
|
866
|
+
setShowCommands(false);
|
|
867
|
+
if (contextMenuRef.current && !contextMenuRef.current.contains(e.target))
|
|
868
|
+
setContextMenu(null);
|
|
869
|
+
};
|
|
870
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
871
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
872
|
+
}, []);
|
|
873
|
+
const toggleCommands = (0, react_1.useCallback)((e) => {
|
|
874
|
+
e.stopPropagation();
|
|
875
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
876
|
+
const menuWidth = 310;
|
|
877
|
+
const menuHeight = 450;
|
|
878
|
+
const padding = 10;
|
|
879
|
+
let left = rect.left;
|
|
880
|
+
if (left + menuWidth > window.innerWidth) {
|
|
881
|
+
left = window.innerWidth - menuWidth - padding;
|
|
882
|
+
}
|
|
883
|
+
if (left < padding) {
|
|
884
|
+
left = padding;
|
|
885
|
+
}
|
|
886
|
+
let top;
|
|
887
|
+
const spaceBelow = window.innerHeight - rect.bottom - padding;
|
|
888
|
+
const spaceAbove = rect.top - padding;
|
|
889
|
+
if (spaceBelow >= menuHeight) {
|
|
890
|
+
top = rect.bottom + 8;
|
|
891
|
+
}
|
|
892
|
+
else if (spaceAbove >= menuHeight) {
|
|
893
|
+
top = rect.top - menuHeight - 8;
|
|
894
|
+
}
|
|
895
|
+
else {
|
|
896
|
+
top = Math.max(padding, window.innerHeight - menuHeight - padding);
|
|
897
|
+
}
|
|
898
|
+
top = Math.max(padding, Math.min(top, window.innerHeight - menuHeight - padding));
|
|
899
|
+
setCommandMenuPos({ top, left });
|
|
900
|
+
setShowCommands(s => !s);
|
|
901
|
+
}, []);
|
|
902
|
+
const handleExport = (0, react_1.useCallback)((format) => {
|
|
903
|
+
const visibleColumns = table.getVisibleLeafColumns();
|
|
904
|
+
// Get filtered and sorted rows, excluding group header rows
|
|
905
|
+
const allRows = table.getFilteredRowModel().flatRows;
|
|
906
|
+
const leafRows = allRows
|
|
907
|
+
.filter(r => !r.getIsGrouped()) // Exclude group header rows
|
|
908
|
+
.map(r => {
|
|
909
|
+
const rowData = {};
|
|
910
|
+
visibleColumns.forEach(col => {
|
|
911
|
+
const header = typeof col.columnDef.header === 'string' ? col.columnDef.header : col.id;
|
|
912
|
+
rowData[header] = r.getValue(col.id);
|
|
913
|
+
});
|
|
914
|
+
return rowData;
|
|
915
|
+
});
|
|
916
|
+
const fileName = (title || 'Export').toLowerCase().replace(/\s+/g, '_');
|
|
917
|
+
if (format === 'excel')
|
|
918
|
+
(0, exportUtils_1.exportTableToExcel)(leafRows, fileName, title);
|
|
919
|
+
else
|
|
920
|
+
(0, exportUtils_1.exportTableToCSV)(leafRows, fileName);
|
|
921
|
+
setShowCommands(false);
|
|
922
|
+
}, [table, title]);
|
|
923
|
+
const toggleGrouping = (0, react_1.useCallback)((colId) => setGrouping(prev => prev.includes(colId) ? prev.filter(g => g !== colId) : [...prev, colId]), []);
|
|
924
|
+
const clearGrouping = (0, react_1.useCallback)(() => { setGrouping([]); setExpanded({}); }, []);
|
|
925
|
+
const handleCopy = (0, react_1.useCallback)(() => { if (contextMenu?.content)
|
|
926
|
+
navigator.clipboard.writeText(contextMenu.content); setContextMenu(null); }, [contextMenu]);
|
|
927
|
+
const expandAllGroups = (0, react_1.useCallback)(() => { table.toggleAllRowsExpanded(true); setContextMenu(null); }, [table]);
|
|
928
|
+
const collapseAllGroups = (0, react_1.useCallback)(() => { table.toggleAllRowsExpanded(false); setContextMenu(null); }, [table]);
|
|
929
|
+
const clearAllFilters = (0, react_1.useCallback)(() => table.setColumnFilters([]), [table]);
|
|
930
|
+
const clearAllSorting = (0, react_1.useCallback)(() => table.setSorting([]), [table]);
|
|
931
|
+
const toggleMenuSection = (0, react_1.useCallback)((section) => {
|
|
932
|
+
setExpandedSections(prev => {
|
|
933
|
+
const isExpanding = !prev[section];
|
|
934
|
+
if (isExpanding) {
|
|
935
|
+
const next = {};
|
|
936
|
+
Object.keys(prev).forEach(k => { next[k] = k === section; });
|
|
937
|
+
return next;
|
|
938
|
+
}
|
|
939
|
+
return { ...prev, [section]: false };
|
|
940
|
+
});
|
|
941
|
+
}, []);
|
|
942
|
+
// Drag-Drop Columns
|
|
943
|
+
const [draggedColumnId, setDraggedColumnId] = (0, react_1.useState)(null);
|
|
944
|
+
const handleDragStart = (0, react_1.useCallback)((id) => setDraggedColumnId(id), []);
|
|
945
|
+
const handleDragEnd = (0, react_1.useCallback)(() => setDraggedColumnId(null), []);
|
|
946
|
+
const handleDragOver = (0, react_1.useCallback)((e, _targetColumnId) => {
|
|
947
|
+
e.preventDefault();
|
|
948
|
+
if (e.dataTransfer) {
|
|
949
|
+
e.dataTransfer.dropEffect = 'move';
|
|
950
|
+
}
|
|
951
|
+
}, []);
|
|
952
|
+
const handleDrop = (0, react_1.useCallback)((e, targetColumnId) => {
|
|
953
|
+
e.preventDefault();
|
|
954
|
+
const sourceId = e.dataTransfer.getData('text/plain') || draggedColumnId;
|
|
955
|
+
if (sourceId && sourceId !== targetColumnId) {
|
|
956
|
+
setColumnOrder(prev => {
|
|
957
|
+
// Use current table column order when prev is empty so drop always has effect
|
|
958
|
+
const order = prev.length > 0 ? prev : (tableRef.current ? tableRef.current.getVisibleLeafColumns().map(c => c.id) : []);
|
|
959
|
+
const newOrder = [...order];
|
|
960
|
+
const draggedIdx = newOrder.indexOf(sourceId);
|
|
961
|
+
const targetIdx = newOrder.indexOf(targetColumnId);
|
|
962
|
+
if (draggedIdx !== -1 && targetIdx !== -1) {
|
|
963
|
+
newOrder.splice(draggedIdx, 1);
|
|
964
|
+
newOrder.splice(targetIdx, 0, sourceId);
|
|
965
|
+
return newOrder;
|
|
966
|
+
}
|
|
967
|
+
return prev.length > 0 ? prev : order;
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
setDraggedColumnId(null);
|
|
971
|
+
}, [draggedColumnId]);
|
|
972
|
+
const handleGroupDrop = (0, react_1.useCallback)((e) => {
|
|
973
|
+
e.preventDefault();
|
|
974
|
+
const colId = e.dataTransfer.getData('text/plain') || draggedColumnId;
|
|
975
|
+
if (colId && !grouping.includes(colId)) {
|
|
976
|
+
toggleGrouping(colId);
|
|
977
|
+
}
|
|
978
|
+
setDraggedColumnId(null);
|
|
979
|
+
}, [draggedColumnId, grouping, toggleGrouping]);
|
|
980
|
+
const isGrouped = grouping.length > 0;
|
|
981
|
+
const isGroupingZoneVisible = isGrouped || showGroupingZone;
|
|
982
|
+
const isFloatingDrag = !!draggedColumnId && !isGrouped && !showGroupingZone;
|
|
983
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `slick-enterprise-table ${layoutMode}`, "data-sab-grid": "true", onContextMenu: (e) => e.preventDefault(), children: [(0, jsx_runtime_1.jsx)("div", { className: `slick-grouping-zone-wrapper ${isGroupingZoneVisible ? 'expanded' : 'collapsed'} ${isFloatingDrag ? 'floating' : ''}`, children: isGroupingZoneVisible && ((0, jsx_runtime_1.jsxs)("div", { className: `slick-grouping-zone ${draggedColumnId && isGroupingZoneVisible ? 'dropping-target' : ''} ${isGrouped ? 'active' : ''}`, onDragOver: (e) => { e.preventDefault(); if (e.dataTransfer)
|
|
984
|
+
e.dataTransfer.dropEffect = 'move'; }, onDragEnter: (e) => e.preventDefault(), onDrop: handleGroupDrop, children: [!isGrouped && showGroupingZone && (0, jsx_runtime_1.jsx)("div", { className: "group-drop-hint", children: "Drop column here to group" }), (0, jsx_runtime_1.jsx)("div", { className: "slick-group-chips-container", children: grouping.map(colId => ((0, jsx_runtime_1.jsxs)("div", { className: "slick-group-chip", children: [(0, jsx_runtime_1.jsx)("span", { className: "chip-label", children: resolveGroupingLabel(colId, table, columns, resolvedGroupingLabels) }), (0, jsx_runtime_1.jsx)("button", { className: "chip-remove", onClick: () => toggleGrouping(colId), children: "\u00D7" })] }, colId))) }), isGrouped && (0, jsx_runtime_1.jsx)("button", { className: "clear-all-groups-btn-premium", onClick: clearGrouping, children: "Clear All" })] })) }), (0, jsx_runtime_1.jsx)("div", { className: "slick-toolbar", children: (0, jsx_runtime_1.jsxs)("div", { className: "slick-toolbar-content", children: [(0, jsx_runtime_1.jsxs)("div", { className: "slick-toolbar-left-group", children: [(0, jsx_runtime_1.jsx)("div", { className: "slick-title-icon", children: (0, jsx_runtime_1.jsxs)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [(0, jsx_runtime_1.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }), (0, jsx_runtime_1.jsx)("line", { x1: "9", y1: "3", x2: "9", y2: "21" }), (0, jsx_runtime_1.jsx)("line", { x1: "15", y1: "3", x2: "15", y2: "21" }), (0, jsx_runtime_1.jsx)("line", { x1: "3", y1: "9", x2: "21", y2: "9" }), (0, jsx_runtime_1.jsx)("line", { x1: "3", y1: "15", x2: "21", y2: "15" })] }) }), (0, jsx_runtime_1.jsx)("span", { className: "slick-table-title", children: title }), (0, jsx_runtime_1.jsx)("div", { className: "slick-command-separator", children: "|" }), (0, jsx_runtime_1.jsx)("div", { className: "hamburger-trigger-area", ref: triggerRef, children: (0, jsx_runtime_1.jsx)("button", { className: "slick-command-btn circular", onClick: toggleCommands, title: "Context menu", children: (0, jsx_runtime_1.jsx)("span", { className: "slick-icon-touch-target", "aria-hidden": true, children: (0, jsx_runtime_1.jsxs)("span", { className: "slick-icon-css slick-icon-hamburger", children: [(0, jsx_runtime_1.jsx)("span", {}), (0, jsx_runtime_1.jsx)("span", {}), (0, jsx_runtime_1.jsx)("span", {})] }) }) }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "slick-toolbar-right-group", children: [showPaginationState && ((0, jsx_runtime_1.jsxs)("div", { className: "slick-pagination-controls-integrated", children: [(0, jsx_runtime_1.jsx)("span", { className: "slick-items-label", children: "Items per page :" }), (0, jsx_runtime_1.jsx)("select", { value: pagination.pageSize, onChange: e => { table.setPageSize(Number(e.target.value)); setPagination(prev => ({ ...prev, pageSize: Number(e.target.value) })); }, className: "slick-pagesize-select compact", children: pageSizeOptions.map(n => (0, jsx_runtime_1.jsx)("option", { value: n, children: n }, n)) }), (0, jsx_runtime_1.jsxs)("span", { className: "slick-stat-range", children: [pagination.pageIndex * pagination.pageSize + 1, " - ", Math.min((pagination.pageIndex + 1) * pagination.pageSize, filteredTotalCount), " of ", filteredTotalCount] }), (0, jsx_runtime_1.jsxs)("span", { className: "slick-page-info", children: [pagination.pageIndex + 1, "/", pageCount || 1, " Page"] }), (0, jsx_runtime_1.jsxs)("div", { className: "slick-nav-buttons", children: [(0, jsx_runtime_1.jsx)("button", { className: "slick-icon-action mini nav-arrow", onClick: () => table.previousPage(), disabled: !table.getCanPreviousPage(), children: "\u2039" }), (0, jsx_runtime_1.jsx)("button", { className: "slick-icon-action mini nav-arrow", onClick: () => table.nextPage(), disabled: !table.getCanNextPage(), children: "\u203A" })] })] })), (0, jsx_runtime_1.jsx)("button", { className: `slick-icon-action filter-toggle ${showFilters ? 'active' : ''}`, onClick: () => setShowFilters(s => !s), title: "Toggle filters", children: (0, jsx_runtime_1.jsx)("span", { className: "slick-icon-touch-target", "aria-hidden": true, children: (0, jsx_runtime_1.jsxs)("span", { className: "slick-icon-css slick-icon-filter", "aria-hidden": true, children: [(0, jsx_runtime_1.jsx)("span", {}), (0, jsx_runtime_1.jsx)("span", {}), (0, jsx_runtime_1.jsx)("span", {})] }) }) })] })] }) }), (0, jsx_runtime_1.jsx)("div", { className: `slick-grid-container ${visibleCount === 1 ? 'single-column-mode' : ''}`, ref: tableContainerRef, children: (0, jsx_runtime_1.jsxs)("table", { className: "slick-table", style: {
|
|
985
|
+
width: layoutMode === 'fit-content' ? 'max-content' : '100%',
|
|
986
|
+
minWidth: '100%',
|
|
987
|
+
// fixed layout so column widths come only from header + row data (resizeColumnsByCellContent); filter panel content is excluded
|
|
988
|
+
tableLayout: 'fixed'
|
|
989
|
+
}, children: [(0, jsx_runtime_1.jsx)("thead", { children: visibleHeaderGroups.map(hg => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)("tr", { className: `slick-header-row ${draggedColumnId ? 'dragging-active' : ''}`, children: hg.headers.map(h => ((0, jsx_runtime_1.jsx)(MemoizedHeaderCell, { header: h, draggedColumnId: draggedColumnId, onDragStart: handleDragStart, onDragOver: handleDragOver, onDragEnd: handleDragEnd, onDrop: handleDrop, layoutMode: layoutMode, totalSize: totalSize }, h.id))) }), showFilters && ((0, jsx_runtime_1.jsx)("tr", { className: "slick-filter-row", children: hg.headers.map(h => ((0, jsx_runtime_1.jsx)(MemoizedFilterCell, { header: h, filterValue: h.column.getFilterValue(), draggedId: draggedColumnId, layoutMode: layoutMode, totalSize: totalSize, columnMeta: columnMetaById[h.column.id] ?? columnMetaById[h.column.columnDef?.accessorKey] }, h.id))) }))] }, hg.id))) }), (0, jsx_runtime_1.jsxs)("tbody", { children: [paddingTop > 0 && (0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsx)("td", { style: { height: `${paddingTop}px` } }) }), virtualRows.map(vr => ((0, jsx_runtime_1.jsx)(MemoizedRow, { row: rows[vr.index], visibleCount: visibleCount, onRowClick: onRowClick, onActionClick: onActionClick, setContextMenu: setContextMenu, getGroupingLabel: getGroupingLabel, layoutMode: layoutMode, totalSize: totalSize, columnOrder: columnOrder, columnMetaById: columnMetaById }, rows[vr.index].id))), paddingBottom > 0 && (0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsx)("td", { style: { height: `${paddingBottom}px` } }) })] })] }) }), showCommands && commandMenuPos && ((0, jsx_runtime_1.jsxs)("div", { ref: menuRef, className: "slick-fixed-cmd-menu consolidated-menu", style: {
|
|
990
|
+
top: commandMenuPos.top,
|
|
991
|
+
left: commandMenuPos.left,
|
|
992
|
+
position: 'fixed',
|
|
993
|
+
maxHeight: `calc(100vh - ${commandMenuPos.top + 16}px)`,
|
|
994
|
+
overflowY: 'auto'
|
|
995
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { className: `menu-collapsible-section ${expandedSections.quickActions ? 'expanded' : ''}`, children: [(0, jsx_runtime_1.jsxs)("div", { className: "menu-header clickable", onClick: () => toggleMenuSection('quickActions'), children: [(0, jsx_runtime_1.jsx)("span", { children: "QUICK ACTIONS" }), (0, jsx_runtime_1.jsx)("span", { className: "expand-icon", children: (0, jsx_runtime_1.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", style: { transform: expandedSections.quickActions ? 'rotate(90deg)' : 'rotate(0deg)', transition: 'transform 0.2s' }, children: (0, jsx_runtime_1.jsx)("polyline", { points: "9 18 15 12 9 6" }) }) })] }), expandedSections.quickActions && ((0, jsx_runtime_1.jsxs)("div", { className: "section-content", children: [(0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => { clearAllFilters(); setShowCommands(false); }, children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon", children: (0, jsx_runtime_1.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: (0, jsx_runtime_1.jsx)("path", { d: "M22 3H2l8 9.46V19l4 2v-8.54L22 3z" }) }) }), (0, jsx_runtime_1.jsx)("span", { children: "Clear All Filters" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => { clearAllSorting(); setShowCommands(false); }, children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon", children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("circle", { cx: "12", cy: "12", r: "3" }), (0, jsx_runtime_1.jsx)("path", { d: "M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-2 2 2 2 0 01-2-2v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83 0 2 2 0 010-2.83l.06-.06a1.65 1.65 0 00.33-1.82 1.65 1.65 0 00-1.51-1H3a2 2 0 01-2-2 2 2 0 012-2h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 010-2.83 2 2 0 012.83 0l.06.06a1.65 1.65 0 001.82.33H9a1.65 1.65 0 001-1.51V3a2 2 0 012-2 2 2 0 012 2v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 0 2 2 0 010 2.83l-.06.06a1.65 1.65 0 00-.33 1.82V9a1.65 1.65 0 001.51 1H21a2 2 0 012 2 2 2 0 01-2 2h-.09a1.65 1.65 0 00-1.51 1z" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Clear All Sorting" })] })] }))] }), (0, jsx_runtime_1.jsx)("div", { className: "menu-divider" }), (0, jsx_runtime_1.jsxs)("div", { className: `menu-collapsible-section ${expandedSections.dataExport ? 'expanded' : ''}`, children: [(0, jsx_runtime_1.jsxs)("div", { className: "menu-header clickable", onClick: () => toggleMenuSection('dataExport'), children: [(0, jsx_runtime_1.jsx)("span", { children: "DATA EXPORT" }), (0, jsx_runtime_1.jsx)("span", { className: "expand-icon", children: (0, jsx_runtime_1.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", style: { transform: expandedSections.dataExport ? 'rotate(90deg)' : 'rotate(0deg)', transition: 'transform 0.2s' }, children: (0, jsx_runtime_1.jsx)("polyline", { points: "9 18 15 12 9 6" }) }) })] }), expandedSections.dataExport && ((0, jsx_runtime_1.jsxs)("div", { className: "section-content", children: [(0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => handleExport('excel'), children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon", style: { background: '#10b981', color: '#fff' }, children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("path", { d: "M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" }), (0, jsx_runtime_1.jsx)("polyline", { points: "14 2 14 8 20 8" }), (0, jsx_runtime_1.jsx)("line", { x1: "16", y1: "13", x2: "8", y2: "13" }), (0, jsx_runtime_1.jsx)("line", { x1: "16", y1: "17", x2: "8", y2: "17" }), (0, jsx_runtime_1.jsx)("polyline", { points: "10 9 9 9 8 9" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Export to Excel" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => handleExport('csv'), children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon", style: { background: '#f59e0b', color: '#fff' }, children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("path", { d: "M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" }), (0, jsx_runtime_1.jsx)("polyline", { points: "14 2 14 8 20 8" }), (0, jsx_runtime_1.jsx)("line", { x1: "16", y1: "13", x2: "8", y2: "13" }), (0, jsx_runtime_1.jsx)("line", { x1: "16", y1: "17", x2: "8", y2: "17" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Export to CSV" })] })] }))] }), (0, jsx_runtime_1.jsx)("div", { className: "menu-divider" }), (0, jsx_runtime_1.jsxs)("div", { className: `menu-collapsible-section ${expandedSections.layoutMode ? 'expanded' : ''}`, children: [(0, jsx_runtime_1.jsxs)("div", { className: "menu-header clickable", onClick: () => toggleMenuSection('layoutMode'), children: [(0, jsx_runtime_1.jsx)("span", { children: "LAYOUT MODE" }), (0, jsx_runtime_1.jsx)("span", { className: "expand-icon", children: (0, jsx_runtime_1.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", style: { transform: expandedSections.layoutMode ? 'rotate(90deg)' : 'rotate(0deg)', transition: 'transform 0.2s' }, children: (0, jsx_runtime_1.jsx)("polyline", { points: "9 18 15 12 9 6" }) }) })] }), expandedSections.layoutMode && ((0, jsx_runtime_1.jsxs)("div", { className: "section-content", children: [(0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => { setLayoutMode('fit-default'); setShowCommands(false); }, children: [(0, jsx_runtime_1.jsx)("div", { className: `radio-circle ${layoutMode === 'fit-default' ? 'checked' : ''}`, children: (0, jsx_runtime_1.jsx)("div", { className: "dot" }) }), (0, jsx_runtime_1.jsx)("span", { children: "Fit to Default" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => { setLayoutMode('fit-window'); setShowCommands(false); }, children: [(0, jsx_runtime_1.jsx)("div", { className: `radio-circle ${layoutMode === 'fit-window' ? 'checked' : ''}`, children: (0, jsx_runtime_1.jsx)("div", { className: "dot" }) }), (0, jsx_runtime_1.jsx)("span", { children: "Fit to Window" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => { setLayoutMode('fit-content'); setShowCommands(false); }, children: [(0, jsx_runtime_1.jsx)("div", { className: `radio-circle ${layoutMode === 'fit-content' ? 'checked' : ''}`, children: (0, jsx_runtime_1.jsx)("div", { className: "dot" }) }), (0, jsx_runtime_1.jsx)("span", { children: "Fit to Content" })] })] }))] }), (0, jsx_runtime_1.jsx)("div", { className: "menu-divider" }), (0, jsx_runtime_1.jsxs)("div", { className: `menu-collapsible-section ${expandedSections.columns ? 'expanded' : ''}`, children: [(0, jsx_runtime_1.jsxs)("div", { className: "menu-header clickable", onClick: () => toggleMenuSection('columns'), children: [(0, jsx_runtime_1.jsx)("span", { children: "COLUMNS" }), (0, jsx_runtime_1.jsx)("span", { className: "expand-icon", children: (0, jsx_runtime_1.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", style: { transform: expandedSections.columns ? 'rotate(90deg)' : 'rotate(0deg)', transition: 'transform 0.2s' }, children: (0, jsx_runtime_1.jsx)("polyline", { points: "9 18 15 12 9 6" }) }) })] }), expandedSections.columns && ((0, jsx_runtime_1.jsx)("div", { className: "section-content", children: (0, jsx_runtime_1.jsx)("div", { className: "menu-columns-scroll consolidated", children: (() => {
|
|
996
|
+
const allCols = table.getAllLeafColumns();
|
|
997
|
+
const visibleCols = allCols.filter(c => c.getIsVisible());
|
|
998
|
+
const visibleCount = visibleCols.length;
|
|
999
|
+
return allCols.map(column => {
|
|
1000
|
+
const isVisible = column.getIsVisible();
|
|
1001
|
+
const isLastVisible = isVisible && visibleCount === 1;
|
|
1002
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "menu-column-list-item-pro", children: (0, jsx_runtime_1.jsxs)("div", { className: "column-checkbox-part", onClick: (e) => {
|
|
1003
|
+
e.stopPropagation();
|
|
1004
|
+
if (isLastVisible)
|
|
1005
|
+
return;
|
|
1006
|
+
column.toggleVisibility();
|
|
1007
|
+
}, style: { cursor: 'pointer' }, children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: isVisible, readOnly: true }), (0, jsx_runtime_1.jsx)("span", { className: "col-label-text", children: typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id })] }) }, column.id));
|
|
1008
|
+
});
|
|
1009
|
+
})() }) }))] }), (0, jsx_runtime_1.jsx)("div", { className: "menu-divider" }), (0, jsx_runtime_1.jsxs)("div", { className: `menu-collapsible-section ${expandedSections.groupingOptions ? 'expanded' : ''}`, children: [(0, jsx_runtime_1.jsxs)("div", { className: "menu-header clickable", onClick: () => toggleMenuSection('groupingOptions'), children: [(0, jsx_runtime_1.jsx)("span", { children: "GROUPING OPTIONS" }), (0, jsx_runtime_1.jsx)("span", { className: "expand-icon", children: (0, jsx_runtime_1.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", style: { transform: expandedSections.groupingOptions ? 'rotate(90deg)' : 'rotate(0deg)', transition: 'transform 0.2s' }, children: (0, jsx_runtime_1.jsx)("polyline", { points: "9 18 15 12 9 6" }) }) })] }), expandedSections.groupingOptions && ((0, jsx_runtime_1.jsxs)("div", { className: "section-content", children: [(0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => { setShowGroupingZone(!showGroupingZone); setShowCommands(false); }, children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon", children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }), (0, jsx_runtime_1.jsx)("line", { x1: "9", y1: "3", x2: "9", y2: "21" }), (0, jsx_runtime_1.jsx)("line", { x1: "15", y1: "3", x2: "15", y2: "21" })] }) }), (0, jsx_runtime_1.jsxs)("span", { children: [showGroupingZone ? 'Hide' : 'Enable', " Group By"] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => { clearGrouping(); setShowCommands(false); }, children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon", children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("path", { d: "M21 4H8l-7 8 7 8h13a2 2 0 002-2V6a2 2 0 00-2-2z" }), (0, jsx_runtime_1.jsx)("line", { x1: "18", y1: "9", x2: "12", y2: "15" }), (0, jsx_runtime_1.jsx)("line", { x1: "12", y1: "9", x2: "18", y2: "15" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Clear All Grouping" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => { expandAllGroups(); setShowCommands(false); }, children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon", children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("path", { d: "M15 9l6-6" }), (0, jsx_runtime_1.jsx)("path", { d: "M9 15l-6 6" }), (0, jsx_runtime_1.jsx)("path", { d: "M3 15h6v6" }), (0, jsx_runtime_1.jsx)("path", { d: "M21 9h-6V3" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Expand All Groups" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => { collapseAllGroups(); setShowCommands(false); }, children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon", children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("path", { d: "M4 14h6v6" }), (0, jsx_runtime_1.jsx)("path", { d: "M20 10h-6V4" }), (0, jsx_runtime_1.jsx)("path", { d: "M14 10l7-7" }), (0, jsx_runtime_1.jsx)("path", { d: "M3 21l7-7" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Collapse All Groups" })] })] }))] })] })), contextMenu && ((0, jsx_runtime_1.jsxs)("div", { ref: contextMenuRef, className: "slick-fixed-cmd-menu consolidated-menu context-premium", style: {
|
|
1010
|
+
top: contextMenu.y + 350 > window.innerHeight ? contextMenu.y - 350 : contextMenu.y,
|
|
1011
|
+
left: Math.min(contextMenu.x, window.innerWidth - 320),
|
|
1012
|
+
position: 'fixed',
|
|
1013
|
+
maxHeight: '350px',
|
|
1014
|
+
overflowY: 'auto'
|
|
1015
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { className: "menu-header-main", children: "QUICK ACTIONS" }), (0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: handleCopy, children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon", style: { background: '#f8fafc', color: '#64748b' }, children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }), (0, jsx_runtime_1.jsx)("path", { d: "M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Copy Selection" })] }), isGrouped && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "menu-divider" }), (0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => { collapseAllGroups(); setContextMenu(null); }, children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon", style: { background: '#f8fafc', color: '#64748b' }, children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("path", { d: "M4 14h6v6" }), (0, jsx_runtime_1.jsx)("path", { d: "M20 10h-6V4" }), (0, jsx_runtime_1.jsx)("path", { d: "M14 10l7-7" }), (0, jsx_runtime_1.jsx)("path", { d: "M3 21l7-7" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Collapse All Groups" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => { expandAllGroups(); setContextMenu(null); }, children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon", style: { background: '#f8fafc', color: '#64748b' }, children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [(0, jsx_runtime_1.jsx)("path", { d: "M15 9l6-6" }), (0, jsx_runtime_1.jsx)("path", { d: "M9 15l-6 6" }), (0, jsx_runtime_1.jsx)("path", { d: "M3 15h6v6" }), (0, jsx_runtime_1.jsx)("path", { d: "M21 9h-6V3" })] }) }), (0, jsx_runtime_1.jsx)("span", { children: "Expand All Groups" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "menu-action-item", onClick: () => { clearGrouping(); setContextMenu(null); }, children: [(0, jsx_runtime_1.jsx)("div", { className: "round-icon-bg action-icon", style: { background: '#f8fafc', color: '#64748b' }, children: (0, jsx_runtime_1.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: (0, jsx_runtime_1.jsx)("path", { d: "M18 6L6 18M6 6l12 12" }) }) }), (0, jsx_runtime_1.jsx)("span", { children: "Clear All Grouping" })] })] }))] })), (0, jsx_runtime_1.jsx)("style", { children: `
|
|
1016
|
+
.slick-enterprise-table { width: 100%; font-family: 'Inter', system-ui, sans-serif; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.06); }
|
|
1017
|
+
.slick-grouping-zone { margin: 12px 20px 0; padding: 10px 18px; border: 1.5px dashed #cbd5e1; border-radius: 12px; display: flex; align-items: center; justify-content: space-between; background: #fdfdfd; transition: all 0.2s; min-height: 48px; position: relative; }
|
|
1018
|
+
.slick-grouping-zone.dropping-target { border-color: #3b82f6; background: #f0f7ff; border-style: solid; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
|
|
1019
|
+
.group-drop-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 13px; color: #3b82f6; font-weight: 600; pointer-events: none; }
|
|
1020
|
+
.slick-group-chips-container { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
1021
|
+
.slick-group-chip { background: #fff; border: 1px solid #3b82f6; border-radius: 20px; padding: 4px 12px; display: flex; align-items: center; gap: 8px; box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1); }
|
|
1022
|
+
.chip-label { font-size: 12.5px; font-weight: 700; color: #1e40af; }
|
|
1023
|
+
.chip-remove { background: transparent; border: none; color: #3b82f6; font-size: 18px; font-weight: 700; cursor: pointer; padding: 0; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: all 0.2s; }
|
|
1024
|
+
.chip-remove:hover { background: #3b82f6; color: #fff; }
|
|
1025
|
+
.clear-all-groups-btn-premium { background: #ef4444; color: #fff; border: none; padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all 0.2s; }
|
|
1026
|
+
.clear-all-groups-btn-premium:hover { background: #dc2626; box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3); }
|
|
1027
|
+
.slick-group-row td { padding: 0 !important; background: #fff !important; border-bottom: 1px solid #e2e8f0; }
|
|
1028
|
+
.slick-group-header-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; background: #f8fafc; border-left: 4px solid transparent; transition: all 0.2s; font-size: 12.5px; font-weight: 700; color: #334155; }
|
|
1029
|
+
.slick-group-header-row.expanded { background: #f1f7ff; border-left-color: #3b82f6; border-bottom: 1px solid #dbeafe; }
|
|
1030
|
+
.slick-group-chevron { display: flex; align-items: center; color: #64748b; transition: transform 0.2s; }
|
|
1031
|
+
.slick-group-header-row.expanded .slick-group-chevron { transform: rotate(90deg); color: #3b82f6; }
|
|
1032
|
+
.slick-group-title { font-size: 12.5px; font-weight: 700; color: #334155; }
|
|
1033
|
+
.slick-group-title .group-col-label { font-size: 12.5px; font-weight: 700; color: #334155; }
|
|
1034
|
+
.slick-group-count { font-size: 12px; color: #3b82f6; font-weight: 600; background: #eff6ff; padding: 2px 8px; border-radius: 12px; }
|
|
1035
|
+
.slick-toolbar { border-bottom: 1px solid #f1f5f9; background: #f8fafc; padding: 0 16px; height: 48px; display: flex; align-items: center; }
|
|
1036
|
+
.slick-toolbar-content { width: 100%; display: flex; justify-content: space-between; align-items: center; }
|
|
1037
|
+
.slick-toolbar-left-group { display: flex; align-items: center; gap: 12px; }
|
|
1038
|
+
.slick-toolbar-right-group { display: flex; align-items: center; gap: 16px; }
|
|
1039
|
+
.slick-title-icon { color:black; background: #ecfdf5; padding: 6px; border-radius: 8px; display: flex; align-items: center; }
|
|
1040
|
+
.slick-table-title { font-weight: 700; color: #334155; font-size: 14.5px; }
|
|
1041
|
+
.slick-command-separator { color: #e2e8f0; font-weight: 300; margin: 0 4px; }
|
|
1042
|
+
.slick-command-btn.circular { width: 34px; height: 34px; border-radius: 50%; border: 1px solid #e2e8f0; background: #eff6ff; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #3b82f6; transition: all 0.2s; }
|
|
1043
|
+
.slick-command-btn.circular:hover { border-color: #3b82f6; color: #1d4ed8; background: #dbeafe; box-shadow: 0 2px 8px rgba(59, 130, 246, 0.12); }
|
|
1044
|
+
/* CSS-only toolbar/filter icons (span-based, no SVG) so consumers can target reliably */
|
|
1045
|
+
.slick-icon-touch-target { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; color: inherit; }
|
|
1046
|
+
.slick-icon-css.slick-icon-hamburger { display: flex; flex-direction: column; justify-content: space-between; width: 18px; height: 12px; color: currentColor; }
|
|
1047
|
+
.slick-icon-css.slick-icon-hamburger span { display: block; height: 2px; background: currentColor; border-radius: 1px; width: 100%; }
|
|
1048
|
+
/* Three-bar filter icon (top longest, middle shorter, bottom shortest) – CSS-only */
|
|
1049
|
+
.slick-icon-css.slick-icon-filter { display: flex; flex-direction: column; align-items: center; justify-content: space-between; width: 16px; height: 12px; color: currentColor; gap: 3px; }
|
|
1050
|
+
.slick-icon-css.slick-icon-filter span { display: block; height: 2px; background: currentColor; border-radius: 1px; }
|
|
1051
|
+
.slick-icon-css.slick-icon-filter span:nth-child(1) { width: 100%; }
|
|
1052
|
+
.slick-icon-css.slick-icon-filter span:nth-child(2) { width: 65%; }
|
|
1053
|
+
.slick-icon-css.slick-icon-filter span:nth-child(3) { width: 40%; }
|
|
1054
|
+
.slick-icon-css.slick-icon-search { width: 12px; height: 12px; border: 2px solid currentColor; border-radius: 50%; position: relative; box-sizing: border-box; color: currentColor; }
|
|
1055
|
+
.slick-icon-css.slick-icon-search::after { content: ''; position: absolute; bottom: -1px; right: -1px; width: 6px; height: 2px; background: currentColor; transform: rotate(45deg); transform-origin: right center; border-radius: 1px; }
|
|
1056
|
+
.slick-icon-css.slick-icon-calendar { width: 12px; height: 12px; border: 2px solid currentColor; border-radius: 2px; position: relative; box-sizing: border-box; color: currentColor; }
|
|
1057
|
+
.slick-icon-css.slick-icon-calendar::before { content: ''; position: absolute; top: -2px; left: 50%; transform: translateX(-50%); width: 4px; height: 2px; background: currentColor; border-radius: 1px; }
|
|
1058
|
+
.slick-icon-css.slick-icon-calendar::after { content: ''; position: absolute; top: 2px; left: 1px; right: 1px; height: 1px; background: currentColor; border-radius: 0; }
|
|
1059
|
+
|
|
1060
|
+
.slick-pagination-controls-integrated { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #64748b; font-weight: 500; }
|
|
1061
|
+
.slick-pagesize-select { border: 1px solid #e2e8f0; border-radius: 6px; padding: 2px 8px; font-size: 12px; outline: none; background: #fff; cursor: pointer; }
|
|
1062
|
+
.slick-nav-buttons { display: flex; align-items: center; border-left: 1px solid #e2e8f0; padding-left: 12px; margin-left: 4px; gap: 4px; }
|
|
1063
|
+
.slick-icon-action { width: 32px; height: 32px; border-radius: 50%; border: 1px solid #e2e8f0; background: #eff6ff; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #3b82f6; transition: all 0.2s; }
|
|
1064
|
+
.slick-icon-action:hover:not(:disabled) { border-color: #3b82f6; color: #1d4ed8; background: #dbeafe; }
|
|
1065
|
+
.slick-icon-action:disabled { opacity: 0.4; cursor: not-allowed; }
|
|
1066
|
+
.slick-icon-action.mini { width: 28px; height: 28px; font-size: 18px; }
|
|
1067
|
+
.slick-icon-action.filter-toggle { border-color: #e2e8f0; background: #eff6ff; color: #3b82f6; }
|
|
1068
|
+
.slick-icon-action.filter-toggle.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
|
|
1069
|
+
.slick-icon-action.filter-toggle:not(.active):hover { background: #dbeafe; color: #1d4ed8; border-color: #3b82f6; }
|
|
1070
|
+
.consolidated-menu { width: 310px; background: #fff; border: 1px solid #cbd5e1; border-radius: 14px; box-shadow: 0 12px 48px rgba(0,0,0,0.18); z-index: 10000; padding: 10px 0; max-height: 520px; overflow-y: auto; }
|
|
1071
|
+
.menu-header-main { padding: 10px 18px 12px; font-size: 14px; font-weight: 700; color: #334155; border-bottom: 1px solid #f1f5f9; margin-bottom: 8px; }
|
|
1072
|
+
.menu-action-item { padding: 8px 18px; display: flex; align-items: center; gap: 14px; cursor: pointer; }
|
|
1073
|
+
.menu-action-item:hover { background: #f8fafc; }
|
|
1074
|
+
.menu-action-item span { font-size: 14px; font-weight: 600; color: #1e293b; }
|
|
1075
|
+
.round-icon-bg.action-icon { width: 34px; height: 34px; border-radius: 50%; background: #eff6ff; display: flex; align-items: center; justify-content: center; color: #3b82f6; }
|
|
1076
|
+
.round-icon-bg.action-icon.mini-icon { width: 26px; height: 26px; }
|
|
1077
|
+
.menu-header.clickable { display: flex; justify-content: space-between; align-items: center; cursor: pointer; margin: 0 8px; padding: 10px 12px; border-radius: 8px; font-size: 11px; font-weight: 800; color: #94a3b8; text-transform: uppercase; }
|
|
1078
|
+
.menu-header.clickable:hover { background: #f8fafc; }
|
|
1079
|
+
.menu-collapsible-section.expanded .menu-header.clickable { color: #3b82f6; background: #f0f7ff; }
|
|
1080
|
+
.expand-icon { width: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
|
|
1081
|
+
|
|
1082
|
+
.slick-grid-container { width: 100%; overflow: auto; height: calc(100vh - 420px); min-height: 420px; }
|
|
1083
|
+
.slick-table { border-collapse: separate; border-spacing: 0; min-width: 100%; table-layout: fixed; }
|
|
1084
|
+
/* Column headers fixed (sticky) by default - do not scroll with body */
|
|
1085
|
+
.slick-header-th { border-bottom: 2px solid #dde3ed; border-right: 1px solid #e8ecf2; background: #f0f4f8; position: sticky; top: 0; z-index: 35; }
|
|
1086
|
+
.slick-header-cell-inner { padding: 8px 10px; font-size: 12.5px; font-weight: 700; color: #334155; display: flex; align-items: center; justify-content: flex-start; gap: 4px; position: relative; min-height: 24px; }
|
|
1087
|
+
.slick-header-label { flex: 1; text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
|
|
1088
|
+
.slick-header-actions { display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 1px; border-radius: 4px; color: #94a3b8; width: 20px; height: 20px; opacity: 0; visibility: hidden; transition: opacity 0.2s; flex-shrink: 0; }
|
|
1089
|
+
.slick-header-th:hover .slick-header-actions, .slick-header-actions.visible { opacity: 1; visibility: visible; }
|
|
1090
|
+
.slick-header-actions:hover { background: #e2e8f0; color: #3b82f6; }
|
|
1091
|
+
.slick-header-actions svg, .slick-header-label svg { pointer-events: none; }
|
|
1092
|
+
|
|
1093
|
+
.slick-header-dropdown-menu { position: absolute; top: 100%; right: 0; width: 220px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); z-index: 1000; padding: 6px 0; margin-top: 4px; }
|
|
1094
|
+
.dropdown-item { padding: 8px 16px; font-size: 13px; font-weight: 500; color: #475569; display: flex; align-items: center; gap: 10px; cursor: pointer; }
|
|
1095
|
+
.dropdown-item:hover { background: #f8fafc; color: #3b82f6; }
|
|
1096
|
+
.dropdown-divider { height: 1px; background: #f1f5f9; margin: 4px 0; }
|
|
1097
|
+
|
|
1098
|
+
.slick-data-row:nth-child(even) { background: #fdfdfd; }
|
|
1099
|
+
.slick-data-row:hover { background: #e8f4fd; }
|
|
1100
|
+
.slick-data-row td { border-bottom: 1px solid #edf0f5; border-right: 1px solid #edf0f5; padding: 7px 10px; font-size: 13px; vertical-align: middle; }
|
|
1101
|
+
|
|
1102
|
+
/* Single Column Professional Mode */
|
|
1103
|
+
.single-column-mode .slick-table { border: 1px solid #e2e8f0; border-radius: 4px; overflow: visible; margin: 4px; width: calc(100% - 8px); }
|
|
1104
|
+
.single-column-mode .slick-header-th { background: #f1f5f9; border-bottom: 1px solid #e2e8f0; font-weight: 700; color: #334155; }
|
|
1105
|
+
.single-column-mode .slick-data-row td { border-bottom: 1px solid #f1f5f9; background: #fff; }
|
|
1106
|
+
.single-column-mode .slick-data-row:hover td { background: #f8fafc; }
|
|
1107
|
+
.single-column-mode .slick-header-cell-inner { padding: 8px 12px; }
|
|
1108
|
+
.slick-cell-content { font-size: 13px; color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
1109
|
+
|
|
1110
|
+
.slick-filter-prefix { width: 24px; display: flex; align-items: center; justify-content: center; background: #f1f5f9; border-right: 1px solid #e2e8f0; cursor: pointer; border-radius: 6px 0 0 6px; }
|
|
1111
|
+
.filter-placeholder-char { font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center; color: #94a3b8; }
|
|
1112
|
+
.prefix-dot-trigger { width: 10px; height: 4px; border-radius: 50%; background: #94a3b8; }
|
|
1113
|
+
.prefix-operand-symbol { font-size: 13px; font-weight: 700; color: #000; display: flex; align-items: center; justify-content: center; width: 100%; }
|
|
1114
|
+
.prefix-operand-symbol.placeholder { color: #cbd5e1; }
|
|
1115
|
+
.prefix-operand-placeholder { display: block; width: 14px; height: 14px; }
|
|
1116
|
+
.slick-filter-search-area { flex: 1; min-width: 0; display: flex; align-items: center; position: relative; padding-left: 8px; overflow: hidden; cursor: text; }
|
|
1117
|
+
.active-operand-overlay { position: absolute; bottom: -2px; right: -4px; font-size: 8px; font-weight: 900; background: #3b82f6; color: #fff; border-radius: 3px; padding: 0 2px; line-height: 1; }
|
|
1118
|
+
.operand-selector { cursor: pointer; position: relative; user-select: none; }
|
|
1119
|
+
.operand-selector-chevron { display: flex; align-items: center; color: #64748b; }
|
|
1120
|
+
.operand-selector:hover .operand-selector-chevron { color: #3b82f6; }
|
|
1121
|
+
.operand-dropdown { position: absolute; top: 100%; left: 0; min-width: 140px; width: max-content; max-width: 280px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); z-index: 2000; padding: 6px 0; margin-top: 4px; }
|
|
1122
|
+
.operand-item { padding: 8px 12px; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
|
|
1123
|
+
.operand-item:hover { background: #f0f7ff; }
|
|
1124
|
+
.operand-item.active { background: #eff6ff; border-left: 3px solid #3b82f6; }
|
|
1125
|
+
.op-symbol { width: 14px; font-weight: 800; color: #3b82f6; font-size: 15px; text-align: center; }
|
|
1126
|
+
.op-label { font-size: 11px; color: #475569; font-weight: 700; text-transform: uppercase; letter-spacing: 0.2px; }
|
|
1127
|
+
|
|
1128
|
+
.slick-premium-filter-container { display: flex; height: 32px; min-width: 0; max-width: 100%; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; overflow: visible; transition: all 0.2s; position: relative; }
|
|
1129
|
+
.slick-premium-filter-container:focus-within { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1); }
|
|
1130
|
+
.slick-premium-filter-input { flex: 1; min-width: 0; border: none; outline: none; padding: 0; font-size: 12.5px; color: #334155; background: transparent; overflow: hidden; text-overflow: ellipsis; }
|
|
1131
|
+
|
|
1132
|
+
.menu-header-sec { padding: 8px 18px 4px; font-size: 11px; font-weight: 800; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; }
|
|
1133
|
+
.menu-context-groups-list { max-height: 200px; overflow-y: auto; padding: 4px 0; }
|
|
1134
|
+
.round-icon-bg.action-icon.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
|
|
1135
|
+
.slick-header-th.dragging { opacity: 0.35; background: #e0f2fe !important; border: 2px dashed #0ea5e9; }
|
|
1136
|
+
.slick-header-th .slick-header-label { user-select: none; pointer-events: auto !important; }
|
|
1137
|
+
.slick-header-th .slick-header-actions, .slick-header-th .slick-header-dropdown-menu, .filter-wrapper { pointer-events: auto; }
|
|
1138
|
+
/* Prevent child pointer interferences during reordering, but keep the TH accessible for dragover/drop */
|
|
1139
|
+
.slick-header-row.dragging-active .slick-header-th:not(.dragging) * { pointer-events: none !important; }
|
|
1140
|
+
.slick-grouping-zone-wrapper { transition: all 0.3s ease; overflow: hidden; position: relative; }
|
|
1141
|
+
.slick-grouping-zone-wrapper.collapsed { height: 0; margin-top: 0; }
|
|
1142
|
+
.slick-grouping-zone-wrapper.expanded { height: auto; min-height: 48px; }
|
|
1143
|
+
.slick-grouping-zone-wrapper.floating { position: absolute; top: 0; left: 0; right: 0; z-index: 1000; background: #fff; border-bottom: 2px solid #3b82f6; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
|
|
1144
|
+
.slick-resizer { position: absolute; right: 0; top: 0; height: 100%; width: 5px; background: rgba(0,0,0,0.05); cursor: col-resize; z-index: 40; }
|
|
1145
|
+
.slick-resizer:hover { background: #3b82f6; width: 3px; }
|
|
1146
|
+
.slick-resizer:hover { background: #3b82f6; width: 6px; }
|
|
1147
|
+
.muted-action { opacity: 0.4; pointer-events: none; }
|
|
1148
|
+
.slick-edit-input { width: 100%; padding: 4px 10px; border: 1px solid #3b82f6; border-radius: 4px; outline: none; }
|
|
1149
|
+
.menu-column-list-item-pro { padding: 8px 16px; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; }
|
|
1150
|
+
.column-checkbox-part { display: flex; align-items: center; gap: 10px; cursor: pointer; flex: 1; }
|
|
1151
|
+
.col-label-text { font-size: 13.5px; font-weight: 600; color: #334155; }
|
|
1152
|
+
.menu-divider { height: 1px; background: #f1f5f9; margin: 4px 0; }
|
|
1153
|
+
/* Toolbar icons: ensure visible when consumed from NPM (override host app button/global styles) */
|
|
1154
|
+
.slick-enterprise-table[data-sab-grid] .slick-toolbar .slick-command-btn.circular,
|
|
1155
|
+
.slick-enterprise-table[data-sab-grid] .slick-toolbar .slick-icon-action { background-color: #eff6ff !important; color: #3b82f6 !important; border-color: #e2e8f0 !important; }
|
|
1156
|
+
.slick-enterprise-table[data-sab-grid] .slick-toolbar .slick-command-btn.circular:hover,
|
|
1157
|
+
.slick-enterprise-table[data-sab-grid] .slick-toolbar .slick-icon-action:hover:not(:disabled) { background-color: #dbeafe !important; color: #1d4ed8 !important; border-color: #3b82f6 !important; }
|
|
1158
|
+
.slick-enterprise-table[data-sab-grid] .slick-toolbar .slick-icon-action.filter-toggle { background-color: #eff6ff !important; color: #3b82f6 !important; }
|
|
1159
|
+
.slick-enterprise-table[data-sab-grid] .slick-toolbar .slick-icon-action.filter-toggle:not(.active):hover { background-color: #dbeafe !important; color: #1d4ed8 !important; }
|
|
1160
|
+
.slick-enterprise-table[data-sab-grid] .slick-toolbar .slick-icon-action.filter-toggle.active { background-color: #3b82f6 !important; color: #fff !important; border-color: #3b82f6 !important; }
|
|
1161
|
+
/* Force toolbar icons to be visible (CSS span icons; override host app button styles) */
|
|
1162
|
+
.slick-enterprise-table[data-sab-grid] .slick-toolbar .slick-command-btn.circular .slick-icon-css,
|
|
1163
|
+
.slick-enterprise-table[data-sab-grid] .slick-toolbar .slick-icon-action .slick-icon-css { color: inherit !important; }
|
|
1164
|
+
|
|
1165
|
+
/* New Filter Styles */
|
|
1166
|
+
.filter-clear-btn { cursor: pointer; color: #94a3b8; width: 24px; display: flex; align-items: center; justify-content: center; transition: color 0.2s; }
|
|
1167
|
+
.filter-clear-btn:hover { color: #ef4444; }
|
|
1168
|
+
.slick-filter-dropdown-btn { width: 100%; height: 100%; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; font-size: 12.5px; color: #334155; cursor: pointer; }
|
|
1169
|
+
.dropdown-text-container { min-width: 0; flex: 1; }
|
|
1170
|
+
.dropdown-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 100%; }
|
|
1171
|
+
.dropdown-icons { display: flex; align-items: center; gap: 6px; color: #94a3b8; }
|
|
1172
|
+
.mini-clear-btn { cursor: pointer; display: flex; align-items: center; }
|
|
1173
|
+
.mini-clear-btn:hover { color: #ef4444; }
|
|
1174
|
+
/* Filter panel: fixed default size so column width is not affected */
|
|
1175
|
+
.slick-filter-row td { min-height: 40px; vertical-align: middle; }
|
|
1176
|
+
.operand-dropdown.check-list { width: 220px; min-width: 220px; max-width: 220px; max-height: 260px; overflow-y: auto; }
|
|
1177
|
+
|
|
1178
|
+
.checkbox-box { width: 16px; height: 16px; border: 1.5px solid #cbd5e1; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: #fff; transition: all 0.2s; background: #fff; }
|
|
1179
|
+
.checkbox-box.checked { background: #3b82f6; border-color: #3b82f6; }
|
|
1180
|
+
|
|
1181
|
+
.radio-circle { width: 16px; height: 16px; border: 1.5px solid #cbd5e1; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #fff; margin-right: 2px; }
|
|
1182
|
+
.radio-circle .dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; transform: scale(0); transition: transform 0.2s; }
|
|
1183
|
+
.radio-circle.checked { border-color: #3b82f6; }
|
|
1184
|
+
.radio-circle.checked .dot { background: #3b82f6; transform: scale(1); }
|
|
1185
|
+
.operand-item.active .radio-circle { border-color: #3b82f6; }
|
|
1186
|
+
.operand-item.active .radio-circle .dot { background: #3b82f6; transform: scale(1); }
|
|
1187
|
+
.filter-popup-footer { padding: 8px 12px; border-top: 1px solid #f1f5f9; display: flex; justify-content: center; }
|
|
1188
|
+
.filter-ok-btn { font-size: 13px; font-weight: 600; color: #fff; background: #0ea5e9; border: none; padding: 6px 20px; border-radius: 6px; cursor: pointer; transition: background 0.2s; }
|
|
1189
|
+
.filter-ok-btn:hover { background: #0284c7; }
|
|
1190
|
+
` })] }));
|
|
1191
|
+
}
|
|
1192
|
+
//# sourceMappingURL=SabReactTable.js.map
|