infinity-ui-elements 1.7.11 → 1.7.13
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/components/Dropdown/Dropdown.d.ts +8 -0
- package/dist/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/components/Dropdown/Dropdown.stories.d.ts +7 -0
- package/dist/components/Dropdown/Dropdown.stories.d.ts.map +1 -1
- package/dist/components/Dropdown/DropdownMenu.d.ts +8 -0
- package/dist/components/Dropdown/DropdownMenu.d.ts.map +1 -1
- package/dist/components/Table/Table.d.ts +1 -5
- package/dist/components/Table/Table.d.ts.map +1 -1
- package/dist/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/components/Table/TableBody.d.ts +2 -5
- package/dist/components/Table/TableBody.d.ts.map +1 -1
- package/dist/components/Table/TableHeader.d.ts +1 -3
- package/dist/components/Table/TableHeader.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.js +39 -99
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +39 -99
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1454,11 +1454,14 @@ const Link = React__namespace.forwardRef(({ className, type = "anchor", color =
|
|
|
1454
1454
|
});
|
|
1455
1455
|
Link.displayName = "Link";
|
|
1456
1456
|
|
|
1457
|
-
const DropdownMenu = React__namespace.forwardRef(({ items = [], sectionHeading, isLoading = false, isEmpty = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText = "Primary", secondaryButtonText = "Secondary", onPrimaryClick, onSecondaryClick, showChevron = false, emptyIcon, disableFooter = false, footerLayout = "horizontal", onClose, focusedIndex = -1, className, width = "auto", }, ref) => {
|
|
1457
|
+
const DropdownMenu = React__namespace.forwardRef(({ items = [], customContent, sectionHeading, isLoading = false, isEmpty = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText = "Primary", secondaryButtonText = "Secondary", onPrimaryClick, onSecondaryClick, showChevron = false, emptyIcon, disableFooter = false, showFooter, footerLayout = "horizontal", onClose, focusedIndex = -1, className, width = "auto", }, ref) => {
|
|
1458
1458
|
const renderContent = () => {
|
|
1459
1459
|
if (isLoading) {
|
|
1460
1460
|
return (jsxRuntime.jsx("div", { className: "flex flex-col items-center justify-center py-12 px-6", children: jsxRuntime.jsx(lucideReact.Loader2, { className: "w-12 h-12 text-action-ink-primary-normal mb-4 animate-spin" }) }));
|
|
1461
1461
|
}
|
|
1462
|
+
if (customContent) {
|
|
1463
|
+
return (jsxRuntime.jsxs("div", { className: "py-3 px-3 max-h-[400px] overflow-y-auto", children: [sectionHeading && (jsxRuntime.jsx(Text, { as: "div", variant: "body", size: "small", weight: "medium", className: "text-body-small-medium text-surface-ink-neutral-muted px-3 py-2 mb-1", children: sectionHeading })), jsxRuntime.jsx("div", { className: "px-1", children: customContent })] }));
|
|
1464
|
+
}
|
|
1462
1465
|
if (isEmpty || items.length === 0) {
|
|
1463
1466
|
return (jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center py-8 px-6 text-center", children: [emptyIcon || (jsxRuntime.jsx(lucideReact.Search, { className: "w-12 h-12 text-surface-ink-neutral-muted mb-4" })), jsxRuntime.jsx(Text, { as: "h3", variant: "body", size: "small", weight: "semibold", className: "text-surface-ink-neutral-normal mb-2", children: emptyTitle }), jsxRuntime.jsx(Text, { as: "p", variant: "body", size: "small", weight: "regular", className: "text-surface-ink-neutral-muted mb-3", children: emptyDescription }), emptyLinkText && (jsxRuntime.jsx(Link, { type: "anchor", color: "primary", size: "small", onClick: onEmptyLinkClick, children: emptyLinkText }))] }));
|
|
1464
1467
|
}
|
|
@@ -1468,10 +1471,11 @@ const DropdownMenu = React__namespace.forwardRef(({ items = [], sectionHeading,
|
|
|
1468
1471
|
}, containerClassName: cn(index === focusedIndex && "bg-action-fill-primary-faded") }, item.id))) })] }));
|
|
1469
1472
|
};
|
|
1470
1473
|
const widthClass = width === "full" ? "w-full" : width === "auto" ? "w-auto" : "";
|
|
1474
|
+
const footerVisible = showFooter ?? !disableFooter;
|
|
1471
1475
|
return (jsxRuntime.jsxs("div", { ref: ref, className: cn("bg-white rounded-large overflow-hidden", widthClass, className), style: {
|
|
1472
1476
|
boxShadow: "0 1px 2px rgba(25, 25, 30, 0.1), 0 2px 6px rgba(25, 25, 30, 0.06)",
|
|
1473
1477
|
...(width !== "full" && width !== "auto" ? { width } : {}),
|
|
1474
|
-
}, children: [renderContent(),
|
|
1478
|
+
}, children: [renderContent(), footerVisible && (jsxRuntime.jsxs("div", { className: "flex flex-col", children: [jsxRuntime.jsx(Divider, { thickness: "thin", variant: "muted" }), jsxRuntime.jsxs("div", { className: cn("flex gap-3 p-4", footerLayout === "vertical"
|
|
1475
1479
|
? "flex-col"
|
|
1476
1480
|
: "items-center flex-row"), children: [jsxRuntime.jsx(Button, { variant: "secondary", color: "primary", size: "medium", isFullWidth: true, onClick: onSecondaryClick, children: secondaryButtonText }), jsxRuntime.jsx(Button, { variant: "primary", color: "primary", size: "medium", isFullWidth: true, onClick: onPrimaryClick, children: primaryButtonText })] })] }))] }));
|
|
1477
1481
|
});
|
|
@@ -1489,7 +1493,7 @@ const dropdownVariants = classVarianceAuthority.cva("bg-surface-fill-primary-nor
|
|
|
1489
1493
|
size: "medium",
|
|
1490
1494
|
},
|
|
1491
1495
|
});
|
|
1492
|
-
const Dropdown = React__namespace.forwardRef(({ className, trigger, items = [], sectionHeading, isLoading = false, isEmpty = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText = "Primary", secondaryButtonText = "Secondary", onPrimaryClick, onSecondaryClick, size = "medium", open: controlledOpen, defaultOpen = false, onOpenChange, containerClassName, menuClassName, showChevron = false, emptyIcon, disableFooter = false, ...props }, ref) => {
|
|
1496
|
+
const Dropdown = React__namespace.forwardRef(({ className, trigger, items = [], customContent, sectionHeading, isLoading = false, isEmpty = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText = "Primary", secondaryButtonText = "Secondary", onPrimaryClick, onSecondaryClick, size = "medium", open: controlledOpen, defaultOpen = false, onOpenChange, containerClassName, menuClassName, showChevron = false, emptyIcon, disableFooter = false, showFooter, ...props }, ref) => {
|
|
1493
1497
|
const [uncontrolledOpen, setUncontrolledOpen] = React__namespace.useState(defaultOpen);
|
|
1494
1498
|
const isOpen = controlledOpen !== undefined ? controlledOpen : uncontrolledOpen;
|
|
1495
1499
|
const dropdownRef = React__namespace.useRef(null);
|
|
@@ -1536,7 +1540,7 @@ const Dropdown = React__namespace.forwardRef(({ className, trigger, items = [],
|
|
|
1536
1540
|
medium: "w-80",
|
|
1537
1541
|
large: "w-96",
|
|
1538
1542
|
};
|
|
1539
|
-
return (jsxRuntime.jsxs("div", { ref: dropdownRef, className: cn("relative inline-block", containerClassName), ...props, children: [trigger && (jsxRuntime.jsx("div", { onClick: toggleOpen, className: "cursor-pointer", children: trigger })), isOpen && (jsxRuntime.jsx(DropdownMenu, { ref: ref, items: items, sectionHeading: sectionHeading, isLoading: isLoading, isEmpty: isEmpty, emptyTitle: emptyTitle, emptyDescription: emptyDescription, emptyLinkText: emptyLinkText, onEmptyLinkClick: onEmptyLinkClick, primaryButtonText: primaryButtonText, secondaryButtonText: secondaryButtonText, onPrimaryClick: onPrimaryClick, onSecondaryClick: onSecondaryClick, showChevron: showChevron, emptyIcon: emptyIcon, disableFooter: disableFooter, onClose: () => handleOpenChange(false), className: cn("absolute z-50 mt-2", menuClassName, className), width: sizeMap[size] }))] }));
|
|
1543
|
+
return (jsxRuntime.jsxs("div", { ref: dropdownRef, className: cn("relative inline-block", containerClassName), ...props, children: [trigger && (jsxRuntime.jsx("div", { onClick: toggleOpen, className: "cursor-pointer", children: trigger })), isOpen && (jsxRuntime.jsx(DropdownMenu, { ref: ref, items: items, customContent: customContent, sectionHeading: sectionHeading, isLoading: isLoading, isEmpty: isEmpty, emptyTitle: emptyTitle, emptyDescription: emptyDescription, emptyLinkText: emptyLinkText, onEmptyLinkClick: onEmptyLinkClick, primaryButtonText: primaryButtonText, secondaryButtonText: secondaryButtonText, onPrimaryClick: onPrimaryClick, onSecondaryClick: onSecondaryClick, showChevron: showChevron, emptyIcon: emptyIcon, disableFooter: disableFooter, showFooter: showFooter, onClose: () => handleOpenChange(false), className: cn("absolute z-50 mt-2", menuClassName, className), width: sizeMap[size] }))] }));
|
|
1540
1544
|
});
|
|
1541
1545
|
Dropdown.displayName = "Dropdown";
|
|
1542
1546
|
|
|
@@ -2856,7 +2860,7 @@ const tableCellVariants = classVarianceAuthority.cva("text-body-medium-regular b
|
|
|
2856
2860
|
},
|
|
2857
2861
|
});
|
|
2858
2862
|
|
|
2859
|
-
function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHeaderBackground, stickyHeader, size, headerClassName,
|
|
2863
|
+
function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHeaderBackground, stickyHeader, size, headerClassName, onToggleAllRows, isAllRowsSelected, isSomeRowsSelected, getColumnStyle, }) {
|
|
2860
2864
|
const headerHeight = {
|
|
2861
2865
|
small: 32,
|
|
2862
2866
|
medium: 40,
|
|
@@ -2865,20 +2869,18 @@ function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHe
|
|
|
2865
2869
|
return (jsxRuntime.jsx("thead", { className: cn(showHeaderBackground ? "bg-surface-fill-neutral-moderate" : "bg-white", stickyHeader && "sticky top-0 z-10"), children: headerGroups.map((headerGroup, groupIndex) => {
|
|
2866
2870
|
const stickyTop = stickyHeader ? groupIndex * headerHeight : undefined;
|
|
2867
2871
|
return (jsxRuntime.jsxs("tr", { children: [enableRowSelection && enableSelectAll && (jsxRuntime.jsx("th", { className: cn(tableHeaderVariants({ size }), showHeaderBackground && "bg-surface-fill-neutral-moderate", stickyHeader && "sticky z-20", "w-10 rounded-tl-xlarge rounded-bl-xlarge", headerClassName), style: { top: stickyTop }, children: jsxRuntime.jsx(Checkbox, { checked: isAllRowsSelected, isIndeterminate: isSomeRowsSelected, onChange: onToggleAllRows, "aria-label": "Select all rows" }) })), headerGroup.headers.map((header, index) => {
|
|
2868
|
-
const
|
|
2869
|
-
const
|
|
2870
|
-
? index === visibleHeadersCount - 1
|
|
2871
|
-
: index === headerGroup.headers.length - 1;
|
|
2872
|
+
const isFirstColumn = index === 0;
|
|
2873
|
+
const isLastColumn = index === headerGroup.headers.length - 1;
|
|
2872
2874
|
return (jsxRuntime.jsx("th", { className: cn(tableHeaderVariants({ size }), showHeaderBackground &&
|
|
2873
|
-
"bg-surface-fill-neutral-moderate border-none", stickyHeader && "sticky z-20", !enableRowSelection && index === 0 && "rounded-tl-xlarge ",
|
|
2874
|
-
? "opacity-0 translate-x-8 pointer-events-none"
|
|
2875
|
-
: "opacity-100 translate-x-0"), style: {
|
|
2875
|
+
"bg-surface-fill-neutral-moderate border-none", stickyHeader && "sticky z-20", !enableRowSelection && index === 0 && "rounded-tl-xlarge ", isLastColumn && "rounded-tr-xlarge", header.column.columnDef.meta?.headerClassName, headerClassName), style: {
|
|
2876
2876
|
...getColumnStyle(header.column.id, {
|
|
2877
2877
|
width: header.getSize(),
|
|
2878
2878
|
minWidth: header.column.columnDef.minSize,
|
|
2879
2879
|
maxWidth: header.column.columnDef.maxSize,
|
|
2880
2880
|
}),
|
|
2881
2881
|
top: stickyTop,
|
|
2882
|
+
...(isFirstColumn && { paddingLeft: "24px" }),
|
|
2883
|
+
...(isLastColumn && { paddingRight: "24px" }),
|
|
2882
2884
|
}, children: header.isPlaceholder ? null : (jsxRuntime.jsxs("div", { className: cn("flex items-center gap-2", header.column.getCanSort() &&
|
|
2883
2885
|
"cursor-pointer select-none"), onClick: header.column.getToggleSortingHandler(), children: [reactTable.flexRender(header.column.columnDef.header, header.getContext()), header.column.getCanSort() && (jsxRuntime.jsx("span", { className: "text-surface-ink-neutral-muted", children: {
|
|
2884
2886
|
asc: "↑",
|
|
@@ -2888,42 +2890,41 @@ function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHe
|
|
|
2888
2890
|
}) }));
|
|
2889
2891
|
}
|
|
2890
2892
|
|
|
2891
|
-
function TableBody({ rows, enableRowSelection, size, variant, showRowHover, cellClassName,
|
|
2893
|
+
function TableBody({ rows, enableRowSelection, size, variant, showRowHover, cellClassName, onRowClick, getRowClassName, handleRowClick, getColumnStyle, }) {
|
|
2892
2894
|
const [focusedCell, setFocusedCell] = React__namespace.useState(null);
|
|
2893
2895
|
const [hoveredRow, setHoveredRow] = React__namespace.useState(null);
|
|
2894
2896
|
return (jsxRuntime.jsx("tbody", { className: cn("bg-surface-fill-neutral-intense"), children: rows.map((row) => {
|
|
2895
|
-
const isRowSelected = row.id === effectiveSelectedRowId;
|
|
2896
2897
|
const isRowHovered = hoveredRow === row.id;
|
|
2897
|
-
const handleClick = () => handleRowClick(row.original
|
|
2898
|
+
const handleClick = () => handleRowClick(row.original);
|
|
2898
2899
|
return (jsxRuntime.jsxs("tr", { className: cn(variant === "striped" &&
|
|
2899
2900
|
row.index % 2 === 1 &&
|
|
2900
|
-
"bg-surface-fill-neutral-moderate", onRowClick && "cursor-pointer",
|
|
2901
|
+
"bg-surface-fill-neutral-moderate", onRowClick && "cursor-pointer", isRowHovered &&
|
|
2901
2902
|
showRowHover &&
|
|
2902
|
-
"bg-surface-fill-neutral-moderate", getRowClassName(row.original)), onClick: handleClick, onMouseEnter: () => setHoveredRow(row.id), onMouseLeave: () => setHoveredRow(null), children: [enableRowSelection && (jsxRuntime.jsx("td", { className: cn(tableCellVariants({ size }), "w-10", cellClassName),
|
|
2903
|
-
|
|
2903
|
+
"bg-surface-fill-neutral-moderate", getRowClassName(row.original)), onClick: handleClick, onMouseEnter: () => setHoveredRow(row.id), onMouseLeave: () => setHoveredRow(null), children: [enableRowSelection && (jsxRuntime.jsx("td", { className: cn(tableCellVariants({ size }), "w-10", cellClassName), style: {
|
|
2904
|
+
paddingTop: "20px",
|
|
2905
|
+
paddingBottom: "20px",
|
|
2906
|
+
}, children: jsxRuntime.jsx(Checkbox, { checked: row.getIsSelected(), isIndeterminate: row.getIsSomeSelected(), onChange: row.getToggleSelectedHandler(), onClick: (e) => e.stopPropagation(), "aria-label": `Select row ${row.id}` }) })), row.getVisibleCells().map((cell, cellIndex) => {
|
|
2904
2907
|
const isCellFocused = focusedCell?.rowId === row.id &&
|
|
2905
2908
|
focusedCell?.cellId === cell.id;
|
|
2906
2909
|
const cellState = isCellFocused ? "focus" : "default";
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2910
|
+
const visibleCells = row.getVisibleCells();
|
|
2911
|
+
const isFirstCell = cellIndex === 0;
|
|
2912
|
+
const isLastCell = cellIndex === visibleCells.length - 1;
|
|
2913
|
+
return (jsxRuntime.jsx("td", { className: cn(tableCellVariants({ size, state: cellState }), cell.column.columnDef.meta?.cellClassName, cellClassName), style: {
|
|
2914
|
+
...getColumnStyle(cell.column.id, {
|
|
2915
|
+
width: cell.column.getSize(),
|
|
2916
|
+
minWidth: cell.column.columnDef.minSize,
|
|
2917
|
+
maxWidth: cell.column.columnDef.maxSize,
|
|
2918
|
+
}),
|
|
2919
|
+
paddingTop: "20px",
|
|
2920
|
+
paddingBottom: "20px",
|
|
2921
|
+
...(isFirstCell && { paddingLeft: "24px" }),
|
|
2922
|
+
...(isLastCell && { paddingRight: "24px" }),
|
|
2923
|
+
}, tabIndex: 0, onFocus: () => setFocusedCell({ rowId: row.id, cellId: cell.id }), onBlur: () => setFocusedCell(null), children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
2914
2924
|
})] }, row.id));
|
|
2915
2925
|
}) }));
|
|
2916
2926
|
}
|
|
2917
2927
|
|
|
2918
|
-
function DetailPanel({ isOpen, content, data, onClose, }) {
|
|
2919
|
-
return (jsxRuntime.jsx("div", { className: cn("absolute top-0 right-0 h-full z-20 transition-all duration-300 ease-in-out", isOpen
|
|
2920
|
-
? "translate-x-0 opacity-100"
|
|
2921
|
-
: "translate-x-full opacity-0 pointer-events-none"), style: { width: "332px", paddingLeft: "12px" }, children: jsxRuntime.jsx("div", { className: "w-full h-full bg-white border border-surface-outline-neutral-muted rounded-tr-xlarge rounded-br-xlarge overflow-hidden", children: jsxRuntime.jsx("div", { className: "w-full h-full overflow-auto", children: data && (jsxRuntime.jsxs("div", { className: "relative h-full", children: [jsxRuntime.jsx("button", { onClick: (e) => {
|
|
2922
|
-
e.stopPropagation();
|
|
2923
|
-
onClose();
|
|
2924
|
-
}, className: "absolute top-4 right-4 z-10 p-2 rounded-medium hover:bg-surface-fill-neutral-faded transition-colors", "aria-label": "Close detail panel", children: jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", className: "text-surface-ink-neutral-muted", children: jsxRuntime.jsx("path", { d: "M12 4L4 12M4 4l8 8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }), content(data)] })) }) }) }));
|
|
2925
|
-
}
|
|
2926
|
-
|
|
2927
2928
|
function renderDefaultLoadingState({ colSpan }) {
|
|
2928
2929
|
return (jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { colSpan: colSpan, className: "text-center py-12 text-surface-ink-neutral-muted", children: jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-2", children: [jsxRuntime.jsx("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-action-fill-primary-default" }), jsxRuntime.jsx("span", { children: "Loading..." })] }) }) }));
|
|
2929
2930
|
}
|
|
@@ -2932,47 +2933,10 @@ function renderDefaultEmptyState({ colSpan }) {
|
|
|
2932
2933
|
}
|
|
2933
2934
|
|
|
2934
2935
|
// ==================== Component ====================
|
|
2935
|
-
function TableComponent({ className, wrapperClassName, containerClassName, variant, size = "medium", table, enableRowSelection = false, enableSelectAll = false, isLoading = false, loading, loadingComponent, emptyComponent, enableHorizontalScroll = false, stickyHeader = false, maxHeight, showRowHover = true, onRowClick, rowClassName, headerClassName, cellClassName, showHeaderBackground = true,
|
|
2936
|
-
// ==================== State ====================
|
|
2937
|
-
const [internalSelectedRowId, setInternalSelectedRowId] = React__namespace.useState(null);
|
|
2938
|
-
const selectedRowIdRef = React__namespace.useRef(null);
|
|
2939
|
-
const effectiveSelectedRowId = selectedRowId !== undefined ? selectedRowId : internalSelectedRowId;
|
|
2940
|
-
const isDetailPanelOpen = Boolean(effectiveSelectedRowId);
|
|
2941
|
-
// ==================== Effects ====================
|
|
2942
|
-
// Keep ref in sync
|
|
2943
|
-
React__namespace.useEffect(() => {
|
|
2944
|
-
selectedRowIdRef.current = effectiveSelectedRowId;
|
|
2945
|
-
}, [effectiveSelectedRowId]);
|
|
2946
|
-
// Clear selection if selected row is not in current data
|
|
2947
|
-
React__namespace.useEffect(() => {
|
|
2948
|
-
if (effectiveSelectedRowId) {
|
|
2949
|
-
const rowExists = table
|
|
2950
|
-
.getRowModel()
|
|
2951
|
-
.rows.some((r) => r.id === effectiveSelectedRowId);
|
|
2952
|
-
if (!rowExists) {
|
|
2953
|
-
if (selectedRowId === undefined) {
|
|
2954
|
-
setInternalSelectedRowId(null);
|
|
2955
|
-
}
|
|
2956
|
-
if (onRowSelectionChange) {
|
|
2957
|
-
onRowSelectionChange(null);
|
|
2958
|
-
}
|
|
2959
|
-
}
|
|
2960
|
-
}
|
|
2961
|
-
}, [
|
|
2962
|
-
table.getRowModel().rows,
|
|
2963
|
-
effectiveSelectedRowId,
|
|
2964
|
-
selectedRowId,
|
|
2965
|
-
onRowSelectionChange,
|
|
2966
|
-
]);
|
|
2936
|
+
function TableComponent({ className, wrapperClassName, containerClassName, variant, size = "medium", table, enableRowSelection = false, enableSelectAll = false, isLoading = false, loading, loadingComponent, emptyComponent, enableHorizontalScroll = false, stickyHeader = false, maxHeight, showRowHover = true, onRowClick, rowClassName, headerClassName, cellClassName, showHeaderBackground = true, loadingSkeletonRows, loadingSkeletonHeight, columnWidths, columnMinWidths, columnMaxWidths, ...props }, ref) {
|
|
2967
2937
|
// ==================== Computed Values ====================
|
|
2968
2938
|
const hasData = table.getRowModel().rows?.length > 0;
|
|
2969
2939
|
const headerGroups = table.getHeaderGroups();
|
|
2970
|
-
const headers = headerGroups[0]?.headers || [];
|
|
2971
|
-
const visibleHeadersCount = React__namespace.useMemo(() => {
|
|
2972
|
-
return isDetailPanelOpen
|
|
2973
|
-
? headers.length - hideColumnsOnDetailOpen
|
|
2974
|
-
: headers.length;
|
|
2975
|
-
}, [isDetailPanelOpen, headers.length, hideColumnsOnDetailOpen]);
|
|
2976
2940
|
const normalizeSizeValue = (value) => {
|
|
2977
2941
|
if (value === undefined)
|
|
2978
2942
|
return undefined;
|
|
@@ -3039,42 +3003,18 @@ function TableComponent({ className, wrapperClassName, containerClassName, varia
|
|
|
3039
3003
|
}
|
|
3040
3004
|
return rowClassName || "";
|
|
3041
3005
|
}, [rowClassName]);
|
|
3042
|
-
const handleRowClickInternal = React__namespace.useCallback((row
|
|
3043
|
-
const currentSelectedId = selectedRowIdRef.current;
|
|
3044
|
-
const newSelectedId = currentSelectedId === rowId ? null : rowId;
|
|
3045
|
-
if (selectedRowId === undefined) {
|
|
3046
|
-
setInternalSelectedRowId(newSelectedId);
|
|
3047
|
-
}
|
|
3048
|
-
if (onRowSelectionChange) {
|
|
3049
|
-
onRowSelectionChange(newSelectedId);
|
|
3050
|
-
}
|
|
3006
|
+
const handleRowClickInternal = React__namespace.useCallback((row) => {
|
|
3051
3007
|
if (onRowClick) {
|
|
3052
3008
|
onRowClick(row);
|
|
3053
3009
|
}
|
|
3054
|
-
}, [
|
|
3055
|
-
const getSelectedRowData = () => {
|
|
3056
|
-
if (!effectiveSelectedRowId)
|
|
3057
|
-
return null;
|
|
3058
|
-
const row = table
|
|
3059
|
-
.getRowModel()
|
|
3060
|
-
.rows.find((r) => r.id === effectiveSelectedRowId);
|
|
3061
|
-
return row ? row.original : null;
|
|
3062
|
-
};
|
|
3063
|
-
const handleDetailPanelClose = () => {
|
|
3064
|
-
if (selectedRowId === undefined) {
|
|
3065
|
-
setInternalSelectedRowId(null);
|
|
3066
|
-
}
|
|
3067
|
-
if (onRowSelectionChange) {
|
|
3068
|
-
onRowSelectionChange(null);
|
|
3069
|
-
}
|
|
3070
|
-
};
|
|
3010
|
+
}, [onRowClick]);
|
|
3071
3011
|
const renderEmptyState = () => {
|
|
3072
3012
|
if (emptyComponent)
|
|
3073
3013
|
return emptyComponent;
|
|
3074
3014
|
return renderDefaultEmptyState({ colSpan: table.getAllColumns().length });
|
|
3075
3015
|
};
|
|
3076
3016
|
// ==================== Render ====================
|
|
3077
|
-
return (jsxRuntime.jsx("div", { ref: ref, className: cn("w-full", wrapperClassName), ...props, children: jsxRuntime.
|
|
3017
|
+
return (jsxRuntime.jsx("div", { ref: ref, className: cn("w-full", wrapperClassName), ...props, children: jsxRuntime.jsx("div", { className: cn("relative", enableHorizontalScroll ? "overflow-x-auto" : "overflow-x-hidden", maxHeight && "overflow-y-auto", containerClassName), style: containerStyle, children: jsxRuntime.jsxs("table", { className: cn(tableVariants({ variant, size }), className), children: [jsxRuntime.jsx(TableHeader, { headerGroups: headerGroups, enableRowSelection: enableRowSelection, enableSelectAll: enableSelectAll, showHeaderBackground: showHeaderBackground, stickyHeader: stickyHeader, size: size || "medium", headerClassName: headerClassName, onToggleAllRows: (e) => table.getToggleAllRowsSelectedHandler()(e), isAllRowsSelected: table.getIsAllRowsSelected(), isSomeRowsSelected: table.getIsSomeRowsSelected(), getColumnStyle: getColumnStyle }), resolvedLoading ? (jsxRuntime.jsx("tbody", { children: renderLoadingContent() })) : !hasData ? (jsxRuntime.jsx("tbody", { children: renderEmptyState() })) : (jsxRuntime.jsx(TableBody, { rows: table.getRowModel().rows, enableRowSelection: enableRowSelection, size: size || "medium", variant: variant || "default", showRowHover: showRowHover, cellClassName: cellClassName, onRowClick: onRowClick, getRowClassName: getRowClassName, handleRowClick: handleRowClickInternal, getColumnStyle: getColumnStyle }))] }) }) }));
|
|
3078
3018
|
}
|
|
3079
3019
|
// ==================== Export ====================
|
|
3080
3020
|
const Table = React__namespace.forwardRef(TableComponent);
|