infinity-ui-elements 1.7.9 → 1.7.11
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/Table/Table.d.ts +7 -1
- package/dist/components/Table/Table.d.ts.map +1 -1
- package/dist/components/Table/Table.stories.d.ts +2 -0
- package/dist/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/components/Table/TableBody.d.ts +7 -1
- package/dist/components/Table/TableBody.d.ts.map +1 -1
- package/dist/components/Table/TableHeader.d.ts +7 -1
- package/dist/components/Table/TableHeader.d.ts.map +1 -1
- package/dist/index.esm.js +63 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +63 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2856,7 +2856,7 @@ const tableCellVariants = classVarianceAuthority.cva("text-body-medium-regular b
|
|
|
2856
2856
|
},
|
|
2857
2857
|
});
|
|
2858
2858
|
|
|
2859
|
-
function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHeaderBackground, stickyHeader, size, headerClassName, isDetailPanelOpen, visibleHeadersCount, onToggleAllRows, isAllRowsSelected, isSomeRowsSelected, }) {
|
|
2859
|
+
function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHeaderBackground, stickyHeader, size, headerClassName, isDetailPanelOpen, visibleHeadersCount, onToggleAllRows, isAllRowsSelected, isSomeRowsSelected, getColumnStyle, }) {
|
|
2860
2860
|
const headerHeight = {
|
|
2861
2861
|
small: 32,
|
|
2862
2862
|
medium: 40,
|
|
@@ -2873,9 +2873,11 @@ function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHe
|
|
|
2873
2873
|
"bg-surface-fill-neutral-moderate border-none", stickyHeader && "sticky z-20", !enableRowSelection && index === 0 && "rounded-tl-xlarge ", isLastVisibleColumn && "rounded-tr-xlarge", header.column.columnDef.meta?.headerClassName, headerClassName, "transition-all duration-300 ease-in-out", shouldHideColumn
|
|
2874
2874
|
? "opacity-0 translate-x-8 pointer-events-none"
|
|
2875
2875
|
: "opacity-100 translate-x-0"), style: {
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2876
|
+
...getColumnStyle(header.column.id, {
|
|
2877
|
+
width: header.getSize(),
|
|
2878
|
+
minWidth: header.column.columnDef.minSize,
|
|
2879
|
+
maxWidth: header.column.columnDef.maxSize,
|
|
2880
|
+
}),
|
|
2879
2881
|
top: stickyTop,
|
|
2880
2882
|
}, children: header.isPlaceholder ? null : (jsxRuntime.jsxs("div", { className: cn("flex items-center gap-2", header.column.getCanSort() &&
|
|
2881
2883
|
"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: {
|
|
@@ -2886,7 +2888,7 @@ function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHe
|
|
|
2886
2888
|
}) }));
|
|
2887
2889
|
}
|
|
2888
2890
|
|
|
2889
|
-
function TableBody({ rows, enableRowSelection, size, variant, showRowHover, cellClassName, isDetailPanelOpen, visibleHeadersCount, effectiveSelectedRowId, onRowClick, getRowClassName, handleRowClick, }) {
|
|
2891
|
+
function TableBody({ rows, enableRowSelection, size, variant, showRowHover, cellClassName, isDetailPanelOpen, visibleHeadersCount, effectiveSelectedRowId, onRowClick, getRowClassName, handleRowClick, getColumnStyle, }) {
|
|
2890
2892
|
const [focusedCell, setFocusedCell] = React__namespace.useState(null);
|
|
2891
2893
|
const [hoveredRow, setHoveredRow] = React__namespace.useState(null);
|
|
2892
2894
|
return (jsxRuntime.jsx("tbody", { className: cn("bg-surface-fill-neutral-intense"), children: rows.map((row) => {
|
|
@@ -2904,11 +2906,11 @@ function TableBody({ rows, enableRowSelection, size, variant, showRowHover, cell
|
|
|
2904
2906
|
const cellState = isCellFocused ? "focus" : "default";
|
|
2905
2907
|
return (jsxRuntime.jsx("td", { className: cn(tableCellVariants({ size, state: cellState }), cell.column.columnDef.meta?.cellClassName, cellClassName, "transition-all duration-300 ease-in-out", shouldHideColumn
|
|
2906
2908
|
? "opacity-0 translate-x-8 pointer-events-none"
|
|
2907
|
-
: "opacity-100 translate-x-0"), style: {
|
|
2909
|
+
: "opacity-100 translate-x-0"), style: getColumnStyle(cell.column.id, {
|
|
2908
2910
|
width: cell.column.getSize(),
|
|
2909
2911
|
minWidth: cell.column.columnDef.minSize,
|
|
2910
2912
|
maxWidth: cell.column.columnDef.maxSize,
|
|
2911
|
-
}, tabIndex: 0, onFocus: () => setFocusedCell({ rowId: row.id, cellId: cell.id }), onBlur: () => setFocusedCell(null), children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
2913
|
+
}), tabIndex: 0, onFocus: () => setFocusedCell({ rowId: row.id, cellId: cell.id }), onBlur: () => setFocusedCell(null), children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
2912
2914
|
})] }, row.id));
|
|
2913
2915
|
}) }));
|
|
2914
2916
|
}
|
|
@@ -2930,7 +2932,7 @@ function renderDefaultEmptyState({ colSpan }) {
|
|
|
2930
2932
|
}
|
|
2931
2933
|
|
|
2932
2934
|
// ==================== Component ====================
|
|
2933
|
-
function TableComponent({ className, wrapperClassName, containerClassName, variant, size = "medium", table, enableRowSelection = false, enableSelectAll = false, isLoading = false, loadingComponent, emptyComponent, enableHorizontalScroll = false, stickyHeader = false, maxHeight, showRowHover = true, onRowClick, rowClassName, headerClassName, cellClassName, showHeaderBackground = true, detailPanel, hideColumnsOnDetailOpen = 3, selectedRowId, onRowSelectionChange, ...props }, ref) {
|
|
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, detailPanel, hideColumnsOnDetailOpen = 3, selectedRowId, onRowSelectionChange, loadingSkeletonRows, loadingSkeletonHeight, columnWidths, columnMinWidths, columnMaxWidths, ...props }, ref) {
|
|
2934
2936
|
// ==================== State ====================
|
|
2935
2937
|
const [internalSelectedRowId, setInternalSelectedRowId] = React__namespace.useState(null);
|
|
2936
2938
|
const selectedRowIdRef = React__namespace.useRef(null);
|
|
@@ -2971,6 +2973,21 @@ function TableComponent({ className, wrapperClassName, containerClassName, varia
|
|
|
2971
2973
|
? headers.length - hideColumnsOnDetailOpen
|
|
2972
2974
|
: headers.length;
|
|
2973
2975
|
}, [isDetailPanelOpen, headers.length, hideColumnsOnDetailOpen]);
|
|
2976
|
+
const normalizeSizeValue = (value) => {
|
|
2977
|
+
if (value === undefined)
|
|
2978
|
+
return undefined;
|
|
2979
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
2980
|
+
};
|
|
2981
|
+
const getColumnStyle = React__namespace.useCallback((columnId, fallback) => {
|
|
2982
|
+
const width = columnWidths?.[columnId] ?? fallback?.width ?? undefined;
|
|
2983
|
+
const minWidth = columnMinWidths?.[columnId] ?? fallback?.minWidth ?? undefined;
|
|
2984
|
+
const maxWidth = columnMaxWidths?.[columnId] ?? fallback?.maxWidth ?? undefined;
|
|
2985
|
+
return {
|
|
2986
|
+
width: normalizeSizeValue(width),
|
|
2987
|
+
minWidth: normalizeSizeValue(minWidth),
|
|
2988
|
+
maxWidth: normalizeSizeValue(maxWidth),
|
|
2989
|
+
};
|
|
2990
|
+
}, [columnWidths, columnMinWidths, columnMaxWidths]);
|
|
2974
2991
|
const containerStyle = React__namespace.useMemo(() => {
|
|
2975
2992
|
if (!maxHeight)
|
|
2976
2993
|
return undefined;
|
|
@@ -2978,6 +2995,43 @@ function TableComponent({ className, wrapperClassName, containerClassName, varia
|
|
|
2978
2995
|
maxHeight: typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight,
|
|
2979
2996
|
};
|
|
2980
2997
|
}, [maxHeight]);
|
|
2998
|
+
const resolvedLoading = typeof loading === "boolean" ? loading : Boolean(isLoading);
|
|
2999
|
+
const skeletonRowCount = loadingSkeletonRows ?? 5;
|
|
3000
|
+
const sizeKey = size || "medium";
|
|
3001
|
+
const skeletonHeightMap = {
|
|
3002
|
+
small: 16,
|
|
3003
|
+
medium: 20,
|
|
3004
|
+
large: 24,
|
|
3005
|
+
};
|
|
3006
|
+
const skeletonCellHeight = normalizeSizeValue(loadingSkeletonHeight ?? skeletonHeightMap[sizeKey]);
|
|
3007
|
+
const selectionSkeletonSize = sizeKey === "small" ? 14 : sizeKey === "large" ? 20 : 16;
|
|
3008
|
+
const renderSkeletonRows = React__namespace.useCallback(() => {
|
|
3009
|
+
const visibleColumns = table.getVisibleLeafColumns();
|
|
3010
|
+
if (visibleColumns.length === 0) {
|
|
3011
|
+
return renderDefaultLoadingState({
|
|
3012
|
+
colSpan: table.getAllColumns().length || 1,
|
|
3013
|
+
});
|
|
3014
|
+
}
|
|
3015
|
+
return Array.from({ length: skeletonRowCount }).map((_, rowIndex) => (jsxRuntime.jsxs("tr", { children: [enableRowSelection && (jsxRuntime.jsx("td", { className: cn(tableCellVariants({ size: sizeKey }), "w-10", cellClassName), children: jsxRuntime.jsx(Skeleton, { variant: "circle", width: selectionSkeletonSize, height: selectionSkeletonSize }) })), visibleColumns.map((column) => (jsxRuntime.jsx("td", { className: cn(tableCellVariants({ size: sizeKey }), column.columnDef.meta?.cellClassName, cellClassName), style: getColumnStyle(column.id, {
|
|
3016
|
+
width: column.getSize(),
|
|
3017
|
+
minWidth: column.columnDef.minSize,
|
|
3018
|
+
maxWidth: column.columnDef.maxSize,
|
|
3019
|
+
}), children: jsxRuntime.jsx(Skeleton, { className: "w-full", height: skeletonCellHeight, rounded: "medium" }) }, `${column.id}-${rowIndex}`)))] }, `skeleton-row-${rowIndex}`)));
|
|
3020
|
+
}, [
|
|
3021
|
+
cellClassName,
|
|
3022
|
+
enableRowSelection,
|
|
3023
|
+
getColumnStyle,
|
|
3024
|
+
selectionSkeletonSize,
|
|
3025
|
+
sizeKey,
|
|
3026
|
+
skeletonCellHeight,
|
|
3027
|
+
skeletonRowCount,
|
|
3028
|
+
table,
|
|
3029
|
+
]);
|
|
3030
|
+
const renderLoadingContent = React__namespace.useCallback(() => {
|
|
3031
|
+
if (loadingComponent)
|
|
3032
|
+
return loadingComponent;
|
|
3033
|
+
return renderSkeletonRows();
|
|
3034
|
+
}, [loadingComponent, renderSkeletonRows]);
|
|
2981
3035
|
// ==================== Callbacks ====================
|
|
2982
3036
|
const getRowClassName = React__namespace.useCallback((row) => {
|
|
2983
3037
|
if (typeof rowClassName === "function") {
|
|
@@ -3014,19 +3068,13 @@ function TableComponent({ className, wrapperClassName, containerClassName, varia
|
|
|
3014
3068
|
onRowSelectionChange(null);
|
|
3015
3069
|
}
|
|
3016
3070
|
};
|
|
3017
|
-
// ==================== Render Helpers ====================
|
|
3018
|
-
const renderLoadingState = () => {
|
|
3019
|
-
if (loadingComponent)
|
|
3020
|
-
return loadingComponent;
|
|
3021
|
-
return renderDefaultLoadingState({ colSpan: table.getAllColumns().length });
|
|
3022
|
-
};
|
|
3023
3071
|
const renderEmptyState = () => {
|
|
3024
3072
|
if (emptyComponent)
|
|
3025
3073
|
return emptyComponent;
|
|
3026
3074
|
return renderDefaultEmptyState({ colSpan: table.getAllColumns().length });
|
|
3027
3075
|
};
|
|
3028
3076
|
// ==================== Render ====================
|
|
3029
|
-
return (jsxRuntime.jsx("div", { ref: ref, className: cn("w-full", wrapperClassName), ...props, children: jsxRuntime.jsxs("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, isDetailPanelOpen: isDetailPanelOpen, visibleHeadersCount: visibleHeadersCount, onToggleAllRows: (e) => table.getToggleAllRowsSelectedHandler()(e), isAllRowsSelected: table.getIsAllRowsSelected(), isSomeRowsSelected: table.getIsSomeRowsSelected() }),
|
|
3077
|
+
return (jsxRuntime.jsx("div", { ref: ref, className: cn("w-full", wrapperClassName), ...props, children: jsxRuntime.jsxs("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, isDetailPanelOpen: isDetailPanelOpen, visibleHeadersCount: visibleHeadersCount, 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, isDetailPanelOpen: isDetailPanelOpen, visibleHeadersCount: visibleHeadersCount, effectiveSelectedRowId: effectiveSelectedRowId, onRowClick: onRowClick, getRowClassName: getRowClassName, handleRowClick: handleRowClickInternal, getColumnStyle: getColumnStyle }))] }), detailPanel && (jsxRuntime.jsx(DetailPanel, { isOpen: isDetailPanelOpen, content: detailPanel, data: getSelectedRowData(), onClose: handleDetailPanelClose }))] }) }));
|
|
3030
3078
|
}
|
|
3031
3079
|
// ==================== Export ====================
|
|
3032
3080
|
const Table = React__namespace.forwardRef(TableComponent);
|