@alexgorbatchev/shadcn 0.0.206 → 0.0.208
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-42tcze5n.js} +144 -25
- package/dist/components/Kanban.d.ts +9 -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 +34 -0
- package/package.json +1 -1
|
@@ -303,20 +303,150 @@ 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 readOnlyGridClassName = "grid gap-6 @3xl:auto-cols-[minmax(14rem,1fr)] @3xl:grid-flow-col @3xl:gap-4";
|
|
313
|
+
var readOnlyColumnClassName = "flex min-w-0 flex-col gap-3 @3xl:self-start @3xl:rounded-sm @3xl:border @3xl:border-border @3xl:bg-muted/30 @3xl:p-3";
|
|
314
|
+
var cardClassName = "grid gap-3 rounded-sm border border-border bg-card p-3 text-sm";
|
|
315
|
+
var readOnlyCardClassName = `${cardClassName} outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring`;
|
|
316
|
+
function ColumnHeader({ label, count }) {
|
|
317
|
+
return /* @__PURE__ */ jsxs3("header", {
|
|
318
|
+
className: "flex items-center justify-between gap-2",
|
|
319
|
+
children: [
|
|
320
|
+
/* @__PURE__ */ jsx4("h2", {
|
|
321
|
+
className: "text-sm font-semibold",
|
|
322
|
+
children: label
|
|
323
|
+
}),
|
|
324
|
+
/* @__PURE__ */ jsx4(Badge2, {
|
|
325
|
+
variant: "secondary",
|
|
326
|
+
"aria-label": `${label} count`,
|
|
327
|
+
children: count
|
|
328
|
+
})
|
|
329
|
+
]
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
function EmptyColumn({ children }) {
|
|
333
|
+
return /* @__PURE__ */ jsx4("p", {
|
|
334
|
+
className: "py-6 text-center text-sm text-muted-foreground",
|
|
335
|
+
children
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function getNextCard(cards, current, key) {
|
|
339
|
+
const column = cards.findIndex((list) => list.includes(current));
|
|
340
|
+
const index = cards[column].indexOf(current);
|
|
341
|
+
if (key === "ArrowDown")
|
|
342
|
+
return cards[column][index + 1];
|
|
343
|
+
if (key === "ArrowUp")
|
|
344
|
+
return cards[column][index - 1];
|
|
345
|
+
if (key === "Home")
|
|
346
|
+
return cards[column][0];
|
|
347
|
+
if (key === "End")
|
|
348
|
+
return cards[column].at(-1);
|
|
349
|
+
const step = key === "ArrowRight" ? 1 : key === "ArrowLeft" ? -1 : 0;
|
|
350
|
+
if (!step)
|
|
351
|
+
return;
|
|
352
|
+
for (let next = column + step;next >= 0 && next < cards.length; next += step) {
|
|
353
|
+
const list = cards[next];
|
|
354
|
+
if (list.length)
|
|
355
|
+
return list[Math.min(index, list.length - 1)];
|
|
356
|
+
}
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
function ReadOnlyKanban({
|
|
310
360
|
label,
|
|
311
361
|
columns,
|
|
312
362
|
items,
|
|
313
|
-
onItemsChange,
|
|
314
363
|
renderItem,
|
|
315
|
-
|
|
316
|
-
disabled,
|
|
364
|
+
emptyLabel,
|
|
317
365
|
density
|
|
318
366
|
}) {
|
|
367
|
+
const cards = columns.map((column) => items.filter((item) => item.columnId === column.id));
|
|
368
|
+
const [currentId, setCurrentId] = useState3();
|
|
369
|
+
const tabStopId = items.some((item) => item.id === currentId) ? currentId : cards.flat()[0]?.id;
|
|
370
|
+
const onKeyDown = (event, item) => {
|
|
371
|
+
if (event.target !== event.currentTarget || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
|
|
372
|
+
return;
|
|
373
|
+
if (event.key === "Enter") {
|
|
374
|
+
event.preventDefault();
|
|
375
|
+
event.currentTarget.querySelector("a[href], button:not(:disabled)")?.click();
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const next = getNextCard(cards, item, event.key);
|
|
379
|
+
if (!next)
|
|
380
|
+
return;
|
|
381
|
+
event.preventDefault();
|
|
382
|
+
const board = event.currentTarget.closest("[data-kanban-board]");
|
|
383
|
+
board?.querySelector(`[data-kanban-card="${CSS.escape(next.id)}"]`)?.focus();
|
|
384
|
+
};
|
|
385
|
+
return /* @__PURE__ */ jsx4("div", {
|
|
386
|
+
role: "region",
|
|
387
|
+
"aria-label": label,
|
|
388
|
+
"data-density": density,
|
|
389
|
+
"data-kanban-board": "",
|
|
390
|
+
className: boardClassName,
|
|
391
|
+
children: /* @__PURE__ */ jsx4("div", {
|
|
392
|
+
className: readOnlyGridClassName,
|
|
393
|
+
children: columns.map((column, columnIndex) => {
|
|
394
|
+
const list = cards[columnIndex];
|
|
395
|
+
return /* @__PURE__ */ jsxs3("section", {
|
|
396
|
+
"aria-label": column.label,
|
|
397
|
+
"data-scroll": "none",
|
|
398
|
+
className: readOnlyColumnClassName,
|
|
399
|
+
children: [
|
|
400
|
+
/* @__PURE__ */ jsx4(ColumnHeader, {
|
|
401
|
+
label: column.label,
|
|
402
|
+
count: list.length
|
|
403
|
+
}),
|
|
404
|
+
/* @__PURE__ */ jsx4("ol", {
|
|
405
|
+
className: "grid gap-2",
|
|
406
|
+
children: list.map((item) => /* @__PURE__ */ jsx4("li", {
|
|
407
|
+
children: /* @__PURE__ */ jsx4("div", {
|
|
408
|
+
role: "group",
|
|
409
|
+
"aria-label": item.title,
|
|
410
|
+
tabIndex: item.id === tabStopId ? 0 : -1,
|
|
411
|
+
"data-kanban-card": item.id,
|
|
412
|
+
"data-scroll": "none",
|
|
413
|
+
className: readOnlyCardClassName,
|
|
414
|
+
onFocus: () => setCurrentId(item.id),
|
|
415
|
+
onKeyDown: (event) => onKeyDown(event, item),
|
|
416
|
+
children: renderItem ? renderItem(item) : /* @__PURE__ */ jsx4("h3", {
|
|
417
|
+
className: "font-medium",
|
|
418
|
+
children: item.title
|
|
419
|
+
})
|
|
420
|
+
})
|
|
421
|
+
}, item.id))
|
|
422
|
+
}),
|
|
423
|
+
!list.length && /* @__PURE__ */ jsx4(EmptyColumn, {
|
|
424
|
+
children: emptyLabel
|
|
425
|
+
})
|
|
426
|
+
]
|
|
427
|
+
}, column.id);
|
|
428
|
+
})
|
|
429
|
+
})
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
function Kanban2(props) {
|
|
433
|
+
const {
|
|
434
|
+
label,
|
|
435
|
+
columns,
|
|
436
|
+
items,
|
|
437
|
+
onItemsChange,
|
|
438
|
+
renderItem,
|
|
439
|
+
canMove,
|
|
440
|
+
disabled,
|
|
441
|
+
emptyLabel = "No items",
|
|
442
|
+
density
|
|
443
|
+
} = props;
|
|
319
444
|
const boardId = useId3();
|
|
445
|
+
if (!onItemsChange)
|
|
446
|
+
return /* @__PURE__ */ jsx4(ReadOnlyKanban, {
|
|
447
|
+
...props,
|
|
448
|
+
emptyLabel
|
|
449
|
+
});
|
|
320
450
|
const type = `application/x-kanban-${boardId.replaceAll(":", "").toLowerCase()}`;
|
|
321
451
|
const canDropInto = (data, columnId) => typeof data === "string" && !disabled && items.some((item) => item.id === data && (!canMove || canMove(item, columnId)));
|
|
322
452
|
const move = (id, columnId, beforeId) => {
|
|
@@ -333,9 +463,9 @@ function Kanban2({
|
|
|
333
463
|
role: "region",
|
|
334
464
|
"aria-label": label,
|
|
335
465
|
"data-density": density,
|
|
336
|
-
className:
|
|
466
|
+
className: boardClassName,
|
|
337
467
|
children: /* @__PURE__ */ jsx4("div", {
|
|
338
|
-
className:
|
|
468
|
+
className: gridClassName,
|
|
339
469
|
children: columns.map((column) => {
|
|
340
470
|
const cards = items.filter((item) => item.columnId === column.id);
|
|
341
471
|
return /* @__PURE__ */ jsxs3(DropTarget2, {
|
|
@@ -349,21 +479,11 @@ function Kanban2({
|
|
|
349
479
|
"aria-label": column.label,
|
|
350
480
|
"data-scroll": "none"
|
|
351
481
|
}),
|
|
352
|
-
className:
|
|
482
|
+
className: columnClassName,
|
|
353
483
|
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
|
-
]
|
|
484
|
+
/* @__PURE__ */ jsx4(ColumnHeader, {
|
|
485
|
+
label: column.label,
|
|
486
|
+
count: cards.length
|
|
367
487
|
}),
|
|
368
488
|
/* @__PURE__ */ jsx4("ol", {
|
|
369
489
|
className: "grid gap-2",
|
|
@@ -380,7 +500,7 @@ function Kanban2({
|
|
|
380
500
|
data: item.id,
|
|
381
501
|
labels: [item.title],
|
|
382
502
|
disabled,
|
|
383
|
-
className:
|
|
503
|
+
className: `${cardClassName} data-dragging:opacity-50`,
|
|
384
504
|
role: "group",
|
|
385
505
|
"aria-label": item.title,
|
|
386
506
|
"data-scroll": "none",
|
|
@@ -431,9 +551,8 @@ function Kanban2({
|
|
|
431
551
|
})
|
|
432
552
|
}, item.id))
|
|
433
553
|
}),
|
|
434
|
-
!cards.length && /* @__PURE__ */ jsx4(
|
|
435
|
-
|
|
436
|
-
children: "No items"
|
|
554
|
+
!cards.length && /* @__PURE__ */ jsx4(EmptyColumn, {
|
|
555
|
+
children: emptyLabel
|
|
437
556
|
})
|
|
438
557
|
]
|
|
439
558
|
}, column.id);
|
|
@@ -13,11 +13,18 @@ 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
|
+
* Its columns end after their last card, and stacked columns show their heading over their cards without a panel.
|
|
20
|
+
*/
|
|
21
|
+
onItemsChange?: (items: T[]) => void;
|
|
17
22
|
renderItem?: (item: T) => ReactNode;
|
|
18
23
|
canMove?: (item: T, columnId: string) => boolean;
|
|
19
24
|
disabled?: boolean;
|
|
25
|
+
/** Shown in a column without cards. */
|
|
26
|
+
emptyLabel?: ReactNode;
|
|
20
27
|
};
|
|
21
|
-
declare function Kanban<T extends KanbanItem>(
|
|
28
|
+
declare function Kanban<T extends KanbanItem>(props: KanbanProps<T>): ReactElement;
|
|
22
29
|
export { Kanban };
|
|
23
30
|
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.208",
|
|
2055
2055
|
description: "Sharp, monospace React components with compact, comfortable, and touch densities.",
|
|
2056
2056
|
license: "MIT",
|
|
2057
2057
|
repository: {
|
|
@@ -48,3 +48,37 @@ 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
|
+
### ReadOnlyWide
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
{
|
|
72
|
+
render: () => <ReadOnlyExample width={1000}/>
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Wide
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
{
|
|
80
|
+
render: () => (<div style={{ width: 1000 }}>
|
|
81
|
+
<Example />
|
|
82
|
+
</div>)
|
|
83
|
+
}
|
|
84
|
+
```
|