@pixpilot/shadcn-kanban 0.0.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.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -0
  3. package/dist/AddColumnButton.cjs +82 -0
  4. package/dist/AddColumnButton.js +77 -0
  5. package/dist/ColumnFilterButton.cjs +68 -0
  6. package/dist/ColumnFilterButton.js +63 -0
  7. package/dist/KanbanBoard.cjs +137 -0
  8. package/dist/KanbanBoard.d.cts +36 -0
  9. package/dist/KanbanBoard.d.ts +36 -0
  10. package/dist/KanbanBoard.js +131 -0
  11. package/dist/KanbanColumn.cjs +142 -0
  12. package/dist/KanbanColumn.js +134 -0
  13. package/dist/KanbanColumnCards.cjs +25 -0
  14. package/dist/KanbanColumnCards.js +23 -0
  15. package/dist/KanbanDragOverlay.cjs +42 -0
  16. package/dist/KanbanDragOverlay.js +37 -0
  17. package/dist/KanbanItem.cjs +58 -0
  18. package/dist/KanbanItem.js +52 -0
  19. package/dist/KanbanVirtualColumnCards.cjs +70 -0
  20. package/dist/KanbanVirtualColumnCards.js +66 -0
  21. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  22. package/dist/hooks/use-kanban-board-state.cjs +43 -0
  23. package/dist/hooks/use-kanban-board-state.js +41 -0
  24. package/dist/hooks/use-kanban-card-drag.cjs +83 -0
  25. package/dist/hooks/use-kanban-card-drag.js +81 -0
  26. package/dist/hooks/use-kanban-collision-detection.cjs +70 -0
  27. package/dist/hooks/use-kanban-collision-detection.js +67 -0
  28. package/dist/hooks/use-kanban-column-reorder.cjs +31 -0
  29. package/dist/hooks/use-kanban-column-reorder.js +28 -0
  30. package/dist/hooks/use-kanban-drag.cjs +98 -0
  31. package/dist/hooks/use-kanban-drag.js +95 -0
  32. package/dist/hooks/use-kanban-filters.cjs +49 -0
  33. package/dist/hooks/use-kanban-filters.js +47 -0
  34. package/dist/index.cjs +3 -0
  35. package/dist/index.d.cts +5 -0
  36. package/dist/index.d.ts +5 -0
  37. package/dist/index.js +3 -0
  38. package/dist/infinite-scroll/InfiniteScrollSentinel.cjs +54 -0
  39. package/dist/infinite-scroll/InfiniteScrollSentinel.d.cts +2 -0
  40. package/dist/infinite-scroll/InfiniteScrollSentinel.d.ts +2 -0
  41. package/dist/infinite-scroll/InfiniteScrollSentinel.js +49 -0
  42. package/dist/infinite-scroll/index.d.cts +3 -0
  43. package/dist/infinite-scroll/index.d.ts +3 -0
  44. package/dist/infinite-scroll/types.d.cts +29 -0
  45. package/dist/infinite-scroll/types.d.ts +29 -0
  46. package/dist/infinite-scroll/use-intersection-observer.cjs +46 -0
  47. package/dist/infinite-scroll/use-intersection-observer.d.cts +1 -0
  48. package/dist/infinite-scroll/use-intersection-observer.d.ts +1 -0
  49. package/dist/infinite-scroll/use-intersection-observer.js +44 -0
  50. package/dist/types.d.cts +251 -0
  51. package/dist/types.d.ts +251 -0
  52. package/dist/utils/apply-kanban-drop.cjs +37 -0
  53. package/dist/utils/apply-kanban-drop.js +35 -0
  54. package/dist/utils/column-sortable-id.cjs +23 -0
  55. package/dist/utils/column-sortable-id.js +20 -0
  56. package/dist/utils/is-below-over-item.cjs +17 -0
  57. package/dist/utils/is-below-over-item.js +16 -0
  58. package/dist/utils/items-order-equal.cjs +13 -0
  59. package/dist/utils/items-order-equal.js +12 -0
  60. package/dist/utils/kanban-keyboard-coordinates.cjs +64 -0
  61. package/dist/utils/kanban-keyboard-coordinates.js +62 -0
  62. package/dist/utils/move-kanban-item.cjs +28 -0
  63. package/dist/utils/move-kanban-item.js +27 -0
  64. package/dist/utils/replace-state.cjs +15 -0
  65. package/dist/utils/replace-state.js +14 -0
  66. package/dist/utils/resolve-column-id.cjs +25 -0
  67. package/dist/utils/resolve-column-id.js +24 -0
  68. package/package.json +97 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pixpilot
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # @pixpilot/shadcn-kanban
2
+
3
+ A generic, controlled Kanban board with drag-and-drop powered by
4
+ [`@dnd-kit`](https://dndkit.com), built on
5
+ [`@pixpilot/shadcn-ui`](../shadcn-ui). It owns dragging, column reordering,
6
+ filtering and paging; you own the data.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ pnpm add @pixpilot/shadcn-kanban
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```tsx
17
+ import { KanbanBoard } from '@pixpilot/shadcn-kanban';
18
+
19
+ <KanbanBoard
20
+ columns={[
21
+ { id: 'todo', title: 'To Do' },
22
+ { id: 'done', title: 'Done' },
23
+ ]}
24
+ items={items}
25
+ onChange={(event) => setItems(event.items)}
26
+ />;
27
+ ```
28
+
29
+ The board is **controlled**: it renders the `items` prop and never mutates your
30
+ data. A drop produces a `KanbanChangeEvent` carrying the full reordered array —
31
+ assign `event.items` back to your state and the board settles.
32
+
33
+ ## Documentation
34
+
35
+ | Document | Covers |
36
+ | ---------------------------------------------------- | -------------------------------------------------------------- |
37
+ | [docs/README.md](./docs/README.md) | Overview, layout contract and generics |
38
+ | [docs/api.md](./docs/api.md) | Every prop, type and callback |
39
+ | [docs/drag-and-drop.md](./docs/drag-and-drop.md) | How the drag state machine works, and why it is built this way |
40
+ | [docs/filters.md](./docs/filters.md) | Per-column filters, board-side and parent-side |
41
+ | [docs/infinite-scroll.md](./docs/infinite-scroll.md) | Loading a column's items a page at a time |
42
+ | [docs/virtualization.md](./docs/virtualization.md) | Mounting only the cards near a column's scroll window |
43
+
44
+ ## License
45
+
46
+ MIT
@@ -0,0 +1,82 @@
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
5
+ let __pixpilot_shadcn_ui = require("@pixpilot/shadcn-ui");
6
+ __pixpilot_shadcn_ui = require_rolldown_runtime.__toESM(__pixpilot_shadcn_ui);
7
+ let react = require("react");
8
+ react = require_rolldown_runtime.__toESM(react);
9
+ let lucide_react = require("lucide-react");
10
+ lucide_react = require_rolldown_runtime.__toESM(lucide_react);
11
+ let react_jsx_runtime = require("react/jsx-runtime");
12
+ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
13
+
14
+ //#region src/AddColumnButton.tsx
15
+ /**
16
+ * A button + inline popover that lets the user type a column name
17
+ * and add it to the Kanban board.
18
+ */
19
+ function AddColumnButton({ onAdd, className }) {
20
+ const [open, setOpen] = react.default.useState(false);
21
+ const [value, setValue] = react.default.useState("");
22
+ const inputRef = react.default.useRef(null);
23
+ const handleOpen = () => {
24
+ setOpen(true);
25
+ requestAnimationFrame(() => inputRef.current?.focus());
26
+ };
27
+ const handleClose = () => {
28
+ setOpen(false);
29
+ setValue("");
30
+ };
31
+ const handleSubmit = (e) => {
32
+ e.preventDefault();
33
+ const trimmed = value.trim();
34
+ if (trimmed.length === 0) return;
35
+ onAdd(trimmed);
36
+ handleClose();
37
+ };
38
+ const handleKeyDown = (e) => {
39
+ if (e.key === "Escape") handleClose();
40
+ };
41
+ if (!open) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
42
+ type: "button",
43
+ onClick: handleOpen,
44
+ className: (0, __pixpilot_shadcn_ui.cn)("flex min-w-[250px] shrink-0 cursor-pointer items-center justify-center gap-2", "border-muted-foreground/30 rounded-lg border-2 border-dashed", "bg-muted/20 text-muted-foreground p-4 text-sm", "hover:border-primary/40 hover:bg-muted/40 hover:text-foreground transition-colors", className),
45
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Plus, { className: "h-4 w-4" }), "Add column"]
46
+ });
47
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
48
+ className: (0, __pixpilot_shadcn_ui.cn)("bg-muted/40 flex min-w-[250px] shrink-0 flex-col gap-3 rounded-lg border p-3", className),
49
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
50
+ className: "flex items-center justify-between",
51
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
52
+ className: "text-sm font-semibold",
53
+ children: "New column"
54
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
55
+ type: "button",
56
+ onClick: handleClose,
57
+ className: "text-muted-foreground hover:text-foreground rounded p-0.5 transition-colors",
58
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "h-4 w-4" })
59
+ })]
60
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
61
+ onSubmit: handleSubmit,
62
+ className: "flex flex-col gap-2",
63
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
64
+ ref: inputRef,
65
+ type: "text",
66
+ placeholder: "Column name…",
67
+ value,
68
+ onChange: (e) => setValue(e.target.value),
69
+ onKeyDown: handleKeyDown,
70
+ className: (0, __pixpilot_shadcn_ui.cn)("bg-background rounded-md border px-3 py-1.5 text-sm", "placeholder:text-muted-foreground", "focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none")
71
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
72
+ type: "submit",
73
+ disabled: value.trim().length === 0,
74
+ className: (0, __pixpilot_shadcn_ui.cn)("bg-primary text-primary-foreground rounded-md px-3 py-1.5 text-sm font-medium", "hover:bg-primary/90 transition-colors", "disabled:cursor-not-allowed disabled:opacity-50"),
75
+ children: "Add"
76
+ })]
77
+ })]
78
+ });
79
+ }
80
+
81
+ //#endregion
82
+ exports.AddColumnButton = AddColumnButton;
@@ -0,0 +1,77 @@
1
+ 'use client';
2
+
3
+
4
+ import { cn } from "@pixpilot/shadcn-ui";
5
+ import React from "react";
6
+ import { Plus, X } from "lucide-react";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+
9
+ //#region src/AddColumnButton.tsx
10
+ /**
11
+ * A button + inline popover that lets the user type a column name
12
+ * and add it to the Kanban board.
13
+ */
14
+ function AddColumnButton({ onAdd, className }) {
15
+ const [open, setOpen] = React.useState(false);
16
+ const [value, setValue] = React.useState("");
17
+ const inputRef = React.useRef(null);
18
+ const handleOpen = () => {
19
+ setOpen(true);
20
+ requestAnimationFrame(() => inputRef.current?.focus());
21
+ };
22
+ const handleClose = () => {
23
+ setOpen(false);
24
+ setValue("");
25
+ };
26
+ const handleSubmit = (e) => {
27
+ e.preventDefault();
28
+ const trimmed = value.trim();
29
+ if (trimmed.length === 0) return;
30
+ onAdd(trimmed);
31
+ handleClose();
32
+ };
33
+ const handleKeyDown = (e) => {
34
+ if (e.key === "Escape") handleClose();
35
+ };
36
+ if (!open) return /* @__PURE__ */ jsxs("button", {
37
+ type: "button",
38
+ onClick: handleOpen,
39
+ className: cn("flex min-w-[250px] shrink-0 cursor-pointer items-center justify-center gap-2", "border-muted-foreground/30 rounded-lg border-2 border-dashed", "bg-muted/20 text-muted-foreground p-4 text-sm", "hover:border-primary/40 hover:bg-muted/40 hover:text-foreground transition-colors", className),
40
+ children: [/* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }), "Add column"]
41
+ });
42
+ return /* @__PURE__ */ jsxs("div", {
43
+ className: cn("bg-muted/40 flex min-w-[250px] shrink-0 flex-col gap-3 rounded-lg border p-3", className),
44
+ children: [/* @__PURE__ */ jsxs("div", {
45
+ className: "flex items-center justify-between",
46
+ children: [/* @__PURE__ */ jsx("span", {
47
+ className: "text-sm font-semibold",
48
+ children: "New column"
49
+ }), /* @__PURE__ */ jsx("button", {
50
+ type: "button",
51
+ onClick: handleClose,
52
+ className: "text-muted-foreground hover:text-foreground rounded p-0.5 transition-colors",
53
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
54
+ })]
55
+ }), /* @__PURE__ */ jsxs("form", {
56
+ onSubmit: handleSubmit,
57
+ className: "flex flex-col gap-2",
58
+ children: [/* @__PURE__ */ jsx("input", {
59
+ ref: inputRef,
60
+ type: "text",
61
+ placeholder: "Column name…",
62
+ value,
63
+ onChange: (e) => setValue(e.target.value),
64
+ onKeyDown: handleKeyDown,
65
+ className: cn("bg-background rounded-md border px-3 py-1.5 text-sm", "placeholder:text-muted-foreground", "focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none")
66
+ }), /* @__PURE__ */ jsx("button", {
67
+ type: "submit",
68
+ disabled: value.trim().length === 0,
69
+ className: cn("bg-primary text-primary-foreground rounded-md px-3 py-1.5 text-sm font-medium", "hover:bg-primary/90 transition-colors", "disabled:cursor-not-allowed disabled:opacity-50"),
70
+ children: "Add"
71
+ })]
72
+ })]
73
+ });
74
+ }
75
+
76
+ //#endregion
77
+ export { AddColumnButton };
@@ -0,0 +1,68 @@
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
5
+ let __pixpilot_shadcn_ui = require("@pixpilot/shadcn-ui");
6
+ __pixpilot_shadcn_ui = require_rolldown_runtime.__toESM(__pixpilot_shadcn_ui);
7
+ let react = require("react");
8
+ react = require_rolldown_runtime.__toESM(react);
9
+ let lucide_react = require("lucide-react");
10
+ lucide_react = require_rolldown_runtime.__toESM(lucide_react);
11
+ let react_jsx_runtime = require("react/jsx-runtime");
12
+ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
13
+
14
+ //#region src/ColumnFilterButton.tsx
15
+ /**
16
+ * A filter icon button rendered in a Kanban column header. Clicking it opens
17
+ * a popover listing the column's filters; selecting one toggles it. A badge
18
+ * shows how many filters are currently active.
19
+ */
20
+ function ColumnFilterButton({ filters, activeFilterIds, onToggle, onClear }) {
21
+ const activeCount = activeFilterIds.length;
22
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.Popover, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.PopoverTrigger, {
23
+ asChild: true,
24
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
25
+ type: "button",
26
+ "aria-label": "Filter column",
27
+ className: (0, __pixpilot_shadcn_ui.cn)("text-muted-foreground hover:text-foreground relative rounded p-0.5 transition-colors", activeCount > 0 && "text-primary"),
28
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Filter, { className: "h-4 w-4" }), activeCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
29
+ className: "bg-primary text-primary-foreground absolute -top-1 -right-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full px-1 text-[10px] leading-none font-medium",
30
+ children: activeCount
31
+ }) : null]
32
+ })
33
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.PopoverContent, {
34
+ align: "end",
35
+ className: "w-56 p-1",
36
+ children: [
37
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
38
+ className: "text-muted-foreground px-2 py-1.5 text-xs font-medium",
39
+ children: "Filters"
40
+ }),
41
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
42
+ className: "flex flex-col",
43
+ children: filters.map((filter) => {
44
+ const active = activeFilterIds.includes(filter.id);
45
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
46
+ type: "button",
47
+ onClick: () => onToggle(filter.id),
48
+ "aria-pressed": active,
49
+ className: (0, __pixpilot_shadcn_ui.cn)("hover:bg-accent hover:text-accent-foreground flex w-full items-center justify-between gap-2 rounded-sm px-2 py-1.5 text-left text-sm transition-colors", active && "text-foreground font-medium"),
50
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
51
+ className: "truncate",
52
+ children: filter.label
53
+ }), active ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "text-primary h-4 w-4 shrink-0" }) : null]
54
+ }) }, filter.id);
55
+ })
56
+ }),
57
+ activeCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "bg-border my-1 h-px" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
58
+ type: "button",
59
+ onClick: onClear,
60
+ className: "text-muted-foreground hover:bg-accent hover:text-accent-foreground w-full rounded-sm px-2 py-1.5 text-left text-sm transition-colors",
61
+ children: "Clear filters"
62
+ })] }) : null
63
+ ]
64
+ })] });
65
+ }
66
+
67
+ //#endregion
68
+ exports.ColumnFilterButton = ColumnFilterButton;
@@ -0,0 +1,63 @@
1
+ 'use client';
2
+
3
+
4
+ import { Popover, PopoverContent, PopoverTrigger, cn } from "@pixpilot/shadcn-ui";
5
+ import React from "react";
6
+ import { Check, Filter } from "lucide-react";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+
9
+ //#region src/ColumnFilterButton.tsx
10
+ /**
11
+ * A filter icon button rendered in a Kanban column header. Clicking it opens
12
+ * a popover listing the column's filters; selecting one toggles it. A badge
13
+ * shows how many filters are currently active.
14
+ */
15
+ function ColumnFilterButton({ filters, activeFilterIds, onToggle, onClear }) {
16
+ const activeCount = activeFilterIds.length;
17
+ return /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsx(PopoverTrigger, {
18
+ asChild: true,
19
+ children: /* @__PURE__ */ jsxs("button", {
20
+ type: "button",
21
+ "aria-label": "Filter column",
22
+ className: cn("text-muted-foreground hover:text-foreground relative rounded p-0.5 transition-colors", activeCount > 0 && "text-primary"),
23
+ children: [/* @__PURE__ */ jsx(Filter, { className: "h-4 w-4" }), activeCount > 0 ? /* @__PURE__ */ jsx("span", {
24
+ className: "bg-primary text-primary-foreground absolute -top-1 -right-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full px-1 text-[10px] leading-none font-medium",
25
+ children: activeCount
26
+ }) : null]
27
+ })
28
+ }), /* @__PURE__ */ jsxs(PopoverContent, {
29
+ align: "end",
30
+ className: "w-56 p-1",
31
+ children: [
32
+ /* @__PURE__ */ jsx("div", {
33
+ className: "text-muted-foreground px-2 py-1.5 text-xs font-medium",
34
+ children: "Filters"
35
+ }),
36
+ /* @__PURE__ */ jsx("ul", {
37
+ className: "flex flex-col",
38
+ children: filters.map((filter) => {
39
+ const active = activeFilterIds.includes(filter.id);
40
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
41
+ type: "button",
42
+ onClick: () => onToggle(filter.id),
43
+ "aria-pressed": active,
44
+ className: cn("hover:bg-accent hover:text-accent-foreground flex w-full items-center justify-between gap-2 rounded-sm px-2 py-1.5 text-left text-sm transition-colors", active && "text-foreground font-medium"),
45
+ children: [/* @__PURE__ */ jsx("span", {
46
+ className: "truncate",
47
+ children: filter.label
48
+ }), active ? /* @__PURE__ */ jsx(Check, { className: "text-primary h-4 w-4 shrink-0" }) : null]
49
+ }) }, filter.id);
50
+ })
51
+ }),
52
+ activeCount > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { className: "bg-border my-1 h-px" }), /* @__PURE__ */ jsx("button", {
53
+ type: "button",
54
+ onClick: onClear,
55
+ className: "text-muted-foreground hover:bg-accent hover:text-accent-foreground w-full rounded-sm px-2 py-1.5 text-left text-sm transition-colors",
56
+ children: "Clear filters"
57
+ })] }) : null
58
+ ]
59
+ })] });
60
+ }
61
+
62
+ //#endregion
63
+ export { ColumnFilterButton };
@@ -0,0 +1,137 @@
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
5
+ const require_AddColumnButton = require('./AddColumnButton.cjs');
6
+ const require_column_sortable_id = require('./utils/column-sortable-id.cjs');
7
+ const require_use_kanban_drag = require('./hooks/use-kanban-drag.cjs');
8
+ const require_use_kanban_filters = require('./hooks/use-kanban-filters.cjs');
9
+ const require_KanbanColumn = require('./KanbanColumn.cjs');
10
+ const require_KanbanDragOverlay = require('./KanbanDragOverlay.cjs');
11
+ let __dnd_kit_core = require("@dnd-kit/core");
12
+ __dnd_kit_core = require_rolldown_runtime.__toESM(__dnd_kit_core);
13
+ let __dnd_kit_sortable = require("@dnd-kit/sortable");
14
+ __dnd_kit_sortable = require_rolldown_runtime.__toESM(__dnd_kit_sortable);
15
+ let __pixpilot_shadcn_ui = require("@pixpilot/shadcn-ui");
16
+ __pixpilot_shadcn_ui = require_rolldown_runtime.__toESM(__pixpilot_shadcn_ui);
17
+ let react = require("react");
18
+ react = require_rolldown_runtime.__toESM(react);
19
+ let react_jsx_runtime = require("react/jsx-runtime");
20
+ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
21
+
22
+ //#region src/KanbanBoard.tsx
23
+ const MEASURING = { droppable: { strategy: __dnd_kit_core.MeasuringStrategy.Always } };
24
+ /**
25
+ * Warns once, in development only, when a scroll-only feature is requested for
26
+ * a column mode that cannot support it. Deliberately non-throwing: a mis-set
27
+ * prop should not take a board down in production.
28
+ */
29
+ function useScrollOnlyFeatureWarning(feature, consequence, requested, columnOverflow) {
30
+ const warned = react.default.useRef(false);
31
+ react.default.useEffect(() => {
32
+ if (process.env.NODE_ENV === "production") return;
33
+ if (!requested || columnOverflow === "scroll" || warned.current) return;
34
+ warned.current = true;
35
+ console.error(`[KanbanBoard] \`${feature}\` is not implemented for columnOverflow="${columnOverflow}" — only "scroll" is supported. ${consequence}`);
36
+ }, [
37
+ feature,
38
+ consequence,
39
+ requested,
40
+ columnOverflow
41
+ ]);
42
+ }
43
+ /**
44
+ * A generic, reusable Kanban board with drag-and-drop powered by `@dnd-kit`.
45
+ *
46
+ * Accepts an array of {@link KanbanItem} items and {@link KanbanColumn}
47
+ * column definitions and calls `onChange` whenever an item is moved
48
+ * between (or within) columns.
49
+ */
50
+ function KanbanBoard({ items: externalItems, columns, onChange, renderItem, renderColumnHeader, className, style, columnClassName, getColumnProps, hideColumnHeaders = false, itemClassName, columnOverflow = "scroll", allowAddColumn, onAddColumn, onColumnChange, filters, onFilterChange, infiniteScroll, virtualization, dragDisabled = false }) {
51
+ useScrollOnlyFeatureWarning("infiniteScroll", "The sentinel will not be rendered.", Boolean(infiniteScroll), columnOverflow);
52
+ useScrollOnlyFeatureWarning("virtualization", "Every card will be rendered.", Boolean(virtualization), columnOverflow);
53
+ const activeInfiniteScroll = columnOverflow === "scroll" ? infiniteScroll : void 0;
54
+ const activeVirtualization = columnOverflow === "scroll" && virtualization?.disabled !== true ? virtualization : void 0;
55
+ const { items, internalColumns, activeId, isDraggingColumn, sensors, collisionDetection, handleDragStart, handleDragOver, handleDragEnd, handleDragCancel } = require_use_kanban_drag.useKanbanDrag({
56
+ externalItems,
57
+ columns,
58
+ onChange,
59
+ onColumnChange
60
+ });
61
+ const { activeFilters, resolveFilters, handleToggleFilter, handleClearFilters } = require_use_kanban_filters.useKanbanFilters({
62
+ filters,
63
+ onFilterChange
64
+ });
65
+ const activeItem = activeId !== null && !isDraggingColumn ? items.find((i) => i.id === activeId) ?? null : null;
66
+ const activeItemColumn = activeItem ? internalColumns.find((c) => c.id === activeItem.columnId) : void 0;
67
+ const activeColumn = activeId !== null && isDraggingColumn ? internalColumns.find((c) => require_column_sortable_id.toColumnSortableId(c.id) === String(activeId)) : void 0;
68
+ const columnItemsMap = react.default.useMemo(() => internalColumns.map((col) => {
69
+ const colFilters = resolveFilters(col);
70
+ const activeIds = activeFilters[col.id] ?? [];
71
+ const activePredicates = colFilters.filter((f) => activeIds.includes(f.id) && typeof f.predicate === "function");
72
+ let colItems = items.filter((i) => i.columnId === col.id);
73
+ if (activePredicates.length > 0) colItems = colItems.filter((item) => activePredicates.every((f) => f.predicate(item, col)));
74
+ return {
75
+ column: col,
76
+ colItems,
77
+ colFilters,
78
+ activeIds
79
+ };
80
+ }), [
81
+ internalColumns,
82
+ items,
83
+ resolveFilters,
84
+ activeFilters
85
+ ]);
86
+ const columnSortableIds = react.default.useMemo(() => internalColumns.map((c) => require_column_sortable_id.toColumnSortableId(c.id)), [internalColumns]);
87
+ const isColumnSortable = Boolean(onColumnChange) && !dragDisabled;
88
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__dnd_kit_core.DndContext, {
89
+ sensors,
90
+ collisionDetection,
91
+ measuring: MEASURING,
92
+ onDragStart: handleDragStart,
93
+ onDragOver: handleDragOver,
94
+ onDragEnd: handleDragEnd,
95
+ onDragCancel: handleDragCancel,
96
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__dnd_kit_sortable.SortableContext, {
97
+ items: columnSortableIds,
98
+ strategy: __dnd_kit_sortable.horizontalListSortingStrategy,
99
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
100
+ "data-testid": "kanban-board",
101
+ className: (0, __pixpilot_shadcn_ui.cn)("relative flex gap-4 overflow-x-auto overscroll-x-contain p-2", columnOverflow === "scroll" ? "h-full min-h-0" : "min-h-full", className),
102
+ style,
103
+ children: [columnItemsMap.map(({ column, colItems, colFilters, activeIds }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_KanbanColumn.KanbanColumn, {
104
+ column,
105
+ items: colItems,
106
+ renderItem,
107
+ renderColumnHeader,
108
+ columnClassName,
109
+ containerProps: getColumnProps?.(column),
110
+ hideHeader: hideColumnHeaders,
111
+ itemClassName,
112
+ sortable: isColumnSortable,
113
+ filters: colFilters,
114
+ activeFilterIds: activeIds,
115
+ columnOverflow,
116
+ infiniteScroll: activeInfiniteScroll,
117
+ virtualization: activeVirtualization,
118
+ dragDisabled,
119
+ activeItemId: activeItem?.id ?? null,
120
+ onToggleFilter: (filterId) => handleToggleFilter(column, filterId),
121
+ onClearFilters: () => handleClearFilters(column)
122
+ }, column.id)), allowAddColumn && onAddColumn ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AddColumnButton.AddColumnButton, { onAdd: onAddColumn }) : null]
123
+ })
124
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_KanbanDragOverlay.KanbanDragOverlay, {
125
+ activeItem,
126
+ activeItemColumn,
127
+ activeColumn,
128
+ activeColumnItemCount: activeColumn ? items.filter((i) => i.columnId === activeColumn.id).length : 0,
129
+ renderItem,
130
+ itemClassName,
131
+ columnClassName
132
+ })]
133
+ });
134
+ }
135
+
136
+ //#endregion
137
+ exports.KanbanBoard = KanbanBoard;
@@ -0,0 +1,36 @@
1
+ import { KanbanBoardProps } from "./types.cjs";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+
4
+ //#region src/KanbanBoard.d.ts
5
+
6
+ /**
7
+ * A generic, reusable Kanban board with drag-and-drop powered by `@dnd-kit`.
8
+ *
9
+ * Accepts an array of {@link KanbanItem} items and {@link KanbanColumn}
10
+ * column definitions and calls `onChange` whenever an item is moved
11
+ * between (or within) columns.
12
+ */
13
+ declare function KanbanBoard<T = Record<string, unknown>>({
14
+ items: externalItems,
15
+ columns,
16
+ onChange,
17
+ renderItem,
18
+ renderColumnHeader,
19
+ className,
20
+ style,
21
+ columnClassName,
22
+ getColumnProps,
23
+ hideColumnHeaders,
24
+ itemClassName,
25
+ columnOverflow,
26
+ allowAddColumn,
27
+ onAddColumn,
28
+ onColumnChange,
29
+ filters,
30
+ onFilterChange,
31
+ infiniteScroll,
32
+ virtualization,
33
+ dragDisabled
34
+ }: KanbanBoardProps<T>): react_jsx_runtime0.JSX.Element;
35
+ //#endregion
36
+ export { KanbanBoard };
@@ -0,0 +1,36 @@
1
+ import { KanbanBoardProps } from "./types.js";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+
4
+ //#region src/KanbanBoard.d.ts
5
+
6
+ /**
7
+ * A generic, reusable Kanban board with drag-and-drop powered by `@dnd-kit`.
8
+ *
9
+ * Accepts an array of {@link KanbanItem} items and {@link KanbanColumn}
10
+ * column definitions and calls `onChange` whenever an item is moved
11
+ * between (or within) columns.
12
+ */
13
+ declare function KanbanBoard<T = Record<string, unknown>>({
14
+ items: externalItems,
15
+ columns,
16
+ onChange,
17
+ renderItem,
18
+ renderColumnHeader,
19
+ className,
20
+ style,
21
+ columnClassName,
22
+ getColumnProps,
23
+ hideColumnHeaders,
24
+ itemClassName,
25
+ columnOverflow,
26
+ allowAddColumn,
27
+ onAddColumn,
28
+ onColumnChange,
29
+ filters,
30
+ onFilterChange,
31
+ infiniteScroll,
32
+ virtualization,
33
+ dragDisabled
34
+ }: KanbanBoardProps<T>): react_jsx_runtime0.JSX.Element;
35
+ //#endregion
36
+ export { KanbanBoard };