@stll/ui 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/button-variants.d.ts +2 -2
- package/dist/components/composer.d.ts +108 -0
- package/dist/components/composer.js +132 -0
- package/dist/components/landing.d.ts +61 -0
- package/dist/components/landing.js +97 -0
- package/dist/components/sidebar.d.ts +109 -0
- package/dist/components/sidebar.js +361 -0
- package/dist/components/sidebar.logic.d.ts +34 -0
- package/dist/components/sidebar.logic.js +27 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +6 -3
- package/dist/inspector/entity-tab.d.ts +54 -0
- package/dist/inspector/entity-tab.js +56 -0
- package/dist/inspector/entity-tab.logic.d.ts +28 -0
- package/dist/inspector/entity-tab.logic.js +32 -0
- package/dist/inspector/facet-bar.d.ts +46 -0
- package/dist/inspector/facet-bar.js +166 -0
- package/dist/inspector/facet-bar.logic.d.ts +51 -0
- package/dist/inspector/facet-bar.logic.js +53 -0
- package/dist/inspector/index.d.ts +3 -1
- package/dist/inspector/index.js +3 -1
- package/dist/inspector/tabs.d.ts +1 -1
- package/dist/kanban/band-peek.d.ts +26 -33
- package/dist/kanban/band-peek.js +24 -30
- package/dist/kanban/column-header.d.ts +8 -1
- package/dist/kanban/column-header.js +9 -2
- package/dist/kanban/drag-interactions.d.ts +9 -1
- package/dist/kanban/drag-interactions.js +10 -1
- package/dist/kanban/index.d.ts +2 -2
- package/dist/kanban/index.js +2 -2
- package/dist/kanban/sortable-interactions.d.ts +12 -0
- package/dist/kanban/subgroup-board.d.ts +33 -6
- package/dist/kanban/subgroup-board.js +75 -22
- package/dist/kanban/virtual-cell.d.ts +10 -1
- package/dist/kanban/virtual-cell.js +25 -3
- package/dist/lib/control-size.d.ts +1 -1
- package/dist/lib/slot.d.ts +28 -0
- package/dist/lib/slot.js +64 -0
- package/package.json +17 -1
package/dist/kanban/band-peek.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
//#region src/kanban/band-peek.ts
|
|
2
2
|
/**
|
|
3
|
-
* The peek a collapsed band opens while a
|
|
4
|
-
* as a state machine with an injectable scheduler so its timing rules
|
|
5
|
-
* tested without a DOM.
|
|
3
|
+
* The peek a collapsed band opens while a dragged card rests on its folded
|
|
4
|
+
* slot, as a state machine with an injectable scheduler so its timing rules
|
|
5
|
+
* can be tested without a DOM. A plain hover never peeks: the peek exists so
|
|
6
|
+
* a drag can still land on a specific column inside a folded band, and the
|
|
7
|
+
* board only feeds the controller drag events.
|
|
6
8
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* band for a short linger. The band renders as separate elements (its
|
|
15
|
-
* caption, then its columns in each lane), so moving from the caption
|
|
16
|
-
* down into a column crosses an element boundary; without the linger the
|
|
17
|
-
* band would fold under the pointer and the slot would peek it straight
|
|
18
|
-
* back open.
|
|
9
|
+
* One rule keeps a peek from fighting the drag: it ends only after the drag
|
|
10
|
+
* has left every part of the open band for a short linger. The band renders
|
|
11
|
+
* as separate elements (its caption, then its columns in each lane), so
|
|
12
|
+
* moving from the caption down into a column crosses an element boundary;
|
|
13
|
+
* without the linger the band would fold under the card and the slot would
|
|
14
|
+
* peek it straight back open. The end of the drag, wherever it lands, ends
|
|
15
|
+
* the peek at once.
|
|
19
16
|
*/
|
|
20
|
-
/** How long a
|
|
17
|
+
/** How long a dragged card rests on a folded slot before the band peeks open. */
|
|
21
18
|
const KANBAN_BAND_PEEK_DELAY_MS = 400;
|
|
22
|
-
/** How long the
|
|
19
|
+
/** How long the drag may be outside an open band before the peek ends. */
|
|
23
20
|
const KANBAN_BAND_PEEK_LINGER_MS = 150;
|
|
24
21
|
const hostScheduler = (callback, ms) => {
|
|
25
22
|
const timer = setTimeout(callback, ms);
|
|
@@ -27,7 +24,6 @@ const hostScheduler = (callback, ms) => {
|
|
|
27
24
|
};
|
|
28
25
|
const createBandPeekController = ({ onChange, delayMs = 400, lingerMs = 150, schedule = hostScheduler }) => {
|
|
29
26
|
let peekingBandId = null;
|
|
30
|
-
let suppressedBandId = null;
|
|
31
27
|
let cancelOpen = null;
|
|
32
28
|
let openingBandId = null;
|
|
33
29
|
let cancelEnd = null;
|
|
@@ -57,8 +53,8 @@ const createBandPeekController = ({ onChange, delayMs = 400, lingerMs = 150, sch
|
|
|
57
53
|
}
|
|
58
54
|
};
|
|
59
55
|
return {
|
|
60
|
-
|
|
61
|
-
if (
|
|
56
|
+
slotDragOver: (bandId) => {
|
|
57
|
+
if (peekingBandId === bandId || openingBandId === bandId) return;
|
|
62
58
|
clearOpenTimer();
|
|
63
59
|
openingBandId = bandId;
|
|
64
60
|
cancelOpen = schedule(() => {
|
|
@@ -68,28 +64,22 @@ const createBandPeekController = ({ onChange, delayMs = 400, lingerMs = 150, sch
|
|
|
68
64
|
setPeeking(bandId);
|
|
69
65
|
}, delayMs);
|
|
70
66
|
},
|
|
71
|
-
|
|
67
|
+
slotDragLeave: (bandId) => {
|
|
72
68
|
if (openingBandId === bandId) clearOpenTimer();
|
|
73
|
-
if (suppressedBandId === bandId) suppressedBandId = null;
|
|
74
69
|
},
|
|
75
|
-
|
|
70
|
+
openDragEnter: (bandId) => {
|
|
76
71
|
if (peekingBandId === bandId) clearEndTimer();
|
|
77
72
|
},
|
|
78
|
-
|
|
73
|
+
openDragLeave: (bandId) => {
|
|
79
74
|
if (peekingBandId !== bandId || cancelEnd !== null) return;
|
|
80
75
|
cancelEnd = schedule(() => {
|
|
81
76
|
cancelEnd = null;
|
|
82
77
|
setPeeking(null);
|
|
83
78
|
}, lingerMs);
|
|
84
79
|
},
|
|
85
|
-
foldedUnderPointer: (bandId) => {
|
|
86
|
-
bandFolded(bandId);
|
|
87
|
-
suppressedBandId = bandId;
|
|
88
|
-
},
|
|
89
80
|
bandFolded,
|
|
90
81
|
bandExpanded: (bandId) => {
|
|
91
82
|
if (openingBandId === bandId) clearOpenTimer();
|
|
92
|
-
if (suppressedBandId === bandId) suppressedBandId = null;
|
|
93
83
|
if (peekingBandId === bandId) {
|
|
94
84
|
clearEndTimer();
|
|
95
85
|
setPeeking(null);
|
|
@@ -97,7 +87,11 @@ const createBandPeekController = ({ onChange, delayMs = 400, lingerMs = 150, sch
|
|
|
97
87
|
},
|
|
98
88
|
slotUnmounted: (bandId) => {
|
|
99
89
|
if (openingBandId === bandId) clearOpenTimer();
|
|
100
|
-
|
|
90
|
+
},
|
|
91
|
+
dragEnded: () => {
|
|
92
|
+
clearOpenTimer();
|
|
93
|
+
clearEndTimer();
|
|
94
|
+
setPeeking(null);
|
|
101
95
|
},
|
|
102
96
|
dispose: () => {
|
|
103
97
|
clearOpenTimer();
|
|
@@ -13,11 +13,18 @@ type KanbanColumnHeaderProps = {
|
|
|
13
13
|
dragHandle?: ReactNode;
|
|
14
14
|
/** Column menu. */
|
|
15
15
|
actions?: ReactNode;
|
|
16
|
+
/** Extra classes, e.g. to opt a caller out of the default row height. */
|
|
17
|
+
className?: string;
|
|
16
18
|
};
|
|
17
19
|
/**
|
|
18
20
|
* The column header row: one rhythm for the swatch, the name, the count, the
|
|
19
21
|
* calculation, and the column's controls, so every board's header lines up.
|
|
22
|
+
*
|
|
23
|
+
* Fixed at `TOOLBAR_ROW_HEIGHT`, the same height as the page header, the view
|
|
24
|
+
* switcher, and the inspector rail's cells, so a column's top edge lines up
|
|
25
|
+
* with every other chrome row above the board. The title clips instead of
|
|
26
|
+
* wrapping so a long name can never grow the row past that height.
|
|
20
27
|
*/
|
|
21
|
-
declare const KanbanColumnHeader: ({ swatch, title, meta, calculation, dragHandle, actions }: KanbanColumnHeaderProps) => import("react").JSX.Element;
|
|
28
|
+
declare const KanbanColumnHeader: ({ swatch, title, meta, calculation, dragHandle, actions, className }: KanbanColumnHeaderProps) => import("react").JSX.Element;
|
|
22
29
|
//#endregion
|
|
23
30
|
export { KanbanColumnHeader, KanbanColumnHeaderProps };
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { cn } from "../lib/utils.js";
|
|
2
|
+
import { TOOLBAR_ROW_HEIGHT } from "../inspector/layout-tokens.js";
|
|
1
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
4
|
//#region src/kanban/column-header.tsx
|
|
3
5
|
/**
|
|
4
6
|
* The column header row: one rhythm for the swatch, the name, the count, the
|
|
5
7
|
* calculation, and the column's controls, so every board's header lines up.
|
|
8
|
+
*
|
|
9
|
+
* Fixed at `TOOLBAR_ROW_HEIGHT`, the same height as the page header, the view
|
|
10
|
+
* switcher, and the inspector rail's cells, so a column's top edge lines up
|
|
11
|
+
* with every other chrome row above the board. The title clips instead of
|
|
12
|
+
* wrapping so a long name can never grow the row past that height.
|
|
6
13
|
*/
|
|
7
|
-
const KanbanColumnHeader = ({ swatch, title, meta, calculation, dragHandle, actions }) => /* @__PURE__ */ jsxs("div", {
|
|
8
|
-
className: "flex items-center gap-2 px-3
|
|
14
|
+
const KanbanColumnHeader = ({ swatch, title, meta, calculation, dragHandle, actions, className }) => /* @__PURE__ */ jsxs("div", {
|
|
15
|
+
className: cn("flex items-center gap-2 px-3", TOOLBAR_ROW_HEIGHT, className),
|
|
9
16
|
children: [
|
|
10
17
|
swatch,
|
|
11
18
|
/* @__PURE__ */ jsxs("span", {
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
2
2
|
//#region src/kanban/drag-interactions.d.ts
|
|
3
3
|
type AtlaskitDraggableOptions = Parameters<typeof draggable>[0];
|
|
4
|
+
/**
|
|
5
|
+
* Marks a card drag on the native `DataTransfer` so the board's native
|
|
6
|
+
* `dragover`/`dragenter`/`dragleave` listeners (which also see reorders,
|
|
7
|
+
* file drops, and any other native drag passing over the board) can tell a
|
|
8
|
+
* kanban card drag from everything else. Pragmatic's `getInitialData` never
|
|
9
|
+
* reaches those native events; only data attached this way does.
|
|
10
|
+
*/
|
|
11
|
+
declare const KANBAN_CARD_DRAG_MIME: "application/x-stella-kanban-card";
|
|
4
12
|
type RegisterKanbanCardDragOptions = {
|
|
5
13
|
/** The drag wrapper rendered by `KanbanCardShell`. */
|
|
6
14
|
element: AtlaskitDraggableOptions["element"];
|
|
@@ -32,4 +40,4 @@ type RegisterKanbanBoardAutoScrollOptions = {
|
|
|
32
40
|
/** Register horizontal auto-scroll at the board's overflow boundary. */
|
|
33
41
|
declare const registerKanbanBoardAutoScroll: ({ element, sources }: RegisterKanbanBoardAutoScrollOptions) => (() => void);
|
|
34
42
|
//#endregion
|
|
35
|
-
export { KANBAN_BOARD_AUTO_SCROLL_SOURCES, RegisterKanbanBoardAutoScrollOptions, RegisterKanbanCardDragOptions, registerKanbanBoardAutoScroll, registerKanbanCardDrag };
|
|
43
|
+
export { KANBAN_BOARD_AUTO_SCROLL_SOURCES, KANBAN_CARD_DRAG_MIME, RegisterKanbanBoardAutoScrollOptions, RegisterKanbanCardDragOptions, registerKanbanBoardAutoScroll, registerKanbanCardDrag };
|
|
@@ -6,6 +6,14 @@ import { centerUnderPointer } from "@atlaskit/pragmatic-drag-and-drop/element/ce
|
|
|
6
6
|
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
7
7
|
//#region src/kanban/drag-interactions.ts
|
|
8
8
|
/**
|
|
9
|
+
* Marks a card drag on the native `DataTransfer` so the board's native
|
|
10
|
+
* `dragover`/`dragenter`/`dragleave` listeners (which also see reorders,
|
|
11
|
+
* file drops, and any other native drag passing over the board) can tell a
|
|
12
|
+
* kanban card drag from everything else. Pragmatic's `getInitialData` never
|
|
13
|
+
* reaches those native events; only data attached this way does.
|
|
14
|
+
*/
|
|
15
|
+
const KANBAN_CARD_DRAG_MIME = "application/x-stella-kanban-card";
|
|
16
|
+
/**
|
|
9
17
|
* Register the standard kanban card drag source and native preview.
|
|
10
18
|
*
|
|
11
19
|
* Movement remains with the caller: the package does not inspect the drag data
|
|
@@ -15,6 +23,7 @@ import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/el
|
|
|
15
23
|
const registerKanbanCardDrag = ({ element, getInitialData, canDrag, onDragStart, onDrop }) => draggable({
|
|
16
24
|
element,
|
|
17
25
|
getInitialData,
|
|
26
|
+
getInitialDataForExternal: () => ({ [KANBAN_CARD_DRAG_MIME]: "" }),
|
|
18
27
|
...canDrag === void 0 ? {} : { canDrag },
|
|
19
28
|
...onDragStart === void 0 ? {} : { onDragStart },
|
|
20
29
|
...onDrop === void 0 ? {} : { onDrop },
|
|
@@ -50,4 +59,4 @@ const registerKanbanBoardAutoScroll = ({ element, sources }) => {
|
|
|
50
59
|
}));
|
|
51
60
|
};
|
|
52
61
|
//#endregion
|
|
53
|
-
export { KANBAN_BOARD_AUTO_SCROLL_SOURCES, registerKanbanBoardAutoScroll, registerKanbanCardDrag };
|
|
62
|
+
export { KANBAN_BOARD_AUTO_SCROLL_SOURCES, KANBAN_CARD_DRAG_MIME, registerKanbanBoardAutoScroll, registerKanbanCardDrag };
|
package/dist/kanban/index.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ import { KanbanColumnHeader, KanbanColumnHeaderProps } from "./column-header.js"
|
|
|
9
9
|
import { KANBAN_BOARD_COLLISION_DETECTION, KanbanCellVirtualNavigation, KanbanSortableCellPosition, KanbanVirtualScrollRequest, kanbanKeyboardCoordinates } from "./sortable-interactions.logic.js";
|
|
10
10
|
import { KANBAN_BOARD_AUTO_SCROLL_OPTIONS, KANBAN_DRAG_OVERLAY_Z_INDEX, KANBAN_MOUSE_ACTIVATION_DISTANCE, KANBAN_SORTABLE_ACTIVATION_MODES, KANBAN_TOUCH_ACTIVATION_CONSTRAINT, KanbanCardDragSurface, KanbanCardDragSurfaceProps, KanbanDragCancelEvent, KanbanDragEndEvent, KanbanDragHandle, KanbanDragHandleProps, KanbanDragOverEvent, KanbanDragStartEvent, KanbanSortableActivationMode, KanbanSortableBindings, KanbanSortableBoard, KanbanSortableBoardProps, KanbanSortableColumns, KanbanSortableColumnsProps, KanbanSortableList, KanbanSortableListProps, UseKanbanDropTargetOptions, UseKanbanSortableOptions, useKanbanDropTarget, useKanbanSortable, useKanbanSortableSensors } from "./sortable-interactions.js";
|
|
11
11
|
import { KANBAN_DIRECTIONS, KANBAN_HORIZONTAL_EDGES, KanbanDirection, KanbanHorizontalEdge, getKanbanHorizontalEdge } from "./sortable-edge.js";
|
|
12
|
-
import { KANBAN_BOARD_AUTO_SCROLL_SOURCES, RegisterKanbanBoardAutoScrollOptions, RegisterKanbanCardDragOptions, registerKanbanBoardAutoScroll, registerKanbanCardDrag } from "./drag-interactions.js";
|
|
12
|
+
import { KANBAN_BOARD_AUTO_SCROLL_SOURCES, KANBAN_CARD_DRAG_MIME, RegisterKanbanBoardAutoScrollOptions, RegisterKanbanCardDragOptions, registerKanbanBoardAutoScroll, registerKanbanCardDrag } from "./drag-interactions.js";
|
|
13
13
|
import { KanbanSubgroupBandHeaderContext, KanbanSubgroupBoard, KanbanSubgroupBoardProps, KanbanSubgroupCellContext, KanbanSubgroupCollapsedBandCellContext, KanbanSubgroupColumnHeaderContext, KanbanSubgroupLaneIdentityContext } from "./subgroup-board.js";
|
|
14
14
|
import { KANBAN_BAND_PEEK_DELAY_MS, KANBAN_BAND_PEEK_LINGER_MS } from "./band-peek.js";
|
|
15
15
|
import { KANBAN_VIRTUAL_CELL_PAGINATION, KanbanVirtualCell, KanbanVirtualCellPagination, KanbanVirtualCellProps, KanbanVirtualCellSortableContext } from "./virtual-cell.js";
|
|
16
|
-
export { type BuildKanbanBoardMatrixParams, type CreateKanbanDropIntentParams, KANBAN_BAND_PEEK_DELAY_MS, KANBAN_BAND_PEEK_LINGER_MS, KANBAN_BOARD_AUTO_SCROLL_OPTIONS, KANBAN_BOARD_AUTO_SCROLL_SOURCES, KANBAN_BOARD_AXES, KANBAN_BOARD_COLLISION_DETECTION, KANBAN_COLLAPSED_BAND_WIDTH_CLASS, KANBAN_COLLAPSED_BAND_WIDTH_PX, KANBAN_COLUMN_GAP_PX, KANBAN_COLUMN_WIDTH_CLASS, KANBAN_COLUMN_WIDTH_PX, KANBAN_DIRECTIONS, KANBAN_DRAG_OVERLAY_Z_INDEX, KANBAN_HORIZONTAL_EDGES, KANBAN_MOUSE_ACTIVATION_DISTANCE, KANBAN_SORTABLE_ACTIVATION_MODES, KANBAN_TOUCH_ACTIVATION_CONSTRAINT, KANBAN_VIRTUAL_CELL_PAGINATION, type KanbanBandToggleActivation, type KanbanBoardAxis, type KanbanBoardCell, type KanbanBoardColumn, type KanbanBoardCoordinate, type KanbanBoardDestination, type KanbanBoardLane, type KanbanBoardMatrix, type KanbanBuiltInGroup, KanbanCardDragSurface, type KanbanCardDragSurfaceProps, type KanbanCardFieldSelection, KanbanCardShell, type KanbanCardShellProps, KanbanCellAction, type KanbanCellActionProps, type KanbanCellVirtualNavigation, type KanbanColumnBand, KanbanColumnBandHeader, type KanbanColumnBandHeaderProps, type KanbanColumnBandSpan, KanbanColumnHeader, type KanbanColumnHeaderProps, type KanbanDirection, type KanbanDragCancelEvent, type KanbanDragEndEvent, KanbanDragHandle, type KanbanDragHandleProps, type KanbanDragOverEvent, type KanbanDragStartEvent, type KanbanDropAxisChange, type KanbanDropIntent, type KanbanGroup, type KanbanGroupOption, type KanbanGrouping, type KanbanHorizontalEdge, type KanbanSchema, type KanbanSortableActivationMode, type KanbanSortableBindings, KanbanSortableBoard, type KanbanSortableBoardProps, type KanbanSortableCellPosition, KanbanSortableColumns, type KanbanSortableColumnsProps, KanbanSortableList, type KanbanSortableListProps, type KanbanSubgroupBandHeaderContext, KanbanSubgroupBoard, type KanbanSubgroupBoardProps, type KanbanSubgroupCellContext, type KanbanSubgroupCollapsedBandCellContext, type KanbanSubgroupColumnHeaderContext, type KanbanSubgroupLaneIdentityContext, KanbanVirtualCell, type KanbanVirtualCellPagination, type KanbanVirtualCellProps, type KanbanVirtualCellSortableContext, type KanbanVirtualScrollRequest, type OrderKanbanCellsByColumnsParams, type RegisterKanbanBoardAutoScrollOptions, type RegisterKanbanCardDragOptions, type ResolveKanbanGroupValueParams, type ResolveKanbanGroupingParams, type UseKanbanDropTargetOptions, type UseKanbanSortableOptions, buildKanbanBoardMatrix, createKanbanDropIntent, getKanbanBoardColumnIdentity, getKanbanBoardLaneIdentity, getKanbanGroupingPropertyId, getKanbanGroups, getKanbanHorizontalEdge, hasKanbanColumnBands, isKanbanGroupingRenderable, kanbanKeyboardCoordinates, orderKanbanCellsByColumns, registerKanbanBoardAutoScroll, registerKanbanCardDrag, resolveKanbanColumnBands, resolveKanbanGroupOptions, resolveKanbanGrouping, selectKanbanCardFieldIds, selectKanbanRows, useKanbanDropTarget, useKanbanSortable, useKanbanSortableSensors };
|
|
16
|
+
export { type BuildKanbanBoardMatrixParams, type CreateKanbanDropIntentParams, KANBAN_BAND_PEEK_DELAY_MS, KANBAN_BAND_PEEK_LINGER_MS, KANBAN_BOARD_AUTO_SCROLL_OPTIONS, KANBAN_BOARD_AUTO_SCROLL_SOURCES, KANBAN_BOARD_AXES, KANBAN_BOARD_COLLISION_DETECTION, KANBAN_CARD_DRAG_MIME, KANBAN_COLLAPSED_BAND_WIDTH_CLASS, KANBAN_COLLAPSED_BAND_WIDTH_PX, KANBAN_COLUMN_GAP_PX, KANBAN_COLUMN_WIDTH_CLASS, KANBAN_COLUMN_WIDTH_PX, KANBAN_DIRECTIONS, KANBAN_DRAG_OVERLAY_Z_INDEX, KANBAN_HORIZONTAL_EDGES, KANBAN_MOUSE_ACTIVATION_DISTANCE, KANBAN_SORTABLE_ACTIVATION_MODES, KANBAN_TOUCH_ACTIVATION_CONSTRAINT, KANBAN_VIRTUAL_CELL_PAGINATION, type KanbanBandToggleActivation, type KanbanBoardAxis, type KanbanBoardCell, type KanbanBoardColumn, type KanbanBoardCoordinate, type KanbanBoardDestination, type KanbanBoardLane, type KanbanBoardMatrix, type KanbanBuiltInGroup, KanbanCardDragSurface, type KanbanCardDragSurfaceProps, type KanbanCardFieldSelection, KanbanCardShell, type KanbanCardShellProps, KanbanCellAction, type KanbanCellActionProps, type KanbanCellVirtualNavigation, type KanbanColumnBand, KanbanColumnBandHeader, type KanbanColumnBandHeaderProps, type KanbanColumnBandSpan, KanbanColumnHeader, type KanbanColumnHeaderProps, type KanbanDirection, type KanbanDragCancelEvent, type KanbanDragEndEvent, KanbanDragHandle, type KanbanDragHandleProps, type KanbanDragOverEvent, type KanbanDragStartEvent, type KanbanDropAxisChange, type KanbanDropIntent, type KanbanGroup, type KanbanGroupOption, type KanbanGrouping, type KanbanHorizontalEdge, type KanbanSchema, type KanbanSortableActivationMode, type KanbanSortableBindings, KanbanSortableBoard, type KanbanSortableBoardProps, type KanbanSortableCellPosition, KanbanSortableColumns, type KanbanSortableColumnsProps, KanbanSortableList, type KanbanSortableListProps, type KanbanSubgroupBandHeaderContext, KanbanSubgroupBoard, type KanbanSubgroupBoardProps, type KanbanSubgroupCellContext, type KanbanSubgroupCollapsedBandCellContext, type KanbanSubgroupColumnHeaderContext, type KanbanSubgroupLaneIdentityContext, KanbanVirtualCell, type KanbanVirtualCellPagination, type KanbanVirtualCellProps, type KanbanVirtualCellSortableContext, type KanbanVirtualScrollRequest, type OrderKanbanCellsByColumnsParams, type RegisterKanbanBoardAutoScrollOptions, type RegisterKanbanCardDragOptions, type ResolveKanbanGroupValueParams, type ResolveKanbanGroupingParams, type UseKanbanDropTargetOptions, type UseKanbanSortableOptions, buildKanbanBoardMatrix, createKanbanDropIntent, getKanbanBoardColumnIdentity, getKanbanBoardLaneIdentity, getKanbanGroupingPropertyId, getKanbanGroups, getKanbanHorizontalEdge, hasKanbanColumnBands, isKanbanGroupingRenderable, kanbanKeyboardCoordinates, orderKanbanCellsByColumns, registerKanbanBoardAutoScroll, registerKanbanCardDrag, resolveKanbanColumnBands, resolveKanbanGroupOptions, resolveKanbanGrouping, selectKanbanCardFieldIds, selectKanbanRows, useKanbanDropTarget, useKanbanSortable, useKanbanSortableSensors };
|
package/dist/kanban/index.js
CHANGED
|
@@ -9,8 +9,8 @@ import { KanbanColumnHeader } from "./column-header.js";
|
|
|
9
9
|
import { KANBAN_BOARD_COLLISION_DETECTION, kanbanKeyboardCoordinates } from "./sortable-interactions.logic.js";
|
|
10
10
|
import { KANBAN_BOARD_AUTO_SCROLL_OPTIONS, KANBAN_DRAG_OVERLAY_Z_INDEX, KANBAN_MOUSE_ACTIVATION_DISTANCE, KANBAN_SORTABLE_ACTIVATION_MODES, KANBAN_TOUCH_ACTIVATION_CONSTRAINT, KanbanCardDragSurface, KanbanDragHandle, KanbanSortableBoard, KanbanSortableColumns, KanbanSortableList, useKanbanDropTarget, useKanbanSortable, useKanbanSortableSensors } from "./sortable-interactions.js";
|
|
11
11
|
import { KANBAN_DIRECTIONS, KANBAN_HORIZONTAL_EDGES, getKanbanHorizontalEdge } from "./sortable-edge.js";
|
|
12
|
-
import { KANBAN_BOARD_AUTO_SCROLL_SOURCES, registerKanbanBoardAutoScroll, registerKanbanCardDrag } from "./drag-interactions.js";
|
|
12
|
+
import { KANBAN_BOARD_AUTO_SCROLL_SOURCES, KANBAN_CARD_DRAG_MIME, registerKanbanBoardAutoScroll, registerKanbanCardDrag } from "./drag-interactions.js";
|
|
13
13
|
import { KANBAN_BAND_PEEK_DELAY_MS, KANBAN_BAND_PEEK_LINGER_MS } from "./band-peek.js";
|
|
14
14
|
import { KanbanSubgroupBoard } from "./subgroup-board.js";
|
|
15
15
|
import { KANBAN_VIRTUAL_CELL_PAGINATION, KanbanVirtualCell } from "./virtual-cell.js";
|
|
16
|
-
export { KANBAN_BAND_PEEK_DELAY_MS, KANBAN_BAND_PEEK_LINGER_MS, KANBAN_BOARD_AUTO_SCROLL_OPTIONS, KANBAN_BOARD_AUTO_SCROLL_SOURCES, KANBAN_BOARD_AXES, KANBAN_BOARD_COLLISION_DETECTION, KANBAN_COLLAPSED_BAND_WIDTH_CLASS, KANBAN_COLLAPSED_BAND_WIDTH_PX, KANBAN_COLUMN_GAP_PX, KANBAN_COLUMN_WIDTH_CLASS, KANBAN_COLUMN_WIDTH_PX, KANBAN_DIRECTIONS, KANBAN_DRAG_OVERLAY_Z_INDEX, KANBAN_HORIZONTAL_EDGES, KANBAN_MOUSE_ACTIVATION_DISTANCE, KANBAN_SORTABLE_ACTIVATION_MODES, KANBAN_TOUCH_ACTIVATION_CONSTRAINT, KANBAN_VIRTUAL_CELL_PAGINATION, KanbanCardDragSurface, KanbanCardShell, KanbanCellAction, KanbanColumnBandHeader, KanbanColumnHeader, KanbanDragHandle, KanbanSortableBoard, KanbanSortableColumns, KanbanSortableList, KanbanSubgroupBoard, KanbanVirtualCell, buildKanbanBoardMatrix, createKanbanDropIntent, getKanbanBoardColumnIdentity, getKanbanBoardLaneIdentity, getKanbanGroupingPropertyId, getKanbanGroups, getKanbanHorizontalEdge, hasKanbanColumnBands, isKanbanGroupingRenderable, kanbanKeyboardCoordinates, orderKanbanCellsByColumns, registerKanbanBoardAutoScroll, registerKanbanCardDrag, resolveKanbanColumnBands, resolveKanbanGroupOptions, resolveKanbanGrouping, selectKanbanCardFieldIds, selectKanbanRows, useKanbanDropTarget, useKanbanSortable, useKanbanSortableSensors };
|
|
16
|
+
export { KANBAN_BAND_PEEK_DELAY_MS, KANBAN_BAND_PEEK_LINGER_MS, KANBAN_BOARD_AUTO_SCROLL_OPTIONS, KANBAN_BOARD_AUTO_SCROLL_SOURCES, KANBAN_BOARD_AXES, KANBAN_BOARD_COLLISION_DETECTION, KANBAN_CARD_DRAG_MIME, KANBAN_COLLAPSED_BAND_WIDTH_CLASS, KANBAN_COLLAPSED_BAND_WIDTH_PX, KANBAN_COLUMN_GAP_PX, KANBAN_COLUMN_WIDTH_CLASS, KANBAN_COLUMN_WIDTH_PX, KANBAN_DIRECTIONS, KANBAN_DRAG_OVERLAY_Z_INDEX, KANBAN_HORIZONTAL_EDGES, KANBAN_MOUSE_ACTIVATION_DISTANCE, KANBAN_SORTABLE_ACTIVATION_MODES, KANBAN_TOUCH_ACTIVATION_CONSTRAINT, KANBAN_VIRTUAL_CELL_PAGINATION, KanbanCardDragSurface, KanbanCardShell, KanbanCellAction, KanbanColumnBandHeader, KanbanColumnHeader, KanbanDragHandle, KanbanSortableBoard, KanbanSortableColumns, KanbanSortableList, KanbanSubgroupBoard, KanbanVirtualCell, buildKanbanBoardMatrix, createKanbanDropIntent, getKanbanBoardColumnIdentity, getKanbanBoardLaneIdentity, getKanbanGroupingPropertyId, getKanbanGroups, getKanbanHorizontalEdge, hasKanbanColumnBands, isKanbanGroupingRenderable, kanbanKeyboardCoordinates, orderKanbanCellsByColumns, registerKanbanBoardAutoScroll, registerKanbanCardDrag, resolveKanbanColumnBands, resolveKanbanGroupOptions, resolveKanbanGrouping, selectKanbanCardFieldIds, selectKanbanRows, useKanbanDropTarget, useKanbanSortable, useKanbanSortableSensors };
|
|
@@ -40,7 +40,19 @@ type KanbanSortableBoardProps = {
|
|
|
40
40
|
sensors?: DndContextProps["sensors"] | undefined;
|
|
41
41
|
/** Overrides dnd-kit's screen-reader announcements when supplied. */
|
|
42
42
|
accessibility?: DndContextProps["accessibility"] | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Fires on drag start and on every drag end or cancel; a board over a
|
|
45
|
+
* `KanbanSubgroupBoard` combines the two into that board's `isDragging`
|
|
46
|
+
* (`true` here, `false` on `onDragEnd`/`onDragCancel`).
|
|
47
|
+
*/
|
|
43
48
|
onDragStart?: ((event: KanbanDragStartEvent) => void) | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Fires whenever dnd-kit's collision detection changes the drop target
|
|
51
|
+
* the drag is over, `event.over` included when it becomes none. A board
|
|
52
|
+
* over a `KanbanSubgroupBoard` maps `event.over?.id ?? null` to a band id
|
|
53
|
+
* (via `KanbanSubgroupCellContext.band`, or a droppable registered for a
|
|
54
|
+
* folded band's slot) to drive that board's `dragOverBandId`.
|
|
55
|
+
*/
|
|
44
56
|
onDragOver?: ((event: KanbanDragOverEvent) => void) | undefined;
|
|
45
57
|
onDragCancel?: ((event: KanbanDragCancelEvent) => void) | undefined;
|
|
46
58
|
/** Called once mounted child drop targets can safely receive input. */
|
|
@@ -16,6 +16,12 @@ type KanbanSubgroupCellContext<TRow> = {
|
|
|
16
16
|
/** Number of rows in this lane/column intersection, including zero. */
|
|
17
17
|
count: number;
|
|
18
18
|
laneValue: string | null;
|
|
19
|
+
/**
|
|
20
|
+
* The band this cell's column belongs to, or `null` outside any band. Lets
|
|
21
|
+
* a host that drives its own drag-and-drop (see `dragOverBandId` on the
|
|
22
|
+
* board) map a cell's droppable id back to the band it should report.
|
|
23
|
+
*/
|
|
24
|
+
band: KanbanColumnBand | null;
|
|
19
25
|
};
|
|
20
26
|
type KanbanSubgroupBandHeaderContext = {
|
|
21
27
|
band: KanbanColumnBand;
|
|
@@ -31,9 +37,9 @@ type KanbanSubgroupBandHeaderContext = {
|
|
|
31
37
|
*/
|
|
32
38
|
folded: boolean;
|
|
33
39
|
/**
|
|
34
|
-
* A custom caption
|
|
35
|
-
*
|
|
36
|
-
*
|
|
40
|
+
* A custom caption may report which way it was activated (pointer vs.
|
|
41
|
+
* keyboard); the board itself has no use for the distinction and passes
|
|
42
|
+
* it through unread, purely as information for a host's own header.
|
|
37
43
|
*/
|
|
38
44
|
onCollapsedChange: (collapsed: boolean, activation?: KanbanBandToggleActivation) => void;
|
|
39
45
|
};
|
|
@@ -82,6 +88,27 @@ type KanbanSubgroupBoardProps<TRow> = {
|
|
|
82
88
|
formatCount?: ((count: number) => ReactNode) | undefined;
|
|
83
89
|
footer?: ReactNode;
|
|
84
90
|
className?: string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* The band whose folded slot (or, for a peeked band, whose open part) the
|
|
93
|
+
* host's own drag is currently over, or `null` when it is over neither.
|
|
94
|
+
* Omit (`undefined`) when the host does not drive drags itself — the
|
|
95
|
+
* board's native `dragover`/`dragenter`/`dragleave` listeners already feed
|
|
96
|
+
* the peek controller in that case. A host drives its own drag when it
|
|
97
|
+
* builds the drop targets itself (for example a `KanbanSortableBoard`,
|
|
98
|
+
* whose `onDragOver` reports the active `over` droppable); it maps that
|
|
99
|
+
* droppable back to a band id — a folded cell's context and an open
|
|
100
|
+
* cell's context (see `KanbanSubgroupCellContext.band`) both carry the
|
|
101
|
+
* band — and passes it here. The controller treats "over the band" as
|
|
102
|
+
* entering the open band when it is already peeked, and as hovering its
|
|
103
|
+
* folded slot otherwise; leaving it is reported the same way.
|
|
104
|
+
*/
|
|
105
|
+
dragOverBandId?: string | null | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Whether the host's own drag (see `dragOverBandId`) is in progress.
|
|
108
|
+
* Flipping to `false` ends any peek immediately, mirroring the native
|
|
109
|
+
* `dragend`/`drop` listeners the board installs for its own drags.
|
|
110
|
+
*/
|
|
111
|
+
isDragging?: boolean | undefined;
|
|
85
112
|
} & KanbanSubgroupCollapseControl;
|
|
86
113
|
/**
|
|
87
114
|
* Reusable swimlane layout over the canonical two-axis Kanban matrix.
|
|
@@ -89,12 +116,12 @@ type KanbanSubgroupBoardProps<TRow> = {
|
|
|
89
116
|
* Columns that carry band metadata render under a one-line band caption and
|
|
90
117
|
* can be collapsed as a run: the band folds into one narrow slot in every
|
|
91
118
|
* row, whose cells stay reachable (a host renders its drop target in them),
|
|
92
|
-
* and peeks open while a
|
|
93
|
-
* specific column inside. Every row is laid out span by span with the same
|
|
119
|
+
* and peeks open while a dragged card rests on it, so a drag can still land
|
|
120
|
+
* on a specific column inside; a plain hover never opens it. Every row is laid out span by span with the same
|
|
94
121
|
* widths, which is what keeps captions, headers, counts, and cells aligned
|
|
95
122
|
* in every state; the caption line never grows past its own height, so a
|
|
96
123
|
* folded band costs no vertical space.
|
|
97
124
|
*/
|
|
98
|
-
declare const KanbanSubgroupBoard: <TRow>({ matrix, renderColumnHeader, renderLaneIdentity, renderCell, renderBandHeader, renderCollapsedBandCell, formatBandToggleLabel, formatCount, isLaneCollapsed, onLaneCollapsedChange, isBandCollapsed, onBandCollapsedChange, footer, className }: KanbanSubgroupBoardProps<TRow>) => import("react").JSX.Element;
|
|
125
|
+
declare const KanbanSubgroupBoard: <TRow>({ matrix, renderColumnHeader, renderLaneIdentity, renderCell, renderBandHeader, renderCollapsedBandCell, formatBandToggleLabel, formatCount, isLaneCollapsed, onLaneCollapsedChange, isBandCollapsed, onBandCollapsedChange, footer, className, dragOverBandId, isDragging }: KanbanSubgroupBoardProps<TRow>) => import("react").JSX.Element;
|
|
99
126
|
//#endregion
|
|
100
127
|
export { KanbanSubgroupBandHeaderContext, KanbanSubgroupBoard, KanbanSubgroupBoardProps, KanbanSubgroupCellContext, KanbanSubgroupCollapsedBandCellContext, KanbanSubgroupColumnHeaderContext, KanbanSubgroupLaneIdentityContext };
|
|
@@ -2,10 +2,11 @@ import { cn } from "../lib/utils.js";
|
|
|
2
2
|
import { DirectionalIcon } from "../components/directional-icon.js";
|
|
3
3
|
import { KanbanColumnBandHeader } from "./column-band-header.js";
|
|
4
4
|
import { KANBAN_COLLAPSED_BAND_WIDTH_CLASS, KANBAN_COLUMN_WIDTH_CLASS, resolveKanbanColumnBands } from "./column-bands.js";
|
|
5
|
+
import { KANBAN_CARD_DRAG_MIME } from "./drag-interactions.js";
|
|
5
6
|
import { createBandPeekController } from "./band-peek.js";
|
|
6
7
|
import { ChevronDownIcon } from "lucide-react";
|
|
7
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { useEffect, useMemo, useState } from "react";
|
|
9
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
9
10
|
//#region src/kanban/subgroup-board.tsx
|
|
10
11
|
const groupValueKey = (value) => value === null ? "null" : `value:${value.length}:${value}`;
|
|
11
12
|
const columnKey = (column) => column.type === "group" ? `group:${groupValueKey(column.group.value)}` : `destination:${column.destination.id}`;
|
|
@@ -17,19 +18,48 @@ const rowsIn = (cells) => cells.reduce((sum, cell) => sum + cell.rows.length, 0)
|
|
|
17
18
|
* Columns that carry band metadata render under a one-line band caption and
|
|
18
19
|
* can be collapsed as a run: the band folds into one narrow slot in every
|
|
19
20
|
* row, whose cells stay reachable (a host renders its drop target in them),
|
|
20
|
-
* and peeks open while a
|
|
21
|
-
* specific column inside. Every row is laid out span by span with the same
|
|
21
|
+
* and peeks open while a dragged card rests on it, so a drag can still land
|
|
22
|
+
* on a specific column inside; a plain hover never opens it. Every row is laid out span by span with the same
|
|
22
23
|
* widths, which is what keeps captions, headers, counts, and cells aligned
|
|
23
24
|
* in every state; the caption line never grows past its own height, so a
|
|
24
25
|
* folded band costs no vertical space.
|
|
25
26
|
*/
|
|
26
|
-
const KanbanSubgroupBoard = ({ matrix, renderColumnHeader, renderLaneIdentity, renderCell, renderBandHeader, renderCollapsedBandCell, formatBandToggleLabel, formatCount = String, isLaneCollapsed, onLaneCollapsedChange, isBandCollapsed, onBandCollapsedChange, footer, className }) => {
|
|
27
|
+
const KanbanSubgroupBoard = ({ matrix, renderColumnHeader, renderLaneIdentity, renderCell, renderBandHeader, renderCollapsedBandCell, formatBandToggleLabel, formatCount = String, isLaneCollapsed, onLaneCollapsedChange, isBandCollapsed, onBandCollapsedChange, footer, className, dragOverBandId, isDragging }) => {
|
|
27
28
|
const [collapsedLaneValues, setCollapsedLaneValues] = useState(() => /* @__PURE__ */ new Set());
|
|
28
29
|
const [expandedEmptyLaneValues, setExpandedEmptyLaneValues] = useState(() => /* @__PURE__ */ new Set());
|
|
29
30
|
const [collapsedBandIds, setCollapsedBandIds] = useState(() => /* @__PURE__ */ new Set());
|
|
30
31
|
const [peekingBandId, setPeekingBandId] = useState(null);
|
|
31
32
|
const [peek] = useState(() => createBandPeekController({ onChange: setPeekingBandId }));
|
|
32
33
|
useEffect(() => () => peek.dispose(), [peek]);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const end = () => peek.dragEnded();
|
|
36
|
+
window.addEventListener("dragend", end);
|
|
37
|
+
window.addEventListener("drop", end);
|
|
38
|
+
return () => {
|
|
39
|
+
window.removeEventListener("dragend", end);
|
|
40
|
+
window.removeEventListener("drop", end);
|
|
41
|
+
};
|
|
42
|
+
}, [peek]);
|
|
43
|
+
const previousDragOverBandId = useRef(null);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (dragOverBandId === void 0 || dragOverBandId === previousDragOverBandId.current) return;
|
|
46
|
+
const previous = previousDragOverBandId.current;
|
|
47
|
+
previousDragOverBandId.current = dragOverBandId;
|
|
48
|
+
if (previous !== null) if (peekingBandId === previous) peek.openDragLeave(previous);
|
|
49
|
+
else peek.slotDragLeave(previous);
|
|
50
|
+
if (dragOverBandId !== null) if (peekingBandId === dragOverBandId) peek.openDragEnter(dragOverBandId);
|
|
51
|
+
else peek.slotDragOver(dragOverBandId);
|
|
52
|
+
}, [
|
|
53
|
+
dragOverBandId,
|
|
54
|
+
peek,
|
|
55
|
+
peekingBandId
|
|
56
|
+
]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (isDragging === false) {
|
|
59
|
+
previousDragOverBandId.current = null;
|
|
60
|
+
peek.dragEnded();
|
|
61
|
+
}
|
|
62
|
+
}, [isDragging, peek]);
|
|
33
63
|
const { cellsByLaneValue, countByColumnValue, ungroupedCells } = useMemo(() => {
|
|
34
64
|
const laneCells = /* @__PURE__ */ new Map();
|
|
35
65
|
const columnCounts = /* @__PURE__ */ new Map();
|
|
@@ -89,11 +119,9 @@ const KanbanSubgroupBoard = ({ matrix, renderColumnHeader, renderLaneIdentity, r
|
|
|
89
119
|
useEffect(() => {
|
|
90
120
|
if (staleBandId !== null) peek.bandExpanded(staleBandId);
|
|
91
121
|
}, [peek, staleBandId]);
|
|
92
|
-
const setBandCollapsed = (band, collapsed
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
else if (viaPointer) peek.foldedUnderPointer(band.id);
|
|
96
|
-
else peek.bandFolded(band.id);
|
|
122
|
+
const setBandCollapsed = (band, collapsed) => {
|
|
123
|
+
if (collapsed) peek.bandFolded(band.id);
|
|
124
|
+
else peek.bandExpanded(band.id);
|
|
97
125
|
if (onBandCollapsedChange) {
|
|
98
126
|
onBandCollapsedChange(band, collapsed);
|
|
99
127
|
return;
|
|
@@ -126,11 +154,15 @@ const KanbanSubgroupBoard = ({ matrix, renderColumnHeader, renderLaneIdentity, r
|
|
|
126
154
|
return /* @__PURE__ */ jsx("div", {
|
|
127
155
|
className: "flex gap-3",
|
|
128
156
|
"data-kanban-band": band?.id,
|
|
129
|
-
|
|
130
|
-
|
|
157
|
+
onDragEnter: band === null ? void 0 : (event) => {
|
|
158
|
+
if (isKanbanCardDragEvent(event)) peek.openDragEnter(band.id);
|
|
159
|
+
},
|
|
160
|
+
onDragLeave: band === null ? void 0 : (event) => {
|
|
161
|
+
if (leavesElement(event) && isKanbanCardDragEvent(event)) peek.openDragLeave(band.id);
|
|
162
|
+
},
|
|
131
163
|
children: span.columns.map((column) => /* @__PURE__ */ jsx("div", {
|
|
132
164
|
className: KANBAN_COLUMN_WIDTH_CLASS,
|
|
133
|
-
children: renderColumn(column)
|
|
165
|
+
children: renderColumn(column, band)
|
|
134
166
|
}, columnKey(column)))
|
|
135
167
|
}, spanKey(span));
|
|
136
168
|
})
|
|
@@ -144,7 +176,7 @@ const KanbanSubgroupBoard = ({ matrix, renderColumnHeader, renderLaneIdentity, r
|
|
|
144
176
|
columns: span.columns,
|
|
145
177
|
count: span.columns.reduce((sum, column) => sum + columnCount(column), 0),
|
|
146
178
|
folded,
|
|
147
|
-
onCollapsedChange: (next
|
|
179
|
+
onCollapsedChange: (next) => setBandCollapsed(band, next)
|
|
148
180
|
};
|
|
149
181
|
if (renderBandHeader) return /* @__PURE__ */ jsx(Fragment, { children: renderBandHeader(context) });
|
|
150
182
|
return /* @__PURE__ */ jsx(KanbanColumnBandHeader, {
|
|
@@ -214,8 +246,12 @@ const KanbanSubgroupBoard = ({ matrix, renderColumnHeader, renderLaneIdentity, r
|
|
|
214
246
|
className: "border-border/60 shrink-0 border-b",
|
|
215
247
|
"data-kanban-band": band.id,
|
|
216
248
|
style: { width: `${String(spanWidth(span))}px` },
|
|
217
|
-
|
|
218
|
-
|
|
249
|
+
onDragEnter: (event) => {
|
|
250
|
+
if (isKanbanCardDragEvent(event)) peek.openDragEnter(band.id);
|
|
251
|
+
},
|
|
252
|
+
onDragLeave: (event) => {
|
|
253
|
+
if (leavesElement(event) && isKanbanCardDragEvent(event)) peek.openDragLeave(band.id);
|
|
254
|
+
},
|
|
219
255
|
children: bandHeader(band, span)
|
|
220
256
|
}, spanKey(span));
|
|
221
257
|
})
|
|
@@ -229,9 +265,10 @@ const KanbanSubgroupBoard = ({ matrix, renderColumnHeader, renderLaneIdentity, r
|
|
|
229
265
|
}),
|
|
230
266
|
ungroupedCells.length === 0 ? null : renderRow({
|
|
231
267
|
className: "pb-1",
|
|
232
|
-
renderColumn: (column) => {
|
|
268
|
+
renderColumn: (column, band) => {
|
|
233
269
|
const cell = ungroupedCells.find((candidate) => columnKey(candidate.coordinate.column) === columnKey(column));
|
|
234
270
|
return cell === void 0 ? null : /* @__PURE__ */ jsx(Fragment, { children: renderCell({
|
|
271
|
+
band,
|
|
235
272
|
cell,
|
|
236
273
|
count: cell.rows.length,
|
|
237
274
|
laneValue: null
|
|
@@ -291,9 +328,10 @@ const KanbanSubgroupBoard = ({ matrix, renderColumnHeader, renderLaneIdentity, r
|
|
|
291
328
|
}),
|
|
292
329
|
!collapsed && renderRow({
|
|
293
330
|
className: "pb-1",
|
|
294
|
-
renderColumn: (column) => {
|
|
331
|
+
renderColumn: (column, band) => {
|
|
295
332
|
const cell = cellFor(column);
|
|
296
333
|
return cell === void 0 ? null : /* @__PURE__ */ jsx(Fragment, { children: renderCell({
|
|
334
|
+
band,
|
|
297
335
|
cell,
|
|
298
336
|
count: cell.rows.length,
|
|
299
337
|
laneValue: group.value
|
|
@@ -310,9 +348,20 @@ const KanbanSubgroupBoard = ({ matrix, renderColumnHeader, renderLaneIdentity, r
|
|
|
310
348
|
});
|
|
311
349
|
};
|
|
312
350
|
/**
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
|
|
351
|
+
* Whether a drag-leave event actually leaves `currentTarget` rather than
|
|
352
|
+
* moving between its descendants, which fire leave/enter pairs of their own.
|
|
353
|
+
*/
|
|
354
|
+
const leavesElement = (event) => !(event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget));
|
|
355
|
+
/**
|
|
356
|
+
* Whether a native drag event is a kanban card drag, rather than some other
|
|
357
|
+
* native drag (a column reorder, a file, text) passing over the board. Only
|
|
358
|
+
* a card drag should ever open or hold a band's peek.
|
|
359
|
+
*/
|
|
360
|
+
const isKanbanCardDragEvent = (event) => event.dataTransfer.types.includes(KANBAN_CARD_DRAG_MIME);
|
|
361
|
+
/**
|
|
362
|
+
* The narrow slot a folded band occupies in a row. Its drag events go to
|
|
363
|
+
* the board's peek controller, which decides when a resting drag peeks the
|
|
364
|
+
* band open.
|
|
316
365
|
*/
|
|
317
366
|
const FoldedBandSlot = ({ band, children, className, peek }) => {
|
|
318
367
|
useEffect(() => () => peek.slotUnmounted(band.id), [peek, band.id]);
|
|
@@ -320,8 +369,12 @@ const FoldedBandSlot = ({ band, children, className, peek }) => {
|
|
|
320
369
|
className,
|
|
321
370
|
"data-kanban-band": band.id,
|
|
322
371
|
"data-kanban-band-collapsed": "",
|
|
323
|
-
|
|
324
|
-
|
|
372
|
+
onDragOver: (event) => {
|
|
373
|
+
if (isKanbanCardDragEvent(event)) peek.slotDragOver(band.id);
|
|
374
|
+
},
|
|
375
|
+
onDragLeave: (event) => {
|
|
376
|
+
if (leavesElement(event) && isKanbanCardDragEvent(event)) peek.slotDragLeave(band.id);
|
|
377
|
+
},
|
|
325
378
|
children
|
|
326
379
|
});
|
|
327
380
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OptionColor } from "../lib/option-color.js";
|
|
1
2
|
import { UseKanbanDropTargetOptions } from "./sortable-interactions.js";
|
|
2
3
|
import { Key, ReactNode, RefObject } from "react";
|
|
3
4
|
import { UniqueIdentifier } from "@dnd-kit/core";
|
|
@@ -38,6 +39,14 @@ type KanbanVirtualCellProps<TRow> = {
|
|
|
38
39
|
containerRef?: RefObject<HTMLDivElement | null> | undefined;
|
|
39
40
|
active?: boolean | undefined;
|
|
40
41
|
backgroundColor?: string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Optional colour identity for the cell surface: a faint resting tint at
|
|
44
|
+
* the same alpha as `option-color`'s own subtle background, with a
|
|
45
|
+
* stronger accent-coloured wash and ring while `active` is also set. Omit
|
|
46
|
+
* for the plain neutral surface; `backgroundColor` still wins outright
|
|
47
|
+
* when both are given, since that prop is the caller's explicit override.
|
|
48
|
+
*/
|
|
49
|
+
accent?: OptionColor | undefined;
|
|
41
50
|
footer?: ReactNode;
|
|
42
51
|
estimateSize?: number | undefined;
|
|
43
52
|
overscan?: number | undefined;
|
|
@@ -45,6 +54,6 @@ type KanbanVirtualCellProps<TRow> = {
|
|
|
45
54
|
className?: string | undefined;
|
|
46
55
|
};
|
|
47
56
|
/** Bounded, virtualized Kanban cell with cursor-page request deduplication. */
|
|
48
|
-
declare const KanbanVirtualCell: <TRow>({ rows, getRowKey, renderRow, pagination, sortable, containerRef, active, backgroundColor, footer, estimateSize, overscan, loadMoreThreshold, className }: KanbanVirtualCellProps<TRow>) => import("react").JSX.Element;
|
|
57
|
+
declare const KanbanVirtualCell: <TRow>({ rows, getRowKey, renderRow, pagination, sortable, containerRef, active, backgroundColor, accent, footer, estimateSize, overscan, loadMoreThreshold, className }: KanbanVirtualCellProps<TRow>) => import("react").JSX.Element;
|
|
49
58
|
//#endregion
|
|
50
59
|
export { KANBAN_VIRTUAL_CELL_PAGINATION, KanbanVirtualCell, KanbanVirtualCellPagination, KanbanVirtualCellProps, KanbanVirtualCellSortableContext };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cn } from "../lib/utils.js";
|
|
2
2
|
import { useKanbanDropTarget } from "./sortable-interactions.js";
|
|
3
|
+
import { resolveOptionColor } from "../lib/option-color.js";
|
|
3
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
5
|
import { useId, useRef } from "react";
|
|
5
6
|
import { useDndContext } from "@dnd-kit/core";
|
|
@@ -9,6 +10,18 @@ import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual";
|
|
|
9
10
|
const DEFAULT_ESTIMATE_SIZE_PX = 128;
|
|
10
11
|
const DEFAULT_OVERSCAN = 8;
|
|
11
12
|
const DEFAULT_LOAD_MORE_THRESHOLD_PX = 200;
|
|
13
|
+
/** The CSS custom property every accent tint and the active accent ring are
|
|
14
|
+
* derived from, so both stay in lockstep with the resolved colour token. */
|
|
15
|
+
const KANBAN_CELL_ACCENT_VAR = "--kanban-cell-accent";
|
|
16
|
+
/** Faint resting wash: matches the alpha `option-color` already uses for its
|
|
17
|
+
* own subtle background token, so a tinted cell reads at the same weight as
|
|
18
|
+
* the swatch and badges that carry the same colour. */
|
|
19
|
+
const KANBAN_CELL_ACCENT_RESTING_ALPHA = 12;
|
|
20
|
+
/** Stronger wash while a card is dragged over an accented cell. */
|
|
21
|
+
const KANBAN_CELL_ACCENT_ACTIVE_ALPHA = 22;
|
|
22
|
+
/** Ring alpha for the active accent frame, well above the wash so the frame
|
|
23
|
+
* still reads as the drag-over affordance rather than more background tint. */
|
|
24
|
+
const KANBAN_CELL_ACCENT_ACTIVE_RING_ALPHA = 55;
|
|
12
25
|
const retainActiveSortableIndex = (range, activeIndex) => {
|
|
13
26
|
const indexes = defaultRangeExtractor(range);
|
|
14
27
|
if (activeIndex < 0 || indexes.includes(activeIndex)) return indexes;
|
|
@@ -21,7 +34,7 @@ const KANBAN_VIRTUAL_CELL_PAGINATION = {
|
|
|
21
34
|
CURSOR: "cursor"
|
|
22
35
|
};
|
|
23
36
|
/** Bounded, virtualized Kanban cell with cursor-page request deduplication. */
|
|
24
|
-
const KanbanVirtualCell = ({ rows, getRowKey, renderRow, pagination, sortable, containerRef, active = false, backgroundColor, footer, estimateSize = DEFAULT_ESTIMATE_SIZE_PX, overscan = DEFAULT_OVERSCAN, loadMoreThreshold = DEFAULT_LOAD_MORE_THRESHOLD_PX, className }) => {
|
|
37
|
+
const KanbanVirtualCell = ({ rows, getRowKey, renderRow, pagination, sortable, containerRef, active = false, backgroundColor, accent, footer, estimateSize = DEFAULT_ESTIMATE_SIZE_PX, overscan = DEFAULT_OVERSCAN, loadMoreThreshold = DEFAULT_LOAD_MORE_THRESHOLD_PX, className }) => {
|
|
25
38
|
const internalRef = useRef(null);
|
|
26
39
|
const fallbackDropTargetId = useId();
|
|
27
40
|
const scrollRef = internalRef;
|
|
@@ -69,12 +82,21 @@ const KanbanVirtualCell = ({ rows, getRowKey, renderRow, pagination, sortable, c
|
|
|
69
82
|
if (containerRef) containerRef.current = element;
|
|
70
83
|
dropTarget.setNodeRef(element);
|
|
71
84
|
};
|
|
85
|
+
const accentVariants = accent === void 0 ? void 0 : resolveOptionColor(accent);
|
|
86
|
+
const accentBackground = accentVariants === void 0 ? void 0 : `color-mix(in srgb, var(${KANBAN_CELL_ACCENT_VAR}) ${active ? KANBAN_CELL_ACCENT_ACTIVE_ALPHA : KANBAN_CELL_ACCENT_RESTING_ALPHA}%, var(--background))`;
|
|
87
|
+
const activeAccentRing = active && accentVariants !== void 0 ? `0 0 0 2px color-mix(in srgb, var(${KANBAN_CELL_ACCENT_VAR}) ${KANBAN_CELL_ACCENT_ACTIVE_RING_ALPHA}%, transparent)` : void 0;
|
|
88
|
+
const style = backgroundColor === void 0 && accentVariants === void 0 ? void 0 : {
|
|
89
|
+
backgroundColor: backgroundColor ?? accentBackground,
|
|
90
|
+
...activeAccentRing === void 0 ? void 0 : { boxShadow: activeAccentRing },
|
|
91
|
+
...accentVariants === void 0 ? void 0 : { [KANBAN_CELL_ACCENT_VAR]: accentVariants.color }
|
|
92
|
+
};
|
|
72
93
|
const content = /* @__PURE__ */ jsxs("div", {
|
|
73
|
-
className: cn("bg-muted/20 max-h-[min(60vh,40rem)] min-h-20 overflow-y-auto overscroll-y-contain rounded-xl p-2 transition-[background-color,outline-color]", active && "bg-primary/5 ring-primary/50 ring-2", className),
|
|
94
|
+
className: cn("bg-muted/20 max-h-[min(60vh,40rem)] min-h-20 overflow-y-auto overscroll-y-contain rounded-xl p-2 transition-[background-color,outline-color]", active && accentVariants === void 0 && "bg-primary/5 ring-primary/50 ring-2", className),
|
|
74
95
|
"data-kanban-cell": sortable?.dropTarget.id,
|
|
96
|
+
"data-kanban-cell-accent": accentVariants === void 0 ? void 0 : "true",
|
|
75
97
|
onScroll: handleScroll,
|
|
76
98
|
ref: setScrollElement,
|
|
77
|
-
style
|
|
99
|
+
style,
|
|
78
100
|
children: [/* @__PURE__ */ jsx("div", {
|
|
79
101
|
className: "relative",
|
|
80
102
|
style: { height: virtualizer.getTotalSize() },
|
|
@@ -5,6 +5,6 @@ declare const CONTROL_SIZE: Readonly<{
|
|
|
5
5
|
readonly lg: "lg";
|
|
6
6
|
}>;
|
|
7
7
|
type ControlSize = (typeof CONTROL_SIZE)[keyof typeof CONTROL_SIZE];
|
|
8
|
-
declare const CONTROL_SIZES: readonly ("
|
|
8
|
+
declare const CONTROL_SIZES: readonly ("sm" | "default" | "lg")[];
|
|
9
9
|
//#endregion
|
|
10
10
|
export { CONTROL_SIZE, CONTROL_SIZES, type ControlSize };
|