hi-tm 0.0.7 → 0.0.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.
@@ -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
  };
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const react_2 = require("react");
9
9
  const image_1 = __importDefault(require("next/image"));
10
+ const SafeImage_1 = __importDefault(require("@/elements/SafeImage"));
10
11
  // Simple Loader component defined inline to avoid import issues
11
12
  const Loader = () => {
12
13
  return (react_1.default.createElement("div", { className: "flex items-center justify-center" },
@@ -15,53 +16,53 @@ const Loader = () => {
15
16
  // Helper function to format numbers with commas
16
17
  const formatWithCommas = (value) => {
17
18
  if (value === undefined || value === null)
18
- return "";
19
- const numValue = typeof value === "string" ? Number.parseFloat(value) : value;
19
+ return '';
20
+ const numValue = typeof value === 'string' ? Number.parseFloat(value) : value;
20
21
  if (isNaN(numValue))
21
22
  return value.toString();
22
23
  return numValue.toLocaleString();
23
24
  };
24
25
  // Helper function to handle modal styles
25
26
  const modalStyleOperationHandler = (classType) => {
26
- if (classType === "delete") {
27
- return "hover:bg-red-500/20 text-red-700";
27
+ if (classType === 'delete') {
28
+ return 'hover:bg-red-500/20 text-red-700';
28
29
  }
29
30
  else {
30
- return "hover:bg-gray-500/10";
31
+ return 'hover:bg-gray-500/10';
31
32
  }
32
33
  };
33
34
  const ModernTable = ({ rows = [], onEdit, loadingProps = {
34
35
  isLoading: false,
35
- loadingText: "درحال دریافت اطلاعات",
36
+ loadingText: 'درحال دریافت اطلاعات',
36
37
  loadingIcon: react_1.default.createElement(Loader, null),
37
38
  }, onView, onAction, selectable, onSelectionChange, actions, ShowActionModal = true, modalActions, noItemFoundProps, selectedItems = [], iconsSRC,
38
39
  // Child row configuration with defaults
39
40
  childRowConfig = {
40
41
  expandByDefault: false,
41
- indentSize: "1.5rem",
42
- childRowClass: "bg-blue-300 bg-opacity-10",
42
+ indentSize: '1.5rem',
43
+ childRowClass: 'bg-blue-300 bg-opacity-10',
43
44
  },
44
45
  // Mobile card view configuration props
45
46
  mobileCardConfig = {
46
47
  enabled: true,
47
48
  showFolderIcon: true,
48
- folderIconPath: "",
49
+ folderIconPath: '',
49
50
  showFavoriteIcon: true,
50
- favoriteFilledIconPath: "/icons/star-filled.svg",
51
- favoriteOutlineIconPath: "/icons/star-outline.svg",
51
+ favoriteFilledIconPath: '/icons/star-filled.svg',
52
+ favoriteOutlineIconPath: '/icons/star-outline.svg',
52
53
  showMoreOptions: true,
53
- moreOptionsIconPath: "/icons/table/more.svg",
54
+ moreOptionsIconPath: '/icons/table/more.svg',
54
55
  showAvatars: true,
55
56
  maxVisibleAvatars: 2,
56
57
  cardStyle: {
57
- backgroundColor: "bg-white",
58
- borderRadius: "rounded-lg",
59
- shadow: "shadow-sm",
60
- border: "border border-gray-100",
61
- padding: "p-4",
62
- 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',
63
64
  },
64
- gridLayoutClassName: "grid-cols-1 sm:grid-cols-2 gap-4",
65
+ gridLayoutClassName: 'grid-cols-1 sm:grid-cols-2 gap-4',
65
66
  }, showModalIcon = true, actionButtonsStyle, gridClassName, isMobileView = false, // Default to false
66
67
  mobileViewGridClassName, itemsPerPage = 10, // Default to 10 items per page
67
68
  pageIndex = 0, // Default to first page (0-indexed)
@@ -102,17 +103,16 @@ pageIndex = 0, // Default to first page (0-indexed)
102
103
  .filter((row) => row.data &&
103
104
  row.data[colIndex] &&
104
105
  row.data[colIndex].inlineCSS &&
105
- "width" in (row.data[colIndex].inlineCSS || {}))
106
+ 'width' in (row.data[colIndex].inlineCSS || {}))
106
107
  .map((row) => row.data[colIndex]);
107
108
  if (columnsWithWidth.length > 0) {
108
109
  // Use the first defined width (could be enhanced to use max/average)
109
110
  const firstWidth = columnsWithWidth[0].inlineCSS?.width;
110
111
  if (firstWidth) {
111
- widths[colIndex] =
112
- typeof firstWidth === "string" ? firstWidth : `${firstWidth}px`;
112
+ widths[colIndex] = typeof firstWidth === 'string' ? firstWidth : `${firstWidth}px`;
113
113
  }
114
114
  else {
115
- widths[colIndex] = "auto";
115
+ widths[colIndex] = 'auto';
116
116
  }
117
117
  }
118
118
  else {
@@ -133,17 +133,16 @@ pageIndex = 0, // Default to first page (0-indexed)
133
133
  (0, react_2.useEffect)(() => {
134
134
  const handleClickOutside = (event) => {
135
135
  const target = event.target;
136
- if (target.closest(".modal-content")) {
136
+ if (target.closest('.modal-content')) {
137
137
  return;
138
138
  }
139
- if (modalRef.current &&
140
- !modalRef.current.contains(event.target)) {
139
+ if (modalRef.current && !modalRef.current.contains(event.target)) {
141
140
  setActiveModal(null);
142
141
  }
143
142
  };
144
- document.addEventListener("mousedown", handleClickOutside);
143
+ document.addEventListener('mousedown', handleClickOutside);
145
144
  return () => {
146
- document.removeEventListener("mousedown", handleClickOutside);
145
+ document.removeEventListener('mousedown', handleClickOutside);
147
146
  };
148
147
  }, []);
149
148
  (0, react_2.useEffect)(() => {
@@ -152,9 +151,9 @@ pageIndex = 0, // Default to first page (0-indexed)
152
151
  setActiveModal(null);
153
152
  }
154
153
  };
155
- window.addEventListener("scroll", handleScroll, { passive: true });
154
+ window.addEventListener('scroll', handleScroll, { passive: true });
156
155
  return () => {
157
- window.removeEventListener("scroll", handleScroll);
156
+ window.removeEventListener('scroll', handleScroll);
158
157
  };
159
158
  }, [activeModal]);
160
159
  const [mousePosition, setMousePosition] = (0, react_2.useState)({ x: 0, y: 0 });
@@ -173,42 +172,40 @@ pageIndex = 0, // Default to first page (0-indexed)
173
172
  };
174
173
  const handleRowExpandToggle = (rowId, e) => {
175
174
  e.stopPropagation();
176
- setExpandedRows((prev) => prev.includes(rowId)
177
- ? prev.filter((id) => id !== rowId)
178
- : [...prev, rowId]);
175
+ setExpandedRows((prev) => prev.includes(rowId) ? prev.filter((id) => id !== rowId) : [...prev, rowId]);
179
176
  };
180
177
  const getStatusClass = (statusClass) => {
181
178
  switch (statusClass) {
182
- case "success":
183
- return "text-[#37935f] px-4 py-2 rounded-lg bg-[#d1f4e0]";
184
- case "danger":
185
- return "text-[#d75482] rounded-lg bg-[#fdd0df] px-2 py-2";
186
- case "warning":
187
- return "text-yellow-700";
188
- case "info":
189
- return "text-blue-700";
190
- case "primary":
191
- return "text-[#6b46c1] rounded-lg bg-[#ede9f8] px-4 py-2";
192
- case "secondary":
193
- 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';
194
191
  default:
195
- return "";
192
+ return '';
196
193
  }
197
194
  };
198
195
  const renderCellContent = (item) => {
199
196
  switch (item.type) {
200
- case "status":
197
+ case 'status':
201
198
  return (react_1.default.createElement("p", { className: `text-xs font-medium w-fit ${item.contentClass} ${getStatusClass(item.statusClass)} ` }, item.value));
202
- case "price":
203
- 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)));
204
201
  default:
205
202
  return (react_1.default.createElement("div", { onClick: () => {
206
203
  if (item.onClick) {
207
204
  item.onClick(item.id);
208
205
  }
209
206
  }, className: "flex items-center gap-2 w-full" }, item.hasImage ? (react_1.default.createElement("div", { className: "flex items-center gap-2 w-full" },
210
- react_1.default.createElement(image_1.default, { src: item.imageUrl || "/placeholder.svg", alt: item.value?.toString() || "Table item", width: item.imageWidth || 24, height: item.imageHeight || 24, className: `${item.imageClass || "h-6 w-6 object-cover"}` }),
211
- 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))));
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))));
212
209
  }
