@nccirtu/tablefy 0.8.2 → 0.8.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/index.d.ts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +160 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +162 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/columns/index.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ 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
15
|
export { ProgressColumn, SelectColumn } from "./columns";
|
|
16
|
+
export { ActionsColumn, ActionsColumn as actionsColumn, } from "./columns/actions-column";
|
|
17
|
+
export type { ActionItem } from "./columns/actions-column";
|
|
18
|
+
export { TextColumn, TextColumn as textColumn } from "./columns/text-column";
|
|
16
19
|
export { EnumColumn, EnumColumn as enumColumn } from "./columns/enum-column";
|
|
17
20
|
export type { EnumOption } from "./columns/enum-column";
|
|
18
21
|
export { ConfirmProvider, confirm } from "./confirm";
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ 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
15
|
export { ProgressColumn, SelectColumn } from "./columns";
|
|
16
|
+
export { ActionsColumn, ActionsColumn as actionsColumn, } from "./columns/actions-column";
|
|
17
|
+
export type { ActionItem } from "./columns/actions-column";
|
|
18
|
+
export { TextColumn, TextColumn as textColumn } from "./columns/text-column";
|
|
16
19
|
export { EnumColumn, EnumColumn as enumColumn } from "./columns/enum-column";
|
|
17
20
|
export type { EnumOption } from "./columns/enum-column";
|
|
18
21
|
export { ConfirmProvider, confirm } from "./confirm";
|
package/dist/index.esm.js
CHANGED
|
@@ -6,7 +6,7 @@ import { cn } from '@/lib/utils';
|
|
|
6
6
|
import { Button } from '@/components/ui/button';
|
|
7
7
|
import { Input } from '@/components/ui/input';
|
|
8
8
|
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuCheckboxItem, DropdownMenuItem } from '@/components/ui/dropdown-menu';
|
|
9
|
-
import { Search, X, Columns, ChevronDown, ChevronsLeft, ChevronLeft, ChevronRight, ChevronsRight, ArrowUpDown, Calendar, ExternalLink } from 'lucide-react';
|
|
9
|
+
import { Search, X, Columns, ChevronDown, ChevronsLeft, ChevronLeft, ChevronRight, ChevronsRight, ArrowUpDown, Calendar, ExternalLink, MoreHorizontal } 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';
|
|
@@ -1542,6 +1542,164 @@ class SelectColumn extends BaseColumn {
|
|
|
1542
1542
|
}
|
|
1543
1543
|
}
|
|
1544
1544
|
|
|
1545
|
+
class TextColumn extends BaseColumn {
|
|
1546
|
+
static make(accessor) {
|
|
1547
|
+
return new TextColumn(accessor);
|
|
1548
|
+
}
|
|
1549
|
+
formatter(fn) {
|
|
1550
|
+
this.config.formatter = fn;
|
|
1551
|
+
return this;
|
|
1552
|
+
}
|
|
1553
|
+
prefix(prefix) {
|
|
1554
|
+
this.config.prefix = prefix;
|
|
1555
|
+
return this;
|
|
1556
|
+
}
|
|
1557
|
+
suffix(suffix) {
|
|
1558
|
+
this.config.suffix = suffix;
|
|
1559
|
+
return this;
|
|
1560
|
+
}
|
|
1561
|
+
placeholder(placeholder) {
|
|
1562
|
+
this.config.placeholder = placeholder;
|
|
1563
|
+
return this;
|
|
1564
|
+
}
|
|
1565
|
+
// Shortcuts für gängige Formatierungen
|
|
1566
|
+
uppercase() {
|
|
1567
|
+
const existingFormatter = this.config.formatter;
|
|
1568
|
+
this.config.formatter = (value, row) => {
|
|
1569
|
+
const result = existingFormatter ? existingFormatter(value, row) : value;
|
|
1570
|
+
return typeof result === "string"
|
|
1571
|
+
? result.toUpperCase()
|
|
1572
|
+
: result;
|
|
1573
|
+
};
|
|
1574
|
+
return this;
|
|
1575
|
+
}
|
|
1576
|
+
lowercase() {
|
|
1577
|
+
const existingFormatter = this.config.formatter;
|
|
1578
|
+
this.config.formatter = (value, row) => {
|
|
1579
|
+
const result = existingFormatter ? existingFormatter(value, row) : value;
|
|
1580
|
+
return typeof result === "string"
|
|
1581
|
+
? result.toLowerCase()
|
|
1582
|
+
: result;
|
|
1583
|
+
};
|
|
1584
|
+
return this;
|
|
1585
|
+
}
|
|
1586
|
+
limit(chars) {
|
|
1587
|
+
const existingFormatter = this.config.formatter;
|
|
1588
|
+
this.config.formatter = (value, row) => {
|
|
1589
|
+
const result = existingFormatter ? existingFormatter(value, row) : value;
|
|
1590
|
+
if (typeof result === "string" && result.length > chars) {
|
|
1591
|
+
return result.slice(0, chars) + "...";
|
|
1592
|
+
}
|
|
1593
|
+
return result;
|
|
1594
|
+
};
|
|
1595
|
+
return this;
|
|
1596
|
+
}
|
|
1597
|
+
build() {
|
|
1598
|
+
const { accessor, label, sortable, prefix, suffix, placeholder, formatter, visibleByDefault, visibilityLabel, } = this.config;
|
|
1599
|
+
return {
|
|
1600
|
+
accessorKey: accessor,
|
|
1601
|
+
meta: {
|
|
1602
|
+
visibleByDefault,
|
|
1603
|
+
visibilityLabel: visibilityLabel || label || String(accessor),
|
|
1604
|
+
},
|
|
1605
|
+
header: ({ column }) => {
|
|
1606
|
+
const displayLabel = label || String(accessor);
|
|
1607
|
+
if (!sortable) {
|
|
1608
|
+
return (jsx("span", { className: cn("text-muted-foreground font-medium", this.getAlignmentClass(), this.config.headerClassName), children: displayLabel }));
|
|
1609
|
+
}
|
|
1610
|
+
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" })] }));
|
|
1611
|
+
},
|
|
1612
|
+
cell: ({ row, getValue }) => {
|
|
1613
|
+
let value = getValue();
|
|
1614
|
+
// Custom Formatter anwenden
|
|
1615
|
+
if (formatter) {
|
|
1616
|
+
value = formatter(value, row);
|
|
1617
|
+
}
|
|
1618
|
+
// Placeholder wenn leer
|
|
1619
|
+
if (value === null || value === undefined || value === "") {
|
|
1620
|
+
return (jsx("span", { className: cn("text-muted-foreground", this.getAlignmentClass(), this.config.cellClassName), children: placeholder || "—" }));
|
|
1621
|
+
}
|
|
1622
|
+
// Prefix/Suffix hinzufügen
|
|
1623
|
+
const displayValue = `${prefix || ""}${value}${suffix || ""}`;
|
|
1624
|
+
return (jsx("span", { className: cn(this.getAlignmentClass(), this.config.cellClassName), children: displayValue }));
|
|
1625
|
+
},
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
class ActionsColumn {
|
|
1631
|
+
config = {
|
|
1632
|
+
actions: [],
|
|
1633
|
+
label: "Aktionen",
|
|
1634
|
+
};
|
|
1635
|
+
static make() {
|
|
1636
|
+
return new ActionsColumn();
|
|
1637
|
+
}
|
|
1638
|
+
label(label) {
|
|
1639
|
+
this.config.label = label;
|
|
1640
|
+
return this;
|
|
1641
|
+
}
|
|
1642
|
+
triggerIcon(icon) {
|
|
1643
|
+
this.config.triggerIcon = icon;
|
|
1644
|
+
return this;
|
|
1645
|
+
}
|
|
1646
|
+
// Action hinzufügen
|
|
1647
|
+
action(action) {
|
|
1648
|
+
this.config.actions.push(action);
|
|
1649
|
+
return this;
|
|
1650
|
+
}
|
|
1651
|
+
// Shortcuts für gängige Actions
|
|
1652
|
+
view(onClick) {
|
|
1653
|
+
return this.action({ label: "Anzeigen", onClick });
|
|
1654
|
+
}
|
|
1655
|
+
edit(onClick) {
|
|
1656
|
+
return this.action({ label: "Bearbeiten", onClick });
|
|
1657
|
+
}
|
|
1658
|
+
delete(onClick) {
|
|
1659
|
+
return this.action({
|
|
1660
|
+
label: "Löschen",
|
|
1661
|
+
onClick,
|
|
1662
|
+
variant: "destructive",
|
|
1663
|
+
separator: true,
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
link(label, href) {
|
|
1667
|
+
return this.action({ label, href });
|
|
1668
|
+
}
|
|
1669
|
+
separator() {
|
|
1670
|
+
if (this.config.actions.length > 0) {
|
|
1671
|
+
this.config.actions[this.config.actions.length - 1].separator = true;
|
|
1672
|
+
}
|
|
1673
|
+
return this;
|
|
1674
|
+
}
|
|
1675
|
+
build() {
|
|
1676
|
+
const { actions, label, triggerIcon } = this.config;
|
|
1677
|
+
return {
|
|
1678
|
+
id: "actions",
|
|
1679
|
+
header: () => jsx("span", { className: "sr-only", children: label }),
|
|
1680
|
+
cell: ({ row }) => {
|
|
1681
|
+
const data = row.original;
|
|
1682
|
+
const visibleActions = actions.filter((action) => !action.hidden || !action.hidden(data));
|
|
1683
|
+
if (visibleActions.length === 0)
|
|
1684
|
+
return null;
|
|
1685
|
+
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 ? (
|
|
1686
|
+
// Custom render function takes priority
|
|
1687
|
+
action.render(data)) : (
|
|
1688
|
+
// Standard menu item
|
|
1689
|
+
jsxs(DropdownMenuItem, { disabled: action.disabled?.(data), className: cn(action.variant === "destructive" &&
|
|
1690
|
+
"text-destructive focus:text-destructive"), onClick: () => {
|
|
1691
|
+
if (action.href) {
|
|
1692
|
+
window.location.href = action.href(data);
|
|
1693
|
+
}
|
|
1694
|
+
else if (action.onClick) {
|
|
1695
|
+
action.onClick(data);
|
|
1696
|
+
}
|
|
1697
|
+
}, children: [action.icon && (jsx("span", { className: "mr-2", children: action.icon })), action.label] })), action.separator && index < visibleActions.length - 1 && (jsx(DropdownMenuSeparator, {}))] }, index))) })] }));
|
|
1698
|
+
},
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1545
1703
|
class EnumColumn extends BaseColumn {
|
|
1546
1704
|
constructor(accessor) {
|
|
1547
1705
|
super(accessor);
|
|
@@ -1676,5 +1834,5 @@ function ConfirmProvider({ children }) {
|
|
|
1676
1834
|
return (jsxs(Fragment, { children: [children, jsx(AlertDialog, { open: !!currentRequest, onOpenChange: (open) => !open && handleCancel(), children: jsxs(AlertDialogContent, { className: "max-w-md", children: [jsxs(AlertDialogHeader, { children: [jsx(AlertDialogTitle, { className: "text-center", children: title || "Bestätigung erforderlich" }), description && (jsx(AlertDialogDescription, { className: "text-center", children: description }))] }), image && (jsx("div", { className: "flex justify-center py-4", children: jsx("img", { src: image, alt: "Confirmation", className: "h-24 w-24 object-contain" }) })), icon && !image && (jsx("div", { className: "flex justify-center py-4 text-6xl", children: icon })), jsxs(AlertDialogFooter, { className: "flex flex-row !justify-between w-full", children: [jsx(AlertDialogCancel, { onClick: handleCancel, className: "mt-0", children: cancelLabel || "Abbrechen" }), jsx(AlertDialogAction, { onClick: handleConfirm, variant: variant === "destructive" ? "destructive" : "default", children: confirmLabel || "Bestätigen" })] })] }) })] }));
|
|
1677
1835
|
}
|
|
1678
1836
|
|
|
1679
|
-
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 };
|
|
1837
|
+
export { ActionsColumn, AvatarGroupColumn, BadgeColumn, ButtonColumn, CheckboxColumn, ConfirmProvider, DataTable, DataTableSchema, DateColumn, DropdownColumn, EmptyStateBuilder, EnumColumn, IconColumn, ImageColumn, InputColumn, LinkColumn, NumberColumn, ProgressColumn, SelectColumn, TableSchema, TextColumn, ActionsColumn as actionsColumn, 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, TextColumn as textColumn };
|
|
1680
1838
|
//# sourceMappingURL=index.esm.js.map
|