@definable/ui 0.1.20 → 0.1.21
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/components/table.js +45 -41
- package/package.json +1 -1
package/dist/components/table.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
1
|
+
import { jsx as r, jsxs as l } from "react/jsx-runtime";
|
|
2
2
|
import { cn as d } from "../lib/utils.js";
|
|
3
|
-
import { Checkbox as
|
|
4
|
-
import { Tooltip as
|
|
5
|
-
import { useState as
|
|
6
|
-
import { TableEmpty as
|
|
7
|
-
const
|
|
8
|
-
function
|
|
3
|
+
import { Checkbox as y } from "./checkbox.js";
|
|
4
|
+
import { Tooltip as k } from "./tooltip.js";
|
|
5
|
+
import { useState as w } from "react";
|
|
6
|
+
import { TableEmpty as z } from "./table-empty.js";
|
|
7
|
+
const u = ({ children: t, className: n }) => /* @__PURE__ */ r("div", { className: d("border border-border/50 rounded-lg overflow-hidden bg-background shadow-sm", n), children: t });
|
|
8
|
+
function q({
|
|
9
9
|
data: t,
|
|
10
10
|
columns: n,
|
|
11
|
-
showCheckbox:
|
|
12
|
-
onRowClick:
|
|
13
|
-
className:
|
|
11
|
+
showCheckbox: s = !0,
|
|
12
|
+
onRowClick: c,
|
|
13
|
+
className: v,
|
|
14
14
|
selectedItems: a,
|
|
15
15
|
onSelect: o,
|
|
16
16
|
emptyState: N,
|
|
17
17
|
isLoading: x = !1,
|
|
18
|
-
loadingRows:
|
|
19
|
-
tableHeightOffset:
|
|
18
|
+
loadingRows: T = 5,
|
|
19
|
+
tableHeightOffset: f
|
|
20
20
|
}) {
|
|
21
|
-
const [
|
|
22
|
-
|
|
21
|
+
const [j, m] = w(null), g = { height: f ? `calc(100vh - ${f})` : "calc(100vh - 8rem)" }, p = [
|
|
22
|
+
s ? "40px" : null,
|
|
23
23
|
...n.map((i) => i.width || "1fr")
|
|
24
|
-
].filter(Boolean).join(" "),
|
|
24
|
+
].filter(Boolean).join(" "), $ = () => /* @__PURE__ */ r(
|
|
25
25
|
"div",
|
|
26
26
|
{
|
|
27
27
|
className: d("divide-y divide-border/50 overflow-y-auto"),
|
|
28
28
|
style: g,
|
|
29
|
-
children: Array(
|
|
29
|
+
children: Array(T).fill(0).map((i, h) => /* @__PURE__ */ l(
|
|
30
30
|
"div",
|
|
31
31
|
{
|
|
32
32
|
className: "grid items-center px-6 py-4 text-sm",
|
|
33
|
-
style: { gridTemplateColumns:
|
|
33
|
+
style: { gridTemplateColumns: p },
|
|
34
34
|
children: [
|
|
35
|
-
|
|
35
|
+
s && /* @__PURE__ */ r("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "h-4 w-4 rounded bg-muted animate-pulse" }) }),
|
|
36
36
|
n.map((e) => /* @__PURE__ */ r(
|
|
37
37
|
"div",
|
|
38
38
|
{
|
|
@@ -49,40 +49,44 @@ function L({
|
|
|
49
49
|
))
|
|
50
50
|
]
|
|
51
51
|
},
|
|
52
|
-
`skeleton-${
|
|
52
|
+
`skeleton-${h}`
|
|
53
53
|
))
|
|
54
54
|
}
|
|
55
55
|
);
|
|
56
|
-
return x ? /* @__PURE__ */ r(
|
|
57
|
-
/* @__PURE__ */
|
|
56
|
+
return x ? /* @__PURE__ */ r(u, { className: v, children: /* @__PURE__ */ l("div", { className: "relative bg-card", children: [
|
|
57
|
+
/* @__PURE__ */ l(
|
|
58
58
|
"div",
|
|
59
59
|
{
|
|
60
60
|
className: d(
|
|
61
61
|
"grid items-center px-6 py-3 text-xs font-medium text-muted-foreground/80 bg-muted/30 border-b border-border/50 sticky top-0 z-10"
|
|
62
62
|
),
|
|
63
|
-
style: { gridTemplateColumns:
|
|
63
|
+
style: { gridTemplateColumns: p },
|
|
64
64
|
children: [
|
|
65
|
-
|
|
65
|
+
s && /* @__PURE__ */ r("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "h-4 w-4 rounded bg-muted animate-pulse" }) }),
|
|
66
66
|
n.map((i) => /* @__PURE__ */ r("div", { className: d("px-2 font-medium", i.className), children: i.header }, i.id))
|
|
67
67
|
]
|
|
68
68
|
}
|
|
69
69
|
),
|
|
70
|
-
/* @__PURE__ */ r(
|
|
71
|
-
] }) }) : t.length === 0 ? /* @__PURE__ */ r(
|
|
72
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ r($, {})
|
|
71
|
+
] }) }) : t.length === 0 ? /* @__PURE__ */ r(u, { className: v, children: /* @__PURE__ */ r("div", { className: "relative bg-card", children: /* @__PURE__ */ r(z, { ...N }) }) }) : /* @__PURE__ */ r(u, { className: v, children: /* @__PURE__ */ l("div", { className: "relative bg-card", children: [
|
|
72
|
+
/* @__PURE__ */ l(
|
|
73
73
|
"div",
|
|
74
74
|
{
|
|
75
75
|
className: d(
|
|
76
76
|
"grid items-center px-6 py-3 text-xs font-medium text-muted-foreground/80 bg-muted/30 border-b border-border/50 sticky top-0 z-10"
|
|
77
77
|
),
|
|
78
|
-
style: { gridTemplateColumns:
|
|
78
|
+
style: { gridTemplateColumns: p },
|
|
79
79
|
children: [
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
s && /* @__PURE__ */ r("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ r(
|
|
81
|
+
y,
|
|
82
82
|
{
|
|
83
83
|
checked: t.length > 0 && (a == null ? void 0 : a.size) === t.length,
|
|
84
84
|
onClick: (i) => {
|
|
85
|
-
i.stopPropagation()
|
|
85
|
+
i.stopPropagation();
|
|
86
|
+
const e = !((a == null ? void 0 : a.size) === t.length);
|
|
87
|
+
t.forEach((b) => {
|
|
88
|
+
(a == null ? void 0 : a.has(b.id)) !== e && (o == null || o(b.id, e));
|
|
89
|
+
});
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
) }),
|
|
@@ -95,17 +99,17 @@ function L({
|
|
|
95
99
|
{
|
|
96
100
|
className: d("divide-y divide-border/30 overflow-y-auto"),
|
|
97
101
|
style: g,
|
|
98
|
-
children: t.map((i,
|
|
102
|
+
children: t.map((i, h) => /* @__PURE__ */ l(
|
|
99
103
|
"div",
|
|
100
104
|
{
|
|
101
105
|
className: d(
|
|
102
106
|
"grid items-center px-6 py-4 text-sm text-foreground hover:bg-muted/30 transition-colors duration-150 group cursor-pointer"
|
|
103
107
|
),
|
|
104
|
-
style: { gridTemplateColumns:
|
|
105
|
-
onClick: () =>
|
|
108
|
+
style: { gridTemplateColumns: p },
|
|
109
|
+
onClick: () => c == null ? void 0 : c(i),
|
|
106
110
|
children: [
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
s && /* @__PURE__ */ r("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ r(
|
|
112
|
+
y,
|
|
109
113
|
{
|
|
110
114
|
checked: a == null ? void 0 : a.has(i.id),
|
|
111
115
|
onClick: (e) => {
|
|
@@ -113,15 +117,15 @@ function L({
|
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
119
|
) }),
|
|
116
|
-
n.map((e) => /* @__PURE__ */
|
|
120
|
+
n.map((e) => /* @__PURE__ */ l(
|
|
117
121
|
"div",
|
|
118
122
|
{
|
|
119
123
|
className: d(
|
|
120
124
|
"px-2 relative min-w-0",
|
|
121
125
|
e.className
|
|
122
126
|
),
|
|
123
|
-
onMouseEnter: () => e.tooltipValue &&
|
|
124
|
-
onMouseLeave: () =>
|
|
127
|
+
onMouseEnter: () => e.tooltipValue && m(`${h}-${e.id}`),
|
|
128
|
+
onMouseLeave: () => m(null),
|
|
125
129
|
children: [
|
|
126
130
|
/* @__PURE__ */ r("div", { className: d(
|
|
127
131
|
"flex items-center gap-2",
|
|
@@ -130,8 +134,8 @@ function L({
|
|
|
130
134
|
"w-full",
|
|
131
135
|
e.truncate && "truncate"
|
|
132
136
|
), children: e.cell(i) }) }),
|
|
133
|
-
e.tooltipValue &&
|
|
134
|
-
|
|
137
|
+
e.tooltipValue && j === `${h}-${e.id}` && /* @__PURE__ */ r(
|
|
138
|
+
k,
|
|
135
139
|
{
|
|
136
140
|
content: e.tooltipValue(i),
|
|
137
141
|
side: "bottom",
|
|
@@ -152,5 +156,5 @@ function L({
|
|
|
152
156
|
] }) });
|
|
153
157
|
}
|
|
154
158
|
export {
|
|
155
|
-
|
|
159
|
+
q as Table
|
|
156
160
|
};
|