hi-tm 0.11.9 → 0.12.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.
@@ -1,11 +1,43 @@
1
1
  "use strict";
2
2
  "use client";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
3
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
38
  };
6
39
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const react_1 = __importDefault(require("react"));
8
- const react_2 = require("react");
40
+ const react_1 = __importStar(require("react"));
9
41
  const image_1 = __importDefault(require("next/image"));
10
42
  const SafeImage_1 = __importDefault(require("../../../elements/SafeImage"));
11
43
  // Simple Loader component defined inline to avoid import issues
@@ -68,62 +100,89 @@ mobileViewGridClassName, itemsPerPage = 10, // Default to 10 items per page
68
100
  pageIndex = 0, // Default to first page (0-indexed)
69
101
  }) => {
70
102
  // Track which rows are expanded to show their children
71
- const [expandedRows, setExpandedRows] = (0, react_2.useState)([]);
72
- const [activeModal, setActiveModal] = (0, react_2.useState)(null);
73
- const modalRef = (0, react_2.useRef)(null);
103
+ const [expandedRows, setExpandedRows] = (0, react_1.useState)([]);
104
+ const [activeModal, setActiveModal] = (0, react_1.useState)(null);
105
+ const modalRef = (0, react_1.useRef)(null);
74
106
  // Store calculated column widths
75
- const [selectedRows, setSelectedRows] = (0, react_2.useState)(selectedItems || []);
76
- // Calculate and store column widths based on all rows (parents and children)
77
- (0, react_2.useEffect)(() => {
78
- // if (!rows || rows.length === 0) return;
79
- // Get all rows including children
80
- const allRows = [];
81
- // Helper function to recursively collect all rows at any depth
82
- const collectRows = (rowsArray, level = 0) => {
83
- rowsArray?.forEach((row) => {
84
- // Add level information to the row for proper indentation
85
- const rowWithLevel = { ...row, level };
86
- allRows.push(rowWithLevel);
87
- // Recursively process children at any depth
88
- if (row.hasChildren && row.childRows && row.childRows.length > 0) {
89
- collectRows(row.childRows, level + 1);
107
+ const [selectedRows, setSelectedRows] = (0, react_1.useState)(selectedItems || []);
108
+ const [mousePosition, setMousePosition] = (0, react_1.useState)({ x: 0, y: 0 });
109
+ // --- Optimized Maps ---
110
+ const { rowsMap, descendantsMap } = (0, react_1.useMemo)(() => {
111
+ const rowsMap = new Map();
112
+ const descendantsMap = new Map();
113
+ const buildMaps = (rows) => {
114
+ rows?.forEach((row) => {
115
+ rowsMap.set(row.id, row);
116
+ const descendantIds = [];
117
+ const collectDescendants = (children) => {
118
+ children.forEach((child) => {
119
+ descendantIds.push(child.id);
120
+ if (child.hasChildren && child.childRows) {
121
+ collectDescendants(child.childRows);
122
+ }
123
+ });
124
+ };
125
+ if (row.hasChildren && row.childRows) {
126
+ collectDescendants(row.childRows);
90
127
  }
128
+ descendantsMap.set(row.id, descendantIds);
91
129
  });
92
130
  };
93
- if (rows) {
94
- collectRows(rows);
131
+ buildMaps(rows);
132
+ return { rowsMap, descendantsMap };
133
+ }, [rows]);
134
+ // --- Optimized Functions ---
135
+ const findRowById = (id) => {
136
+ return rowsMap.get(id) || null;
137
+ };
138
+ const getAllDescendantIds = (id) => {
139
+ return descendantsMap.get(id) || [];
140
+ };
141
+ const isSelected = (rowId) => {
142
+ return selectedRows.includes(rowId);
143
+ };
144
+ const isIndeterminate = (rowId) => {
145
+ const row = rowsMap.get(rowId);
146
+ if (!row || !row.hasChildren || !descendantsMap.has(rowId)) {
147
+ return false;
95
148
  }
96
- // Find the maximum number of columns
97
- const maxColumns = Math.max(...allRows.map((row) => (row.data ? row.data.length : 0)));
98
- // Calculate the width for each column
99
- const widths = [];
100
- for (let colIndex = 0; colIndex < maxColumns; colIndex++) {
101
- // Check if any row has a defined width for this column
102
- const columnsWithWidth = allRows
103
- .filter((row) => row.data &&
104
- row.data[colIndex] &&
105
- row.data[colIndex].inlineCSS &&
106
- "width" in (row.data[colIndex].inlineCSS || {}))
107
- .map((row) => row.data[colIndex]);
108
- if (columnsWithWidth.length > 0) {
109
- // Use the first defined width (could be enhanced to use max/average)
110
- const firstWidth = columnsWithWidth[0].inlineCSS?.width;
111
- if (firstWidth) {
112
- widths[colIndex] =
113
- typeof firstWidth === "string" ? firstWidth : `${firstWidth}px`;
114
- }
115
- else {
116
- widths[colIndex] = "auto";
117
- }
118
- }
119
- else {
120
- // If no defined width, set a responsive width
121
- widths[colIndex] = `${100 / maxColumns}%`;
122
- }
149
+ const descendantIds = descendantsMap.get(rowId) || [];
150
+ const isRowSelected = selectedRows.includes(rowId);
151
+ const hasAnySelected = descendantIds.some((id) => selectedRows.includes(id));
152
+ const hasAllSelected = descendantIds.every((id) => selectedRows.includes(id));
153
+ return ((hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected));
154
+ };
155
+ (0, react_1.useEffect)(() => {
156
+ console.time("isIndeterminate-all-rows"); // شروع اندازه‌گیری زمان کل
157
+ // اجرای تابع برای همه رکوردها
158
+ rows?.forEach((row) => {
159
+ isIndeterminate(row.id);
160
+ });
161
+ console.timeEnd("isIndeterminate-all-rows"); // پایان اندازه‌گیری زمان کل
162
+ }, [rows, selectedRows]); // وابستگی‌ها: تغییر در داده‌ها یا انتخاب‌ها
163
+ const handleCheckboxChange = (id) => {
164
+ const row = findRowById(id);
165
+ if (!row)
166
+ return;
167
+ const descendantIds = getAllDescendantIds(id);
168
+ const updatedSelection = [...selectedRows];
169
+ if (selectedRows.includes(id)) {
170
+ const idsToRemove = [id, ...descendantIds];
171
+ setSelectedRows(updatedSelection.filter((itemId) => !idsToRemove.includes(itemId)));
123
172
  }
124
- }, [rows]);
125
- // Initialize expanded rows if specified in config
126
- (0, react_2.useEffect)(() => {
173
+ else {
174
+ const idsToAdd = [id, ...descendantIds];
175
+ setSelectedRows([
176
+ ...updatedSelection,
177
+ ...idsToAdd.filter((i) => !updatedSelection.includes(i)),
178
+ ]);
179
+ }
180
+ if (onSelectionChange) {
181
+ onSelectionChange(id);
182
+ }
183
+ };
184
+ // --- Effects ---
185
+ (0, react_1.useEffect)(() => {
127
186
  if (childRowConfig.expandByDefault && rows) {
128
187
  const parentIds = rows
129
188
  .filter((row) => row.hasChildren && row.childRows && row.childRows.length > 0)
@@ -131,7 +190,7 @@ pageIndex = 0, // Default to first page (0-indexed)
131
190
  setExpandedRows(parentIds);
132
191
  }
133
192
  }, [rows, childRowConfig.expandByDefault]);
134
- (0, react_2.useEffect)(() => {
193
+ (0, react_1.useEffect)(() => {
135
194
  const handleClickOutside = (event) => {
136
195
  const target = event.target;
137
196
  if (target.closest(".modal-content")) {
@@ -147,7 +206,7 @@ pageIndex = 0, // Default to first page (0-indexed)
147
206
  document.removeEventListener("mousedown", handleClickOutside);
148
207
  };
149
208
  }, []);
150
- (0, react_2.useEffect)(() => {
209
+ (0, react_1.useEffect)(() => {
151
210
  const handleScroll = () => {
152
211
  if (activeModal !== null) {
153
212
  setActiveModal(null);
@@ -158,7 +217,10 @@ pageIndex = 0, // Default to first page (0-indexed)
158
217
  window.removeEventListener("scroll", handleScroll);
159
218
  };
160
219
  }, [activeModal]);
161
- const [mousePosition, setMousePosition] = (0, react_2.useState)({ x: 0, y: 0 });
220
+ (0, react_1.useEffect)(() => {
221
+ setSelectedRows(selectedItems || []);
222
+ }, [selectedItems]);
223
+ // --- Handlers ---
162
224
  const handleModalToggle = (id, e) => {
163
225
  e.stopPropagation();
164
226
  e.preventDefault();
@@ -214,223 +276,6 @@ pageIndex = 0, // Default to first page (0-indexed)
214
276
  react_1.default.createElement("p", { className: `${item.contentClass || "text-start"} text-sm w-full truncate ` }, item.value))) : (react_1.default.createElement("p", { className: `${item.contentClass || "text-start"} text-sm mr-[5px] w-full truncate`, title: item.value?.toString() || "" }, item.value))));
215
277
  }
216
278
  };
217
- // Update selectedRows when selectedItems prop changes
218
- (0, react_2.useEffect)(() => {
219
- setSelectedRows(selectedItems || []);
220
- }, [selectedItems]);
221
- // Handle checkbox change for row selection
222
- // const handleCheckboxChange = (id: number) => {
223
- // console.log(`Processing ID: ${id}`);
224
- // // Create a new copy of the current selection
225
- // let updatedSelection = [...selectedRows];
226
- // // Check if the row is currently selected
227
- // const isSelected = updatedSelection.includes(id);
228
- // console.log(`ID ${id} is currently selected: ${isSelected}`);
229
- // // Find the item in the rows data
230
- // const findItemById = (items: TableRowData[] | undefined, itemId: number): TableRowData | null => {
231
- // if (!items) return null;
232
- // for (const item of items) {
233
- // if (item.id === itemId) {
234
- // return item;
235
- // }
236
- // if (item.hasChildren && item.childRows && item.childRows.length > 0) {
237
- // const foundInChildren = findItemById(item.childRows, itemId);
238
- // if (foundInChildren) return foundInChildren;
239
- // }
240
- // }
241
- // return null;
242
- // };
243
- // const item = findItemById(rows!, id);
244
- // console.log(`Found item for ID ${id}:`, item);
245
- // if (isSelected) {
246
- // // DESELECTION LOGIC
247
- // console.log(`Deselecting ID ${id}`);
248
- // // Remove the item itself
249
- // updatedSelection = updatedSelection.filter(itemId => itemId !== id);
250
- // // If item exists and has children, remove all children too
251
- // if (item && item.hasChildren && item.childRows && item.childRows.length > 0) {
252
- // // Function to collect all descendant IDs
253
- // const getAllDescendantIds = (items: TableRowData[]): number[] => {
254
- // let allIds: number[] = [];
255
- // for (const childItem of items) {
256
- // allIds.push(childItem.id);
257
- // if (childItem.hasChildren && childItem.childRows && childItem.childRows.length > 0) {
258
- // allIds = [...allIds, ...getAllDescendantIds(childItem.childRows)];
259
- // }
260
- // }
261
- // return allIds;
262
- // };
263
- // const descendantIds = getAllDescendantIds(item.childRows);
264
- // console.log(`Descendant IDs to remove:`, descendantIds);
265
- // // Remove all descendant IDs from the selection
266
- // updatedSelection = updatedSelection.filter(itemId => !descendantIds.includes(itemId));
267
- // }
268
- // } else {
269
- // // SELECTION LOGIC
270
- // console.log(`Selecting ID ${id}`);
271
- // // Add the item itself
272
- // updatedSelection.push(id);
273
- // // If item exists and has children, add all children too
274
- // if (item && item.hasChildren && item.childRows && item.childRows.length > 0) {
275
- // // Function to collect all descendant IDs
276
- // const getAllDescendantIds = (items: TableRowData[]): number[] => {
277
- // let allIds: number[] = [];
278
- // for (const childItem of items) {
279
- // allIds.push(childItem.id);
280
- // if (childItem.hasChildren && childItem.childRows && childItem.childRows.length > 0) {
281
- // allIds = [...allIds, ...getAllDescendantIds(childItem.childRows)];
282
- // }
283
- // }
284
- // return allIds;
285
- // };
286
- // const descendantIds = getAllDescendantIds(item.childRows);
287
- // console.log(`Descendant IDs to add:`, descendantIds);
288
- // // Add all descendant IDs to the selection if not already included
289
- // for (const descendantId of descendantIds) {
290
- // if (!updatedSelection.includes(descendantId)) {
291
- // updatedSelection.push(descendantId);
292
- // }
293
- // }
294
- // }
295
- // }
296
- // console.log("New selection:", updatedSelection);
297
- // setSelectedRows(updatedSelection);
298
- // if (onSelectionChange) {
299
- // onSelectionChange([...updatedSelection]);
300
- // }
301
- // };
302
- // Function to determine if a row has any descendants selected (not just direct children)
303
- const isIndeterminate = (rowId) => {
304
- // Find the row in the data
305
- const findRow = (rows, id) => {
306
- if (!rows)
307
- return null;
308
- for (const row of rows) {
309
- if (row.id === id)
310
- return row;
311
- if (row.hasChildren && row.childRows) {
312
- const found = findRow(row.childRows, id);
313
- if (found)
314
- 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 (!row ||
322
- !row.hasChildren ||
323
- !row.childRows ||
324
- row.childRows.length === 0) {
325
- return false;
326
- }
327
- // Check if the row itself is selected
328
- const isRowSelected = selectedRows.includes(rowId);
329
- // Recursively check if any descendant is selected
330
- const hasSelectedDescendant = (children) => {
331
- for (const child of children) {
332
- // If any child is selected
333
- if (selectedRows.includes(child.id)) {
334
- return true;
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
- }
344
- }
345
- return false;
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
- }
362
- }
363
- return true;
364
- };
365
- const hasAnySelected = hasSelectedDescendant(row.childRows);
366
- const hasAllSelected = areAllDescendantsSelected(row.childRows);
367
- // Indeterminate if some but not all descendants are selected
368
- // Or if the parent is not selected but some children are
369
- return ((hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected));
370
- };
371
- // Function to check if a row is selected
372
- const isSelected = (rowId) => {
373
- return selectedRows.includes(rowId);
374
- };
375
- // const handleCheckboxChange = (id: number) => {
376
- // // Call your existing handleSelectionChange function
377
- // // This will handle the hierarchical selection logic
378
- // if (onSelectionChange) {
379
- // onSelectionChange(id);
380
- // } else {
381
- // // Fallback to simple selection if no onSelectionChange is provided
382
- // const updatedSelection = selectedRows.includes(id)
383
- // ? selectedRows.filter((rowId) => rowId !== id)
384
- // : [...selectedRows, id];
385
- // setSelectedRows(updatedSelection);
386
- // }
387
- // };
388
- const handleCheckboxChange = (id) => {
389
- const findRowById = (rows, targetId) => {
390
- for (const row of rows) {
391
- if (row.id === targetId)
392
- return row;
393
- if (row.hasChildren && row.childRows) {
394
- const found = findRowById(row.childRows, targetId);
395
- if (found)
396
- return found;
397
- }
398
- }
399
- return null;
400
- };
401
- const getAllDescendantIds = (row) => {
402
- let ids = [];
403
- if (row.hasChildren && row.childRows) {
404
- for (const child of row.childRows) {
405
- ids.push(child.id);
406
- ids = [...ids, ...getAllDescendantIds(child)];
407
- }
408
- }
409
- return ids;
410
- };
411
- const updatedSelection = [...selectedRows];
412
- const row = findRowById(rows, id);
413
- if (!row)
414
- return;
415
- const descendantIds = getAllDescendantIds(row);
416
- if (selectedRows.includes(id)) {
417
- // Remove parent + all descendants
418
- const idsToRemove = [id, ...descendantIds];
419
- setSelectedRows(updatedSelection.filter((itemId) => !idsToRemove.includes(itemId)));
420
- }
421
- else {
422
- // Add parent + all descendants
423
- const idsToAdd = [id, ...descendantIds];
424
- setSelectedRows([
425
- ...updatedSelection,
426
- ...idsToAdd.filter((i) => !updatedSelection.includes(i)),
427
- ]);
428
- }
429
- if (onSelectionChange) {
430
- onSelectionChange(id);
431
- }
432
- };
433
- // Extract title and subtitle from row data
434
279
  const extractCardData = (row) => {
435
280
  let title = "";
436
281
  let subtitle = "";
@@ -440,58 +285,46 @@ pageIndex = 0, // Default to first page (0-indexed)
440
285
  let price = "";
441
286
  if (!row.data)
442
287
  return { title, subtitle, icon, status, statusClass, price };
443
- // Find title (usually first text item)
444
288
  const titleItem = row.data.find((item) => item.type === "text" && item.value);
445
289
  if (titleItem) {
446
290
  title = titleItem.value;
447
291
  }
448
292
  else if (row.data.length > 0) {
449
- // Fallback to first item
450
293
  title = String(row.data[0].value || "");
451
294
  }
452
- // Find subtitle (usually size or description)
453
295
  const subtitleItem = row.data.find((item) => item.type === "text" && item.isSubtitle);
454
296
  if (subtitleItem) {
455
297
  subtitle = subtitleItem.value;
456
298
  }
457
299
  else if (row.data.length > 1) {
458
- // Fallback to second item
459
300
  subtitle = String(row.data[1].value || "");
460
301
  }
461
- // Find status
462
302
  const statusItem = row.data.find((item) => item.type === "status");
463
303
  if (statusItem) {
464
304
  status = String(statusItem.value || "");
465
305
  statusClass = statusItem.statusClass || "";
466
306
  }
467
- // Find price (look for item with isPrice flag)
468
307
  const priceItem = row.data.find((item) => item.isPrice);
469
308
  if (priceItem) {
470
309
  price = String(priceItem.value || "");
471
310
  }
472
- // Find icon (usually avatar or image)
473
311
  const iconItem = row.data.find((item) => item.hasImage);
474
312
  if (iconItem && iconItem.value) {
475
313
  icon = String(iconItem.imageUrl || "");
476
314
  }
477
315
  return { title, subtitle, icon, status, statusClass, price };
478
316
  };
479
- // Find avatar items in row data
480
317
  const findAvatarItems = (row) => {
481
318
  if (!row.data)
482
319
  return [];
483
320
  return row.data.filter((item) => item.type === "avatar" && item.isUserAvatar);
484
321
  };
485
- // Get all rows and their children for mobile view - updated for multi-level nesting
486
322
  const getAllMobileRows = () => {
487
323
  const result = [];
488
- // Helper function to add parent rows and child rows that should be visible at any depth
489
324
  const processRows = (rows, level = 0) => {
490
325
  rows?.forEach((row) => {
491
- // Add level information to the row for proper indentation
492
326
  const rowWithLevel = { ...row, level, isChild: level > 0 };
493
327
  result.push(rowWithLevel);
494
- // Add child rows if this row is expanded - recursively check all levels
495
328
  if (row.hasChildren &&
496
329
  expandedRows.includes(row.id) &&
497
330
  row.childRows &&
@@ -505,7 +338,6 @@ pageIndex = 0, // Default to first page (0-indexed)
505
338
  }
506
339
  return result;
507
340
  };
508
- // Mobile card view
509
341
  const renderMobileCard = (row) => {
510
342
  if (!row || !row.data)
511
343
  return null;
@@ -514,10 +346,7 @@ pageIndex = 0, // Default to first page (0-indexed)
514
346
  const isFavorited = row.data.some((item) => item.isFavorite);
515
347
  const hasChildren = row.hasChildren && row.childRows && row?.childRows?.length > 0;
516
348
  const level = row.level || 0;
517
- const { cardStyle, showFolderIcon, folderIconPath, isMobileCardSelectable, showFavoriteIcon, favoriteFilledIconPath, favoriteOutlineIconPath,
518
- // showMoreOptions,
519
- moreOptionsIconPath, showAvatars, maxVisibleAvatars = 0, } = mobileCardConfig;
520
- // Calculate card classes - add special styling for child cards
349
+ const { cardStyle, showFolderIcon, folderIconPath, showFavoriteIcon, favoriteFilledIconPath, favoriteOutlineIconPath, moreOptionsIconPath, showAvatars, maxVisibleAvatars = 0, } = mobileCardConfig;
521
350
  const cardClasses = `
522
351
  ${cardStyle?.backgroundColor || "bg-white"}
523
352
  ${cardStyle?.borderRadius || "rounded-lg"}
@@ -536,7 +365,7 @@ pageIndex = 0, // Default to first page (0-indexed)
536
365
  react_1.default.createElement("div", { className: "w-10 h-10 flex items-center justify-center" }, row.data &&
537
366
  row.data.find((item) => item.hasImage)?.imageUrl ? (react_1.default.createElement(image_1.default, { src: row.data.find((item) => item.hasImage)?.imageUrl ||
538
367
  "/placeholder.svg", alt: "folder", width: 40, height: 40, className: "h-full w-full object-cover" })) : (react_1.default.createElement(image_1.default, { src: folderIconPath || "/placeholder.svg", alt: "folder", width: 40, height: 40, className: "text-yellow-400" }))))),
539
- react_1.default.createElement("div", null, isMobileCardSelectable && (react_1.default.createElement("div", { className: "relative flex-shrink-0 flex" },
368
+ react_1.default.createElement("div", null, selectable && (react_1.default.createElement("div", { className: "relative flex-shrink-0 flex" },
540
369
  react_1.default.createElement("input", { type: "checkbox", checked: isSelected(row.id), onChange: () => handleCheckboxChange(row.id), className: "peer h-5 w-5 mr-2 cursor-pointer appearance-none rounded-md border-2 border-gray-300 transition-all checked:border-blue-500 checked:bg-blue-500 hover:border-blue-500", onClick: (e) => e.stopPropagation(), ref: (el) => {
541
370
  if (el) {
542
371
  el.indeterminate = isIndeterminate(row.id);
@@ -580,7 +409,7 @@ pageIndex = 0, // Default to first page (0-indexed)
580
409
  ShowActionModal && activeModal === row.id && (react_1.default.createElement("div", { ref: modalRef, className: "modal-content fixed z-[9999] w-40 rounded-md bg-white shadow-lg", style: {
581
410
  position: "fixed",
582
411
  top: `${mousePosition.y}px`,
583
- left: `${Math.max(0, Math.min(window.innerWidth - 160, mousePosition.x - 80) + 35)}px `, // Ensure modal stays within screen
412
+ left: `${Math.max(0, Math.min(window.innerWidth - 160, mousePosition.x - 80) + 35)}px `,
584
413
  }, onClick: (e) => e.stopPropagation() },
585
414
  react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === "function"
586
415
  ? modalActions(row)
@@ -593,9 +422,7 @@ pageIndex = 0, // Default to first page (0-indexed)
593
422
  "+",
594
423
  avatarItems.length - maxVisibleAvatars)))))))));
595
424
  };
596
- // Render a single table row (parent or child)
597
425
  const renderTableRow = (row, index, isLastRow) => {
598
- // Width for the expand/collapse control column
599
426
  return (react_1.default.createElement("div", { key: `row-container-${row.id}` },
600
427
  react_1.default.createElement("div", { className: `grid w-full items-center ${row.isChild
601
428
  ? childRowConfig.childRowClass || "bg-blue-300 bg-opacity-10"
@@ -617,9 +444,7 @@ pageIndex = 0, // Default to first page (0-indexed)
617
444
  react_1.default.createElement("div", { className: "flex items-center justify-center gap-1" },
618
445
  row.hasChildren && row.childRows && row.childRows?.length > 0 ? (react_1.default.createElement("button", { onClick: (e) => handleRowExpandToggle(row.id, e), className: "transition-transform duration-200 flex-shrink-0" },
619
446
  react_1.default.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: `transition-transform ${expandedRows.includes(row.id) ? "-rotate-90" : ""}` },
620
- react_1.default.createElement("path", { d: "M15 5L8 12L15 19", stroke: "rgba(0, 0, 0, 0.40)", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })))) : row.isChild ? (
621
- // Child row indicator
622
- react_1.default.createElement("div", { className: "h-2 w-2 rounded-full bg-black/20 flex-shrink-0" })) : null,
447
+ react_1.default.createElement("path", { d: "M15 5L8 12L15 19", stroke: "rgba(0, 0, 0, 0.40)", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })))) : row.isChild ? (react_1.default.createElement("div", { className: "h-2 w-2 rounded-full bg-black/20 flex-shrink-0" })) : null,
623
448
  selectable === true && !row.isChild && (react_1.default.createElement("div", { className: "relative flex-shrink-0 flex" },
624
449
  react_1.default.createElement("input", { type: "checkbox", checked: isSelected(row.id), onChange: () => handleCheckboxChange(row.id), className: "peer h-5 w-5 cursor-pointer appearance-none rounded-md border-2 border-gray-300 transition-all checked:border-blue-500 checked:bg-blue-500 hover:border-blue-500", onClick: (e) => e.stopPropagation(), ref: (el) => {
625
450
  if (el) {
@@ -667,21 +492,15 @@ pageIndex = 0, // Default to first page (0-indexed)
667
492
  (typeof showModalIcon === "function"
668
493
  ? showModalIcon(row)
669
494
  : showModalIcon) ? (react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: "", "data-row-id": row.id },
670
- react_1.default.createElement(image_1.default, { src: iconsSRC?.moreIcon || "/placeholder.svg", alt: "menu", width: 18, height: 18, className: iconsSRC?.moreIconTailwindStyle || "" }))) : (
671
- // Render an invisible placeholder to maintain spacing when icon is hidden
672
- react_1.default.createElement("div", { className: "w-[18px] h-[18px]" })),
495
+ react_1.default.createElement(image_1.default, { src: iconsSRC?.moreIcon || "/placeholder.svg", alt: "menu", width: 18, height: 18, className: iconsSRC?.moreIconTailwindStyle || "" }))) : (react_1.default.createElement("div", { className: "w-[18px] h-[18px]" })),
673
496
  ShowActionModal && activeModal === row.id && (react_1.default.createElement("div", { ref: modalRef, className: "modal-content fixed z-[9999] w-40 rounded-md bg-white shadow-lg", style: {
674
497
  position: "fixed",
675
498
  top: (() => {
676
- // Get all visible rows for the current view
677
499
  const allRows = isMobileView
678
500
  ? getAllMobileRows()
679
501
  : rows;
680
- // Find the index of the current row
681
502
  const currentRowIndex = allRows?.findIndex((r) => r.id === row.id);
682
- // Check if this is one of the last 3 rows
683
503
  const isLastThreeRows = allRows && currentRowIndex >= allRows.length - 3;
684
- // If it's one of the last 3 rows, reduce the top position by 100px
685
504
  return isLastThreeRows
686
505
  ? `${mousePosition.y - 110}px`
687
506
  : `${mousePosition.y}px`;
@@ -696,15 +515,12 @@ pageIndex = 0, // Default to first page (0-indexed)
696
515
  row.childRows &&
697
516
  row.childRows.map((childRow, childIndex) => renderTableRow(childRow, childIndex, childIndex === row.childRows.length - 1 && isLastRow))));
698
517
  };
699
- // Prepare all mobile rows
700
518
  const mobileRows = getAllMobileRows();
701
- // Show loading state if loading is true
702
519
  if (loadingProps.isLoading) {
703
520
  return (react_1.default.createElement("div", { className: "w-full flex justify-center items-center py-8 gap-3" },
704
521
  loadingProps.loadingIcon,
705
522
  loadingProps.loadingText && loadingProps.loadingText));
706
523
  }
707
- // Show no items found if rows are empty or null and not loading
708
524
  if (!loadingProps.isLoading && rows?.length === 0) {
709
525
  return (react_1.default.createElement("div", { className: "flex flex-col items-center justify-center p-8" }, typeof noItemFoundProps?.imagePath === "string" ? (react_1.default.createElement(react_1.default.Fragment, null,
710
526
  react_1.default.createElement(image_1.default, { src: noItemFoundProps?.imagePath || "/icons/no-data.svg", alt: "No items found", width: 120, height: 120 }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.11.9",
3
+ "version": "0.12.1",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {