infinity-ui-elements 1.5.1-beta.1 → 1.5.1-beta.3
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/README.md +826 -223
- package/dist/components/Table/DetailPanel.d.ts +10 -0
- package/dist/components/Table/DetailPanel.d.ts.map +1 -0
- package/dist/components/Table/Table.d.ts +9 -65
- package/dist/components/Table/Table.d.ts.map +1 -1
- package/dist/components/Table/Table.refactored.d.ts +39 -0
- package/dist/components/Table/Table.refactored.d.ts.map +1 -0
- 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 +18 -0
- package/dist/components/Table/TableBody.d.ts.map +1 -0
- package/dist/components/Table/TableCellTypes.d.ts +32 -0
- package/dist/components/Table/TableCellTypes.d.ts.map +1 -0
- package/dist/components/Table/TableDetailPanel.d.ts +25 -0
- package/dist/components/Table/TableDetailPanel.d.ts.map +1 -0
- package/dist/components/Table/TableHeader.d.ts +18 -0
- package/dist/components/Table/TableHeader.d.ts.map +1 -0
- package/dist/components/Table/index.d.ts +3 -0
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/tableHelpers.d.ts +7 -0
- package/dist/components/Table/tableHelpers.d.ts.map +1 -0
- package/dist/components/Table/tableVariants.d.ts +12 -0
- package/dist/components/Table/tableVariants.d.ts.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.esm.js +191 -38
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +196 -37
- package/dist/index.js.map +1 -1
- package/dist/lib/icons.d.ts +1 -0
- package/dist/lib/icons.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -777,6 +777,9 @@ const iconRegistry = {
|
|
|
777
777
|
// Alias: check points to the same icon as tick
|
|
778
778
|
check: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
779
779
|
<path d="M10.364 15.1924L19.5564 6L20.9706 7.41421L10.364 18.0208L4 11.6569L5.41422 10.2427L10.364 15.1924Z" fill="#081416"/>
|
|
780
|
+
</svg>`,
|
|
781
|
+
add: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
782
|
+
<path d="M12.9 11.0999L21 11.0997V12.8997L12.9 12.8999V21H11.1V12.8999L3.00004 12.9001L3 11.1001L11.1 11.0999L11.0999 3.00001L12.8999 3L12.9 11.0999Z" fill="#081416"/>
|
|
780
783
|
</svg>`,
|
|
781
784
|
};
|
|
782
785
|
const Icon = ({ name, size = 24, className = "", style = {}, ...props }) => {
|
|
@@ -2689,69 +2692,219 @@ const tableHeaderVariants = cva("text-body-medium-regular text-left text-surface
|
|
|
2689
2692
|
size: "medium",
|
|
2690
2693
|
},
|
|
2691
2694
|
});
|
|
2692
|
-
const tableCellVariants = cva("text-body-medium-regular border-b border-surface-outline-neutral-muted text-surface-ink-neutral-normal", {
|
|
2695
|
+
const tableCellVariants = cva("text-body-medium-regular border-b border-surface-outline-neutral-muted text-surface-ink-neutral-normal transition-colors duration-150", {
|
|
2693
2696
|
variants: {
|
|
2694
2697
|
size: {
|
|
2695
2698
|
small: "px-3 py-2 h-[40px]",
|
|
2696
|
-
medium: "px-4 py-3 h-[
|
|
2699
|
+
medium: "px-4 py-3 h-[72px]",
|
|
2697
2700
|
large: "px-6 py-4 h-[56px]",
|
|
2698
2701
|
},
|
|
2702
|
+
state: {
|
|
2703
|
+
default: "",
|
|
2704
|
+
focus: "",
|
|
2705
|
+
// focus:
|
|
2706
|
+
// "outline outline-2 outline-action-outline-primary-default outline-offset-[-2px]",
|
|
2707
|
+
},
|
|
2699
2708
|
},
|
|
2700
2709
|
defaultVariants: {
|
|
2701
2710
|
size: "medium",
|
|
2711
|
+
state: "default",
|
|
2702
2712
|
},
|
|
2703
2713
|
});
|
|
2704
|
-
|
|
2714
|
+
|
|
2715
|
+
function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHeaderBackground, stickyHeader, size, headerClassName, isDetailPanelOpen, visibleHeadersCount, onToggleAllRows, isAllRowsSelected, isSomeRowsSelected, }) {
|
|
2716
|
+
return (jsx("thead", { className: cn(showHeaderBackground && "bg-surface-fill-neutral-moderate", stickyHeader && "sticky top-0 z-10"), children: headerGroups.map((headerGroup) => (jsxs("tr", { children: [enableRowSelection && enableSelectAll && (jsx("th", { className: cn(tableHeaderVariants({ size }), showHeaderBackground && "bg-surface-fill-neutral-moderate", "w-10 rounded-tl-xlarge rounded-bl-xlarge", headerClassName), children: jsx(Checkbox, { checked: isAllRowsSelected, isIndeterminate: isSomeRowsSelected, onChange: onToggleAllRows, "aria-label": "Select all rows" }) })), headerGroup.headers.map((header, index) => {
|
|
2717
|
+
const shouldHideColumn = isDetailPanelOpen && index >= visibleHeadersCount;
|
|
2718
|
+
const isLastVisibleColumn = isDetailPanelOpen
|
|
2719
|
+
? index === visibleHeadersCount - 1
|
|
2720
|
+
: index === headerGroup.headers.length - 1;
|
|
2721
|
+
return (jsx("th", { className: cn(tableHeaderVariants({ size }), showHeaderBackground &&
|
|
2722
|
+
"bg-surface-fill-neutral-moderate border-none", !enableRowSelection &&
|
|
2723
|
+
index === 0 &&
|
|
2724
|
+
"rounded-tl-xlarge rounded-bl-xlarge", isLastVisibleColumn && "rounded-tr-xlarge rounded-br-xlarge", header.column.columnDef.meta?.headerClassName, headerClassName, "transition-all duration-300 ease-in-out", shouldHideColumn
|
|
2725
|
+
? "opacity-0 translate-x-8 pointer-events-none"
|
|
2726
|
+
: "opacity-100 translate-x-0"), style: {
|
|
2727
|
+
width: header.getSize(),
|
|
2728
|
+
minWidth: header.column.columnDef.minSize,
|
|
2729
|
+
maxWidth: header.column.columnDef.maxSize,
|
|
2730
|
+
}, children: header.isPlaceholder ? null : (jsxs("div", { className: cn("flex items-center gap-2", header.column.getCanSort() && "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: {
|
|
2731
|
+
asc: "↑",
|
|
2732
|
+
desc: "↓",
|
|
2733
|
+
}[header.column.getIsSorted()] ?? "↕" }))] })) }, header.id));
|
|
2734
|
+
})] }, headerGroup.id))) }));
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
function TableBody({ rows, enableRowSelection, size, variant, showRowHover, cellClassName, isDetailPanelOpen, visibleHeadersCount, effectiveSelectedRowId, onRowClick, getRowClassName, handleRowClick, }) {
|
|
2738
|
+
const [focusedCell, setFocusedCell] = React.useState(null);
|
|
2739
|
+
const [hoveredRow, setHoveredRow] = React.useState(null);
|
|
2740
|
+
return (jsx("tbody", { className: "bg-surface-fill-neutral-intense", children: rows.map((row) => {
|
|
2741
|
+
const isRowSelected = row.id === effectiveSelectedRowId;
|
|
2742
|
+
const isRowHovered = hoveredRow === row.id;
|
|
2743
|
+
const handleClick = () => handleRowClick(row.original, row.id);
|
|
2744
|
+
return (jsxs("tr", { className: cn(variant === "striped" &&
|
|
2745
|
+
row.index % 2 === 1 &&
|
|
2746
|
+
"bg-surface-fill-neutral-moderate", onRowClick && "cursor-pointer", isRowSelected && "bg-action-fill-primary-faded", isRowHovered &&
|
|
2747
|
+
showRowHover &&
|
|
2748
|
+
"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), 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) => {
|
|
2749
|
+
const shouldHideColumn = isDetailPanelOpen && cellIndex >= visibleHeadersCount;
|
|
2750
|
+
const isCellFocused = focusedCell?.rowId === row.id &&
|
|
2751
|
+
focusedCell?.cellId === cell.id;
|
|
2752
|
+
const cellState = isCellFocused ? "focus" : "default";
|
|
2753
|
+
return (jsx("td", { className: cn(tableCellVariants({ size, state: cellState }), cell.column.columnDef.meta?.cellClassName, cellClassName, "transition-all duration-300 ease-in-out", shouldHideColumn
|
|
2754
|
+
? "opacity-0 translate-x-8 pointer-events-none"
|
|
2755
|
+
: "opacity-100 translate-x-0"), style: {
|
|
2756
|
+
width: cell.column.getSize(),
|
|
2757
|
+
minWidth: cell.column.columnDef.minSize,
|
|
2758
|
+
maxWidth: cell.column.columnDef.maxSize,
|
|
2759
|
+
}, tabIndex: 0, onFocus: () => setFocusedCell({ rowId: row.id, cellId: cell.id }), onBlur: () => setFocusedCell(null), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
2760
|
+
})] }, row.id));
|
|
2761
|
+
}) }));
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
function DetailPanel({ isOpen, content, data, onClose, }) {
|
|
2765
|
+
return (jsx("div", { className: cn("absolute top-0 right-0 h-full z-20 transition-all duration-300 ease-in-out", isOpen
|
|
2766
|
+
? "translate-x-0 opacity-100"
|
|
2767
|
+
: "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) => {
|
|
2768
|
+
e.stopPropagation();
|
|
2769
|
+
onClose();
|
|
2770
|
+
}, 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)] })) }) }) }));
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
function renderDefaultLoadingState({ colSpan }) {
|
|
2774
|
+
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..." })] }) }) }));
|
|
2775
|
+
}
|
|
2776
|
+
function renderDefaultEmptyState({ colSpan }) {
|
|
2777
|
+
return (jsx("tr", { children: jsx("td", { colSpan: colSpan, className: "text-center py-12 text-surface-ink-neutral-muted", children: "No data available" }) }));
|
|
2778
|
+
}
|
|
2779
|
+
|
|
2780
|
+
// ==================== Component ====================
|
|
2781
|
+
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) {
|
|
2782
|
+
// ==================== State ====================
|
|
2783
|
+
const [internalSelectedRowId, setInternalSelectedRowId] = React.useState(null);
|
|
2784
|
+
const selectedRowIdRef = React.useRef(null);
|
|
2785
|
+
const effectiveSelectedRowId = selectedRowId !== undefined ? selectedRowId : internalSelectedRowId;
|
|
2786
|
+
const isDetailPanelOpen = Boolean(effectiveSelectedRowId);
|
|
2787
|
+
// ==================== Effects ====================
|
|
2788
|
+
// Keep ref in sync
|
|
2789
|
+
React.useEffect(() => {
|
|
2790
|
+
selectedRowIdRef.current = effectiveSelectedRowId;
|
|
2791
|
+
}, [effectiveSelectedRowId]);
|
|
2792
|
+
// Clear selection if selected row is not in current data
|
|
2793
|
+
React.useEffect(() => {
|
|
2794
|
+
if (effectiveSelectedRowId) {
|
|
2795
|
+
const rowExists = table
|
|
2796
|
+
.getRowModel()
|
|
2797
|
+
.rows.some((r) => r.id === effectiveSelectedRowId);
|
|
2798
|
+
if (!rowExists) {
|
|
2799
|
+
if (selectedRowId === undefined) {
|
|
2800
|
+
setInternalSelectedRowId(null);
|
|
2801
|
+
}
|
|
2802
|
+
if (onRowSelectionChange) {
|
|
2803
|
+
onRowSelectionChange(null);
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
}, [
|
|
2808
|
+
table.getRowModel().rows,
|
|
2809
|
+
effectiveSelectedRowId,
|
|
2810
|
+
selectedRowId,
|
|
2811
|
+
onRowSelectionChange,
|
|
2812
|
+
]);
|
|
2813
|
+
// ==================== Computed Values ====================
|
|
2705
2814
|
const hasData = table.getRowModel().rows?.length > 0;
|
|
2706
|
-
const
|
|
2815
|
+
const headerGroups = table.getHeaderGroups();
|
|
2816
|
+
const headers = headerGroups[0]?.headers || [];
|
|
2817
|
+
const visibleHeadersCount = React.useMemo(() => {
|
|
2818
|
+
return isDetailPanelOpen
|
|
2819
|
+
? headers.length - hideColumnsOnDetailOpen
|
|
2820
|
+
: headers.length;
|
|
2821
|
+
}, [isDetailPanelOpen, headers.length, hideColumnsOnDetailOpen]);
|
|
2822
|
+
// ==================== Callbacks ====================
|
|
2823
|
+
const getRowClassName = React.useCallback((row) => {
|
|
2707
2824
|
if (typeof rowClassName === "function") {
|
|
2708
2825
|
return rowClassName(row);
|
|
2709
2826
|
}
|
|
2710
2827
|
return rowClassName || "";
|
|
2828
|
+
}, [rowClassName]);
|
|
2829
|
+
const handleRowClickInternal = React.useCallback((row, rowId) => {
|
|
2830
|
+
const currentSelectedId = selectedRowIdRef.current;
|
|
2831
|
+
const newSelectedId = currentSelectedId === rowId ? null : rowId;
|
|
2832
|
+
if (selectedRowId === undefined) {
|
|
2833
|
+
setInternalSelectedRowId(newSelectedId);
|
|
2834
|
+
}
|
|
2835
|
+
if (onRowSelectionChange) {
|
|
2836
|
+
onRowSelectionChange(newSelectedId);
|
|
2837
|
+
}
|
|
2838
|
+
if (onRowClick) {
|
|
2839
|
+
onRowClick(row);
|
|
2840
|
+
}
|
|
2841
|
+
}, [selectedRowId, onRowSelectionChange, onRowClick]);
|
|
2842
|
+
const getSelectedRowData = () => {
|
|
2843
|
+
if (!effectiveSelectedRowId)
|
|
2844
|
+
return null;
|
|
2845
|
+
const row = table
|
|
2846
|
+
.getRowModel()
|
|
2847
|
+
.rows.find((r) => r.id === effectiveSelectedRowId);
|
|
2848
|
+
return row ? row.original : null;
|
|
2849
|
+
};
|
|
2850
|
+
const handleDetailPanelClose = () => {
|
|
2851
|
+
if (selectedRowId === undefined) {
|
|
2852
|
+
setInternalSelectedRowId(null);
|
|
2853
|
+
}
|
|
2854
|
+
if (onRowSelectionChange) {
|
|
2855
|
+
onRowSelectionChange(null);
|
|
2856
|
+
}
|
|
2711
2857
|
};
|
|
2858
|
+
// ==================== Render Helpers ====================
|
|
2712
2859
|
const renderLoadingState = () => {
|
|
2713
|
-
if (loadingComponent)
|
|
2860
|
+
if (loadingComponent)
|
|
2714
2861
|
return loadingComponent;
|
|
2715
|
-
}
|
|
2716
|
-
return (jsx("tr", { children: jsx("td", { colSpan: table.getAllColumns().length, 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..." })] }) }) }));
|
|
2862
|
+
return renderDefaultLoadingState({ colSpan: table.getAllColumns().length });
|
|
2717
2863
|
};
|
|
2718
2864
|
const renderEmptyState = () => {
|
|
2719
|
-
if (emptyComponent)
|
|
2865
|
+
if (emptyComponent)
|
|
2720
2866
|
return emptyComponent;
|
|
2721
|
-
}
|
|
2722
|
-
return (jsx("tr", { children: jsx("td", { colSpan: table.getAllColumns().length, className: "text-center py-12 text-surface-ink-neutral-muted", children: "No data available" }) }));
|
|
2867
|
+
return renderDefaultEmptyState({ colSpan: table.getAllColumns().length });
|
|
2723
2868
|
};
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
"bg-surface-fill-neutral-moderate border-none",
|
|
2727
|
-
// Apply rounded corners to first and last headers
|
|
2728
|
-
!enableRowSelection &&
|
|
2729
|
-
index === 0 &&
|
|
2730
|
-
"rounded-tl-xlarge rounded-bl-xlarge", index === headerGroup.headers.length - 1 &&
|
|
2731
|
-
"rounded-tr-xlarge rounded-br-xlarge", header.column.columnDef.meta?.headerClassName, headerClassName), style: {
|
|
2732
|
-
width: header.getSize(),
|
|
2733
|
-
minWidth: header.column.columnDef.minSize,
|
|
2734
|
-
maxWidth: header.column.columnDef.maxSize,
|
|
2735
|
-
}, children: header.isPlaceholder ? null : (jsxs("div", { className: cn("flex items-center gap-2", header.column.getCanSort() &&
|
|
2736
|
-
"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: {
|
|
2737
|
-
asc: "↑",
|
|
2738
|
-
desc: "↓",
|
|
2739
|
-
}[header.column.getIsSorted()] ?? "↕" }))] })) }, header.id)))] }, headerGroup.id))) }), jsx("tbody", { className: "bg-surface-fill-neutral-intense", children: isLoading
|
|
2740
|
-
? renderLoadingState()
|
|
2741
|
-
: !hasData
|
|
2742
|
-
? renderEmptyState()
|
|
2743
|
-
: table.getRowModel().rows.map((row) => (jsxs("tr", { className: cn(variant === "striped" &&
|
|
2744
|
-
row.index % 2 === 1 &&
|
|
2745
|
-
"bg-surface-fill-neutral-moderate", showRowHover && "hover:bg-surface-fill-neutral-moderate", onRowClick && "cursor-pointer", getRowClassName(row.original)), onClick: () => onRowClick?.(row.original), children: [enableRowSelection && (jsx("td", { className: cn(tableCellVariants({ size }), "w-10", cellClassName), 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) => (jsx("td", { className: cn(tableCellVariants({ size }), cell.column.columnDef.meta?.cellClassName, cellClassName), style: {
|
|
2746
|
-
width: cell.column.getSize(),
|
|
2747
|
-
minWidth: cell.column.columnDef.minSize,
|
|
2748
|
-
maxWidth: cell.column.columnDef.maxSize,
|
|
2749
|
-
}, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)))] }, row.id))) })] }) }) }));
|
|
2869
|
+
// ==================== Render ====================
|
|
2870
|
+
return (jsx("div", { ref: ref, className: cn("w-full", wrapperClassName), ...props, children: jsxs("div", { className: cn("relative overflow-x-hidden", maxHeight && "overflow-y-auto", containerClassName), style: maxHeight ? { maxHeight } : undefined, 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, isDetailPanelOpen: isDetailPanelOpen, visibleHeadersCount: visibleHeadersCount, onToggleAllRows: (e) => table.getToggleAllRowsSelectedHandler()(e), isAllRowsSelected: table.getIsAllRowsSelected(), isSomeRowsSelected: table.getIsSomeRowsSelected() }), isLoading ? (jsx("tbody", { children: renderLoadingState() })) : !hasData ? (jsx("tbody", { children: renderEmptyState() })) : (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 }))] }), detailPanel && (jsx(DetailPanel, { isOpen: isDetailPanelOpen, content: detailPanel, data: getSelectedRowData(), onClose: handleDetailPanelClose }))] }) }));
|
|
2750
2871
|
}
|
|
2751
|
-
//
|
|
2872
|
+
// ==================== Export ====================
|
|
2752
2873
|
const Table = React.forwardRef(TableComponent);
|
|
2753
2874
|
Table.displayName = "Table";
|
|
2754
2875
|
|
|
2876
|
+
const TableDetailPanel = React.forwardRef(({ isOpen, onClose, children, className, width = "400px" }, ref) => {
|
|
2877
|
+
return (jsx("div", { ref: ref, className: cn("absolute top-0 right-0 h-full bg-white border border-surface-outline-neutral-muted transition-transform duration-300 ease-in-out overflow-auto", isOpen ? "translate-x-0" : "translate-x-full", className), style: { width }, children: children }));
|
|
2878
|
+
});
|
|
2879
|
+
TableDetailPanel.displayName = "TableDetailPanel";
|
|
2880
|
+
|
|
2881
|
+
function NumberCell({ value, currency, subtitle, className, }) {
|
|
2882
|
+
return (jsxs("div", { className: cn("flex flex-col", className), children: [jsxs("div", { className: "text-body-medium-medium text-surface-ink-neutral-normal", children: [currency, " ", value.toLocaleString("en-IN", {
|
|
2883
|
+
minimumFractionDigits: 2,
|
|
2884
|
+
maximumFractionDigits: 2,
|
|
2885
|
+
})] }), subtitle && (jsx("div", { className: "text-body-small-regular text-surface-ink-neutral-muted", children: subtitle }))] }));
|
|
2886
|
+
}
|
|
2887
|
+
function IconCell({ icon, background = "neutral", className, }) {
|
|
2888
|
+
const backgrounds = {
|
|
2889
|
+
neutral: "bg-surface-fill-neutral-faded",
|
|
2890
|
+
primary: "bg-action-fill-primary-faded",
|
|
2891
|
+
success: "bg-action-fill-positive-faded",
|
|
2892
|
+
warning: "bg-action-fill-warning-faded",
|
|
2893
|
+
danger: "bg-action-fill-negative-faded",
|
|
2894
|
+
};
|
|
2895
|
+
return (jsx("div", { className: cn("inline-flex items-center justify-center w-10 h-10 rounded-medium", backgrounds[background], className), children: icon }));
|
|
2896
|
+
}
|
|
2897
|
+
// ==================== Spacer Cell ====================
|
|
2898
|
+
function SpacerCell() {
|
|
2899
|
+
return jsx("div", { className: "w-full h-full" });
|
|
2900
|
+
}
|
|
2901
|
+
function SlotCell({ onDragStart, onDragEnd, className }) {
|
|
2902
|
+
return (jsx("div", { draggable: true, onDragStart: onDragStart, onDragEnd: onDragEnd, className: cn("flex items-center justify-center cursor-grab active:cursor-grabbing", className), children: jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", className: "text-surface-ink-neutral-muted", children: [jsx("path", { d: "M6 4C6 3.44772 5.55228 3 5 3C4.44772 3 4 3.44772 4 4C4 4.55228 4.44772 5 5 5C5.55228 5 6 4.55228 6 4Z", fill: "currentColor" }), jsx("path", { d: "M6 8C6 7.44772 5.55228 7 5 7C4.44772 7 4 7.44772 4 8C4 8.55228 4.44772 9 5 9C5.55228 9 6 8.55228 6 8Z", fill: "currentColor" }), jsx("path", { d: "M6 12C6 11.4477 5.55228 11 5 11C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13C5.55228 13 6 12.5523 6 12Z", fill: "currentColor" }), jsx("path", { d: "M12 4C12 3.44772 11.5523 3 11 3C10.4477 3 10 3.44772 10 4C10 4.55228 10.4477 5 11 5C11.5523 5 12 4.55228 12 4Z", fill: "currentColor" }), jsx("path", { d: "M12 8C12 7.44772 11.5523 7 11 7C10.4477 7 10 7.44772 10 8C10 8.55228 10.4477 9 11 9C11.5523 9 12 8.55228 12 8Z", fill: "currentColor" }), jsx("path", { d: "M12 12C12 11.4477 11.5523 11 11 11C10.4477 11 10 11.4477 10 12C10 12.5523 10.4477 13 11 13C11.5523 13 12 12.5523 12 12Z", fill: "currentColor" })] }) }));
|
|
2903
|
+
}
|
|
2904
|
+
function AvatarCell({ name, initials, avatar, subtitle, color = "a1", className, }) {
|
|
2905
|
+
return (jsxs("div", { className: cn("flex items-center gap-3", className), children: [avatar ? (jsx("img", { src: avatar, alt: name, className: "w-10 h-10 rounded-full object-cover" })) : (jsx("div", { className: cn("w-10 h-10 rounded-full flex items-center justify-center text-body-medium-medium", `bg-${color}`), children: initials || name.charAt(0).toUpperCase() })), jsxs("div", { className: "flex flex-col", children: [jsx("div", { className: "text-body-medium-medium text-surface-ink-neutral-normal", children: name }), subtitle && (jsx("div", { className: "text-body-small-regular text-surface-ink-neutral-muted", children: subtitle }))] })] }));
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2755
2908
|
const tabItemVariants = cva("inline-flex items-center justify-center gap-2 whitespace-nowrap transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 relative cursor-pointer", {
|
|
2756
2909
|
variants: {
|
|
2757
2910
|
variant: {
|
|
@@ -2954,5 +3107,5 @@ const TextArea = React.forwardRef(({ label, helperText, errorText, successText,
|
|
|
2954
3107
|
});
|
|
2955
3108
|
TextArea.displayName = "TextArea";
|
|
2956
3109
|
|
|
2957
|
-
export { Avatar, Badge, Button, ButtonGroup, Checkbox, Counter, Divider, Dropdown, DropdownMenu, FormFooter, FormHeader, Icon, Link, ListItem, Modal, Pagination, Radio, SearchableDropdown, Select, Switch, TabItem, Table, Tabs, Text, TextArea, TextField, Tooltip, avatarVariants, badgeVariants, buttonGroupVariants, buttonVariants, checkboxVariants, cn, counterVariants, dropdownVariants, getAvailableIcons, hasIcon, iconRegistry, linkVariants, listItemVariants, paginationVariants, radioVariants, selectVariants, switchVariants, tableCellVariants, tableHeaderVariants, tableVariants, textAreaVariants, textFieldVariants, tooltipVariants };
|
|
3110
|
+
export { Avatar, AvatarCell, Badge, Button, ButtonGroup, Checkbox, Counter, Divider, Dropdown, DropdownMenu, FormFooter, FormHeader, Icon, IconCell, Link, ListItem, Modal, NumberCell, Pagination, Radio, SearchableDropdown, Select, SlotCell, SpacerCell, Switch, TabItem, Table, TableDetailPanel, Tabs, Text, TextArea, TextField, Tooltip, avatarVariants, badgeVariants, buttonGroupVariants, buttonVariants, checkboxVariants, cn, counterVariants, dropdownVariants, getAvailableIcons, hasIcon, iconRegistry, linkVariants, listItemVariants, paginationVariants, radioVariants, selectVariants, switchVariants, tableCellVariants, tableHeaderVariants, tableVariants, textAreaVariants, textFieldVariants, tooltipVariants };
|
|
2958
3111
|
//# sourceMappingURL=index.esm.js.map
|