@nccirtu/tablefy 0.7.1 → 0.7.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/dist/columns/columns/enum-column.d.ts +52 -0
- package/dist/columns/columns/index.d.ts +2 -0
- package/dist/columns/enum-column.d.ts +52 -0
- package/dist/columns/index.d.ts +3 -5
- package/dist/columns/index.esm.js +95 -1
- package/dist/columns/index.esm.js.map +1 -1
- package/dist/columns/index.js +95 -0
- package/dist/columns/index.js.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.esm.js +64 -125
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +63 -127
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,11 +12,9 @@ export { ImageColumn } from "./columns/image-column";
|
|
|
12
12
|
export { InputColumn, InputColumn as inputColumn, } from "./columns/input-column";
|
|
13
13
|
export { LinkColumn } from "./columns/link-column";
|
|
14
14
|
export { NumberColumn } from "./columns/number-column";
|
|
15
|
-
export { ProgressColumn,
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export { ActionsColumn } from "./columns/actions-column";
|
|
19
|
-
export type { ActionItem } from "./columns/actions-column";
|
|
15
|
+
export { ProgressColumn, SelectColumn } from "./columns";
|
|
16
|
+
export { EnumColumn, EnumColumn as enumColumn } from "./columns/enum-column";
|
|
17
|
+
export type { EnumOption } from "./columns/enum-column";
|
|
20
18
|
export { ConfirmProvider, confirm } from "./confirm";
|
|
21
19
|
export type { ConfirmOptions } from "./confirm";
|
|
22
20
|
export type { DataTableConfig, EmptyStateConfig, FilterConfig, HeaderAction, PaginationConfig, SearchConfig, } from "./types";
|
package/dist/index.esm.js
CHANGED
|
@@ -5,8 +5,8 @@ import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from '@
|
|
|
5
5
|
import { cn } from '@/lib/utils';
|
|
6
6
|
import { Button } from '@/components/ui/button';
|
|
7
7
|
import { Input } from '@/components/ui/input';
|
|
8
|
-
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem
|
|
9
|
-
import { Search, X, ChevronDown, ChevronsLeft, ChevronLeft, ChevronRight, ChevronsRight, ArrowUpDown, Calendar, ExternalLink
|
|
8
|
+
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@/components/ui/dropdown-menu';
|
|
9
|
+
import { Search, X, ChevronDown, ChevronsLeft, ChevronLeft, ChevronRight, ChevronsRight, ArrowUpDown, Calendar, ExternalLink } from 'lucide-react';
|
|
10
10
|
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@/components/ui/select';
|
|
11
11
|
import { Badge } from '@/components/ui/badge';
|
|
12
12
|
import { Checkbox } from '@/components/ui/checkbox';
|
|
@@ -1596,60 +1596,70 @@ class SelectColumn extends BaseColumn {
|
|
|
1596
1596
|
}
|
|
1597
1597
|
}
|
|
1598
1598
|
|
|
1599
|
-
class
|
|
1599
|
+
class EnumColumn extends BaseColumn {
|
|
1600
|
+
constructor(accessor) {
|
|
1601
|
+
super(accessor);
|
|
1602
|
+
this.config.asBadge = true;
|
|
1603
|
+
this.config.showIcon = true;
|
|
1604
|
+
this.config.iconPosition = "left";
|
|
1605
|
+
}
|
|
1600
1606
|
static make(accessor) {
|
|
1601
|
-
return new
|
|
1607
|
+
return new EnumColumn(accessor);
|
|
1602
1608
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1609
|
+
/**
|
|
1610
|
+
* Define the enum options with labels, icons, and colors
|
|
1611
|
+
*/
|
|
1612
|
+
options(options) {
|
|
1613
|
+
this.config.options = options;
|
|
1605
1614
|
return this;
|
|
1606
1615
|
}
|
|
1607
|
-
|
|
1608
|
-
|
|
1616
|
+
/**
|
|
1617
|
+
* Display as plain text instead of badge
|
|
1618
|
+
*/
|
|
1619
|
+
asText() {
|
|
1620
|
+
this.config.asBadge = false;
|
|
1609
1621
|
return this;
|
|
1610
1622
|
}
|
|
1611
|
-
|
|
1612
|
-
|
|
1623
|
+
/**
|
|
1624
|
+
* Display as badge (default)
|
|
1625
|
+
*/
|
|
1626
|
+
asBadge() {
|
|
1627
|
+
this.config.asBadge = true;
|
|
1613
1628
|
return this;
|
|
1614
1629
|
}
|
|
1615
|
-
|
|
1616
|
-
|
|
1630
|
+
/**
|
|
1631
|
+
* Hide icons
|
|
1632
|
+
*/
|
|
1633
|
+
hideIcon() {
|
|
1634
|
+
this.config.showIcon = false;
|
|
1617
1635
|
return this;
|
|
1618
1636
|
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
return typeof result === "string"
|
|
1625
|
-
? result.toUpperCase()
|
|
1626
|
-
: result;
|
|
1627
|
-
};
|
|
1637
|
+
/**
|
|
1638
|
+
* Show icons (default)
|
|
1639
|
+
*/
|
|
1640
|
+
showIcon() {
|
|
1641
|
+
this.config.showIcon = true;
|
|
1628
1642
|
return this;
|
|
1629
1643
|
}
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
? result.toLowerCase()
|
|
1636
|
-
: result;
|
|
1637
|
-
};
|
|
1644
|
+
/**
|
|
1645
|
+
* Set icon position
|
|
1646
|
+
*/
|
|
1647
|
+
iconPosition(position) {
|
|
1648
|
+
this.config.iconPosition = position;
|
|
1638
1649
|
return this;
|
|
1639
1650
|
}
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
return result.slice(0, chars) + "...";
|
|
1646
|
-
}
|
|
1647
|
-
return result;
|
|
1648
|
-
};
|
|
1651
|
+
/**
|
|
1652
|
+
* Placeholder for unknown values
|
|
1653
|
+
*/
|
|
1654
|
+
placeholder(placeholder) {
|
|
1655
|
+
this.config.placeholder = placeholder;
|
|
1649
1656
|
return this;
|
|
1650
1657
|
}
|
|
1651
1658
|
build() {
|
|
1652
|
-
const { accessor, label, sortable,
|
|
1659
|
+
const { accessor, label, sortable, options, asBadge, showIcon, iconPosition, placeholder, } = this.config;
|
|
1660
|
+
if (!options || options.length === 0) {
|
|
1661
|
+
throw new Error(`EnumColumn "${String(accessor)}" requires options to be defined`);
|
|
1662
|
+
}
|
|
1653
1663
|
return {
|
|
1654
1664
|
accessorKey: accessor,
|
|
1655
1665
|
header: ({ column }) => {
|
|
@@ -1659,92 +1669,22 @@ class TextColumn extends BaseColumn {
|
|
|
1659
1669
|
}
|
|
1660
1670
|
return (jsxs(Button, { variant: "table_header", size: "table_header", onClick: () => column.toggleSorting(column.getIsSorted() === "asc"), className: cn("text-muted-foreground font-medium", this.getAlignmentClass(), this.config.headerClassName), children: [displayLabel, jsx(ArrowUpDown, { className: "ml-2 h-4 w-4" })] }));
|
|
1661
1671
|
},
|
|
1662
|
-
cell: ({
|
|
1663
|
-
|
|
1664
|
-
//
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
// Placeholder wenn leer
|
|
1669
|
-
if (value === null || value === undefined || value === "") {
|
|
1672
|
+
cell: ({ getValue }) => {
|
|
1673
|
+
const value = getValue();
|
|
1674
|
+
// Find matching option
|
|
1675
|
+
const option = options.find((opt) => opt.value === value);
|
|
1676
|
+
// Handle unknown values
|
|
1677
|
+
if (!option) {
|
|
1670
1678
|
return (jsx("span", { className: cn("text-muted-foreground", this.getAlignmentClass(), this.config.cellClassName), children: placeholder || "—" }));
|
|
1671
1679
|
}
|
|
1672
|
-
|
|
1673
|
-
const
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
class ActionsColumn {
|
|
1681
|
-
config = {
|
|
1682
|
-
actions: [],
|
|
1683
|
-
label: "Aktionen",
|
|
1684
|
-
};
|
|
1685
|
-
static make() {
|
|
1686
|
-
return new ActionsColumn();
|
|
1687
|
-
}
|
|
1688
|
-
label(label) {
|
|
1689
|
-
this.config.label = label;
|
|
1690
|
-
return this;
|
|
1691
|
-
}
|
|
1692
|
-
triggerIcon(icon) {
|
|
1693
|
-
this.config.triggerIcon = icon;
|
|
1694
|
-
return this;
|
|
1695
|
-
}
|
|
1696
|
-
// Action hinzufügen
|
|
1697
|
-
action(action) {
|
|
1698
|
-
this.config.actions.push(action);
|
|
1699
|
-
return this;
|
|
1700
|
-
}
|
|
1701
|
-
// Shortcuts für gängige Actions
|
|
1702
|
-
view(onClick) {
|
|
1703
|
-
return this.action({ label: "Anzeigen", onClick });
|
|
1704
|
-
}
|
|
1705
|
-
edit(onClick) {
|
|
1706
|
-
return this.action({ label: "Bearbeiten", onClick });
|
|
1707
|
-
}
|
|
1708
|
-
delete(onClick) {
|
|
1709
|
-
return this.action({
|
|
1710
|
-
label: "Löschen",
|
|
1711
|
-
onClick,
|
|
1712
|
-
variant: "destructive",
|
|
1713
|
-
separator: true,
|
|
1714
|
-
});
|
|
1715
|
-
}
|
|
1716
|
-
link(label, href) {
|
|
1717
|
-
return this.action({ label, href });
|
|
1718
|
-
}
|
|
1719
|
-
separator() {
|
|
1720
|
-
if (this.config.actions.length > 0) {
|
|
1721
|
-
this.config.actions[this.config.actions.length - 1].separator = true;
|
|
1722
|
-
}
|
|
1723
|
-
return this;
|
|
1724
|
-
}
|
|
1725
|
-
build() {
|
|
1726
|
-
const { actions, label, triggerIcon } = this.config;
|
|
1727
|
-
return {
|
|
1728
|
-
id: "actions",
|
|
1729
|
-
header: () => jsx("span", { className: "sr-only", children: label }),
|
|
1730
|
-
cell: ({ row }) => {
|
|
1731
|
-
const data = row.original;
|
|
1732
|
-
const visibleActions = actions.filter((action) => !action.hidden || !action.hidden(data));
|
|
1733
|
-
if (visibleActions.length === 0)
|
|
1734
|
-
return null;
|
|
1735
|
-
return (jsxs(DropdownMenu, { children: [jsx(DropdownMenuTrigger, { asChild: true, children: jsxs(Button, { variant: "ghost", className: "h-10 w-10 p-0", children: [jsx("span", { className: "sr-only", children: label }), triggerIcon || jsx(MoreHorizontal, { className: "h-8 w-8" })] }) }), jsx(DropdownMenuContent, { align: "end", children: visibleActions.map((action, index) => (jsxs("div", { children: [action.render ? (
|
|
1736
|
-
// Custom render function takes priority
|
|
1737
|
-
action.render(data)) : (
|
|
1738
|
-
// Standard menu item
|
|
1739
|
-
jsxs(DropdownMenuItem, { disabled: action.disabled?.(data), className: cn(action.variant === "destructive" &&
|
|
1740
|
-
"text-destructive focus:text-destructive"), onClick: () => {
|
|
1741
|
-
if (action.href) {
|
|
1742
|
-
window.location.href = action.href(data);
|
|
1743
|
-
}
|
|
1744
|
-
else if (action.onClick) {
|
|
1745
|
-
action.onClick(data);
|
|
1746
|
-
}
|
|
1747
|
-
}, children: [action.icon && (jsx("span", { className: "mr-2", children: action.icon })), action.label] })), action.separator && index < visibleActions.length - 1 && (jsx(DropdownMenuSeparator, {}))] }, index))) })] }));
|
|
1680
|
+
const Icon = option.icon;
|
|
1681
|
+
const iconElement = showIcon && Icon ? jsx(Icon, { className: "h-4 w-4" }) : null;
|
|
1682
|
+
// Render as Badge
|
|
1683
|
+
if (asBadge) {
|
|
1684
|
+
return (jsx("div", { className: cn(this.getAlignmentClass(), this.config.cellClassName), children: jsxs(Badge, { variant: option.color || "default", className: cn("inline-flex items-center gap-1.5", option.className), children: [iconPosition === "left" && iconElement, option.label, iconPosition === "right" && iconElement] }) }));
|
|
1685
|
+
}
|
|
1686
|
+
// Render as plain text with icon
|
|
1687
|
+
return (jsxs("div", { className: cn("inline-flex items-center gap-2", this.getAlignmentClass(), this.config.cellClassName, option.className), children: [iconPosition === "left" && iconElement, jsx("span", { children: option.label }), iconPosition === "right" && iconElement] }));
|
|
1748
1688
|
},
|
|
1749
1689
|
};
|
|
1750
1690
|
}
|
|
@@ -1766,7 +1706,6 @@ function ConfirmProvider({ children }) {
|
|
|
1766
1706
|
const currentRequest = queue[0];
|
|
1767
1707
|
useEffect(() => {
|
|
1768
1708
|
registerConfirm(async (options) => {
|
|
1769
|
-
console.log("ConfirmProvider received options:", options);
|
|
1770
1709
|
return new Promise((resolve) => {
|
|
1771
1710
|
setQueue((q) => [...q, { options, resolve }]);
|
|
1772
1711
|
});
|
|
@@ -1790,5 +1729,5 @@ function ConfirmProvider({ children }) {
|
|
|
1790
1729
|
return (jsxs(Fragment, { children: [children, jsx(Dialog, { open: !!currentRequest, onOpenChange: (open) => !open && handleCancel(), children: jsxs(DialogContent, { children: [jsxs(DialogHeader, { children: [jsx(DialogTitle, { children: currentRequest?.options?.title || "Bestätigung erforderlich" }), currentRequest?.options?.description && (jsx(DialogDescription, { children: currentRequest.options.description }))] }), jsxs(DialogFooter, { children: [jsx(Button, { variant: "outline", onClick: handleCancel, children: currentRequest?.options.cancelLabel || "Abbrechen" }), jsx(Button, { variant: currentRequest?.options.variant || "default", onClick: handleConfirm, children: currentRequest?.options.confirmLabel || "Bestätigen" })] })] }) })] }));
|
|
1791
1730
|
}
|
|
1792
1731
|
|
|
1793
|
-
export {
|
|
1732
|
+
export { AvatarGroupColumn, BadgeColumn, ButtonColumn, CheckboxColumn, ConfirmProvider, DataTable, DataTableSchema, DateColumn, DropdownColumn, EmptyStateBuilder, EnumColumn, IconColumn, ImageColumn, InputColumn, LinkColumn, NumberColumn, ProgressColumn, SelectColumn, TableSchema, AvatarGroupColumn as avatarGroupColumn, BadgeColumn as badgeColumn, ButtonColumn as buttonColumn, CheckboxColumn as checkboxColumn, confirm, DateColumn as dateColumn, DropdownColumn as dropdownColumn, EnumColumn as enumColumn, IconColumn as iconColumn, InputColumn as inputColumn };
|
|
1794
1733
|
//# sourceMappingURL=index.esm.js.map
|