@nucel/ui 0.2.0 → 0.3.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/package.json +5 -1
- package/src/lib/components/ui/CodeBlock.svelte +92 -0
- package/src/lib/components/ui/CopyButton.svelte +43 -0
- package/src/lib/components/ui/FilterBar.svelte +63 -0
- package/src/lib/components/ui/KanbanBoard.svelte +27 -0
- package/src/lib/components/ui/KanbanCard.svelte +43 -0
- package/src/lib/components/ui/KanbanColumn.svelte +52 -0
- package/src/lib/components/ui/MetricCard.svelte +79 -0
- package/src/lib/components/ui/Pagination.svelte +85 -0
- package/src/lib/components/ui/Timeline.svelte +85 -0
- package/src/lib/index.ts +25 -0
- package/src/lib/components/ui/Alert.test.ts +0 -206
- package/src/lib/components/ui/BranchPill.test.ts +0 -121
- package/src/lib/components/ui/CostDisplay.test.ts +0 -1115
- package/src/lib/components/ui/FormField.test.ts +0 -41
- package/src/lib/components/ui/PageHeader.test.ts +0 -72
- package/src/lib/components/ui/ProgressRing.test.ts +0 -239
- package/src/lib/components/ui/Section.test.ts +0 -44
- package/src/lib/components/ui/StatusBadge.test.ts +0 -150
- package/src/lib/components/ui/StatusPill.test.ts +0 -125
- package/src/lib/components/ui/table/Table.test.ts +0 -317
- package/src/lib/utils/cn.test.ts +0 -993
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { render } from "@testing-library/svelte";
|
|
3
|
-
import Table from "./Table.svelte";
|
|
4
|
-
import TableHeader from "./TableHeader.svelte";
|
|
5
|
-
import TableBody from "./TableBody.svelte";
|
|
6
|
-
import TableRow from "./TableRow.svelte";
|
|
7
|
-
import TableHead from "./TableHead.svelte";
|
|
8
|
-
import TableCell from "./TableCell.svelte";
|
|
9
|
-
import TableCaption from "./TableCaption.svelte";
|
|
10
|
-
|
|
11
|
-
describe("Table", () => {
|
|
12
|
-
it("renders a div wrapper with overflow-auto", () => {
|
|
13
|
-
const { container } = render(Table, {
|
|
14
|
-
props: { children: (() => {}) as any },
|
|
15
|
-
});
|
|
16
|
-
const wrapper = container.querySelector("div");
|
|
17
|
-
expect(wrapper).not.toBeNull();
|
|
18
|
-
expect(wrapper!.className).toContain("overflow-auto");
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("renders a table element inside the wrapper", () => {
|
|
22
|
-
const { container } = render(Table, {
|
|
23
|
-
props: { children: (() => {}) as any },
|
|
24
|
-
});
|
|
25
|
-
const table = container.querySelector("table");
|
|
26
|
-
expect(table).not.toBeNull();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("table element has caption-bottom class", () => {
|
|
30
|
-
const { container } = render(Table, {
|
|
31
|
-
props: { children: (() => {}) as any },
|
|
32
|
-
});
|
|
33
|
-
const table = container.querySelector("table");
|
|
34
|
-
expect(table!.className).toContain("caption-bottom");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("table element has text-sm class", () => {
|
|
38
|
-
const { container } = render(Table, {
|
|
39
|
-
props: { children: (() => {}) as any },
|
|
40
|
-
});
|
|
41
|
-
const table = container.querySelector("table");
|
|
42
|
-
expect(table!.className).toContain("text-sm");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("wrapper has w-full class", () => {
|
|
46
|
-
const { container } = render(Table, {
|
|
47
|
-
props: { children: (() => {}) as any },
|
|
48
|
-
});
|
|
49
|
-
const wrapper = container.querySelector("div");
|
|
50
|
-
expect(wrapper!.className).toContain("w-full");
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("accepts an extra class on the wrapper", () => {
|
|
54
|
-
const { container } = render(Table, {
|
|
55
|
-
props: { children: (() => {}) as any, class: "my-table-wrapper" },
|
|
56
|
-
});
|
|
57
|
-
const wrapper = container.querySelector("div");
|
|
58
|
-
expect(wrapper!.className).toContain("my-table-wrapper");
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("does not lose default classes when class prop is provided", () => {
|
|
62
|
-
const { container } = render(Table, {
|
|
63
|
-
props: { children: (() => {}) as any, class: "extra" },
|
|
64
|
-
});
|
|
65
|
-
const wrapper = container.querySelector("div");
|
|
66
|
-
expect(wrapper!.className).toContain("overflow-auto");
|
|
67
|
-
expect(wrapper!.className).toContain("extra");
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe("TableHeader", () => {
|
|
72
|
-
it("renders a thead element", () => {
|
|
73
|
-
const { container } = render(TableHeader, {
|
|
74
|
-
props: { children: (() => {}) as any },
|
|
75
|
-
});
|
|
76
|
-
expect(container.querySelector("thead")).not.toBeNull();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("thead has [&_tr]:border-b class", () => {
|
|
80
|
-
const { container } = render(TableHeader, {
|
|
81
|
-
props: { children: (() => {}) as any },
|
|
82
|
-
});
|
|
83
|
-
const thead = container.querySelector("thead");
|
|
84
|
-
expect(thead!.className).toContain("[&_tr]:border-b");
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("thead has [&_tr]:border-border class", () => {
|
|
88
|
-
const { container } = render(TableHeader, {
|
|
89
|
-
props: { children: (() => {}) as any },
|
|
90
|
-
});
|
|
91
|
-
const thead = container.querySelector("thead");
|
|
92
|
-
expect(thead!.className).toContain("[&_tr]:border-border");
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("accepts an extra class", () => {
|
|
96
|
-
const { container } = render(TableHeader, {
|
|
97
|
-
props: { children: (() => {}) as any, class: "my-header" },
|
|
98
|
-
});
|
|
99
|
-
const thead = container.querySelector("thead");
|
|
100
|
-
expect(thead!.className).toContain("my-header");
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
describe("TableBody", () => {
|
|
105
|
-
it("renders a tbody element", () => {
|
|
106
|
-
const { container } = render(TableBody, {
|
|
107
|
-
props: { children: (() => {}) as any },
|
|
108
|
-
});
|
|
109
|
-
expect(container.querySelector("tbody")).not.toBeNull();
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("tbody has [&_tr:last-child]:border-0 class", () => {
|
|
113
|
-
const { container } = render(TableBody, {
|
|
114
|
-
props: { children: (() => {}) as any },
|
|
115
|
-
});
|
|
116
|
-
const tbody = container.querySelector("tbody");
|
|
117
|
-
expect(tbody!.className).toContain("[&_tr:last-child]:border-0");
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("accepts an extra class", () => {
|
|
121
|
-
const { container } = render(TableBody, {
|
|
122
|
-
props: { children: (() => {}) as any, class: "my-body" },
|
|
123
|
-
});
|
|
124
|
-
const tbody = container.querySelector("tbody");
|
|
125
|
-
expect(tbody!.className).toContain("my-body");
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
describe("TableRow", () => {
|
|
130
|
-
it("renders a tr element", () => {
|
|
131
|
-
const { container } = render(TableRow, {
|
|
132
|
-
props: { children: (() => {}) as any },
|
|
133
|
-
});
|
|
134
|
-
expect(container.querySelector("tr")).not.toBeNull();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("tr has border-b class", () => {
|
|
138
|
-
const { container } = render(TableRow, {
|
|
139
|
-
props: { children: (() => {}) as any },
|
|
140
|
-
});
|
|
141
|
-
const tr = container.querySelector("tr");
|
|
142
|
-
expect(tr!.className).toContain("border-b");
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("tr has hover:bg-accent/50 class", () => {
|
|
146
|
-
const { container } = render(TableRow, {
|
|
147
|
-
props: { children: (() => {}) as any },
|
|
148
|
-
});
|
|
149
|
-
const tr = container.querySelector("tr");
|
|
150
|
-
expect(tr!.className).toContain("hover:bg-accent/50");
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("tr has transition-colors class", () => {
|
|
154
|
-
const { container } = render(TableRow, {
|
|
155
|
-
props: { children: (() => {}) as any },
|
|
156
|
-
});
|
|
157
|
-
const tr = container.querySelector("tr");
|
|
158
|
-
expect(tr!.className).toContain("transition-colors");
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it("accepts an extra class", () => {
|
|
162
|
-
const { container } = render(TableRow, {
|
|
163
|
-
props: { children: (() => {}) as any, class: "bg-muted/20" },
|
|
164
|
-
});
|
|
165
|
-
const tr = container.querySelector("tr");
|
|
166
|
-
expect(tr!.className).toContain("bg-muted/20");
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it("does not lose base classes when extra class is added", () => {
|
|
170
|
-
const { container } = render(TableRow, {
|
|
171
|
-
props: { children: (() => {}) as any, class: "extra" },
|
|
172
|
-
});
|
|
173
|
-
const tr = container.querySelector("tr");
|
|
174
|
-
expect(tr!.className).toContain("border-b");
|
|
175
|
-
expect(tr!.className).toContain("extra");
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
describe("TableHead", () => {
|
|
180
|
-
it("renders a th element", () => {
|
|
181
|
-
const { container } = render(TableHead, {
|
|
182
|
-
props: { children: (() => {}) as any },
|
|
183
|
-
});
|
|
184
|
-
expect(container.querySelector("th")).not.toBeNull();
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it("th has h-9 class", () => {
|
|
188
|
-
const { container } = render(TableHead, {
|
|
189
|
-
props: { children: (() => {}) as any },
|
|
190
|
-
});
|
|
191
|
-
const th = container.querySelector("th");
|
|
192
|
-
expect(th!.className).toContain("h-9");
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it("th has text-left class", () => {
|
|
196
|
-
const { container } = render(TableHead, {
|
|
197
|
-
props: { children: (() => {}) as any },
|
|
198
|
-
});
|
|
199
|
-
const th = container.querySelector("th");
|
|
200
|
-
expect(th!.className).toContain("text-left");
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it("th has uppercase class", () => {
|
|
204
|
-
const { container } = render(TableHead, {
|
|
205
|
-
props: { children: (() => {}) as any },
|
|
206
|
-
});
|
|
207
|
-
const th = container.querySelector("th");
|
|
208
|
-
expect(th!.className).toContain("uppercase");
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("th has text-muted-foreground class", () => {
|
|
212
|
-
const { container } = render(TableHead, {
|
|
213
|
-
props: { children: (() => {}) as any },
|
|
214
|
-
});
|
|
215
|
-
const th = container.querySelector("th");
|
|
216
|
-
expect(th!.className).toContain("text-muted-foreground");
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it("accepts an extra class", () => {
|
|
220
|
-
const { container } = render(TableHead, {
|
|
221
|
-
props: { children: (() => {}) as any, class: "w-1/4" },
|
|
222
|
-
});
|
|
223
|
-
const th = container.querySelector("th");
|
|
224
|
-
expect(th!.className).toContain("w-1/4");
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
describe("TableCell", () => {
|
|
229
|
-
it("renders a td element", () => {
|
|
230
|
-
const { container } = render(TableCell, {
|
|
231
|
-
props: { children: (() => {}) as any },
|
|
232
|
-
});
|
|
233
|
-
expect(container.querySelector("td")).not.toBeNull();
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it("td has px-4 class", () => {
|
|
237
|
-
const { container } = render(TableCell, {
|
|
238
|
-
props: { children: (() => {}) as any },
|
|
239
|
-
});
|
|
240
|
-
const td = container.querySelector("td");
|
|
241
|
-
expect(td!.className).toContain("px-4");
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it("td has py-2.5 class", () => {
|
|
245
|
-
const { container } = render(TableCell, {
|
|
246
|
-
props: { children: (() => {}) as any },
|
|
247
|
-
});
|
|
248
|
-
const td = container.querySelector("td");
|
|
249
|
-
expect(td!.className).toContain("py-2.5");
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it("td has align-middle class", () => {
|
|
253
|
-
const { container } = render(TableCell, {
|
|
254
|
-
props: { children: (() => {}) as any },
|
|
255
|
-
});
|
|
256
|
-
const td = container.querySelector("td");
|
|
257
|
-
expect(td!.className).toContain("align-middle");
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
it("accepts an extra class", () => {
|
|
261
|
-
const { container } = render(TableCell, {
|
|
262
|
-
props: { children: (() => {}) as any, class: "font-mono" },
|
|
263
|
-
});
|
|
264
|
-
const td = container.querySelector("td");
|
|
265
|
-
expect(td!.className).toContain("font-mono");
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it("does not lose base classes when extra class is added", () => {
|
|
269
|
-
const { container } = render(TableCell, {
|
|
270
|
-
props: { children: (() => {}) as any, class: "extra" },
|
|
271
|
-
});
|
|
272
|
-
const td = container.querySelector("td");
|
|
273
|
-
expect(td!.className).toContain("px-4");
|
|
274
|
-
expect(td!.className).toContain("extra");
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
describe("TableCaption", () => {
|
|
279
|
-
it("renders a caption element", () => {
|
|
280
|
-
const { container } = render(TableCaption, {
|
|
281
|
-
props: { children: (() => {}) as any },
|
|
282
|
-
});
|
|
283
|
-
expect(container.querySelector("caption")).not.toBeNull();
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
it("caption has mt-4 class", () => {
|
|
287
|
-
const { container } = render(TableCaption, {
|
|
288
|
-
props: { children: (() => {}) as any },
|
|
289
|
-
});
|
|
290
|
-
const caption = container.querySelector("caption");
|
|
291
|
-
expect(caption!.className).toContain("mt-4");
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it("caption has text-xs class", () => {
|
|
295
|
-
const { container } = render(TableCaption, {
|
|
296
|
-
props: { children: (() => {}) as any },
|
|
297
|
-
});
|
|
298
|
-
const caption = container.querySelector("caption");
|
|
299
|
-
expect(caption!.className).toContain("text-xs");
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it("caption has text-muted-foreground class", () => {
|
|
303
|
-
const { container } = render(TableCaption, {
|
|
304
|
-
props: { children: (() => {}) as any },
|
|
305
|
-
});
|
|
306
|
-
const caption = container.querySelector("caption");
|
|
307
|
-
expect(caption!.className).toContain("text-muted-foreground");
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
it("accepts an extra class", () => {
|
|
311
|
-
const { container } = render(TableCaption, {
|
|
312
|
-
props: { children: (() => {}) as any, class: "italic" },
|
|
313
|
-
});
|
|
314
|
-
const caption = container.querySelector("caption");
|
|
315
|
-
expect(caption!.className).toContain("italic");
|
|
316
|
-
});
|
|
317
|
-
});
|