@dappworks/kit 0.5.7 → 0.5.9
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 +2 -2
- package/dist/{chunk-2HNXZE3X.mjs → chunk-5RDWJ3BR.mjs} +2 -2
- package/dist/{chunk-NPQ7GCFM.mjs → chunk-6AX24IFY.mjs} +2 -2
- package/dist/{chunk-63DQOYRW.mjs → chunk-DVNRHEKS.mjs} +2 -2
- package/dist/{chunk-QA3E2PJT.mjs → chunk-ELOEHZQA.mjs} +2 -2
- package/dist/chunk-LOTOTF5J.mjs +40247 -0
- package/dist/chunk-LOTOTF5J.mjs.map +1 -0
- package/dist/{chunk-24SBSTZU.mjs → chunk-UNOD2CPN.mjs} +240 -256
- package/dist/chunk-UNOD2CPN.mjs.map +1 -0
- package/dist/chunk-VIK2VI34.mjs +69 -0
- package/dist/dev.mjs +2 -2
- package/dist/experimental.mjs +1 -1
- package/dist/form.mjs +2 -2
- package/dist/index.mjs +4 -4
- package/dist/inspector.mjs +1 -1
- package/dist/jsoncomponent.mjs +1 -1
- package/dist/jsontable.d.mts +12 -5
- package/dist/jsontable.mjs +4 -4
- package/dist/metrics.mjs +4 -4
- package/dist/plugins.mjs +4 -4
- package/dist/ui.mjs +3 -3
- package/dist/utils.mjs +1 -1
- package/dist/wallet.d.mts +6 -1
- package/dist/wallet.mjs +5 -5
- package/dist/wallet.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-24SBSTZU.mjs.map +0 -1
- package/dist/chunk-R4SQKVDQ.mjs +0 -35
- package/dist/chunk-U4TYFTZN.mjs +0 -1106
- package/dist/chunk-U4TYFTZN.mjs.map +0 -1
- /package/dist/{chunk-2HNXZE3X.mjs.map → chunk-5RDWJ3BR.mjs.map} +0 -0
- /package/dist/{chunk-NPQ7GCFM.mjs.map → chunk-6AX24IFY.mjs.map} +0 -0
- /package/dist/{chunk-63DQOYRW.mjs.map → chunk-DVNRHEKS.mjs.map} +0 -0
- /package/dist/{chunk-QA3E2PJT.mjs.map → chunk-ELOEHZQA.mjs.map} +0 -0
- /package/dist/{chunk-R4SQKVDQ.mjs.map → chunk-VIK2VI34.mjs.map} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PaginationState } from './chunk-ONVPCAMQ.mjs';
|
|
2
|
-
import { SkeletonBox } from './chunk-
|
|
2
|
+
import { SkeletonBox } from './chunk-ELOEHZQA.mjs';
|
|
3
3
|
import { _ } from './chunk-K7LFG5BA.mjs';
|
|
4
|
-
import { cn } from './chunk-
|
|
5
|
-
import { __objRest, __spreadValues, __spreadProps } from './chunk-
|
|
4
|
+
import { cn } from './chunk-5RDWJ3BR.mjs';
|
|
5
|
+
import { __objRest, __spreadValues, __spreadProps } from './chunk-VIK2VI34.mjs';
|
|
6
6
|
import * as React2 from 'react';
|
|
7
7
|
import React2__default, { useRef, useEffect, useState, useMemo } from 'react';
|
|
8
|
-
import {
|
|
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';
|
|
@@ -496,83 +496,77 @@ function SortingComponent({
|
|
|
496
496
|
}
|
|
497
497
|
));
|
|
498
498
|
}
|
|
499
|
-
var CardUI = observer(
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
return /* @__PURE__ */ React2__default.createElement(
|
|
525
|
-
Card,
|
|
526
|
-
{
|
|
527
|
-
className: cn("mb-2 w-full shadow-sm p-4 rounded-lg", cardOptions == null ? void 0 : cardOptions.cardClassName),
|
|
528
|
-
isPressable: !!onRowClick,
|
|
529
|
-
onPress: () => {
|
|
530
|
-
onRowClick == null ? void 0 : onRowClick(item);
|
|
531
|
-
}
|
|
532
|
-
},
|
|
533
|
-
columns.map((column, i) => {
|
|
534
|
-
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) }));
|
|
535
|
-
}),
|
|
536
|
-
typeof columnSlot === "function" ? columnSlot({ row: item }) : columnSlot
|
|
537
|
-
);
|
|
538
|
-
};
|
|
539
|
-
const GroupUI = () => {
|
|
540
|
-
const colSpan = (cardOptions == null ? void 0 : cardOptions.colSpan) || 1;
|
|
541
|
-
if (colSpan === 1) {
|
|
542
|
-
return data.map((item, index) => {
|
|
543
|
-
return /* @__PURE__ */ React2__default.createElement(MyCard, { key: rowKey ? item[rowKey] || index : index, item });
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
const groupData = groupByColSpan(data, colSpan);
|
|
547
|
-
return groupData.map((group, gIndex) => {
|
|
548
|
-
return /* @__PURE__ */ React2__default.createElement("div", { className: cn("flex items-center justify-between space-x-1", cardOptions == null ? void 0 : cardOptions.cardGroupClassName), key: gIndex }, group.map((item, index) => {
|
|
549
|
-
return /* @__PURE__ */ React2__default.createElement(MyCard, { key: rowKey ? item[rowKey] || index : index, item });
|
|
550
|
-
}));
|
|
551
|
-
});
|
|
552
|
-
};
|
|
553
|
-
return /* @__PURE__ */ React2__default.createElement("div", { className, ref: cardBoxRef }, sortedData.length > 0 ? /* @__PURE__ */ React2__default.createElement(React2__default.Fragment, null, /* @__PURE__ */ React2__default.createElement(GroupUI, null), showPagination && pagination.total > pagination.limit && /* @__PURE__ */ React2__default.createElement("div", { className: "flex justify-center" }, /* @__PURE__ */ React2__default.createElement(
|
|
554
|
-
Pagination,
|
|
555
|
-
__spreadValues({
|
|
556
|
-
className: "mt-2",
|
|
557
|
-
showControls: true,
|
|
558
|
-
showShadow: true,
|
|
559
|
-
size: "sm",
|
|
560
|
-
radius: "sm",
|
|
561
|
-
color: "primary",
|
|
562
|
-
initialPage: 1,
|
|
563
|
-
total: Math.ceil(pagination.total / pagination.limit),
|
|
564
|
-
page: pagination.page,
|
|
565
|
-
onChange: (currentPage) => {
|
|
499
|
+
var CardUI = observer(
|
|
500
|
+
({
|
|
501
|
+
className,
|
|
502
|
+
sortedData,
|
|
503
|
+
columns,
|
|
504
|
+
rowKey,
|
|
505
|
+
cardOptions,
|
|
506
|
+
onRowClick,
|
|
507
|
+
emptyContent,
|
|
508
|
+
columnSlot,
|
|
509
|
+
isServerPaging,
|
|
510
|
+
showPagination,
|
|
511
|
+
pagination,
|
|
512
|
+
nextuiPaginationProps,
|
|
513
|
+
autoScrollToTop
|
|
514
|
+
}) => {
|
|
515
|
+
const cardBoxRef = useRef(null);
|
|
516
|
+
pagination = pagination ? pagination : useRef(
|
|
517
|
+
new PaginationState({
|
|
518
|
+
page: 1,
|
|
519
|
+
limit: 10
|
|
520
|
+
})
|
|
521
|
+
).current;
|
|
522
|
+
useEffect(() => {
|
|
523
|
+
if (!isServerPaging && pagination) {
|
|
566
524
|
pagination.setData({
|
|
567
|
-
|
|
525
|
+
total: sortedData.length
|
|
568
526
|
});
|
|
569
|
-
if (autoScrollToTop && cardBoxRef.current) {
|
|
570
|
-
scrollIntoTop(cardBoxRef.current);
|
|
571
|
-
}
|
|
572
527
|
}
|
|
573
|
-
},
|
|
574
|
-
|
|
575
|
-
})
|
|
528
|
+
}, [sortedData]);
|
|
529
|
+
const data = isServerPaging || !showPagination ? sortedData : sortedData.slice(pagination.offset, pagination.offset + pagination.limit);
|
|
530
|
+
return /* @__PURE__ */ React2__default.createElement("div", { className, ref: cardBoxRef }, sortedData.length > 0 ? /* @__PURE__ */ React2__default.createElement(React2__default.Fragment, null, /* @__PURE__ */ React2__default.createElement("div", { className: cardOptions == null ? void 0 : cardOptions.cardContainerClassName }, data.map((item, index) => {
|
|
531
|
+
return /* @__PURE__ */ React2__default.createElement(
|
|
532
|
+
Card,
|
|
533
|
+
{
|
|
534
|
+
key: rowKey ? item[rowKey] || index : index,
|
|
535
|
+
className: cn("mb-2 w-full shadow-sm p-4 rounded-lg", cardOptions == null ? void 0 : cardOptions.cardClassName),
|
|
536
|
+
isPressable: !!onRowClick,
|
|
537
|
+
onPress: () => {
|
|
538
|
+
onRowClick == null ? void 0 : onRowClick(item);
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
columns.map((column, i) => {
|
|
542
|
+
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) }));
|
|
543
|
+
}),
|
|
544
|
+
typeof columnSlot === "function" ? columnSlot({ row: item }) : columnSlot
|
|
545
|
+
);
|
|
546
|
+
})), showPagination && pagination.total > pagination.limit && /* @__PURE__ */ React2__default.createElement("div", { className: "flex justify-center" }, /* @__PURE__ */ React2__default.createElement(
|
|
547
|
+
Pagination,
|
|
548
|
+
__spreadValues({
|
|
549
|
+
className: "mt-2",
|
|
550
|
+
showControls: true,
|
|
551
|
+
showShadow: true,
|
|
552
|
+
size: "sm",
|
|
553
|
+
radius: "sm",
|
|
554
|
+
color: "primary",
|
|
555
|
+
initialPage: 1,
|
|
556
|
+
total: Math.ceil(pagination.total / pagination.limit),
|
|
557
|
+
page: pagination.page,
|
|
558
|
+
onChange: (currentPage) => {
|
|
559
|
+
pagination.setData({
|
|
560
|
+
page: currentPage
|
|
561
|
+
});
|
|
562
|
+
if (autoScrollToTop && cardBoxRef.current) {
|
|
563
|
+
scrollIntoTop(cardBoxRef.current);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}, nextuiPaginationProps)
|
|
567
|
+
))) : emptyContent != null ? emptyContent : /* @__PURE__ */ React2__default.createElement(DefaultEmptyContent, null));
|
|
568
|
+
}
|
|
569
|
+
);
|
|
576
570
|
function VirtualizedCardUI({
|
|
577
571
|
className,
|
|
578
572
|
sortedData,
|
|
@@ -587,41 +581,47 @@ function VirtualizedCardUI({
|
|
|
587
581
|
virtualizedOptions,
|
|
588
582
|
columnSlot
|
|
589
583
|
}) {
|
|
590
|
-
|
|
584
|
+
var _a, _b;
|
|
585
|
+
const colSpan = ((_a = virtualizedOptions == null ? void 0 : virtualizedOptions.cardOptions) == null ? void 0 : _a.colSpan) || ((_b = cardOptions == null ? void 0 : cardOptions.virtualizedOptions) == null ? void 0 : _b.colSpan) || 1;
|
|
591
586
|
const fetchedCountRef = useRef(-1);
|
|
592
|
-
const elements = useMemo(
|
|
593
|
-
() => {
|
|
594
|
-
|
|
587
|
+
const elements = useMemo(() => {
|
|
588
|
+
const MyCard = ({ item }) => {
|
|
589
|
+
return /* @__PURE__ */ React2__default.createElement(
|
|
590
|
+
Card,
|
|
591
|
+
{
|
|
592
|
+
className: cn("mb-2 w-full shadow-sm p-4 rounded-lg", cardOptions == null ? void 0 : cardOptions.cardClassName),
|
|
593
|
+
isPressable: !!onRowClick,
|
|
594
|
+
onPress: () => {
|
|
595
|
+
onRowClick == null ? void 0 : onRowClick(item);
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
columns.map((column, i) => {
|
|
599
|
+
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) }));
|
|
600
|
+
}),
|
|
601
|
+
typeof columnSlot === "function" ? columnSlot({ row: item }) : columnSlot
|
|
602
|
+
);
|
|
603
|
+
};
|
|
604
|
+
if (colSpan === 1) {
|
|
605
|
+
return sortedData.map((item, index) => {
|
|
606
|
+
return /* @__PURE__ */ React2__default.createElement(MyCard, { key: rowKey ? item[rowKey] || index : index, item });
|
|
607
|
+
});
|
|
608
|
+
} else {
|
|
609
|
+
const groupData = groupByColSpan(sortedData, colSpan);
|
|
610
|
+
return groupData.map((group, gIndex) => {
|
|
611
|
+
var _a2, _b2;
|
|
595
612
|
return /* @__PURE__ */ React2__default.createElement(
|
|
596
|
-
|
|
613
|
+
"div",
|
|
597
614
|
{
|
|
598
|
-
className: cn("
|
|
599
|
-
|
|
600
|
-
onPress: () => {
|
|
601
|
-
onRowClick == null ? void 0 : onRowClick(item);
|
|
602
|
-
}
|
|
615
|
+
className: cn("flex items-center justify-between space-x-1", ((_a2 = virtualizedOptions == null ? void 0 : virtualizedOptions.cardOptions) == null ? void 0 : _a2.cardContainerClassName) || ((_b2 = cardOptions == null ? void 0 : cardOptions.virtualizedOptions) == null ? void 0 : _b2.cardContainerClassName)),
|
|
616
|
+
key: gIndex
|
|
603
617
|
},
|
|
604
|
-
|
|
605
|
-
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) }));
|
|
606
|
-
}),
|
|
607
|
-
typeof columnSlot === "function" ? columnSlot({ row: item }) : columnSlot
|
|
608
|
-
);
|
|
609
|
-
};
|
|
610
|
-
if (colSpan === 1) {
|
|
611
|
-
return sortedData.map((item, index) => {
|
|
612
|
-
return /* @__PURE__ */ React2__default.createElement(MyCard, { key: rowKey ? item[rowKey] || index : index, item });
|
|
613
|
-
});
|
|
614
|
-
} else {
|
|
615
|
-
const groupData = groupByColSpan(sortedData, colSpan);
|
|
616
|
-
return groupData.map((group, gIndex) => {
|
|
617
|
-
return /* @__PURE__ */ React2__default.createElement("div", { className: cn("flex items-center justify-between space-x-1", cardOptions == null ? void 0 : cardOptions.cardGroupClassName), key: gIndex }, group.map((item, index) => {
|
|
618
|
+
group.map((item, index) => {
|
|
618
619
|
return /* @__PURE__ */ React2__default.createElement(MyCard, { key: rowKey ? item[rowKey] || index : index, item });
|
|
619
|
-
})
|
|
620
|
-
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
);
|
|
620
|
+
})
|
|
621
|
+
);
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
}, [sortedData]);
|
|
625
625
|
return /* @__PURE__ */ React2__default.createElement("div", { className }, sortedData.length > 0 ? /* @__PURE__ */ React2__default.createElement(
|
|
626
626
|
VList,
|
|
627
627
|
{
|
|
@@ -742,150 +742,141 @@ function VirtualizedListUI({
|
|
|
742
742
|
isLoading ? loadingContent || DefaultLoading({ loadingOptions }) : null
|
|
743
743
|
) : emptyContent != null ? emptyContent : /* @__PURE__ */ React2__default.createElement(DefaultEmptyContent, null)));
|
|
744
744
|
}
|
|
745
|
-
var TableUI = observer(
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
"th",
|
|
788
|
-
{
|
|
789
|
-
key: item.key,
|
|
790
|
-
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),
|
|
791
|
-
style: {
|
|
792
|
-
minWidth: item.width
|
|
793
|
-
}
|
|
794
|
-
},
|
|
795
|
-
/* @__PURE__ */ React2__default.createElement("div", { className: "flex items-center" }, /* @__PURE__ */ React2__default.createElement("span", null, item.label), !!sortableColumnsMap[item.key] && /* @__PURE__ */ React2__default.createElement(
|
|
796
|
-
SortingComponent,
|
|
797
|
-
{
|
|
798
|
-
sortingUIOptions,
|
|
799
|
-
columnOptions,
|
|
800
|
-
sortableColumnsMap,
|
|
801
|
-
item,
|
|
802
|
-
onSort: ({ type, key, sortKey }) => {
|
|
803
|
-
const { sortableColumns, sortedData: sortedData2 } = sortData({
|
|
804
|
-
type,
|
|
805
|
-
key,
|
|
806
|
-
sortKey,
|
|
807
|
-
sortableColumnsMap,
|
|
808
|
-
dataSource
|
|
809
|
-
});
|
|
810
|
-
setSortableColumnsMap(sortableColumns);
|
|
811
|
-
setSortedData(sortedData2);
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
))
|
|
815
|
-
))), /* @__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(
|
|
816
|
-
"td",
|
|
817
|
-
{
|
|
818
|
-
className: classNames.td,
|
|
819
|
-
colSpan: columns.length
|
|
820
|
-
},
|
|
821
|
-
loadingContent || DefaultLoading({ loadingOptions })
|
|
822
|
-
))) : data.length > 0 ? /* @__PURE__ */ React2__default.createElement("tbody", { className: classNames.tbody }, showCollapsedTables ? data.map((item) => {
|
|
823
|
-
return /* @__PURE__ */ React2__default.createElement(
|
|
824
|
-
CollapseBodyRow,
|
|
825
|
-
{
|
|
826
|
-
classNames,
|
|
827
|
-
item,
|
|
828
|
-
columns,
|
|
829
|
-
rowCss,
|
|
830
|
-
onRowClick,
|
|
831
|
-
collapsedTableConfig,
|
|
832
|
-
collapsedTables
|
|
745
|
+
var TableUI = observer(
|
|
746
|
+
({
|
|
747
|
+
className,
|
|
748
|
+
classNames = {},
|
|
749
|
+
isHeaderSticky,
|
|
750
|
+
sortedData,
|
|
751
|
+
dataSource,
|
|
752
|
+
columns,
|
|
753
|
+
columnOptions,
|
|
754
|
+
sortableColumnsMap,
|
|
755
|
+
sortingUIOptions,
|
|
756
|
+
setSortableColumnsMap,
|
|
757
|
+
setSortedData,
|
|
758
|
+
isLoading,
|
|
759
|
+
loadingContent,
|
|
760
|
+
loadingOptions,
|
|
761
|
+
emptyContent,
|
|
762
|
+
rowCss,
|
|
763
|
+
onRowClick,
|
|
764
|
+
showCollapsedTables,
|
|
765
|
+
collapsedTableConfig,
|
|
766
|
+
collapsedTables,
|
|
767
|
+
rowKey,
|
|
768
|
+
isServerPaging,
|
|
769
|
+
showPagination,
|
|
770
|
+
pagination,
|
|
771
|
+
nextuiPaginationProps = {},
|
|
772
|
+
autoScrollToTop,
|
|
773
|
+
columnSlot
|
|
774
|
+
}) => {
|
|
775
|
+
const tableBoxRef = useRef(null);
|
|
776
|
+
pagination = pagination ? pagination : useRef(
|
|
777
|
+
new PaginationState({
|
|
778
|
+
page: 1,
|
|
779
|
+
limit: 10
|
|
780
|
+
})
|
|
781
|
+
).current;
|
|
782
|
+
useEffect(() => {
|
|
783
|
+
if (!isServerPaging) {
|
|
784
|
+
pagination.setData({
|
|
785
|
+
total: dataSource.length
|
|
786
|
+
});
|
|
833
787
|
}
|
|
834
|
-
);
|
|
835
|
-
|
|
836
|
-
return /* @__PURE__ */ React2__default.createElement(React2__default.Fragment, null, /* @__PURE__ */ React2__default.createElement(
|
|
837
|
-
"
|
|
788
|
+
}, [dataSource]);
|
|
789
|
+
const data = isServerPaging || !showPagination ? sortedData : sortedData.slice(pagination.offset, pagination.offset + pagination.limit);
|
|
790
|
+
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(
|
|
791
|
+
"th",
|
|
838
792
|
{
|
|
839
|
-
key:
|
|
840
|
-
className: cn(
|
|
841
|
-
|
|
842
|
-
|
|
793
|
+
key: item.key,
|
|
794
|
+
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),
|
|
795
|
+
style: {
|
|
796
|
+
minWidth: item.width
|
|
843
797
|
}
|
|
844
798
|
},
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
colSpan: columns.length
|
|
864
|
-
},
|
|
865
|
-
emptyContent != null ? emptyContent : /* @__PURE__ */ React2__default.createElement(DefaultEmptyContent, null)
|
|
866
|
-
))))), showPagination && pagination.total > pagination.limit && /* @__PURE__ */ React2__default.createElement("div", { className: "flex justify-center" }, /* @__PURE__ */ React2__default.createElement(
|
|
867
|
-
Pagination,
|
|
868
|
-
__spreadValues({
|
|
869
|
-
className: "mt-2",
|
|
870
|
-
showControls: true,
|
|
871
|
-
showShadow: true,
|
|
872
|
-
size: "sm",
|
|
873
|
-
radius: "sm",
|
|
874
|
-
color: "primary",
|
|
875
|
-
initialPage: 1,
|
|
876
|
-
total: Math.ceil(pagination.total / pagination.limit),
|
|
877
|
-
page: pagination.page,
|
|
878
|
-
onChange: (currentPage) => {
|
|
879
|
-
pagination.setData({
|
|
880
|
-
page: currentPage
|
|
881
|
-
});
|
|
882
|
-
if (autoScrollToTop && tableBoxRef.current) {
|
|
883
|
-
scrollIntoTop(tableBoxRef.current);
|
|
799
|
+
/* @__PURE__ */ React2__default.createElement("div", { className: "flex items-center" }, /* @__PURE__ */ React2__default.createElement("span", null, item.label), !!sortableColumnsMap[item.key] && /* @__PURE__ */ React2__default.createElement(
|
|
800
|
+
SortingComponent,
|
|
801
|
+
{
|
|
802
|
+
sortingUIOptions,
|
|
803
|
+
columnOptions,
|
|
804
|
+
sortableColumnsMap,
|
|
805
|
+
item,
|
|
806
|
+
onSort: ({ type, key, sortKey }) => {
|
|
807
|
+
const { sortableColumns, sortedData: sortedData2 } = sortData({
|
|
808
|
+
type,
|
|
809
|
+
key,
|
|
810
|
+
sortKey,
|
|
811
|
+
sortableColumnsMap,
|
|
812
|
+
dataSource
|
|
813
|
+
});
|
|
814
|
+
setSortableColumnsMap(sortableColumns);
|
|
815
|
+
setSortedData(sortedData2);
|
|
816
|
+
}
|
|
884
817
|
}
|
|
885
|
-
|
|
886
|
-
},
|
|
887
|
-
|
|
888
|
-
|
|
818
|
+
))
|
|
819
|
+
))), /* @__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("td", { className: classNames.td, colSpan: columns.length }, loadingContent || DefaultLoading({ loadingOptions })))) : data.length > 0 ? /* @__PURE__ */ React2__default.createElement("tbody", { className: classNames.tbody }, showCollapsedTables ? data.map((item) => {
|
|
820
|
+
return /* @__PURE__ */ React2__default.createElement(
|
|
821
|
+
CollapseBodyRow,
|
|
822
|
+
{
|
|
823
|
+
classNames,
|
|
824
|
+
item,
|
|
825
|
+
columns,
|
|
826
|
+
rowCss,
|
|
827
|
+
onRowClick,
|
|
828
|
+
collapsedTableConfig,
|
|
829
|
+
collapsedTables
|
|
830
|
+
}
|
|
831
|
+
);
|
|
832
|
+
}) : data.map((item, index) => {
|
|
833
|
+
return /* @__PURE__ */ React2__default.createElement(React2__default.Fragment, null, /* @__PURE__ */ React2__default.createElement(
|
|
834
|
+
"tr",
|
|
835
|
+
{
|
|
836
|
+
key: rowKey ? item[rowKey] || index : index,
|
|
837
|
+
className: cn(classNames.tr, typeof rowCss === "function" ? rowCss(item) : rowCss),
|
|
838
|
+
onClick: () => {
|
|
839
|
+
onRowClick == null ? void 0 : onRowClick(item);
|
|
840
|
+
}
|
|
841
|
+
},
|
|
842
|
+
columns.map((column) => {
|
|
843
|
+
return /* @__PURE__ */ React2__default.createElement(
|
|
844
|
+
"td",
|
|
845
|
+
{
|
|
846
|
+
key: column.key,
|
|
847
|
+
className: cn("py-2 px-3 text-xs", classNames.td),
|
|
848
|
+
style: {
|
|
849
|
+
minWidth: column.width
|
|
850
|
+
}
|
|
851
|
+
},
|
|
852
|
+
column.render ? column.render(item) : renderFieldValue(item[column.key])
|
|
853
|
+
);
|
|
854
|
+
})
|
|
855
|
+
), columnSlot && /* @__PURE__ */ React2__default.createElement("tr", null, /* @__PURE__ */ React2__default.createElement("td", { colSpan: columns.length }, typeof columnSlot === "function" ? columnSlot({ row: item }) : columnSlot)));
|
|
856
|
+
})) : /* @__PURE__ */ React2__default.createElement("tbody", { className: classNames.tbody }, /* @__PURE__ */ React2__default.createElement("tr", { className: classNames.tr }, /* @__PURE__ */ React2__default.createElement("td", { className: classNames.td, colSpan: columns.length }, emptyContent != null ? emptyContent : /* @__PURE__ */ React2__default.createElement(DefaultEmptyContent, null)))))), showPagination && pagination.total > pagination.limit && /* @__PURE__ */ React2__default.createElement("div", { className: "flex justify-center" }, /* @__PURE__ */ React2__default.createElement(
|
|
857
|
+
Pagination,
|
|
858
|
+
__spreadValues({
|
|
859
|
+
className: "mt-2",
|
|
860
|
+
showControls: true,
|
|
861
|
+
showShadow: true,
|
|
862
|
+
size: "sm",
|
|
863
|
+
radius: "sm",
|
|
864
|
+
color: "primary",
|
|
865
|
+
initialPage: 1,
|
|
866
|
+
total: Math.ceil(pagination.total / pagination.limit),
|
|
867
|
+
page: pagination.page,
|
|
868
|
+
onChange: (currentPage) => {
|
|
869
|
+
pagination.setData({
|
|
870
|
+
page: currentPage
|
|
871
|
+
});
|
|
872
|
+
if (autoScrollToTop && tableBoxRef.current) {
|
|
873
|
+
scrollIntoTop(tableBoxRef.current);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}, nextuiPaginationProps)
|
|
877
|
+
)));
|
|
878
|
+
}
|
|
879
|
+
);
|
|
889
880
|
function DefaultLoading({ loadingOptions }) {
|
|
890
881
|
const type = (loadingOptions == null ? void 0 : loadingOptions.type) || "skeleton";
|
|
891
882
|
const skeletonOptions = loadingOptions == null ? void 0 : loadingOptions.skeleton;
|
|
@@ -1024,14 +1015,7 @@ function CollapseBodyRow({
|
|
|
1024
1015
|
);
|
|
1025
1016
|
})
|
|
1026
1017
|
);
|
|
1027
|
-
})) : /* @__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(
|
|
1028
|
-
"td",
|
|
1029
|
-
{
|
|
1030
|
-
className: (_g = collapsedTableConfig == null ? void 0 : collapsedTableConfig.classNames) == null ? void 0 : _g.td,
|
|
1031
|
-
colSpan: columns.length
|
|
1032
|
-
},
|
|
1033
|
-
(_h = collapsedTableConfig == null ? void 0 : collapsedTableConfig.emptyContent) != null ? _h : /* @__PURE__ */ React2__default.createElement(DefaultEmptyContent, null)
|
|
1034
|
-
))));
|
|
1018
|
+
})) : /* @__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("td", { className: (_g = collapsedTableConfig == null ? void 0 : collapsedTableConfig.classNames) == null ? void 0 : _g.td, colSpan: columns.length }, (_h = collapsedTableConfig == null ? void 0 : collapsedTableConfig.emptyContent) != null ? _h : /* @__PURE__ */ React2__default.createElement(DefaultEmptyContent, null)))));
|
|
1035
1019
|
}))));
|
|
1036
1020
|
}
|
|
1037
1021
|
function groupByColSpan(arr, colSpan) {
|
|
@@ -1044,4 +1028,4 @@ function groupByColSpan(arr, colSpan) {
|
|
|
1044
1028
|
|
|
1045
1029
|
export { JSONTable };
|
|
1046
1030
|
//# sourceMappingURL=out.js.map
|
|
1047
|
-
//# sourceMappingURL=chunk-
|
|
1031
|
+
//# sourceMappingURL=chunk-UNOD2CPN.mjs.map
|