@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.
@@ -1,38 +1,38 @@
1
- import { jsx as r, jsxs as s } from "react/jsx-runtime";
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 b } from "./checkbox.js";
4
- import { Tooltip as $ } from "./tooltip.js";
5
- import { useState as k } from "react";
6
- import { TableEmpty as w } from "./table-empty.js";
7
- const m = ({ 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 L({
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: p = !0,
12
- onRowClick: v,
13
- className: c,
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: y = 5,
19
- tableHeightOffset: u
18
+ loadingRows: T = 5,
19
+ tableHeightOffset: f
20
20
  }) {
21
- const [T, f] = k(null), g = { height: u ? `calc(100vh - ${u})` : "calc(100vh - 8rem)" }, h = [
22
- p ? "40px" : null,
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(" "), j = () => /* @__PURE__ */ r(
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(y).fill(0).map((i, l) => /* @__PURE__ */ s(
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: h },
33
+ style: { gridTemplateColumns: p },
34
34
  children: [
35
- p && /* @__PURE__ */ r("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "h-4 w-4 rounded bg-muted animate-pulse" }) }),
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-${l}`
52
+ `skeleton-${h}`
53
53
  ))
54
54
  }
55
55
  );
56
- return x ? /* @__PURE__ */ r(m, { className: c, children: /* @__PURE__ */ s("div", { className: "relative bg-card", children: [
57
- /* @__PURE__ */ s(
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: h },
63
+ style: { gridTemplateColumns: p },
64
64
  children: [
65
- p && /* @__PURE__ */ r("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "h-4 w-4 rounded bg-muted animate-pulse" }) }),
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(j, {})
71
- ] }) }) : t.length === 0 ? /* @__PURE__ */ r(m, { className: c, children: /* @__PURE__ */ r("div", { className: "relative bg-card", children: /* @__PURE__ */ r(w, { ...N }) }) }) : /* @__PURE__ */ r(m, { className: c, children: /* @__PURE__ */ s("div", { className: "relative bg-card", children: [
72
- /* @__PURE__ */ s(
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: h },
78
+ style: { gridTemplateColumns: p },
79
79
  children: [
80
- p && /* @__PURE__ */ r("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ r(
81
- b,
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(), t.forEach((l) => o == null ? void 0 : o(l.id, !(a != null && a.has(l.id))));
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, l) => /* @__PURE__ */ s(
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: h },
105
- onClick: () => v == null ? void 0 : v(i),
108
+ style: { gridTemplateColumns: p },
109
+ onClick: () => c == null ? void 0 : c(i),
106
110
  children: [
107
- p && /* @__PURE__ */ r("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ r(
108
- b,
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__ */ s(
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 && f(`${l}-${e.id}`),
124
- onMouseLeave: () => f(null),
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 && T === `${l}-${e.id}` && /* @__PURE__ */ r(
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
- L as Table
159
+ q as Table
156
160
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@definable/ui",
3
3
  "type": "module",
4
- "version": "0.1.20",
4
+ "version": "0.1.21",
5
5
  "private": false,
6
6
  "description": "Definable UI Component Library",
7
7
  "main": "dist/index.js",