@sth87/shadcn-design-system 0.2.11 → 0.2.12
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/cjs/components/Table/data-table.cjs +1 -1
- package/dist/cjs/styles/index.css +1 -1
- package/dist/cjs/utils/data-table.cjs +1 -1
- package/dist/esm/components/Table/data-table.js +51 -47
- package/dist/esm/styles/index.css +1 -1
- package/dist/esm/utils/data-table.js +6 -0
- package/dist/types/components/Table/data-table.d.ts.map +1 -1
- package/dist/types/utils/data-table.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function s({column:t,withBorder:i=!1}){const e=t.getIsPinned(),n=e==="left"&&t.getIsLastColumn("left"),r=e==="right"&&t.getIsFirstColumn("right");return{boxShadow:i?n?"-4px 0 4px -4px var(--border) inset":r?"4px 0 4px -4px var(--border) inset":void 0:void 0,left:e==="left"?`${t.getStart("left")}px`:void 0,right:e==="right"?`${t.getAfter("right")}px`:void 0,position:e?"sticky":"relative",width:t.getSize(),minWidth:t.getSize(),maxWidth:t.getSize(),zIndex:e?1:void 0}}exports.getCommonPinningStyles=s;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as f, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { flexRender as C } from "@tanstack/react-table";
|
|
3
3
|
import { Fragment as k } from "react";
|
|
4
4
|
import { DataTablePagination as F } from "./data-table-pagination.js";
|
|
5
|
-
import { cn as
|
|
6
|
-
import { Table as B, TableHeader as L, TableRow as
|
|
5
|
+
import { cn as n } from "../../packages/ui/src/lib/utils.js";
|
|
6
|
+
import { Table as B, TableHeader as L, TableRow as c, TableHead as O, TableBody as V, TableCell as b, TableFooter as q } from "../../packages/ui/src/components/table.js";
|
|
7
7
|
import { getCommonPinningStyles as T } from "../../utils/data-table.js";
|
|
8
|
-
import { DataTableColumnHeader as
|
|
9
|
-
function
|
|
10
|
-
table:
|
|
8
|
+
import { DataTableColumnHeader as W } from "./data-table-column-header.js";
|
|
9
|
+
function U({
|
|
10
|
+
table: d,
|
|
11
11
|
actionBar: g,
|
|
12
12
|
children: H,
|
|
13
13
|
className: R,
|
|
@@ -16,26 +16,26 @@ function W({
|
|
|
16
16
|
stickyFooter: D = !1,
|
|
17
17
|
bordered: P = !0,
|
|
18
18
|
loading: p,
|
|
19
|
-
loadingIndicator:
|
|
19
|
+
loadingIndicator: z,
|
|
20
20
|
footer: h,
|
|
21
|
-
emptyState:
|
|
22
|
-
onRowClick:
|
|
23
|
-
rowClassName:
|
|
21
|
+
emptyState: I,
|
|
22
|
+
onRowClick: m,
|
|
23
|
+
rowClassName: u,
|
|
24
24
|
renderRow: w,
|
|
25
25
|
renderCell: x,
|
|
26
26
|
classNames: l,
|
|
27
27
|
showTotalCount: N = !0,
|
|
28
|
-
totalCount:
|
|
28
|
+
totalCount: j,
|
|
29
29
|
...M
|
|
30
30
|
}) {
|
|
31
|
-
const
|
|
31
|
+
const i = s ? {
|
|
32
32
|
offsetHeader: typeof s == "object" ? s.offsetHeader ?? 0 : 0,
|
|
33
33
|
offsetScroll: typeof s == "object" ? s.offsetScroll : void 0
|
|
34
|
-
} : null, v =
|
|
35
|
-
return /* @__PURE__ */
|
|
34
|
+
} : null, v = d.getVisibleLeafColumns().length;
|
|
35
|
+
return /* @__PURE__ */ f(
|
|
36
36
|
"div",
|
|
37
37
|
{
|
|
38
|
-
className:
|
|
38
|
+
className: n(
|
|
39
39
|
"ds:flex ds:w-full ds:flex-col ds:gap-2.5 ds:relative",
|
|
40
40
|
R
|
|
41
41
|
),
|
|
@@ -45,18 +45,19 @@ function W({
|
|
|
45
45
|
p && /* @__PURE__ */ e(
|
|
46
46
|
"div",
|
|
47
47
|
{
|
|
48
|
-
className:
|
|
48
|
+
className: n(
|
|
49
49
|
"ds:absolute ds:inset-0 ds:bg-background/50 ds:flex ds:items-center ds:justify-center ds:z-20",
|
|
50
50
|
l?.loadingOverlay
|
|
51
51
|
),
|
|
52
|
-
children:
|
|
52
|
+
children: z ?? "Loading..."
|
|
53
53
|
}
|
|
54
54
|
),
|
|
55
|
-
/* @__PURE__ */
|
|
55
|
+
/* @__PURE__ */ f(
|
|
56
56
|
B,
|
|
57
57
|
{
|
|
58
|
-
className: l?.table,
|
|
59
|
-
|
|
58
|
+
className: n("ds:table-fixed", l?.table),
|
|
59
|
+
style: { minWidth: d.getTotalSize() },
|
|
60
|
+
containerClassName: n(
|
|
60
61
|
P && "ds:rounded-md ds:border ds:border-border",
|
|
61
62
|
// Thin, unobtrusive scrollbar that darkens only when hovering the thumb itself
|
|
62
63
|
"ds:[scrollbar-width:thin] ds:[scrollbar-color:var(--border)_transparent]",
|
|
@@ -64,18 +65,20 @@ function W({
|
|
|
64
65
|
"ds:[&::-webkit-scrollbar-track]:bg-transparent",
|
|
65
66
|
"ds:[&::-webkit-scrollbar-thumb]:rounded-full ds:[&::-webkit-scrollbar-thumb]:bg-border",
|
|
66
67
|
"ds:[&::-webkit-scrollbar-thumb:hover]:bg-muted-foreground",
|
|
68
|
+
// Size container so the footer can use `cqw` units (see footer cell)
|
|
69
|
+
"ds:[container-type:inline-size]",
|
|
67
70
|
p && "ds:blur-sm",
|
|
68
71
|
l?.container
|
|
69
72
|
),
|
|
70
|
-
containerStyle:
|
|
71
|
-
maxHeight: `calc(100vh - ${
|
|
73
|
+
containerStyle: i ? {
|
|
74
|
+
maxHeight: `calc(100vh - ${i.offsetScroll ?? 0}px)`
|
|
72
75
|
} : void 0,
|
|
73
76
|
children: [
|
|
74
|
-
/* @__PURE__ */ e(L, { children:
|
|
77
|
+
/* @__PURE__ */ e(L, { children: d.getHeaderGroups().map((t) => /* @__PURE__ */ e(c, { className: l?.headerRow, children: t.headers.map((o) => /* @__PURE__ */ e(
|
|
75
78
|
O,
|
|
76
79
|
{
|
|
77
80
|
colSpan: o.colSpan,
|
|
78
|
-
className:
|
|
81
|
+
className: n(
|
|
79
82
|
l?.headerCell,
|
|
80
83
|
o.column.getIsPinned() && "ds:bg-background"
|
|
81
84
|
),
|
|
@@ -84,9 +87,9 @@ function W({
|
|
|
84
87
|
column: o.column,
|
|
85
88
|
withBorder: !0
|
|
86
89
|
}),
|
|
87
|
-
...
|
|
90
|
+
...i && {
|
|
88
91
|
position: "sticky",
|
|
89
|
-
top:
|
|
92
|
+
top: i.offsetHeader,
|
|
90
93
|
zIndex: o.column.getIsPinned() ? 3 : 2,
|
|
91
94
|
background: "var(--background)"
|
|
92
95
|
}
|
|
@@ -94,26 +97,27 @@ function W({
|
|
|
94
97
|
children: o.isPlaceholder ? null : o.column.columnDef.header ? typeof o.column.columnDef.header == "function" ? C(
|
|
95
98
|
o.column.columnDef.header,
|
|
96
99
|
o.getContext()
|
|
97
|
-
) : /* @__PURE__ */ e(
|
|
100
|
+
) : /* @__PURE__ */ e(W, { column: o.column }) : null
|
|
98
101
|
},
|
|
99
102
|
o.id
|
|
100
103
|
)) }, t.id)) }),
|
|
101
|
-
/* @__PURE__ */ e(V, { className: l?.body, children:
|
|
102
|
-
const o = typeof
|
|
103
|
-
|
|
104
|
+
/* @__PURE__ */ e(V, { className: l?.body, children: d.getRowModel().rows?.length ? d.getRowModel().rows.map((t) => {
|
|
105
|
+
const o = typeof u == "function" ? u(t) : u, y = /* @__PURE__ */ e(
|
|
106
|
+
c,
|
|
104
107
|
{
|
|
105
108
|
"data-state": t.getIsSelected() && "selected",
|
|
106
|
-
className:
|
|
109
|
+
className: n(
|
|
107
110
|
l?.row,
|
|
108
111
|
o,
|
|
109
|
-
|
|
112
|
+
m && "ds:cursor-pointer"
|
|
110
113
|
),
|
|
111
|
-
onClick:
|
|
114
|
+
onClick: m ? (r) => m(t, r) : void 0,
|
|
112
115
|
children: t.getVisibleCells().map((r) => {
|
|
113
116
|
const S = /* @__PURE__ */ e(
|
|
114
|
-
|
|
117
|
+
b,
|
|
115
118
|
{
|
|
116
|
-
className:
|
|
119
|
+
className: n(
|
|
120
|
+
"ds:overflow-hidden ds:text-ellipsis",
|
|
117
121
|
l?.cell,
|
|
118
122
|
// Static background on purpose — see the comment on
|
|
119
123
|
// getCommonPinningStyles for why pinned cells must
|
|
@@ -139,16 +143,16 @@ function W({
|
|
|
139
143
|
t.id
|
|
140
144
|
);
|
|
141
145
|
return w ? /* @__PURE__ */ e(k, { children: w(t, y) }, t.id) : y;
|
|
142
|
-
}) : /* @__PURE__ */ e(
|
|
143
|
-
|
|
146
|
+
}) : /* @__PURE__ */ e(c, { className: l?.emptyRow, children: /* @__PURE__ */ e(
|
|
147
|
+
b,
|
|
144
148
|
{
|
|
145
149
|
colSpan: v,
|
|
146
|
-
className:
|
|
147
|
-
children:
|
|
150
|
+
className: n("ds:h-24 ds:text-center", l?.emptyCell),
|
|
151
|
+
children: I ?? "No results."
|
|
148
152
|
}
|
|
149
153
|
) }) }),
|
|
150
|
-
h && /* @__PURE__ */ e(
|
|
151
|
-
|
|
154
|
+
h && /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(c, { className: l?.footerRow, children: /* @__PURE__ */ e(
|
|
155
|
+
b,
|
|
152
156
|
{
|
|
153
157
|
colSpan: v,
|
|
154
158
|
className: l?.footerCell,
|
|
@@ -157,30 +161,30 @@ function W({
|
|
|
157
161
|
bottom: 0,
|
|
158
162
|
zIndex: 2
|
|
159
163
|
} : void 0,
|
|
160
|
-
children: h(
|
|
164
|
+
children: /* @__PURE__ */ e("div", { className: "ds:sticky ds:left-2 ds:w-[calc(100cqw-1rem)]", children: h(d.getRowModel().rows.map((t) => t.original)) })
|
|
161
165
|
}
|
|
162
166
|
) }) })
|
|
163
167
|
]
|
|
164
168
|
}
|
|
165
169
|
),
|
|
166
|
-
/* @__PURE__ */
|
|
170
|
+
/* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-2.5", children: [
|
|
167
171
|
a && /* @__PURE__ */ e(
|
|
168
172
|
F,
|
|
169
173
|
{
|
|
170
174
|
showTotalCount: N,
|
|
171
|
-
totalCount:
|
|
175
|
+
totalCount: j,
|
|
172
176
|
showPageSizeOptions: !0,
|
|
173
177
|
showRowSelectionCount: !0,
|
|
174
|
-
table:
|
|
178
|
+
table: d,
|
|
175
179
|
...a === !0 ? {} : a
|
|
176
180
|
}
|
|
177
181
|
),
|
|
178
|
-
g &&
|
|
182
|
+
g && d.getFilteredSelectedRowModel().rows.length > 0 && g
|
|
179
183
|
] })
|
|
180
184
|
]
|
|
181
185
|
}
|
|
182
186
|
);
|
|
183
187
|
}
|
|
184
188
|
export {
|
|
185
|
-
|
|
189
|
+
U as DataTable
|
|
186
190
|
};
|