213
210
  };
214
211
  // Update selectedRows when selectedItems prop changes
@@ -315,10 +312,7 @@ pageIndex = 0, // Default to first page (0-indexed)
315
312
  };
316
313
  const row = findRow(rows, rowId);
317
314
  // If row has no children, it can't be indeterminate
318
- if (!row ||
319
- !row.hasChildren ||
320
- !row.childRows ||
321
- row.childRows.length === 0) {
315
+ if (!row || !row.hasChildren || !row.childRows || row.childRows.length === 0) {
322
316
  return false;
323
317
  }
324
318
  // Check if the row itself is selected
@@ -331,9 +325,7 @@ pageIndex = 0, // Default to first page (0-indexed)
331
325
  return true;
332
326
  }
333
327
  // Check grandchildren if they exist
334
- if (child.hasChildren &&
335
- child.childRows &&
336
- child.childRows.length > 0) {
328
+ if (child.hasChildren && child.childRows && child.childRows.length > 0) {
337
329
  if (hasSelectedDescendant(child.childRows)) {
338
330
  return true;
339
331
  }
@@ -349,9 +341,7 @@ pageIndex = 0, // Default to first page (0-indexed)
349
341
  return false;
350
342
  }
351
343
  // Check grandchildren if they exist
352
- if (child.hasChildren &&
353
- child.childRows &&
354
- child.childRows.length > 0) {
344
+ if (child.hasChildren && child.childRows && child.childRows.length > 0) {
355
345
  if (!areAllDescendantsSelected(child.childRows)) {
356
346
  return false;
357
347
  }
@@ -363,7 +353,7 @@ pageIndex = 0, // Default to first page (0-indexed)
363
353
  const hasAllSelected = areAllDescendantsSelected(row.childRows);
364
354
  // Indeterminate if some but not all descendants are selected
365
355
  // Or if the parent is not selected but some children are
366
- return ((hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected));
356
+ return (hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected);
367
357
  };
368
358
  // Function to check if a row is selected
369
359
  const isSelected = (rowId) => {
@@ -385,47 +375,47 @@ pageIndex = 0, // Default to first page (0-indexed)
385
375
  };
386
376
  // Extract title and subtitle from row data
387
377
  const extractCardData = (row) => {
388
- let title = "";
389
- let subtitle = "";
390
- let icon = "";
391
- let status = "";
392
- let statusClass = "";
393
- let price = "";
378
+ let title = '';
379
+ let subtitle = '';
380
+ let icon = '';
381
+ let status = '';
382
+ let statusClass = '';
383
+ let price = '';
394
384
  if (!row.data)
395
385
  return { title, subtitle, icon, status, statusClass, price };
396
386
  // Find title (usually first text item)
397
- const titleItem = row.data.find((item) => item.type === "text" && item.value);
387
+ const titleItem = row.data.find((item) => item.type === 'text' && item.value);
398
388
  if (titleItem) {
399
389
  title = titleItem.value;
400
390
  }
401
391
  else if (row.data.length > 0) {
402
392
  // Fallback to first item
403
- title = String(row.data[0].value || "");
393
+ title = String(row.data[0].value || '');
404
394
  }
405
395
  // Find subtitle (usually size or description)
406
- const subtitleItem = row.data.find((item) => item.type === "text" && item.isSubtitle);
396
+ const subtitleItem = row.data.find((item) => item.type === 'text' && item.isSubtitle);
407
397
  if (subtitleItem) {
408
398
  subtitle = subtitleItem.value;
409
399
  }
410
400
  else if (row.data.length > 1) {
411
401
  // Fallback to second item
412
- subtitle = String(row.data[1].value || "");
402
+ subtitle = String(row.data[1].value || '');
413
403
  }
414
404
  // Find status
415
- const statusItem = row.data.find((item) => item.type === "status");
405
+ const statusItem = row.data.find((item) => item.type === 'status');
416
406
  if (statusItem) {
417
- status = String(statusItem.value || "");
418
- statusClass = statusItem.statusClass || "";
407
+ status = String(statusItem.value || '');
408
+ statusClass = statusItem.statusClass || '';
419
409
  }
420
410
  // Find price (look for item with isPrice flag)
421
411
  const priceItem = row.data.find((item) => item.isPrice);
422
412
  if (priceItem) {
423
- price = String(priceItem.value || "");
413
+ price = String(priceItem.value || '');
424
414
  }
425
415
  // Find icon (usually avatar or image)
426
416
  const iconItem = row.data.find((item) => item.hasImage);
427
417
  if (iconItem && iconItem.value) {
428
- icon = String(iconItem.imageUrl || "");
418
+ icon = String(iconItem.imageUrl || '');
429
419
  }
430
420
  return { title, subtitle, icon, status, statusClass, price };
431
421
  };
@@ -433,7 +423,7 @@ pageIndex = 0, // Default to first page (0-indexed)
433
423
  const findAvatarItems = (row) => {
434
424
  if (!row.data)
435
425
  return [];
436
- return row.data.filter((item) => item.type === "avatar" && item.isUserAvatar);
426
+ return row.data.filter((item) => item.type === 'avatar' && item.isUserAvatar);
437
427
  };
438
428
  // Get all rows and their children for mobile view - updated for multi-level nesting
439
429
  const getAllMobileRows = () => {
@@ -472,23 +462,19 @@ pageIndex = 0, // Default to first page (0-indexed)
472
462
  moreOptionsIconPath, showAvatars, maxVisibleAvatars = 0, } = mobileCardConfig;
473
463
  // Calculate card classes - add special styling for child cards
474
464
  const cardClasses = `
475
- ${cardStyle?.backgroundColor || "bg-white"}
476
- ${cardStyle?.borderRadius || "rounded-lg"}
477
- ${cardStyle?.shadow || "shadow-sm"}
478
- ${row.isChild
479
- ? "border-l-4 border-l-blue-300"
480
- : cardStyle?.border || "border border-gray-100"}
481
- ${cardStyle?.padding || "p-4"}
482
- ${cardStyle?.marginBottom || "mb-4"}
483
- ${row.isChild ? "bg-opacity-90" : ""}
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' : ''}
484
472
  w-full h-full
485
473
  `;
486
474
  return (react_1.default.createElement("div", { className: cardClasses },
487
475
  react_1.default.createElement("div", { className: "flex items-start gap-2" },
488
476
  showFolderIcon && (react_1.default.createElement("div", { className: "mr-3 flex-shrink-0" },
489
- react_1.default.createElement("div", { className: "w-10 h-10 flex items-center justify-center" }, row.data &&
490
- row.data.find((item) => item.hasImage)?.imageUrl ? (react_1.default.createElement(image_1.default, { src: row.data.find((item) => item.hasImage)?.imageUrl ||
491
- "/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" }))))),
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" }))))),
492
478
  react_1.default.createElement("div", { className: "flex-1 min-w-0" },
493
479
  react_1.default.createElement("div", { className: "flex items-start justify-between" },
494
480
  react_1.default.createElement("div", { className: "overflow-hidden" },
@@ -496,7 +482,7 @@ pageIndex = 0, // Default to first page (0-indexed)
496
482
  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` })),
497
483
  react_1.default.createElement("h3", { className: "text-sm font-medium truncate" }, title)),
498
484
  react_1.default.createElement("p", { className: "text-xs text-gray-500 mt-1 truncate" }, subtitle),
499
- price && (react_1.default.createElement("p", { className: "text-sm font-semibold mt-1" }, price)),
485
+ price && react_1.default.createElement("p", { className: "text-sm font-semibold mt-1" }, price),
500
486
  status && (react_1.default.createElement("div", { className: "mt-2" },
501
487
  react_1.default.createElement("span", { className: `text-xs font-medium px-2 py-1 rounded-full ${getStatusClass(statusClass)} bg-opacity-10` }, status)))),
502
488
  react_1.default.createElement("div", { className: "flex items-center flex-shrink-0 ml-2" },
@@ -504,38 +490,32 @@ pageIndex = 0, // Default to first page (0-indexed)
504
490
  e.stopPropagation();
505
491
  handleRowExpandToggle(row.id, e);
506
492
  }, className: "p-2 hover:bg-gray-100 rounded" },
507
- 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" : ""}` },
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' : ''}` },
508
494
  react_1.default.createElement("path", { d: "M15 5L8 12L15 19", stroke: "rgba(0, 0, 0, 0.40)", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })))),
509
495
  showFavoriteIcon && (react_1.default.createElement("button", { className: "p-2 hover:bg-gray-100 rounded" },
510
496
  react_1.default.createElement(image_1.default, { src: isFavorited
511
- ? favoriteFilledIconPath ?? "/defaultFilledIcon.svg"
512
- : favoriteOutlineIconPath ?? "/defaultOutlineIcon.svg", alt: "favorite", width: 20, height: 20, className: isFavorited ? "text-yellow-400" : "text-gray-400" }))),
513
- (typeof mobileCardConfig.showMoreOptions === "function"
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'
514
500
  ? mobileCardConfig.showMoreOptions(row)
515
501
  : mobileCardConfig.showMoreOptions) &&
516
502
  modalActions &&
517
503
  modalActions.length > 0 &&
518
- (typeof showModalIcon === "function"
519
- ? showModalIcon(row)
520
- : showModalIcon) && (react_1.default.createElement("div", { className: "relative" },
521
- react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: `p-2 hover:bg-gray-100 rounded ${ShowActionModal
522
- ? ""
523
- : "opacity-50 cursor-not-allowed "} ` },
524
- react_1.default.createElement(image_1.default, { src: moreOptionsIconPath || "/placeholder.svg", alt: "menu", width: 20, height: 20, className: `${ShowActionModal
525
- ? ""
526
- : "opacity-50 cursor-not-allowed"}` })),
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'}` })),
527
507
  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: {
528
- position: "fixed",
508
+ position: 'fixed',
529
509
  top: `${mousePosition.y}px`,
530
510
  left: `${Math.max(0, Math.min(window.innerWidth - 160, mousePosition.x - 80) + 35)}px `, // Ensure modal stays within screen
531
511
  }, onClick: (e) => e.stopPropagation() },
532
- react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === "function"
512
+ react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === 'function'
533
513
  ? modalActions(row)
534
- : 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)))))))))),
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)))))))))),
535
515
  showAvatars && avatarItems.length > 0 && (react_1.default.createElement("div", { className: "flex items-center mt-3" },
536
516
  react_1.default.createElement("div", { className: "flex -space-x-2" },
537
517
  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" },
538
- 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" })))),
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" })))),
539
519
  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" },
540
520
  "+",
541
521
  avatarItems.length - maxVisibleAvatars)))))))));
