@dappworks/kit 0.4.162 → 0.4.163
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.
- package/dist/aiem.mjs +20 -11
- package/dist/aiem.mjs.map +1 -1
- package/dist/{chunk-F7Y3RG4J.mjs → chunk-2UD4IDBE.mjs} +287 -126
- package/dist/chunk-2UD4IDBE.mjs.map +1 -0
- package/dist/experimental.d.mts +5 -7
- package/dist/jsontable.d.mts +14 -3
- package/dist/jsontable.mjs +1 -1
- package/dist/metrics.mjs +1 -1
- package/dist/plugins.d.mts +4 -4
- package/dist/utils.d.mts +1 -1
- package/package.json +3 -2
- package/dist/chunk-F7Y3RG4J.mjs.map +0 -1
|
@@ -4,11 +4,12 @@ import { _ } from './chunk-K7LFG5BA.mjs';
|
|
|
4
4
|
import { cn } from './chunk-WYGQ3Y4R.mjs';
|
|
5
5
|
import { __objRest, __spreadValues, __spreadProps } from './chunk-6F7H4PAA.mjs';
|
|
6
6
|
import * as React2 from 'react';
|
|
7
|
-
import React2__default, { useState,
|
|
8
|
-
import {
|
|
7
|
+
import React2__default, { useState, useMemo, useEffect, useRef } from 'react';
|
|
8
|
+
import { Card, Divider, Pagination, Spinner } from '@nextui-org/react';
|
|
9
9
|
import { ChevronRight, Check, Circle, ChevronDown, ChevronUp, ChevronsUpDown, ChevronLeft } from 'lucide-react';
|
|
10
10
|
import { observer } from 'mobx-react-lite';
|
|
11
11
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
12
|
+
import { VList } from 'virtua';
|
|
12
13
|
|
|
13
14
|
var DropdownMenu = DropdownMenuPrimitive.Root;
|
|
14
15
|
var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
@@ -132,8 +133,6 @@ var DropdownMenuSeparator = React2.forwardRef((_a, ref) => {
|
|
|
132
133
|
);
|
|
133
134
|
});
|
|
134
135
|
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
135
|
-
|
|
136
|
-
// components/JSONTable/index.tsx
|
|
137
136
|
var JSONTable = observer((props) => {
|
|
138
137
|
const {
|
|
139
138
|
className,
|
|
@@ -166,11 +165,11 @@ var JSONTable = observer((props) => {
|
|
|
166
165
|
loadingContent,
|
|
167
166
|
isHeaderSticky = false,
|
|
168
167
|
sortingUIOptions,
|
|
169
|
-
collapsedTableConfig
|
|
168
|
+
collapsedTableConfig,
|
|
169
|
+
virtualizedOptions
|
|
170
170
|
} = props;
|
|
171
171
|
const [sortableColumnsMap, setSortableColumnsMap] = useState({});
|
|
172
172
|
const [sortedData, setSortedData] = useState(dataSource);
|
|
173
|
-
const tableBoxRef = useRef(null);
|
|
174
173
|
const { columns, sortableColumnsDefaultValue, showCollapsedTables, collapsedTables } = useMemo(() => {
|
|
175
174
|
const firstData = dataSource[0];
|
|
176
175
|
const allKeys = firstData ? Object.keys(firstData) : [];
|
|
@@ -230,7 +229,7 @@ var JSONTable = observer((props) => {
|
|
|
230
229
|
});
|
|
231
230
|
}
|
|
232
231
|
const showCollapsedTables2 = collapsedTables2.length > 0;
|
|
233
|
-
if (showCollapsedTables2) {
|
|
232
|
+
if (showCollapsedTables2 && !(virtualizedOptions == null ? void 0 : virtualizedOptions.isVirtualized)) {
|
|
234
233
|
const collapsedHandlerPosition = (collapsedTableConfig == null ? void 0 : collapsedTableConfig.collapsedHandlerPosition) || "right";
|
|
235
234
|
if (collapsedHandlerPosition === "right") {
|
|
236
235
|
columns2.push({
|
|
@@ -259,7 +258,7 @@ var JSONTable = observer((props) => {
|
|
|
259
258
|
});
|
|
260
259
|
}
|
|
261
260
|
}, [dataSource]);
|
|
262
|
-
const data = isServerPaging || !showPagination ? sortedData : sortedData.slice(pagination.offset, pagination.offset + pagination.limit);
|
|
261
|
+
const data = isServerPaging || !showPagination || (virtualizedOptions == null ? void 0 : virtualizedOptions.isVirtualized) || asCard ? sortedData : sortedData.slice(pagination.offset, pagination.offset + pagination.limit);
|
|
263
262
|
if (asCard) {
|
|
264
263
|
return /* @__PURE__ */ React2__default.createElement(
|
|
265
264
|
CardUI,
|
|
@@ -268,116 +267,70 @@ var JSONTable = observer((props) => {
|
|
|
268
267
|
rowKey,
|
|
269
268
|
data,
|
|
270
269
|
columns,
|
|
271
|
-
columnOptions,
|
|
272
270
|
cardOptions,
|
|
273
|
-
pagination,
|
|
274
|
-
nextuiPaginationProps,
|
|
275
|
-
showPagination,
|
|
276
271
|
onRowClick,
|
|
277
272
|
autoScrollToTop,
|
|
278
273
|
emptyContent,
|
|
279
274
|
isLoading,
|
|
280
275
|
loadingOptions,
|
|
281
|
-
loadingContent
|
|
276
|
+
loadingContent,
|
|
277
|
+
virtualizedOptions
|
|
282
278
|
}
|
|
283
279
|
);
|
|
284
280
|
}
|
|
285
|
-
|
|
286
|
-
"th",
|
|
287
|
-
{
|
|
288
|
-
key: item.key,
|
|
289
|
-
className: cn("px-3 h-10 text-xs font-semibold whitespace-nowrap bg-default-100 first:rounded-l-lg last:rounded-r-lg outline-none", classNames.th)
|
|
290
|
-
},
|
|
291
|
-
/* @__PURE__ */ React2__default.createElement("div", { className: "flex items-center" }, /* @__PURE__ */ React2__default.createElement("span", null, item.label), !!sortableColumnsMap[item.key] && /* @__PURE__ */ React2__default.createElement(
|
|
292
|
-
SortingComponent,
|
|
293
|
-
{
|
|
294
|
-
sortingUIOptions,
|
|
295
|
-
columnOptions,
|
|
296
|
-
sortableColumnsMap,
|
|
297
|
-
item,
|
|
298
|
-
onSort: ({ type, key, sortKey }) => {
|
|
299
|
-
const { sortableColumns, sortedData: sortedData2 } = sortData({
|
|
300
|
-
type,
|
|
301
|
-
key,
|
|
302
|
-
sortKey,
|
|
303
|
-
sortableColumnsMap,
|
|
304
|
-
dataSource
|
|
305
|
-
});
|
|
306
|
-
setSortableColumnsMap(sortableColumns);
|
|
307
|
-
setSortedData(sortedData2);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
))
|
|
311
|
-
))), /* @__PURE__ */ React2__default.createElement("tr", { "aria-hidden": "true", className: "w-px h-px block ml-[0.25rem] mt-[0.25rem]" })), isLoading ? /* @__PURE__ */ React2__default.createElement("tbody", { className: classNames.tbody }, /* @__PURE__ */ React2__default.createElement("tr", { className: classNames.tr }, /* @__PURE__ */ React2__default.createElement(
|
|
312
|
-
"td",
|
|
313
|
-
{
|
|
314
|
-
className: classNames.td,
|
|
315
|
-
colSpan: columns.length
|
|
316
|
-
},
|
|
317
|
-
loadingContent || DefaultLoading({ loadingOptions })
|
|
318
|
-
))) : data.length > 0 ? /* @__PURE__ */ React2__default.createElement("tbody", { className: classNames.tbody }, showCollapsedTables ? data.map((item) => {
|
|
281
|
+
if (virtualizedOptions.isVirtualized) {
|
|
319
282
|
return /* @__PURE__ */ React2__default.createElement(
|
|
320
|
-
|
|
283
|
+
VirtualizedListUI,
|
|
321
284
|
{
|
|
322
|
-
|
|
323
|
-
|
|
285
|
+
className,
|
|
286
|
+
rowKey,
|
|
287
|
+
data,
|
|
288
|
+
dataSource,
|
|
324
289
|
columns,
|
|
325
|
-
|
|
290
|
+
columnOptions,
|
|
291
|
+
sortableColumnsMap,
|
|
292
|
+
sortingUIOptions,
|
|
293
|
+
setSortableColumnsMap,
|
|
294
|
+
setSortedData,
|
|
326
295
|
onRowClick,
|
|
327
|
-
|
|
328
|
-
|
|
296
|
+
emptyContent,
|
|
297
|
+
isLoading,
|
|
298
|
+
loadingOptions,
|
|
299
|
+
loadingContent,
|
|
300
|
+
virtualizedOptions
|
|
329
301
|
}
|
|
330
302
|
);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
{
|
|
335
|
-
key: rowKey ? item[rowKey] || index : index,
|
|
336
|
-
className: cn(classNames.tr, typeof rowCss === "function" ? rowCss(item) : rowCss),
|
|
337
|
-
onClick: () => {
|
|
338
|
-
onRowClick == null ? void 0 : onRowClick(item);
|
|
339
|
-
}
|
|
340
|
-
},
|
|
341
|
-
columns.map((column) => {
|
|
342
|
-
return /* @__PURE__ */ React2__default.createElement(
|
|
343
|
-
"td",
|
|
344
|
-
{
|
|
345
|
-
key: column.key,
|
|
346
|
-
className: cn("py-2 px-3 text-xs", classNames.td)
|
|
347
|
-
},
|
|
348
|
-
column.render ? column.render(item) : renderFieldValue(item[column.key])
|
|
349
|
-
);
|
|
350
|
-
})
|
|
351
|
-
);
|
|
352
|
-
})) : /* @__PURE__ */ React2__default.createElement("tbody", { className: classNames.tbody }, /* @__PURE__ */ React2__default.createElement("tr", { className: classNames.tr }, /* @__PURE__ */ React2__default.createElement(
|
|
353
|
-
"td",
|
|
303
|
+
}
|
|
304
|
+
return /* @__PURE__ */ React2__default.createElement(
|
|
305
|
+
TableUI,
|
|
354
306
|
{
|
|
355
|
-
className
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
307
|
+
className,
|
|
308
|
+
classNames,
|
|
309
|
+
isHeaderSticky,
|
|
310
|
+
columns,
|
|
311
|
+
columnOptions,
|
|
312
|
+
sortableColumnsMap,
|
|
313
|
+
sortingUIOptions,
|
|
314
|
+
setSortableColumnsMap,
|
|
315
|
+
setSortedData,
|
|
316
|
+
data,
|
|
317
|
+
dataSource,
|
|
318
|
+
isLoading,
|
|
319
|
+
loadingContent,
|
|
320
|
+
loadingOptions,
|
|
321
|
+
emptyContent,
|
|
322
|
+
rowCss,
|
|
323
|
+
onRowClick,
|
|
324
|
+
showCollapsedTables,
|
|
325
|
+
collapsedTableConfig,
|
|
326
|
+
collapsedTables,
|
|
327
|
+
rowKey,
|
|
328
|
+
showPagination,
|
|
329
|
+
pagination,
|
|
330
|
+
nextuiPaginationProps,
|
|
331
|
+
autoScrollToTop
|
|
332
|
+
}
|
|
333
|
+
);
|
|
381
334
|
});
|
|
382
335
|
function renderFieldValue(v) {
|
|
383
336
|
if (typeof v == "string" || typeof v == "number") {
|
|
@@ -525,37 +478,245 @@ function CardUI({
|
|
|
525
478
|
className,
|
|
526
479
|
data,
|
|
527
480
|
columns,
|
|
528
|
-
columnOptions,
|
|
529
481
|
rowKey,
|
|
530
482
|
cardOptions,
|
|
531
|
-
pagination,
|
|
532
|
-
nextuiPaginationProps,
|
|
533
|
-
showPagination,
|
|
534
483
|
onRowClick,
|
|
535
|
-
autoScrollToTop,
|
|
536
484
|
emptyContent,
|
|
537
485
|
isLoading,
|
|
538
486
|
loadingOptions,
|
|
539
|
-
loadingContent
|
|
487
|
+
loadingContent,
|
|
488
|
+
virtualizedOptions
|
|
540
489
|
}) {
|
|
541
|
-
const
|
|
542
|
-
|
|
490
|
+
const fetchedCountRef = useRef(-1);
|
|
491
|
+
const elements = useMemo(
|
|
492
|
+
() => data.map((item, index) => {
|
|
493
|
+
return /* @__PURE__ */ React2__default.createElement(
|
|
494
|
+
Card,
|
|
495
|
+
{
|
|
496
|
+
key: rowKey ? item[rowKey] || index : index,
|
|
497
|
+
className: cn("mb-2 w-full shadow-sm p-4 rounded-lg", cardOptions == null ? void 0 : cardOptions.cardClassName),
|
|
498
|
+
isPressable: !!onRowClick,
|
|
499
|
+
onPress: () => {
|
|
500
|
+
onRowClick == null ? void 0 : onRowClick(item);
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
columns.map((column, i) => {
|
|
504
|
+
return /* @__PURE__ */ React2__default.createElement("div", { className: "w-full", key: column.key }, /* @__PURE__ */ React2__default.createElement("div", { className: cn("w-full", cardOptions == null ? void 0 : cardOptions.itemClassName) }, /* @__PURE__ */ React2__default.createElement("div", { className: cn("font-meidum text-xs text-foreground-400", cardOptions == null ? void 0 : cardOptions.labelClassName) }, column.label), /* @__PURE__ */ React2__default.createElement("div", { className: cn("text-xs", cardOptions == null ? void 0 : cardOptions.valueClassName) }, column.render ? column.render(item) : renderFieldValue(item[column.key]))), (cardOptions == null ? void 0 : cardOptions.showDivider) && i !== columns.length - 1 && /* @__PURE__ */ React2__default.createElement(Divider, { className: cn("my-2", cardOptions == null ? void 0 : cardOptions.dividerClassName) }));
|
|
505
|
+
})
|
|
506
|
+
);
|
|
507
|
+
}),
|
|
508
|
+
[data]
|
|
509
|
+
);
|
|
510
|
+
return /* @__PURE__ */ React2__default.createElement("div", { className }, data.length > 0 ? /* @__PURE__ */ React2__default.createElement(
|
|
511
|
+
VList,
|
|
512
|
+
{
|
|
513
|
+
style: { height: (virtualizedOptions == null ? void 0 : virtualizedOptions.vListHeight) || 400 },
|
|
514
|
+
onRangeChange: async (_2, endIndex) => {
|
|
515
|
+
const count = data.length;
|
|
516
|
+
if (endIndex + 1 >= count && fetchedCountRef.current < count) {
|
|
517
|
+
fetchedCountRef.current = count;
|
|
518
|
+
if (virtualizedOptions == null ? void 0 : virtualizedOptions.fetchData) {
|
|
519
|
+
await virtualizedOptions.fetchData();
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
elements,
|
|
525
|
+
isLoading ? loadingContent || DefaultLoading({ loadingOptions }) : null
|
|
526
|
+
) : emptyContent != null ? emptyContent : /* @__PURE__ */ React2__default.createElement(DefaultEmptyContent, null));
|
|
527
|
+
}
|
|
528
|
+
function VirtualizedListUI({
|
|
529
|
+
className,
|
|
530
|
+
data,
|
|
531
|
+
dataSource,
|
|
532
|
+
columns,
|
|
533
|
+
columnOptions,
|
|
534
|
+
sortableColumnsMap,
|
|
535
|
+
sortingUIOptions,
|
|
536
|
+
setSortableColumnsMap,
|
|
537
|
+
setSortedData,
|
|
538
|
+
rowKey,
|
|
539
|
+
onRowClick,
|
|
540
|
+
rowCss,
|
|
541
|
+
emptyContent,
|
|
542
|
+
isLoading,
|
|
543
|
+
loadingOptions,
|
|
544
|
+
loadingContent,
|
|
545
|
+
virtualizedOptions
|
|
546
|
+
}) {
|
|
547
|
+
var _a;
|
|
548
|
+
const fetchedCountRef = useRef(-1);
|
|
549
|
+
const elements = useMemo(
|
|
550
|
+
() => data.map((item, index) => {
|
|
551
|
+
var _a2;
|
|
552
|
+
return /* @__PURE__ */ React2__default.createElement(
|
|
553
|
+
"div",
|
|
554
|
+
{
|
|
555
|
+
key: rowKey ? item[rowKey] || index : index,
|
|
556
|
+
className: cn("flex items-center", (_a2 = virtualizedOptions == null ? void 0 : virtualizedOptions.classNames) == null ? void 0 : _a2.row, typeof rowCss === "function" ? rowCss(item) : rowCss),
|
|
557
|
+
onClick: () => {
|
|
558
|
+
onRowClick == null ? void 0 : onRowClick(item);
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
columns.map((column) => {
|
|
562
|
+
var _a3;
|
|
563
|
+
return /* @__PURE__ */ React2__default.createElement(
|
|
564
|
+
"div",
|
|
565
|
+
{
|
|
566
|
+
key: column.key,
|
|
567
|
+
className: cn("w-full py-2 px-3 text-xs", (_a3 = virtualizedOptions == null ? void 0 : virtualizedOptions.classNames) == null ? void 0 : _a3.rowItem)
|
|
568
|
+
},
|
|
569
|
+
column.render ? column.render(item) : renderFieldValue(item[column.key])
|
|
570
|
+
);
|
|
571
|
+
})
|
|
572
|
+
);
|
|
573
|
+
}),
|
|
574
|
+
[data]
|
|
575
|
+
);
|
|
576
|
+
return /* @__PURE__ */ React2__default.createElement("div", { className }, /* @__PURE__ */ React2__default.createElement("div", { className: cn("w-full flex items-center rounded-lg bg-default-100", (_a = virtualizedOptions == null ? void 0 : virtualizedOptions.classNames) == null ? void 0 : _a.header) }, columns.map((column) => {
|
|
577
|
+
var _a2;
|
|
578
|
+
return /* @__PURE__ */ React2__default.createElement("div", { key: column.key, className: cn("w-full h-10 px-3 flex items-center text-xs font-semibold whitespace-nowrap", (_a2 = virtualizedOptions == null ? void 0 : virtualizedOptions.classNames) == null ? void 0 : _a2.column) }, /* @__PURE__ */ React2__default.createElement("span", null, column.label), !!sortableColumnsMap[column.key] && /* @__PURE__ */ React2__default.createElement(
|
|
579
|
+
SortingComponent,
|
|
580
|
+
{
|
|
581
|
+
sortingUIOptions,
|
|
582
|
+
columnOptions,
|
|
583
|
+
sortableColumnsMap,
|
|
584
|
+
item: column,
|
|
585
|
+
onSort: ({ type, key, sortKey }) => {
|
|
586
|
+
const { sortableColumns, sortedData } = sortData({
|
|
587
|
+
type,
|
|
588
|
+
key,
|
|
589
|
+
sortKey,
|
|
590
|
+
sortableColumnsMap,
|
|
591
|
+
dataSource
|
|
592
|
+
});
|
|
593
|
+
setSortableColumnsMap(sortableColumns);
|
|
594
|
+
setSortedData(sortedData);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
));
|
|
598
|
+
})), data.length > 0 ? /* @__PURE__ */ React2__default.createElement(
|
|
599
|
+
VList,
|
|
600
|
+
{
|
|
601
|
+
className: "mt-2 w-full",
|
|
602
|
+
style: { height: (virtualizedOptions == null ? void 0 : virtualizedOptions.vListHeight) || 200 },
|
|
603
|
+
onRangeChange: async (_2, endIndex) => {
|
|
604
|
+
const count = data.length;
|
|
605
|
+
if (endIndex + 1 >= count && fetchedCountRef.current < count) {
|
|
606
|
+
fetchedCountRef.current = count;
|
|
607
|
+
if (virtualizedOptions == null ? void 0 : virtualizedOptions.fetchData) {
|
|
608
|
+
await virtualizedOptions.fetchData();
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
},
|
|
613
|
+
elements,
|
|
614
|
+
isLoading ? loadingContent || DefaultLoading({ loadingOptions }) : null
|
|
615
|
+
) : emptyContent != null ? emptyContent : /* @__PURE__ */ React2__default.createElement(DefaultEmptyContent, null));
|
|
616
|
+
}
|
|
617
|
+
function TableUI({
|
|
618
|
+
className,
|
|
619
|
+
classNames,
|
|
620
|
+
isHeaderSticky,
|
|
621
|
+
columns,
|
|
622
|
+
columnOptions,
|
|
623
|
+
sortableColumnsMap,
|
|
624
|
+
sortingUIOptions,
|
|
625
|
+
setSortableColumnsMap,
|
|
626
|
+
setSortedData,
|
|
627
|
+
data,
|
|
628
|
+
dataSource,
|
|
629
|
+
isLoading,
|
|
630
|
+
loadingContent,
|
|
631
|
+
loadingOptions,
|
|
632
|
+
emptyContent,
|
|
633
|
+
rowCss,
|
|
634
|
+
onRowClick,
|
|
635
|
+
showCollapsedTables,
|
|
636
|
+
collapsedTableConfig,
|
|
637
|
+
collapsedTables,
|
|
638
|
+
rowKey,
|
|
639
|
+
showPagination,
|
|
640
|
+
pagination,
|
|
641
|
+
nextuiPaginationProps,
|
|
642
|
+
autoScrollToTop
|
|
643
|
+
}) {
|
|
644
|
+
const tableBoxRef = useRef(null);
|
|
645
|
+
return /* @__PURE__ */ React2__default.createElement(React2__default.Fragment, null, /* @__PURE__ */ React2__default.createElement("div", { className: cn("relative w-full", className), ref: tableBoxRef }, /* @__PURE__ */ React2__default.createElement("table", { className: cn("w-full h-auto table-auto", classNames.table) }, /* @__PURE__ */ React2__default.createElement("thead", { className: cn(classNames.thead, { "sticky top-0 z-30 [&>tr]:first:shadow-small [&>tr]:first:rounded-lg": isHeaderSticky }) }, /* @__PURE__ */ React2__default.createElement("tr", { className: classNames.tr }, columns.map((item) => /* @__PURE__ */ React2__default.createElement(
|
|
646
|
+
"th",
|
|
647
|
+
{
|
|
648
|
+
key: item.key,
|
|
649
|
+
className: cn("px-3 h-10 text-xs font-semibold whitespace-nowrap bg-default-100 first:rounded-l-lg last:rounded-r-lg outline-none", classNames.th)
|
|
650
|
+
},
|
|
651
|
+
/* @__PURE__ */ React2__default.createElement("div", { className: "flex items-center" }, /* @__PURE__ */ React2__default.createElement("span", null, item.label), !!sortableColumnsMap[item.key] && /* @__PURE__ */ React2__default.createElement(
|
|
652
|
+
SortingComponent,
|
|
653
|
+
{
|
|
654
|
+
sortingUIOptions,
|
|
655
|
+
columnOptions,
|
|
656
|
+
sortableColumnsMap,
|
|
657
|
+
item,
|
|
658
|
+
onSort: ({ type, key, sortKey }) => {
|
|
659
|
+
const { sortableColumns, sortedData } = sortData({
|
|
660
|
+
type,
|
|
661
|
+
key,
|
|
662
|
+
sortKey,
|
|
663
|
+
sortableColumnsMap,
|
|
664
|
+
dataSource
|
|
665
|
+
});
|
|
666
|
+
setSortableColumnsMap(sortableColumns);
|
|
667
|
+
setSortedData(sortedData);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
))
|
|
671
|
+
))), /* @__PURE__ */ React2__default.createElement("tr", { "aria-hidden": "true", className: "w-px h-px block ml-[0.25rem] mt-[0.25rem]" })), isLoading ? /* @__PURE__ */ React2__default.createElement("tbody", { className: classNames.tbody }, /* @__PURE__ */ React2__default.createElement("tr", { className: classNames.tr }, /* @__PURE__ */ React2__default.createElement(
|
|
672
|
+
"td",
|
|
673
|
+
{
|
|
674
|
+
className: classNames.td,
|
|
675
|
+
colSpan: columns.length
|
|
676
|
+
},
|
|
677
|
+
loadingContent || DefaultLoading({ loadingOptions })
|
|
678
|
+
))) : data.length > 0 ? /* @__PURE__ */ React2__default.createElement("tbody", { className: classNames.tbody }, showCollapsedTables ? data.map((item) => {
|
|
543
679
|
return /* @__PURE__ */ React2__default.createElement(
|
|
544
|
-
|
|
680
|
+
CollapseBodyRow,
|
|
681
|
+
{
|
|
682
|
+
classNames,
|
|
683
|
+
item,
|
|
684
|
+
columns,
|
|
685
|
+
rowCss,
|
|
686
|
+
onRowClick,
|
|
687
|
+
collapsedTableConfig,
|
|
688
|
+
collapsedTables
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
}) : data.map((item, index) => {
|
|
692
|
+
return /* @__PURE__ */ React2__default.createElement(
|
|
693
|
+
"tr",
|
|
545
694
|
{
|
|
546
695
|
key: rowKey ? item[rowKey] || index : index,
|
|
547
|
-
className: cn(
|
|
548
|
-
|
|
549
|
-
onPress: () => {
|
|
696
|
+
className: cn(classNames.tr, typeof rowCss === "function" ? rowCss(item) : rowCss),
|
|
697
|
+
onClick: () => {
|
|
550
698
|
onRowClick == null ? void 0 : onRowClick(item);
|
|
551
699
|
}
|
|
552
700
|
},
|
|
553
|
-
columns.map((column
|
|
554
|
-
|
|
555
|
-
|
|
701
|
+
columns.map((column) => {
|
|
702
|
+
return /* @__PURE__ */ React2__default.createElement(
|
|
703
|
+
"td",
|
|
704
|
+
{
|
|
705
|
+
key: column.key,
|
|
706
|
+
className: cn("py-2 px-3 text-xs", classNames.td)
|
|
707
|
+
},
|
|
708
|
+
column.render ? column.render(item) : renderFieldValue(item[column.key])
|
|
709
|
+
);
|
|
556
710
|
})
|
|
557
711
|
);
|
|
558
|
-
}) : /* @__PURE__ */ React2__default.createElement(
|
|
712
|
+
})) : /* @__PURE__ */ React2__default.createElement("tbody", { className: classNames.tbody }, /* @__PURE__ */ React2__default.createElement("tr", { className: classNames.tr }, /* @__PURE__ */ React2__default.createElement(
|
|
713
|
+
"td",
|
|
714
|
+
{
|
|
715
|
+
className: classNames.td,
|
|
716
|
+
colSpan: columns.length
|
|
717
|
+
},
|
|
718
|
+
emptyContent != null ? emptyContent : /* @__PURE__ */ React2__default.createElement(DefaultEmptyContent, null)
|
|
719
|
+
))))), showPagination && pagination.total > pagination.limit && /* @__PURE__ */ React2__default.createElement("div", { className: "flex justify-center" }, /* @__PURE__ */ React2__default.createElement(
|
|
559
720
|
Pagination,
|
|
560
721
|
__spreadValues({
|
|
561
722
|
className: "mt-2",
|
|
@@ -571,8 +732,8 @@ function CardUI({
|
|
|
571
732
|
pagination.setData({
|
|
572
733
|
page: currentPage
|
|
573
734
|
});
|
|
574
|
-
if (autoScrollToTop &&
|
|
575
|
-
scrollIntoTop(
|
|
735
|
+
if (autoScrollToTop && tableBoxRef.current) {
|
|
736
|
+
scrollIntoTop(tableBoxRef.current);
|
|
576
737
|
}
|
|
577
738
|
}
|
|
578
739
|
}, nextuiPaginationProps)
|
|
@@ -643,8 +804,8 @@ function CollapseBodyRow({
|
|
|
643
804
|
}
|
|
644
805
|
return /* @__PURE__ */ React2__default.createElement("td", { key: column.key, className: cn("py-2 px-3 text-xs", classNames == null ? void 0 : classNames.td) }, column.render ? column.render(item) : renderFieldValue(item[column.key]));
|
|
645
806
|
})
|
|
646
|
-
), /* @__PURE__ */ React2__default.createElement("tr", { className: cn(classNames == null ? void 0 : classNames.tr, isOpen ? "table-row" : "hidden") }, /* @__PURE__ */ React2__default.createElement("td", { colSpan: columns.length
|
|
647
|
-
var _a, _b, _c, _d, _e;
|
|
807
|
+
), /* @__PURE__ */ React2__default.createElement("tr", { className: cn(classNames == null ? void 0 : classNames.tr, isOpen ? "table-row" : "hidden") }, /* @__PURE__ */ React2__default.createElement("td", { colSpan: columns.length, className: cn("py-2 px-3 text-xs", classNames == null ? void 0 : classNames.td) }, collapsedTables.map((ex) => {
|
|
808
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
648
809
|
const exColumns = ex.columns;
|
|
649
810
|
const exData = item[ex.key] || [];
|
|
650
811
|
return /* @__PURE__ */ React2__default.createElement("table", { className: cn("w-full h-auto table-auto", (_a = collapsedTableConfig == null ? void 0 : collapsedTableConfig.classNames) == null ? void 0 : _a.table), key: ex.key }, /* @__PURE__ */ React2__default.createElement("thead", { className: (_b = collapsedTableConfig == null ? void 0 : collapsedTableConfig.classNames) == null ? void 0 : _b.thead }, /* @__PURE__ */ React2__default.createElement("tr", { className: (_c = collapsedTableConfig == null ? void 0 : collapsedTableConfig.classNames) == null ? void 0 : _c.tr }, exColumns == null ? void 0 : exColumns.map((exC) => {
|
|
@@ -691,17 +852,17 @@ function CollapseBodyRow({
|
|
|
691
852
|
);
|
|
692
853
|
})
|
|
693
854
|
);
|
|
694
|
-
})) : /* @__PURE__ */ React2__default.createElement("tbody", { className: classNames.tbody }, /* @__PURE__ */ React2__default.createElement("tr", { className: classNames.tr }, /* @__PURE__ */ React2__default.createElement(
|
|
855
|
+
})) : /* @__PURE__ */ React2__default.createElement("tbody", { className: (_e = collapsedTableConfig == null ? void 0 : collapsedTableConfig.classNames) == null ? void 0 : _e.tbody }, /* @__PURE__ */ React2__default.createElement("tr", { className: (_f = collapsedTableConfig == null ? void 0 : collapsedTableConfig.classNames) == null ? void 0 : _f.tr }, /* @__PURE__ */ React2__default.createElement(
|
|
695
856
|
"td",
|
|
696
857
|
{
|
|
697
|
-
className: classNames.td,
|
|
858
|
+
className: (_g = collapsedTableConfig == null ? void 0 : collapsedTableConfig.classNames) == null ? void 0 : _g.td,
|
|
698
859
|
colSpan: columns.length
|
|
699
860
|
},
|
|
700
|
-
(
|
|
861
|
+
(_h = collapsedTableConfig == null ? void 0 : collapsedTableConfig.emptyContent) != null ? _h : /* @__PURE__ */ React2__default.createElement(DefaultEmptyContent, null)
|
|
701
862
|
))));
|
|
702
863
|
}))));
|
|
703
864
|
}
|
|
704
865
|
|
|
705
866
|
export { JSONTable };
|
|
706
867
|
//# sourceMappingURL=out.js.map
|
|
707
|
-
//# sourceMappingURL=chunk-
|
|
868
|
+
//# sourceMappingURL=chunk-2UD4IDBE.mjs.map
|