hi-tm 0.2.6 → 0.2.8

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.
@@ -51,10 +51,7 @@ const react_1 = __importStar(require("react"));
51
51
  *
52
52
  * @returns {React.JSX.Element} - A React component for a toggle switch.
53
53
  */
54
- const Toggle = ({ label, value, textError, onChangeValueHandler, style = {
55
- margin: "mt-2",
56
- width: "w-full",
57
- }, }) => {
54
+ const Toggle = ({ label, value, textError, onChangeValueHandler, style, }) => {
58
55
  const [isChecked, setIsChecked] = (0, react_1.useState)(value ?? false);
59
56
  const handleToggle = () => {
60
57
  const newValue = !isChecked;
@@ -71,7 +68,7 @@ const Toggle = ({ label, value, textError, onChangeValueHandler, style = {
71
68
  return textError === "" || textError === null || textError.trim() === "";
72
69
  };
73
70
  return (react_1.default.createElement(react_1.default.Fragment, null,
74
- react_1.default.createElement("div", { onClick: handleToggle, className: `bg-primaryBackGroundWhite cursor-pointer text-primaryTextColor flex flex-row items-center justify-between border border-solid border-gray-secondary h-12 px-4 rounded-2xl ${style.margin} ${style.width}` },
71
+ react_1.default.createElement("div", { onClick: handleToggle, style: style, className: `bg-primaryBackGroundWhite cursor-pointer text-primaryTextColor flex flex-row items-center justify-between border border-solid border-gray-secondary h-12 px-4 rounded-2xl ` },
75
72
  react_1.default.createElement("div", { className: `w-full relative flex flex-row items-center justify-between gap-4 py-2 md:py-0 select-none-custom ` },
76
73
  label,
77
74
  react_1.default.createElement("div", { className: "absolute left-0 inline-block w-8 h-4 rounded-full cursor-pointer" },
@@ -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
38
  }, onView, onAction, selectable, onSelectionChange, actions, ShowActionModal = true, modalActions, 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,16 +103,17 @@ 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] = typeof firstWidth === 'string' ? firstWidth : `${firstWidth}px`;
112
+ widths[colIndex] =
113
+ typeof firstWidth === "string" ? firstWidth : `${firstWidth}px`;
113
114
  }
114
115
  else {
115
- widths[colIndex] = 'auto';
116
+ widths[colIndex] = "auto";
116
117
  }
117
118
  }
118
119
  else {
@@ -133,16 +134,17 @@ pageIndex = 0, // Default to first page (0-indexed)
133
134
  (0, react_2.useEffect)(() => {
134
135
  const handleClickOutside = (event) => {
135
136
  const target = event.target;
136
- if (target.closest('.modal-content')) {
137
+ if (target.closest(".modal-content")) {
137
138
  return;
138
139
  }
139
- if (modalRef.current && !modalRef.current.contains(event.target)) {
140
+ if (modalRef.current &&
141
+ !modalRef.current.contains(event.target)) {
140
142
  setActiveModal(null);
141
143
  }
142
144
  };
143
- document.addEventListener('mousedown', handleClickOutside);
145
+ document.addEventListener("mousedown", handleClickOutside);
144
146
  return () => {
145
- document.removeEventListener('mousedown', handleClickOutside);
147
+ document.removeEventListener("mousedown", handleClickOutside);
146
148
  };
147
149
  }, []);
148
150
  (0, react_2.useEffect)(() => {
@@ -151,9 +153,9 @@ pageIndex = 0, // Default to first page (0-indexed)
151
153
  setActiveModal(null);
152
154
  }
153
155
  };
154
- window.addEventListener('scroll', handleScroll, { passive: true });
156
+ window.addEventListener("scroll", handleScroll, { passive: true });
155
157
  return () => {
156
- window.removeEventListener('scroll', handleScroll);
158
+ window.removeEventListener("scroll", handleScroll);
157
159
  };
158
160
  }, [activeModal]);
159
161
  const [mousePosition, setMousePosition] = (0, react_2.useState)({ x: 0, y: 0 });
@@ -172,40 +174,42 @@ pageIndex = 0, // Default to first page (0-indexed)
172
174
  };
173
175
  const handleRowExpandToggle = (rowId, e) => {
174
176
  e.stopPropagation();
175
- setExpandedRows((prev) => prev.includes(rowId) ? prev.filter((id) => id !== rowId) : [...prev, rowId]);
177
+ setExpandedRows((prev) => prev.includes(rowId)
178
+ ? prev.filter((id) => id !== rowId)
179
+ : [...prev, rowId]);
176
180
  };
177
181
  const getStatusClass = (statusClass) => {
178
182
  switch (statusClass) {
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';
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";
191
195
  default:
192
- return '';
196
+ return "";
193
197
  }
194
198
  };
195
199
  const renderCellContent = (item) => {
196
200
  switch (item.type) {
197
- case 'status':
201
+ case "status":
198
202
  return (react_1.default.createElement("p", { className: `text-xs font-medium w-fit ${item.contentClass} ${getStatusClass(item.statusClass)} ` }, 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)));
203
+ case "price":
204
+ return (react_1.default.createElement("p", { className: `${item.contentClass || "text-start"} text-sm w-full truncate ` }, formatWithCommas(item.value)));
201
205
  default:
202
206
  return (react_1.default.createElement("div", { onClick: () => {
203
207
  if (item.onClick) {
204
208
  item.onClick(item.id);
205
209
  }
206
210
  }, className: "flex items-center gap-2 w-full" }, item.hasImage && item.imageUrl !== null ? (react_1.default.createElement("div", { className: "flex items-center gap-2 w-full" },
207
- react_1.default.createElement(SafeImage_1.default, { src: item.imageUrl || '/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' }),
208
- 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))));
211
+ react_1.default.createElement(SafeImage_1.default, { src: item.imageUrl || "/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" }),
212
+ 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))));
209
213
  }
210
214
  };
211
215
  // Update selectedRows when selectedItems prop changes
@@ -312,7 +316,10 @@ pageIndex = 0, // Default to first page (0-indexed)
312
316
  };
313
317
  const row = findRow(rows, rowId);
314
318
  // If row has no children, it can't be indeterminate
315
- if (!row || !row.hasChildren || !row.childRows || row.childRows.length === 0) {
319
+ if (!row ||
320
+ !row.hasChildren ||
321
+ !row.childRows ||
322
+ row.childRows.length === 0) {
316
323
  return false;
317
324
  }
318
325
  // Check if the row itself is selected
@@ -325,7 +332,9 @@ pageIndex = 0, // Default to first page (0-indexed)
325
332
  return true;
326
333
  }
327
334
  // Check grandchildren if they exist
328
- if (child.hasChildren && child.childRows && child.childRows.length > 0) {
335
+ if (child.hasChildren &&
336
+ child.childRows &&
337
+ child.childRows.length > 0) {
329
338
  if (hasSelectedDescendant(child.childRows)) {
330
339
  return true;
331
340
  }
@@ -341,7 +350,9 @@ pageIndex = 0, // Default to first page (0-indexed)
341
350
  return false;
342
351
  }
343
352
  // Check grandchildren if they exist
344
- if (child.hasChildren && child.childRows && child.childRows.length > 0) {
353
+ if (child.hasChildren &&
354
+ child.childRows &&
355
+ child.childRows.length > 0) {
345
356
  if (!areAllDescendantsSelected(child.childRows)) {
346
357
  return false;
347
358
  }
@@ -353,7 +364,7 @@ pageIndex = 0, // Default to first page (0-indexed)
353
364
  const hasAllSelected = areAllDescendantsSelected(row.childRows);
354
365
  // Indeterminate if some but not all descendants are selected
355
366
  // Or if the parent is not selected but some children are
356
- return (hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected);
367
+ return ((hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected));
357
368
  };
358
369
  // Function to check if a row is selected
359
370
  const isSelected = (rowId) => {
@@ -375,47 +386,47 @@ pageIndex = 0, // Default to first page (0-indexed)
375
386
  };
376
387
  // Extract title and subtitle from row data
377
388
  const extractCardData = (row) => {
378
- let title = '';
379
- let subtitle = '';
380
- let icon = '';
381
- let status = '';
382
- let statusClass = '';
383
- let price = '';
389
+ let title = "";
390
+ let subtitle = "";
391
+ let icon = "";
392
+ let status = "";
393
+ let statusClass = "";
394
+ let price = "";
384
395
  if (!row.data)
385
396
  return { title, subtitle, icon, status, statusClass, price };
386
397
  // Find title (usually first text item)
387
- const titleItem = row.data.find((item) => item.type === 'text' && item.value);
398
+ const titleItem = row.data.find((item) => item.type === "text" && item.value);
388
399
  if (titleItem) {
389
400
  title = titleItem.value;
390
401
  }
391
402
  else if (row.data.length > 0) {
392
403
  // Fallback to first item
393
- title = String(row.data[0].value || '');
404
+ title = String(row.data[0].value || "");
394
405
  }
395
406
  // Find subtitle (usually size or description)
396
- const subtitleItem = row.data.find((item) => item.type === 'text' && item.isSubtitle);
407
+ const subtitleItem = row.data.find((item) => item.type === "text" && item.isSubtitle);
397
408
  if (subtitleItem) {
398
409
  subtitle = subtitleItem.value;
399
410
  }
400
411
  else if (row.data.length > 1) {
401
412
  // Fallback to second item
402
- subtitle = String(row.data[1].value || '');
413
+ subtitle = String(row.data[1].value || "");
403
414
  }
404
415
  // Find status
405
- const statusItem = row.data.find((item) => item.type === 'status');
416
+ const statusItem = row.data.find((item) => item.type === "status");
406
417
  if (statusItem) {
407
- status = String(statusItem.value || '');
408
- statusClass = statusItem.statusClass || '';
418
+ status = String(statusItem.value || "");
419
+ statusClass = statusItem.statusClass || "";
409
420
  }
410
421
  // Find price (look for item with isPrice flag)
411
422
  const priceItem = row.data.find((item) => item.isPrice);
412
423
  if (priceItem) {
413
- price = String(priceItem.value || '');
424
+ price = String(priceItem.value || "");
414
425
  }
415
426
  // Find icon (usually avatar or image)
416
427
  const iconItem = row.data.find((item) => item.hasImage);
417
428
  if (iconItem && iconItem.value) {
418
- icon = String(iconItem.imageUrl || '');
429
+ icon = String(iconItem.imageUrl || "");
419
430
  }
420
431
  return { title, subtitle, icon, status, statusClass, price };
421
432
  };
@@ -423,7 +434,7 @@ pageIndex = 0, // Default to first page (0-indexed)
423
434
  const findAvatarItems = (row) => {
424
435
  if (!row.data)
425
436
  return [];
426
- return row.data.filter((item) => item.type === 'avatar' && item.isUserAvatar);
437
+ return row.data.filter((item) => item.type === "avatar" && item.isUserAvatar);
427
438
  };
428
439
  // Get all rows and their children for mobile view - updated for multi-level nesting
429
440
  const getAllMobileRows = () => {
@@ -457,24 +468,34 @@ pageIndex = 0, // Default to first page (0-indexed)
457
468
  const isFavorited = row.data.some((item) => item.isFavorite);
458
469
  const hasChildren = row.hasChildren && row.childRows && row?.childRows?.length > 0;
459
470
  const level = row.level || 0;
460
- const { cardStyle, showFolderIcon, folderIconPath, showFavoriteIcon, favoriteFilledIconPath, favoriteOutlineIconPath,
471
+ const { cardStyle, showFolderIcon, folderIconPath, isMobileCardSelectable, showFavoriteIcon, favoriteFilledIconPath, favoriteOutlineIconPath,
461
472
  // showMoreOptions,
462
473
  moreOptionsIconPath, showAvatars, maxVisibleAvatars = 0, } = mobileCardConfig;
463
474
  // Calculate card classes - add special styling for child cards
464
475
  const cardClasses = `
465
- ${cardStyle?.backgroundColor || 'bg-white'}
466
- ${cardStyle?.borderRadius || 'rounded-lg'}
467
- ${cardStyle?.shadow || 'shadow-sm'}
468
- ${row.isChild ? 'border-l-4 border-l-blue-300' : cardStyle?.border || 'border border-gray-100'}
469
- ${cardStyle?.padding || 'p-4'}
470
- ${cardStyle?.marginBottom || 'mb-4'}
471
- ${row.isChild ? 'bg-opacity-90' : ''}
476
+ ${cardStyle?.backgroundColor || "bg-white"}
477
+ ${cardStyle?.borderRadius || "rounded-lg"}
478
+ ${cardStyle?.shadow || "shadow-sm"}
479
+ ${row.isChild
480
+ ? "border-l-4 border-l-blue-300"
481
+ : cardStyle?.border || "border border-gray-100"}
482
+ ${cardStyle?.padding || "p-4"}
483
+ ${cardStyle?.marginBottom || "mb-4"}
484
+ ${row.isChild ? "bg-opacity-90" : ""}
472
485
  w-full h-full
473
486
  `;
474
487
  return (react_1.default.createElement("div", { className: cardClasses },
475
488
  react_1.default.createElement("div", { className: "flex items-start gap-2" },
476
489
  showFolderIcon && (react_1.default.createElement("div", { className: "mr-3 flex-shrink-0" },
477
- 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" }))))),
490
+ react_1.default.createElement("div", { className: "w-10 h-10 flex items-center justify-center" }, row.data &&
491
+ row.data.find((item) => item.hasImage)?.imageUrl ? (react_1.default.createElement(image_1.default, { src: row.data.find((item) => item.hasImage)?.imageUrl ||
492
+ "/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" }))))),
493
+ react_1.default.createElement("div", null, isMobileCardSelectable && (react_1.default.createElement("div", { className: "relative flex-shrink-0 flex" },
494
+ 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) => {
495
+ if (el) {
496
+ el.indeterminate = isIndeterminate(row.id);
497
+ }
498
+ } })))),
478
499
  react_1.default.createElement("div", { className: "flex-1 min-w-0" },
479
500
  react_1.default.createElement("div", { className: "flex items-start justify-between" },
480
501
  react_1.default.createElement("div", { className: "overflow-hidden" },
@@ -482,7 +503,7 @@ pageIndex = 0, // Default to first page (0-indexed)
482
503
  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` })),
483
504
  react_1.default.createElement("h3", { className: "text-sm font-medium truncate" }, title)),
484
505
  react_1.default.createElement("p", { className: "text-xs text-gray-500 mt-1 truncate" }, subtitle),
485
- price && react_1.default.createElement("p", { className: "text-sm font-semibold mt-1" }, price),
506
+ price && (react_1.default.createElement("p", { className: "text-sm font-semibold mt-1" }, price)),
486
507
  status && (react_1.default.createElement("div", { className: "mt-2" },
487
508
  react_1.default.createElement("span", { className: `text-xs font-medium px-2 py-1 rounded-full ${getStatusClass(statusClass)} bg-opacity-10` }, status)))),
488
509
  react_1.default.createElement("div", { className: "flex items-center flex-shrink-0 ml-2" },
@@ -490,32 +511,38 @@ pageIndex = 0, // Default to first page (0-indexed)
490
511
  e.stopPropagation();
491
512
  handleRowExpandToggle(row.id, e);
492
513
  }, className: "p-2 hover:bg-gray-100 rounded" },
493
- 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' : ''}` },
514
+ 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" : ""}` },
494
515
  react_1.default.createElement("path", { d: "M15 5L8 12L15 19", stroke: "rgba(0, 0, 0, 0.40)", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })))),
495
516
  showFavoriteIcon && (react_1.default.createElement("button", { className: "p-2 hover:bg-gray-100 rounded" },
496
517
  react_1.default.createElement(image_1.default, { src: isFavorited
497
- ? favoriteFilledIconPath ?? '/defaultFilledIcon.svg'
498
- : favoriteOutlineIconPath ?? '/defaultOutlineIcon.svg', alt: "favorite", width: 20, height: 20, className: isFavorited ? 'text-yellow-400' : 'text-gray-400' }))),
499
- (typeof mobileCardConfig.showMoreOptions === 'function'
518
+ ? favoriteFilledIconPath ?? "/defaultFilledIcon.svg"
519
+ : favoriteOutlineIconPath ?? "/defaultOutlineIcon.svg", alt: "favorite", width: 20, height: 20, className: isFavorited ? "text-yellow-400" : "text-gray-400" }))),
520
+ (typeof mobileCardConfig.showMoreOptions === "function"
500
521
  ? mobileCardConfig.showMoreOptions(row)
501
522
  : mobileCardConfig.showMoreOptions) &&
502
523
  modalActions &&
503
524
  modalActions.length > 0 &&
504
- (typeof showModalIcon === 'function' ? showModalIcon(row) : showModalIcon) && (react_1.default.createElement("div", { className: "relative" },
505
- 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 '} ` },
506
- react_1.default.createElement(image_1.default, { src: moreOptionsIconPath || '/placeholder.svg', alt: "menu", width: 20, height: 20, className: `${ShowActionModal ? '' : 'opacity-50 cursor-not-allowed'}` })),
525
+ (typeof showModalIcon === "function"
526
+ ? showModalIcon(row)
527
+ : showModalIcon) && (react_1.default.createElement("div", { className: "relative" },
528
+ react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: `p-2 hover:bg-gray-100 rounded ${ShowActionModal
529
+ ? ""
530
+ : "opacity-50 cursor-not-allowed "} ` },
531
+ react_1.default.createElement(image_1.default, { src: moreOptionsIconPath || "/placeholder.svg", alt: "menu", width: 20, height: 20, className: `${ShowActionModal
532
+ ? ""
533
+ : "opacity-50 cursor-not-allowed"}` })),
507
534
  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: {
508
- position: 'fixed',
535
+ position: "fixed",
509
536
  top: `${mousePosition.y}px`,
510
537
  left: `${Math.max(0, Math.min(window.innerWidth - 160, mousePosition.x - 80) + 35)}px `, // Ensure modal stays within screen
511
538
  }, onClick: (e) => e.stopPropagation() },
512
- react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === 'function'
539
+ react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === "function"
513
540
  ? modalActions(row)
514
- : 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)))))))))),
541
+ : 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)))))))))),
515
542
  showAvatars && avatarItems.length > 0 && (react_1.default.createElement("div", { className: "flex items-center mt-3" },
516
543
  react_1.default.createElement("div", { className: "flex -space-x-2" },
517
544
  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" },
518
- 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" })))),
545
+ 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" })))),
519
546
  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" },
520
547
  "+",
521
548
  avatarItems.length - maxVisibleAvatars)))))))));
