@alexgorbatchev/shadcn 0.0.213 → 0.0.215

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.
@@ -1675,12 +1675,26 @@ function Breadcrumb2({ density, className, ...props }) {
1675
1675
  ...props
1676
1676
  });
1677
1677
  }
1678
- function BreadcrumbList2({ density, overflow = "wrap", className, ...props }) {
1678
+ var LIST_SIZE_CLASSES = {
1679
+ sm: "text-sm leading-6",
1680
+ base: "text-base leading-6",
1681
+ lg: "text-lg leading-7",
1682
+ xl: "text-xl leading-7",
1683
+ "2xl": "text-2xl leading-8 tracking-tight",
1684
+ "3xl": "text-3xl leading-9 tracking-tight"
1685
+ };
1686
+ function BreadcrumbList2({
1687
+ density,
1688
+ size = "sm",
1689
+ overflow = "wrap",
1690
+ className,
1691
+ ...props
1692
+ }) {
1679
1693
  return /* @__PURE__ */ jsx18("ol", {
1680
1694
  "data-density": density,
1681
1695
  "data-slot": "breadcrumb-list",
1682
1696
  "data-overflow": overflow,
1683
- className: cn2("flex items-center gap-control-gap text-sm text-muted-foreground", overflow === "wrap" ? "flex-wrap wrap-break-word" : "min-w-0 flex-nowrap overflow-hidden whitespace-nowrap [&>li]:min-w-0 [&>li>*]:min-w-0 [&>li>*]:truncate [&>li[data-slot=breadcrumb-separator]]:shrink-0", className),
1697
+ className: cn2("flex items-center gap-control-gap text-muted-foreground", LIST_SIZE_CLASSES[size], overflow === "wrap" ? "flex-wrap wrap-break-word" : "min-w-0 flex-nowrap overflow-hidden whitespace-nowrap [&>li]:min-w-0 [&>li>*]:min-w-0 [&>li>*]:truncate [&>li[data-slot=breadcrumb-separator]]:shrink-0", className),
1684
1698
  ...props
1685
1699
  });
1686
1700
  }
@@ -1697,7 +1711,7 @@ function BreadcrumbLink2({ analytics, density, className, render, ...props }) {
1697
1711
  return useRender3({
1698
1712
  defaultTagName: "a",
1699
1713
  props: mergeProps3({
1700
- className: cn2("inline-block cursor-pointer rounded-xs border-b border-input px-0.5 -mx-0.5 leading-6 transition-colors outline-none hover:border-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring", className)
1714
+ className: cn2("inline-block cursor-pointer rounded-xs px-0.5 -mx-0.5 text-muted-foreground no-underline visited:text-muted-foreground active:text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring", className)
1701
1715
  }, { ...props, onClick }),
1702
1716
  render,
1703
1717
  state: {
@@ -1706,15 +1720,20 @@ function BreadcrumbLink2({ analytics, density, className, render, ...props }) {
1706
1720
  }
1707
1721
  });
1708
1722
  }
1709
- function BreadcrumbPage2({ density, className, ...props }) {
1710
- return /* @__PURE__ */ jsx18("span", {
1711
- "data-density": density,
1712
- "data-slot": "breadcrumb-page",
1713
- role: "link",
1714
- "aria-disabled": "true",
1715
- "aria-current": "page",
1716
- className: cn2("inline-block border-b border-transparent leading-6 font-normal text-foreground", className),
1717
- ...props
1723
+ function BreadcrumbPage2({ density, className, render, ...props }) {
1724
+ const isCustomRender = render !== undefined;
1725
+ return useRender3({
1726
+ defaultTagName: "span",
1727
+ props: mergeProps3({
1728
+ ...isCustomRender ? {} : { role: "link", "aria-disabled": "true" },
1729
+ "aria-current": "page",
1730
+ className: cn2(isCustomRender ? "inline-block" : "inline-block font-normal text-foreground", className)
1731
+ }, props),
1732
+ render,
1733
+ state: {
1734
+ density,
1735
+ slot: "breadcrumb-page"
1736
+ }
1718
1737
  });
1719
1738
  }
1720
1739
  function BreadcrumbSeparator2({ density, children, className, ...props }) {
@@ -1723,7 +1742,7 @@ function BreadcrumbSeparator2({ density, children, className, ...props }) {
1723
1742
  "data-slot": "breadcrumb-separator",
1724
1743
  role: "presentation",
1725
1744
  "aria-hidden": "true",
1726
- className: cn2("[&>svg]:size-3.5", className),
1745
+ className: cn2("[&>svg]:size-[0.95em]", className),
1727
1746
  ...props,
1728
1747
  children: children ?? /* @__PURE__ */ jsx18(ChevronRightIcon, {
1729
1748
  className: "rtl:rotate-180"
@@ -4626,13 +4645,14 @@ function PageHeader2({
4626
4645
  actions,
4627
4646
  density
4628
4647
  }) {
4648
+ const hasSeparateTitle = title !== undefined;
4629
4649
  return /* @__PURE__ */ jsxs28("header", {
4630
4650
  "data-density": density,
4631
4651
  "data-slot": "page-header",
4632
4652
  "data-scroll": "none",
4633
4653
  className: "flex min-w-0 flex-col gap-field-gap",
4634
4654
  children: [
4635
- breadcrumbs,
4655
+ hasSeparateTitle && breadcrumbs,
4636
4656
  /* @__PURE__ */ jsxs28("div", {
4637
4657
  className: "flex min-w-0 flex-wrap items-start justify-between gap-panel",
4638
4658
  children: [
@@ -4643,13 +4663,13 @@ function PageHeader2({
4643
4663
  className: "mb-2 text-xs font-medium tracking-widest text-muted-foreground",
4644
4664
  children: eyebrow
4645
4665
  }),
4646
- /* @__PURE__ */ jsx45(Heading2, {
4666
+ hasSeparateTitle ? /* @__PURE__ */ jsx45(Heading2, {
4647
4667
  level: 1,
4648
4668
  size: titleSize,
4649
4669
  ...headingProps,
4650
4670
  className: cn2("outline-none", headingProps?.className),
4651
4671
  children: title
4652
- }),
4672
+ }) : breadcrumbs,
4653
4673
  description && /* @__PURE__ */ jsx45("div", {
4654
4674
  className: "mt-1 text-sm text-muted-foreground",
4655
4675
  children: description
@@ -112,7 +112,11 @@ var DragDropContext = createContext(null);
112
112
 
113
113
  // src/components/DragDropProvider.tsx
114
114
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
115
- function DragDropProvider2({ children, maxPreviewItems = 5 }) {
115
+ function DragDropProvider2({
116
+ children,
117
+ maxPreviewItems = 5,
118
+ announce = true
119
+ }) {
116
120
  const [active, setActive] = useState(null);
117
121
  const [over, setOver] = useState(null);
118
122
  const preview = useRef(null);
@@ -155,7 +159,7 @@ function DragDropProvider2({ children, maxPreviewItems = 5 }) {
155
159
  maxItems: maxPreviewItems
156
160
  })
157
161
  }),
158
- /* @__PURE__ */ jsx3("span", {
162
+ announce && /* @__PURE__ */ jsx3("span", {
159
163
  role: "status",
160
164
  "aria-label": "Drag status",
161
165
  className: "sr-only",
@@ -307,13 +311,16 @@ function DropTarget2({
307
311
 
308
312
  // src/components/Kanban.tsx
309
313
  import {
314
+ useContext as useContext2,
310
315
  useEffect as useEffect2,
311
316
  useId as useId3,
317
+ useLayoutEffect,
312
318
  useRef as useRef2,
313
319
  useState as useState3
314
320
  } from "react";
321
+ import { mergeProps as mergeProps3 } from "@base-ui/react/merge-props";
315
322
  import { ArrowDownIcon, ArrowUpIcon } from "lucide-react";
316
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
323
+ import { jsx as jsx4, jsxs as jsxs3, Fragment } from "react/jsx-runtime";
317
324
  var boardClassName = "@container relative overflow-x-auto";
318
325
  var fillClassName = "h-full min-h-0 overflow-y-auto";
319
326
  var LONG_PRESS_MS = 500;
@@ -345,9 +352,13 @@ function useCardDescriptions(describeItem) {
345
352
  };
346
353
  }
347
354
  var readOnlyCardClassName = `${cardClassName} outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring`;
348
- function ColumnHeader({ label, count, className }) {
349
- return /* @__PURE__ */ jsxs3("header", {
350
- className: cn2("flex items-center justify-between gap-2", className),
355
+ function ColumnHeader({
356
+ label,
357
+ count,
358
+ className,
359
+ refusal
360
+ }) {
361
+ const heading = /* @__PURE__ */ jsxs3(Fragment, {
351
362
  children: [
352
363
  /* @__PURE__ */ jsx4("h2", {
353
364
  className: "text-sm font-semibold",
@@ -360,6 +371,25 @@ function ColumnHeader({ label, count, className }) {
360
371
  })
361
372
  ]
362
373
  });
374
+ if (refusal === undefined)
375
+ return /* @__PURE__ */ jsx4("header", {
376
+ className: cn2("flex items-center justify-between gap-2", className),
377
+ children: heading
378
+ });
379
+ return /* @__PURE__ */ jsxs3("header", {
380
+ className: cn2("grid gap-1", className),
381
+ children: [
382
+ /* @__PURE__ */ jsx4("div", {
383
+ className: "flex items-center justify-between gap-2",
384
+ children: heading
385
+ }),
386
+ /* @__PURE__ */ jsx4("p", {
387
+ "data-kanban-refusal": "",
388
+ className: "text-xs text-muted-foreground",
389
+ children: refusal
390
+ })
391
+ ]
392
+ });
363
393
  }
364
394
  function EmptyColumn({ children }) {
365
395
  return /* @__PURE__ */ jsx4("p", {
@@ -452,25 +482,254 @@ function useCardTooltips() {
452
482
  })
453
483
  };
454
484
  }
455
- function ReadOnlyKanban({
485
+ var MOVE_SHORTCUTS = [
486
+ "Control+Shift+ArrowLeft",
487
+ "Control+Shift+ArrowRight",
488
+ "Meta+Shift+ArrowLeft",
489
+ "Meta+Shift+ArrowRight",
490
+ "Alt+ArrowUp",
491
+ "Alt+ArrowDown"
492
+ ].join(" ");
493
+ var dropBeforeClassName = "relative data-drop-before:before:absolute data-drop-before:before:inset-x-0 data-drop-before:before:-top-[5px] data-drop-before:before:h-0.5 data-drop-before:before:bg-primary";
494
+ var dropEndClassName = "h-0.5 bg-primary";
495
+ function isSamePlace(cards, item, target) {
496
+ if (item.columnId !== target.columnId)
497
+ return false;
498
+ if (target.beforeId === item.id)
499
+ return true;
500
+ const index = cards.indexOf(item);
501
+ return target.beforeId === undefined ? index === cards.length - 1 : cards[index + 1]?.id === target.beforeId;
502
+ }
503
+ function useBoardDrop({ getRefusal, accept, onRefused, onAccepted, onDrop }) {
504
+ const drag = useContext2(DragDropContext);
505
+ const target = useDropTarget2({
506
+ accept: [accept],
507
+ canDrop: (dragged) => {
508
+ const { item, reason } = getRefusal(dragged.data);
509
+ return item !== undefined && reason === undefined;
510
+ },
511
+ onDrop: (dragged) => {
512
+ if (typeof dragged.data === "string")
513
+ onDrop(dragged.data);
514
+ }
515
+ });
516
+ return {
517
+ isOver: target.isOver,
518
+ props: mergeProps3(target.props, {
519
+ onDragOver: (event) => {
520
+ if (!drag?.active || drag.active.type !== accept || !event.dataTransfer.types.includes(accept))
521
+ return;
522
+ const { item, reason } = getRefusal(drag.active.data);
523
+ if (!item)
524
+ return;
525
+ if (reason === undefined)
526
+ onAccepted();
527
+ else
528
+ onRefused(item.id, reason);
529
+ }
530
+ })
531
+ };
532
+ }
533
+ function CardShell({ cardProps, content, tooltip, isTooltipOpen, onTooltipOpenChange }) {
534
+ if (tooltip === undefined)
535
+ return /* @__PURE__ */ jsx4("div", {
536
+ ...cardProps,
537
+ children: content
538
+ });
539
+ return /* @__PURE__ */ jsxs3(Tooltip2, {
540
+ open: isTooltipOpen,
541
+ onOpenChange: onTooltipOpenChange,
542
+ children: [
543
+ /* @__PURE__ */ jsx4(TooltipTrigger2, {
544
+ render: /* @__PURE__ */ jsx4("div", {
545
+ ...cardProps
546
+ }),
547
+ children: content
548
+ }),
549
+ /* @__PURE__ */ jsx4(TooltipContent2, {
550
+ children: tooltip
551
+ })
552
+ ]
553
+ });
554
+ }
555
+ function MovableCard({
556
+ item,
557
+ disabled,
558
+ drop,
559
+ ...frame
560
+ }) {
561
+ const source = useDragSource2({ type: drop.accept, data: item.id, labels: [item.title], disabled });
562
+ const target = useBoardDrop(drop);
563
+ return /* @__PURE__ */ jsxs3("li", {
564
+ className: dropBeforeClassName,
565
+ "data-drop-before": target.isOver ? "" : undefined,
566
+ children: [
567
+ /* @__PURE__ */ jsx4(CardShell, {
568
+ ...frame,
569
+ cardProps: {
570
+ ...mergeProps3(frame.cardProps, source.props, target.props),
571
+ "data-dragging": source.isDragging ? "" : undefined
572
+ }
573
+ }),
574
+ frame.description
575
+ ]
576
+ });
577
+ }
578
+ function MovableColumn({ label, className, children, drop }) {
579
+ const target = useBoardDrop(drop);
580
+ return /* @__PURE__ */ jsxs3("section", {
581
+ ...target.props,
582
+ "aria-label": label,
583
+ "data-scroll": "none",
584
+ "data-over": target.isOver ? "" : undefined,
585
+ className,
586
+ children: [
587
+ children,
588
+ target.isOver && /* @__PURE__ */ jsx4("div", {
589
+ "aria-hidden": "true",
590
+ "data-kanban-drop-end": "",
591
+ className: dropEndClassName
592
+ })
593
+ ]
594
+ });
595
+ }
596
+ function Board({
456
597
  label,
457
598
  columns,
458
599
  items,
600
+ onItemsChange,
459
601
  renderItem,
602
+ canMove,
603
+ getMoveRefusal,
604
+ onMoveRefused,
605
+ disabled,
460
606
  emptyLabel,
461
607
  density,
462
608
  describeItem,
463
609
  fill = false,
464
610
  itemTooltip
465
611
  }) {
612
+ const isMovable = onItemsChange !== undefined;
466
613
  const cards = columns.map((column) => items.filter((item) => item.columnId === column.id));
467
614
  const getDescription = useCardDescriptions(describeItem);
468
615
  const tooltips = useCardTooltips();
616
+ const drag = useContext2(DragDropContext);
617
+ const boardId = useId3();
618
+ const type = `application/x-kanban-${boardId.replaceAll(":", "").toLowerCase()}`;
469
619
  const [currentId, setCurrentId] = useState3();
620
+ const [refusal, setRefusal] = useState3();
621
+ const focusedId = useRef2(undefined);
622
+ const movedId = useRef2(undefined);
470
623
  const tabStopId = items.some((item) => item.id === currentId) ? currentId : cards.flat()[0]?.id;
471
- const onKeyDown = (event, item) => {
472
- if (event.target !== event.currentTarget || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
624
+ const findCard = (id) => tooltips.boardRef.current?.querySelector(`[data-kanban-card="${CSS.escape(id)}"]`);
625
+ useLayoutEffect(() => {
626
+ const moved = movedId.current;
627
+ movedId.current = undefined;
628
+ const id = moved ?? focusedId.current;
629
+ if (!id)
630
+ return;
631
+ const card = findCard(id);
632
+ if (!card || card === document.activeElement)
633
+ return;
634
+ if (document.activeElement && document.activeElement !== document.body)
635
+ return;
636
+ card.focus({ preventScroll: moved === undefined });
637
+ });
638
+ const dragging = drag?.active;
639
+ const latest = useRef2({ refusal, items, onMoveRefused });
640
+ latest.current = { refusal, items, onMoveRefused };
641
+ useEffect2(() => {
642
+ if (dragging)
643
+ return;
644
+ const { refusal: ended, items: current, onMoveRefused: report } = latest.current;
645
+ if (ended?.source !== "drag")
646
+ return;
647
+ setRefusal(undefined);
648
+ const item = current.find((candidate) => candidate.id === ended.itemId);
649
+ if (item)
650
+ report?.(item, ended.reason);
651
+ }, [dragging]);
652
+ const getRefusal = (item, target) => {
653
+ const reason = getMoveRefusal?.(item, target);
654
+ if (reason !== undefined)
655
+ return reason;
656
+ if (canMove && !canMove(item, target.columnId)) {
657
+ const column = columns.find((candidate) => candidate.id === target.columnId);
658
+ return `${item.title} can't move to ${column?.label ?? target.columnId}`;
659
+ }
660
+ return;
661
+ };
662
+ const apply = (item, target) => {
663
+ if (!onItemsChange || disabled)
664
+ return;
665
+ const remaining = items.filter((candidate) => candidate.id !== item.id);
666
+ const index = target.beforeId ? remaining.findIndex((candidate) => candidate.id === target.beforeId) : remaining.length;
667
+ remaining.splice(index < 0 ? remaining.length : index, 0, { ...item, columnId: target.columnId });
668
+ onItemsChange(remaining, { item, ...target });
669
+ };
670
+ const moveByKey = (item, target) => {
671
+ const reason = getRefusal(item, target);
672
+ if (reason !== undefined) {
673
+ setRefusal({ itemId: item.id, columnId: target.columnId, reason, source: "key" });
674
+ onMoveRefused?.(item, reason);
675
+ return;
676
+ }
677
+ setRefusal(undefined);
678
+ if (disabled)
679
+ return;
680
+ movedId.current = item.id;
681
+ apply(item, target);
682
+ };
683
+ const getDrop = (target) => ({
684
+ accept: type,
685
+ getRefusal: (data) => {
686
+ const item = items.find((candidate) => candidate.id === data);
687
+ if (!item || disabled)
688
+ return {};
689
+ if (isSamePlace(cards[columns.findIndex((column) => column.id === item.columnId)] ?? [], item, target))
690
+ return { item };
691
+ return { item, reason: getRefusal(item, target) };
692
+ },
693
+ onRefused: (itemId, reason) => setRefusal((current) => current?.source === "drag" && current.itemId === itemId && current.columnId === target.columnId ? current : { itemId, columnId: target.columnId, reason, source: "drag" }),
694
+ onAccepted: () => setRefusal((current) => current?.source === "drag" ? undefined : current),
695
+ onDrop: (itemId) => {
696
+ setRefusal(undefined);
697
+ const item = items.find((candidate) => candidate.id === itemId);
698
+ if (!item)
699
+ return;
700
+ const columnCards = cards[columns.findIndex((column) => column.id === item.columnId)] ?? [];
701
+ if (!isSamePlace(columnCards, item, target))
702
+ apply(item, target);
703
+ }
704
+ });
705
+ const onKeyDown = (event, item, columnIndex) => {
706
+ if (event.target !== event.currentTarget)
473
707
  return;
708
+ const list = cards[columnIndex];
709
+ if (isMovable) {
710
+ const isMod = event.metaKey || event.ctrlKey;
711
+ if (isMod && event.shiftKey && !event.altKey && (event.key === "ArrowLeft" || event.key === "ArrowRight")) {
712
+ event.preventDefault();
713
+ const column = columns[columnIndex + (event.key === "ArrowRight" ? 1 : -1)];
714
+ if (column)
715
+ moveByKey(item, { columnId: column.id });
716
+ return;
717
+ }
718
+ if (event.altKey && !isMod && !event.shiftKey && (event.key === "ArrowUp" || event.key === "ArrowDown")) {
719
+ event.preventDefault();
720
+ const index = list.indexOf(item);
721
+ const columnId = columns[columnIndex].id;
722
+ if (event.key === "ArrowUp" && index > 0)
723
+ moveByKey(item, { columnId, beforeId: list[index - 1].id });
724
+ if (event.key === "ArrowDown" && index < list.length - 1)
725
+ moveByKey(item, { columnId, beforeId: list[index + 2]?.id });
726
+ return;
727
+ }
728
+ }
729
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
730
+ return;
731
+ if (refusal?.source === "key")
732
+ setRefusal(undefined);
474
733
  if (event.key === "Enter") {
475
734
  event.preventDefault();
476
735
  event.currentTarget.querySelector("a[href], button:not(:disabled)")?.click();
@@ -480,9 +739,9 @@ function ReadOnlyKanban({
480
739
  if (!next)
481
740
  return;
482
741
  event.preventDefault();
483
- const board = event.currentTarget.closest("[data-kanban-board]");
484
- board?.querySelector(`[data-kanban-card="${CSS.escape(next.id)}"]`)?.focus();
742
+ findCard(next.id)?.focus();
485
743
  };
744
+ const shownRefusal = refusal && (refusal.source === "key" || dragging) ? refusal : undefined;
486
745
  return /* @__PURE__ */ jsx4("div", {
487
746
  ref: tooltips.boardRef,
488
747
  role: "region",
@@ -491,20 +750,27 @@ function ReadOnlyKanban({
491
750
  "data-kanban-board": "",
492
751
  "data-fill": fill ? "" : undefined,
493
752
  className: cn2(boardClassName, fill && fillClassName),
753
+ onDragLeave: (event) => {
754
+ if (!(event.relatedTarget instanceof Node) || !event.currentTarget.contains(event.relatedTarget))
755
+ setRefusal((current) => current?.source === "drag" ? undefined : current);
756
+ },
757
+ onBlur: (event) => {
758
+ if (!(event.relatedTarget instanceof Node) || !event.currentTarget.contains(event.relatedTarget))
759
+ setRefusal((current) => current?.source === "key" ? undefined : current);
760
+ },
494
761
  children: /* @__PURE__ */ jsx4("div", {
495
762
  className: cn2(readOnlyGridClassName, fill && fillGridClassName),
496
763
  children: columns.map((column, columnIndex) => {
497
764
  const list = cards[columnIndex];
498
- return /* @__PURE__ */ jsxs3("section", {
499
- "aria-label": column.label,
500
- "data-scroll": "none",
501
- className: cn2(readOnlyColumnClassName, !fill && readOnlyEndClassName),
765
+ const header = /* @__PURE__ */ jsx4(ColumnHeader, {
766
+ label: column.label,
767
+ count: list.length,
768
+ className: fill ? stickyReadOnlyHeaderClassName : undefined,
769
+ refusal: shownRefusal?.columnId === column.id ? shownRefusal.reason : undefined
770
+ });
771
+ const body = /* @__PURE__ */ jsxs3(Fragment, {
502
772
  children: [
503
- /* @__PURE__ */ jsx4(ColumnHeader, {
504
- label: column.label,
505
- count: list.length,
506
- className: fill ? stickyReadOnlyHeaderClassName : undefined
507
- }),
773
+ header,
508
774
  /* @__PURE__ */ jsx4("ol", {
509
775
  className: "grid gap-2",
510
776
  children: list.map((item, index) => {
@@ -517,33 +783,44 @@ function ReadOnlyKanban({
517
783
  role: "group",
518
784
  "aria-label": item.title,
519
785
  "aria-describedby": description.describedBy,
786
+ "aria-keyshortcuts": isMovable && !disabled ? MOVE_SHORTCUTS : undefined,
520
787
  tabIndex: item.id === tabStopId ? 0 : -1,
521
788
  "data-kanban-card": item.id,
522
789
  "data-scroll": "none",
523
- className: cn2(readOnlyCardClassName, itemTooltip && "[-webkit-touch-callout:none] pointer-coarse:select-none"),
524
- onFocus: () => setCurrentId(item.id),
525
- onKeyDown: (event) => onKeyDown(event, item),
790
+ className: cn2(readOnlyCardClassName, isMovable && "data-dragging:opacity-50", itemTooltip && "[-webkit-touch-callout:none] pointer-coarse:select-none"),
791
+ onFocus: () => {
792
+ focusedId.current = item.id;
793
+ setCurrentId(item.id);
794
+ },
795
+ onBlur: (event) => {
796
+ const card = event.currentTarget;
797
+ queueMicrotask(() => {
798
+ if (card.isConnected && focusedId.current === item.id)
799
+ focusedId.current = undefined;
800
+ });
801
+ },
802
+ onKeyDown: (event) => onKeyDown(event, item, columnIndex),
526
803
  ...itemTooltip ? tooltips.getPressProps(item.id) : {}
527
804
  };
805
+ const frame = {
806
+ cardProps,
807
+ content,
808
+ tooltip: itemTooltip?.(item),
809
+ isTooltipOpen: tooltips.openId === item.id && !dragging,
810
+ onTooltipOpenChange: (open) => tooltips.onOpenChange(item.id, open),
811
+ description: description.element
812
+ };
813
+ if (isMovable)
814
+ return /* @__PURE__ */ jsx4(MovableCard, {
815
+ item,
816
+ disabled,
817
+ drop: getDrop({ columnId: column.id, beforeId: item.id }),
818
+ ...frame
819
+ }, item.id);
528
820
  return /* @__PURE__ */ jsxs3("li", {
529
821
  children: [
530
- itemTooltip ? /* @__PURE__ */ jsxs3(Tooltip2, {
531
- open: tooltips.openId === item.id,
532
- onOpenChange: (open) => tooltips.onOpenChange(item.id, open),
533
- children: [
534
- /* @__PURE__ */ jsx4(TooltipTrigger2, {
535
- render: /* @__PURE__ */ jsx4("div", {
536
- ...cardProps
537
- }),
538
- children: content
539
- }),
540
- /* @__PURE__ */ jsx4(TooltipContent2, {
541
- children: itemTooltip(item)
542
- })
543
- ]
544
- }) : /* @__PURE__ */ jsx4("div", {
545
- ...cardProps,
546
- children: content
822
+ /* @__PURE__ */ jsx4(CardShell, {
823
+ ...frame
547
824
  }),
548
825
  description.element
549
826
  ]
@@ -554,6 +831,19 @@ function ReadOnlyKanban({
554
831
  children: emptyLabel
555
832
  })
556
833
  ]
834
+ });
835
+ if (isMovable)
836
+ return /* @__PURE__ */ jsx4(MovableColumn, {
837
+ label: column.label,
838
+ className: readOnlyColumnClassName,
839
+ drop: getDrop({ columnId: column.id }),
840
+ children: body
841
+ }, column.id);
842
+ return /* @__PURE__ */ jsx4("section", {
843
+ "aria-label": column.label,
844
+ "data-scroll": "none",
845
+ className: cn2(readOnlyColumnClassName, !fill && readOnlyEndClassName),
846
+ children: body
557
847
  }, column.id);
558
848
  })
559
849
  })
@@ -571,15 +861,24 @@ function Kanban2(props) {
571
861
  emptyLabel = "No items",
572
862
  density,
573
863
  describeItem,
574
- fill = false
864
+ fill = false,
865
+ moveControls = true
575
866
  } = props;
576
867
  const boardId = useId3();
577
868
  const getDescription = useCardDescriptions(describeItem);
578
869
  if (!onItemsChange)
579
- return /* @__PURE__ */ jsx4(ReadOnlyKanban, {
870
+ return /* @__PURE__ */ jsx4(Board, {
580
871
  ...props,
581
872
  emptyLabel
582
873
  });
874
+ if (!moveControls)
875
+ return /* @__PURE__ */ jsx4(DragDropProvider2, {
876
+ announce: false,
877
+ children: /* @__PURE__ */ jsx4(Board, {
878
+ ...props,
879
+ emptyLabel
880
+ })
881
+ });
583
882
  const type = `application/x-kanban-${boardId.replaceAll(":", "").toLowerCase()}`;
584
883
  const canDropInto = (data, columnId) => typeof data === "string" && !disabled && items.some((item) => item.id === data && (!canMove || canMove(item, columnId)));
585
884
  const move = (id, columnId, beforeId) => {
@@ -589,7 +888,7 @@ function Kanban2(props) {
589
888
  const remaining = items.filter((candidate) => candidate.id !== id);
590
889
  const index = beforeId ? remaining.findIndex((candidate) => candidate.id === beforeId) : remaining.length;
591
890
  remaining.splice(index < 0 ? remaining.length : index, 0, { ...item, columnId });
592
- onItemsChange(remaining);
891
+ onItemsChange(remaining, { item, columnId, beforeId });
593
892
  };
594
893
  return /* @__PURE__ */ jsx4(DragDropProvider2, {
595
894
  children: /* @__PURE__ */ jsx4("div", {
@@ -2,9 +2,12 @@ import type { IAnalyticsProps } from "../analytics/types.js";
2
2
  import type { IDensityProps } from "../density/types.js";
3
3
  import type { ComponentProps, ReactElement } from "react";
4
4
  import { useRender } from "@base-ui/react/use-render";
5
+ import type { HeadingSize } from "./Heading.js";
5
6
  type BreadcrumbProps = ComponentProps<"nav"> & IDensityProps;
6
7
  declare function Breadcrumb({ density, className, ...props }: BreadcrumbProps): ReactElement;
7
8
  type BreadcrumbListProps = ComponentProps<"ol"> & IDensityProps & {
9
+ /** Text size of the trail. Defaults to `sm`; set to match `Heading` when the final step is an inline page title. */
10
+ size?: HeadingSize;
8
11
  /**
9
12
  * `wrap` (the default) lets a long path break onto more lines. `truncate` keeps the path on one line: every item
10
13
  * shrinks and ends in an ellipsis, longer items giving up more width, while separators keep their size. Give each
@@ -12,13 +15,13 @@ type BreadcrumbListProps = ComponentProps<"ol"> & IDensityProps & {
12
15
  */
13
16
  overflow?: "wrap" | "truncate";
14
17
  };
15
- declare function BreadcrumbList({ density, overflow, className, ...props }: BreadcrumbListProps): ReactElement;
18
+ declare function BreadcrumbList({ density, size, overflow, className, ...props }: BreadcrumbListProps): ReactElement;
16
19
  type BreadcrumbItemProps = ComponentProps<"li"> & IDensityProps;
17
20
  declare function BreadcrumbItem({ density, className, ...props }: BreadcrumbItemProps): ReactElement;
18
21
  type BreadcrumbLinkProps = IAnalyticsProps & useRender.ComponentProps<"a"> & IDensityProps;
19
22
  declare function BreadcrumbLink({ analytics, density, className, render, ...props }: BreadcrumbLinkProps): ReactElement;
20
- type BreadcrumbPageProps = ComponentProps<"span"> & IDensityProps;
21
- declare function BreadcrumbPage({ density, className, ...props }: BreadcrumbPageProps): ReactElement;
23
+ type BreadcrumbPageProps = useRender.ComponentProps<"span"> & IDensityProps;
24
+ declare function BreadcrumbPage({ density, className, render, ...props }: BreadcrumbPageProps): ReactElement;
22
25
  type BreadcrumbSeparatorProps = ComponentProps<"li"> & IDensityProps;
23
26
  declare function BreadcrumbSeparator({ density, children, className, ...props }: BreadcrumbSeparatorProps): ReactElement;
24
27
  type BreadcrumbEllipsisProps = ComponentProps<"span"> & IDensityProps;
@@ -1,6 +1,11 @@
1
1
  import { type PropsWithChildren, type ReactElement } from "react";
2
2
  interface IDragDropProviderProps extends PropsWithChildren {
3
3
  maxPreviewItems?: number;
4
+ /**
5
+ * Whether the provider's own status says how many items are being dragged. Turn it off where the app speaks through
6
+ * its own live regions only, and announce the drag's outcome there instead.
7
+ */
8
+ announce?: boolean;
4
9
  }
5
- export declare function DragDropProvider({ children, maxPreviewItems }: IDragDropProviderProps): ReactElement;
10
+ export declare function DragDropProvider({ children, maxPreviewItems, announce, }: IDragDropProviderProps): ReactElement;
6
11
  export {};
@@ -9,19 +9,47 @@ type KanbanItem = {
9
9
  columnId: string;
10
10
  title: string;
11
11
  };
12
+ /** Where a card goes: a column, and the card it goes before there, or the column's end without one. */
13
+ type KanbanMoveTarget = {
14
+ columnId: string;
15
+ beforeId?: string;
16
+ };
17
+ /** One move a person made: the card as it was, and where it went. */
18
+ type KanbanMove<T extends KanbanItem> = KanbanMoveTarget & {
19
+ item: T;
20
+ };
12
21
  type KanbanProps<T extends KanbanItem> = IDensityProps & {
13
22
  label: string;
14
23
  columns: readonly KanbanColumn[];
15
24
  items: readonly T[];
16
25
  /**
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, except with `fill`, and stacked columns show their heading over their cards
20
- * without a panel.
26
+ * Receives the reordered items after a move, and the move itself. Omit it for a read-only board: cards cannot be
27
+ * dragged and show no move controls, the board is one Tab stop, arrow keys move between cards and Enter activates the
28
+ * card's first link or button. Its columns end after their last card, except with `fill`, and stacked columns show
29
+ * their heading over their cards without a panel.
21
30
  */
22
- onItemsChange?: (items: T[]) => void;
31
+ onItemsChange?: (items: T[], move: KanbanMove<T>) => void;
23
32
  renderItem?: (item: T) => ReactNode;
24
33
  canMove?: (item: T, columnId: string) => boolean;
34
+ /**
35
+ * With `onItemsChange`, false leaves out each card's Move to select and up and down buttons. The board then keeps the
36
+ * read-only board's layout, Tab stop, arrow keys, Enter, `describeItem` and `itemTooltip`, and cards move by dragging
37
+ * and by keys on the focused card: Mod+Shift+Left and Right to the neighbouring column, Alt+Up and Down within its
38
+ * column. Focus stays on the moved card. The board speaks nothing: announce each move and refusal yourself. Give
39
+ * people a pointer way to move that is not dragging, such as Move to… in a card menu.
40
+ */
41
+ moveControls?: boolean;
42
+ /**
43
+ * Why a card cannot go to a place, in words for the person, or nothing when it can. A drag over a refused place shows
44
+ * the reason under that column's heading and drops nothing there; a refused key move shows it the same way. Applies
45
+ * together with `canMove`. Only without `moveControls`.
46
+ */
47
+ getMoveRefusal?: (item: T, target: KanbanMoveTarget) => string | undefined;
48
+ /**
49
+ * Called with the reason when a key move is refused, or a drag ends over a refused place, so the consumer can
50
+ * announce it once. The board shows the reason but does not speak it. Only without `moveControls`.
51
+ */
52
+ onMoveRefused?: (item: T, reason: string) => void;
25
53
  disabled?: boolean;
26
54
  /** Shown in a column without cards. */
27
55
  emptyLabel?: ReactNode;
@@ -46,4 +74,4 @@ type KanbanProps<T extends KanbanItem> = IDensityProps & {
46
74
  };
47
75
  declare function Kanban<T extends KanbanItem>(props: KanbanProps<T>): ReactElement;
48
76
  export { Kanban };
49
- export type { KanbanProps, KanbanColumn, KanbanItem };
77
+ export type { KanbanProps, KanbanColumn, KanbanItem, KanbanMove, KanbanMoveTarget };
@@ -1,18 +1,26 @@
1
1
  import type { ComponentProps, ReactElement, ReactNode } from "react";
2
2
  import type { IDensityProps } from "../density/types.js";
3
3
  import type { HeadingSize } from "./Heading.js";
4
- type PageHeaderProps = IDensityProps & {
4
+ type PageHeaderBaseProps = IDensityProps & {
5
+ /** Context above the page title without introducing another heading. */
6
+ eyebrow?: ReactNode;
7
+ description?: ReactNode;
8
+ actions?: ReactNode;
9
+ };
10
+ type PageHeaderProps = PageHeaderBaseProps & ({
5
11
  title: string;
6
12
  /** The title's visual size. Defaults to `xl`; a page's own title can take a display size such as `3xl`. */
7
13
  titleSize?: HeadingSize;
8
14
  /** Props for the title's `h1`, such as a `ref` and `tabIndex={-1}` so the app can move focus to it. */
9
15
  headingProps?: Omit<ComponentProps<"h1">, "children">;
10
- /** Context above the page title without introducing another heading. */
11
- eyebrow?: ReactNode;
12
- description?: ReactNode;
13
16
  breadcrumbs?: ReactNode;
14
- actions?: ReactNode;
15
- };
17
+ } | {
18
+ /** Omit `title` when `breadcrumbs` carries the page's `h1` as its last step. */
19
+ title?: undefined;
20
+ titleSize?: never;
21
+ headingProps?: never;
22
+ breadcrumbs: ReactNode;
23
+ });
16
24
  declare function PageHeader({ title, titleSize, headingProps, eyebrow, description, breadcrumbs, actions, density, }: PageHeaderProps): ReactElement;
17
25
  export { PageHeader };
18
26
  export type { PageHeaderProps };
@@ -7,7 +7,7 @@ import {
7
7
  DragSource2,
8
8
  DropTarget2,
9
9
  Kanban2
10
- } from "../../chunk-mtbhe5kk.js";
10
+ } from "../../chunk-kr318npc.js";
11
11
  import"../../chunk-en44w1pn.js";
12
12
  import"../../chunk-cgj3ade2.js";
13
13
  import"../../chunk-7ny0vyek.js";
@@ -36,8 +36,8 @@ export declare const componentDefinitions: {
36
36
  none: "none";
37
37
  sm: "sm";
38
38
  lg: "lg";
39
- md: "md";
40
39
  xl: "xl";
40
+ md: "md";
41
41
  }>>;
42
42
  align: z.ZodNullable<z.ZodEnum<{
43
43
  end: "end";
@@ -73,8 +73,8 @@ export declare const componentDefinitions: {
73
73
  gap: z.ZodNullable<z.ZodEnum<{
74
74
  sm: "sm";
75
75
  lg: "lg";
76
- md: "md";
77
76
  xl: "xl";
77
+ md: "md";
78
78
  }>>;
79
79
  className: z.ZodNullable<z.ZodString>;
80
80
  }, z.core.$strip>;
@@ -26,7 +26,7 @@ import {
26
26
  PaginationPrevious2,
27
27
  PaginationNext2,
28
28
  PaginationEllipsis2
29
- } from "../../chunk-0b8zqcdm.js";
29
+ } from "../../chunk-ep5x366b.js";
30
30
  import {
31
31
  MenuPopup,
32
32
  MenuItem2,
@@ -100,7 +100,7 @@ import {
100
100
  TabsList2,
101
101
  TabsTrigger2,
102
102
  TabsContent2
103
- } from "../../chunk-mtbhe5kk.js";
103
+ } from "../../chunk-kr318npc.js";
104
104
  import"../../chunk-4e96tpw0.js";
105
105
  import {
106
106
  Checkbox2
package/dist/index.d.ts CHANGED
@@ -163,7 +163,7 @@ export type { FilterChipProps } from "./components/FilterChip.js";
163
163
  export { FilterBar } from "./components/FilterBar.js";
164
164
  export type { FilterBarProps, FilterDefinition } from "./components/FilterBar.js";
165
165
  export { Kanban } from "./components/Kanban.js";
166
- export type { KanbanProps, KanbanColumn, KanbanItem } from "./components/Kanban.js";
166
+ export type { KanbanProps, KanbanColumn, KanbanItem, KanbanMove, KanbanMoveTarget } from "./components/Kanban.js";
167
167
  export { BarList } from "./components/BarList.js";
168
168
  export type { BarListProps, BarListItem } from "./components/BarList.js";
169
169
  export { StatusTracker } from "./components/StatusTracker.js";
package/dist/index.js CHANGED
@@ -188,7 +188,7 @@ import {
188
188
  DashboardLayout2,
189
189
  BillingUsage2,
190
190
  SelectionAction2
191
- } from "./chunk-0b8zqcdm.js";
191
+ } from "./chunk-ep5x366b.js";
192
192
  import {
193
193
  statusDotVariants2,
194
194
  StatusDot2
@@ -225,7 +225,7 @@ import {
225
225
  useDropTarget2,
226
226
  DropTarget2,
227
227
  Kanban2
228
- } from "./chunk-mtbhe5kk.js";
228
+ } from "./chunk-kr318npc.js";
229
229
  import {
230
230
  NumberField2,
231
231
  NumberFieldGroup2,
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.213",
2054
+ version: "0.0.215",
2055
2055
  description: "Sharp, monospace React components with compact, comfortable, and touch densities.",
2056
2056
  license: "MIT",
2057
2057
  repository: {
@@ -8,7 +8,7 @@ Source: src/components/stories/layout/PageHeader.stories.tsx
8
8
  ## Public imports
9
9
 
10
10
  ```tsx
11
- import { PageHeader, Button } from "@alexgorbatchev/shadcn";
11
+ import { PageHeader, Button, Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Heading } from "@alexgorbatchev/shadcn";
12
12
  ```
13
13
 
14
14
  ## Default component
@@ -80,3 +80,24 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
80
80
  args: { titleSize: "3xl", headingProps: { tabIndex: -1, id: "page-title" } }
81
81
  }
82
82
  ```
83
+
84
+ ### InlineBreadcrumbTitle
85
+
86
+ ```tsx
87
+ {
88
+ args: {
89
+ title: undefined,
90
+ breadcrumbs: (<Breadcrumb aria-label="Breadcrumb">
91
+ <BreadcrumbList size="xl">
92
+ <BreadcrumbItem>
93
+ <BreadcrumbLink href="#projects">Projects</BreadcrumbLink>
94
+ </BreadcrumbItem>
95
+ <BreadcrumbSeparator />
96
+ <BreadcrumbItem>
97
+ <BreadcrumbPage render={<Heading level={1} size="xl"/>}>workflows</BreadcrumbPage>
98
+ </BreadcrumbItem>
99
+ </BreadcrumbList>
100
+ </Breadcrumb>),
101
+ }
102
+ }
103
+ ```
@@ -8,7 +8,7 @@ Source: src/components/stories/navigation/Breadcrumb.stories.tsx
8
8
  ## Public imports
9
9
 
10
10
  ```tsx
11
- import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "@alexgorbatchev/shadcn";
11
+ import { Button, Heading, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "@alexgorbatchev/shadcn";
12
12
  ```
13
13
 
14
14
  ## Supporting imports
@@ -49,6 +49,28 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
49
49
  {}
50
50
  ```
51
51
 
52
+ ### InlineHeading
53
+
54
+ ```tsx
55
+ {
56
+ render: (args) => (<Breadcrumb {...args}>
57
+ <BreadcrumbList size="xl">
58
+ <BreadcrumbItem>
59
+ <BreadcrumbLink href="#projects">Projects</BreadcrumbLink>
60
+ </BreadcrumbItem>
61
+ <BreadcrumbSeparator />
62
+ <BreadcrumbItem>
63
+ <BreadcrumbLink href="#workflows">workflows</BreadcrumbLink>
64
+ </BreadcrumbItem>
65
+ <BreadcrumbSeparator />
66
+ <BreadcrumbItem>
67
+ <BreadcrumbPage render={<Heading level={1} size="xl"/>}>commander</BreadcrumbPage>
68
+ </BreadcrumbItem>
69
+ </BreadcrumbList>
70
+ </Breadcrumb>)
71
+ }
72
+ ```
73
+
52
74
  ### Collapsed
53
75
 
54
76
  ```tsx
@@ -14,7 +14,7 @@ import { Kanban, type KanbanItem, Text } from "@alexgorbatchev/shadcn";
14
14
  ## Supporting imports
15
15
 
16
16
  ```tsx
17
- import { useState } from "react";
17
+ import { useEffect, useState } from "react";
18
18
  ```
19
19
 
20
20
  ## Default render
@@ -154,3 +154,54 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
154
154
  render: () => <TooltipExample />
155
155
  }
156
156
  ```
157
+
158
+ ### Movable
159
+
160
+ ```tsx
161
+ {
162
+ render: () => <MovableExample width={1000}/>
163
+ }
164
+ ```
165
+
166
+ ### MovableRefusalClearsOnLeave
167
+
168
+ ```tsx
169
+ {
170
+ render: () => (<>
171
+ <MovableExample width={1000}/>
172
+ <button type="button">After the board</button>
173
+ </>)
174
+ }
175
+ ```
176
+
177
+ ### MovableDisabled
178
+
179
+ ```tsx
180
+ {
181
+ render: () => <MovableExample width={1000} disabled/>
182
+ }
183
+ ```
184
+
185
+ ### MovableNarrow
186
+
187
+ ```tsx
188
+ {
189
+ render: () => <MovableExample width={320}/>
190
+ }
191
+ ```
192
+
193
+ ### MovableWide
194
+
195
+ ```tsx
196
+ {
197
+ render: () => <MovableExample width={1000}/>
198
+ }
199
+ ```
200
+
201
+ ### ReadOnlyArrival
202
+
203
+ ```tsx
204
+ {
205
+ render: () => <ArrivalExample />
206
+ }
207
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.213",
3
+ "version": "0.0.215",
4
4
  "description": "Sharp, monospace React components with compact, comfortable, and touch densities.",
5
5
  "license": "MIT",
6
6
  "repository": {