hi-tm 0.0.1 → 0.0.2

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.
Files changed (36) hide show
  1. package/README.md +61 -0
  2. package/dist/components/Cards/AutoComplete&DropDown/ItemCard.js +2 -2
  3. package/dist/components/DropDowns/CreatableDropDown.d.ts +3 -0
  4. package/dist/components/DropDowns/CreatableDropDown.js +255 -0
  5. package/dist/components/Inputs/InputMultiselect.js +17 -7
  6. package/dist/components/Layout/Headers/HeaderLayout.js +9 -3
  7. package/dist/components/Layout/Sidebar.js +1 -1
  8. package/dist/components/Table/ModernTable/ModernTable.d.ts +4 -0
  9. package/dist/components/Table/ModernTable/ModernTable.js +421 -0
  10. package/dist/components/Table/ModernTable/ModernTableHeader.d.ts +102 -0
  11. package/dist/components/Table/ModernTable/ModernTableHeader.js +322 -0
  12. package/dist/components/Table/RtlTable/RtlTable.d.ts +5 -0
  13. package/dist/components/Table/RtlTable/RtlTable.js +126 -0
  14. package/dist/components/Table/TableHeaderDiv.js +1 -1
  15. package/dist/components/Table/TableRowDiv.d.ts +1 -0
  16. package/dist/components/Table/TableRowDiv.js +0 -1
  17. package/dist/components/Wrapper/Bounded.d.ts +5 -3
  18. package/dist/components/Wrapper/Bounded.js +6 -6
  19. package/dist/components/Wrapper/ModernTable/ModernTableBounded.d.ts +26 -0
  20. package/dist/components/Wrapper/ModernTable/ModernTableBounded.js +23 -0
  21. package/dist/components/Wrapper/TableBodyBoundedDiv.js +1 -1
  22. package/dist/components/Wrapper/TableBoundedDiv.d.ts +2 -2
  23. package/dist/components/Wrapper/TableBoundedDiv.js +2 -2
  24. package/dist/components/sections/components/Tabs/TabsComponent.js +6 -1
  25. package/dist/elements/Loader.d.ts +3 -0
  26. package/dist/elements/Loader.js +21 -0
  27. package/dist/index.d.ts +5 -0
  28. package/dist/index.js +14 -1
  29. package/dist/styles/globals.css +100 -96
  30. package/dist/types/DropDown/CreatableDropDown.d.ts +57 -0
  31. package/dist/types/DropDown/CreatableDropDown.js +2 -0
  32. package/dist/types/ModernTable/index.d.ts +87 -0
  33. package/dist/types/ModernTable/index.js +2 -0
  34. package/dist/types/RtlTable/index.d.ts +73 -0
  35. package/dist/types/RtlTable/index.js +2 -0
  36. package/package.json +3 -1
