@snowpact/react-tanstack-query-table 1.1.0 → 1.1.2
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/README.md +43 -21
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +13 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare type BaseAction = {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* Base props shared between
|
|
63
|
+
* Base props shared between SnowClientDataTable and SnowServerDataTable
|
|
64
64
|
*/
|
|
65
65
|
export declare interface BaseSnowTableProps<T extends Record<string, unknown>, K> extends DataTableUIOptions<T> {
|
|
66
66
|
queryKey: string[];
|
|
@@ -160,6 +160,7 @@ export declare type DataTableProps<T extends object> = {
|
|
|
160
160
|
};
|
|
161
161
|
|
|
162
162
|
declare interface DataTableStyles {
|
|
163
|
+
root: string;
|
|
163
164
|
container: string;
|
|
164
165
|
header: string;
|
|
165
166
|
headerCell: string;
|
|
@@ -375,12 +376,12 @@ export declare interface SingleFilterDropdownProps<T extends object> {
|
|
|
375
376
|
onFilterChange: (key: keyof T, selectedValues: string[]) => void;
|
|
376
377
|
}
|
|
377
378
|
|
|
378
|
-
export declare const
|
|
379
|
+
export declare const SnowClientDataTable: <T extends Record<string, unknown>, K>({ queryKey, columnConfig, actions, filters, prefilters, prefilterFn, defaultSortBy, defaultSortOrder, defaultPageSize, persistState, fetchAllItemsEndpoint, ...restProps }: SnowClientDataTableProps<T, K>) => JSX.Element;
|
|
379
380
|
|
|
380
381
|
/**
|
|
381
|
-
* Props for
|
|
382
|
+
* Props for SnowClientDataTable component (client-side filtering/sorting)
|
|
382
383
|
*/
|
|
383
|
-
export declare interface
|
|
384
|
+
export declare interface SnowClientDataTableProps<T extends Record<string, unknown>, K> extends BaseSnowTableProps<T, K> {
|
|
384
385
|
fetchAllItemsEndpoint: () => Promise<T[]>;
|
|
385
386
|
/** Optional function to filter items based on active prefilter */
|
|
386
387
|
prefilterFn?: (item: T, prefilterId: string) => boolean;
|
|
@@ -396,12 +397,12 @@ export declare type SnowColumnConfig<T extends object> = {
|
|
|
396
397
|
meta?: ColumnMeta<T, unknown>;
|
|
397
398
|
};
|
|
398
399
|
|
|
399
|
-
export declare const
|
|
400
|
+
export declare const SnowServerDataTable: <T extends Record<string, unknown>, K>({ queryKey, columnConfig, actions, filters, prefilters, defaultSortBy, defaultSortOrder, defaultPageSize, persistState, fetchServerEndpoint, ...restProps }: SnowServerDataTableProps<T, K>) => JSX.Element;
|
|
400
401
|
|
|
401
402
|
/**
|
|
402
|
-
* Props for
|
|
403
|
+
* Props for SnowServerDataTable component (server-side pagination/filtering/sorting)
|
|
403
404
|
*/
|
|
404
|
-
export declare interface
|
|
405
|
+
export declare interface SnowServerDataTableProps<T extends Record<string, unknown>, K> extends BaseSnowTableProps<T, K> {
|
|
405
406
|
fetchServerEndpoint: (params: ServerFetchParams) => Promise<ServerPaginatedResponse<T>>;
|
|
406
407
|
filters?: FilterConfig<Record<string, unknown>>[];
|
|
407
408
|
}
|
|
@@ -442,7 +443,7 @@ declare interface UseConfirmReturn {
|
|
|
442
443
|
}
|
|
443
444
|
|
|
444
445
|
/**
|
|
445
|
-
* Shared hook for building columns and handling actions in
|
|
446
|
+
* Shared hook for building columns and handling actions in SnowClientDataTable and SnowServerDataTable.
|
|
446
447
|
*
|
|
447
448
|
* Extracts the common logic for:
|
|
448
449
|
* - Transforming SnowColumnConfig into TanStack Table ColumnDef
|
package/dist/index.js
CHANGED
|
@@ -59,9 +59,9 @@ const na = (e) => {
|
|
|
59
59
|
lr = e;
|
|
60
60
|
}, oa = () => lr, ra = {
|
|
61
61
|
state: {
|
|
62
|
-
active: "ring-2 ring-
|
|
63
|
-
activeText: "text-
|
|
64
|
-
focus: "focus-visible:ring-2 focus-visible:ring-
|
|
62
|
+
active: "ring-2 ring-ring/30",
|
|
63
|
+
activeText: "text-foreground",
|
|
64
|
+
focus: "focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2"
|
|
65
65
|
},
|
|
66
66
|
button: {
|
|
67
67
|
visual: "border border-input bg-background rounded-md shadow-xs",
|
|
@@ -72,7 +72,7 @@ const na = (e) => {
|
|
|
72
72
|
info: "border-transparent bg-blue-500 text-white shadow-xs hover:bg-blue-600",
|
|
73
73
|
success: "border-transparent bg-green-500 text-white shadow-xs hover:bg-green-600"
|
|
74
74
|
},
|
|
75
|
-
input: "rounded-md border border-input bg-background focus-visible:border-
|
|
75
|
+
input: "rounded-md border border-input bg-background focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
76
76
|
skeleton: "rounded-md bg-muted animate-pulse",
|
|
77
77
|
dropdown: {
|
|
78
78
|
content: "rounded-md border bg-popover text-popover-foreground shadow-md",
|
|
@@ -81,7 +81,7 @@ const na = (e) => {
|
|
|
81
81
|
separator: "bg-muted"
|
|
82
82
|
},
|
|
83
83
|
select: {
|
|
84
|
-
trigger: "rounded-md border border-input bg-background focus:ring-2 focus:ring-
|
|
84
|
+
trigger: "rounded-md border border-input bg-background focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
85
85
|
content: "rounded-md border bg-popover text-popover-foreground shadow-md",
|
|
86
86
|
item: "hover:bg-accent hover:text-accent-foreground",
|
|
87
87
|
itemSelected: "bg-accent text-accent-foreground"
|
|
@@ -92,6 +92,7 @@ const na = (e) => {
|
|
|
92
92
|
triggerActive: "data-[state=active]:bg-background data-[state=active]:text-foreground"
|
|
93
93
|
},
|
|
94
94
|
table: {
|
|
95
|
+
root: "w-full",
|
|
95
96
|
container: "rounded-lg border",
|
|
96
97
|
header: "bg-muted",
|
|
97
98
|
headerCell: "text-muted-foreground",
|
|
@@ -886,7 +887,7 @@ const Ca = (e, t, n, o) => {
|
|
|
886
887
|
cellContent: {
|
|
887
888
|
base: "w-full"
|
|
888
889
|
}
|
|
889
|
-
}, Ra = "inline-flex items-center justify-center gap-1.5 whitespace-nowrap h-8 px-3 text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-
|
|
890
|
+
}, Ra = "inline-flex items-center justify-center gap-1.5 whitespace-nowrap h-8 px-3 text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring/50 focus-visible:ring-offset-1 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", Te = or(
|
|
890
891
|
({
|
|
891
892
|
children: e,
|
|
892
893
|
variant: t = "default",
|
|
@@ -5735,7 +5736,7 @@ function bs(e, t) {
|
|
|
5735
5736
|
return `${e}-content-${t}`;
|
|
5736
5737
|
}
|
|
5737
5738
|
var jf = ps, Yf = hs, Xf = vs;
|
|
5738
|
-
const Zf = "inline-flex h-9 w-fit items-center justify-center p-[3px]", qf = 'inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 px-2 py-1 text-sm font-medium whitespace-nowrap border border-transparent transition-[color,box-shadow] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-
|
|
5739
|
+
const Zf = "inline-flex h-9 w-fit items-center justify-center p-[3px]", qf = 'inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 px-2 py-1 text-sm font-medium whitespace-nowrap border border-transparent transition-[color,box-shadow] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*="size-"])]:size-4';
|
|
5739
5740
|
function Jf({ value: e, onValueChange: t, children: n }) {
|
|
5740
5741
|
return /* @__PURE__ */ p(jf, { value: e, onValueChange: t, children: n });
|
|
5741
5742
|
}
|
|
@@ -5973,10 +5974,10 @@ function Cs({
|
|
|
5973
5974
|
const Q = String(Y), ge = { ...U };
|
|
5974
5975
|
J.length === 0 ? delete ge[Q] : ge[Q] = J, se(ge);
|
|
5975
5976
|
}, Ps = d || I || c && c.length > 0 || T, go = Re(() => he ? e.length : _e.getRowModel().rows.length, [he, e.length, _e]), Is = Re(() => he && s !== void 0 ? s : _e.getFilteredRowModel().rows.length, [he, s, _e]);
|
|
5976
|
-
return /* @__PURE__ */ F("div", { className: "relative flex flex-col flex-1", "data-testid": "datatable", children: [
|
|
5977
|
+
return /* @__PURE__ */ F("div", { className: X("relative flex flex-col flex-1", k.table.root), "data-testid": "datatable", children: [
|
|
5977
5978
|
o && !n && /* @__PURE__ */ p("div", { className: X("absolute inset-0 z-10 pointer-events-none", k.table.loadingOverlay) }),
|
|
5978
5979
|
Ps && /* @__PURE__ */ F("div", { className: "flex flex-col sm:flex-row sm:items-center sm:justify-between py-4 gap-4", children: [
|
|
5979
|
-
/* @__PURE__ */ p("div", { className: "flex items-center gap-2
|
|
5980
|
+
/* @__PURE__ */ p("div", { className: "flex items-center gap-2", children: w && w.length > 0 && v && /* @__PURE__ */ p(
|
|
5980
5981
|
tp,
|
|
5981
5982
|
{
|
|
5982
5983
|
prefilters: w,
|
|
@@ -6129,7 +6130,7 @@ function ap({ item: e, actions: t, onAction: n }) {
|
|
|
6129
6130
|
to: w,
|
|
6130
6131
|
target: g.external ? "_blank" : void 0,
|
|
6131
6132
|
rel: g.external ? "noopener noreferrer" : void 0,
|
|
6132
|
-
className: `inline-flex items-center justify-center gap-1.5 whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-
|
|
6133
|
+
className: `inline-flex items-center justify-center gap-1.5 whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-8 rounded-md ${c.showLabel ? "px-3" : "w-8"}`,
|
|
6133
6134
|
"aria-disabled": c.disabled,
|
|
6134
6135
|
onMouseEnter: (m) => r(c.label, m.currentTarget),
|
|
6135
6136
|
onMouseLeave: i,
|
|
@@ -6431,8 +6432,8 @@ export {
|
|
|
6431
6432
|
tp as PrefilterTabs,
|
|
6432
6433
|
rp as SearchBar,
|
|
6433
6434
|
ip as SingleFilterDropdown,
|
|
6434
|
-
vp as
|
|
6435
|
-
wp as
|
|
6435
|
+
vp as SnowClientDataTable,
|
|
6436
|
+
wp as SnowServerDataTable,
|
|
6436
6437
|
sp as SortButton,
|
|
6437
6438
|
mp as isSnowTableSetup,
|
|
6438
6439
|
hp as redirectToPageWithParam,
|