@@ -525,23 +552,25 @@ pageIndex = 0, // Default to first page (0-indexed)
525
552
  // Width for the expand/collapse control column
526
553
  return (react_1.default.createElement("div", { key: `row-container-${row.id}` },
527
554
  react_1.default.createElement("div", { className: `grid w-full items-center ${row.isChild
528
- ? childRowConfig.childRowClass || 'bg-blue-300 bg-opacity-10'
555
+ ? childRowConfig.childRowClass || "bg-blue-300 bg-opacity-10"
529
556
  : index % 2 === 0
530
- ? 'bg-white'
531
- : 'bg-[#c8cfd8] bg-opacity-[0.08]'} border-b border-solid border-black/15 ${onView ? 'cursor-pointer hover:bg-blue-100' : ''} ${row.data?.some((item) => item.type === 'avatar') ? 'h-[60px]' : 'h-14'}`, style: {
557
+ ? "bg-white"
558
+ : "bg-[#c8cfd8] bg-opacity-[0.08]"} border-b border-solid border-black/15 ${onView ? "cursor-pointer hover:bg-blue-100" : ""} ${row.data?.some((item) => item.type === "avatar")
559
+ ? "h-[60px]"
560
+ : "h-14"}`, style: {
532
561
  gridTemplateColumns: isMobileView && mobileViewGridClassName
533
562
  ? mobileViewGridClassName
534
- : gridClassName || 'repeat(auto-fit, minmax(100px, 1fr))',
563
+ : gridClassName || "repeat(auto-fit, minmax(100px, 1fr))",
535
564
  }, onClick: () => {
536
565
  if (onView) {
537
566
  onView(row.id);
538
567
  }
539
568
  } },
540
- react_1.default.createElement("div", { className: `flex items-center justify-center gap-2 ${!row.hasChildren && 'mr-[4px]'}`, style: { width: '55px' } },
569
+ react_1.default.createElement("div", { className: `flex items-center justify-center gap-2 ${!row.hasChildren && "mr-[4px]"}`, style: { width: "55px" } },
541
570
  !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)),
542
571
  react_1.default.createElement("div", { className: "flex items-center justify-center gap-1" },
543
572
  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" },
544
- 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' : ''}` },
573
+ 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" : ""}` },
545
574
  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 ? (
546
575
  // Child row indicator
547
576
  react_1.default.createElement("div", { className: "h-2 w-2 rounded-full bg-black/20 flex-shrink-0" })) : null,
@@ -553,16 +582,18 @@ pageIndex = 0, // Default to first page (0-indexed)
553
582
  } }),
554
583
  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" },
555
584
  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" }))))))),
556
- 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'
557
- ? ''
558
- : ''}`, style: {
585
+ 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" ||
586
+ item.type === "operation" ||
587
+ item.type === "text"
588
+ ? ""
589
+ : ""}`, style: {
559
590
  ...item.inlineCSS,
560
- textAlign: item.textAlign || 'left',
561
- justifyContent: item.textAlign === 'right'
562
- ? 'flex-end'
563
- : item.textAlign === 'center'
564
- ? 'center'
565
- : 'flex-start',
591
+ textAlign: item.textAlign || "left",
592
+ justifyContent: item.textAlign === "right"
593
+ ? "flex-end"
594
+ : item.textAlign === "center"
595
+ ? "center"
596
+ : "flex-start",
566
597
  } },
567
598
  colIndex === 0 && row.isChild && selectable && (react_1.default.createElement("div", { className: "flex items-center" },
568
599
  react_1.default.createElement("div", { style: {
@@ -577,25 +608,29 @@ pageIndex = 0, // Default to first page (0-indexed)
577
608
  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" },
578
609
  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" })))))),
579
610
  renderCellContent(item)))),
580
- actions && (react_1.default.createElement("div", { className: `w-24 py-4 flex items-center justify-end text-sm font-medium ${actionButtonsStyle || ''}` },
611
+ actions && (react_1.default.createElement("div", { className: `w-24 py-4 flex items-center justify-end text-sm font-medium ${actionButtonsStyle || ""}` },
581
612
  react_1.default.createElement("div", { className: "flex items-center justify-center gap-2" },
582
613
  onEdit && (react_1.default.createElement("button", { onClick: (e) => {
583
614
  e.stopPropagation();
584
615
  onEdit(row.id);
585
616
  }, className: "p-1 mb-[5px]" },
586
- react_1.default.createElement(image_1.default, { src: iconsSRC?.editIcon || '/placeholder.svg', alt: "edit", width: 18, height: 18, className: iconsSRC?.editIconTailwindStyle || '' }))),
617
+ react_1.default.createElement(image_1.default, { src: iconsSRC?.editIcon || "/placeholder.svg", alt: "edit", width: 18, height: 18, className: iconsSRC?.editIconTailwindStyle || "" }))),
587
618
  react_1.default.createElement("div", { className: "relative" },
588
619
  modalActions &&
589
620
  modalActions.length > 0 &&
590
- (typeof showModalIcon === 'function' ? showModalIcon(row) : showModalIcon) ? (react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: "", "data-row-id": row.id },
591
- react_1.default.createElement(image_1.default, { src: iconsSRC?.moreIcon || '/placeholder.svg', alt: "menu", width: 18, height: 18, className: iconsSRC?.moreIconTailwindStyle || '' }))) : (
621
+ (typeof showModalIcon === "function"
622
+ ? showModalIcon(row)
623
+ : showModalIcon) ? (react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: "", "data-row-id": row.id },
624
+ react_1.default.createElement(image_1.default, { src: iconsSRC?.moreIcon || "/placeholder.svg", alt: "menu", width: 18, height: 18, className: iconsSRC?.moreIconTailwindStyle || "" }))) : (
592
625
  // Render an invisible placeholder to maintain spacing when icon is hidden
593
626
  react_1.default.createElement("div", { className: "w-[18px] h-[18px]" })),
594
627
  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: {
595
- position: 'fixed',
628
+ position: "fixed",
596
629
  top: (() => {
597
630
  // Get all visible rows for the current view
598
- const allRows = isMobileView ? getAllMobileRows() : rows;
631
+ const allRows = isMobileView
632
+ ? getAllMobileRows()
633
+ : rows;
599
634
  // Find the index of the current row
600
635
  const currentRowIndex = allRows?.findIndex((r) => r.id === row.id);
601
636
  // Check if this is one of the last 3 rows
@@ -607,9 +642,9 @@ pageIndex = 0, // Default to first page (0-indexed)
607
642
  })(),
608
643
  left: `${mousePosition.x + 20}px`,
609
644
  }, onClick: (e) => e.stopPropagation() },
610
- react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === 'function'
645
+ react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === "function"
611
646
  ? modalActions(row)
612
- : 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))))))))))),
647
+ : 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))))))))))),
613
648
  row.hasChildren &&
