hi-tm 0.18.7 → 0.18.9

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.
@@ -261,8 +261,8 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
261
261
  : "/defaultImage.jpg", alt: "logo.svg", width: 16, height: 16, className: "rounded-xl" }),
262
262
  react_1.default.createElement("p", { className: "select-none-custom text-nowrap text-sm font-normal" }, item.name))),
263
263
  item.subBranch?.length > 0 && expandSubBranch && (react_1.default.createElement("ul", { className: "w-full flex flex-col gap-2 mt-2 mr-2" }, item.subBranch.map((subItem) => (react_1.default.createElement("li", { key: subItem.id, onClick: () => selectItemBranchHandler(subItem), className: "flex items-center gap-2 px-5 py-1 cursor-pointer hover:bg-gray-100 rounded-md" },
264
- react_1.default.createElement(image_1.default, { src: item.logoName && item.logoName.trim() !== ""
265
- ? `${baseUrlCDN || ""}/${item.urlName || branchName}/${item.logoName}`
264
+ react_1.default.createElement(image_1.default, { src: subItem.logoName && subItem.logoName.trim() !== ""
265
+ ? `${baseUrlCDN || ""}/${subItem.urlName || branchName}/${subItem.logoName}`
266
266
  : "/defaultImage.jpg", alt: "logo.svg", width: 16, height: 16, className: "rounded-xl" }),
267
267
  react_1.default.createElement("p", { className: "select-none-custom text-nowrap text-sm font-normal" }, subItem.name))))))))))))),
268
268
  react_1.default.createElement("div", { ref: modalCloseRefPC, className: "flex h-full flex-row-reverse items-center justify-center gap-4" },
@@ -336,8 +336,8 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
336
336
  : imageDefaultSRC, alt: "logo.svg", width: 16, height: 16, className: "rounded-xl" }),
337
337
  react_1.default.createElement("p", { className: "select-none-custom text-nowrap text-sm font-normal" }, item.name))),
338
338
  item.subBranch?.length > 0 && expandSubBranch && (react_1.default.createElement("ul", { className: "w-full flex flex-col gap-2 mt-2 mr-2" }, item.subBranch.map((subItem) => (react_1.default.createElement("li", { key: subItem.id, onClick: () => selectItemBranchHandler(subItem), className: "flex items-center gap-2 px-5 py-1 cursor-pointer hover:bg-gray-100 rounded-md" },
339
- react_1.default.createElement(image_1.default, { src: item.logoName && item.logoName.trim() !== ""
340
- ? `${baseUrlCDN || ""}/${item.urlName || branchName}/${item.logoName}`
339
+ react_1.default.createElement(image_1.default, { src: subItem.logoName && subItem.logoName.trim() !== ""
340
+ ? `${baseUrlCDN || ""}/${subItem.urlName || branchName}/${subItem.logoName}`
341
341
  : "/defaultImage.jpg", alt: "logo.svg", width: 16, height: 16, className: "rounded-xl" }),
342
342
  react_1.default.createElement("p", { className: "select-none-custom text-nowrap text-sm font-normal" }, subItem.name)))))))))))),
343
343
  react_1.default.createElement("div", { ref: modalCloseRefMobile, className: "flex flex-row items-center justify-center gap-2" },
@@ -1,4 +1,4 @@
1
- import React from "react";
2
- import { ModernTableProps } from "../../../types/ModernTable";
1
+ import React from 'react';
2
+ import { ModernTableProps } from '../../../types/ModernTable';
3
3
  declare const ModernTable: React.FC<ModernTableProps>;
4
4
  export default ModernTable;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- "use client";
2
+ 'use client';
3
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
@@ -16,53 +16,53 @@ const Loader = () => {
16
16
  // Helper function to format numbers with commas
17
17
  const formatWithCommas = (value) => {
18
18
  if (value === undefined || value === null)
19
- return "";
20
- const numValue = typeof value === "string" ? Number.parseFloat(value) : value;
19
+ return '';
20
+ const numValue = typeof value === 'string' ? Number.parseFloat(value) : value;
21
21
  if (isNaN(numValue))
22
22
  return value.toString();
23
23
  return numValue.toLocaleString();
24
24
  };
25
25
  // Helper function to handle modal styles
26
26
  const modalStyleOperationHandler = (classType) => {
27
- if (classType === "delete") {
28
- return "hover:bg-red-500/20 text-red-700";
27
+ if (classType === 'delete') {
28
+ return 'hover:bg-red-500/20 text-red-700';
29
29
  }
30
30
  else {
31
- return "hover:bg-gray-500/10";
31
+ return 'hover:bg-gray-500/10';
32
32
  }
33
33
  };
34
34
  const ModernTable = ({ rows = [], onEdit, loadingProps = {
35
35
  isLoading: false,
36
- loadingText: "درحال دریافت اطلاعات",
36
+ loadingText: 'درحال دریافت اطلاعات',
37
37
  loadingIcon: react_1.default.createElement(Loader, null),
38
- }, onView, onAction, selectable, onSelectionChange, checkBoxDisable, actions, ShowActionModal = true, modalActions, noItemFoundProps, selectedItems = [], iconsSRC,
38
+ }, onView, onAction, selectable, onSelectionChange, checkBoxDisable, actions, ShowActionModal = true, modalActions, actionModalTopClassName, noItemFoundProps, selectedItems = [], iconsSRC,
39
39
  // Child row configuration with defaults
40
40
  childRowConfig = {
41
41
  expandByDefault: false,
42
- indentSize: "1.5rem",
43
- childRowClass: "bg-blue-300 bg-opacity-10",
42
+ indentSize: '1.5rem',
43
+ childRowClass: 'bg-blue-300 bg-opacity-10',
44
44
  },
45
45
  // Mobile card view configuration props
46
46
  mobileCardConfig = {
47
47
  enabled: true,
48
48
  showFolderIcon: true,
49
- folderIconPath: "",
49
+ folderIconPath: '',
50
50
  showFavoriteIcon: true,
51
- favoriteFilledIconPath: "/icons/star-filled.svg",
52
- favoriteOutlineIconPath: "/icons/star-outline.svg",
51
+ favoriteFilledIconPath: '/icons/star-filled.svg',
52
+ favoriteOutlineIconPath: '/icons/star-outline.svg',
53
53
  showMoreOptions: true,
54
- moreOptionsIconPath: "/icons/table/more.svg",
54
+ moreOptionsIconPath: '/icons/table/more.svg',
55
55
  showAvatars: true,
56
56
  maxVisibleAvatars: 2,
57
57
  cardStyle: {
58
- backgroundColor: "bg-white",
59
- borderRadius: "rounded-lg",
60
- shadow: "shadow-sm",
61
- border: "border border-gray-100",
62
- padding: "p-4",
63
- marginBottom: "mb-4",
58
+ backgroundColor: 'bg-white',
59
+ borderRadius: 'rounded-lg',
60
+ shadow: 'shadow-sm',
61
+ border: 'border border-gray-100',
62
+ padding: 'p-4',
63
+ marginBottom: 'mb-4',
64
64
  },
65
- gridLayoutClassName: "grid-cols-1 sm:grid-cols-2 gap-4",
65
+ gridLayoutClassName: 'grid-cols-1 sm:grid-cols-2 gap-4',
66
66
  }, showModalIcon = true, actionButtonsStyle, gridClassName, isMobileView = false, // Default to false
67
67
  mobileViewGridClassName, itemsPerPage = 10, // Default to 10 items per page
68
68
  pageIndex = 0, // Default to first page (0-indexed)
@@ -103,17 +103,16 @@ pageIndex = 0, // Default to first page (0-indexed)
103
103
  .filter((row) => row.data &&
104
104
  row.data[colIndex] &&
105
105
  row.data[colIndex].inlineCSS &&
106
- "width" in (row.data[colIndex].inlineCSS || {}))
106
+ 'width' in (row.data[colIndex].inlineCSS || {}))
107
107
  .map((row) => row.data[colIndex]);
108
108
  if (columnsWithWidth.length > 0) {
109
109
  // Use the first defined width (could be enhanced to use max/average)
110
110
  const firstWidth = columnsWithWidth[0].inlineCSS?.width;
111
111
  if (firstWidth) {
112
- widths[colIndex] =
113
- typeof firstWidth === "string" ? firstWidth : `${firstWidth}px`;
112
+ widths[colIndex] = typeof firstWidth === 'string' ? firstWidth : `${firstWidth}px`;
114
113
  }
115
114
  else {
116
- widths[colIndex] = "auto";
115
+ widths[colIndex] = 'auto';
117
116
  }
118
117
  }
119
118
  else {
@@ -134,17 +133,16 @@ pageIndex = 0, // Default to first page (0-indexed)
134
133
  (0, react_2.useEffect)(() => {
135
134
  const handleClickOutside = (event) => {
136
135
  const target = event.target;
137
- if (target.closest(".modal-content")) {
136
+ if (target.closest('.modal-content')) {
138
137
  return;
139
138
  }
140
- if (modalRef.current &&
141
- !modalRef.current.contains(event.target)) {
139
+ if (modalRef.current && !modalRef.current.contains(event.target)) {
142
140
  setActiveModal(null);
143
141
  }
144
142
  };
145
- document.addEventListener("mousedown", handleClickOutside);
143
+ document.addEventListener('mousedown', handleClickOutside);
146
144
  return () => {
147
- document.removeEventListener("mousedown", handleClickOutside);
145
+ document.removeEventListener('mousedown', handleClickOutside);
148
146
  };
149
147
  }, []);
150
148
  (0, react_2.useEffect)(() => {
@@ -153,9 +151,9 @@ pageIndex = 0, // Default to first page (0-indexed)
153
151
  setActiveModal(null);
154
152
  }
155
153
  };
156
- window.addEventListener("scroll", handleScroll, { passive: true });
154
+ window.addEventListener('scroll', handleScroll, { passive: true });
157
155
  return () => {
158
- window.removeEventListener("scroll", handleScroll);
156
+ window.removeEventListener('scroll', handleScroll);
159
157
  };
160
158
  }, [activeModal]);
161
159
  const [mousePosition, setMousePosition] = (0, react_2.useState)({ x: 0, y: 0 });
@@ -174,44 +172,42 @@ pageIndex = 0, // Default to first page (0-indexed)
174
172
  };
175
173
  const handleRowExpandToggle = (rowId, e) => {
176
174
  e.stopPropagation();
177
- setExpandedRows((prev) => prev.includes(rowId)
178
- ? prev.filter((id) => id !== rowId)
179
- : [...prev, rowId]);
175
+ setExpandedRows((prev) => prev.includes(rowId) ? prev.filter((id) => id !== rowId) : [...prev, rowId]);
180
176
  };
181
177
  const getStatusClass = (statusClass) => {
182
178
  switch (statusClass) {
183
- case "success":
184
- return "text-[#37935f] px-4 py-2 rounded-lg bg-[#d1f4e0]";
185
- case "danger":
186
- return "text-[#d75482] rounded-lg bg-[#fdd0df] px-2 py-2";
187
- case "warning":
188
- return "text-yellow-700";
189
- case "info":
190
- return "text-blue-700";
191
- case "primary":
192
- return "text-[#6b46c1] rounded-lg bg-[#ede9f8] px-4 py-2";
193
- case "secondary":
194
- return "text-gray-700";
179
+ case 'success':
180
+ return 'text-[#37935f] px-4 py-2 rounded-lg bg-[#d1f4e0]';
181
+ case 'danger':
182
+ return 'text-[#d75482] rounded-lg bg-[#fdd0df] px-2 py-2';
183
+ case 'warning':
184
+ return 'text-yellow-700';
185
+ case 'info':
186
+ return 'text-blue-700';
187
+ case 'primary':
188
+ return 'text-[#6b46c1] rounded-lg bg-[#ede9f8] px-4 py-2';
189
+ case 'secondary':
190
+ return 'text-gray-700';
195
191
  default:
196
- return "";
192
+ return '';
197
193
  }
198
194
  };
199
195
  const renderCellContent = (item) => {
200
196
  switch (item.type) {
201
- case "status":
197
+ case 'status':
202
198
  return (react_1.default.createElement("p", { className: `text-xs font-medium w-fit ${item.contentClass} ${getStatusClass(item.statusClass)} ` }, item.value));
203
- case "price":
204
- return (react_1.default.createElement("p", { className: `${item.contentClass || "text-start"} text-sm w-full truncate ` }, formatWithCommas(item.value)));
199
+ case 'price':
200
+ return (react_1.default.createElement("p", { className: `${item.contentClass || 'text-start'} text-sm w-full truncate ` }, formatWithCommas(item.value)));
205
201
  default:
206
202
  return (react_1.default.createElement("div", { onClick: () => {
207
203
  if (item.onClick) {
208
204
  item.onClick(item.id);
209
205
  }
210
206
  }, className: "flex items-center gap-2 w-full min-h-[60px] h-auto" }, item.hasImage && item.imageUrl !== null ? (react_1.default.createElement("div", { className: "flex items-center gap-2 w-full " },
211
- react_1.default.createElement(SafeImage_1.default, { src: ((item.imageUrl !== null || item.imageUrl !== "") &&
207
+ react_1.default.createElement(SafeImage_1.default, { src: ((item.imageUrl !== null || item.imageUrl !== '') &&
212
208
  item.imageUrl) ||
213
- "/defaultImage.jpg", alt: item.value?.toString() || "Table item", width: item.imageWidth || 24, height: item.imageHeight || 24, className: item.imageClass || "h-6 w-6 object-cover" }),
214
- 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 min-h-[60px] h-auto flex justify-center items-center`, title: item.value?.toString() || "" }, item.value))));
209
+ '/defaultImage.jpg', alt: item.value?.toString() || 'Table item', width: item.imageWidth || 24, height: item.imageHeight || 24, className: item.imageClass || 'h-6 w-6 object-cover' }),
210
+ 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 min-h-[60px] h-auto flex justify-center items-center`, title: item.value?.toString() || '' }, item.value))));
215
211
  }
216
212
  };
217
213
  // Update selectedRows when selectedItems prop changes
@@ -318,10 +314,7 @@ pageIndex = 0, // Default to first page (0-indexed)
318
314
  };
319
315
  const row = findRow(rows, rowId);
320
316
  // If row has no children, it can't be indeterminate
321
- if (!row ||
322
- !row.hasChildren ||
323
- !row.childRows ||
324
- row.childRows.length === 0) {
317
+ if (!row || !row.hasChildren || !row.childRows || row.childRows.length === 0) {
325
318
  return false;
326
319
  }
327
320
  // Check if the row itself is selected
@@ -334,9 +327,7 @@ pageIndex = 0, // Default to first page (0-indexed)
334
327
  return true;
335
328
  }
336
329
  // Check grandchildren if they exist
337
- if (child.hasChildren &&
338
- child.childRows &&
339
- child.childRows.length > 0) {
330
+ if (child.hasChildren && child.childRows && child.childRows.length > 0) {
340
331
  if (hasSelectedDescendant(child.childRows)) {
341
332
  return true;
342
333
  }
@@ -352,9 +343,7 @@ pageIndex = 0, // Default to first page (0-indexed)
352
343
  return false;
353
344
  }
354
345
  // Check grandchildren if they exist
355
- if (child.hasChildren &&
356
- child.childRows &&
357
- child.childRows.length > 0) {
346
+ if (child.hasChildren && child.childRows && child.childRows.length > 0) {
358
347
  if (!areAllDescendantsSelected(child.childRows)) {
359
348
  return false;
360
349
  }
@@ -366,7 +355,7 @@ pageIndex = 0, // Default to first page (0-indexed)
366
355
  const hasAllSelected = areAllDescendantsSelected(row.childRows);
367
356
  // Indeterminate if some but not all descendants are selected
368
357
  // Or if the parent is not selected but some children are
369
- return ((hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected));
358
+ return (hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected);
370
359
  };
371
360
  // Function to check if a row is selected
372
361
  const isSelected = (rowId) => {
@@ -438,47 +427,47 @@ pageIndex = 0, // Default to first page (0-indexed)
438
427
  };
439
428
  // Extract title and subtitle from row data
440
429
  const extractCardData = (row) => {
441
- let title = "";
442
- let subtitle = "";
443
- let icon = "";
444
- let status = "";
445
- let statusClass = "";
446
- let price = "";
430
+ let title = '';
431
+ let subtitle = '';
432
+ let icon = '';
433
+ let status = '';
434
+ let statusClass = '';
435
+ let price = '';
447
436
  if (!row.data)
448
437
  return { title, subtitle, icon, status, statusClass, price };
449
438
  // Find title (usually first text item)
450
- const titleItem = row.data.find((item) => item.type === "text" && item.value);
439
+ const titleItem = row.data.find((item) => item.type === 'text' && item.value);
451
440
  if (titleItem) {
452
441
  title = titleItem.value;
453
442
  }
454
443
  else if (row.data.length > 0) {
455
444
  // Fallback to first item
456
- title = String(row.data[0].value || "");
445
+ title = String(row.data[0].value || '');
457
446
  }
458
447
  // Find subtitle (usually size or description)
459
- const subtitleItem = row.data.find((item) => item.type === "text" && item.isSubtitle);
448
+ const subtitleItem = row.data.find((item) => item.type === 'text' && item.isSubtitle);
460
449
  if (subtitleItem) {
461
450
  subtitle = subtitleItem.value;
462
451
  }
463
452
  else if (row.data.length > 1) {
464
453
  // Fallback to second item
465
- subtitle = String(row.data[1].value || "");
454
+ subtitle = String(row.data[1].value || '');
466
455
  }
467
456
  // Find status
468
- const statusItem = row.data.find((item) => item.type === "status");
457
+ const statusItem = row.data.find((item) => item.type === 'status');
469
458
  if (statusItem) {
470
- status = String(statusItem.value || "");
471
- statusClass = statusItem.statusClass || "";
459
+ status = String(statusItem.value || '');
460
+ statusClass = statusItem.statusClass || '';
472
461
  }
473
462
  // Find price (look for item with isPrice flag)
474
463
  const priceItem = row.data.find((item) => item.isPrice);
475
464
  if (priceItem) {
476
- price = String(priceItem.value || "");
465
+ price = String(priceItem.value || '');
477
466
  }
478
467
  // Find icon (usually avatar or image)
479
468
  const iconItem = row.data.find((item) => item.hasImage);
480
469
  if (iconItem && iconItem.value) {
481
- icon = String(iconItem.imageUrl || "");
470
+ icon = String(iconItem.imageUrl || '');
482
471
  }
483
472
  return { title, subtitle, icon, status, statusClass, price };
484
473
  };
@@ -486,7 +475,7 @@ pageIndex = 0, // Default to first page (0-indexed)
486
475
  const findAvatarItems = (row) => {
487
476
  if (!row.data)
488
477
  return [];
489
- return row.data.filter((item) => item.type === "avatar" && item.isUserAvatar);
478
+ return row.data.filter((item) => item.type === 'avatar' && item.isUserAvatar);
490
479
  };
491
480
  // Get all rows and their children for mobile view - updated for multi-level nesting
492
481
  const getAllMobileRows = () => {
@@ -525,23 +514,19 @@ pageIndex = 0, // Default to first page (0-indexed)
525
514
  moreOptionsIconPath, showAvatars, maxVisibleAvatars = 0, } = mobileCardConfig;
526
515
  // Calculate card classes - add special styling for child cards
527
516
  const cardClasses = `
528
- ${cardStyle?.backgroundColor || "bg-white"}
529
- ${cardStyle?.borderRadius || "rounded-lg"}
530
- ${cardStyle?.shadow || "shadow-sm"}
531
- ${row.isChild
532
- ? "border-l-4 border-l-blue-300"
533
- : cardStyle?.border || "border border-gray-100"}
534
- ${cardStyle?.padding || "p-4"}
535
- ${cardStyle?.marginBottom || "mb-4"}
536
- ${row.isChild ? "bg-opacity-90" : ""}
517
+ ${cardStyle?.backgroundColor || 'bg-white'}
518
+ ${cardStyle?.borderRadius || 'rounded-lg'}
519
+ ${cardStyle?.shadow || 'shadow-sm'}
520
+ ${row.isChild ? 'border-l-4 border-l-blue-300' : cardStyle?.border || 'border border-gray-100'}
521
+ ${cardStyle?.padding || 'p-4'}
522
+ ${cardStyle?.marginBottom || 'mb-4'}
523
+ ${row.isChild ? 'bg-opacity-90' : ''}
537
524
  w-full h-full
538
525
  `;
539
526
  return (react_1.default.createElement("div", { className: cardClasses },
540
527
  react_1.default.createElement("div", { className: "flex items-start gap-2" },
541
528
  showFolderIcon && (react_1.default.createElement("div", { className: "mr-3 flex-shrink-0" },
542
- react_1.default.createElement("div", { className: "w-10 h-10 flex items-center justify-center" }, row.data &&
543
- row.data.find((item) => item.hasImage)?.imageUrl ? (react_1.default.createElement(image_1.default, { src: row.data.find((item) => item.hasImage)?.imageUrl ||
544
- "/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" }))))),
529
+ react_1.default.createElement("div", { className: "w-10 h-10 flex items-center justify-center" }, row.data && row.data.find((item) => item.hasImage)?.imageUrl ? (react_1.default.createElement(image_1.default, { src: row.data.find((item) => item.hasImage)?.imageUrl || '/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" }))))),
545
530
  react_1.default.createElement("div", null, isMobileCardSelectable && (react_1.default.createElement("div", { className: "relative flex-shrink-0 flex" },
546
531
  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) => {
547
532
  if (el) {
@@ -555,7 +540,7 @@ pageIndex = 0, // Default to first page (0-indexed)
555
540
  level > 0 && (react_1.default.createElement("div", { className: `h-2 w-2 rounded-full bg-blue-${Math.min(400 + level * 100, 900)} mr-2 flex-shrink-0` })),
556
541
  react_1.default.createElement("h3", { className: "text-sm font-medium truncate" }, title)),
557
542
  react_1.default.createElement("p", { className: "text-xs text-gray-500 mt-1 truncate" }, subtitle),
558
- price && (react_1.default.createElement("p", { className: "text-sm font-semibold mt-1" }, price)),
543
+ price && react_1.default.createElement("p", { className: "text-sm font-semibold mt-1" }, price),
559
544
  status && (react_1.default.createElement("div", { className: "mt-2" },
560
545
  react_1.default.createElement("span", { className: `text-xs font-medium px-2 py-1 rounded-full ${getStatusClass(statusClass)} bg-opacity-10` }, status)))),
561
546
  react_1.default.createElement("div", { className: "flex items-center flex-shrink-0 ml-2" },
@@ -563,38 +548,34 @@ pageIndex = 0, // Default to first page (0-indexed)
563
548
  e.stopPropagation();
564
549
  handleRowExpandToggle(row.id, e);
565
550
  }, className: "p-2 hover:bg-gray-100 rounded" },
566
- 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" : ""}` },
551
+ 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' : ''}` },
567
552
  react_1.default.createElement("path", { d: "M15 5L8 12L15 19", stroke: "rgba(0, 0, 0, 0.40)", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })))),
568
553
  showFavoriteIcon && (react_1.default.createElement("button", { className: "p-2 hover:bg-gray-100 rounded" },
569
554
  react_1.default.createElement(image_1.default, { src: isFavorited
570
- ? favoriteFilledIconPath ?? "/defaultFilledIcon.svg"
571
- : favoriteOutlineIconPath ?? "/defaultOutlineIcon.svg", alt: "favorite", width: 20, height: 20, className: isFavorited ? "text-yellow-400" : "text-gray-400" }))),
572
- (typeof mobileCardConfig.showMoreOptions === "function"
555
+ ? favoriteFilledIconPath ?? '/defaultFilledIcon.svg'
556
+ : favoriteOutlineIconPath ?? '/defaultOutlineIcon.svg', alt: "favorite", width: 20, height: 20, className: isFavorited ? 'text-yellow-400' : 'text-gray-400' }))),
557
+ (typeof mobileCardConfig.showMoreOptions === 'function'
573
558
  ? mobileCardConfig.showMoreOptions(row)
574
559
  : mobileCardConfig.showMoreOptions) &&
575
560
  modalActions &&
576
561
  modalActions.length > 0 &&
577
- (typeof showModalIcon === "function"
578
- ? showModalIcon(row)
579
- : showModalIcon) && (react_1.default.createElement("div", { className: "relative" },
580
- react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: `p-2 hover:bg-gray-100 rounded ${ShowActionModal
581
- ? ""
582
- : "opacity-50 cursor-not-allowed "} ` },
583
- react_1.default.createElement(image_1.default, { src: moreOptionsIconPath || "/placeholder.svg", alt: "menu", width: 20, height: 20, className: `${ShowActionModal
584
- ? ""
585
- : "opacity-50 cursor-not-allowed"}` })),
586
- 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: {
587
- position: "fixed",
588
- top: `${mousePosition.y}px`,
562
+ (typeof showModalIcon === 'function' ? showModalIcon(row) : showModalIcon) && (react_1.default.createElement("div", { className: "relative" },
563
+ react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: `p-2 hover:bg-gray-100 rounded ${ShowActionModal ? '' : 'opacity-50 cursor-not-allowed '} ` },
564
+ react_1.default.createElement(image_1.default, { src: moreOptionsIconPath || '/placeholder.svg', alt: "menu", width: 20, height: 20, className: `${ShowActionModal ? '' : 'opacity-50 cursor-not-allowed'}` })),
565
+ 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 ${actionModalTopClassName || ''}`, style: {
566
+ position: 'fixed',
567
+ top: actionModalTopClassName
568
+ ? `calc(${mousePosition.y}px + ${actionModalTopClassName})`
569
+ : `${mousePosition.y}px`,
589
570
  left: `${Math.max(0, Math.min(window.innerWidth - 160, mousePosition.x - 80) + 35)}px `, // Ensure modal stays within screen
590
571
  }, onClick: (e) => e.stopPropagation() },
591
- react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === "function"
572
+ react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === 'function'
592
573
  ? modalActions(row)
593
- : modalActions).map((action) => (react_1.default.createElement("li", { key: action.id, onClick: (e) => handleActionClick(action.id, row.id, e), className: `rounded-md p-2 text-sm font-normal text-opacity-70 w-full customTransition ${modalStyleOperationHandler(action.class)} ${action.tailwindClassName || ""} ` }, action.text)))))))))),
574
+ : modalActions).map((action) => (react_1.default.createElement("li", { key: action.id, onClick: (e) => handleActionClick(action.id, row.id, e), className: `rounded-md p-2 text-sm font-normal text-opacity-70 w-full customTransition ${modalStyleOperationHandler(action.class)} ${action.tailwindClassName || ''} ` }, action.text)))))))))),
594
575
  showAvatars && avatarItems.length > 0 && (react_1.default.createElement("div", { className: "flex items-center mt-3" },
595
576
  react_1.default.createElement("div", { className: "flex -space-x-2" },
596
577
  avatarItems.slice(0, maxVisibleAvatars).map((item, idx) => (react_1.default.createElement("div", { key: idx, className: "h-6 w-6 rounded-full border border-white overflow-hidden" },
597
- react_1.default.createElement(image_1.default, { src: item.value || "/placeholder.svg", alt: "Avatar", width: 24, height: 24, className: "h-full w-full object-cover" })))),
578
+ react_1.default.createElement(image_1.default, { src: item.value || '/placeholder.svg', alt: "Avatar", width: 24, height: 24, className: "h-full w-full object-cover" })))),
598
579
  avatarItems.length > maxVisibleAvatars && (react_1.default.createElement("div", { className: "h-6 w-6 rounded-full bg-gray-200 border border-white flex items-center justify-center text-xs text-gray-600" },
599
580
  "+",
600
581
  avatarItems.length - maxVisibleAvatars)))))))));
@@ -604,25 +585,23 @@ pageIndex = 0, // Default to first page (0-indexed)
604
585
  // Width for the expand/collapse control column
605
586
  return (react_1.default.createElement("div", { key: `row-container-${row.id}` },
606
587
  react_1.default.createElement("div", { className: `grid w-full items-center ${row.isChild
607
- ? childRowConfig.childRowClass || "bg-blue-300 bg-opacity-10"
588
+ ? childRowConfig.childRowClass || 'bg-blue-300 bg-opacity-10'
608
589
  : index % 2 === 0
609
- ? "bg-white"
610
- : "bg-[#c8cfd8] bg-opacity-[0.08]"} border-b border-solid border-black/15 ${onView ? "cursor-pointer hover:bg-blue-100" : ""} min-h-[60px] h-auto ${row.data?.some((item) => item.type === "avatar")
611
- ? "h-[60px] "
612
- : "h-14"}`, style: {
590
+ ? 'bg-white'
591
+ : 'bg-[#c8cfd8] bg-opacity-[0.08]'} border-b border-solid border-black/15 ${onView ? 'cursor-pointer hover:bg-blue-100' : ''} min-h-[60px] h-auto ${row.data?.some((item) => item.type === 'avatar') ? 'h-[60px] ' : 'h-14'}`, style: {
613
592
  gridTemplateColumns: isMobileView && mobileViewGridClassName
614
593
  ? mobileViewGridClassName
615
- : gridClassName || "repeat(auto-fit, minmax(100px, 1fr))",
594
+ : gridClassName || 'repeat(auto-fit, minmax(100px, 1fr))',
616
595
  }, onClick: () => {
617
596
  if (onView) {
618
597
  onView(row.id);
619
598
  }
620
599
  } },
621
- react_1.default.createElement("div", { className: `flex items-center justify-center gap-2 ${!row.hasChildren && "mr-[4px]"}`, style: { width: "55px" } },
600
+ react_1.default.createElement("div", { className: `flex items-center justify-center gap-2 ${!row.hasChildren && 'mr-[4px]'}`, style: { width: '55px' } },
622
601
  !row.hasChildren && !row.isChild && (react_1.default.createElement("span", { className: "text-xs text-gray-500 font-semibold flex-shrink-0 mr-1 " }, ((pageIndex || 1) - 1) * (itemsPerPage || 10) + index + 1)),
623
602
  react_1.default.createElement("div", { className: "flex items-center justify-center gap-1" },
624
603
  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" },
625
- 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" : ""}` },
604
+ 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' : ''}` },
626
605
  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 ? (
627
606
  // Child row indicator
628
607
  react_1.default.createElement("div", { className: "h-2 w-2 rounded-full bg-black/20 flex-shrink-0" })) : null,
@@ -634,18 +613,16 @@ pageIndex = 0, // Default to first page (0-indexed)
634
613
  }, disabled: checkBoxDisable }),
635
614
  isIndeterminate(row.id) ? (react_1.default.createElement("div", { className: "pointer-events-none absolute left-[5px] top-[9px] w-2.5 h-0.5 bg-blue-500" })) : (react_1.default.createElement("svg", { className: "pointer-events-none absolute left-[5px] top-[5px] h-2.5 w-2.5 fill-white opacity-0 transition-opacity peer-checked:opacity-100", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" },
636
615
  react_1.default.createElement("path", { d: "M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" }))))))),
637
- row?.data?.map((item, colIndex) => (react_1.default.createElement("div", { key: `${item.id}-${colIndex}`, className: `h-full select-none text-xs font-medium min-w-0 flex items-center ${item.type === "avatar" ||
638
- item.type === "operation" ||
639
- item.type === "text"
640
- ? ""
641
- : ""}`, style: {
616
+ row?.data?.map((item, colIndex) => (react_1.default.createElement("div", { key: `${item.id}-${colIndex}`, className: `h-full select-none text-xs font-medium min-w-0 flex items-center ${item.type === 'avatar' || item.type === 'operation' || item.type === 'text'
617
+ ? ''
618
+ : ''}`, style: {
642
619
  ...item.inlineCSS,
643
- textAlign: item.textAlign || "left",
644
- justifyContent: item.textAlign === "right"
645
- ? "flex-end"
646
- : item.textAlign === "center"
647
- ? "center"
648
- : "flex-start",
620
+ textAlign: item.textAlign || 'left',
621
+ justifyContent: item.textAlign === 'right'
622
+ ? 'flex-end'
623
+ : item.textAlign === 'center'
624
+ ? 'center'
625
+ : 'flex-start',
649
626
  } },
650
627
  colIndex === 0 && row.isChild && selectable && (react_1.default.createElement("div", { className: "flex items-center" },
651
628
  react_1.default.createElement("div", { style: {
@@ -660,29 +637,25 @@ pageIndex = 0, // Default to first page (0-indexed)
660
637
  isIndeterminate(row.id) ? (react_1.default.createElement("div", { className: "pointer-events-none absolute left-[5px] top-[9px] w-2.5 h-0.5 bg-blue-500" })) : (react_1.default.createElement("svg", { className: "pointer-events-none absolute left-[5px] top-[5px] h-2.5 w-2.5 fill-white opacity-0 transition-opacity peer-checked:opacity-100", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" },
661
638
  react_1.default.createElement("path", { d: "M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" })))))),
662
639
  renderCellContent(item)))),
663
- actions && (react_1.default.createElement("div", { className: `w-24 py-4 flex items-center justify-end text-sm font-medium ${actionButtonsStyle || ""}` },
640
+ actions && (react_1.default.createElement("div", { className: `w-24 py-4 flex items-center justify-end text-sm font-medium ${actionButtonsStyle || ''}` },
664
641
  react_1.default.createElement("div", { className: "flex items-center justify-center gap-2" },
665
642
  onEdit && (react_1.default.createElement("button", { onClick: (e) => {
666
643
  e.stopPropagation();
667
644
  onEdit(row.id);
668
645
  }, className: "p-1 mb-[5px]" },
669
- react_1.default.createElement(image_1.default, { src: iconsSRC?.editIcon || "/placeholder.svg", alt: "edit", width: 18, height: 18, className: iconsSRC?.editIconTailwindStyle || "" }))),
646
+ react_1.default.createElement(image_1.default, { src: iconsSRC?.editIcon || '/placeholder.svg', alt: "edit", width: 18, height: 18, className: iconsSRC?.editIconTailwindStyle || '' }))),
670
647
  react_1.default.createElement("div", { className: "relative" },
671
648
  modalActions &&
672
649
  modalActions.length > 0 &&
673
- (typeof showModalIcon === "function"
674
- ? showModalIcon(row)
675
- : showModalIcon) ? (react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: "", "data-row-id": row.id },
676
- react_1.default.createElement(image_1.default, { src: iconsSRC?.moreIcon || "/placeholder.svg", alt: "menu", width: 18, height: 18, className: iconsSRC?.moreIconTailwindStyle || "" }))) : (
650
+ (typeof showModalIcon === 'function' ? showModalIcon(row) : showModalIcon) ? (react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: "", "data-row-id": row.id },
651
+ react_1.default.createElement(image_1.default, { src: iconsSRC?.moreIcon || '/placeholder.svg', alt: "menu", width: 18, height: 18, className: iconsSRC?.moreIconTailwindStyle || '' }))) : (
677
652
  // Render an invisible placeholder to maintain spacing when icon is hidden
678
653
  react_1.default.createElement("div", { className: "w-[18px] h-[18px]" })),
679
654
  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: {
680
- position: "fixed",
655
+ position: 'fixed',
681
656
  top: (() => {
682
657
  // Get all visible rows for the current view
683
- const allRows = isMobileView
684
- ? getAllMobileRows()
685
- : rows;
658
+ const allRows = isMobileView ? getAllMobileRows() : rows;
686
659
  // Find the index of the current row
687
660
  const currentRowIndex = allRows?.findIndex((r) => r.id === row.id);
688
661
  // Check if this is one of the last 3 rows
@@ -694,9 +667,9 @@ pageIndex = 0, // Default to first page (0-indexed)
694
667
  })(),
695
668
  left: `${mousePosition.x + 20}px`,
696
669
  }, onClick: (e) => e.stopPropagation() },
697
- react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === "function"
670
+ react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === 'function'
698
671
  ? modalActions(row)
699
- : modalActions).map((action) => (react_1.default.createElement("li", { key: action.id, onClick: (e) => handleActionClick(action.id, row.id, e), className: `rounded-md p-2 text-sm font-normal text-opacity-70 w-full cursor-pointer ${modalStyleOperationHandler(action.class)} customTransition ${action.tailwindClassName || ""} ` }, action.text))))))))))),
672
+ : modalActions).map((action) => (react_1.default.createElement("li", { key: action.id, onClick: (e) => handleActionClick(action.id, row.id, e), className: `rounded-md p-2 text-sm font-normal text-opacity-70 w-full cursor-pointer ${modalStyleOperationHandler(action.class)} customTransition ${action.tailwindClassName || ''} ` }, action.text))))))))))),
700
673
  row.hasChildren &&