@@ -0,0 +1,421 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const react_1 = __importDefault(require("react"));
8
+ const react_2 = require("react");
9
+ const image_1 = __importDefault(require("next/image"));
10
+ const Loader_1 = __importDefault(require("../../../elements/Loader"));
11
+ // Helper function to handle modal styles
12
+ const modalStyleOperationHandler = (classType) => {
13
+ if (classType === 'delete') {
14
+ return 'hover:bg-red-500/20 text-red-700';
15
+ }
16
+ else {
17
+ return 'hover:bg-gray-500/10';
18
+ }
19
+ };
20
+ const ModernTable = ({ rows = [], onEdit, onDelete, loadingProps = {
21
+ isLoading: false,
22
+ loadingText: 'درحال دریافت اطلاعات',
23
+ loadingIcon: react_1.default.createElement(Loader_1.default, null),
24
+ }, onView, onAction, selectable, onSelectionChange, actions, modalActions, noItemFoundProps, selectedItems = [], iconsSRC,
25
+ // Child row configuration with defaults
26
+ childRowConfig = {
27
+ expandByDefault: false,
28
+ indentSize: '1.5rem',
29
+ childRowClass: 'bg-blue-300 bg-opacity-10',
30
+ },
31
+ // Mobile card view configuration props
32
+ mobileCardConfig = {
33
+ enabled: true,
34
+ showFolderIcon: true,
35
+ folderIconPath: '',
36
+ showFavoriteIcon: true,
37
+ favoriteFilledIconPath: '/icons/star-filled.svg',
38
+ favoriteOutlineIconPath: '/icons/star-outline.svg',
39
+ showMoreOptions: true,
40
+ moreOptionsIconPath: '/icons/table/more.svg',
41
+ showAvatars: true,
42
+ maxVisibleAvatars: 2,
43
+ cardStyle: {
44
+ backgroundColor: 'bg-white',
45
+ borderRadius: 'rounded-lg',
46
+ shadow: 'shadow-sm',
47
+ border: 'border border-gray-100',
48
+ padding: 'p-4',
49
+ marginBottom: 'mb-4',
50
+ },
51
+ gridLayoutClassName: 'grid-cols-1 sm:grid-cols-2 gap-4',
52
+ }, actionButtonsStyle, gridClassName, }) => {
53
+ // Track which rows are expanded to show their children
54
+ const [expandedRows, setExpandedRows] = (0, react_2.useState)([]);
55
+ const [activeModal, setActiveModal] = (0, react_2.useState)(null);
56
+ const modalRef = (0, react_2.useRef)(null);
57
+ // Store calculated column widths
58
+ const [columnWidths, setColumnWidths] = (0, react_2.useState)([]);
59
+ const [selectedRows, setSelectedRows] = (0, react_2.useState)(selectedItems || []);
60
+ // Calculate and store column widths based on all rows (parents and children)
61
+ (0, react_2.useEffect)(() => {
62
+ // if (!rows || rows.length === 0) return;
63
+ // Get all rows including children
64
+ const allRows = [];
65
+ // Helper function to recursively collect all rows
66
+ const collectRows = (rowsArray) => {
67
+ rowsArray?.forEach((row) => {
68
+ allRows.push(row);
69
+ if (row.hasChildren && row.childRows && row.childRows.length > 0) {
70
+ collectRows(row.childRows);
71
+ }
72
+ });
73
+ };
74
+ if (rows) {
75
+ collectRows(rows);
76
+ }
77
+ // Find the maximum number of columns
78
+ const maxColumns = Math.max(...allRows.map((row) => (row.data ? row.data.length : 0)));
79
+ // Calculate the width for each column
80
+ const widths = [];
81
+ for (let colIndex = 0; colIndex < maxColumns; colIndex++) {
82
+ // Check if any row has a defined width for this column
83
+ const columnsWithWidth = allRows
84
+ .filter((row) => row.data &&
85
+ row.data[colIndex] &&
86
+ row.data[colIndex].inlineCSS &&
87
+ 'width' in (row.data[colIndex].inlineCSS || {}))
88
+ .map((row) => row.data[colIndex]);
89
+ if (columnsWithWidth.length > 0) {
90
+ // Use the first defined width (could be enhanced to use max/average)
91
+ const firstWidth = columnsWithWidth[0].inlineCSS?.width;
92
+ if (firstWidth) {
93
+ widths[colIndex] = typeof firstWidth === 'string' ? firstWidth : `${firstWidth}px`;
94
+ }
95
+ else {
96
+ widths[colIndex] = 'auto';
97
+ }
98
+ }
99
+ else {
100
+ // If no defined width, set a responsive width
101
+ widths[colIndex] = `${100 / maxColumns}%`;
102
+ }
103
+ }
104
+ setColumnWidths(widths);
105
+ }, [rows]);
106
+ // Initialize expanded rows if specified in config
107
+ (0, react_2.useEffect)(() => {
108
+ if (childRowConfig.expandByDefault && rows) {
109
+ const parentIds = rows
110
+ .filter((row) => row.hasChildren && row.childRows && row.childRows.length > 0)
111
+ .map((row) => row.id);
112
+ setExpandedRows(parentIds);
113
+ }
114
+ }, [rows, childRowConfig.expandByDefault]);
115
+ (0, react_2.useEffect)(() => {
116
+ const handleClickOutside = (event) => {
117
+ const target = event.target;
118
+ if (target.closest('.modal-content')) {
119
+ return;
120
+ }
121
+ if (modalRef.current && !modalRef.current.contains(event.target)) {
122
+ setActiveModal(null);
123
+ }
124
+ };
125
+ document.addEventListener('mousedown', handleClickOutside);
126
+ return () => {
127
+ document.removeEventListener('mousedown', handleClickOutside);
128
+ };
129
+ }, []);
130
+ (0, react_2.useEffect)(() => {
131
+ const handleScroll = () => {
132
+ if (activeModal !== null) {
133
+ setActiveModal(null);
134
+ }
135
+ };
136
+ window.addEventListener('scroll', handleScroll, { passive: true });
137
+ return () => {
138
+ window.removeEventListener('scroll', handleScroll);
139
+ };
140
+ }, [activeModal]);
141
+ // Remove this problematic useEffect that's causing the infinite loop
142
+ // useEffect(() => {
143
+ // console.log(rows, 'ROws');
144
+ // }, [rows]);
145
+ const [mousePosition, setMousePosition] = (0, react_2.useState)({ x: 0, y: 0 });
146
+ const handleModalToggle = (id, e) => {
147
+ e.stopPropagation();
148
+ e.preventDefault();
149
+ setMousePosition({ x: e.clientX, y: e.clientY });
150
+ setActiveModal(activeModal === id ? null : id);
151
+ };
152
+ const handleActionClick = (actionId, rowId, e) => {
153
+ e.stopPropagation();
154
+ setActiveModal(null);
155
+ if (onAction) {
156
+ onAction(actionId, rowId);
157
+ }
158
+ };
159
+ const handleRowExpandToggle = (rowId, e) => {
160
+ e.stopPropagation();
161
+ setExpandedRows((prev) => prev.includes(rowId) ? prev.filter((id) => id !== rowId) : [...prev, rowId]);
162
+ };
163
+ const getStatusClass = (statusClass) => {
164
+ switch (statusClass) {
165
+ case 'success':
166
+ return 'text-green-700';
167
+ case 'danger':
168
+ return 'text-red-700';
169
+ case 'warning':
170
+ return 'text-yellow-700';
171
+ case 'info':
172
+ return 'text-blue-700';
173
+ case 'primary':
174
+ return 'text-purple-700';
175
+ case 'secondary':
176
+ return 'text-gray-700';
177
+ default:
178
+ return '';
179
+ }
180
+ };
181
+ const renderCellContent = (item) => {
182
+ switch (item.type) {
183
+ case 'status':
184
+ return (react_1.default.createElement("p", { className: `text-xs font-medium w-full ${item.contentClass} ${getStatusClass(item.statusClass)}` }, item.value));
185
+ default:
186
+ return (react_1.default.createElement("div", { className: "flex items-center gap-2 w-full" }, item.hasImage ? (react_1.default.createElement("div", { className: "flex items-center gap-2 w-full" },
187
+ 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'}` }),
188
+ 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` }, item.value))));
189
+ }
190
+ };
191
+ // Update selectedRows when selectedItems prop changes
192
+ (0, react_2.useEffect)(() => {
193
+ setSelectedRows(selectedItems || []);
194
+ }, []);
195
+ // Handle checkbox change for row selection
196
+ const handleCheckboxChange = (id) => {
197
+ const updatedSelection = selectedRows.includes(id)
198
+ ? selectedRows.filter((rowId) => rowId !== id)
199
+ : [...selectedRows, id];
200
+ setSelectedRows(updatedSelection);
201
+ if (onSelectionChange) {
202
+ onSelectionChange([...updatedSelection]);
203
+ }
204
+ };
205
+ // Method to check if all items are selected
206
+ const areAllItemsSelected = () => {
207
+ return Boolean(rows && rows.length > 0 && selectedRows.length === rows.length);
208
+ };
209
+ // Extract title and subtitle from row data
210
+ const extractCardData = (row) => {
211
+ let title = '';
212
+ let subtitle = '';
213
+ let icon = '';
214
+ let status = '';
215
+ let statusClass = '';
216
+ if (!row.data)
217
+ return { title, subtitle, icon, status, statusClass };
218
+ // Find title (usually first text item)
219
+ const titleItem = row.data.find((item) => item.type === 'text' && item.value);
220
+ if (titleItem) {
221
+ title = titleItem.value;
222
+ }
223
+ else if (row.data.length > 0) {
224
+ // Fallback to first item
225
+ title = String(row.data[0].value || '');
226
+ }
227
+ // Find subtitle (usually size or description)
228
+ const subtitleItem = row.data.find((item) => item.type === 'text' && item.isSubtitle);
229
+ if (subtitleItem) {
230
+ subtitle = subtitleItem.value;
231
+ }
232
+ else if (row.data.length > 1) {
233
+ // Fallback to second item
234
+ subtitle = String(row.data[1].value || '');
235
+ }
236
+ // Find status
237
+ const statusItem = row.data.find((item) => item.type === 'status');
238
+ if (statusItem) {
239
+ status = String(statusItem.value || '');
240
+ statusClass = statusItem.statusClass || '';
241
+ }
242
+ // Find icon (usually avatar or image)
243
+ const iconItem = row.data.find((item) => item.hasImage);
244
+ if (iconItem && iconItem.value) {
245
+ icon = String(iconItem.imageUrl || '');
246
+ }
247
+ return { title, subtitle, icon, status, statusClass };
248
+ };
249
+ // Find avatar items in row data
250
+ const findAvatarItems = (row) => {
251
+ if (!row.data)
252
+ return [];
253
+ return row.data.filter((item) => item.type === 'avatar' && item.isUserAvatar);
254
+ };
255
+ // Get all rows and their children for mobile view
256
+ const getAllMobileRows = () => {
257
+ const result = [];
258
+ // Helper function to add parent rows and child rows that should be visible
259
+ const processRows = (rows) => {
260
+ rows?.forEach((row) => {
261
+ result.push(row);
262
+ // Add child rows if this row is expanded
263
+ if (row.hasChildren &&
264
+ expandedRows.includes(row.id) &&
265
+ row.childRows &&
266
+ row.childRows.length > 0) {
267
+ row.childRows?.forEach((childRow) => {
268
+ result.push(childRow);
269
+ });
270
+ }
271
+ });
272
+ };
273
+ if (rows) {
274
+ processRows(rows);
275
+ }
276
+ return result;
277
+ };
278
+ // Mobile card view
279
+ const renderMobileCard = (row) => {
280
+ if (!row || !row.data)
281
+ return null;
282
+ const { title, subtitle, icon, status, statusClass } = extractCardData(row);
283
+ const avatarItems = findAvatarItems(row);
284
+ const isFavorited = row.data.some((item) => item.isFavorite);
285
+ const hasChildren = row.hasChildren && row.childRows && row?.childRows?.length > 0;
286
+ const { cardStyle, showFolderIcon, folderIconPath, showFavoriteIcon, favoriteFilledIconPath, favoriteOutlineIconPath, showMoreOptions, moreOptionsIconPath, showAvatars, maxVisibleAvatars = 0, } = mobileCardConfig;
287
+ // Calculate card classes - add special styling for child cards
288
+ const cardClasses = `
289
+ ${cardStyle?.backgroundColor || 'bg-white'}
290
+ ${cardStyle?.borderRadius || 'rounded-lg'}
291
+ ${cardStyle?.shadow || 'shadow-sm'}
292
+ ${row.isChild ? 'border-l-4 border-l-blue-300' : cardStyle?.border || 'border border-gray-100'}
293
+ ${cardStyle?.padding || 'p-4'}
294
+ ${cardStyle?.marginBottom || 'mb-4'}
295
+ ${row.isChild ? 'bg-opacity-90' : ''}
296
+ w-full h-full
297
+ `;
298
+ return (react_1.default.createElement("div", { className: cardClasses },
299
+ react_1.default.createElement("div", { className: "flex items-start gap-2" },
300
+ showFolderIcon && (react_1.default.createElement("div", { className: "mr-3 flex-shrink-0" },
301
+ react_1.default.createElement("div", { className: "w-10 h-10 flex items-center justify-center" },
302
+ react_1.default.createElement(image_1.default, { src: folderIconPath ? folderIconPath : icon || '/placeholder.svg', alt: "folder", width: 40, height: 40, className: "text-yellow-400" })))),
303
+ react_1.default.createElement("div", { className: "flex-1 min-w-0" },
304
+ react_1.default.createElement("div", { className: "flex items-start justify-between" },
305
+ react_1.default.createElement("div", { className: "overflow-hidden" },
306
+ react_1.default.createElement("div", { className: "flex items-center" },
307
+ row.isChild && (react_1.default.createElement("div", { className: "h-2 w-2 rounded-full bg-blue-400 mr-2 flex-shrink-0" })),
308
+ react_1.default.createElement("h3", { className: "text-sm font-medium truncate" }, title)),
309
+ react_1.default.createElement("p", { className: "text-xs text-gray-500 mt-1 truncate" }, subtitle),
310
+ status && (react_1.default.createElement("div", { className: "mt-2" },
311
+ react_1.default.createElement("span", { className: `text-xs font-medium px-2 py-1 rounded-full ${getStatusClass(statusClass)} bg-opacity-10` }, status)))),
312
+ react_1.default.createElement("div", { className: "flex items-center flex-shrink-0 ml-2" },
313
+ hasChildren && (react_1.default.createElement("button", { onClick: (e) => {
314
+ e.stopPropagation();
315
+ handleRowExpandToggle(row.id, e);
316
+ }, className: "p-2 hover:bg-gray-100 rounded" },
317
+ 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' : ''}` },
318
+ react_1.default.createElement("path", { d: "M15 5L8 12L15 19", stroke: "rgba(0, 0, 0, 0.40)", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })))),
319
+ showFavoriteIcon && (react_1.default.createElement("button", { className: "p-2 hover:bg-gray-100 rounded" },
320
+ react_1.default.createElement(image_1.default, { src: isFavorited
321
+ ? favoriteFilledIconPath ?? '/defaultFilledIcon.svg'
322
+ : favoriteOutlineIconPath ?? '/defaultOutlineIcon.svg', alt: "favorite", width: 20, height: 20, className: isFavorited ? 'text-yellow-400' : 'text-gray-400' }))),
323
+ showMoreOptions && modalActions && modalActions.length > 0 && (react_1.default.createElement("div", { className: "relative" },
324
+ react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: "p-2 hover:bg-gray-100 rounded" },
325
+ react_1.default.createElement(image_1.default, { src: moreOptionsIconPath || '/placeholder.svg', alt: "menu", width: 20, height: 20 })),
326
+ 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: {
327
+ position: 'fixed',
328
+ top: `${mousePosition.y}px`,
329
+ left: `${Math.max(0, Math.min(window.innerWidth - 160, mousePosition.x - 80) + 35)}px `, // Ensure modal stays within screen
330
+ }, onClick: (e) => e.stopPropagation() },
331
+ react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, 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.text)))))))))),
332
+ showAvatars && avatarItems.length > 0 && (react_1.default.createElement("div", { className: "flex items-center mt-3" },
333
+ react_1.default.createElement("div", { className: "flex -space-x-2" },
334
+ 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" },
335
+ 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" })))),
336
+ 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" },
337
+ "+",
338
+ avatarItems.length - maxVisibleAvatars)))))))));
339
+ };
340
+ // Render a single table row (parent or child)
341
+ const renderTableRow = (row, index, isLastRow) => {
342
+ // Width for the expand/collapse control column
343
+ return (react_1.default.createElement("div", { key: `row-container-${row.id}` },
344
+ react_1.default.createElement("div", { className: `grid w-full items-center ${row.isChild
345
+ ? childRowConfig.childRowClass || 'bg-blue-300 bg-opacity-10'
346
+ : index % 2 === 0
347
+ ? 'bg-white'
348
+ : '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: { gridTemplateColumns: gridClassName || 'repeat(auto-fit, minmax(100px, 1fr))' }, onClick: () => {
349
+ if (onView) {
350
+ onView(row.id);
351
+ }
352
+ } },
353
+ react_1.default.createElement("div", { className: `flex items-center justify-center gap-2 ${!row.hasChildren && 'mr-[4px]'}"`, style: { width: '55px' } },
354
+ !row.hasChildren && !row.isChild && (react_1.default.createElement("span", { className: "text-xs text-gray-500 font-medium flex-shrink-0 mr-1" }, index + 1)),
355
+ react_1.default.createElement("div", { className: "flex items-center justify-center gap-1" },
356
+ 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" },
357
+ 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' : ''}` },
358
+ 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 ? (
359
+ // Child row indicator
360
+ react_1.default.createElement("div", { className: "h-2 w-2 rounded-full bg-black/20 flex-shrink-0" })) : null,
361
+ selectable === true && (react_1.default.createElement("div", { className: `relative flex-shrink-0 flex-row-reverse flex ${row.hasChildren && ''} ` },
362
+ react_1.default.createElement("input", { type: "checkbox", checked: selectedRows?.includes(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() }),
363
+ 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" },
364
+ 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" })))))),
365
+ 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'
366
+ ? ''
367
+ : ''}`, style: {
368
+ ...item.inlineCSS,
369
+ textAlign: item.textAlign || 'left',
370
+ justifyContent: item.textAlign === 'right'
371
+ ? 'flex-end'
372
+ : item.textAlign === 'center'
373
+ ? 'center'
374
+ : 'flex-start',
375
+ } }, renderCellContent(item)))),
376
+ actions && (react_1.default.createElement("div", { className: `w-24 py-4 flex items-center justify-end text-sm font-medium ${actionButtonsStyle || ''}` },
377
+ react_1.default.createElement("div", { className: "flex items-center justify-center gap-2" },
378
+ onEdit && (react_1.default.createElement("button", { onClick: (e) => {
379
+ e.stopPropagation();
380
+ onEdit(row.id);
381
+ }, className: "p-1 mb-[5px]" },
382
+ react_1.default.createElement(image_1.default, { src: iconsSRC.editIcon || '/placeholder.svg', alt: "edit", width: 18, height: 18 }))),
383
+ modalActions && modalActions.length > 0 && (react_1.default.createElement("div", { className: "relative" },
384
+ react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: "", "data-row-id": row.id },
385
+ react_1.default.createElement(image_1.default, { src: iconsSRC.moreIcon || '/placeholder.svg', alt: "menu", width: 18, height: 18 })),
386
+ 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: {
387
+ position: 'fixed',
388
+ top: `${mousePosition.y}px`,
389
+ left: `${mousePosition.x + 20}px`,
390
+ }, onClick: (e) => e.stopPropagation() },
391
+ react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, 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.text)))))))))))),
392
+ row.hasChildren &&
393
+ expandedRows.includes(row.id) &&
394
+ row.childRows &&
395
+ row.childRows.map((childRow, childIndex) => renderTableRow(childRow, childIndex, childIndex === row.childRows.length - 1 && isLastRow))));
396
+ };
397
+ // Prepare all mobile rows
398
+ const mobileRows = getAllMobileRows();
399
+ // Show loading state if loading is true
400
+ if (loadingProps.isLoading) {
401
+ return (react_1.default.createElement("div", { className: "w-full flex justify-center items-center py-8 gap-3" },
402
+ loadingProps.loadingIcon,
403
+ loadingProps.loadingText && loadingProps.loadingText));
404
+ }
405
+ // Show no items found if rows are empty or null and not loading
406
+ if (!loadingProps.isLoading && rows?.length === 0) {
407
+ 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,
408
+ react_1.default.createElement(image_1.default, { src: noItemFoundProps?.imagePath || '/icons/no-data.svg', alt: "No items found", width: 120, height: 120 }),
409
+ react_1.default.createElement("p", { className: "mt-4 text-gray-500 text-sm" },
410
+ noItemFoundProps?.title,
411
+ " "))) : (react_1.default.createElement(react_1.default.Fragment, null,
412
+ noItemFoundProps?.imagePath,
413
+ react_1.default.createElement("p", { className: "mt-4 text-gray-500 text-sm" },
414
+ noItemFoundProps?.title,
415
+ " ")))));
416
+ }
417
+ return (react_1.default.createElement(react_1.default.Fragment, null,
418
+ 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)))))),
419
+ react_1.default.createElement("div", { className: `${mobileCardConfig.enabled ? 'hidden lg:block' : ''} w-full` }, rows?.map((row, index) => renderTableRow(row, index, index === rows.length - 1)))));
420
+ };
421
+ exports.default = ModernTable;
@@ -0,0 +1,102 @@
1
+ import React from 'react';
2
+ export interface CustomColumnStyle extends React.CSSProperties {
3
+ width?: string | number;
4
+ textAlign?: 'left' | 'center' | 'right';
5
+ flex?: string;
6
+ padding?: string;
7
+ margin?: string;
8
+ backgroundColor?: string;
9
+ justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'end' | 'start';
10
+ alignItems?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
11
+ position?: 'static' | 'relative' | 'absolute' | 'fixed' | 'sticky';
12
+ }
13
+ interface BaseModalFilterData {
14
+ id: number;
15
+ name: string;
16
+ content: string;
17
+ type?: 'pin' | 'sort' | 'filter';
18
+ FilterIcon?: React.ComponentType<any> | string | React.ReactNode;
19
+ iconTailwindStyle?: string;
20
+ }
21
+ interface ModalFilterDataWithRequiredCheckedIcon extends BaseModalFilterData {
22
+ CheckedIcon: React.ComponentType<any> | string | React.ReactNode;
23
+ }
24
+ interface ModalFilterDataWithOptionalCheckedIcon extends BaseModalFilterData {
25
+ CheckedIcon?: React.ComponentType<any> | string | React.ReactNode;
26
+ }
27
+ interface SortingItem extends BaseModalFilterData {
28
+ CheckedIcon?: React.ComponentType<any> | string | React.ReactNode;
29
+ }
30
+ interface PinItem extends BaseModalFilterData {
31
+ CheckedIcon?: React.ComponentType<any> | string | React.ReactNode;
32
+ }
33
+ interface FilterItem {
34
+ id: number;
35
+ name: string;
36
+ content: string;
37
+ FilterIcon?: React.ComponentType<any> | string | React.ReactNode;
38
+ iconTailwindStyle?: string;
39
+ }
40
+ interface ColumnFilterSections {
41
+ sortingSection?: SortingItem[];
42
+ pinSection?: PinItem[];
43
+ filterSection?: FilterItem;
44
+ }
45
+ interface ColumnWithFilter {
46
+ id: number;
47
+ content: string;
48
+ hasSort: boolean;
49
+ hasFilter: true;
50
+ name?: string;
51
+ inlineCss?: CustomColumnStyle;
52
+ modalFilterData?: ModalFilterDataWithRequiredCheckedIcon[];
53
+ filterSections?: ColumnFilterSections;
54
+ }
55
+ interface ColumnWithoutFilter {
56
+ id: number;
57
+ content: string;
58
+ hasSort: boolean;
59
+ hasFilter: false;
60
+ name?: string;
61
+ inlineCss?: CustomColumnStyle;
62
+ modalFilterData?: ModalFilterDataWithOptionalCheckedIcon[];
63
+ filterSections?: ColumnFilterSections;
64
+ }
65
+ type Column = ColumnWithFilter | ColumnWithoutFilter;
66
+ interface ModernTableHeaderProps {
67
+ sortIcon: string;
68
+ columns: Column[];
69
+ filterHandler?: (params: {
70
+ id: number;
71
+ content: string;
72
+ name: string;
73
+ }) => void;
74
+ hasSelect?: boolean;
75
+ hasCheckbox?: boolean;
76
+ onCheckboxClick?: (checked: boolean) => void;
77
+ onClickHandlerColumn?: (params: {
78
+ name: string;
79
+ id: number;
80
+ }) => void;
81
+ onSelectAllClick?: (checked: boolean) => void;
82
+ FilterIcon?: React.ComponentType<any> | string | React.ReactNode;
83
+ onFilterClick?: (filterData: {
84
+ id: number;
85
+ name: string;
86
+ content: string;
87
+ }) => void;
88
+ onSortingClick?: (sortingData: {
89
+ id: number;
90
+ name: string;
91
+ content: string;
92
+ }) => void;
93
+ onPinClick?: (pinData: {
94
+ id: number;
95
+ name: string;
96
+ content: string;
97
+ }) => void;
98
+ onFilterButtonClick?: (columnId: number) => boolean;
99
+ gridClassName?: string;
100
+ }
101
+ declare const ModernTableHeader: ({ columns, sortIcon, hasSelect, hasCheckbox, onCheckboxClick, onClickHandlerColumn, filterHandler, onSelectAllClick, FilterIcon, onFilterClick, onSortingClick, onPinClick, onFilterButtonClick, gridClassName, }: ModernTableHeaderProps) => React.JSX.Element;
102
+ export default ModernTableHeader;