@nccirtu/tablefy 0.1.7 → 0.2.0
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/lib/builders/empty-state.d.ts +19 -0
- package/dist/columns/lib/builders/table-schema.d.ts +71 -2
- package/dist/index.esm.js +215 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +215 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/builders/empty-state.d.ts +19 -0
- package/dist/lib/builders/table-schema.d.ts +71 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7835,21 +7835,193 @@ function DataTablePagination({ table, config, className, }) {
|
|
|
7835
7835
|
return (jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-4 px-4 py-4 sm:flex-row sm:items-center sm:justify-between", className), children: [jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground", children: table.getFilteredSelectedRowModel().rows.length > 0 ? (jsxRuntime.jsxs("span", { children: [table.getFilteredSelectedRowModel().rows.length, " von", " ", table.getFilteredRowModel().rows.length, " Zeile(n) ausgew\u00E4hlt"] })) : showPageInfo ? (jsxRuntime.jsxs("span", { children: [table.getFilteredRowModel().rows.length, " Eintr\u00E4ge"] })) : null }), jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:gap-6", children: [showPageSizeSelector && (jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground whitespace-nowrap", children: "Zeilen pro Seite" }), jsxRuntime.jsxs(Select, { value: `${table.getState().pagination.pageSize}`, onValueChange: (value) => table.setPageSize(Number(value)), children: [jsxRuntime.jsx(SelectTrigger, { className: "h-8 w-[70px]", children: jsxRuntime.jsx(SelectValue, { placeholder: table.getState().pagination.pageSize }) }), jsxRuntime.jsx(SelectContent, { side: "top", children: pageSizeOptions.map((pageSize) => (jsxRuntime.jsx(SelectItem, { value: `${pageSize}`, children: pageSize }, pageSize))) })] })] })), showPageInfo && (jsxRuntime.jsxs("div", { className: "text-sm text-muted-foreground whitespace-nowrap", children: ["Seite ", table.getState().pagination.pageIndex + 1, " von", " ", table.getPageCount()] })), jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [jsxRuntime.jsxs(Button, { variant: "outline", size: "icon", className: "h-8 w-8", onClick: () => table.setPageIndex(0), disabled: !table.getCanPreviousPage(), children: [jsxRuntime.jsx(lucideReact.ChevronsLeft, { className: "h-4 w-4" }), jsxRuntime.jsx("span", { className: "sr-only", children: "Erste Seite" })] }), jsxRuntime.jsxs(Button, { variant: "outline", size: "icon", className: "h-8 w-8", onClick: () => table.previousPage(), disabled: !table.getCanPreviousPage(), children: [jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4" }), jsxRuntime.jsx("span", { className: "sr-only", children: "Vorherige Seite" })] }), jsxRuntime.jsxs(Button, { variant: "outline", size: "icon", className: "h-8 w-8", onClick: () => table.nextPage(), disabled: !table.getCanNextPage(), children: [jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4" }), jsxRuntime.jsx("span", { className: "sr-only", children: "N\u00E4chste Seite" })] }), jsxRuntime.jsxs(Button, { variant: "outline", size: "icon", className: "h-8 w-8", onClick: () => table.setPageIndex(table.getPageCount() - 1), disabled: !table.getCanNextPage(), children: [jsxRuntime.jsx(lucideReact.ChevronsRight, { className: "h-4 w-4" }), jsxRuntime.jsx("span", { className: "sr-only", children: "Letzte Seite" })] })] })] })] }));
|
|
7836
7836
|
}
|
|
7837
7837
|
|
|
7838
|
+
/**
|
|
7839
|
+
* Header Actions Builder
|
|
7840
|
+
* Fluent API for building header actions
|
|
7841
|
+
*/
|
|
7842
|
+
class HeaderActionsBuilder {
|
|
7843
|
+
actions = [];
|
|
7844
|
+
create(config) {
|
|
7845
|
+
this.actions.push({
|
|
7846
|
+
id: "create",
|
|
7847
|
+
label: config.label,
|
|
7848
|
+
href: config.href,
|
|
7849
|
+
onClick: config.onClick,
|
|
7850
|
+
icon: config.icon,
|
|
7851
|
+
variant: "default",
|
|
7852
|
+
});
|
|
7853
|
+
return this;
|
|
7854
|
+
}
|
|
7855
|
+
export(config) {
|
|
7856
|
+
if (config.formats && config.formats.length > 0) {
|
|
7857
|
+
this.actions.push({
|
|
7858
|
+
id: "export",
|
|
7859
|
+
label: config.label,
|
|
7860
|
+
icon: config.icon,
|
|
7861
|
+
variant: "outline",
|
|
7862
|
+
children: config.formats.map((format, index) => ({
|
|
7863
|
+
id: `export-${index}`,
|
|
7864
|
+
label: format.label,
|
|
7865
|
+
onClick: format.onClick,
|
|
7866
|
+
})),
|
|
7867
|
+
});
|
|
7868
|
+
}
|
|
7869
|
+
else {
|
|
7870
|
+
this.actions.push({
|
|
7871
|
+
id: "export",
|
|
7872
|
+
label: config.label,
|
|
7873
|
+
icon: config.icon,
|
|
7874
|
+
variant: "outline",
|
|
7875
|
+
});
|
|
7876
|
+
}
|
|
7877
|
+
return this;
|
|
7878
|
+
}
|
|
7879
|
+
import(config) {
|
|
7880
|
+
this.actions.push({
|
|
7881
|
+
id: "import",
|
|
7882
|
+
label: config.label,
|
|
7883
|
+
icon: config.icon,
|
|
7884
|
+
onClick: config.onClick,
|
|
7885
|
+
variant: "outline",
|
|
7886
|
+
});
|
|
7887
|
+
return this;
|
|
7888
|
+
}
|
|
7889
|
+
bulkExport(config) {
|
|
7890
|
+
this.actions.push({
|
|
7891
|
+
id: "bulk-export",
|
|
7892
|
+
label: config.label,
|
|
7893
|
+
icon: config.icon,
|
|
7894
|
+
bulk: true,
|
|
7895
|
+
bulkOnClick: config.onExport,
|
|
7896
|
+
variant: "outline",
|
|
7897
|
+
});
|
|
7898
|
+
return this;
|
|
7899
|
+
}
|
|
7900
|
+
bulkDelete(config) {
|
|
7901
|
+
this.actions.push({
|
|
7902
|
+
id: "bulk-delete",
|
|
7903
|
+
label: config.label,
|
|
7904
|
+
icon: config.icon,
|
|
7905
|
+
bulk: true,
|
|
7906
|
+
bulkOnClick: config.onDelete,
|
|
7907
|
+
variant: "destructive",
|
|
7908
|
+
});
|
|
7909
|
+
return this;
|
|
7910
|
+
}
|
|
7911
|
+
custom(action) {
|
|
7912
|
+
this.actions.push(action);
|
|
7913
|
+
return this;
|
|
7914
|
+
}
|
|
7915
|
+
build() {
|
|
7916
|
+
return this.actions;
|
|
7917
|
+
}
|
|
7918
|
+
}
|
|
7838
7919
|
/**
|
|
7839
7920
|
* Table Schema Builder
|
|
7840
|
-
* Fluent API for building table
|
|
7921
|
+
* Fluent API for building complete table configurations
|
|
7841
7922
|
*/
|
|
7842
7923
|
class TableSchema {
|
|
7843
7924
|
columnBuilders = [];
|
|
7925
|
+
config = {};
|
|
7844
7926
|
static make() {
|
|
7845
7927
|
return new TableSchema();
|
|
7846
7928
|
}
|
|
7929
|
+
// Configuration Methods
|
|
7930
|
+
description(text) {
|
|
7931
|
+
this.config.description = text;
|
|
7932
|
+
return this;
|
|
7933
|
+
}
|
|
7934
|
+
title(text) {
|
|
7935
|
+
this.config.title = text;
|
|
7936
|
+
return this;
|
|
7937
|
+
}
|
|
7938
|
+
headerActions(builder) {
|
|
7939
|
+
const actionsBuilder = new HeaderActionsBuilder();
|
|
7940
|
+
this.config.headerActions = builder(actionsBuilder).build();
|
|
7941
|
+
return this;
|
|
7942
|
+
}
|
|
7943
|
+
emptyState(config) {
|
|
7944
|
+
this.config.emptyState = config;
|
|
7945
|
+
return this;
|
|
7946
|
+
}
|
|
7947
|
+
searchEmptyState(config) {
|
|
7948
|
+
this.config.searchEmptyState = config;
|
|
7949
|
+
return this;
|
|
7950
|
+
}
|
|
7951
|
+
filterEmptyState(config) {
|
|
7952
|
+
this.config.filterEmptyState = config;
|
|
7953
|
+
return this;
|
|
7954
|
+
}
|
|
7955
|
+
// Feature Methods
|
|
7956
|
+
searchable(config) {
|
|
7957
|
+
if (typeof config === "boolean") {
|
|
7958
|
+
this.config.search = config ? { enabled: true } : { enabled: false };
|
|
7959
|
+
}
|
|
7960
|
+
else {
|
|
7961
|
+
this.config.search = {
|
|
7962
|
+
enabled: true,
|
|
7963
|
+
placeholder: config?.placeholder,
|
|
7964
|
+
};
|
|
7965
|
+
}
|
|
7966
|
+
return this;
|
|
7967
|
+
}
|
|
7968
|
+
paginated(config) {
|
|
7969
|
+
if (typeof config === "boolean") {
|
|
7970
|
+
this.config.pagination = { enabled: config };
|
|
7971
|
+
}
|
|
7972
|
+
else {
|
|
7973
|
+
this.config.pagination = {
|
|
7974
|
+
enabled: true,
|
|
7975
|
+
pageSize: config?.pageSize,
|
|
7976
|
+
pageSizeOptions: config?.pageSizeOptions,
|
|
7977
|
+
};
|
|
7978
|
+
}
|
|
7979
|
+
return this;
|
|
7980
|
+
}
|
|
7981
|
+
selectable(multiSelect = true) {
|
|
7982
|
+
this.config.enableRowSelection = true;
|
|
7983
|
+
this.config.enableMultiRowSelection = multiSelect;
|
|
7984
|
+
return this;
|
|
7985
|
+
}
|
|
7986
|
+
sortable(defaultSort) {
|
|
7987
|
+
this.config.enableSorting = true;
|
|
7988
|
+
if (defaultSort) {
|
|
7989
|
+
this.config.defaultSort = defaultSort;
|
|
7990
|
+
}
|
|
7991
|
+
return this;
|
|
7992
|
+
}
|
|
7993
|
+
columnVisibility(enabled = true) {
|
|
7994
|
+
this.config.enableColumnVisibility = enabled;
|
|
7995
|
+
return this;
|
|
7996
|
+
}
|
|
7997
|
+
// Styling Methods
|
|
7998
|
+
bordered(enabled = true) {
|
|
7999
|
+
this.config.bordered = enabled;
|
|
8000
|
+
return this;
|
|
8001
|
+
}
|
|
8002
|
+
striped(enabled = true) {
|
|
8003
|
+
this.config.striped = enabled;
|
|
8004
|
+
return this;
|
|
8005
|
+
}
|
|
8006
|
+
hoverable(enabled = true) {
|
|
8007
|
+
this.config.hoverable = enabled;
|
|
8008
|
+
return this;
|
|
8009
|
+
}
|
|
8010
|
+
density(density) {
|
|
8011
|
+
this.config.density = density;
|
|
8012
|
+
return this;
|
|
8013
|
+
}
|
|
8014
|
+
// Columns
|
|
7847
8015
|
columns(...builders) {
|
|
7848
8016
|
this.columnBuilders.push(...builders);
|
|
7849
8017
|
return this;
|
|
7850
8018
|
}
|
|
8019
|
+
// Build
|
|
7851
8020
|
build() {
|
|
7852
|
-
return
|
|
8021
|
+
return {
|
|
8022
|
+
columns: this.columnBuilders.map((builder) => builder.build()),
|
|
8023
|
+
config: this.config,
|
|
8024
|
+
};
|
|
7853
8025
|
}
|
|
7854
8026
|
}
|
|
7855
8027
|
|
|
@@ -7925,6 +8097,47 @@ class EmptyStateBuilder {
|
|
|
7925
8097
|
build() {
|
|
7926
8098
|
return this.config;
|
|
7927
8099
|
}
|
|
8100
|
+
// Static helper methods for quick configuration
|
|
8101
|
+
static noData(config) {
|
|
8102
|
+
return {
|
|
8103
|
+
variant: "default",
|
|
8104
|
+
title: config.title,
|
|
8105
|
+
description: config.description,
|
|
8106
|
+
action: config.createLabel
|
|
8107
|
+
? {
|
|
8108
|
+
label: config.createLabel,
|
|
8109
|
+
href: config.createHref,
|
|
8110
|
+
onClick: config.createOnClick,
|
|
8111
|
+
}
|
|
8112
|
+
: undefined,
|
|
8113
|
+
};
|
|
8114
|
+
}
|
|
8115
|
+
static noSearchResults(config) {
|
|
8116
|
+
return {
|
|
8117
|
+
variant: "search",
|
|
8118
|
+
title: config.title,
|
|
8119
|
+
description: config.description,
|
|
8120
|
+
action: config.clearLabel
|
|
8121
|
+
? {
|
|
8122
|
+
label: config.clearLabel,
|
|
8123
|
+
onClick: config.onClear,
|
|
8124
|
+
}
|
|
8125
|
+
: undefined,
|
|
8126
|
+
};
|
|
8127
|
+
}
|
|
8128
|
+
static noFilterResults(config) {
|
|
8129
|
+
return {
|
|
8130
|
+
variant: "filter",
|
|
8131
|
+
title: config.title,
|
|
8132
|
+
description: config.description,
|
|
8133
|
+
action: config.resetLabel
|
|
8134
|
+
? {
|
|
8135
|
+
label: config.resetLabel,
|
|
8136
|
+
onClick: config.onReset,
|
|
8137
|
+
}
|
|
8138
|
+
: undefined,
|
|
8139
|
+
};
|
|
8140
|
+
}
|
|
7928
8141
|
}
|
|
7929
8142
|
|
|
7930
8143
|
function DataTable({ columns, data, config = {}, className, isLoading = false, isError = false, onRetry, }) {
|