701
674
  expandedRows.includes(row.id) &&
702
675
  row.childRows &&
@@ -712,8 +685,8 @@ pageIndex = 0, // Default to first page (0-indexed)
712
685
  }
713
686
  // Show no items found if rows are empty or null and not loading
714
687
  if (!loadingProps.isLoading && rows?.length === 0) {
715
- 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,
716
- react_1.default.createElement(image_1.default, { src: noItemFoundProps?.imagePath || "/icons/no-data.svg", alt: "No items found", width: 120, height: 120 }),
688
+ 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,
689
+ react_1.default.createElement(image_1.default, { src: noItemFoundProps?.imagePath || '/icons/no-data.svg', alt: "No items found", width: 120, height: 120 }),
717
690
  react_1.default.createElement("p", { className: "mt-4 text-gray-500 text-sm" },
718
691
  noItemFoundProps?.title,
719
692
  " "))) : (react_1.default.createElement(react_1.default.Fragment, null,
@@ -728,7 +701,7 @@ pageIndex = 0, // Default to first page (0-indexed)
728
701
  loadingProps.loadingText && loadingProps.loadingText));
729
702
  }
730
703
  return (react_1.default.createElement(react_1.default.Fragment, null,
731
- mobileCardConfig.enabled && (react_1.default.createElement("div", { className: `lg:hidden grid ${mobileCardConfig.gridLayoutClassName}` }, mobileRows.map((row) => (react_1.default.createElement("div", { key: `mobile-grid-item-${row.id}`, className: `col-span-1 ${row.isChild ? "pl-2" : ""}` }, renderMobileCard(row)))))),
732
- react_1.default.createElement("div", { className: `${mobileCardConfig.enabled ? "hidden lg:block" : ""} w-full` }, rows?.map((row, index) => renderTableRow(row, index, index === rows.length - 1)))));
704
+ mobileCardConfig.enabled && (react_1.default.createElement("div", { className: `lg:hidden grid ${mobileCardConfig.gridLayoutClassName}` }, mobileRows.map((row) => (react_1.default.createElement("div", { key: `mobile-grid-item-${row.id}`, className: `col-span-1 ${row.isChild ? 'pl-2' : ''}` }, renderMobileCard(row)))))),
705
+ react_1.default.createElement("div", { className: `${mobileCardConfig.enabled ? 'hidden lg:block' : ''} w-full` }, rows?.map((row, index) => renderTableRow(row, index, index === rows.length - 1)))));
733
706
  };
