hi-tm 0.11.9 → 0.12.0

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,81 @@ 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
+ const handleCheckboxChange = (id) => {
156
+ const row = findRowById(id);
157
+ if (!row)
158
+ return;
159
+ const descendantIds = getAllDescendantIds(id);
160
+ const updatedSelection = [...selectedRows];
161
+ if (selectedRows.includes(id)) {
162
+ const idsToRemove = [id, ...descendantIds];
163
+ setSelectedRows(updatedSelection.filter((itemId) => !idsToRemove.includes(itemId)));
123
164
  }
124
- }, [rows]);
125
- // Initialize expanded rows if specified in config
126
- (0, react_2.useEffect)(() => {
165
+ else {
166
+ const idsToAdd = [id, ...descendantIds];
167
+ setSelectedRows([
168
+ ...updatedSelection,
169
+ ...idsToAdd.filter((i) => !updatedSelection.includes(i)),
170
+ ]);
171
+ }
172
+ if (onSelectionChange) {
173
+ onSelectionChange(id);
174
+ }
175
+ };
176
+ // --- Effects ---
177
+ (0, react_1.useEffect)(() => {
127
178
  if (childRowConfig.expandByDefault && rows) {
128
179
  const parentIds = rows
129
180
  .filter((row) => row.hasChildren && row.childRows && row.childRows.length > 0)
@@ -131,7 +182,7 @@ pageIndex = 0, // Default to first page (0-indexed)
131
182
  setExpandedRows(parentIds);
132
183
  }
133
184
  }, [rows, childRowConfig.expandByDefault]);
134
- (0, react_2.useEffect)(() => {
185
+ (0, react_1.useEffect)(() => {
135
186
  const handleClickOutside = (event) => {
136
187
  const target = event.target;
137
188
  if (target.closest(".modal-content")) {
@@ -147,7 +198,7 @@ pageIndex = 0, // Default to first page (0-indexed)
147
198
  document.removeEventListener("mousedown", handleClickOutside);
148
199
  };
149
200
  }, []);
150
- (0, react_2.useEffect)(() => {
201
+ (0, react_1.useEffect)(() => {
151
202
  const handleScroll = () => {
152
203
  if (activeModal !== null) {
153
204
  setActiveModal(null);
@@ -158,7 +209,10 @@ pageIndex = 0, // Default to first page (0-indexed)
158
209
  window.removeEventListener("scroll", handleScroll);
159
210
  };
160
211
  }, [activeModal]);
161
- const [mousePosition, setMousePosition] = (0, react_2.useState)({ x: 0, y: 0 });
212
+ (0, react_1.useEffect)(() => {
213
+ setSelectedRows(selectedItems || []);
214
+ }, [selectedItems]);
215
+ // --- Handlers ---
162
216
  const handleModalToggle = (id, e) => {
163
217
  e.stopPropagation();
164
218
  e.preventDefault();
@@ -214,223 +268,6 @@ pageIndex = 0, // Default to first page (0-indexed)
214
268
  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
269
  }
216
270
  };
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
271
  const extractCardData = (row) => {
435
272
  let title = "";
436
273
  let subtitle = "";
@@ -440,58 +277,46 @@ pageIndex = 0, // Default to first page (0-indexed)
440
277
  let price = "";
441
278
  if (!row.data)
442
279
  return { title, subtitle, icon, status, statusClass, price };
443
- // Find title (usually first text item)
444
280
  const titleItem = row.data.find((item) => item.type === "text" && item.value);
445
281
  if (titleItem) {
446
282
  title = titleItem.value;
447
283
  }
448
284
  else if (row.data.length > 0) {
449
- // Fallback to first item
450
285
  title = String(row.data[0].value || "");
451
286
  }
452
- // Find subtitle (usually size or description)
453
287
  const subtitleItem = row.data.find((item) => item.type === "text" && item.isSubtitle);
454
288
  if (subtitleItem) {
455
289
  subtitle = subtitleItem.value;
456
290
  }
457
291
  else if (row.data.length > 1) {
458
- // Fallback to second item
459
292
  subtitle = String(row.data[1].value || "");
460
293
  }
461
- // Find status
462
294
  const statusItem = row.data.find((item) => item.type === "status");
463
295
  if (statusItem) {
464
296
  status = String(statusItem.value || "");
465
297
  statusClass = statusItem.statusClass || "";
466
298
  }
467
- // Find price (look for item with isPrice flag)
468
299
  const priceItem = row.data.find((item) => item.isPrice);
469
300
  if (priceItem) {
470
301
  price = String(priceItem.value || "");
471
302
  }
472
- // Find icon (usually avatar or image)
473
303
  const iconItem = row.data.find((item) => item.hasImage);
474
304
  if (iconItem && iconItem.value) {
475
305
  icon = String(iconItem.imageUrl || "");
476
306
  }
477
307
  return { title, subtitle, icon, status, statusClass, price };
478
308
  };
479
- // Find avatar items in row data
480
309
  const findAvatarItems = (row) => {
481
310
  if (!row.data)
482
311
  return [];
483
312
  return row.data.filter((item) => item.type === "avatar" && item.isUserAvatar);
484
313
  };
485
- // Get all rows and their children for mobile view - updated for multi-level nesting
486
314
  const getAllMobileRows = () => {
487
315
  const result = [];
488
- // Helper function to add parent rows and child rows that should be visible at any depth
489
316
  const processRows = (rows, level = 0) => {
490
317
  rows?.forEach((row) => {
491
- // Add level information to the row for proper indentation
492
318
  const rowWithLevel = { ...row, level, isChild: level > 0 };
493
319
  result.push(rowWithLevel);
494
- // Add child rows if this row is expanded - recursively check all levels
495
320
  if (row.hasChildren &&
496
321
  expandedRows.includes(row.id) &&
497
322
  row.childRows &&
@@ -505,7 +330,6 @@ pageIndex = 0, // Default to first page (0-indexed)
505
330
  }
506
331
  return result;
507
332
  };
508
- // Mobile card view
509
333
  const renderMobileCard = (row) => {
510
334
  if (!row || !row.data)
511
335
  return null;
@@ -514,10 +338,7 @@ pageIndex = 0, // Default to first page (0-indexed)
514
338
  const isFavorited = row.data.some((item) => item.isFavorite);
515
339
  const hasChildren = row.hasChildren && row.childRows && row?.childRows?.length > 0;
516
340
  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
341
+ const { cardStyle, showFolderIcon, folderIconPath, showFavoriteIcon, favoriteFilledIconPath, favoriteOutlineIconPath, moreOptionsIconPath, showAvatars, maxVisibleAvatars = 0, } = mobileCardConfig;
521
342
  const cardClasses = `
522
343
  ${cardStyle?.backgroundColor || "bg-white"}
523
344
  ${cardStyle?.borderRadius || "rounded-lg"}
@@ -536,7 +357,7 @@ pageIndex = 0, // Default to first page (0-indexed)
536
357
  react_1.default.createElement("div", { className: "w-10 h-10 flex items-center justify-center" }, row.data &&
537
358
  row.data.find((item) => item.hasImage)?.imageUrl ? (react_1.default.createElement(image_1.default, { src: row.data.find((item) => item.hasImage)?.imageUrl ||
538
359
  "/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" },
360
+ react_1.default.createElement("div", null, selectable && (react_1.default.createElement("div", { className: "relative flex-shrink-0 flex" },
540
361
  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
362
  if (el) {
542
363
  el.indeterminate = isIndeterminate(row.id);
@@ -580,7 +401,7 @@ pageIndex = 0, // Default to first page (0-indexed)
580
401
  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
402
  position: "fixed",
582
403
  top: `${mousePosition.y}px`,
583
- left: `${Math.max(0, Math.min(window.innerWidth - 160, mousePosition.x - 80) + 35)}px `, // Ensure modal stays within screen
404
+ left: `${Math.max(0, Math.min(window.innerWidth - 160, mousePosition.x - 80) + 35)}px `,
584
405
  }, onClick: (e) => e.stopPropagation() },
585
406
  react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === "function"
586
407
  ? modalActions(row)
@@ -593,9 +414,7 @@ pageIndex = 0, // Default to first page (0-indexed)
593
414
  "+",
594
415
  avatarItems.length - maxVisibleAvatars)))))))));
595
416
  };
596
- // Render a single table row (parent or child)
597
417
  const renderTableRow = (row, index, isLastRow) => {
598
- // Width for the expand/collapse control column
599
418
  return (react_1.default.createElement("div", { key: `row-container-${row.id}` },
600
419
  react_1.default.createElement("div", { className: `grid w-full items-center ${row.isChild
601
420
  ? childRowConfig.childRowClass || "bg-blue-300 bg-opacity-10"
@@ -617,9 +436,7 @@ pageIndex = 0, // Default to first page (0-indexed)
617
436
  react_1.default.createElement("div", { className: "flex items-center justify-center gap-1" },
618
437
  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
438
  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,
439
+ 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
440
  selectable === true && !row.isChild && (react_1.default.createElement("div", { className: "relative flex-shrink-0 flex" },
624
441
  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
442
  if (el) {
@@ -667,21 +484,15 @@ pageIndex = 0, // Default to first page (0-indexed)
667
484
  (typeof showModalIcon === "function"
668
485
  ? showModalIcon(row)
669
486
  : 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]" })),
487
+ 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
488
  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
489
  position: "fixed",
675
490
  top: (() => {
676
- // Get all visible rows for the current view
677
491
  const allRows = isMobileView
678
492
  ? getAllMobileRows()
679
493
  : rows;
680
- // Find the index of the current row
681
494
  const currentRowIndex = allRows?.findIndex((r) => r.id === row.id);
682
- // Check if this is one of the last 3 rows
683
495
  const isLastThreeRows = allRows && currentRowIndex >= allRows.length - 3;
684
- // If it's one of the last 3 rows, reduce the top position by 100px
685
496
  return isLastThreeRows
686
497
  ? `${mousePosition.y - 110}px`
687
498
  : `${mousePosition.y}px`;
@@ -696,15 +507,12 @@ pageIndex = 0, // Default to first page (0-indexed)
696
507
  row.childRows &&
697
508
  row.childRows.map((childRow, childIndex) => renderTableRow(childRow, childIndex, childIndex === row.childRows.length - 1 && isLastRow))));
698
509
  };
699
- // Prepare all mobile rows
700
510
  const mobileRows = getAllMobileRows();
701
- // Show loading state if loading is true
702
511
  if (loadingProps.isLoading) {
703
512
  return (react_1.default.createElement("div", { className: "w-full flex justify-center items-center py-8 gap-3" },
704
513
  loadingProps.loadingIcon,
705
514
  loadingProps.loadingText && loadingProps.loadingText));
706
515
  }
707
- // Show no items found if rows are empty or null and not loading
708
516
  if (!loadingProps.isLoading && rows?.length === 0) {
709
517
  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
518
  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.0",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {