@alexgorbatchev/shadcn 0.0.206 → 0.0.207
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/{chunk-zpqfte56.js → chunk-w474hday.js} +142 -25
- package/dist/components/Kanban.d.ts +8 -2
- package/dist/components/gantt/index.js +1 -1
- package/dist/components/json-render/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/prototype.js +1 -1
- package/llms/components/planning/Kanban.md +26 -0
- package/package.json +1 -1
|
@@ -303,20 +303,148 @@ function DropTarget2({
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
// src/components/Kanban.tsx
|
|
306
|
-
import { useId as useId3 } from "react";
|
|
306
|
+
import { useId as useId3, useState as useState3 } from "react";
|
|
307
307
|
import { ArrowDownIcon, ArrowUpIcon } from "lucide-react";
|
|
308
308
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
309
|
-
|
|
309
|
+
var boardClassName = "@container overflow-x-auto";
|
|
310
|
+
var gridClassName = "grid gap-4 @3xl:auto-cols-[minmax(14rem,1fr)] @3xl:grid-flow-col";
|
|
311
|
+
var columnClassName = "flex min-w-0 flex-col gap-3 @3xl:min-h-48 rounded-sm border border-border bg-muted/30 p-3 data-over:border-primary";
|
|
312
|
+
var cardClassName = "grid gap-3 rounded-sm border border-border bg-card p-3 text-sm";
|
|
313
|
+
var readOnlyCardClassName = `${cardClassName} outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring`;
|
|
314
|
+
function ColumnHeader({ label, count }) {
|
|
315
|
+
return /* @__PURE__ */ jsxs3("header", {
|
|
316
|
+
className: "flex items-center justify-between gap-2",
|
|
317
|
+
children: [
|
|
318
|
+
/* @__PURE__ */ jsx4("h2", {
|
|
319
|
+
className: "text-sm font-semibold",
|
|
320
|
+
children: label
|
|
321
|
+
}),
|
|
322
|
+
/* @__PURE__ */ jsx4(Badge2, {
|
|
323
|
+
variant: "secondary",
|
|
324
|
+
"aria-label": `${label} count`,
|
|
325
|
+
children: count
|
|
326
|
+
})
|
|
327
|
+
]
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
function EmptyColumn({ children }) {
|
|
331
|
+
return /* @__PURE__ */ jsx4("p", {
|
|
332
|
+
className: "py-6 text-center text-sm text-muted-foreground",
|
|
333
|
+
children
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
function getNextCard(cards, current, key) {
|
|
337
|
+
const column = cards.findIndex((list) => list.includes(current));
|
|
338
|
+
const index = cards[column].indexOf(current);
|
|
339
|
+
if (key === "ArrowDown")
|
|
340
|
+
return cards[column][index + 1];
|
|
341
|
+
if (key === "ArrowUp")
|
|
342
|
+
return cards[column][index - 1];
|
|
343
|
+
if (key === "Home")
|
|
344
|
+
return cards[column][0];
|
|
345
|
+
if (key === "End")
|
|
346
|
+
return cards[column].at(-1);
|
|
347
|
+
const step = key === "ArrowRight" ? 1 : key === "ArrowLeft" ? -1 : 0;
|
|
348
|
+
if (!step)
|
|
349
|
+
return;
|
|
350
|
+
for (let next = column + step;next >= 0 && next < cards.length; next += step) {
|
|
351
|
+
const list = cards[next];
|
|
352
|
+
if (list.length)
|
|
353
|
+
return list[Math.min(index, list.length - 1)];
|
|
354
|
+
}
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
function ReadOnlyKanban({
|
|
310
358
|
label,
|
|
311
359
|
columns,
|
|
312
360
|
items,
|
|
313
|
-
onItemsChange,
|
|
314
361
|
renderItem,
|
|
315
|
-
|
|
316
|
-
disabled,
|
|
362
|
+
emptyLabel,
|
|
317
363
|
density
|
|
318
364
|
}) {
|
|
365
|
+
const cards = columns.map((column) => items.filter((item) => item.columnId === column.id));
|
|
366
|
+
const [currentId, setCurrentId] = useState3();
|
|
367
|
+
const tabStopId = items.some((item) => item.id === currentId) ? currentId : cards.flat()[0]?.id;
|
|
368
|
+
const onKeyDown = (event, item) => {
|
|
369
|
+
if (event.target !== event.currentTarget || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
|
|
370
|
+
return;
|
|
371
|
+
if (event.key === "Enter") {
|
|
372
|
+
event.preventDefault();
|
|
373
|
+
event.currentTarget.querySelector("a[href], button:not(:disabled)")?.click();
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
const next = getNextCard(cards, item, event.key);
|
|
377
|
+
if (!next)
|
|
378
|
+
return;
|
|
379
|
+
event.preventDefault();
|
|
380
|
+
const board = event.currentTarget.closest("[data-kanban-board]");
|
|
381
|
+
board?.querySelector(`[data-kanban-card="${CSS.escape(next.id)}"]`)?.focus();
|
|
382
|
+
};
|
|
383
|
+
return /* @__PURE__ */ jsx4("div", {
|
|
384
|
+
role: "region",
|
|
385
|
+
"aria-label": label,
|
|
386
|
+
"data-density": density,
|
|
387
|
+
"data-kanban-board": "",
|
|
388
|
+
className: boardClassName,
|
|
389
|
+
children: /* @__PURE__ */ jsx4("div", {
|
|
390
|
+
className: gridClassName,
|
|
391
|
+
children: columns.map((column, columnIndex) => {
|
|
392
|
+
const list = cards[columnIndex];
|
|
393
|
+
return /* @__PURE__ */ jsxs3("section", {
|
|
394
|
+
"aria-label": column.label,
|
|
395
|
+
"data-scroll": "none",
|
|
396
|
+
className: columnClassName,
|
|
397
|
+
children: [
|
|
398
|
+
/* @__PURE__ */ jsx4(ColumnHeader, {
|
|
399
|
+
label: column.label,
|
|
400
|
+
count: list.length
|
|
401
|
+
}),
|
|
402
|
+
/* @__PURE__ */ jsx4("ol", {
|
|
403
|
+
className: "grid gap-2",
|
|
404
|
+
children: list.map((item) => /* @__PURE__ */ jsx4("li", {
|
|
405
|
+
children: /* @__PURE__ */ jsx4("div", {
|
|
406
|
+
role: "group",
|
|
407
|
+
"aria-label": item.title,
|
|
408
|
+
tabIndex: item.id === tabStopId ? 0 : -1,
|
|
409
|
+
"data-kanban-card": item.id,
|
|
410
|
+
"data-scroll": "none",
|
|
411
|
+
className: readOnlyCardClassName,
|
|
412
|
+
onFocus: () => setCurrentId(item.id),
|
|
413
|
+
onKeyDown: (event) => onKeyDown(event, item),
|
|
414
|
+
children: renderItem ? renderItem(item) : /* @__PURE__ */ jsx4("h3", {
|
|
415
|
+
className: "font-medium",
|
|
416
|
+
children: item.title
|
|
417
|
+
})
|
|
418
|
+
})
|
|
419
|
+
}, item.id))
|
|
420
|
+
}),
|
|
421
|
+
!list.length && /* @__PURE__ */ jsx4(EmptyColumn, {
|
|
422
|
+
children: emptyLabel
|
|
423
|
+
})
|
|
424
|
+
]
|
|
425
|
+
}, column.id);
|
|
426
|
+
})
|
|
427
|
+
})
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
function Kanban2(props) {
|
|
431
|
+
const {
|
|
432
|
+
label,
|
|
433
|
+
columns,
|
|
434
|
+
items,
|
|
435
|
+
onItemsChange,
|
|
436
|
+
renderItem,
|
|
437
|
+
canMove,
|
|
438
|
+
disabled,
|
|
439
|
+
emptyLabel = "No items",
|
|
440
|
+
density
|
|
441
|
+
} = props;
|
|
319
442
|
const boardId = useId3();
|
|
443
|
+
if (!onItemsChange)
|
|
444
|
+
return /* @__PURE__ */ jsx4(ReadOnlyKanban, {
|
|
445
|
+
...props,
|
|
446
|
+
emptyLabel
|
|
447
|
+
});
|
|
320
448
|
const type = `application/x-kanban-${boardId.replaceAll(":", "").toLowerCase()}`;
|
|
321
449
|
const canDropInto = (data, columnId) => typeof data === "string" && !disabled && items.some((item) => item.id === data && (!canMove || canMove(item, columnId)));
|
|
322
450
|
const move = (id, columnId, beforeId) => {
|
|
@@ -333,9 +461,9 @@ function Kanban2({
|
|
|
333
461
|
role: "region",
|
|
334
462
|
"aria-label": label,
|
|
335
463
|
"data-density": density,
|
|
336
|
-
className:
|
|
464
|
+
className: boardClassName,
|
|
337
465
|
children: /* @__PURE__ */ jsx4("div", {
|
|
338
|
-
className:
|
|
466
|
+
className: gridClassName,
|
|
339
467
|
children: columns.map((column) => {
|
|
340
468
|
const cards = items.filter((item) => item.columnId === column.id);
|
|
341
469
|
return /* @__PURE__ */ jsxs3(DropTarget2, {
|
|
@@ -349,21 +477,11 @@ function Kanban2({
|
|
|
349
477
|
"aria-label": column.label,
|
|
350
478
|
"data-scroll": "none"
|
|
351
479
|
}),
|
|
352
|
-
className:
|
|
480
|
+
className: columnClassName,
|
|
353
481
|
children: [
|
|
354
|
-
/* @__PURE__ */
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
/* @__PURE__ */ jsx4("h2", {
|
|
358
|
-
className: "text-sm font-semibold",
|
|
359
|
-
children: column.label
|
|
360
|
-
}),
|
|
361
|
-
/* @__PURE__ */ jsx4(Badge2, {
|
|
362
|
-
variant: "secondary",
|
|
363
|
-
"aria-label": `${column.label} count`,
|
|
364
|
-
children: cards.length
|
|
365
|
-
})
|
|
366
|
-
]
|
|
482
|
+
/* @__PURE__ */ jsx4(ColumnHeader, {
|
|
483
|
+
label: column.label,
|
|
484
|
+
count: cards.length
|
|
367
485
|
}),
|
|
368
486
|
/* @__PURE__ */ jsx4("ol", {
|
|
369
487
|
className: "grid gap-2",
|
|
@@ -380,7 +498,7 @@ function Kanban2({
|
|
|
380
498
|
data: item.id,
|
|
381
499
|
labels: [item.title],
|
|
382
500
|
disabled,
|
|
383
|
-
className:
|
|
501
|
+
className: `${cardClassName} data-dragging:opacity-50`,
|
|
384
502
|
role: "group",
|
|
385
503
|
"aria-label": item.title,
|
|
386
504
|
"data-scroll": "none",
|
|
@@ -431,9 +549,8 @@ function Kanban2({
|
|
|
431
549
|
})
|
|
432
550
|
}, item.id))
|
|
433
551
|
}),
|
|
434
|
-
!cards.length && /* @__PURE__ */ jsx4(
|
|
435
|
-
|
|
436
|
-
children: "No items"
|
|
552
|
+
!cards.length && /* @__PURE__ */ jsx4(EmptyColumn, {
|
|
553
|
+
children: emptyLabel
|
|
437
554
|
})
|
|
438
555
|
]
|
|
439
556
|
}, column.id);
|
|
@@ -13,11 +13,17 @@ type KanbanProps<T extends KanbanItem> = IDensityProps & {
|
|
|
13
13
|
label: string;
|
|
14
14
|
columns: readonly KanbanColumn[];
|
|
15
15
|
items: readonly T[];
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Receives the reordered items after a move. Omit it for a read-only board: cards cannot be dragged and show no move
|
|
18
|
+
* controls, the board is one Tab stop, arrow keys move between cards and Enter activates the card's first link or button.
|
|
19
|
+
*/
|
|
20
|
+
onItemsChange?: (items: T[]) => void;
|
|
17
21
|
renderItem?: (item: T) => ReactNode;
|
|
18
22
|
canMove?: (item: T, columnId: string) => boolean;
|
|
19
23
|
disabled?: boolean;
|
|
24
|
+
/** Shown in a column without cards. */
|
|
25
|
+
emptyLabel?: ReactNode;
|
|
20
26
|
};
|
|
21
|
-
declare function Kanban<T extends KanbanItem>(
|
|
27
|
+
declare function Kanban<T extends KanbanItem>(props: KanbanProps<T>): ReactElement;
|
|
22
28
|
export { Kanban };
|
|
23
29
|
export type { KanbanProps, KanbanColumn, KanbanItem };
|
package/dist/index.js
CHANGED
package/dist/prototype.js
CHANGED
|
@@ -2051,7 +2051,7 @@ var program = new Command;
|
|
|
2051
2051
|
// package.json
|
|
2052
2052
|
var package_default = {
|
|
2053
2053
|
name: "@alexgorbatchev/shadcn",
|
|
2054
|
-
version: "0.0.
|
|
2054
|
+
version: "0.0.207",
|
|
2055
2055
|
description: "Sharp, monospace React components with compact, comfortable, and touch densities.",
|
|
2056
2056
|
license: "MIT",
|
|
2057
2057
|
repository: {
|
|
@@ -48,3 +48,29 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
48
48
|
render: () => <Example restricted/>
|
|
49
49
|
}
|
|
50
50
|
```
|
|
51
|
+
|
|
52
|
+
### ReadOnly
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
{
|
|
56
|
+
render: () => <ReadOnlyExample />
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### ReadOnlyNarrow
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
{
|
|
64
|
+
render: () => <ReadOnlyExample width={320}/>
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Wide
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
{
|
|
72
|
+
render: () => (<div style={{ width: 1000 }}>
|
|
73
|
+
<Example />
|
|
74
|
+
</div>)
|
|
75
|
+
}
|
|
76
|
+
```
|