734
707
  exports.default = ModernTable;
@@ -1,10 +1,10 @@
1
- import { CSSProperties } from "react";
1
+ import { CSSProperties } from 'react';
2
2
  export interface DataItem {
3
3
  id: number;
4
- type: "text" | "avatar" | "status" | "operation" | "icon" | "date" | "price" | "contactNumber";
4
+ type: 'text' | 'avatar' | 'status' | 'operation' | 'icon' | 'date' | 'price' | 'contactNumber';
5
5
  value: string | number | boolean | null;
6
6
  statusClass?: string;
7
- textAlign?: "left" | "center" | "right";
7
+ textAlign?: 'left' | 'center' | 'right';
8
8
  inlineCSS?: CSSProperties;
9
9
  contentClass?: string;
10
10
  isTitle?: boolean;
@@ -74,6 +74,7 @@ export interface ModernTableProps {
74
74
  onSelectionChange?: (id: number | number[]) => void;
75
75
  checkBoxDisable?: boolean;
76
76
  actions?: boolean;
77
+ actionModalTopClassName?: string;
77
78
  ShowActionModal?: boolean;
78
79
  modalActions: ModalAction[] | ((row: TableRowData) => ModalAction[]);
79
80
  noItemFoundProps?: NoItemFoundProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.18.7",
3
+ "version": "0.18.9",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {