@myrjfa/ui 1.0.4 → 1.0.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.
|
@@ -6,5 +6,5 @@ export function ActionButtons(_a) {
|
|
|
6
6
|
var actions = _a.actions, _b = _a.includeMoreMenu, includeMoreMenu = _b === void 0 ? true : _b, _c = _a.maxDisplayed, maxDisplayed = _c === void 0 ? 0 : _c;
|
|
7
7
|
var displayedActions = actions.slice(0, maxDisplayed);
|
|
8
8
|
var menuActions = includeMoreMenu ? actions.slice(maxDisplayed) : [];
|
|
9
|
-
return (_jsxs("div", { className: "flex items-center gap-2", children: [displayedActions.map(function (action, index) { return (_jsxs(Button, { variant: action.variant || 'outline', size: "sm", onClick: action.action, className: 'cursor-pointer', children: [action.icon, _jsx("span", { className: "ml-1
|
|
9
|
+
return (_jsxs("div", { className: "flex items-center gap-2", children: [displayedActions.map(function (action, index) { return (_jsxs(Button, { variant: action.variant || 'outline', size: "sm", onClick: action.action, className: 'cursor-pointer', children: [action.icon, _jsx("span", { className: "ml-1", children: action.label })] }, index)); }), menuActions.length > 0 && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "outline", size: "sm", children: _jsx(MoreHorizontal, { className: "h-4 w-4 cursor-pointer" }) }) }), _jsx(DropdownMenuContent, { align: "end", children: menuActions.map(function (action, index) { return (_jsxs(DropdownMenuItem, { onClick: action.action, children: [action.icon, _jsx("span", { className: "ml-2", children: action.label })] }, index)); }) })] }))] }));
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../../src/dashboard/data-table.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,GAAG,EAAqB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../../src/dashboard/data-table.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,GAAG,EAAqB,MAAM,OAAO,CAAC;AAYtD,MAAM,WAAW,MAAM,CAAC,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC,CAAC;IACrB,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,cAAc,CAAC,CAAC;IACtB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC;IACnC,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACjE,IAAI,EACJ,OAAO,EACP,OAAO,EACP,UAAU,GACb,EAAE,cAAc,CAAC,CAAC,CAAC,2CAuNnB"}
|
|
@@ -7,7 +7,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
7
7
|
}
|
|
8
8
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
9
|
};
|
|
10
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
11
|
import { ChevronDown, ChevronUp, Inbox } from 'lucide-react';
|
|
12
12
|
import { useMemo, useState } from 'react';
|
|
13
13
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '../dashboard/table';
|
|
@@ -50,10 +50,17 @@ export function DataTable(_a) {
|
|
|
50
50
|
setSortDirection('asc');
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
return (_jsxs("div", { className: "w-full
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
return (_jsxs("div", { className: "w-full", children: [_jsx("div", { className: "p-2", children: _jsx(Input, { placeholder: "Search...", className: "mb-4 max-w-sm", value: searchQuery, onChange: function (e) { return setSearchQuery(e.target.value); } }) }), _jsx("div", { className: "hidden lg:block overflow-auto", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [columns.map(function (column) { return (_jsx(TableHead, { className: "cursor-pointer select-none", onClick: function () { return column.sortable && toggleSort(column.accessorKey); }, children: _jsxs("div", { className: "flex items-center gap-1", children: [column.header, column.sortable && (sortColumn === column.accessorKey ? (sortDirection === 'asc' ? (_jsx(ChevronUp, { className: "w-4 h-4 text-black" })) : (_jsx(ChevronDown, { className: "w-4 h-4 text-black" }))) : (_jsxs("div", { className: "flex flex-col text-gray-400 leading-none", children: [_jsx(ChevronUp, { className: "w-3 h-3 -mb-1" }), _jsx(ChevronDown, { className: "w-3 h-3" })] })))] }) }, column.accessorKey)); }), actions && _jsx(TableHead, { children: "Actions" })] }) }), _jsx(TableBody, { children: sortedData.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: columns.length + (actions ? 1 : 0), className: "h-40 text-center text-gray-500", children: _jsxs("div", { className: "flex flex-col items-center justify-center gap-2", children: [_jsx(Inbox, { className: "w-8 h-8 text-gray-400" }), _jsx("span", { className: "text-base font-medium", children: "No data available" })] }) }) })) : (sortedData.map(function (item) {
|
|
54
|
+
var key = item.slug || item._id || Math.random().toString();
|
|
55
|
+
return (_jsxs(TableRow, { onClick: function () { return onRowClick && onRowClick(key); }, className: onRowClick ? 'hover:bg-accent cursor-pointer' : '', children: [columns.map(function (column) { return (_jsx(TableCell, { children: column.cell
|
|
56
|
+
? column.cell(item)
|
|
57
|
+
: item[column.accessorKey] }, column.accessorKey)); }), actions && (_jsx(TableCell, { onClick: function (e) { return e.stopPropagation(); }, children: actions(item) }))] }, key));
|
|
58
|
+
})) })] }) }), _jsx("div", { className: "lg:hidden", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsx(TableRow, { children: columns.slice(1).map(function (column) { return (_jsx(TableHead, { className: "cursor-pointer select-none", onClick: function () { return column.sortable && toggleSort(column.accessorKey); }, children: _jsxs("div", { className: "flex items-center gap-1", children: [column.header, column.sortable && (sortColumn === column.accessorKey ? (sortDirection === 'asc' ? (_jsx(ChevronUp, { className: "w-4 h-4 text-black" })) : (_jsx(ChevronDown, { className: "w-4 h-4 text-black" }))) : (_jsxs("div", { className: "flex flex-col text-gray-400 leading-none", children: [_jsx(ChevronUp, { className: "w-3 h-3 -mb-1" }), _jsx(ChevronDown, { className: "w-3 h-3" })] })))] }) }, column.accessorKey)); }) }) }), _jsx(TableBody, { children: sortedData.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: columns.length + (actions ? 1 : 0), className: "h-40 text-center text-gray-500", children: _jsxs("div", { className: "flex flex-col items-center justify-center gap-2", children: [_jsx(Inbox, { className: "w-8 h-8 text-gray-400" }), _jsx("span", { className: "text-base font-medium", children: "No data available" })] }) }) })) : (sortedData.map(function (item) {
|
|
59
|
+
var key = item.slug || item._id || Math.random().toString();
|
|
60
|
+
return (_jsxs(_Fragment, { children: [_jsx(TableRow, { className: "bg-gray-100", children: _jsx(TableCell, { colSpan: columns.length - 1, className: "py-3", children: _jsx("div", { className: "font-semibold text-gray-900", children: columns[0].cell
|
|
61
|
+
? columns[0].cell(item)
|
|
62
|
+
: item[columns[0].accessorKey] }) }) }), _jsx(TableRow, { onClick: function () { return onRowClick && onRowClick(key); }, className: onRowClick ? 'hover:bg-accent cursor-pointer' : '', children: columns.slice(1).map(function (column) { return (_jsx(TableCell, { children: column.cell
|
|
63
|
+
? column.cell(item)
|
|
64
|
+
: item[column.accessorKey] }, column.accessorKey)); }) }, key), actions && (_jsx(TableRow, { className: "bg-gray-30", children: _jsx(TableCell, { colSpan: columns.length - 1, className: "py-3", onClick: function (e) { return e.stopPropagation(); }, children: actions(item) }) }))] }));
|
|
65
|
+
})) })] }) })] }));
|
|
59
66
|
}
|