hi-tm 0.10.3 → 0.10.5
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.
|
@@ -300,72 +300,122 @@ pageIndex = 0, // Default to first page (0-indexed)
|
|
|
300
300
|
// }
|
|
301
301
|
// };
|
|
302
302
|
// Function to determine if a row has any descendants selected (not just direct children)
|
|
303
|
+
// const isIndeterminate = (rowId: number): boolean => {
|
|
304
|
+
// // Find the row in the data
|
|
305
|
+
// const findRow = (
|
|
306
|
+
// rows: TableRowData[] | undefined,
|
|
307
|
+
// id: number
|
|
308
|
+
// ): TableRowData | null => {
|
|
309
|
+
// if (!rows) return null;
|
|
310
|
+
// for (const row of rows) {
|
|
311
|
+
// if (row.id === id) return row;
|
|
312
|
+
// if (row.hasChildren && row.childRows) {
|
|
313
|
+
// const found = findRow(row.childRows, id);
|
|
314
|
+
// if (found) return found;
|
|
315
|
+
// }
|
|
316
|
+
// }
|
|
317
|
+
// return null;
|
|
318
|
+
// };
|
|
319
|
+
// const row = findRow(rows!, rowId);
|
|
320
|
+
// // If row has no children, it can't be indeterminate
|
|
321
|
+
// if (
|
|
322
|
+
// !row ||
|
|
323
|
+
// !row.hasChildren ||
|
|
324
|
+
// !row.childRows ||
|
|
325
|
+
// row.childRows.length === 0
|
|
326
|
+
// ) {
|
|
327
|
+
// return false;
|
|
328
|
+
// }
|
|
329
|
+
// // Check if the row itself is selected
|
|
330
|
+
// const isRowSelected = selectedRows.includes(rowId);
|
|
331
|
+
// // Recursively check if any descendant is selected
|
|
332
|
+
// const hasSelectedDescendant = (children: TableRowData[]): boolean => {
|
|
333
|
+
// for (const child of children) {
|
|
334
|
+
// // If any child is selected
|
|
335
|
+
// if (selectedRows.includes(child.id)) {
|
|
336
|
+
// return true;
|
|
337
|
+
// }
|
|
338
|
+
// // Check grandchildren if they exist
|
|
339
|
+
// if (
|
|
340
|
+
// child.hasChildren &&
|
|
341
|
+
// child.childRows &&
|
|
342
|
+
// child.childRows.length > 0
|
|
343
|
+
// ) {
|
|
344
|
+
// if (hasSelectedDescendant(child.childRows)) {
|
|
345
|
+
// return true;
|
|
346
|
+
// }
|
|
347
|
+
// }
|
|
348
|
+
// }
|
|
349
|
+
// return false;
|
|
350
|
+
// };
|
|
351
|
+
// // Check if all descendants are selected
|
|
352
|
+
// const areAllDescendantsSelected = (children: TableRowData[]): boolean => {
|
|
353
|
+
// for (const child of children) {
|
|
354
|
+
// // If any child is not selected
|
|
355
|
+
// if (!selectedRows.includes(child.id)) {
|
|
356
|
+
// return false;
|
|
357
|
+
// }
|
|
358
|
+
// // Check grandchildren if they exist
|
|
359
|
+
// if (
|
|
360
|
+
// child.hasChildren &&
|
|
361
|
+
// child.childRows &&
|
|
362
|
+
// child.childRows.length > 0
|
|
363
|
+
// ) {
|
|
364
|
+
// if (!areAllDescendantsSelected(child.childRows)) {
|
|
365
|
+
// return false;
|
|
366
|
+
// }
|
|
367
|
+
// }
|
|
368
|
+
// }
|
|
369
|
+
// return true;
|
|
370
|
+
// };
|
|
371
|
+
// const hasAnySelected = hasSelectedDescendant(row.childRows);
|
|
372
|
+
// const hasAllSelected = areAllDescendantsSelected(row.childRows);
|
|
373
|
+
// // Indeterminate if some but not all descendants are selected
|
|
374
|
+
// // Or if the parent is not selected but some children are
|
|
375
|
+
// return (
|
|
376
|
+
// (hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected)
|
|
377
|
+
// );
|
|
378
|
+
// };
|
|
303
379
|
const isIndeterminate = (rowId) => {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
380
|
+
if (!rows || rows.length === 0)
|
|
381
|
+
return false;
|
|
382
|
+
// یک Map برای دسترسی سریع به ردیفها (اگر میخوای میتونی قبل از render بسازی)
|
|
383
|
+
const rowMap = new Map();
|
|
384
|
+
const buildRowMap = (rows) => {
|
|
308
385
|
for (const row of rows) {
|
|
309
|
-
|
|
310
|
-
return row;
|
|
386
|
+
rowMap.set(row.id, row);
|
|
311
387
|
if (row.hasChildren && row.childRows) {
|
|
312
|
-
|
|
313
|
-
if (found)
|
|
314
|
-
return found;
|
|
388
|
+
buildRowMap(row.childRows);
|
|
315
389
|
}
|
|
316
390
|
}
|
|
317
|
-
return null;
|
|
318
391
|
};
|
|
319
|
-
|
|
320
|
-
|
|
392
|
+
buildRowMap(rows);
|
|
393
|
+
const row = rowMap.get(rowId);
|
|
321
394
|
if (!row ||
|
|
322
395
|
!row.hasChildren ||
|
|
323
396
|
!row.childRows ||
|
|
324
397
|
row.childRows.length === 0) {
|
|
325
|
-
return false;
|
|
398
|
+
return false; // اگر child ندارد
|
|
326
399
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
// Check grandchildren if they exist
|
|
337
|
-
if (child.hasChildren &&
|
|
338
|
-
child.childRows &&
|
|
339
|
-
child.childRows.length > 0) {
|
|
340
|
-
if (hasSelectedDescendant(child.childRows)) {
|
|
341
|
-
return true;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
400
|
+
const selectedSet = new Set(selectedRows); // lookup سریع
|
|
401
|
+
let hasAnySelected = false;
|
|
402
|
+
let hasAllSelected = true;
|
|
403
|
+
const stack = [...row.childRows];
|
|
404
|
+
while (stack.length > 0) {
|
|
405
|
+
const current = stack.pop();
|
|
406
|
+
if (selectedSet.has(current.id)) {
|
|
407
|
+
hasAnySelected = true;
|
|
344
408
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
// Check if all descendants are selected
|
|
348
|
-
const areAllDescendantsSelected = (children) => {
|
|
349
|
-
for (const child of children) {
|
|
350
|
-
// If any child is not selected
|
|
351
|
-
if (!selectedRows.includes(child.id)) {
|
|
352
|
-
return false;
|
|
353
|
-
}
|
|
354
|
-
// Check grandchildren if they exist
|
|
355
|
-
if (child.hasChildren &&
|
|
356
|
-
child.childRows &&
|
|
357
|
-
child.childRows.length > 0) {
|
|
358
|
-
if (!areAllDescendantsSelected(child.childRows)) {
|
|
359
|
-
return false;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
409
|
+
else {
|
|
410
|
+
hasAllSelected = false;
|
|
362
411
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
412
|
+
if (current.hasChildren &&
|
|
413
|
+
current.childRows &&
|
|
414
|
+
current.childRows.length > 0) {
|
|
415
|
+
stack.push(...current.childRows);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
const isRowSelected = selectedSet.has(rowId);
|
|
369
419
|
return ((hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected));
|
|
370
420
|
};
|
|
371
421
|
// Function to check if a row is selected
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from "react";
|
|
2
2
|
export interface CustomColumnStyle extends React.CSSProperties {
|
|
3
3
|
width?: string | number;
|
|
4
|
-
textAlign?:
|
|
4
|
+
textAlign?: "left" | "center" | "right";
|
|
5
5
|
flex?: string;
|
|
6
6
|
padding?: string;
|
|
7
7
|
margin?: string;
|
|
8
8
|
backgroundColor?: string;
|
|
9
|
-
justifyContent?:
|
|
10
|
-
alignItems?:
|
|
11
|
-
position?:
|
|
9
|
+
justifyContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "end" | "start";
|
|
10
|
+
alignItems?: "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
|
|
11
|
+
position?: "static" | "relative" | "absolute" | "fixed" | "sticky";
|
|
12
12
|
}
|
|
13
13
|
interface BaseModalFilterData {
|
|
14
14
|
id: number;
|
|
15
15
|
name: string;
|
|
16
16
|
content: string;
|
|
17
|
-
type?:
|
|
17
|
+
type?: "pin" | "sort" | "filter";
|
|
18
18
|
FilterIcon?: React.ComponentType<any> | string | React.ReactNode;
|
|
19
19
|
iconTailwindStyle?: string;
|
|
20
20
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
"use client";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -57,15 +57,17 @@ const ModernTableHeader = ({ columns = [], sortIcon, hasSelect = false, hasCheck
|
|
|
57
57
|
onSelectAllClick?.(newCheckedState);
|
|
58
58
|
};
|
|
59
59
|
const totalColumns = columns?.length || 0;
|
|
60
|
-
const columnsWithWidth = columns?.filter((col) => col.inlineCss &&
|
|
60
|
+
const columnsWithWidth = columns?.filter((col) => col.inlineCss && "width" in (col.inlineCss || {})) || [];
|
|
61
61
|
const totalDefinedWidth = columnsWithWidth.reduce((acc, col) => {
|
|
62
62
|
if (!col.inlineCss?.width)
|
|
63
63
|
return acc;
|
|
64
64
|
const width = col.inlineCss.width;
|
|
65
|
-
return acc + (typeof width ===
|
|
65
|
+
return acc + (typeof width === "string" ? Number.parseInt(width) : width);
|
|
66
66
|
}, 0);
|
|
67
67
|
const remainingColumns = totalColumns - columnsWithWidth.length;
|
|
68
|
-
const remainingWidth = remainingColumns > 0
|
|
68
|
+
const remainingWidth = remainingColumns > 0
|
|
69
|
+
? `${(100 - totalDefinedWidth) / remainingColumns}%`
|
|
70
|
+
: "auto";
|
|
69
71
|
const handleColumnClick = (name, id) => {
|
|
70
72
|
if (onClickHandlerColumn) {
|
|
71
73
|
onClickHandlerColumn({ name, id });
|
|
@@ -127,14 +129,14 @@ const ModernTableHeader = ({ columns = [], sortIcon, hasSelect = false, hasCheck
|
|
|
127
129
|
}
|
|
128
130
|
// For backward compatibility, infer type from name if not explicitly provided
|
|
129
131
|
let inferredType;
|
|
130
|
-
if (filterItem.name?.includes(
|
|
131
|
-
inferredType =
|
|
132
|
+
if (filterItem.name?.includes("sort_")) {
|
|
133
|
+
inferredType = "sort";
|
|
132
134
|
}
|
|
133
|
-
else if (filterItem.name?.includes(
|
|
134
|
-
inferredType =
|
|
135
|
+
else if (filterItem.name?.includes("pin_")) {
|
|
136
|
+
inferredType = "pin";
|
|
135
137
|
}
|
|
136
|
-
else if (filterItem.name?.includes(
|
|
137
|
-
inferredType =
|
|
138
|
+
else if (filterItem.name?.includes("filter")) {
|
|
139
|
+
inferredType = "filter";
|
|
138
140
|
}
|
|
139
141
|
return { ...filterItem, type: inferredType };
|
|
140
142
|
});
|
|
@@ -145,9 +147,9 @@ const ModernTableHeader = ({ columns = [], sortIcon, hasSelect = false, hasCheck
|
|
|
145
147
|
(sortOrder[b.type] || 4));
|
|
146
148
|
});
|
|
147
149
|
// Group by type
|
|
148
|
-
const sortingItems = typedFilterData.filter((filterItem) => filterItem.type ===
|
|
149
|
-
const pinItems = typedFilterData.filter((filterItem) => filterItem.type ===
|
|
150
|
-
const filterItems = typedFilterData.filter((filterItem) => filterItem.type ===
|
|
150
|
+
const sortingItems = typedFilterData.filter((filterItem) => filterItem.type === "sort");
|
|
151
|
+
const pinItems = typedFilterData.filter((filterItem) => filterItem.type === "pin");
|
|
152
|
+
const filterItems = typedFilterData.filter((filterItem) => filterItem.type === "filter");
|
|
151
153
|
return {
|
|
152
154
|
sortingSection: sortingItems.length > 0 ? sortingItems : undefined,
|
|
153
155
|
pinSection: pinItems.length > 0 ? pinItems : undefined,
|
|
@@ -165,15 +167,15 @@ const ModernTableHeader = ({ columns = [], sortIcon, hasSelect = false, hasCheck
|
|
|
165
167
|
}
|
|
166
168
|
setIsFilterClicked(false);
|
|
167
169
|
};
|
|
168
|
-
document.addEventListener(
|
|
170
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
169
171
|
return () => {
|
|
170
|
-
document.removeEventListener(
|
|
172
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
171
173
|
};
|
|
172
174
|
}, [isFilterClicked]);
|
|
173
|
-
return (react_1.default.createElement("div", { className: `group ${containerClassName ? containerClassName :
|
|
175
|
+
return (react_1.default.createElement("div", { className: `group ${containerClassName ? containerClassName : ""} max-lg:hidden grid w-full border-b border-t border-black/15 `, style: {
|
|
174
176
|
gridTemplateColumns: isMobileView && mobileViewGridClassName
|
|
175
177
|
? mobileViewGridClassName
|
|
176
|
-
: gridClassName ||
|
|
178
|
+
: gridClassName || "repeat(auto-fit, minmax(100px, 1fr))",
|
|
177
179
|
} },
|
|
178
180
|
react_1.default.createElement("div", { className: "relative flex items-center justify-center gap-2 w-14 mr-[-10px]" },
|
|
179
181
|
react_1.default.createElement("p", { className: "w-6 text-center flex items-center justify-center opacity-50 mr-3" }, "#"),
|
|
@@ -184,19 +186,27 @@ const ModernTableHeader = ({ columns = [], sortIcon, hasSelect = false, hasCheck
|
|
|
184
186
|
hasSelect && (react_1.default.createElement("div", { className: `ml-2 mr-5 flex h-14 w-14 cursor-pointer items-center justify-center rounded-sm` })),
|
|
185
187
|
columns.map((item) => {
|
|
186
188
|
const columnStyle = {
|
|
187
|
-
flex:
|
|
188
|
-
textAlign: item.inlineCss?.textAlign ||
|
|
189
|
+
flex: "1 1 0",
|
|
190
|
+
textAlign: item.inlineCss?.textAlign || "left",
|
|
189
191
|
};
|
|
190
192
|
// Organize modalFilterData into sections if filterSections is not provided
|
|
191
|
-
const organizedSections = !item.filterSections && item.modalFilterData
|
|
193
|
+
const organizedSections = !item.filterSections && item.modalFilterData
|
|
194
|
+
? organizeFilterData(item)
|
|
195
|
+
: null;
|
|
192
196
|
return (react_1.default.createElement(react_1.default.Fragment, { key: item.id },
|
|
193
197
|
react_1.default.createElement("div", { className: `flex items-center h-14 select-none text-sm font-medium text-gray-700 justify-center`, style: {
|
|
194
198
|
...item.inlineCss,
|
|
195
199
|
} },
|
|
196
|
-
item.hasFilter && (react_1.default.createElement("div", { ref: filterIconRef, onClick: (event) => item.hasFilter && handleFilterIconClick(event, item.id), className: `group mr-2 transition-all duration-300 ease-in-out ${item.hasFilter
|
|
200
|
+
item.hasFilter && (react_1.default.createElement("div", { ref: filterIconRef, onClick: (event) => item.hasFilter && handleFilterIconClick(event, item.id), className: `group mr-2 transition-all duration-300 ease-in-out ${item.hasFilter
|
|
201
|
+
? "cursor-pointer opacity-100 hover:scale-105"
|
|
202
|
+
: "opacity-0"}` }, FilterIcon ? (typeof FilterIcon === "string" ? (react_1.default.createElement(image_1.default, { src: FilterIcon || "/placeholder.svg", alt: "filter", width: 16, height: 16 })) : react_1.default.isValidElement(FilterIcon) ? (FilterIcon) : typeof FilterIcon === "function" ? (react_1.default.createElement(FilterIcon)) : (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "size-4 hover:fill-current hover:opacity-50" },
|
|
197
203
|
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M3.75 6.75h16.5M6.75 12h10.5M8.75 17.25h6.5" })))) : (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "size-4 hover:fill-current hover:opacity-50" },
|
|
198
204
|
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M3.75 6.75h16.5M6.75 12h10.5M8.75 17.25h6.5" }))))),
|
|
199
|
-
react_1.default.createElement("div", { onClick: () => item.hasSort &&
|
|
205
|
+
react_1.default.createElement("div", { onClick: () => item.hasSort &&
|
|
206
|
+
item.name &&
|
|
207
|
+
handleColumnClick(item.name, item.id), className: `transition-all relative text-nowrap ${item.hasSort
|
|
208
|
+
? "cursor-pointer hover:text-black "
|
|
209
|
+
: "cursor-default"}` },
|
|
200
210
|
item.content,
|
|
201
211
|
item.modalFilterData &&
|
|
202
212
|
item.modalFilterData.length > 0 &&
|
|
@@ -219,19 +229,28 @@ const ModernTableHeader = ({ columns = [], sortIcon, hasSelect = false, hasCheck
|
|
|
219
229
|
content: sortingItem.content,
|
|
220
230
|
});
|
|
221
231
|
}
|
|
222
|
-
}, className: `cursor-pointer py-[10px] px-[10px] text-sm text-gray-700 flex items-center justify-between hover:bg-gray-100 ${checkedSorting[sortingItem.id]
|
|
232
|
+
}, className: `cursor-pointer py-[10px] px-[10px] text-sm text-gray-700 flex items-center justify-between hover:bg-gray-100 ${checkedSorting[sortingItem.id]
|
|
233
|
+
? "bg-gray-200"
|
|
234
|
+
: ""}` },
|
|
223
235
|
react_1.default.createElement("div", { className: "flex items-center gap-2" },
|
|
224
|
-
sortingItem.FilterIcon ? (typeof sortingItem.FilterIcon ===
|
|
236
|
+
sortingItem.FilterIcon ? (typeof sortingItem.FilterIcon ===
|
|
237
|
+
"string" ? (react_1.default.createElement(image_1.default, { src: sortingItem.FilterIcon ||
|
|
238
|
+
"/placeholder.svg", alt: "sort icon", width: 16, height: 16, className: `mr-2 ${sortingItem.iconTailwindStyle}` })) : react_1.default.isValidElement(sortingItem.FilterIcon) ? (react_1.default.createElement("span", { className: `mr-2 ${sortingItem.iconTailwindStyle}` }, sortingItem.FilterIcon)) : typeof sortingItem.FilterIcon ===
|
|
239
|
+
"function" ? (react_1.default.createElement("span", { className: `mr-2 ${sortingItem.iconTailwindStyle}` }, react_1.default.createElement(sortingItem.FilterIcon))) : null) : null,
|
|
225
240
|
react_1.default.createElement("span", null, sortingItem.content)),
|
|
226
241
|
checkedSorting[sortingItem.id] &&
|
|
227
242
|
sortingItem.CheckedIcon &&
|
|
228
|
-
(typeof sortingItem.CheckedIcon ===
|
|
243
|
+
(typeof sortingItem.CheckedIcon ===
|
|
244
|
+
"string" ? (react_1.default.createElement(image_1.default, { src: sortingItem.CheckedIcon ||
|
|
245
|
+
"/placeholder.svg", alt: "checked", width: 16, height: 16 })) : react_1.default.isValidElement(sortingItem.CheckedIcon) ? (sortingItem.CheckedIcon) : typeof sortingItem.CheckedIcon ===
|
|
246
|
+
"function" ? (react_1.default.createElement(sortingItem.CheckedIcon)) : (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "size-4 hover:fill-current hover:opacity-50" },
|
|
229
247
|
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 12.75l6 6 9-13.5" }))))))))),
|
|
230
248
|
organizedSections?.sortingSection &&
|
|
231
249
|
organizedSections.sortingSection.length > 0 &&
|
|
232
250
|
organizedSections?.pinSection &&
|
|
233
251
|
organizedSections.pinSection.length > 0 && (react_1.default.createElement("div", { className: "border-t border-gray-200 my-1" })),
|
|
234
|
-
organizedSections?.pinSection &&
|
|
252
|
+
organizedSections?.pinSection &&
|
|
253
|
+
organizedSections.pinSection.length > 0 && (react_1.default.createElement("div", { className: "pin-section" }, organizedSections.pinSection.map((pinItem) => (react_1.default.createElement("div", { key: pinItem.id, onClick: (event) => {
|
|
235
254
|
event.stopPropagation();
|
|
236
255
|
handlePinItemClick(pinItem.id, pinItem.name, pinItem.content);
|
|
237
256
|
if (filterHandler) {
|
|
@@ -248,13 +267,17 @@ const ModernTableHeader = ({ columns = [], sortIcon, hasSelect = false, hasCheck
|
|
|
248
267
|
content: pinItem.content,
|
|
249
268
|
});
|
|
250
269
|
}
|
|
251
|
-
}, className: `cursor-pointer py-[10px] px-[10px] text-sm text-gray-700 flex items-center justify-between hover:bg-gray-100 ${checkedPins[pinItem.id] ?
|
|
270
|
+
}, className: `cursor-pointer py-[10px] px-[10px] text-sm text-gray-700 flex items-center justify-between hover:bg-gray-100 ${checkedPins[pinItem.id] ? "bg-gray-200" : ""}` },
|
|
252
271
|
react_1.default.createElement("div", { className: "flex items-center gap-2" },
|
|
253
|
-
pinItem.FilterIcon ? (typeof pinItem.FilterIcon ===
|
|
272
|
+
pinItem.FilterIcon ? (typeof pinItem.FilterIcon === "string" ? (react_1.default.createElement(image_1.default, { src: pinItem.FilterIcon ||
|
|
273
|
+
"/placeholder.svg", alt: "pin icon", width: 16, height: 16, className: `mr-2 ${pinItem.iconTailwindStyle}` })) : react_1.default.isValidElement(pinItem.FilterIcon) ? (react_1.default.createElement("span", { className: `mr-2 ${pinItem.iconTailwindStyle}` }, pinItem.FilterIcon)) : typeof pinItem.FilterIcon ===
|
|
274
|
+
"function" ? (react_1.default.createElement("span", { className: `mr-2 ${pinItem.iconTailwindStyle}` }, react_1.default.createElement(pinItem.FilterIcon))) : null) : null,
|
|
254
275
|
react_1.default.createElement("span", null, pinItem.content)),
|
|
255
276
|
checkedPins[pinItem.id] &&
|
|
256
277
|
pinItem.CheckedIcon &&
|
|
257
|
-
(typeof pinItem.CheckedIcon ===
|
|
278
|
+
(typeof pinItem.CheckedIcon === "string" ? (react_1.default.createElement(image_1.default, { src: pinItem.CheckedIcon ||
|
|
279
|
+
"/placeholder.svg", alt: "checked", width: 16, height: 16 })) : react_1.default.isValidElement(pinItem.CheckedIcon) ? (pinItem.CheckedIcon) : typeof pinItem.CheckedIcon ===
|
|
280
|
+
"function" ? (react_1.default.createElement(pinItem.CheckedIcon)) : (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "size-4 hover:fill-current hover:opacity-50" },
|
|
258
281
|
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 12.75l6 6 9-13.5" }))))))))),
|
|
259
282
|
((organizedSections?.sortingSection &&
|
|
260
283
|
organizedSections.sortingSection.length > 0) ||
|
|
@@ -268,26 +291,30 @@ const ModernTableHeader = ({ columns = [], sortIcon, hasSelect = false, hasCheck
|
|
|
268
291
|
if (filterHandler) {
|
|
269
292
|
filterHandler({
|
|
270
293
|
id: organizedSections.filterSection?.id ?? 0,
|
|
271
|
-
content: organizedSections.filterSection?.content ??
|
|
272
|
-
|
|
294
|
+
content: organizedSections.filterSection?.content ??
|
|
295
|
+
"",
|
|
296
|
+
name: organizedSections.filterSection?.name ?? "",
|
|
273
297
|
});
|
|
274
298
|
}
|
|
275
299
|
if (onFilterClick) {
|
|
276
300
|
onFilterClick({
|
|
277
301
|
id: organizedSections.filterSection?.id ?? 0,
|
|
278
|
-
name: organizedSections.filterSection?.name ??
|
|
279
|
-
content: organizedSections.filterSection?.content ??
|
|
302
|
+
name: organizedSections.filterSection?.name ?? "",
|
|
303
|
+
content: organizedSections.filterSection?.content ??
|
|
304
|
+
"",
|
|
280
305
|
});
|
|
281
306
|
}
|
|
282
307
|
}, className: "cursor-pointer py-[10px] px-[10px] text-sm text-gray-700 flex items-center justify-between hover:bg-gray-100" },
|
|
283
308
|
react_1.default.createElement("div", { className: "flex items-center gap-2" },
|
|
284
|
-
organizedSections.filterSection.FilterIcon ? (typeof organizedSections.filterSection
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
309
|
+
organizedSections.filterSection.FilterIcon ? (typeof organizedSections.filterSection
|
|
310
|
+
.FilterIcon === "string" ? (react_1.default.createElement(image_1.default, { src: organizedSections.filterSection
|
|
311
|
+
.FilterIcon ||
|
|
312
|
+
"/placeholder.svg" ||
|
|
313
|
+
"/placeholder.svg" ||
|
|
314
|
+
"/placeholder.svg" ||
|
|
315
|
+
"/placeholder.svg" ||
|
|
316
|
+
"/placeholder.svg", alt: "filter icon", width: 16, height: 16, className: `mr-2 ${organizedSections.filterSection.iconTailwindStyle}` })) : react_1.default.isValidElement(organizedSections.filterSection.FilterIcon) ? (react_1.default.createElement("span", { className: `mr-2 ${organizedSections.filterSection.iconTailwindStyle}` }, organizedSections.filterSection.FilterIcon)) : typeof organizedSections.filterSection
|
|
317
|
+
.FilterIcon === "function" ? (react_1.default.createElement("span", { className: `mr-2 ${organizedSections.filterSection.iconTailwindStyle}` }, react_1.default.createElement(organizedSections.filterSection
|
|
291
318
|
.FilterIcon))) : (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "size-4 mr-2" },
|
|
292
319
|
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 01-.659 1.591l-5.432 5.432a2.25 2.25 0 00-.659 1.591v2.927a2.25 2.25 0 01-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 00-.659-1.591L3.659 7.409A2.25 2.25 0 013 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0112 3z" })))) : (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "size-4 mr-2" },
|
|
293
320
|
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 01-.659 1.591l-5.432 5.432a2.25 2.25 0 00-.659 1.591v2.927a2.25 2.25 0 01-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 00-.659-1.591L3.659 7.409A2.25 2.25 0 013 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0112 3z" }))),
|
|
@@ -310,17 +337,20 @@ const ModernTableHeader = ({ columns = [], sortIcon, hasSelect = false, hasCheck
|
|
|
310
337
|
content: filterItem.content,
|
|
311
338
|
});
|
|
312
339
|
}
|
|
313
|
-
}, className: `cursor-pointer py-[10px] px-[10px] text-sm text-gray-700 flex items-center justify-between hover:bg-gray-100 ${checkedFilters[filterItem.id] ?
|
|
340
|
+
}, className: `cursor-pointer py-[10px] px-[10px] text-sm text-gray-700 flex items-center justify-between hover:bg-gray-100 ${checkedFilters[filterItem.id] ? "bg-gray-200" : ""}` },
|
|
314
341
|
react_1.default.createElement("div", { className: "flex items-center gap-2" },
|
|
315
|
-
filterItem.FilterIcon ? (typeof filterItem.FilterIcon ===
|
|
342
|
+
filterItem.FilterIcon ? (typeof filterItem.FilterIcon === "string" ? (react_1.default.createElement(image_1.default, { src: filterItem.FilterIcon ||
|
|
343
|
+
"/placeholder.svg", alt: "filter icon", width: 16, height: 16, className: `mr-2 ${filterItem.iconTailwindStyle}` })) : react_1.default.isValidElement(filterItem.FilterIcon) ? (react_1.default.createElement("span", { className: `mr-2 ${filterItem.iconTailwindStyle}` }, filterItem.FilterIcon)) : typeof filterItem.FilterIcon ===
|
|
344
|
+
"function" ? (react_1.default.createElement("span", { className: `mr-2 ${filterItem.iconTailwindStyle}` }, react_1.default.createElement(filterItem.FilterIcon))) : null) : null,
|
|
316
345
|
react_1.default.createElement("span", null, filterItem.content)),
|
|
317
346
|
item.hasFilter &&
|
|
318
347
|
checkedFilters[filterItem.id] &&
|
|
319
348
|
filterItem.CheckedIcon &&
|
|
320
|
-
(typeof filterItem.CheckedIcon ===
|
|
349
|
+
(typeof filterItem.CheckedIcon === "string" ? (react_1.default.createElement(image_1.default, { src: filterItem.CheckedIcon || "/placeholder.svg", alt: "checked", width: 16, height: 16 })) : react_1.default.isValidElement(filterItem.CheckedIcon) ? (filterItem.CheckedIcon) : typeof filterItem.CheckedIcon ===
|
|
350
|
+
"function" ? (react_1.default.createElement(filterItem.CheckedIcon)) : (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "size-4 hover:fill-current hover:opacity-50" },
|
|
321
351
|
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 12.75l6 6 9-13.5" })))))))))),
|
|
322
|
-
item.hasSort && (react_1.default.createElement("div", { className: `ml-1 transition-all duration-300 ease-in-out ${arrowDir && clickedColumn === item.name ?
|
|
323
|
-
react_1.default.createElement(image_1.default, { src: sortIcon ||
|
|
352
|
+
item.hasSort && (react_1.default.createElement("div", { className: `ml-1 transition-all duration-300 ease-in-out ${arrowDir && clickedColumn === item.name ? "rotate-180" : ""} ${clickedColumn === item.name ? "opacity-100" : "opacity-0"}` },
|
|
353
|
+
react_1.default.createElement(image_1.default, { src: sortIcon || "/placeholder.svg", alt: "sortIcon", width: 12, height: 12 }))))));
|
|
324
354
|
})));
|
|
325
355
|
};
|
|
326
356
|
exports.default = ModernTableHeader;
|