@@ -545,25 +525,23 @@ pageIndex = 0, // Default to first page (0-indexed)
545
525
  // Width for the expand/collapse control column
546
526
  return (react_1.default.createElement("div", { key: `row-container-${row.id}` },
547
527
  react_1.default.createElement("div", { className: `grid w-full items-center ${row.isChild
548
- ? childRowConfig.childRowClass || "bg-blue-300 bg-opacity-10"
528
+ ? childRowConfig.childRowClass || 'bg-blue-300 bg-opacity-10'
549
529
  : index % 2 === 0
550
- ? "bg-white"
551
- : "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")
552
- ? "h-[60px]"
553
- : "h-14"}`, style: {
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: {
554
532
  gridTemplateColumns: isMobileView && mobileViewGridClassName
555
533
  ? mobileViewGridClassName
556
- : gridClassName || "repeat(auto-fit, minmax(100px, 1fr))",
534
+ : gridClassName || 'repeat(auto-fit, minmax(100px, 1fr))',
557
535
  }, onClick: () => {
558
536
  if (onView) {
559
537
  onView(row.id);
560
538
  }
561
539
  } },
562
- react_1.default.createElement("div", { className: `flex items-center justify-center gap-2 ${!row.hasChildren && "mr-[4px]"}`, style: { width: "55px" } },
540
+ react_1.default.createElement("div", { className: `flex items-center justify-center gap-2 ${!row.hasChildren && 'mr-[4px]'}`, style: { width: '55px' } },
563
541
  !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)),
564
542
  react_1.default.createElement("div", { className: "flex items-center justify-center gap-1" },
565
543
  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" },
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" : ""}` },
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' : ''}` },
567
545
  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 ? (
568
546
  // Child row indicator
569
547
  react_1.default.createElement("div", { className: "h-2 w-2 rounded-full bg-black/20 flex-shrink-0" })) : null,
@@ -575,18 +553,16 @@ pageIndex = 0, // Default to first page (0-indexed)
575
553
  } }),
576
554
  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" },
577
555
  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" }))))))),
578
- 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" ||
579
- item.type === "operation" ||
580
- item.type === "text"
581
- ? ""
582
- : ""}`, style: {
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: {
583
559
  ...item.inlineCSS,
584
- textAlign: item.textAlign || "left",
585
- justifyContent: item.textAlign === "right"
586
- ? "flex-end"
587
- : item.textAlign === "center"
588
- ? "center"
589
- : "flex-start",
560
+ textAlign: item.textAlign || 'left',
561
+ justifyContent: item.textAlign === 'right'
562
+ ? 'flex-end'
563
+ : item.textAlign === 'center'
564
+ ? 'center'
565
+ : 'flex-start',
590
566
  } },
591
567
  colIndex === 0 && row.isChild && selectable && (react_1.default.createElement("div", { className: "flex items-center" },
592
568
  react_1.default.createElement("div", { style: {
@@ -601,29 +577,25 @@ pageIndex = 0, // Default to first page (0-indexed)
601
577
  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" },
602
578
  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" })))))),
603
579
  renderCellContent(item)))),
604
- actions && (react_1.default.createElement("div", { className: `w-24 py-4 flex items-center justify-end text-sm font-medium ${actionButtonsStyle || ""}` },
580
+ actions && (react_1.default.createElement("div", { className: `w-24 py-4 flex items-center justify-end text-sm font-medium ${actionButtonsStyle || ''}` },
605
581
  react_1.default.createElement("div", { className: "flex items-center justify-center gap-2" },
606
582
  onEdit && (react_1.default.createElement("button", { onClick: (e) => {
607
583
  e.stopPropagation();
608
584
  onEdit(row.id);
609
585
  }, className: "p-1 mb-[5px]" },
610
- react_1.default.createElement(image_1.default, { src: iconsSRC?.editIcon || "/placeholder.svg", alt: "edit", width: 18, height: 18, className: iconsSRC?.editIconTailwindStyle || "" }))),
586
+ react_1.default.createElement(image_1.default, { src: iconsSRC?.editIcon || '/placeholder.svg', alt: "edit", width: 18, height: 18, className: iconsSRC?.editIconTailwindStyle || '' }))),
611
587
  react_1.default.createElement("div", { className: "relative" },
612
588
  modalActions &&
613
589
  modalActions.length > 0 &&
614
- (typeof showModalIcon === "function"
615
- ? showModalIcon(row)
616
- : showModalIcon) ? (react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: "", "data-row-id": row.id },
617
- react_1.default.createElement(image_1.default, { src: iconsSRC?.moreIcon || "/placeholder.svg", alt: "menu", width: 18, height: 18, className: iconsSRC?.moreIconTailwindStyle || "" }))) : (
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 || '' }))) : (
618
592
  // Render an invisible placeholder to maintain spacing when icon is hidden
619
593
  react_1.default.createElement("div", { className: "w-[18px] h-[18px]" })),
620
594
  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: {
621
- position: "fixed",
595
+ position: 'fixed',
622
596
  top: (() => {
623
597
  // Get all visible rows for the current view
624
- const allRows = isMobileView
625
- ? getAllMobileRows()
626
- : rows;
598
+ const allRows = isMobileView ? getAllMobileRows() : rows;
627
599
  // Find the index of the current row
628
600
  const currentRowIndex = allRows?.findIndex((r) => r.id === row.id);
629
601
  // Check if this is one of the last 3 rows
@@ -635,9 +607,9 @@ pageIndex = 0, // Default to first page (0-indexed)
635
607
  })(),
636
608
  left: `${mousePosition.x + 20}px`,
637
609
  }, onClick: (e) => e.stopPropagation() },
638
- react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === "function"
610
+ react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === 'function'
639
611
  ? modalActions(row)
640
- : 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))))))))))),
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))))))))))),
641
613
  row.hasChildren &&
642
614
  expandedRows.includes(row.id) &&
643
615
  row.childRows &&
@@ -653,8 +625,8 @@ pageIndex = 0, // Default to first page (0-indexed)
653
625
  }
654
626
  // Show no items found if rows are empty or null and not loading
655
627
  if (!loadingProps.isLoading && rows?.length === 0) {
656
- 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,
657
- react_1.default.createElement(image_1.default, { src: noItemFoundProps?.imagePath || "/icons/no-data.svg", alt: "No items found", width: 120, height: 120 }),
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 }),
658
630
  react_1.default.createElement("p", { className: "mt-4 text-gray-500 text-sm" },
659
631
  noItemFoundProps?.title,
660
632
  " "))) : (react_1.default.createElement(react_1.default.Fragment, null,
@@ -664,7 +636,7 @@ pageIndex = 0, // Default to first page (0-indexed)
664
636
  " ")))));
665
637
  }
666
638
  return (react_1.default.createElement(react_1.default.Fragment, null,
667
- 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)))))),
668
- react_1.default.createElement("div", { className: `${mobileCardConfig.enabled ? "hidden lg:block" : ""} w-full` }, rows?.map((row, index) => renderTableRow(row, index, index === rows.length - 1)))));
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)))));
669
641
  };
670
642
  exports.default = ModernTable;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ type SafeImageProps = {
3
+ src: string;
4
+ alt: string;
5
+ width: number;
6
+ height: number;
7
+ className?: string;
8
+ fallbackSrc?: string;
9
+ };
10
+ declare const SafeImage: React.FC<SafeImageProps>;
11
+ export default SafeImage;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const react_1 = __importStar(require("react"));
40
+ const image_1 = __importDefault(require("next/image"));
41
+ const SafeImage = ({ src, alt, width, height, className, fallbackSrc = '/images/imageDef.jpg', }) => {
42
+ const [imgSrc, setImgSrc] = (0, react_1.useState)(src || fallbackSrc);
43
+ return (react_1.default.createElement(image_1.default, { src: imgSrc, alt: alt, width: width, height: height, className: className, onError: () => setImgSrc(fallbackSrc) }));
44
+ };
45
+ exports.default = SafeImage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {