luxtable 0.3.4 → 0.3.5
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/EXAMPLE.md +1 -1
- package/README.md +1 -1
- package/USAGE.md +1 -1
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +171 -107
- package/dist/index.mjs +159 -95
- package/package.json +2 -2
package/EXAMPLE.md
CHANGED
|
@@ -342,7 +342,7 @@ module.exports = {
|
|
|
342
342
|
|
|
343
343
|
## 💡 Need Help?
|
|
344
344
|
|
|
345
|
-
- GitHub Issues: [github.com/
|
|
345
|
+
- GitHub Issues: [github.com/Huseyin-altun/luxtable/issues](https://github.com/Huseyin-altun/luxtable/issues)
|
|
346
346
|
- Documentation: [luxtable.dev/docs](https://luxtable.dev/docs)
|
|
347
347
|
|
|
348
348
|
Happy coding! 🎉
|
package/README.md
CHANGED
package/USAGE.md
CHANGED
|
@@ -599,7 +599,7 @@ function App() {
|
|
|
599
599
|
|
|
600
600
|
For more detailed examples and full API documentation, visit:
|
|
601
601
|
- **Documentation**: [https://luxtable.dev](https://luxtable.dev)
|
|
602
|
-
- **GitHub**: [https://github.com/
|
|
602
|
+
- **GitHub**: [https://github.com/Huseyin-altun/luxtable](https://github.com/Huseyin-altun/luxtable)
|
|
603
603
|
- **npm**: [https://www.npmjs.com/package/luxtable](https://www.npmjs.com/package/luxtable)
|
|
604
604
|
|
|
605
605
|
---
|
package/dist/index.d.mts
CHANGED
|
@@ -22,6 +22,10 @@ interface LuxTableOptions {
|
|
|
22
22
|
pageSize?: number;
|
|
23
23
|
/** Sorting feature (default: true) */
|
|
24
24
|
sorting?: boolean;
|
|
25
|
+
/** Multi-column sorting - hold Shift and click to sort by multiple columns (default: true) */
|
|
26
|
+
multiSort?: boolean;
|
|
27
|
+
/** Maximum number of columns that can be sorted at once (default: unlimited) */
|
|
28
|
+
maxMultiSortColCount?: number;
|
|
25
29
|
/** Column filtering feature (default: false) */
|
|
26
30
|
filtering?: boolean;
|
|
27
31
|
/** Row selection mode - "single": single select, "multiple": multi-select, "none": disabled */
|
|
@@ -162,6 +166,9 @@ interface LuxDataTableColumnHeaderProps<TData, TValue> extends React.HTMLAttribu
|
|
|
162
166
|
column: Column<TData, TValue>;
|
|
163
167
|
title: string;
|
|
164
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Column header component with sort indicator and actions menu
|
|
171
|
+
*/
|
|
165
172
|
declare function LuxDataTableColumnHeader<TData, TValue>({ column, title, className, }: LuxDataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime.JSX.Element;
|
|
166
173
|
|
|
167
174
|
declare const Table: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLTableElement> & React$1.RefAttributes<HTMLTableElement>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,10 @@ interface LuxTableOptions {
|
|
|
22
22
|
pageSize?: number;
|
|
23
23
|
/** Sorting feature (default: true) */
|
|
24
24
|
sorting?: boolean;
|
|
25
|
+
/** Multi-column sorting - hold Shift and click to sort by multiple columns (default: true) */
|
|
26
|
+
multiSort?: boolean;
|
|
27
|
+
/** Maximum number of columns that can be sorted at once (default: unlimited) */
|
|
28
|
+
maxMultiSortColCount?: number;
|
|
25
29
|
/** Column filtering feature (default: false) */
|
|
26
30
|
filtering?: boolean;
|
|
27
31
|
/** Row selection mode - "single": single select, "multiple": multi-select, "none": disabled */
|
|
@@ -162,6 +166,9 @@ interface LuxDataTableColumnHeaderProps<TData, TValue> extends React.HTMLAttribu
|
|
|
162
166
|
column: Column<TData, TValue>;
|
|
163
167
|
title: string;
|
|
164
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Column header component with sort indicator and actions menu
|
|
171
|
+
*/
|
|
165
172
|
declare function LuxDataTableColumnHeader<TData, TValue>({ column, title, className, }: LuxDataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime.JSX.Element;
|
|
166
173
|
|
|
167
174
|
declare const Table: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLTableElement> & React$1.RefAttributes<HTMLTableElement>>;
|
package/dist/index.js
CHANGED
|
@@ -90,17 +90,17 @@ __export(index_exports, {
|
|
|
90
90
|
createColumnsFromData: () => createColumnsFromData,
|
|
91
91
|
createCopyableCell: () => createCopyableCell,
|
|
92
92
|
defaultStatusColors: () => defaultStatusColors,
|
|
93
|
-
flexRender: () =>
|
|
94
|
-
getCoreRowModel: () =>
|
|
95
|
-
getFilteredRowModel: () =>
|
|
96
|
-
getPaginationRowModel: () =>
|
|
97
|
-
getSortedRowModel: () =>
|
|
93
|
+
flexRender: () => import_react_table4.flexRender,
|
|
94
|
+
getCoreRowModel: () => import_react_table4.getCoreRowModel,
|
|
95
|
+
getFilteredRowModel: () => import_react_table4.getFilteredRowModel,
|
|
96
|
+
getPaginationRowModel: () => import_react_table4.getPaginationRowModel,
|
|
97
|
+
getSortedRowModel: () => import_react_table4.getSortedRowModel
|
|
98
98
|
});
|
|
99
99
|
module.exports = __toCommonJS(index_exports);
|
|
100
100
|
|
|
101
101
|
// src/components/lux-table/lux-table.tsx
|
|
102
102
|
var React7 = __toESM(require("react"));
|
|
103
|
-
var
|
|
103
|
+
var import_react_table2 = require("@tanstack/react-table");
|
|
104
104
|
var import_lucide_react7 = require("lucide-react");
|
|
105
105
|
|
|
106
106
|
// src/lib/utils.ts
|
|
@@ -918,15 +918,51 @@ function TableToolbar({
|
|
|
918
918
|
);
|
|
919
919
|
}
|
|
920
920
|
|
|
921
|
+
// src/components/lux-table/sortable-header.tsx
|
|
922
|
+
var import_react_table = require("@tanstack/react-table");
|
|
923
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
924
|
+
function SortableHeader({
|
|
925
|
+
header,
|
|
926
|
+
showSortIndex = false
|
|
927
|
+
}) {
|
|
928
|
+
const column = header.column;
|
|
929
|
+
const canSort = column.getCanSort();
|
|
930
|
+
const isSorted = column.getIsSorted();
|
|
931
|
+
const sortIndex = column.getSortIndex();
|
|
932
|
+
const headerContent = header.isPlaceholder ? null : (0, import_react_table.flexRender)(column.columnDef.header, header.getContext());
|
|
933
|
+
if (!canSort) {
|
|
934
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: headerContent });
|
|
935
|
+
}
|
|
936
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
937
|
+
"button",
|
|
938
|
+
{
|
|
939
|
+
type: "button",
|
|
940
|
+
className: cn(
|
|
941
|
+
"flex items-center gap-1.5 w-full text-left font-medium group",
|
|
942
|
+
"hover:text-slate-900 dark:hover:text-slate-100",
|
|
943
|
+
"transition-colors duration-150",
|
|
944
|
+
"-ml-2 px-2 py-1 rounded-md",
|
|
945
|
+
"hover:bg-slate-100 dark:hover:bg-slate-800",
|
|
946
|
+
isSorted && "text-blue-600 dark:text-blue-400"
|
|
947
|
+
),
|
|
948
|
+
onClick: header.column.getToggleSortingHandler(),
|
|
949
|
+
children: [
|
|
950
|
+
headerContent,
|
|
951
|
+
showSortIndex && isSorted && sortIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "ml-0.5 text-[10px] font-bold text-blue-500 dark:text-blue-400 bg-blue-100 dark:bg-blue-900/50 rounded-full w-4 h-4 flex items-center justify-center", children: sortIndex + 1 })
|
|
952
|
+
]
|
|
953
|
+
}
|
|
954
|
+
);
|
|
955
|
+
}
|
|
956
|
+
|
|
921
957
|
// src/components/ui/checkbox.tsx
|
|
922
958
|
var CheckboxPrimitive = __toESM(require("@radix-ui/react-checkbox"));
|
|
923
959
|
var import_lucide_react6 = require("lucide-react");
|
|
924
|
-
var
|
|
960
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
925
961
|
function Checkbox({
|
|
926
962
|
className,
|
|
927
963
|
...props
|
|
928
964
|
}) {
|
|
929
|
-
return /* @__PURE__ */ (0,
|
|
965
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
930
966
|
CheckboxPrimitive.Root,
|
|
931
967
|
{
|
|
932
968
|
"data-slot": "checkbox",
|
|
@@ -935,12 +971,12 @@ function Checkbox({
|
|
|
935
971
|
className
|
|
936
972
|
),
|
|
937
973
|
...props,
|
|
938
|
-
children: /* @__PURE__ */ (0,
|
|
974
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
939
975
|
CheckboxPrimitive.Indicator,
|
|
940
976
|
{
|
|
941
977
|
"data-slot": "checkbox-indicator",
|
|
942
978
|
className: "grid place-content-center text-current transition-none",
|
|
943
|
-
children: /* @__PURE__ */ (0,
|
|
979
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react6.CheckIcon, { className: "size-3.5" })
|
|
944
980
|
}
|
|
945
981
|
)
|
|
946
982
|
}
|
|
@@ -948,11 +984,11 @@ function Checkbox({
|
|
|
948
984
|
}
|
|
949
985
|
|
|
950
986
|
// src/components/lux-table/lux-table.tsx
|
|
951
|
-
var
|
|
987
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
952
988
|
function createSelectionColumn() {
|
|
953
989
|
return {
|
|
954
990
|
id: "__selection__",
|
|
955
|
-
header: ({ table }) => /* @__PURE__ */ (0,
|
|
991
|
+
header: ({ table }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
956
992
|
Checkbox,
|
|
957
993
|
{
|
|
958
994
|
checked: table.getIsAllPageRowsSelected() || table.getIsSomePageRowsSelected() && "indeterminate",
|
|
@@ -960,7 +996,7 @@ function createSelectionColumn() {
|
|
|
960
996
|
"aria-label": "Select all rows"
|
|
961
997
|
}
|
|
962
998
|
),
|
|
963
|
-
cell: ({ row }) => /* @__PURE__ */ (0,
|
|
999
|
+
cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
964
1000
|
Checkbox,
|
|
965
1001
|
{
|
|
966
1002
|
checked: row.getIsSelected(),
|
|
@@ -1016,9 +1052,17 @@ function LuxTable({
|
|
|
1016
1052
|
},
|
|
1017
1053
|
[isControlledRowSelection, onRowSelectionChange, rowSelection]
|
|
1018
1054
|
);
|
|
1019
|
-
const
|
|
1055
|
+
const enableSorting = options?.sorting !== false;
|
|
1056
|
+
const enableMultiSort = options?.multiSort !== false;
|
|
1057
|
+
const table = (0, import_react_table2.useReactTable)({
|
|
1020
1058
|
data,
|
|
1021
1059
|
columns: tableColumns,
|
|
1060
|
+
enableSorting,
|
|
1061
|
+
enableMultiSort,
|
|
1062
|
+
// Shift+Click for multi-sort (default behavior)
|
|
1063
|
+
isMultiSortEvent: (e) => e.shiftKey,
|
|
1064
|
+
// Max columns for multi-sort (undefined = unlimited)
|
|
1065
|
+
maxMultiSortColCount: options?.maxMultiSortColCount,
|
|
1022
1066
|
state: {
|
|
1023
1067
|
sorting,
|
|
1024
1068
|
columnFilters,
|
|
@@ -1044,11 +1088,11 @@ function LuxTable({
|
|
|
1044
1088
|
}
|
|
1045
1089
|
return String(index);
|
|
1046
1090
|
}),
|
|
1047
|
-
getCoreRowModel: (0,
|
|
1048
|
-
getPaginationRowModel: options?.pagination ? (0,
|
|
1049
|
-
getSortedRowModel: (0,
|
|
1050
|
-
getFilteredRowModel: (0,
|
|
1051
|
-
getFacetedUniqueValues: (0,
|
|
1091
|
+
getCoreRowModel: (0, import_react_table2.getCoreRowModel)(),
|
|
1092
|
+
getPaginationRowModel: options?.pagination ? (0, import_react_table2.getPaginationRowModel)() : void 0,
|
|
1093
|
+
getSortedRowModel: (0, import_react_table2.getSortedRowModel)(),
|
|
1094
|
+
getFilteredRowModel: (0, import_react_table2.getFilteredRowModel)(),
|
|
1095
|
+
getFacetedUniqueValues: (0, import_react_table2.getFacetedUniqueValues)(),
|
|
1052
1096
|
initialState: {
|
|
1053
1097
|
pagination: {
|
|
1054
1098
|
pageSize: options?.pageSize ?? 10
|
|
@@ -1065,8 +1109,8 @@ function LuxTable({
|
|
|
1065
1109
|
const showToolbar = options?.showToolbar ?? false;
|
|
1066
1110
|
const showGlobalSearch = options?.showGlobalSearch ?? true;
|
|
1067
1111
|
const showColumnVisibility = options?.showColumnVisibility ?? true;
|
|
1068
|
-
return /* @__PURE__ */ (0,
|
|
1069
|
-
showToolbar && /* @__PURE__ */ (0,
|
|
1112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: cn("w-full space-y-4", className), children: [
|
|
1113
|
+
showToolbar && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1070
1114
|
TableToolbar,
|
|
1071
1115
|
{
|
|
1072
1116
|
table,
|
|
@@ -1077,18 +1121,18 @@ function LuxTable({
|
|
|
1077
1121
|
showColumnVisibility
|
|
1078
1122
|
}
|
|
1079
1123
|
),
|
|
1080
|
-
enableRowSelection && Object.keys(rowSelection).length > 0 && /* @__PURE__ */ (0,
|
|
1081
|
-
/* @__PURE__ */ (0,
|
|
1082
|
-
/* @__PURE__ */ (0,
|
|
1083
|
-
/* @__PURE__ */ (0,
|
|
1124
|
+
enableRowSelection && Object.keys(rowSelection).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2 px-4 py-2 text-sm bg-blue-50 dark:bg-blue-950/50 text-blue-700 dark:text-blue-300 rounded-lg border border-blue-200 dark:border-blue-800", children: [
|
|
1125
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react7.CheckCircle2, { className: "w-4 h-4" }),
|
|
1126
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { children: [
|
|
1127
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("strong", { children: Object.keys(rowSelection).length }),
|
|
1084
1128
|
" rows selected",
|
|
1085
|
-
table.getFilteredRowModel().rows.length > 0 && /* @__PURE__ */ (0,
|
|
1129
|
+
table.getFilteredRowModel().rows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "text-blue-500 dark:text-blue-400", children: [
|
|
1086
1130
|
" / ",
|
|
1087
1131
|
table.getFilteredRowModel().rows.length,
|
|
1088
1132
|
" total"
|
|
1089
1133
|
] })
|
|
1090
1134
|
] }),
|
|
1091
|
-
/* @__PURE__ */ (0,
|
|
1135
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1092
1136
|
"button",
|
|
1093
1137
|
{
|
|
1094
1138
|
type: "button",
|
|
@@ -1098,28 +1142,34 @@ function LuxTable({
|
|
|
1098
1142
|
}
|
|
1099
1143
|
)
|
|
1100
1144
|
] }),
|
|
1101
|
-
/* @__PURE__ */ (0,
|
|
1102
|
-
/* @__PURE__ */ (0,
|
|
1103
|
-
table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0,
|
|
1145
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "rounded-md border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-950 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Table, { children: [
|
|
1146
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(TableHeader, { children: [
|
|
1147
|
+
table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableRow, { children: headerGroup.headers.map((header) => {
|
|
1104
1148
|
const isSelectionColumn = header.id === "__selection__";
|
|
1105
|
-
return /* @__PURE__ */ (0,
|
|
1149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1106
1150
|
TableHead,
|
|
1107
1151
|
{
|
|
1108
1152
|
style: isSelectionColumn ? { width: 40, padding: "0 12px" } : void 0,
|
|
1109
|
-
children: header.isPlaceholder ? null : (0,
|
|
1153
|
+
children: header.isPlaceholder ? null : isSelectionColumn ? (0, import_react_table2.flexRender)(
|
|
1110
1154
|
header.column.columnDef.header,
|
|
1111
1155
|
header.getContext()
|
|
1156
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1157
|
+
SortableHeader,
|
|
1158
|
+
{
|
|
1159
|
+
header,
|
|
1160
|
+
showSortIndex: enableMultiSort && sorting.length > 1
|
|
1161
|
+
}
|
|
1112
1162
|
)
|
|
1113
1163
|
},
|
|
1114
1164
|
header.id
|
|
1115
1165
|
);
|
|
1116
1166
|
}) }, headerGroup.id)),
|
|
1117
|
-
filteringVisible && /* @__PURE__ */ (0,
|
|
1167
|
+
filteringVisible && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableRow, { className: "bg-slate-50/50 dark:bg-slate-900/50", children: table.getHeaderGroups()[0]?.headers.map((header) => {
|
|
1118
1168
|
const isSelectionColumn = header.id === "__selection__";
|
|
1119
|
-
return /* @__PURE__ */ (0,
|
|
1169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableHead, { className: "py-2", children: !isSelectionColumn && header.column.getCanFilter() ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ColumnFilter, { column: header.column }) : null }, `filter-${header.id}`);
|
|
1120
1170
|
}) })
|
|
1121
1171
|
] }),
|
|
1122
|
-
/* @__PURE__ */ (0,
|
|
1172
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableBody, { children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1123
1173
|
TableRow,
|
|
1124
1174
|
{
|
|
1125
1175
|
"data-state": row.getIsSelected() && "selected",
|
|
@@ -1136,82 +1186,96 @@ function LuxTable({
|
|
|
1136
1186
|
} : void 0,
|
|
1137
1187
|
children: row.getVisibleCells().map((cell) => {
|
|
1138
1188
|
const isSelectionColumn = cell.column.id === "__selection__";
|
|
1139
|
-
return /* @__PURE__ */ (0,
|
|
1189
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1140
1190
|
TableCell,
|
|
1141
1191
|
{
|
|
1142
1192
|
style: isSelectionColumn ? { width: 40, padding: "0 12px" } : void 0,
|
|
1143
1193
|
onClick: isSelectionColumn ? (e) => e.stopPropagation() : void 0,
|
|
1144
|
-
children: (0,
|
|
1194
|
+
children: (0, import_react_table2.flexRender)(cell.column.columnDef.cell, cell.getContext())
|
|
1145
1195
|
},
|
|
1146
1196
|
cell.id
|
|
1147
1197
|
);
|
|
1148
1198
|
})
|
|
1149
1199
|
},
|
|
1150
1200
|
row.id
|
|
1151
|
-
)) : /* @__PURE__ */ (0,
|
|
1201
|
+
)) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableCell, { colSpan: visibleColumnCount, className: "h-24 text-center", children: "No results." }) }) })
|
|
1152
1202
|
] }) }),
|
|
1153
|
-
options?.pagination && /* @__PURE__ */ (0,
|
|
1203
|
+
options?.pagination && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TablePagination, { table })
|
|
1154
1204
|
] });
|
|
1155
1205
|
}
|
|
1156
1206
|
|
|
1157
1207
|
// src/components/lux-table/column-header.tsx
|
|
1158
1208
|
var import_lucide_react8 = require("lucide-react");
|
|
1159
|
-
var
|
|
1209
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1160
1210
|
function LuxDataTableColumnHeader({
|
|
1161
1211
|
column,
|
|
1162
1212
|
title,
|
|
1163
1213
|
className
|
|
1164
1214
|
}) {
|
|
1165
1215
|
const isSorted = column.getIsSorted();
|
|
1166
|
-
|
|
1167
|
-
|
|
1216
|
+
const canSort = column.getCanSort();
|
|
1217
|
+
const SortIndicator = () => {
|
|
1218
|
+
if (isSorted === "desc") {
|
|
1219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react8.ArrowDown, { className: "h-4 w-4 text-blue-600 dark:text-blue-400" });
|
|
1220
|
+
}
|
|
1221
|
+
if (isSorted === "asc") {
|
|
1222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react8.ArrowUp, { className: "h-4 w-4 text-blue-600 dark:text-blue-400" });
|
|
1223
|
+
}
|
|
1224
|
+
if (canSort) {
|
|
1225
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react8.ArrowUpDown, { className: "h-4 w-4 text-slate-400 dark:text-slate-500" });
|
|
1226
|
+
}
|
|
1227
|
+
return null;
|
|
1228
|
+
};
|
|
1229
|
+
if (!canSort) {
|
|
1230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: cn("text-sm font-medium", className), children: title });
|
|
1168
1231
|
}
|
|
1169
|
-
return /* @__PURE__ */ (0,
|
|
1170
|
-
/* @__PURE__ */ (0,
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
size: "sm",
|
|
1175
|
-
className: "-ml-3 h-8 hover:bg-accent",
|
|
1176
|
-
onClick: () => column.toggleSorting(isSorted === "asc"),
|
|
1177
|
-
children: [
|
|
1178
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: title }),
|
|
1179
|
-
isSorted === "desc" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react8.ArrowDown, { className: "ml-1.5 h-4 w-4 text-primary" }) : isSorted === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react8.ArrowUp, { className: "ml-1.5 h-4 w-4 text-primary" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react8.ChevronsUpDown, { className: "ml-1.5 h-4 w-4 text-muted-foreground/50" })
|
|
1180
|
-
]
|
|
1181
|
-
}
|
|
1182
|
-
),
|
|
1183
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(DropdownMenu, { children: [
|
|
1184
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1232
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: cn("flex items-center gap-2", className), children: [
|
|
1233
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SortIndicator, {}),
|
|
1234
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-sm font-medium", children: title }),
|
|
1235
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DropdownMenu, { children: [
|
|
1236
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1185
1237
|
Button,
|
|
1186
1238
|
{
|
|
1187
1239
|
variant: "ghost",
|
|
1188
1240
|
size: "icon",
|
|
1189
|
-
className: "h-6 w-6 opacity-0 group-hover:opacity-100 hover:opacity-100 focus:opacity-100 data-[state=open]:opacity-100 transition-opacity",
|
|
1241
|
+
className: "h-6 w-6 ml-auto opacity-0 group-hover:opacity-100 hover:opacity-100 focus:opacity-100 data-[state=open]:opacity-100 transition-opacity",
|
|
1190
1242
|
children: [
|
|
1191
|
-
/* @__PURE__ */ (0,
|
|
1192
|
-
/* @__PURE__ */ (0,
|
|
1243
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react8.MoreVertical, { className: "h-3.5 w-3.5" }),
|
|
1244
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "sr-only", children: "Column actions" })
|
|
1193
1245
|
]
|
|
1194
1246
|
}
|
|
1195
1247
|
) }),
|
|
1196
|
-
/* @__PURE__ */ (0,
|
|
1197
|
-
/* @__PURE__ */ (0,
|
|
1198
|
-
|
|
1248
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DropdownMenuContent, { align: "end", children: [
|
|
1249
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DropdownMenuItem, { onClick: (e) => {
|
|
1250
|
+
e.stopPropagation();
|
|
1251
|
+
column.toggleSorting(false);
|
|
1252
|
+
}, children: [
|
|
1253
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react8.ArrowUp, { className: "mr-2 h-3.5 w-3.5 text-muted-foreground/70" }),
|
|
1199
1254
|
"Sort Ascending"
|
|
1200
1255
|
] }),
|
|
1201
|
-
/* @__PURE__ */ (0,
|
|
1202
|
-
|
|
1256
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DropdownMenuItem, { onClick: (e) => {
|
|
1257
|
+
e.stopPropagation();
|
|
1258
|
+
column.toggleSorting(true);
|
|
1259
|
+
}, children: [
|
|
1260
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react8.ArrowDown, { className: "mr-2 h-3.5 w-3.5 text-muted-foreground/70" }),
|
|
1203
1261
|
"Sort Descending"
|
|
1204
1262
|
] }),
|
|
1205
|
-
isSorted && /* @__PURE__ */ (0,
|
|
1206
|
-
/* @__PURE__ */ (0,
|
|
1207
|
-
/* @__PURE__ */ (0,
|
|
1208
|
-
|
|
1263
|
+
isSorted && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
1264
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DropdownMenuSeparator, {}),
|
|
1265
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DropdownMenuItem, { onClick: (e) => {
|
|
1266
|
+
e.stopPropagation();
|
|
1267
|
+
column.clearSorting();
|
|
1268
|
+
}, children: [
|
|
1269
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react8.X, { className: "mr-2 h-3.5 w-3.5 text-muted-foreground/70" }),
|
|
1209
1270
|
"Clear sorting"
|
|
1210
1271
|
] })
|
|
1211
1272
|
] }),
|
|
1212
|
-
/* @__PURE__ */ (0,
|
|
1213
|
-
/* @__PURE__ */ (0,
|
|
1214
|
-
|
|
1273
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DropdownMenuSeparator, {}),
|
|
1274
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DropdownMenuItem, { onClick: (e) => {
|
|
1275
|
+
e.stopPropagation();
|
|
1276
|
+
column.toggleVisibility(false);
|
|
1277
|
+
}, children: [
|
|
1278
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react8.EyeOff, { className: "mr-2 h-3.5 w-3.5 text-muted-foreground/70" }),
|
|
1215
1279
|
"Hide column"
|
|
1216
1280
|
] })
|
|
1217
1281
|
] })
|
|
@@ -1220,7 +1284,7 @@ function LuxDataTableColumnHeader({
|
|
|
1220
1284
|
}
|
|
1221
1285
|
|
|
1222
1286
|
// src/components/cell-renderers/status-cell.tsx
|
|
1223
|
-
var
|
|
1287
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1224
1288
|
var defaultStatusColors = {
|
|
1225
1289
|
Active: {
|
|
1226
1290
|
bg: "bg-green-100",
|
|
@@ -1257,14 +1321,14 @@ function StatusCell({ value, colors, className }) {
|
|
|
1257
1321
|
const mergedColors = { ...defaultStatusColors, ...colors };
|
|
1258
1322
|
const colorConfig = mergedColors[value];
|
|
1259
1323
|
if (!colorConfig) {
|
|
1260
|
-
return /* @__PURE__ */ (0,
|
|
1324
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300 ${className || ""}`, children: value });
|
|
1261
1325
|
}
|
|
1262
1326
|
const { bg, text, darkBg, darkText } = colorConfig;
|
|
1263
|
-
return /* @__PURE__ */ (0,
|
|
1327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `px-2 py-1 rounded-full text-xs font-medium ${bg} ${text} ${darkBg || ""} ${darkText || ""} ${className || ""}`, children: value });
|
|
1264
1328
|
}
|
|
1265
1329
|
|
|
1266
1330
|
// src/components/cell-renderers/progress-cell.tsx
|
|
1267
|
-
var
|
|
1331
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1268
1332
|
function ProgressCell({
|
|
1269
1333
|
value,
|
|
1270
1334
|
barColor = "bg-blue-600",
|
|
@@ -1273,15 +1337,15 @@ function ProgressCell({
|
|
|
1273
1337
|
className
|
|
1274
1338
|
}) {
|
|
1275
1339
|
const clampedValue = Math.min(100, Math.max(0, value));
|
|
1276
|
-
return /* @__PURE__ */ (0,
|
|
1277
|
-
/* @__PURE__ */ (0,
|
|
1340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `flex items-center gap-2 ${className || ""}`, children: [
|
|
1341
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: `w-full rounded-full h-2.5 ${bgColor}`, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1278
1342
|
"div",
|
|
1279
1343
|
{
|
|
1280
1344
|
className: `${barColor} h-2.5 rounded-full transition-all`,
|
|
1281
1345
|
style: { width: `${clampedValue}%` }
|
|
1282
1346
|
}
|
|
1283
1347
|
) }),
|
|
1284
|
-
showLabel && /* @__PURE__ */ (0,
|
|
1348
|
+
showLabel && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "text-xs text-gray-500 dark:text-gray-400 w-8", children: [
|
|
1285
1349
|
value,
|
|
1286
1350
|
"%"
|
|
1287
1351
|
] })
|
|
@@ -1289,7 +1353,7 @@ function ProgressCell({
|
|
|
1289
1353
|
}
|
|
1290
1354
|
|
|
1291
1355
|
// src/components/cell-renderers/boolean-cell.tsx
|
|
1292
|
-
var
|
|
1356
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1293
1357
|
function BooleanCell({
|
|
1294
1358
|
value,
|
|
1295
1359
|
trueLabel = "Yes",
|
|
@@ -1297,15 +1361,15 @@ function BooleanCell({
|
|
|
1297
1361
|
trueColor = "text-green-600 dark:text-green-400",
|
|
1298
1362
|
falseColor = "text-red-600 dark:text-red-400"
|
|
1299
1363
|
}) {
|
|
1300
|
-
return /* @__PURE__ */ (0,
|
|
1364
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: `font-medium ${value ? trueColor : falseColor}`, children: value ? trueLabel : falseLabel });
|
|
1301
1365
|
}
|
|
1302
1366
|
|
|
1303
1367
|
// src/components/cell-renderers/date-cell.tsx
|
|
1304
|
-
var
|
|
1368
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1305
1369
|
function DateCell({ value, format = "short", locale = "en-US" }) {
|
|
1306
1370
|
const date = typeof value === "string" ? new Date(value) : value;
|
|
1307
1371
|
if (isNaN(date.getTime())) {
|
|
1308
|
-
return /* @__PURE__ */ (0,
|
|
1372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-gray-400", children: "-" });
|
|
1309
1373
|
}
|
|
1310
1374
|
let formatted;
|
|
1311
1375
|
switch (format) {
|
|
@@ -1329,23 +1393,23 @@ function DateCell({ value, format = "short", locale = "en-US" }) {
|
|
|
1329
1393
|
default:
|
|
1330
1394
|
formatted = date.toLocaleDateString(locale);
|
|
1331
1395
|
}
|
|
1332
|
-
return /* @__PURE__ */ (0,
|
|
1396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: formatted });
|
|
1333
1397
|
}
|
|
1334
1398
|
|
|
1335
1399
|
// src/components/cell-renderers/currency-cell.tsx
|
|
1336
|
-
var
|
|
1400
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1337
1401
|
function CurrencyCell({ value, currency = "TRY", locale = "tr-TR" }) {
|
|
1338
1402
|
const formatted = new Intl.NumberFormat(locale, {
|
|
1339
1403
|
style: "currency",
|
|
1340
1404
|
currency
|
|
1341
1405
|
}).format(value);
|
|
1342
|
-
return /* @__PURE__ */ (0,
|
|
1406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "font-medium", children: formatted });
|
|
1343
1407
|
}
|
|
1344
1408
|
|
|
1345
1409
|
// src/components/cell-renderers/copyable-cell.tsx
|
|
1346
1410
|
var React8 = __toESM(require("react"));
|
|
1347
1411
|
var import_lucide_react9 = require("lucide-react");
|
|
1348
|
-
var
|
|
1412
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1349
1413
|
function CopyableCell({
|
|
1350
1414
|
value,
|
|
1351
1415
|
feedbackDuration = 2e3,
|
|
@@ -1370,7 +1434,7 @@ function CopyableCell({
|
|
|
1370
1434
|
console.error("Copy error:", err);
|
|
1371
1435
|
}
|
|
1372
1436
|
};
|
|
1373
|
-
return /* @__PURE__ */ (0,
|
|
1437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
1374
1438
|
"button",
|
|
1375
1439
|
{
|
|
1376
1440
|
type: "button",
|
|
@@ -1389,8 +1453,8 @@ function CopyableCell({
|
|
|
1389
1453
|
${className || ""}
|
|
1390
1454
|
`,
|
|
1391
1455
|
children: [
|
|
1392
|
-
/* @__PURE__ */ (0,
|
|
1393
|
-
/* @__PURE__ */ (0,
|
|
1456
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "select-none", children: value }),
|
|
1457
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1394
1458
|
"span",
|
|
1395
1459
|
{
|
|
1396
1460
|
className: `
|
|
@@ -1398,7 +1462,7 @@ function CopyableCell({
|
|
|
1398
1462
|
transition-all duration-200
|
|
1399
1463
|
${alwaysShowIcon || isHovered || copied ? "opacity-100" : "opacity-0"}
|
|
1400
1464
|
`,
|
|
1401
|
-
children: copied ? /* @__PURE__ */ (0,
|
|
1465
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react9.Check, { className: "h-3.5 w-3.5 text-green-600 dark:text-green-400" }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react9.Copy, { className: "h-3.5 w-3.5 text-slate-400 dark:text-slate-500 group-hover:text-slate-600 dark:group-hover:text-slate-300" })
|
|
1402
1466
|
}
|
|
1403
1467
|
)
|
|
1404
1468
|
]
|
|
@@ -1406,18 +1470,18 @@ function CopyableCell({
|
|
|
1406
1470
|
);
|
|
1407
1471
|
}
|
|
1408
1472
|
function createCopyableCell(value, options) {
|
|
1409
|
-
return /* @__PURE__ */ (0,
|
|
1473
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CopyableCell, { value, ...options });
|
|
1410
1474
|
}
|
|
1411
1475
|
|
|
1412
1476
|
// src/components/ui/label.tsx
|
|
1413
1477
|
var React9 = __toESM(require("react"));
|
|
1414
1478
|
var LabelPrimitive = __toESM(require("@radix-ui/react-label"));
|
|
1415
1479
|
var import_class_variance_authority2 = require("class-variance-authority");
|
|
1416
|
-
var
|
|
1480
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1417
1481
|
var labelVariants = (0, import_class_variance_authority2.cva)(
|
|
1418
1482
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
1419
1483
|
);
|
|
1420
|
-
var Label3 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1484
|
+
var Label3 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1421
1485
|
LabelPrimitive.Root,
|
|
1422
1486
|
{
|
|
1423
1487
|
ref,
|
|
@@ -1430,11 +1494,11 @@ Label3.displayName = LabelPrimitive.Root.displayName;
|
|
|
1430
1494
|
// src/components/ui/popover.tsx
|
|
1431
1495
|
var React10 = __toESM(require("react"));
|
|
1432
1496
|
var PopoverPrimitive = __toESM(require("@radix-ui/react-popover"));
|
|
1433
|
-
var
|
|
1497
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1434
1498
|
var Popover = PopoverPrimitive.Root;
|
|
1435
1499
|
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
1436
1500
|
var PopoverAnchor = PopoverPrimitive.Anchor;
|
|
1437
|
-
var PopoverContent = React10.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1501
|
+
var PopoverContent = React10.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PopoverPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1438
1502
|
PopoverPrimitive.Content,
|
|
1439
1503
|
{
|
|
1440
1504
|
ref,
|
|
@@ -1452,9 +1516,9 @@ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
|
1452
1516
|
// src/components/ui/separator.tsx
|
|
1453
1517
|
var React11 = __toESM(require("react"));
|
|
1454
1518
|
var SeparatorPrimitive = __toESM(require("@radix-ui/react-separator"));
|
|
1455
|
-
var
|
|
1519
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1456
1520
|
var Separator3 = React11.forwardRef(
|
|
1457
|
-
({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1521
|
+
({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1458
1522
|
SeparatorPrimitive.Root,
|
|
1459
1523
|
{
|
|
1460
1524
|
ref,
|
|
@@ -1472,13 +1536,13 @@ var Separator3 = React11.forwardRef(
|
|
|
1472
1536
|
Separator3.displayName = SeparatorPrimitive.Root.displayName;
|
|
1473
1537
|
|
|
1474
1538
|
// src/lib/column-helper.tsx
|
|
1475
|
-
var
|
|
1476
|
-
var
|
|
1539
|
+
var import_react_table3 = require("@tanstack/react-table");
|
|
1540
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1477
1541
|
var toTitleCase = (str) => {
|
|
1478
1542
|
return str.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()).trim();
|
|
1479
1543
|
};
|
|
1480
1544
|
function createColumnHelper() {
|
|
1481
|
-
const helper = (0,
|
|
1545
|
+
const helper = (0, import_react_table3.createColumnHelper)();
|
|
1482
1546
|
return {
|
|
1483
1547
|
/**
|
|
1484
1548
|
* Simple accessor - if cell is not provided, value is rendered automatically
|
|
@@ -1492,7 +1556,7 @@ function createColumnHelper() {
|
|
|
1492
1556
|
// Pass meta information (filterVariant etc.)
|
|
1493
1557
|
meta: column?.meta,
|
|
1494
1558
|
// Use LuxDataTableColumnHeader if header is string or undefined
|
|
1495
|
-
header: typeof headerContent === "function" ? headerContent : ({ column: colParam }) => /* @__PURE__ */ (0,
|
|
1559
|
+
header: typeof headerContent === "function" ? headerContent : ({ column: colParam }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1496
1560
|
LuxDataTableColumnHeader,
|
|
1497
1561
|
{
|
|
1498
1562
|
column: colParam,
|
|
@@ -1536,7 +1600,7 @@ function createColumnHelper() {
|
|
|
1536
1600
|
auto: (columns) => {
|
|
1537
1601
|
return columns.map((col) => {
|
|
1538
1602
|
return helper.accessor(col.accessor, {
|
|
1539
|
-
header: ({ column }) => /* @__PURE__ */ (0,
|
|
1603
|
+
header: ({ column }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LuxDataTableColumnHeader, { column, title: col.header }),
|
|
1540
1604
|
cell: col.cell || ((info) => {
|
|
1541
1605
|
const value = info.getValue();
|
|
1542
1606
|
if (value === null || value === void 0) return "-";
|
|
@@ -1549,7 +1613,7 @@ function createColumnHelper() {
|
|
|
1549
1613
|
}
|
|
1550
1614
|
function createColumnsFromData(data, options) {
|
|
1551
1615
|
if (!data || data.length === 0) return [];
|
|
1552
|
-
const helper = (0,
|
|
1616
|
+
const helper = (0, import_react_table3.createColumnHelper)();
|
|
1553
1617
|
const firstRow = data[0];
|
|
1554
1618
|
let keys = Object.keys(firstRow);
|
|
1555
1619
|
if (options?.include) {
|
|
@@ -1562,7 +1626,7 @@ function createColumnsFromData(data, options) {
|
|
|
1562
1626
|
const headerText = options?.headers?.[key] || toTitleCase(key);
|
|
1563
1627
|
const cellRenderer = options?.cells?.[key];
|
|
1564
1628
|
return helper.accessor(key, {
|
|
1565
|
-
header: ({ column }) => /* @__PURE__ */ (0,
|
|
1629
|
+
header: ({ column }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LuxDataTableColumnHeader, { column, title: headerText }),
|
|
1566
1630
|
cell: cellRenderer || ((info) => {
|
|
1567
1631
|
const value = info.getValue();
|
|
1568
1632
|
if (value === null || value === void 0) return "-";
|
|
@@ -1573,7 +1637,7 @@ function createColumnsFromData(data, options) {
|
|
|
1573
1637
|
}
|
|
1574
1638
|
|
|
1575
1639
|
// src/index.ts
|
|
1576
|
-
var
|
|
1640
|
+
var import_react_table4 = require("@tanstack/react-table");
|
|
1577
1641
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1578
1642
|
0 && (module.exports = {
|
|
1579
1643
|
BooleanCell,
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/components/lux-table/lux-table.tsx
|
|
2
2
|
import * as React7 from "react";
|
|
3
3
|
import {
|
|
4
|
-
flexRender,
|
|
4
|
+
flexRender as flexRender2,
|
|
5
5
|
getCoreRowModel,
|
|
6
6
|
useReactTable,
|
|
7
7
|
getPaginationRowModel,
|
|
@@ -840,15 +840,51 @@ function TableToolbar({
|
|
|
840
840
|
);
|
|
841
841
|
}
|
|
842
842
|
|
|
843
|
+
// src/components/lux-table/sortable-header.tsx
|
|
844
|
+
import { flexRender } from "@tanstack/react-table";
|
|
845
|
+
import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
846
|
+
function SortableHeader({
|
|
847
|
+
header,
|
|
848
|
+
showSortIndex = false
|
|
849
|
+
}) {
|
|
850
|
+
const column = header.column;
|
|
851
|
+
const canSort = column.getCanSort();
|
|
852
|
+
const isSorted = column.getIsSorted();
|
|
853
|
+
const sortIndex = column.getSortIndex();
|
|
854
|
+
const headerContent = header.isPlaceholder ? null : flexRender(column.columnDef.header, header.getContext());
|
|
855
|
+
if (!canSort) {
|
|
856
|
+
return /* @__PURE__ */ jsx10(Fragment2, { children: headerContent });
|
|
857
|
+
}
|
|
858
|
+
return /* @__PURE__ */ jsxs6(
|
|
859
|
+
"button",
|
|
860
|
+
{
|
|
861
|
+
type: "button",
|
|
862
|
+
className: cn(
|
|
863
|
+
"flex items-center gap-1.5 w-full text-left font-medium group",
|
|
864
|
+
"hover:text-slate-900 dark:hover:text-slate-100",
|
|
865
|
+
"transition-colors duration-150",
|
|
866
|
+
"-ml-2 px-2 py-1 rounded-md",
|
|
867
|
+
"hover:bg-slate-100 dark:hover:bg-slate-800",
|
|
868
|
+
isSorted && "text-blue-600 dark:text-blue-400"
|
|
869
|
+
),
|
|
870
|
+
onClick: header.column.getToggleSortingHandler(),
|
|
871
|
+
children: [
|
|
872
|
+
headerContent,
|
|
873
|
+
showSortIndex && isSorted && sortIndex > 0 && /* @__PURE__ */ jsx10("span", { className: "ml-0.5 text-[10px] font-bold text-blue-500 dark:text-blue-400 bg-blue-100 dark:bg-blue-900/50 rounded-full w-4 h-4 flex items-center justify-center", children: sortIndex + 1 })
|
|
874
|
+
]
|
|
875
|
+
}
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
|
|
843
879
|
// src/components/ui/checkbox.tsx
|
|
844
880
|
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
845
881
|
import { CheckIcon } from "lucide-react";
|
|
846
|
-
import { jsx as
|
|
882
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
847
883
|
function Checkbox({
|
|
848
884
|
className,
|
|
849
885
|
...props
|
|
850
886
|
}) {
|
|
851
|
-
return /* @__PURE__ */
|
|
887
|
+
return /* @__PURE__ */ jsx11(
|
|
852
888
|
CheckboxPrimitive.Root,
|
|
853
889
|
{
|
|
854
890
|
"data-slot": "checkbox",
|
|
@@ -857,12 +893,12 @@ function Checkbox({
|
|
|
857
893
|
className
|
|
858
894
|
),
|
|
859
895
|
...props,
|
|
860
|
-
children: /* @__PURE__ */
|
|
896
|
+
children: /* @__PURE__ */ jsx11(
|
|
861
897
|
CheckboxPrimitive.Indicator,
|
|
862
898
|
{
|
|
863
899
|
"data-slot": "checkbox-indicator",
|
|
864
900
|
className: "grid place-content-center text-current transition-none",
|
|
865
|
-
children: /* @__PURE__ */
|
|
901
|
+
children: /* @__PURE__ */ jsx11(CheckIcon, { className: "size-3.5" })
|
|
866
902
|
}
|
|
867
903
|
)
|
|
868
904
|
}
|
|
@@ -870,11 +906,11 @@ function Checkbox({
|
|
|
870
906
|
}
|
|
871
907
|
|
|
872
908
|
// src/components/lux-table/lux-table.tsx
|
|
873
|
-
import { jsx as
|
|
909
|
+
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
874
910
|
function createSelectionColumn() {
|
|
875
911
|
return {
|
|
876
912
|
id: "__selection__",
|
|
877
|
-
header: ({ table }) => /* @__PURE__ */
|
|
913
|
+
header: ({ table }) => /* @__PURE__ */ jsx12(
|
|
878
914
|
Checkbox,
|
|
879
915
|
{
|
|
880
916
|
checked: table.getIsAllPageRowsSelected() || table.getIsSomePageRowsSelected() && "indeterminate",
|
|
@@ -882,7 +918,7 @@ function createSelectionColumn() {
|
|
|
882
918
|
"aria-label": "Select all rows"
|
|
883
919
|
}
|
|
884
920
|
),
|
|
885
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
921
|
+
cell: ({ row }) => /* @__PURE__ */ jsx12(
|
|
886
922
|
Checkbox,
|
|
887
923
|
{
|
|
888
924
|
checked: row.getIsSelected(),
|
|
@@ -938,9 +974,17 @@ function LuxTable({
|
|
|
938
974
|
},
|
|
939
975
|
[isControlledRowSelection, onRowSelectionChange, rowSelection]
|
|
940
976
|
);
|
|
977
|
+
const enableSorting = options?.sorting !== false;
|
|
978
|
+
const enableMultiSort = options?.multiSort !== false;
|
|
941
979
|
const table = useReactTable({
|
|
942
980
|
data,
|
|
943
981
|
columns: tableColumns,
|
|
982
|
+
enableSorting,
|
|
983
|
+
enableMultiSort,
|
|
984
|
+
// Shift+Click for multi-sort (default behavior)
|
|
985
|
+
isMultiSortEvent: (e) => e.shiftKey,
|
|
986
|
+
// Max columns for multi-sort (undefined = unlimited)
|
|
987
|
+
maxMultiSortColCount: options?.maxMultiSortColCount,
|
|
944
988
|
state: {
|
|
945
989
|
sorting,
|
|
946
990
|
columnFilters,
|
|
@@ -987,8 +1031,8 @@ function LuxTable({
|
|
|
987
1031
|
const showToolbar = options?.showToolbar ?? false;
|
|
988
1032
|
const showGlobalSearch = options?.showGlobalSearch ?? true;
|
|
989
1033
|
const showColumnVisibility = options?.showColumnVisibility ?? true;
|
|
990
|
-
return /* @__PURE__ */
|
|
991
|
-
showToolbar && /* @__PURE__ */
|
|
1034
|
+
return /* @__PURE__ */ jsxs7("div", { className: cn("w-full space-y-4", className), children: [
|
|
1035
|
+
showToolbar && /* @__PURE__ */ jsx12(
|
|
992
1036
|
TableToolbar,
|
|
993
1037
|
{
|
|
994
1038
|
table,
|
|
@@ -999,18 +1043,18 @@ function LuxTable({
|
|
|
999
1043
|
showColumnVisibility
|
|
1000
1044
|
}
|
|
1001
1045
|
),
|
|
1002
|
-
enableRowSelection && Object.keys(rowSelection).length > 0 && /* @__PURE__ */
|
|
1003
|
-
/* @__PURE__ */
|
|
1004
|
-
/* @__PURE__ */
|
|
1005
|
-
/* @__PURE__ */
|
|
1046
|
+
enableRowSelection && Object.keys(rowSelection).length > 0 && /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2 px-4 py-2 text-sm bg-blue-50 dark:bg-blue-950/50 text-blue-700 dark:text-blue-300 rounded-lg border border-blue-200 dark:border-blue-800", children: [
|
|
1047
|
+
/* @__PURE__ */ jsx12(CheckCircle2, { className: "w-4 h-4" }),
|
|
1048
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
1049
|
+
/* @__PURE__ */ jsx12("strong", { children: Object.keys(rowSelection).length }),
|
|
1006
1050
|
" rows selected",
|
|
1007
|
-
table.getFilteredRowModel().rows.length > 0 && /* @__PURE__ */
|
|
1051
|
+
table.getFilteredRowModel().rows.length > 0 && /* @__PURE__ */ jsxs7("span", { className: "text-blue-500 dark:text-blue-400", children: [
|
|
1008
1052
|
" / ",
|
|
1009
1053
|
table.getFilteredRowModel().rows.length,
|
|
1010
1054
|
" total"
|
|
1011
1055
|
] })
|
|
1012
1056
|
] }),
|
|
1013
|
-
/* @__PURE__ */
|
|
1057
|
+
/* @__PURE__ */ jsx12(
|
|
1014
1058
|
"button",
|
|
1015
1059
|
{
|
|
1016
1060
|
type: "button",
|
|
@@ -1020,28 +1064,34 @@ function LuxTable({
|
|
|
1020
1064
|
}
|
|
1021
1065
|
)
|
|
1022
1066
|
] }),
|
|
1023
|
-
/* @__PURE__ */
|
|
1024
|
-
/* @__PURE__ */
|
|
1025
|
-
table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */
|
|
1067
|
+
/* @__PURE__ */ jsx12("div", { className: "rounded-md border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-950 overflow-hidden", children: /* @__PURE__ */ jsxs7(Table, { children: [
|
|
1068
|
+
/* @__PURE__ */ jsxs7(TableHeader, { children: [
|
|
1069
|
+
table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx12(TableRow, { children: headerGroup.headers.map((header) => {
|
|
1026
1070
|
const isSelectionColumn = header.id === "__selection__";
|
|
1027
|
-
return /* @__PURE__ */
|
|
1071
|
+
return /* @__PURE__ */ jsx12(
|
|
1028
1072
|
TableHead,
|
|
1029
1073
|
{
|
|
1030
1074
|
style: isSelectionColumn ? { width: 40, padding: "0 12px" } : void 0,
|
|
1031
|
-
children: header.isPlaceholder ? null :
|
|
1075
|
+
children: header.isPlaceholder ? null : isSelectionColumn ? flexRender2(
|
|
1032
1076
|
header.column.columnDef.header,
|
|
1033
1077
|
header.getContext()
|
|
1078
|
+
) : /* @__PURE__ */ jsx12(
|
|
1079
|
+
SortableHeader,
|
|
1080
|
+
{
|
|
1081
|
+
header,
|
|
1082
|
+
showSortIndex: enableMultiSort && sorting.length > 1
|
|
1083
|
+
}
|
|
1034
1084
|
)
|
|
1035
1085
|
},
|
|
1036
1086
|
header.id
|
|
1037
1087
|
);
|
|
1038
1088
|
}) }, headerGroup.id)),
|
|
1039
|
-
filteringVisible && /* @__PURE__ */
|
|
1089
|
+
filteringVisible && /* @__PURE__ */ jsx12(TableRow, { className: "bg-slate-50/50 dark:bg-slate-900/50", children: table.getHeaderGroups()[0]?.headers.map((header) => {
|
|
1040
1090
|
const isSelectionColumn = header.id === "__selection__";
|
|
1041
|
-
return /* @__PURE__ */
|
|
1091
|
+
return /* @__PURE__ */ jsx12(TableHead, { className: "py-2", children: !isSelectionColumn && header.column.getCanFilter() ? /* @__PURE__ */ jsx12(ColumnFilter, { column: header.column }) : null }, `filter-${header.id}`);
|
|
1042
1092
|
}) })
|
|
1043
1093
|
] }),
|
|
1044
|
-
/* @__PURE__ */
|
|
1094
|
+
/* @__PURE__ */ jsx12(TableBody, { children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx12(
|
|
1045
1095
|
TableRow,
|
|
1046
1096
|
{
|
|
1047
1097
|
"data-state": row.getIsSelected() && "selected",
|
|
@@ -1058,21 +1108,21 @@ function LuxTable({
|
|
|
1058
1108
|
} : void 0,
|
|
1059
1109
|
children: row.getVisibleCells().map((cell) => {
|
|
1060
1110
|
const isSelectionColumn = cell.column.id === "__selection__";
|
|
1061
|
-
return /* @__PURE__ */
|
|
1111
|
+
return /* @__PURE__ */ jsx12(
|
|
1062
1112
|
TableCell,
|
|
1063
1113
|
{
|
|
1064
1114
|
style: isSelectionColumn ? { width: 40, padding: "0 12px" } : void 0,
|
|
1065
1115
|
onClick: isSelectionColumn ? (e) => e.stopPropagation() : void 0,
|
|
1066
|
-
children:
|
|
1116
|
+
children: flexRender2(cell.column.columnDef.cell, cell.getContext())
|
|
1067
1117
|
},
|
|
1068
1118
|
cell.id
|
|
1069
1119
|
);
|
|
1070
1120
|
})
|
|
1071
1121
|
},
|
|
1072
1122
|
row.id
|
|
1073
|
-
)) : /* @__PURE__ */
|
|
1123
|
+
)) : /* @__PURE__ */ jsx12(TableRow, { children: /* @__PURE__ */ jsx12(TableCell, { colSpan: visibleColumnCount, className: "h-24 text-center", children: "No results." }) }) })
|
|
1074
1124
|
] }) }),
|
|
1075
|
-
options?.pagination && /* @__PURE__ */
|
|
1125
|
+
options?.pagination && /* @__PURE__ */ jsx12(TablePagination, { table })
|
|
1076
1126
|
] });
|
|
1077
1127
|
}
|
|
1078
1128
|
|
|
@@ -1080,67 +1130,81 @@ function LuxTable({
|
|
|
1080
1130
|
import {
|
|
1081
1131
|
ArrowDown,
|
|
1082
1132
|
ArrowUp,
|
|
1083
|
-
|
|
1133
|
+
ArrowUpDown,
|
|
1084
1134
|
EyeOff as EyeOff2,
|
|
1085
1135
|
MoreVertical,
|
|
1086
1136
|
X
|
|
1087
1137
|
} from "lucide-react";
|
|
1088
|
-
import { Fragment as
|
|
1138
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1089
1139
|
function LuxDataTableColumnHeader({
|
|
1090
1140
|
column,
|
|
1091
1141
|
title,
|
|
1092
1142
|
className
|
|
1093
1143
|
}) {
|
|
1094
1144
|
const isSorted = column.getIsSorted();
|
|
1095
|
-
|
|
1096
|
-
|
|
1145
|
+
const canSort = column.getCanSort();
|
|
1146
|
+
const SortIndicator = () => {
|
|
1147
|
+
if (isSorted === "desc") {
|
|
1148
|
+
return /* @__PURE__ */ jsx13(ArrowDown, { className: "h-4 w-4 text-blue-600 dark:text-blue-400" });
|
|
1149
|
+
}
|
|
1150
|
+
if (isSorted === "asc") {
|
|
1151
|
+
return /* @__PURE__ */ jsx13(ArrowUp, { className: "h-4 w-4 text-blue-600 dark:text-blue-400" });
|
|
1152
|
+
}
|
|
1153
|
+
if (canSort) {
|
|
1154
|
+
return /* @__PURE__ */ jsx13(ArrowUpDown, { className: "h-4 w-4 text-slate-400 dark:text-slate-500" });
|
|
1155
|
+
}
|
|
1156
|
+
return null;
|
|
1157
|
+
};
|
|
1158
|
+
if (!canSort) {
|
|
1159
|
+
return /* @__PURE__ */ jsx13("span", { className: cn("text-sm font-medium", className), children: title });
|
|
1097
1160
|
}
|
|
1098
|
-
return /* @__PURE__ */
|
|
1099
|
-
/* @__PURE__ */
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
size: "sm",
|
|
1104
|
-
className: "-ml-3 h-8 hover:bg-accent",
|
|
1105
|
-
onClick: () => column.toggleSorting(isSorted === "asc"),
|
|
1106
|
-
children: [
|
|
1107
|
-
/* @__PURE__ */ jsx12("span", { children: title }),
|
|
1108
|
-
isSorted === "desc" ? /* @__PURE__ */ jsx12(ArrowDown, { className: "ml-1.5 h-4 w-4 text-primary" }) : isSorted === "asc" ? /* @__PURE__ */ jsx12(ArrowUp, { className: "ml-1.5 h-4 w-4 text-primary" }) : /* @__PURE__ */ jsx12(ChevronsUpDown2, { className: "ml-1.5 h-4 w-4 text-muted-foreground/50" })
|
|
1109
|
-
]
|
|
1110
|
-
}
|
|
1111
|
-
),
|
|
1112
|
-
/* @__PURE__ */ jsxs7(DropdownMenu, { children: [
|
|
1113
|
-
/* @__PURE__ */ jsx12(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs7(
|
|
1161
|
+
return /* @__PURE__ */ jsxs8("div", { className: cn("flex items-center gap-2", className), children: [
|
|
1162
|
+
/* @__PURE__ */ jsx13(SortIndicator, {}),
|
|
1163
|
+
/* @__PURE__ */ jsx13("span", { className: "text-sm font-medium", children: title }),
|
|
1164
|
+
/* @__PURE__ */ jsxs8(DropdownMenu, { children: [
|
|
1165
|
+
/* @__PURE__ */ jsx13(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs8(
|
|
1114
1166
|
Button,
|
|
1115
1167
|
{
|
|
1116
1168
|
variant: "ghost",
|
|
1117
1169
|
size: "icon",
|
|
1118
|
-
className: "h-6 w-6 opacity-0 group-hover:opacity-100 hover:opacity-100 focus:opacity-100 data-[state=open]:opacity-100 transition-opacity",
|
|
1170
|
+
className: "h-6 w-6 ml-auto opacity-0 group-hover:opacity-100 hover:opacity-100 focus:opacity-100 data-[state=open]:opacity-100 transition-opacity",
|
|
1119
1171
|
children: [
|
|
1120
|
-
/* @__PURE__ */
|
|
1121
|
-
/* @__PURE__ */
|
|
1172
|
+
/* @__PURE__ */ jsx13(MoreVertical, { className: "h-3.5 w-3.5" }),
|
|
1173
|
+
/* @__PURE__ */ jsx13("span", { className: "sr-only", children: "Column actions" })
|
|
1122
1174
|
]
|
|
1123
1175
|
}
|
|
1124
1176
|
) }),
|
|
1125
|
-
/* @__PURE__ */
|
|
1126
|
-
/* @__PURE__ */
|
|
1127
|
-
|
|
1177
|
+
/* @__PURE__ */ jsxs8(DropdownMenuContent, { align: "end", children: [
|
|
1178
|
+
/* @__PURE__ */ jsxs8(DropdownMenuItem, { onClick: (e) => {
|
|
1179
|
+
e.stopPropagation();
|
|
1180
|
+
column.toggleSorting(false);
|
|
1181
|
+
}, children: [
|
|
1182
|
+
/* @__PURE__ */ jsx13(ArrowUp, { className: "mr-2 h-3.5 w-3.5 text-muted-foreground/70" }),
|
|
1128
1183
|
"Sort Ascending"
|
|
1129
1184
|
] }),
|
|
1130
|
-
/* @__PURE__ */
|
|
1131
|
-
|
|
1185
|
+
/* @__PURE__ */ jsxs8(DropdownMenuItem, { onClick: (e) => {
|
|
1186
|
+
e.stopPropagation();
|
|
1187
|
+
column.toggleSorting(true);
|
|
1188
|
+
}, children: [
|
|
1189
|
+
/* @__PURE__ */ jsx13(ArrowDown, { className: "mr-2 h-3.5 w-3.5 text-muted-foreground/70" }),
|
|
1132
1190
|
"Sort Descending"
|
|
1133
1191
|
] }),
|
|
1134
|
-
isSorted && /* @__PURE__ */
|
|
1135
|
-
/* @__PURE__ */
|
|
1136
|
-
/* @__PURE__ */
|
|
1137
|
-
|
|
1192
|
+
isSorted && /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
1193
|
+
/* @__PURE__ */ jsx13(DropdownMenuSeparator, {}),
|
|
1194
|
+
/* @__PURE__ */ jsxs8(DropdownMenuItem, { onClick: (e) => {
|
|
1195
|
+
e.stopPropagation();
|
|
1196
|
+
column.clearSorting();
|
|
1197
|
+
}, children: [
|
|
1198
|
+
/* @__PURE__ */ jsx13(X, { className: "mr-2 h-3.5 w-3.5 text-muted-foreground/70" }),
|
|
1138
1199
|
"Clear sorting"
|
|
1139
1200
|
] })
|
|
1140
1201
|
] }),
|
|
1141
|
-
/* @__PURE__ */
|
|
1142
|
-
/* @__PURE__ */
|
|
1143
|
-
|
|
1202
|
+
/* @__PURE__ */ jsx13(DropdownMenuSeparator, {}),
|
|
1203
|
+
/* @__PURE__ */ jsxs8(DropdownMenuItem, { onClick: (e) => {
|
|
1204
|
+
e.stopPropagation();
|
|
1205
|
+
column.toggleVisibility(false);
|
|
1206
|
+
}, children: [
|
|
1207
|
+
/* @__PURE__ */ jsx13(EyeOff2, { className: "mr-2 h-3.5 w-3.5 text-muted-foreground/70" }),
|
|
1144
1208
|
"Hide column"
|
|
1145
1209
|
] })
|
|
1146
1210
|
] })
|
|
@@ -1149,7 +1213,7 @@ function LuxDataTableColumnHeader({
|
|
|
1149
1213
|
}
|
|
1150
1214
|
|
|
1151
1215
|
// src/components/cell-renderers/status-cell.tsx
|
|
1152
|
-
import { jsx as
|
|
1216
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1153
1217
|
var defaultStatusColors = {
|
|
1154
1218
|
Active: {
|
|
1155
1219
|
bg: "bg-green-100",
|
|
@@ -1186,14 +1250,14 @@ function StatusCell({ value, colors, className }) {
|
|
|
1186
1250
|
const mergedColors = { ...defaultStatusColors, ...colors };
|
|
1187
1251
|
const colorConfig = mergedColors[value];
|
|
1188
1252
|
if (!colorConfig) {
|
|
1189
|
-
return /* @__PURE__ */
|
|
1253
|
+
return /* @__PURE__ */ jsx14("span", { className: `px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300 ${className || ""}`, children: value });
|
|
1190
1254
|
}
|
|
1191
1255
|
const { bg, text, darkBg, darkText } = colorConfig;
|
|
1192
|
-
return /* @__PURE__ */
|
|
1256
|
+
return /* @__PURE__ */ jsx14("span", { className: `px-2 py-1 rounded-full text-xs font-medium ${bg} ${text} ${darkBg || ""} ${darkText || ""} ${className || ""}`, children: value });
|
|
1193
1257
|
}
|
|
1194
1258
|
|
|
1195
1259
|
// src/components/cell-renderers/progress-cell.tsx
|
|
1196
|
-
import { jsx as
|
|
1260
|
+
import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1197
1261
|
function ProgressCell({
|
|
1198
1262
|
value,
|
|
1199
1263
|
barColor = "bg-blue-600",
|
|
@@ -1202,15 +1266,15 @@ function ProgressCell({
|
|
|
1202
1266
|
className
|
|
1203
1267
|
}) {
|
|
1204
1268
|
const clampedValue = Math.min(100, Math.max(0, value));
|
|
1205
|
-
return /* @__PURE__ */
|
|
1206
|
-
/* @__PURE__ */
|
|
1269
|
+
return /* @__PURE__ */ jsxs9("div", { className: `flex items-center gap-2 ${className || ""}`, children: [
|
|
1270
|
+
/* @__PURE__ */ jsx15("div", { className: `w-full rounded-full h-2.5 ${bgColor}`, children: /* @__PURE__ */ jsx15(
|
|
1207
1271
|
"div",
|
|
1208
1272
|
{
|
|
1209
1273
|
className: `${barColor} h-2.5 rounded-full transition-all`,
|
|
1210
1274
|
style: { width: `${clampedValue}%` }
|
|
1211
1275
|
}
|
|
1212
1276
|
) }),
|
|
1213
|
-
showLabel && /* @__PURE__ */
|
|
1277
|
+
showLabel && /* @__PURE__ */ jsxs9("span", { className: "text-xs text-gray-500 dark:text-gray-400 w-8", children: [
|
|
1214
1278
|
value,
|
|
1215
1279
|
"%"
|
|
1216
1280
|
] })
|
|
@@ -1218,7 +1282,7 @@ function ProgressCell({
|
|
|
1218
1282
|
}
|
|
1219
1283
|
|
|
1220
1284
|
// src/components/cell-renderers/boolean-cell.tsx
|
|
1221
|
-
import { jsx as
|
|
1285
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1222
1286
|
function BooleanCell({
|
|
1223
1287
|
value,
|
|
1224
1288
|
trueLabel = "Yes",
|
|
@@ -1226,15 +1290,15 @@ function BooleanCell({
|
|
|
1226
1290
|
trueColor = "text-green-600 dark:text-green-400",
|
|
1227
1291
|
falseColor = "text-red-600 dark:text-red-400"
|
|
1228
1292
|
}) {
|
|
1229
|
-
return /* @__PURE__ */
|
|
1293
|
+
return /* @__PURE__ */ jsx16("span", { className: `font-medium ${value ? trueColor : falseColor}`, children: value ? trueLabel : falseLabel });
|
|
1230
1294
|
}
|
|
1231
1295
|
|
|
1232
1296
|
// src/components/cell-renderers/date-cell.tsx
|
|
1233
|
-
import { jsx as
|
|
1297
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1234
1298
|
function DateCell({ value, format = "short", locale = "en-US" }) {
|
|
1235
1299
|
const date = typeof value === "string" ? new Date(value) : value;
|
|
1236
1300
|
if (isNaN(date.getTime())) {
|
|
1237
|
-
return /* @__PURE__ */
|
|
1301
|
+
return /* @__PURE__ */ jsx17("span", { className: "text-gray-400", children: "-" });
|
|
1238
1302
|
}
|
|
1239
1303
|
let formatted;
|
|
1240
1304
|
switch (format) {
|
|
@@ -1258,23 +1322,23 @@ function DateCell({ value, format = "short", locale = "en-US" }) {
|
|
|
1258
1322
|
default:
|
|
1259
1323
|
formatted = date.toLocaleDateString(locale);
|
|
1260
1324
|
}
|
|
1261
|
-
return /* @__PURE__ */
|
|
1325
|
+
return /* @__PURE__ */ jsx17("span", { children: formatted });
|
|
1262
1326
|
}
|
|
1263
1327
|
|
|
1264
1328
|
// src/components/cell-renderers/currency-cell.tsx
|
|
1265
|
-
import { jsx as
|
|
1329
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1266
1330
|
function CurrencyCell({ value, currency = "TRY", locale = "tr-TR" }) {
|
|
1267
1331
|
const formatted = new Intl.NumberFormat(locale, {
|
|
1268
1332
|
style: "currency",
|
|
1269
1333
|
currency
|
|
1270
1334
|
}).format(value);
|
|
1271
|
-
return /* @__PURE__ */
|
|
1335
|
+
return /* @__PURE__ */ jsx18("span", { className: "font-medium", children: formatted });
|
|
1272
1336
|
}
|
|
1273
1337
|
|
|
1274
1338
|
// src/components/cell-renderers/copyable-cell.tsx
|
|
1275
1339
|
import * as React8 from "react";
|
|
1276
1340
|
import { Copy, Check as Check3 } from "lucide-react";
|
|
1277
|
-
import { jsx as
|
|
1341
|
+
import { jsx as jsx19, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1278
1342
|
function CopyableCell({
|
|
1279
1343
|
value,
|
|
1280
1344
|
feedbackDuration = 2e3,
|
|
@@ -1299,7 +1363,7 @@ function CopyableCell({
|
|
|
1299
1363
|
console.error("Copy error:", err);
|
|
1300
1364
|
}
|
|
1301
1365
|
};
|
|
1302
|
-
return /* @__PURE__ */
|
|
1366
|
+
return /* @__PURE__ */ jsxs10(
|
|
1303
1367
|
"button",
|
|
1304
1368
|
{
|
|
1305
1369
|
type: "button",
|
|
@@ -1318,8 +1382,8 @@ function CopyableCell({
|
|
|
1318
1382
|
${className || ""}
|
|
1319
1383
|
`,
|
|
1320
1384
|
children: [
|
|
1321
|
-
/* @__PURE__ */
|
|
1322
|
-
/* @__PURE__ */
|
|
1385
|
+
/* @__PURE__ */ jsx19("span", { className: "select-none", children: value }),
|
|
1386
|
+
/* @__PURE__ */ jsx19(
|
|
1323
1387
|
"span",
|
|
1324
1388
|
{
|
|
1325
1389
|
className: `
|
|
@@ -1327,7 +1391,7 @@ function CopyableCell({
|
|
|
1327
1391
|
transition-all duration-200
|
|
1328
1392
|
${alwaysShowIcon || isHovered || copied ? "opacity-100" : "opacity-0"}
|
|
1329
1393
|
`,
|
|
1330
|
-
children: copied ? /* @__PURE__ */
|
|
1394
|
+
children: copied ? /* @__PURE__ */ jsx19(Check3, { className: "h-3.5 w-3.5 text-green-600 dark:text-green-400" }) : /* @__PURE__ */ jsx19(Copy, { className: "h-3.5 w-3.5 text-slate-400 dark:text-slate-500 group-hover:text-slate-600 dark:group-hover:text-slate-300" })
|
|
1331
1395
|
}
|
|
1332
1396
|
)
|
|
1333
1397
|
]
|
|
@@ -1335,18 +1399,18 @@ function CopyableCell({
|
|
|
1335
1399
|
);
|
|
1336
1400
|
}
|
|
1337
1401
|
function createCopyableCell(value, options) {
|
|
1338
|
-
return /* @__PURE__ */
|
|
1402
|
+
return /* @__PURE__ */ jsx19(CopyableCell, { value, ...options });
|
|
1339
1403
|
}
|
|
1340
1404
|
|
|
1341
1405
|
// src/components/ui/label.tsx
|
|
1342
1406
|
import * as React9 from "react";
|
|
1343
1407
|
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
1344
1408
|
import { cva as cva2 } from "class-variance-authority";
|
|
1345
|
-
import { jsx as
|
|
1409
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1346
1410
|
var labelVariants = cva2(
|
|
1347
1411
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
1348
1412
|
);
|
|
1349
|
-
var Label3 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
1413
|
+
var Label3 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx20(
|
|
1350
1414
|
LabelPrimitive.Root,
|
|
1351
1415
|
{
|
|
1352
1416
|
ref,
|
|
@@ -1359,11 +1423,11 @@ Label3.displayName = LabelPrimitive.Root.displayName;
|
|
|
1359
1423
|
// src/components/ui/popover.tsx
|
|
1360
1424
|
import * as React10 from "react";
|
|
1361
1425
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
1362
|
-
import { jsx as
|
|
1426
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
1363
1427
|
var Popover = PopoverPrimitive.Root;
|
|
1364
1428
|
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
1365
1429
|
var PopoverAnchor = PopoverPrimitive.Anchor;
|
|
1366
|
-
var PopoverContent = React10.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */
|
|
1430
|
+
var PopoverContent = React10.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx21(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx21(
|
|
1367
1431
|
PopoverPrimitive.Content,
|
|
1368
1432
|
{
|
|
1369
1433
|
ref,
|
|
@@ -1381,9 +1445,9 @@ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
|
1381
1445
|
// src/components/ui/separator.tsx
|
|
1382
1446
|
import * as React11 from "react";
|
|
1383
1447
|
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
1384
|
-
import { jsx as
|
|
1448
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
1385
1449
|
var Separator3 = React11.forwardRef(
|
|
1386
|
-
({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */
|
|
1450
|
+
({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsx22(
|
|
1387
1451
|
SeparatorPrimitive.Root,
|
|
1388
1452
|
{
|
|
1389
1453
|
ref,
|
|
@@ -1402,7 +1466,7 @@ Separator3.displayName = SeparatorPrimitive.Root.displayName;
|
|
|
1402
1466
|
|
|
1403
1467
|
// src/lib/column-helper.tsx
|
|
1404
1468
|
import { createColumnHelper as tanstackCreateColumnHelper } from "@tanstack/react-table";
|
|
1405
|
-
import { jsx as
|
|
1469
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1406
1470
|
var toTitleCase = (str) => {
|
|
1407
1471
|
return str.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()).trim();
|
|
1408
1472
|
};
|
|
@@ -1421,7 +1485,7 @@ function createColumnHelper() {
|
|
|
1421
1485
|
// Pass meta information (filterVariant etc.)
|
|
1422
1486
|
meta: column?.meta,
|
|
1423
1487
|
// Use LuxDataTableColumnHeader if header is string or undefined
|
|
1424
|
-
header: typeof headerContent === "function" ? headerContent : ({ column: colParam }) => /* @__PURE__ */
|
|
1488
|
+
header: typeof headerContent === "function" ? headerContent : ({ column: colParam }) => /* @__PURE__ */ jsx23(
|
|
1425
1489
|
LuxDataTableColumnHeader,
|
|
1426
1490
|
{
|
|
1427
1491
|
column: colParam,
|
|
@@ -1465,7 +1529,7 @@ function createColumnHelper() {
|
|
|
1465
1529
|
auto: (columns) => {
|
|
1466
1530
|
return columns.map((col) => {
|
|
1467
1531
|
return helper.accessor(col.accessor, {
|
|
1468
|
-
header: ({ column }) => /* @__PURE__ */
|
|
1532
|
+
header: ({ column }) => /* @__PURE__ */ jsx23(LuxDataTableColumnHeader, { column, title: col.header }),
|
|
1469
1533
|
cell: col.cell || ((info) => {
|
|
1470
1534
|
const value = info.getValue();
|
|
1471
1535
|
if (value === null || value === void 0) return "-";
|
|
@@ -1491,7 +1555,7 @@ function createColumnsFromData(data, options) {
|
|
|
1491
1555
|
const headerText = options?.headers?.[key] || toTitleCase(key);
|
|
1492
1556
|
const cellRenderer = options?.cells?.[key];
|
|
1493
1557
|
return helper.accessor(key, {
|
|
1494
|
-
header: ({ column }) => /* @__PURE__ */
|
|
1558
|
+
header: ({ column }) => /* @__PURE__ */ jsx23(LuxDataTableColumnHeader, { column, title: headerText }),
|
|
1495
1559
|
cell: cellRenderer || ((info) => {
|
|
1496
1560
|
const value = info.getValue();
|
|
1497
1561
|
if (value === null || value === void 0) return "-";
|
|
@@ -1503,7 +1567,7 @@ function createColumnsFromData(data, options) {
|
|
|
1503
1567
|
|
|
1504
1568
|
// src/index.ts
|
|
1505
1569
|
import {
|
|
1506
|
-
flexRender as
|
|
1570
|
+
flexRender as flexRender3,
|
|
1507
1571
|
getCoreRowModel as getCoreRowModel2,
|
|
1508
1572
|
getPaginationRowModel as getPaginationRowModel2,
|
|
1509
1573
|
getSortedRowModel as getSortedRowModel2,
|
|
@@ -1570,7 +1634,7 @@ export {
|
|
|
1570
1634
|
createColumnsFromData,
|
|
1571
1635
|
createCopyableCell,
|
|
1572
1636
|
defaultStatusColors,
|
|
1573
|
-
|
|
1637
|
+
flexRender3 as flexRender,
|
|
1574
1638
|
getCoreRowModel2 as getCoreRowModel,
|
|
1575
1639
|
getFilteredRowModel2 as getFilteredRowModel,
|
|
1576
1640
|
getPaginationRowModel2 as getPaginationRowModel,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "luxtable",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Enterprise-Grade Data Management. Minimalist Aesthetics.",
|
|
6
6
|
"keywords": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "https://github.com/
|
|
21
|
+
"url": "https://github.com/Huseyin-altun/luxtable.git"
|
|
22
22
|
},
|
|
23
23
|
"main": "./dist/index.js",
|
|
24
24
|
"module": "./dist/index.mjs",
|