614
649
  expandedRows.includes(row.id) &&
615
650
  row.childRows &&
@@ -625,8 +660,8 @@ pageIndex = 0, // Default to first page (0-indexed)
625
660
  }
626
661
  // Show no items found if rows are empty or null and not loading
627
662
  if (!loadingProps.isLoading && rows?.length === 0) {
628
- 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,
629
- react_1.default.createElement(image_1.default, { src: noItemFoundProps?.imagePath || '/icons/no-data.svg', alt: "No items found", width: 120, height: 120 }),
663
+ 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,
664
+ react_1.default.createElement(image_1.default, { src: noItemFoundProps?.imagePath || "/icons/no-data.svg", alt: "No items found", width: 120, height: 120 }),
630
665
  react_1.default.createElement("p", { className: "mt-4 text-gray-500 text-sm" },
631
666
  noItemFoundProps?.title,
632
667
  " "))) : (react_1.default.createElement(react_1.default.Fragment, null,
@@ -636,7 +671,7 @@ pageIndex = 0, // Default to first page (0-indexed)
636
671
  " ")))));
637
672
  }
638
673
  return (react_1.default.createElement(react_1.default.Fragment, null,
639
- 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)))))),
640
- react_1.default.createElement("div", { className: `${mobileCardConfig.enabled ? 'hidden lg:block' : ''} w-full` }, rows?.map((row, index) => renderTableRow(row, index, index === rows.length - 1)))));
674
+ 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)))))),
675
+ react_1.default.createElement("div", { className: `${mobileCardConfig.enabled ? "hidden lg:block" : ""} w-full` }, rows?.map((row, index) => renderTableRow(row, index, index === rows.length - 1)))));
641
676
  };
642
677
  exports.default = ModernTable;
@@ -43,6 +43,7 @@ export interface MobileCardConfig {
43
43
  showMoreOptions?: boolean | ((row: TableRowData) => boolean);
44
44
  moreOptionsIconPath?: string;
45
45
  showAvatars?: boolean;
46
+ isMobileCardSelectable: boolean;
46
47
  maxVisibleAvatars?: number;
47
48
  cardStyle?: {
48
49
  backgroundColor?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {