hi-tm 0.10.5 → 0.10.7

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,19 +1,46 @@
1
1
  "use strict";
2
- "use client";
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
+ })();
3
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
37
  };
6
38
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const react_1 = __importDefault(require("react"));
8
- const react_2 = require("react");
39
+ const react_1 = __importStar(require("react"));
9
40
  const image_1 = __importDefault(require("next/image"));
10
41
  const SafeImage_1 = __importDefault(require("../../../elements/SafeImage"));
11
- // Simple Loader component defined inline to avoid import issues
12
- const Loader = () => {
13
- return (react_1.default.createElement("div", { className: "flex items-center justify-center" },
14
- react_1.default.createElement("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-gray-900" })));
15
- };
16
- // Helper function to format numbers with commas
42
+ const Loader = () => (react_1.default.createElement("div", { className: "flex items-center justify-center" },
43
+ react_1.default.createElement("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-gray-900" })));
17
44
  const formatWithCommas = (value) => {
18
45
  if (value === undefined || value === null)
19
46
  return "";
@@ -22,28 +49,48 @@ const formatWithCommas = (value) => {
22
49
  return value.toString();
23
50
  return numValue.toLocaleString();
24
51
  };
25
- // Helper function to handle modal styles
26
52
  const modalStyleOperationHandler = (classType) => {
27
- if (classType === "delete") {
28
- return "hover:bg-red-500/20 text-red-700";
53
+ return classType === "delete"
54
+ ? "hover:bg-red-500/20 text-red-700"
55
+ : "hover:bg-gray-500/10";
56
+ };
57
+ // تابع برای محاسبه تمام IDهای فرزندان یک ردیف
58
+ const getDescendantIds = (row) => {
59
+ let ids = [];
60
+ if (row.hasChildren && row.childRows) {
61
+ row.childRows.forEach((child) => {
62
+ ids.push(child.id);
63
+ if (child.hasChildren && child.childRows) {
64
+ ids = [...ids, ...getDescendantIds(child)];
65
+ }
66
+ });
29
67
  }
30
- else {
31
- return "hover:bg-gray-500/10";
68
+ return ids;
69
+ };
70
+ // تابع بهینه‌شده isIndeterminate
71
+ const isIndeterminate = (rowId, rows, selectedRowsSet, descendantIdsMap) => {
72
+ const row = rows?.find((r) => r.id === rowId);
73
+ if (!row ||
74
+ !row.hasChildren ||
75
+ !row.childRows ||
76
+ row.childRows.length === 0) {
77
+ return false;
32
78
  }
79
+ const descendantIds = descendantIdsMap[rowId] || [];
80
+ const selectedCount = descendantIds.filter((id) => selectedRowsSet.has(id)).length;
81
+ const isRowSelected = selectedRowsSet.has(rowId);
82
+ return ((selectedCount > 0 && selectedCount < descendantIds.length) ||
83
+ (!isRowSelected && selectedCount > 0));
33
84
  };
34
- const ModernTable = ({ rows = [], onEdit, loadingProps = {
85
+ const ModernTable = ({ rows = [], selectedItems = [], onEdit, onView, onAction, selectable, onSelectionChange, actions, ShowActionModal = true, modalActions, noItemFoundProps, iconsSRC, loadingProps = {
35
86
  isLoading: false,
36
87
  loadingText: "درحال دریافت اطلاعات",
37
88
  loadingIcon: react_1.default.createElement(Loader, null),
38
- }, onView, onAction, selectable, onSelectionChange, actions, ShowActionModal = true, modalActions, noItemFoundProps, selectedItems = [], iconsSRC,
39
- // Child row configuration with defaults
40
- childRowConfig = {
89
+ }, childRowConfig = {
41
90
  expandByDefault: false,
42
91
  indentSize: "1.5rem",
43
92
  childRowClass: "bg-blue-300 bg-opacity-10",
44
- },
45
- // Mobile card view configuration props
46
- mobileCardConfig = {
93
+ }, mobileCardConfig = {
47
94
  enabled: true,
48
95
  showFolderIcon: true,
49
96
  folderIconPath: "",
@@ -63,102 +110,71 @@ mobileCardConfig = {
63
110
  marginBottom: "mb-4",
64
111
  },
65
112
  gridLayoutClassName: "grid-cols-1 sm:grid-cols-2 gap-4",
66
- }, showModalIcon = true, actionButtonsStyle, gridClassName, isMobileView = false, // Default to false
67
- mobileViewGridClassName, itemsPerPage = 10, // Default to 10 items per page
68
- pageIndex = 0, // Default to first page (0-indexed)
69
- }) => {
70
- // Track which rows are expanded to show their children
71
- const [expandedRows, setExpandedRows] = (0, react_2.useState)([]);
72
- const [activeModal, setActiveModal] = (0, react_2.useState)(null);
73
- const modalRef = (0, react_2.useRef)(null);
74
- // Store calculated column widths
75
- const [selectedRows, setSelectedRows] = (0, react_2.useState)(selectedItems || []);
76
- // Calculate and store column widths based on all rows (parents and children)
77
- (0, react_2.useEffect)(() => {
78
- // if (!rows || rows.length === 0) return;
79
- // Get all rows including children
80
- const allRows = [];
81
- // Helper function to recursively collect all rows at any depth
82
- const collectRows = (rowsArray, level = 0) => {
83
- rowsArray?.forEach((row) => {
84
- // Add level information to the row for proper indentation
85
- const rowWithLevel = { ...row, level };
86
- allRows.push(rowWithLevel);
87
- // Recursively process children at any depth
88
- if (row.hasChildren && row.childRows && row.childRows.length > 0) {
89
- collectRows(row.childRows, level + 1);
90
- }
91
- });
92
- };
93
- if (rows) {
94
- collectRows(rows);
95
- }
96
- // Find the maximum number of columns
97
- const maxColumns = Math.max(...allRows.map((row) => (row.data ? row.data.length : 0)));
98
- // Calculate the width for each column
99
- const widths = [];
100
- for (let colIndex = 0; colIndex < maxColumns; colIndex++) {
101
- // Check if any row has a defined width for this column
102
- const columnsWithWidth = allRows
103
- .filter((row) => row.data &&
104
- row.data[colIndex] &&
105
- row.data[colIndex].inlineCSS &&
106
- "width" in (row.data[colIndex].inlineCSS || {}))
107
- .map((row) => row.data[colIndex]);
108
- if (columnsWithWidth.length > 0) {
109
- // Use the first defined width (could be enhanced to use max/average)
110
- const firstWidth = columnsWithWidth[0].inlineCSS?.width;
111
- if (firstWidth) {
112
- widths[colIndex] =
113
- typeof firstWidth === "string" ? firstWidth : `${firstWidth}px`;
114
- }
115
- else {
116
- widths[colIndex] = "auto";
117
- }
118
- }
119
- else {
120
- // If no defined width, set a responsive width
121
- widths[colIndex] = `${100 / maxColumns}%`;
122
- }
123
- }
113
+ }, showModalIcon = true, actionButtonsStyle, gridClassName, isMobileView = false, mobileViewGridClassName, itemsPerPage = 10, pageIndex = 0, }) => {
114
+ const [expandedRows, setExpandedRows] = (0, react_1.useState)([]);
115
+ const [activeModal, setActiveModal] = (0, react_1.useState)(null);
116
+ const [selectedRows, setSelectedRows] = (0, react_1.useState)(selectedItems);
117
+ const modalRef = (0, react_1.useRef)(null);
118
+ const [mousePosition, setMousePosition] = (0, react_1.useState)({ x: 0, y: 0 });
119
+ // تبدیل selectedRows به Set برای جستجوی سریع‌تر
120
+ const selectedRowsSet = (0, react_1.useMemo)(() => new Set(selectedRows), [selectedRows]);
121
+ // محاسبه descendantIds برای هر ردیف
122
+ const descendantIdsMap = (0, react_1.useMemo)(() => {
123
+ const map = {};
124
+ rows?.forEach((row) => {
125
+ map[row.id] = getDescendantIds(row);
126
+ });
127
+ return map;
124
128
  }, [rows]);
125
- // Initialize expanded rows if specified in config
126
- (0, react_2.useEffect)(() => {
127
- if (childRowConfig.expandByDefault && rows) {
128
- const parentIds = rows
129
- .filter((row) => row.hasChildren && row.childRows && row.childRows.length > 0)
130
- .map((row) => row.id);
131
- setExpandedRows(parentIds);
132
- }
133
- }, [rows, childRowConfig.expandByDefault]);
134
- (0, react_2.useEffect)(() => {
129
+ // Memoize کردن نتایج isIndeterminate
130
+ const indeterminateStates = (0, react_1.useMemo)(() => {
131
+ const states = {};
132
+ rows?.forEach((row) => {
133
+ states[row.id] = isIndeterminate(row.id, rows, selectedRowsSet, descendantIdsMap);
134
+ if (row.hasChildren && row.childRows) {
135
+ row.childRows.forEach((childRow) => {
136
+ states[childRow.id] = isIndeterminate(childRow.id, rows, selectedRowsSet, descendantIdsMap);
137
+ });
138
+ }
139
+ });
140
+ return states;
141
+ }, [rows, selectedRowsSet, descendantIdsMap]);
142
+ // مدیریت کلیک خارج از مودال
143
+ (0, react_1.useEffect)(() => {
135
144
  const handleClickOutside = (event) => {
136
145
  const target = event.target;
137
- if (target.closest(".modal-content")) {
146
+ if (target.closest(".modal-content"))
138
147
  return;
139
- }
140
148
  if (modalRef.current &&
141
149
  !modalRef.current.contains(event.target)) {
142
150
  setActiveModal(null);
143
151
  }
144
152
  };
145
153
  document.addEventListener("mousedown", handleClickOutside);
146
- return () => {
147
- document.removeEventListener("mousedown", handleClickOutside);
148
- };
154
+ return () => document.removeEventListener("mousedown", handleClickOutside);
149
155
  }, []);
150
- (0, react_2.useEffect)(() => {
156
+ // مدیریت اسکرول
157
+ (0, react_1.useEffect)(() => {
151
158
  const handleScroll = () => {
152
- if (activeModal !== null) {
159
+ if (activeModal !== null)
153
160
  setActiveModal(null);
154
- }
155
161
  };
156
162
  window.addEventListener("scroll", handleScroll, { passive: true });
157
- return () => {
158
- window.removeEventListener("scroll", handleScroll);
159
- };
163
+ return () => window.removeEventListener("scroll", handleScroll);
160
164
  }, [activeModal]);
161
- const [mousePosition, setMousePosition] = (0, react_2.useState)({ x: 0, y: 0 });
165
+ // به‌روزرسانی selectedRows با تغییر selectedItems
166
+ (0, react_1.useEffect)(() => {
167
+ setSelectedRows(selectedItems || []);
168
+ }, [selectedItems]);
169
+ // مدیریت گسترش ردیف‌ها
170
+ (0, react_1.useEffect)(() => {
171
+ if (childRowConfig.expandByDefault && rows) {
172
+ const parentIds = rows
173
+ .filter((row) => row.hasChildren && row.childRows && row.childRows.length > 0)
174
+ .map((row) => row.id);
175
+ setExpandedRows(parentIds);
176
+ }
177
+ }, [rows, childRowConfig.expandByDefault]);
162
178
  const handleModalToggle = (id, e) => {
163
179
  e.stopPropagation();
164
180
  e.preventDefault();
@@ -168,9 +184,8 @@ pageIndex = 0, // Default to first page (0-indexed)
168
184
  const handleActionClick = (actionId, rowId, e) => {
169
185
  e.stopPropagation();
170
186
  setActiveModal(null);
171
- if (onAction) {
187
+ if (onAction)
172
188
  onAction(actionId, rowId);
173
- }
174
189
  };
175
190
  const handleRowExpandToggle = (rowId, e) => {
176
191
  e.stopPropagation();
@@ -178,6 +193,20 @@ pageIndex = 0, // Default to first page (0-indexed)
178
193
  ? prev.filter((id) => id !== rowId)
179
194
  : [...prev, rowId]);
180
195
  };
196
+ const handleCheckboxChange = (id) => {
197
+ if (onSelectionChange) {
198
+ onSelectionChange(id);
199
+ }
200
+ else {
201
+ const updatedSelection = selectedRows.includes(id)
202
+ ? selectedRows.filter((rowId) => rowId !== id)
203
+ : [...selectedRows, id];
204
+ setSelectedRows(updatedSelection);
205
+ }
206
+ };
207
+ const isSelected = (rowId) => {
208
+ return selectedRowsSet.has(rowId);
209
+ };
181
210
  const getStatusClass = (statusClass) => {
182
211
  switch (statusClass) {
183
212
  case "success":
@@ -203,240 +232,11 @@ pageIndex = 0, // Default to first page (0-indexed)
203
232
  case "price":
204
233
  return (react_1.default.createElement("p", { className: `${item.contentClass || "text-start"} text-sm w-full truncate ` }, formatWithCommas(item.value)));
205
234
  default:
206
- return (react_1.default.createElement("div", { onClick: () => {
207
- if (item.onClick) {
208
- item.onClick(item.id);
209
- }
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" },
211
- react_1.default.createElement(SafeImage_1.default, { src: ((item.imageUrl !== null || item.imageUrl !== "") &&
212
- item.imageUrl) ||
213
- "/defaultImage.jpg", alt: item.value?.toString() || "Table item", width: item.imageWidth || 24, height: item.imageHeight || 24, className: item.imageClass || "h-6 w-6 object-cover" }),
235
+ return (react_1.default.createElement("div", { onClick: () => item.onClick && item.onClick(item.id), 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" },
236
+ 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" }),
214
237
  react_1.default.createElement("p", { className: `${item.contentClass || "text-start"} text-sm w-full truncate ` }, item.value))) : (react_1.default.createElement("p", { className: `${item.contentClass || "text-start"} text-sm mr-[5px] w-full truncate`, title: item.value?.toString() || "" }, item.value))));
215
238
  }
216
239
  };
217
- // Update selectedRows when selectedItems prop changes
218
- (0, react_2.useEffect)(() => {
219
- setSelectedRows(selectedItems || []);
220
- }, [selectedItems]);
221
- // Handle checkbox change for row selection
222
- // const handleCheckboxChange = (id: number) => {
223
- // console.log(`Processing ID: ${id}`);
224
- // // Create a new copy of the current selection
225
- // let updatedSelection = [...selectedRows];
226
- // // Check if the row is currently selected
227
- // const isSelected = updatedSelection.includes(id);
228
- // console.log(`ID ${id} is currently selected: ${isSelected}`);
229
- // // Find the item in the rows data
230
- // const findItemById = (items: TableRowData[] | undefined, itemId: number): TableRowData | null => {
231
- // if (!items) return null;
232
- // for (const item of items) {
233
- // if (item.id === itemId) {
234
- // return item;
235
- // }
236
- // if (item.hasChildren && item.childRows && item.childRows.length > 0) {
237
- // const foundInChildren = findItemById(item.childRows, itemId);
238
- // if (foundInChildren) return foundInChildren;
239
- // }
240
- // }
241
- // return null;
242
- // };
243
- // const item = findItemById(rows!, id);
244
- // console.log(`Found item for ID ${id}:`, item);
245
- // if (isSelected) {
246
- // // DESELECTION LOGIC
247
- // console.log(`Deselecting ID ${id}`);
248
- // // Remove the item itself
249
- // updatedSelection = updatedSelection.filter(itemId => itemId !== id);
250
- // // If item exists and has children, remove all children too
251
- // if (item && item.hasChildren && item.childRows && item.childRows.length > 0) {
252
- // // Function to collect all descendant IDs
253
- // const getAllDescendantIds = (items: TableRowData[]): number[] => {
254
- // let allIds: number[] = [];
255
- // for (const childItem of items) {
256
- // allIds.push(childItem.id);
257
- // if (childItem.hasChildren && childItem.childRows && childItem.childRows.length > 0) {
258
- // allIds = [...allIds, ...getAllDescendantIds(childItem.childRows)];
259
- // }
260
- // }
261
- // return allIds;
262
- // };
263
- // const descendantIds = getAllDescendantIds(item.childRows);
264
- // console.log(`Descendant IDs to remove:`, descendantIds);
265
- // // Remove all descendant IDs from the selection
266
- // updatedSelection = updatedSelection.filter(itemId => !descendantIds.includes(itemId));
267
- // }
268
- // } else {
269
- // // SELECTION LOGIC
270
- // console.log(`Selecting ID ${id}`);
271
- // // Add the item itself
272
- // updatedSelection.push(id);
273
- // // If item exists and has children, add all children too
274
- // if (item && item.hasChildren && item.childRows && item.childRows.length > 0) {
275
- // // Function to collect all descendant IDs
276
- // const getAllDescendantIds = (items: TableRowData[]): number[] => {
277
- // let allIds: number[] = [];
278
- // for (const childItem of items) {
279
- // allIds.push(childItem.id);
280
- // if (childItem.hasChildren && childItem.childRows && childItem.childRows.length > 0) {
281
- // allIds = [...allIds, ...getAllDescendantIds(childItem.childRows)];
282
- // }
283
- // }
284
- // return allIds;
285
- // };
286
- // const descendantIds = getAllDescendantIds(item.childRows);
287
- // console.log(`Descendant IDs to add:`, descendantIds);
288
- // // Add all descendant IDs to the selection if not already included
289
- // for (const descendantId of descendantIds) {
290
- // if (!updatedSelection.includes(descendantId)) {
291
- // updatedSelection.push(descendantId);
292
- // }
293
- // }
294
- // }
295
- // }
296
- // console.log("New selection:", updatedSelection);
297
- // setSelectedRows(updatedSelection);
298
- // if (onSelectionChange) {
299
- // onSelectionChange([...updatedSelection]);
300
- // }
301
- // };
302
- // Function to determine if a row has any descendants selected (not just direct children)
303
- // const isIndeterminate = (rowId: number): boolean => {
304
- // // Find the row in the data
305
- // const findRow = (
306
- // rows: TableRowData[] | undefined,
307
- // id: number
308
- // ): TableRowData | null => {
309
- // if (!rows) return null;
310
- // for (const row of rows) {
311
- // if (row.id === id) return row;
312
- // if (row.hasChildren && row.childRows) {
313
- // const found = findRow(row.childRows, id);
314
- // if (found) return found;
315
- // }
316
- // }
317
- // return null;
318
- // };
319
- // const row = findRow(rows!, rowId);
320
- // // If row has no children, it can't be indeterminate
321
- // if (
322
- // !row ||
323
- // !row.hasChildren ||
324
- // !row.childRows ||
325
- // row.childRows.length === 0
326
- // ) {
327
- // return false;
328
- // }
329
- // // Check if the row itself is selected
330
- // const isRowSelected = selectedRows.includes(rowId);
331
- // // Recursively check if any descendant is selected
332
- // const hasSelectedDescendant = (children: TableRowData[]): boolean => {
333
- // for (const child of children) {
334
- // // If any child is selected
335
- // if (selectedRows.includes(child.id)) {
336
- // return true;
337
- // }
338
- // // Check grandchildren if they exist
339
- // if (
340
- // child.hasChildren &&
341
- // child.childRows &&
342
- // child.childRows.length > 0
343
- // ) {
344
- // if (hasSelectedDescendant(child.childRows)) {
345
- // return true;
346
- // }
347
- // }
348
- // }
349
- // return false;
350
- // };
351
- // // Check if all descendants are selected
352
- // const areAllDescendantsSelected = (children: TableRowData[]): boolean => {
353
- // for (const child of children) {
354
- // // If any child is not selected
355
- // if (!selectedRows.includes(child.id)) {
356
- // return false;
357
- // }
358
- // // Check grandchildren if they exist
359
- // if (
360
- // child.hasChildren &&
361
- // child.childRows &&
362
- // child.childRows.length > 0
363
- // ) {
364
- // if (!areAllDescendantsSelected(child.childRows)) {
365
- // return false;
366
- // }
367
- // }
368
- // }
369
- // return true;
370
- // };
371
- // const hasAnySelected = hasSelectedDescendant(row.childRows);
372
- // const hasAllSelected = areAllDescendantsSelected(row.childRows);
373
- // // Indeterminate if some but not all descendants are selected
374
- // // Or if the parent is not selected but some children are
375
- // return (
376
- // (hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected)
377
- // );
378
- // };
379
- const isIndeterminate = (rowId) => {
380
- if (!rows || rows.length === 0)
381
- return false;
382
- // یک Map برای دسترسی سریع به ردیف‌ها (اگر می‌خوای می‌تونی قبل از render بسازی)
383
- const rowMap = new Map();
384
- const buildRowMap = (rows) => {
385
- for (const row of rows) {
386
- rowMap.set(row.id, row);
387
- if (row.hasChildren && row.childRows) {
388
- buildRowMap(row.childRows);
389
- }
390
- }
391
- };
392
- buildRowMap(rows);
393
- const row = rowMap.get(rowId);
394
- if (!row ||
395
- !row.hasChildren ||
396
- !row.childRows ||
397
- row.childRows.length === 0) {
398
- return false; // اگر child ندارد
399
- }
400
- const selectedSet = new Set(selectedRows); // lookup سریع
401
- let hasAnySelected = false;
402
- let hasAllSelected = true;
403
- const stack = [...row.childRows];
404
- while (stack.length > 0) {
405
- const current = stack.pop();
406
- if (selectedSet.has(current.id)) {
407
- hasAnySelected = true;
408
- }
409
- else {
410
- hasAllSelected = false;
411
- }
412
- if (current.hasChildren &&
413
- current.childRows &&
414
- current.childRows.length > 0) {
415
- stack.push(...current.childRows);
416
- }
417
- }
418
- const isRowSelected = selectedSet.has(rowId);
419
- return ((hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected));
420
- };
421
- // Function to check if a row is selected
422
- const isSelected = (rowId) => {
423
- return selectedRows.includes(rowId);
424
- };
425
- const handleCheckboxChange = (id) => {
426
- // Call your existing handleSelectionChange function
427
- // This will handle the hierarchical selection logic
428
- if (onSelectionChange) {
429
- onSelectionChange(id);
430
- }
431
- else {
432
- // Fallback to simple selection if no onSelectionChange is provided
433
- const updatedSelection = selectedRows.includes(id)
434
- ? selectedRows.filter((rowId) => rowId !== id)
435
- : [...selectedRows, id];
436
- setSelectedRows(updatedSelection);
437
- }
438
- };
439
- // Extract title and subtitle from row data
440
240
  const extractCardData = (row) => {
441
241
  let title = "";
442
242
  let subtitle = "";
@@ -446,58 +246,46 @@ pageIndex = 0, // Default to first page (0-indexed)
446
246
  let price = "";
447
247
  if (!row.data)
448
248
  return { title, subtitle, icon, status, statusClass, price };
449
- // Find title (usually first text item)
450
249
  const titleItem = row.data.find((item) => item.type === "text" && item.value);
451
250
  if (titleItem) {
452
251
  title = titleItem.value;
453
252
  }
454
253
  else if (row.data.length > 0) {
455
- // Fallback to first item
456
254
  title = String(row.data[0].value || "");
457
255
  }
458
- // Find subtitle (usually size or description)
459
256
  const subtitleItem = row.data.find((item) => item.type === "text" && item.isSubtitle);
460
257
  if (subtitleItem) {
461
258
  subtitle = subtitleItem.value;
462
259
  }
463
260
  else if (row.data.length > 1) {
464
- // Fallback to second item
465
261
  subtitle = String(row.data[1].value || "");
466
262
  }
467
- // Find status
468
263
  const statusItem = row.data.find((item) => item.type === "status");
469
264
  if (statusItem) {
470
265
  status = String(statusItem.value || "");
471
266
  statusClass = statusItem.statusClass || "";
472
267
  }
473
- // Find price (look for item with isPrice flag)
474
268
  const priceItem = row.data.find((item) => item.isPrice);
475
269
  if (priceItem) {
476
270
  price = String(priceItem.value || "");
477
271
  }
478
- // Find icon (usually avatar or image)
479
272
  const iconItem = row.data.find((item) => item.hasImage);
480
273
  if (iconItem && iconItem.value) {
481
274
  icon = String(iconItem.imageUrl || "");
482
275
  }
483
276
  return { title, subtitle, icon, status, statusClass, price };
484
277
  };
485
- // Find avatar items in row data
486
278
  const findAvatarItems = (row) => {
487
279
  if (!row.data)
488
280
  return [];
489
281
  return row.data.filter((item) => item.type === "avatar" && item.isUserAvatar);
490
282
  };
491
- // Get all rows and their children for mobile view - updated for multi-level nesting
492
283
  const getAllMobileRows = () => {
493
284
  const result = [];
494
- // Helper function to add parent rows and child rows that should be visible at any depth
495
285
  const processRows = (rows, level = 0) => {
496
286
  rows?.forEach((row) => {
497
- // Add level information to the row for proper indentation
498
287
  const rowWithLevel = { ...row, level, isChild: level > 0 };
499
288
  result.push(rowWithLevel);
500
- // Add child rows if this row is expanded - recursively check all levels
501
289
  if (row.hasChildren &&
502
290
  expandedRows.includes(row.id) &&
503
291
  row.childRows &&
@@ -506,12 +294,10 @@ pageIndex = 0, // Default to first page (0-indexed)
506
294
  }
507
295
  });
508
296
  };
509
- if (rows) {
297
+ if (rows)
510
298
  processRows(rows);
511
- }
512
299
  return result;
513
300
  };
514
- // Mobile card view
515
301
  const renderMobileCard = (row) => {
516
302
  if (!row || !row.data)
517
303
  return null;
@@ -520,10 +306,7 @@ pageIndex = 0, // Default to first page (0-indexed)
520
306
  const isFavorited = row.data.some((item) => item.isFavorite);
521
307
  const hasChildren = row.hasChildren && row.childRows && row?.childRows?.length > 0;
522
308
  const level = row.level || 0;
523
- const { cardStyle, showFolderIcon, folderIconPath, isMobileCardSelectable, showFavoriteIcon, favoriteFilledIconPath, favoriteOutlineIconPath,
524
- // showMoreOptions,
525
- moreOptionsIconPath, showAvatars, maxVisibleAvatars = 0, } = mobileCardConfig;
526
- // Calculate card classes - add special styling for child cards
309
+ const { cardStyle, showFolderIcon, folderIconPath, isMobileCardSelectable, showFavoriteIcon, favoriteFilledIconPath, favoriteOutlineIconPath, showMoreOptions, moreOptionsIconPath, showAvatars, maxVisibleAvatars = 0, } = mobileCardConfig;
527
310
  const cardClasses = `
528
311
  ${cardStyle?.backgroundColor || "bg-white"}
529
312
  ${cardStyle?.borderRadius || "rounded-lg"}
@@ -545,7 +328,7 @@ pageIndex = 0, // Default to first page (0-indexed)
545
328
  react_1.default.createElement("div", null, isMobileCardSelectable && (react_1.default.createElement("div", { className: "relative flex-shrink-0 flex" },
546
329
  react_1.default.createElement("input", { type: "checkbox", checked: isSelected(row.id), onChange: () => handleCheckboxChange(row.id), className: "peer h-5 w-5 mr-2 cursor-pointer appearance-none rounded-md border-2 border-gray-300 transition-all checked:border-blue-500 checked:bg-blue-500 hover:border-blue-500", onClick: (e) => e.stopPropagation(), ref: (el) => {
547
330
  if (el) {
548
- el.indeterminate = isIndeterminate(row.id);
331
+ el.indeterminate = indeterminateStates[row.id];
549
332
  }
550
333
  } })))),
551
334
  react_1.default.createElement("div", { className: "flex-1 min-w-0" },
@@ -555,42 +338,37 @@ pageIndex = 0, // Default to first page (0-indexed)
555
338
  level > 0 && (react_1.default.createElement("div", { className: `h-2 w-2 rounded-full bg-blue-${Math.min(400 + level * 100, 900)} mr-2 flex-shrink-0` })),
556
339
  react_1.default.createElement("h3", { className: "text-sm font-medium truncate" }, title)),
557
340
  react_1.default.createElement("p", { className: "text-xs text-gray-500 mt-1 truncate" }, subtitle),
558
- price && (react_1.default.createElement("p", { className: "text-sm font-semibold mt-1" }, price)),
341
+ price && react_1.default.createElement("p", { className: "text-sm font-semibold mt-1" }, price),
559
342
  status && (react_1.default.createElement("div", { className: "mt-2" },
560
343
  react_1.default.createElement("span", { className: `text-xs font-medium px-2 py-1 rounded-full ${getStatusClass(statusClass)} bg-opacity-10` }, status)))),
561
344
  react_1.default.createElement("div", { className: "flex items-center flex-shrink-0 ml-2" },
562
- hasChildren && (react_1.default.createElement("button", { onClick: (e) => {
563
- e.stopPropagation();
564
- handleRowExpandToggle(row.id, e);
565
- }, className: "p-2 hover:bg-gray-100 rounded" },
345
+ hasChildren && (react_1.default.createElement("button", { onClick: (e) => handleRowExpandToggle(row.id, e), className: "p-2 hover:bg-gray-100 rounded" },
566
346
  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
347
  react_1.default.createElement("path", { d: "M15 5L8 12L15 19", stroke: "rgba(0, 0, 0, 0.40)", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })))),
568
348
  showFavoriteIcon && (react_1.default.createElement("button", { className: "p-2 hover:bg-gray-100 rounded" },
569
349
  react_1.default.createElement(image_1.default, { src: isFavorited
570
350
  ? favoriteFilledIconPath ?? "/defaultFilledIcon.svg"
571
351
  : favoriteOutlineIconPath ?? "/defaultOutlineIcon.svg", alt: "favorite", width: 20, height: 20, className: isFavorited ? "text-yellow-400" : "text-gray-400" }))),
572
- (typeof mobileCardConfig.showMoreOptions === "function"
573
- ? mobileCardConfig.showMoreOptions(row)
574
- : mobileCardConfig.showMoreOptions) &&
352
+ (typeof showMoreOptions === "function"
353
+ ? showMoreOptions(row)
354
+ : showMoreOptions) &&
575
355
  modalActions &&
576
356
  modalActions.length > 0 &&
577
357
  (typeof showModalIcon === "function"
578
358
  ? showModalIcon(row)
579
359
  : showModalIcon) && (react_1.default.createElement("div", { className: "relative" },
580
- react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: `p-2 hover:bg-gray-100 rounded ${ShowActionModal
581
- ? ""
582
- : "opacity-50 cursor-not-allowed "} ` },
360
+ 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"}` },
583
361
  react_1.default.createElement(image_1.default, { src: moreOptionsIconPath || "/placeholder.svg", alt: "menu", width: 20, height: 20, className: `${ShowActionModal
584
362
  ? ""
585
363
  : "opacity-50 cursor-not-allowed"}` })),
586
364
  ShowActionModal && activeModal === row.id && (react_1.default.createElement("div", { ref: modalRef, className: "modal-content fixed z-[9999] w-40 rounded-md bg-white shadow-lg", style: {
587
365
  position: "fixed",
588
366
  top: `${mousePosition.y}px`,
589
- left: `${Math.max(0, Math.min(window.innerWidth - 160, mousePosition.x - 80) + 35)}px `, // Ensure modal stays within screen
367
+ left: `${Math.max(0, Math.min(window.innerWidth - 160, mousePosition.x - 80)) + 35}px`,
590
368
  }, onClick: (e) => e.stopPropagation() },
591
369
  react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === "function"
592
370
  ? modalActions(row)
593
- : modalActions).map((action) => (react_1.default.createElement("li", { key: action.id, onClick: (e) => handleActionClick(action.id, row.id, e), className: `rounded-md p-2 text-sm font-normal text-opacity-70 w-full customTransition ${modalStyleOperationHandler(action.class)} ${action.tailwindClassName || ""} ` }, action.text)))))))))),
371
+ : modalActions).map((action) => (react_1.default.createElement("li", { key: action.id, onClick: (e) => handleActionClick(action.id, row.id, e), className: `rounded-md p-2 text-sm font-normal text-opacity-70 w-full customTransition ${modalStyleOperationHandler(action.class)} ${action.tailwindClassName || ""}` }, action.text)))))))))),
594
372
  showAvatars && avatarItems.length > 0 && (react_1.default.createElement("div", { className: "flex items-center mt-3" },
595
373
  react_1.default.createElement("div", { className: "flex -space-x-2" },
596
374
  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" },
@@ -599,9 +377,7 @@ pageIndex = 0, // Default to first page (0-indexed)
599
377
  "+",
600
378
  avatarItems.length - maxVisibleAvatars)))))))));
601
379
  };
602
- // Render a single table row (parent or child)
603
380
  const renderTableRow = (row, index, isLastRow) => {
604
- // Width for the expand/collapse control column
605
381
  return (react_1.default.createElement("div", { key: `row-container-${row.id}` },
606
382
  react_1.default.createElement("div", { className: `grid w-full items-center ${row.isChild
607
383
  ? childRowConfig.childRowClass || "bg-blue-300 bg-opacity-10"
@@ -613,26 +389,20 @@ pageIndex = 0, // Default to first page (0-indexed)
613
389
  gridTemplateColumns: isMobileView && mobileViewGridClassName
614
390
  ? mobileViewGridClassName
615
391
  : gridClassName || "repeat(auto-fit, minmax(100px, 1fr))",
616
- }, onClick: () => {
617
- if (onView) {
618
- onView(row.id);
619
- }
620
- } },
392
+ }, onClick: () => onView && onView(row.id) },
621
393
  react_1.default.createElement("div", { className: `flex items-center justify-center gap-2 ${!row.hasChildren && "mr-[4px]"}`, style: { width: "55px" } },
622
- !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)),
394
+ !row.hasChildren && !row.isChild && (react_1.default.createElement("span", { className: "text-xs text-gray-500 font-semibold flex-shrink-0 mr-1" }, ((pageIndex || 1) - 1) * (itemsPerPage || 10) + index + 1)),
623
395
  react_1.default.createElement("div", { className: "flex items-center justify-center gap-1" },
624
396
  row.hasChildren && row.childRows && row.childRows?.length > 0 ? (react_1.default.createElement("button", { onClick: (e) => handleRowExpandToggle(row.id, e), className: "transition-transform duration-200 flex-shrink-0" },
625
397
  react_1.default.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: `transition-transform ${expandedRows.includes(row.id) ? "-rotate-90" : ""}` },
626
- react_1.default.createElement("path", { d: "M15 5L8 12L15 19", stroke: "rgba(0, 0, 0, 0.40)", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })))) : row.isChild ? (
627
- // Child row indicator
628
- react_1.default.createElement("div", { className: "h-2 w-2 rounded-full bg-black/20 flex-shrink-0" })) : null,
398
+ react_1.default.createElement("path", { d: "M15 5L8 12L15 19", stroke: "rgba(0, 0, 0, 0.40)", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })))) : row.isChild ? (react_1.default.createElement("div", { className: "h-2 w-2 rounded-full bg-black/20 flex-shrink-0" })) : null,
629
399
  selectable === true && !row.isChild && (react_1.default.createElement("div", { className: "relative flex-shrink-0 flex" },
630
400
  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) => {
631
401
  if (el) {
632
- el.indeterminate = isIndeterminate(row.id);
402
+ el.indeterminate = indeterminateStates[row.id];
633
403
  }
634
404
  } }),
635
- 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" },
405
+ indeterminateStates[row.id] ? (react_1.default.createElement("div", { className: "pointer-events-none absolute left-[5px] top-[9px] w-2.5 h-0.5 bg-blue-500" })) : (react_1.default.createElement("svg", { className: "pointer-events-none absolute left-[5px] top-[5px] h-2.5 w-2.5 fill-white opacity-0 transition-opacity peer-checked:opacity-100", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" },
636
406
  react_1.default.createElement("path", { d: "M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" }))))))),
637
407
  row?.data?.map((item, colIndex) => (react_1.default.createElement("div", { key: `${item.id}-${colIndex}`, className: `h-full select-none text-xs font-medium min-w-0 flex items-center ${item.type === "avatar" ||
638
408
  item.type === "operation" ||
@@ -648,16 +418,14 @@ pageIndex = 0, // Default to first page (0-indexed)
648
418
  : "flex-start",
649
419
  } },
650
420
  colIndex === 0 && row.isChild && selectable && (react_1.default.createElement("div", { className: "flex items-center" },
651
- react_1.default.createElement("div", { style: {
652
- paddingLeft: `${(row.level || 1) * 7}px`,
653
- }, className: "flex-shrink-0" }),
654
- react_1.default.createElement("div", { className: "relative flex items-center justify-center " },
421
+ react_1.default.createElement("div", { style: { paddingLeft: `${(row.level || 1) * 7}px` }, className: "flex-shrink-0" }),
422
+ react_1.default.createElement("div", { className: "relative flex items-center justify-center" },
655
423
  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) => {
656
424
  if (el) {
657
- el.indeterminate = isIndeterminate(row.id);
425
+ el.indeterminate = indeterminateStates[row.id];
658
426
  }
659
427
  } }),
660
- 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" },
428
+ indeterminateStates[row.id] ? (react_1.default.createElement("div", { className: "pointer-events-none absolute left-[5px] top-[9px] w-2.5 h-0.5 bg-blue-500" })) : (react_1.default.createElement("svg", { className: "pointer-events-none absolute left-[5px] top-[5px] h-2.5 w-2.5 fill-white opacity-0 transition-opacity peer-checked:opacity-100", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" },
661
429
  react_1.default.createElement("path", { d: "M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" })))))),
662
430
  renderCellContent(item)))),
663
431
  actions && (react_1.default.createElement("div", { className: `w-24 py-4 flex items-center justify-end text-sm font-medium ${actionButtonsStyle || ""}` },
@@ -673,21 +441,15 @@ pageIndex = 0, // Default to first page (0-indexed)
673
441
  (typeof showModalIcon === "function"
674
442
  ? showModalIcon(row)
675
443
  : showModalIcon) ? (react_1.default.createElement("button", { onClick: (e) => handleModalToggle(row.id, e), className: "", "data-row-id": row.id },
676
- react_1.default.createElement(image_1.default, { src: iconsSRC?.moreIcon || "/placeholder.svg", alt: "menu", width: 18, height: 18, className: iconsSRC?.moreIconTailwindStyle || "" }))) : (
677
- // Render an invisible placeholder to maintain spacing when icon is hidden
678
- react_1.default.createElement("div", { className: "w-[18px] h-[18px]" })),
444
+ react_1.default.createElement(image_1.default, { src: iconsSRC?.moreIcon || "/placeholder.svg", alt: "menu", width: 18, height: 18, className: iconsSRC?.moreIconTailwindStyle || "" }))) : (react_1.default.createElement("div", { className: "w-[18px] h-[18px]" })),
679
445
  ShowActionModal && activeModal === row.id && (react_1.default.createElement("div", { ref: modalRef, className: "modal-content fixed z-[9999] w-40 rounded-md bg-white shadow-lg", style: {
680
446
  position: "fixed",
681
447
  top: (() => {
682
- // Get all visible rows for the current view
683
448
  const allRows = isMobileView
684
449
  ? getAllMobileRows()
685
450
  : rows;
686
- // Find the index of the current row
687
451
  const currentRowIndex = allRows?.findIndex((r) => r.id === row.id);
688
- // Check if this is one of the last 3 rows
689
452
  const isLastThreeRows = allRows && currentRowIndex >= allRows.length - 3;
690
- // If it's one of the last 3 rows, reduce the top position by 100px
691
453
  return isLastThreeRows
692
454
  ? `${mousePosition.y - 110}px`
693
455
  : `${mousePosition.y}px`;
@@ -696,31 +458,24 @@ pageIndex = 0, // Default to first page (0-indexed)
696
458
  }, onClick: (e) => e.stopPropagation() },
697
459
  react_1.default.createElement("ul", { className: "flex flex-col items-start justify-center gap-1 p-2" }, (typeof modalActions === "function"
698
460
  ? modalActions(row)
699
- : modalActions).map((action) => (react_1.default.createElement("li", { key: action.id, onClick: (e) => handleActionClick(action.id, row.id, e), className: `rounded-md p-2 text-sm font-normal text-opacity-70 w-full cursor-pointer ${modalStyleOperationHandler(action.class)} customTransition ${action.tailwindClassName || ""} ` }, action.text))))))))))),
461
+ : 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)} ${action.tailwindClassName || ""}` }, action.text))))))))))),
700
462
  row.hasChildren &&
701
463
  expandedRows.includes(row.id) &&
702
464
  row.childRows &&
703
465
  row.childRows.map((childRow, childIndex) => renderTableRow(childRow, childIndex, childIndex === row.childRows.length - 1 && isLastRow))));
704
466
  };
705
- // Prepare all mobile rows
706
467
  const mobileRows = getAllMobileRows();
707
- // Show loading state if loading is true
708
468
  if (loadingProps.isLoading) {
709
469
  return (react_1.default.createElement("div", { className: "w-full flex justify-center items-center py-8 gap-3" },
710
470
  loadingProps.loadingIcon,
711
471
  loadingProps.loadingText && loadingProps.loadingText));
712
472
  }
713
- // Show no items found if rows are empty or null and not loading
714
473
  if (!loadingProps.isLoading && rows?.length === 0) {
715
474
  return (react_1.default.createElement("div", { className: "flex flex-col items-center justify-center p-8" }, typeof noItemFoundProps?.imagePath === "string" ? (react_1.default.createElement(react_1.default.Fragment, null,
716
475
  react_1.default.createElement(image_1.default, { src: noItemFoundProps?.imagePath || "/icons/no-data.svg", alt: "No items found", width: 120, height: 120 }),
717
- react_1.default.createElement("p", { className: "mt-4 text-gray-500 text-sm" },
718
- noItemFoundProps?.title,
719
- " "))) : (react_1.default.createElement(react_1.default.Fragment, null,
476
+ react_1.default.createElement("p", { className: "mt-4 text-gray-500 text-sm" }, noItemFoundProps?.title))) : (react_1.default.createElement(react_1.default.Fragment, null,
720
477
  noItemFoundProps?.imagePath,
721
- react_1.default.createElement("p", { className: "mt-4 text-gray-500 text-sm" },
722
- noItemFoundProps?.title,
723
- " ")))));
478
+ react_1.default.createElement("p", { className: "mt-4 text-gray-500 text-sm" }, noItemFoundProps?.title)))));
724
479
  }
725
480
  return (react_1.default.createElement(react_1.default.Fragment, null,
726
481
  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)))))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.10.5",
3
+ "version": "0.10.7",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {