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.esm.js
CHANGED
|
@@ -1433,11 +1433,14 @@ const Link = React.forwardRef(({ className, type = "anchor", color = "primary",
|
|
|
1433
1433
|
});
|
|
1434
1434
|
Link.displayName = "Link";
|
|
1435
1435
|
|
|
1436
|
-
const DropdownMenu = React.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) => {
|
|
1436
|
+
const DropdownMenu = React.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) => {
|
|
1437
1437
|
const renderContent = () => {
|
|
1438
1438
|
if (isLoading) {
|
|
1439
1439
|
return (jsx("div", { className: "flex flex-col items-center justify-center py-12 px-6", children: jsx(Loader2, { className: "w-12 h-12 text-action-ink-primary-normal mb-4 animate-spin" }) }));
|
|
1440
1440
|
}
|
|
1441
|
+
if (customContent) {
|
|
1442
|
+
return (jsxs("div", { className: "py-3 px-3 max-h-[400px] overflow-y-auto", children: [sectionHeading && (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 })), jsx("div", { className: "px-1", children: customContent })] }));
|
|
1443
|
+
}
|
|
1441
1444
|
if (isEmpty || items.length === 0) {
|
|
1442
1445
|
return (jsxs("div", { className: "flex flex-col items-center justify-center py-8 px-6 text-center", children: [emptyIcon || (jsx(Search, { className: "w-12 h-12 text-surface-ink-neutral-muted mb-4" })), jsx(Text, { as: "h3", variant: "body", size: "small", weight: "semibold", className: "text-surface-ink-neutral-normal mb-2", children: emptyTitle }), jsx(Text, { as: "p", variant: "body", size: "small", weight: "regular", className: "text-surface-ink-neutral-muted mb-3", children: emptyDescription }), emptyLinkText && (jsx(Link, { type: "anchor", color: "primary", size: "small", onClick: onEmptyLinkClick, children: emptyLinkText }))] }));
|
|
1443
1446
|
}
|
|
@@ -1447,10 +1450,11 @@ const DropdownMenu = React.forwardRef(({ items = [], sectionHeading, isLoading =
|
|
|
1447
1450
|
}, containerClassName: cn(index === focusedIndex && "bg-action-fill-primary-faded") }, item.id))) })] }));
|
|
1448
1451
|
};
|
|
1449
1452
|
const widthClass = width === "full" ? "w-full" : width === "auto" ? "w-auto" : "";
|
|
1453
|
+
const footerVisible = showFooter ?? !disableFooter;
|
|
1450
1454
|
return (jsxs("div", { ref: ref, className: cn("bg-white rounded-large overflow-hidden", widthClass, className), style: {
|
|
1451
1455
|
boxShadow: "0 1px 2px rgba(25, 25, 30, 0.1), 0 2px 6px rgba(25, 25, 30, 0.06)",
|
|
1452
1456
|
...(width !== "full" && width !== "auto" ? { width } : {}),
|
|
1453
|
-
}, children: [renderContent(),
|
|
1457
|
+
}, children: [renderContent(), footerVisible && (jsxs("div", { className: "flex flex-col", children: [jsx(Divider, { thickness: "thin", variant: "muted" }), jsxs("div", { className: cn("flex gap-3 p-4", footerLayout === "vertical"
|
|
1454
1458
|
? "flex-col"
|
|
1455
1459
|
: "items-center flex-row"), children: [jsx(Button, { variant: "secondary", color: "primary", size: "medium", isFullWidth: true, onClick: onSecondaryClick, children: secondaryButtonText }), jsx(Button, { variant: "primary", color: "primary", size: "medium", isFullWidth: true, onClick: onPrimaryClick, children: primaryButtonText })] })] }))] }));
|
|
1456
1460
|
});
|
|
@@ -1468,7 +1472,7 @@ const dropdownVariants = cva("bg-surface-fill-primary-normal border border-surfa
|
|
|
1468
1472
|
size: "medium",
|
|
1469
1473
|
},
|
|
1470
1474
|
});
|
|
1471
|
-
const Dropdown = React.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) => {
|
|
1475
|
+
const Dropdown = React.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) => {
|
|
1472
1476
|
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
|
|
1473
1477
|
const isOpen = controlledOpen !== undefined ? controlledOpen : uncontrolledOpen;
|
|
1474
1478
|
const dropdownRef = React.useRef(null);
|
|
@@ -1515,7 +1519,7 @@ const Dropdown = React.forwardRef(({ className, trigger, items = [], sectionHead
|
|
|
1515
1519
|
medium: "w-80",
|
|
1516
1520
|
large: "w-96",
|
|
1517
1521
|
};
|
|
1518
|
-
return (jsxs("div", { ref: dropdownRef, className: cn("relative inline-block", containerClassName), ...props, children: [trigger && (jsx("div", { onClick: toggleOpen, className: "cursor-pointer", children: trigger })), isOpen && (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] }))] }));
|
|
1522
|
+
return (jsxs("div", { ref: dropdownRef, className: cn("relative inline-block", containerClassName), ...props, children: [trigger && (jsx("div", { onClick: toggleOpen, className: "cursor-pointer", children: trigger })), isOpen && (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] }))] }));
|
|
1519
1523
|
});
|
|
1520
1524
|
Dropdown.displayName = "Dropdown";
|
|
1521
1525
|
|
|
@@ -2835,7 +2839,7 @@ const tableCellVariants = cva("text-body-medium-regular border-b border-surface-
|
|
|
2835
2839
|
},
|
|
2836
2840
|
});
|
|
2837
2841
|
|
|
2838
|
-
function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHeaderBackground, stickyHeader, size, headerClassName,
|
|
2842
|
+
function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHeaderBackground, stickyHeader, size, headerClassName, onToggleAllRows, isAllRowsSelected, isSomeRowsSelected, getColumnStyle, }) {
|
|
2839
2843
|
const headerHeight = {
|
|
2840
2844
|
small: 32,
|
|
2841
2845
|
medium: 40,
|
|
@@ -2844,20 +2848,18 @@ function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHe
|
|
|
2844
2848
|
return (jsx("thead", { className: cn(showHeaderBackground ? "bg-surface-fill-neutral-moderate" : "bg-white", stickyHeader && "sticky top-0 z-10"), children: headerGroups.map((headerGroup, groupIndex) => {
|
|
2845
2849
|
const stickyTop = stickyHeader ? groupIndex * headerHeight : undefined;
|
|
2846
2850
|
return (jsxs("tr", { children: [enableRowSelection && enableSelectAll && (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: jsx(Checkbox, { checked: isAllRowsSelected, isIndeterminate: isSomeRowsSelected, onChange: onToggleAllRows, "aria-label": "Select all rows" }) })), headerGroup.headers.map((header, index) => {
|
|
2847
|
-
const
|
|
2848
|
-
const
|
|
2849
|
-
? index === visibleHeadersCount - 1
|
|
2850
|
-
: index === headerGroup.headers.length - 1;
|
|
2851
|
+
const isFirstColumn = index === 0;
|
|
2852
|
+
const isLastColumn = index === headerGroup.headers.length - 1;
|
|
2851
2853
|
return (jsx("th", { className: cn(tableHeaderVariants({ size }), showHeaderBackground &&
|
|
2852
|
-
"bg-surface-fill-neutral-moderate border-none", stickyHeader && "sticky z-20", !enableRowSelection && index === 0 && "rounded-tl-xlarge ",
|
|
2853
|
-
? "opacity-0 translate-x-8 pointer-events-none"
|
|
2854
|
-
: "opacity-100 translate-x-0"), style: {
|
|
2854
|
+
"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: {
|
|
2855
2855
|
...getColumnStyle(header.column.id, {
|
|
2856
2856
|
width: header.getSize(),
|
|
2857
2857
|
minWidth: header.column.columnDef.minSize,
|
|
2858
2858
|
maxWidth: header.column.columnDef.maxSize,
|
|
2859
2859
|
}),
|
|
2860
2860
|
top: stickyTop,
|
|
2861
|
+
...(isFirstColumn && { paddingLeft: "24px" }),
|
|
2862
|
+
...(isLastColumn && { paddingRight: "24px" }),
|
|
2861
2863
|
}, children: header.isPlaceholder ? null : (jsxs("div", { className: cn("flex items-center gap-2", header.column.getCanSort() &&
|
|
2862
2864
|
"cursor-pointer select-none"), onClick: header.column.getToggleSortingHandler(), children: [flexRender(header.column.columnDef.header, header.getContext()), header.column.getCanSort() && (jsx("span", { className: "text-surface-ink-neutral-muted", children: {
|
|
2863
2865
|
asc: "↑",
|
|
@@ -2867,42 +2869,41 @@ function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHe
|
|
|
2867
2869
|
}) }));
|
|
2868
2870
|
}
|
|
2869
2871
|
|
|
2870
|
-
function TableBody({ rows, enableRowSelection, size, variant, showRowHover, cellClassName,
|
|
2872
|
+
function TableBody({ rows, enableRowSelection, size, variant, showRowHover, cellClassName, onRowClick, getRowClassName, handleRowClick, getColumnStyle, }) {
|
|
2871
2873
|
const [focusedCell, setFocusedCell] = React.useState(null);
|
|
2872
2874
|
const [hoveredRow, setHoveredRow] = React.useState(null);
|
|
2873
2875
|
return (jsx("tbody", { className: cn("bg-surface-fill-neutral-intense"), children: rows.map((row) => {
|
|
2874
|
-
const isRowSelected = row.id === effectiveSelectedRowId;
|
|
2875
2876
|
const isRowHovered = hoveredRow === row.id;
|
|
2876
|
-
const handleClick = () => handleRowClick(row.original
|
|
2877
|
+
const handleClick = () => handleRowClick(row.original);
|
|
2877
2878
|
return (jsxs("tr", { className: cn(variant === "striped" &&
|
|
2878
2879
|
row.index % 2 === 1 &&
|
|
2879
|
-
"bg-surface-fill-neutral-moderate", onRowClick && "cursor-pointer",
|
|
2880
|
+
"bg-surface-fill-neutral-moderate", onRowClick && "cursor-pointer", isRowHovered &&
|
|
2880
2881
|
showRowHover &&
|
|
2881
|
-
"bg-surface-fill-neutral-moderate", getRowClassName(row.original)), onClick: handleClick, onMouseEnter: () => setHoveredRow(row.id), onMouseLeave: () => setHoveredRow(null), children: [enableRowSelection && (jsx("td", { className: cn(tableCellVariants({ size }), "w-10", cellClassName),
|
|
2882
|
-
|
|
2882
|
+
"bg-surface-fill-neutral-moderate", getRowClassName(row.original)), onClick: handleClick, onMouseEnter: () => setHoveredRow(row.id), onMouseLeave: () => setHoveredRow(null), children: [enableRowSelection && (jsx("td", { className: cn(tableCellVariants({ size }), "w-10", cellClassName), style: {
|
|
2883
|
+
paddingTop: "20px",
|
|
2884
|
+
paddingBottom: "20px",
|
|
2885
|
+
}, children: 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) => {
|
|
2883
2886
|
const isCellFocused = focusedCell?.rowId === row.id &&
|
|
2884
2887
|
focusedCell?.cellId === cell.id;
|
|
2885
2888
|
const cellState = isCellFocused ? "focus" : "default";
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2889
|
+
const visibleCells = row.getVisibleCells();
|
|
2890
|
+
const isFirstCell = cellIndex === 0;
|
|
2891
|
+
const isLastCell = cellIndex === visibleCells.length - 1;
|
|
2892
|
+
return (jsx("td", { className: cn(tableCellVariants({ size, state: cellState }), cell.column.columnDef.meta?.cellClassName, cellClassName), style: {
|
|
2893
|
+
...getColumnStyle(cell.column.id, {
|
|
2894
|
+
width: cell.column.getSize(),
|
|
2895
|
+
minWidth: cell.column.columnDef.minSize,
|
|
2896
|
+
maxWidth: cell.column.columnDef.maxSize,
|
|
2897
|
+
}),
|
|
2898
|
+
paddingTop: "20px",
|
|
2899
|
+
paddingBottom: "20px",
|
|
2900
|
+
...(isFirstCell && { paddingLeft: "24px" }),
|
|
2901
|
+
...(isLastCell && { paddingRight: "24px" }),
|
|
2902
|
+
}, tabIndex: 0, onFocus: () => setFocusedCell({ rowId: row.id, cellId: cell.id }), onBlur: () => setFocusedCell(null), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
2893
2903
|
})] }, row.id));
|
|
2894
2904
|
}) }));
|
|
2895
2905
|
}
|
|
2896
2906
|
|
|
2897
|
-
function DetailPanel({ isOpen, content, data, onClose, }) {
|
|
2898
|
-
return (jsx("div", { className: cn("absolute top-0 right-0 h-full z-20 transition-all duration-300 ease-in-out", isOpen
|
|
2899
|
-
? "translate-x-0 opacity-100"
|
|
2900
|
-
: "translate-x-full opacity-0 pointer-events-none"), style: { width: "332px", paddingLeft: "12px" }, children: jsx("div", { className: "w-full h-full bg-white border border-surface-outline-neutral-muted rounded-tr-xlarge rounded-br-xlarge overflow-hidden", children: jsx("div", { className: "w-full h-full overflow-auto", children: data && (jsxs("div", { className: "relative h-full", children: [jsx("button", { onClick: (e) => {
|
|
2901
|
-
e.stopPropagation();
|
|
2902
|
-
onClose();
|
|
2903
|
-
}, 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: jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", className: "text-surface-ink-neutral-muted", children: jsx("path", { d: "M12 4L4 12M4 4l8 8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }), content(data)] })) }) }) }));
|
|
2904
|
-
}
|
|
2905
|
-
|
|
2906
2907
|
function renderDefaultLoadingState({ colSpan }) {
|
|
2907
2908
|
return (jsx("tr", { children: jsx("td", { colSpan: colSpan, className: "text-center py-12 text-surface-ink-neutral-muted", children: jsxs("div", { className: "flex items-center justify-center gap-2", children: [jsx("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-action-fill-primary-default" }), jsx("span", { children: "Loading..." })] }) }) }));
|
|
2908
2909
|
}
|
|
@@ -2911,47 +2912,10 @@ function renderDefaultEmptyState({ colSpan }) {
|
|
|
2911
2912
|
}
|
|
2912
2913
|
|
|
2913
2914
|
// ==================== Component ====================
|
|
2914
|
-
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,
|
|
2915
|
-
// ==================== State ====================
|
|
2916
|
-
const [internalSelectedRowId, setInternalSelectedRowId] = React.useState(null);
|
|
2917
|
-
const selectedRowIdRef = React.useRef(null);
|
|
2918
|
-
const effectiveSelectedRowId = selectedRowId !== undefined ? selectedRowId : internalSelectedRowId;
|
|
2919
|
-
const isDetailPanelOpen = Boolean(effectiveSelectedRowId);
|
|
2920
|
-
// ==================== Effects ====================
|
|
2921
|
-
// Keep ref in sync
|
|
2922
|
-
React.useEffect(() => {
|
|
2923
|
-
selectedRowIdRef.current = effectiveSelectedRowId;
|
|
2924
|
-
}, [effectiveSelectedRowId]);
|
|
2925
|
-
// Clear selection if selected row is not in current data
|
|
2926
|
-
React.useEffect(() => {
|
|
2927
|
-
if (effectiveSelectedRowId) {
|
|
2928
|
-
const rowExists = table
|
|
2929
|
-
.getRowModel()
|
|
2930
|
-
.rows.some((r) => r.id === effectiveSelectedRowId);
|
|
2931
|
-
if (!rowExists) {
|
|
2932
|
-
if (selectedRowId === undefined) {
|
|
2933
|
-
setInternalSelectedRowId(null);
|
|
2934
|
-
}
|
|
2935
|
-
if (onRowSelectionChange) {
|
|
2936
|
-
onRowSelectionChange(null);
|
|
2937
|
-
}
|
|
2938
|
-
}
|
|
2939
|
-
}
|
|
2940
|
-
}, [
|
|
2941
|
-
table.getRowModel().rows,
|
|
2942
|
-
effectiveSelectedRowId,
|
|
2943
|
-
selectedRowId,
|
|
2944
|
-
onRowSelectionChange,
|
|
2945
|
-
]);
|
|
2915
|
+
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) {
|
|
2946
2916
|
// ==================== Computed Values ====================
|
|
2947
2917
|
const hasData = table.getRowModel().rows?.length > 0;
|
|
2948
2918
|
const headerGroups = table.getHeaderGroups();
|
|
2949
|
-
const headers = headerGroups[0]?.headers || [];
|
|
2950
|
-
const visibleHeadersCount = React.useMemo(() => {
|
|
2951
|
-
return isDetailPanelOpen
|
|
2952
|
-
? headers.length - hideColumnsOnDetailOpen
|
|
2953
|
-
: headers.length;
|
|
2954
|
-
}, [isDetailPanelOpen, headers.length, hideColumnsOnDetailOpen]);
|
|
2955
2919
|
const normalizeSizeValue = (value) => {
|
|
2956
2920
|
if (value === undefined)
|
|
2957
2921
|
return undefined;
|
|
@@ -3018,42 +2982,18 @@ function TableComponent({ className, wrapperClassName, containerClassName, varia
|
|
|
3018
2982
|
}
|
|
3019
2983
|
return rowClassName || "";
|
|
3020
2984
|
}, [rowClassName]);
|
|
3021
|
-
const handleRowClickInternal = React.useCallback((row
|
|
3022
|
-
const currentSelectedId = selectedRowIdRef.current;
|
|
3023
|
-
const newSelectedId = currentSelectedId === rowId ? null : rowId;
|
|
3024
|
-
if (selectedRowId === undefined) {
|
|
3025
|
-
setInternalSelectedRowId(newSelectedId);
|
|
3026
|
-
}
|
|
3027
|
-
if (onRowSelectionChange) {
|
|
3028
|
-
onRowSelectionChange(newSelectedId);
|
|
3029
|
-
}
|
|
2985
|
+
const handleRowClickInternal = React.useCallback((row) => {
|
|
3030
2986
|
if (onRowClick) {
|
|
3031
2987
|
onRowClick(row);
|
|
3032
2988
|
}
|
|
3033
|
-
}, [
|
|
3034
|
-
const getSelectedRowData = () => {
|
|
3035
|
-
if (!effectiveSelectedRowId)
|
|
3036
|
-
return null;
|
|
3037
|
-
const row = table
|
|
3038
|
-
.getRowModel()
|
|
3039
|
-
.rows.find((r) => r.id === effectiveSelectedRowId);
|
|
3040
|
-
return row ? row.original : null;
|
|
3041
|
-
};
|
|
3042
|
-
const handleDetailPanelClose = () => {
|
|
3043
|
-
if (selectedRowId === undefined) {
|
|
3044
|
-
setInternalSelectedRowId(null);
|
|
3045
|
-
}
|
|
3046
|
-
if (onRowSelectionChange) {
|
|
3047
|
-
onRowSelectionChange(null);
|
|
3048
|
-
}
|
|
3049
|
-
};
|
|
2989
|
+
}, [onRowClick]);
|
|
3050
2990
|
const renderEmptyState = () => {
|
|
3051
2991
|
if (emptyComponent)
|
|
3052
2992
|
return emptyComponent;
|
|
3053
2993
|
return renderDefaultEmptyState({ colSpan: table.getAllColumns().length });
|
|
3054
2994
|
};
|
|
3055
2995
|
// ==================== Render ====================
|
|
3056
|
-
return (jsx("div", { ref: ref, className: cn("w-full", wrapperClassName), ...props, children:
|
|
2996
|
+
return (jsx("div", { ref: ref, className: cn("w-full", wrapperClassName), ...props, children: jsx("div", { className: cn("relative", enableHorizontalScroll ? "overflow-x-auto" : "overflow-x-hidden", maxHeight && "overflow-y-auto", containerClassName), style: containerStyle, children: jsxs("table", { className: cn(tableVariants({ variant, size }), className), children: [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 ? (jsx("tbody", { children: renderLoadingContent() })) : !hasData ? (jsx("tbody", { children: renderEmptyState() })) : (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 }))] }) }) }));
|
|
3057
2997
|
}
|
|
3058
2998
|
// ==================== Export ====================
|
|
3059
2999
|
const Table = React.forwardRef(TableComponent);
|