@umituz/web-dashboard 11.11.0 → 11.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-dashboard",
3
- "version": "11.11.0",
3
+ "version": "11.12.0",
4
4
  "description": "Installable app skeleton for the fleet — layouts, analytics (dependency-free SVG charts), calendar, onboarding flow permissions/module registry; udb-* stylesheet on design-system tokens",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -25,6 +25,10 @@
25
25
  "./calendar/utils": "./src/domains/calendar/utils/index.ts",
26
26
  "./chrome.css": "./src/styles/chrome.css",
27
27
  "./config": "./src/config/index.ts",
28
+ "./kanban": "./src/domains/kanban/index.ts",
29
+ "./kanban/kanban.css": "./src/domains/kanban/kanban.css",
30
+ "./kanban/components": "./src/domains/kanban/components/index.ts",
31
+ "./kanban/types": "./src/domains/kanban/types.ts",
28
32
  "./layouts": "./src/domains/layouts/index.ts",
29
33
  "./layouts/components": "./src/domains/layouts/components/index.ts",
30
34
  "./layouts/hooks": "./src/domains/layouts/hooks/index.ts",
@@ -0,0 +1,226 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { render, screen, fireEvent } from '@testing-library/react';
3
+ import { KanbanBoard } from './KanbanBoard';
4
+ import type { KanbanColumn, KanbanItem } from '../types';
5
+
6
+ interface TaskPayload {
7
+ priority: 'low' | 'medium' | 'high';
8
+ }
9
+
10
+ const COLUMNS: readonly KanbanColumn<TaskPayload>[] = [
11
+ { id: 'todo', title: 'To Do', tone: 'neutral' },
12
+ { id: 'in_progress', title: 'In Progress', tone: 'primary', limit: 2 },
13
+ { id: 'done', title: 'Done', tone: 'success' },
14
+ ];
15
+
16
+ const ITEMS: readonly KanbanItem<TaskPayload>[] = [
17
+ {
18
+ id: 'task-1',
19
+ columnId: 'todo',
20
+ title: 'Prepare blueprints',
21
+ description: 'Review structural schematics',
22
+ tone: 'info',
23
+ tags: [{ label: 'Arch' }],
24
+ assignee: { name: 'Alice Smith', initials: 'AS' },
25
+ meta: 'Due tomorrow',
26
+ payload: { priority: 'high' },
27
+ },
28
+ {
29
+ id: 'task-2',
30
+ columnId: 'in_progress',
31
+ title: 'Site excavation',
32
+ tone: 'warning',
33
+ payload: { priority: 'medium' },
34
+ },
35
+ ];
36
+
37
+ describe('KanbanBoard', () => {
38
+ it('renders all columns with titles and counts', () => {
39
+ render(<KanbanBoard<TaskPayload> columns={COLUMNS} items={ITEMS} />);
40
+
41
+ expect(screen.getByText('To Do')).toBeDefined();
42
+ expect(screen.getByText('In Progress')).toBeDefined();
43
+ expect(screen.getByText('Done')).toBeDefined();
44
+
45
+ expect(screen.getByText('Prepare blueprints')).toBeDefined();
46
+ expect(screen.getByText('Site excavation')).toBeDefined();
47
+ });
48
+
49
+ it('renders empty column indicator for columns without items', () => {
50
+ render(
51
+ <KanbanBoard<TaskPayload>
52
+ columns={COLUMNS}
53
+ items={ITEMS}
54
+ emptyText="No tasks here"
55
+ />,
56
+ );
57
+
58
+ expect(screen.getByText('No tasks here')).toBeDefined();
59
+ });
60
+
61
+ it('fires onSelectItem when clicking a card', () => {
62
+ const handleSelect = vi.fn();
63
+ render(
64
+ <KanbanBoard<TaskPayload>
65
+ columns={COLUMNS}
66
+ items={ITEMS}
67
+ onSelectItem={handleSelect}
68
+ />,
69
+ );
70
+
71
+ fireEvent.click(screen.getByText('Prepare blueprints'));
72
+ expect(handleSelect).toHaveBeenCalledWith(ITEMS[0]);
73
+ });
74
+
75
+ it('fires onSelectItem on Enter key press', () => {
76
+ const handleSelect = vi.fn();
77
+ render(
78
+ <KanbanBoard<TaskPayload>
79
+ columns={COLUMNS}
80
+ items={ITEMS}
81
+ onSelectItem={handleSelect}
82
+ />,
83
+ );
84
+
85
+ const card = screen.getByText('Prepare blueprints').closest('.udb-kanban-card');
86
+ expect(card).toBeTruthy();
87
+ if (card) {
88
+ fireEvent.keyDown(card, { key: 'Enter' });
89
+ expect(handleSelect).toHaveBeenCalledWith(ITEMS[0]);
90
+ }
91
+ });
92
+
93
+ it('moves item forward via stage button', () => {
94
+ const handleMove = vi.fn();
95
+ render(
96
+ <KanbanBoard<TaskPayload>
97
+ columns={COLUMNS}
98
+ items={ITEMS}
99
+ onMoveItem={handleMove}
100
+ showStageActions={true}
101
+ />,
102
+ );
103
+
104
+ const forwardBtns = screen.getAllByRole('button', { name: 'Move forward' });
105
+ const firstForward = forwardBtns[0];
106
+ expect(firstForward).toBeDefined();
107
+ if (firstForward) {
108
+ fireEvent.click(firstForward);
109
+ expect(handleMove).toHaveBeenCalledWith('task-1', 'in_progress', 'todo');
110
+ }
111
+ });
112
+
113
+ it('moves item backward via stage button', () => {
114
+ const handleMove = vi.fn();
115
+ render(
116
+ <KanbanBoard<TaskPayload>
117
+ columns={COLUMNS}
118
+ items={ITEMS}
119
+ onMoveItem={handleMove}
120
+ showStageActions={true}
121
+ />,
122
+ );
123
+
124
+ const backwardBtns = screen.getAllByRole('button', { name: 'Move backward' });
125
+ const inProgressBtn = backwardBtns.find((btn) => !btn.hasAttribute('disabled'));
126
+ expect(inProgressBtn).toBeTruthy();
127
+ if (inProgressBtn) {
128
+ fireEvent.click(inProgressBtn);
129
+ expect(handleMove).toHaveBeenCalledWith('task-2', 'todo', 'in_progress');
130
+ }
131
+ });
132
+
133
+ it('handles drag and drop between columns', () => {
134
+ const handleMove = vi.fn();
135
+ const { container } = render(
136
+ <KanbanBoard<TaskPayload>
137
+ columns={COLUMNS}
138
+ items={ITEMS}
139
+ onMoveItem={handleMove}
140
+ />,
141
+ );
142
+
143
+ const card = screen.getByText('Prepare blueprints').closest('.udb-kanban-card');
144
+ const doneCol = container.querySelector('[data-column-id="done"]');
145
+
146
+ expect(card).toBeTruthy();
147
+ expect(doneCol).toBeTruthy();
148
+
149
+ if (card && doneCol) {
150
+ const dataTransfer = {
151
+ setData: vi.fn(),
152
+ getData: vi.fn(() => 'task-1'),
153
+ effectAllowed: 'move',
154
+ dropEffect: 'move',
155
+ };
156
+
157
+ fireEvent.dragStart(card, { dataTransfer });
158
+ fireEvent.dragOver(doneCol, { dataTransfer });
159
+ fireEvent.drop(doneCol, { dataTransfer });
160
+
161
+ expect(handleMove).toHaveBeenCalledWith('task-1', 'done', 'todo');
162
+ }
163
+ });
164
+
165
+ it('prevents dropping into column where canDrop is false', () => {
166
+ const handleMove = vi.fn();
167
+ const blockedCols: readonly KanbanColumn<TaskPayload>[] = [
168
+ { id: 'todo', title: 'To Do', tone: 'neutral' },
169
+ { id: 'in_progress', title: 'In Progress', tone: 'primary' },
170
+ { id: 'done', title: 'Done', tone: 'success', canDrop: false },
171
+ ];
172
+
173
+ const { container } = render(
174
+ <KanbanBoard<TaskPayload>
175
+ columns={blockedCols}
176
+ items={ITEMS}
177
+ onMoveItem={handleMove}
178
+ />,
179
+ );
180
+
181
+ const card = screen.getByText('Prepare blueprints').closest('.udb-kanban-card');
182
+ const doneCol = container.querySelector('[data-column-id="done"]');
183
+
184
+ if (card && doneCol) {
185
+ const dataTransfer = {
186
+ setData: vi.fn(),
187
+ getData: vi.fn(() => 'task-1'),
188
+ effectAllowed: 'move',
189
+ dropEffect: 'move',
190
+ };
191
+
192
+ fireEvent.drop(doneCol, { dataTransfer });
193
+ expect(handleMove).not.toHaveBeenCalled();
194
+ }
195
+ });
196
+
197
+ it('renders custom card when renderCard is provided', () => {
198
+ render(
199
+ <KanbanBoard<TaskPayload>
200
+ columns={COLUMNS}
201
+ items={ITEMS}
202
+ renderCard={(item) => <div data-testid={`custom-${item.id}`}>Custom: {item.title}</div>}
203
+ />,
204
+ );
205
+
206
+ expect(screen.getByTestId('custom-task-1').textContent).toContain('Custom: Prepare blueprints');
207
+ });
208
+
209
+ it('indicates when column limit is exceeded', () => {
210
+ const overflowItems: readonly KanbanItem<TaskPayload>[] = [
211
+ ...ITEMS,
212
+ { id: 'task-3', columnId: 'in_progress', title: 'Task 3' },
213
+ { id: 'task-4', columnId: 'in_progress', title: 'Task 4' },
214
+ ];
215
+
216
+ render(
217
+ <KanbanBoard<TaskPayload>
218
+ columns={COLUMNS}
219
+ items={overflowItems}
220
+ />,
221
+ );
222
+
223
+ const limitPill = screen.getByText('/ 2');
224
+ expect(limitPill.className).toContain('is-exceeded');
225
+ });
226
+ });
@@ -0,0 +1,135 @@
1
+ import { useCallback, useMemo, useState, type DragEvent, type ReactNode } from 'react';
2
+ import type { KanbanBoardProps, KanbanCardActions, KanbanColumn as IKanbanColumn, KanbanItem } from '../types';
3
+ import { KanbanColumn } from './KanbanColumn';
4
+
5
+ export function KanbanBoard<T = unknown>({
6
+ columns,
7
+ items,
8
+ onMoveItem,
9
+ onSelectItem,
10
+ onColumnAction,
11
+ renderCard,
12
+ renderColumnHeader,
13
+ renderColumnFooter,
14
+ renderEmptyColumn,
15
+ showStageActions = true,
16
+ emptyText,
17
+ className,
18
+ columnClassName,
19
+ cardClassName,
20
+ }: KanbanBoardProps<T>): ReactNode {
21
+ const [draggingItemId, setDraggingItemId] = useState<string | null>(null);
22
+
23
+ const itemsByColumn = useMemo(() => {
24
+ const map = new Map<string, KanbanItem<T>[]>();
25
+ for (const col of columns) {
26
+ map.set(col.id, []);
27
+ }
28
+ for (const item of items) {
29
+ const list = map.get(item.columnId);
30
+ if (list) {
31
+ list.push(item);
32
+ } else {
33
+ map.set(item.columnId, [item]);
34
+ }
35
+ }
36
+ return map;
37
+ }, [columns, items]);
38
+
39
+ const columnIndexMap = useMemo(() => {
40
+ const map = new Map<string, number>();
41
+ columns.forEach((col, idx) => {
42
+ map.set(col.id, idx);
43
+ });
44
+ return map;
45
+ }, [columns]);
46
+
47
+ const handleDragStartCard = useCallback(
48
+ (_e: DragEvent<HTMLDivElement>, item: KanbanItem<T>) => {
49
+ setDraggingItemId(item.id);
50
+ },
51
+ [],
52
+ );
53
+
54
+ const handleDragEndCard = useCallback(() => {
55
+ setDraggingItemId(null);
56
+ }, []);
57
+
58
+ const handleDropItem = useCallback(
59
+ (targetColumnId: string, itemId: string) => {
60
+ setDraggingItemId(null);
61
+ const item = items.find((i) => i.id === itemId);
62
+ if (!item || item.columnId === targetColumnId) {
63
+ return;
64
+ }
65
+ const targetColumn = columns.find((c) => c.id === targetColumnId);
66
+ if (targetColumn) {
67
+ if (targetColumn.canDrop === false) {
68
+ return;
69
+ }
70
+ if (typeof targetColumn.canDrop === 'function' && !targetColumn.canDrop(item)) {
71
+ return;
72
+ }
73
+ }
74
+ onMoveItem?.(itemId, targetColumnId, item.columnId);
75
+ },
76
+ [columns, items, onMoveItem],
77
+ );
78
+
79
+ const getCardActions = useCallback(
80
+ (item: KanbanItem<T>, column: IKanbanColumn<T>): KanbanCardActions => {
81
+ const colIdx = columnIndexMap.get(column.id) ?? -1;
82
+ const canMoveBack = colIdx > 0;
83
+ const canMoveForward = colIdx >= 0 && colIdx < columns.length - 1;
84
+
85
+ return {
86
+ canMoveBack,
87
+ canMoveForward,
88
+ moveBack: () => {
89
+ if (canMoveBack) {
90
+ const prevCol = columns[colIdx - 1];
91
+ if (prevCol) {
92
+ onMoveItem?.(item.id, prevCol.id, column.id);
93
+ }
94
+ }
95
+ },
96
+ moveForward: () => {
97
+ if (canMoveForward) {
98
+ const nextCol = columns[colIdx + 1];
99
+ if (nextCol) {
100
+ onMoveItem?.(item.id, nextCol.id, column.id);
101
+ }
102
+ }
103
+ },
104
+ };
105
+ },
106
+ [columnIndexMap, columns, onMoveItem],
107
+ );
108
+
109
+ return (
110
+ <div className={`udb-kanban-board${className ? ` ${className}` : ''}`}>
111
+ {columns.map((column) => (
112
+ <KanbanColumn<T>
113
+ key={column.id}
114
+ column={column}
115
+ items={itemsByColumn.get(column.id) ?? []}
116
+ draggingItemId={draggingItemId}
117
+ getCardActions={getCardActions}
118
+ onDropItem={handleDropItem}
119
+ onSelectItem={onSelectItem}
120
+ onColumnAction={onColumnAction}
121
+ onDragStartCard={handleDragStartCard}
122
+ onDragEndCard={handleDragEndCard}
123
+ renderCard={renderCard}
124
+ renderColumnHeader={renderColumnHeader}
125
+ renderColumnFooter={renderColumnFooter}
126
+ renderEmptyColumn={renderEmptyColumn}
127
+ showStageActions={showStageActions}
128
+ emptyText={emptyText}
129
+ className={columnClassName}
130
+ cardClassName={cardClassName}
131
+ />
132
+ ))}
133
+ </div>
134
+ );
135
+ }
@@ -0,0 +1,160 @@
1
+ import { useCallback, type DragEvent, type KeyboardEvent, type ReactNode } from 'react';
2
+ import { ChevronLeft, ChevronRight } from 'lucide-react';
3
+ import type { KanbanCardActions, KanbanColumn, KanbanItem } from '../types';
4
+
5
+ export interface KanbanCardProps<T = unknown> {
6
+ readonly item: KanbanItem<T>;
7
+ readonly column: KanbanColumn<T>;
8
+ readonly actions?: KanbanCardActions;
9
+ readonly renderCard?: (
10
+ item: KanbanItem<T>,
11
+ column: KanbanColumn<T>,
12
+ actions?: KanbanCardActions,
13
+ ) => ReactNode;
14
+ readonly onSelectItem?: (item: KanbanItem<T>) => void;
15
+ readonly onDragStart?: (e: DragEvent<HTMLDivElement>, item: KanbanItem<T>) => void;
16
+ readonly onDragEnd?: (e: DragEvent<HTMLDivElement>, item: KanbanItem<T>) => void;
17
+ readonly isDragging?: boolean;
18
+ readonly showStageActions?: boolean;
19
+ readonly className?: string;
20
+ }
21
+
22
+ export function KanbanCard<T = unknown>({
23
+ item,
24
+ column,
25
+ actions,
26
+ renderCard,
27
+ onSelectItem,
28
+ onDragStart,
29
+ onDragEnd,
30
+ isDragging = false,
31
+ showStageActions = false,
32
+ className,
33
+ }: KanbanCardProps<T>): ReactNode {
34
+ const handleClick = useCallback(() => {
35
+ onSelectItem?.(item);
36
+ }, [onSelectItem, item]);
37
+
38
+ const handleKeyDown = useCallback(
39
+ (e: KeyboardEvent<HTMLDivElement>) => {
40
+ if (e.key === 'Enter' || e.key === ' ') {
41
+ if ((e.target as HTMLElement).tagName.toLowerCase() === 'button') {
42
+ return;
43
+ }
44
+ e.preventDefault();
45
+ onSelectItem?.(item);
46
+ }
47
+ },
48
+ [onSelectItem, item],
49
+ );
50
+
51
+ const handleDragStart = useCallback(
52
+ (e: DragEvent<HTMLDivElement>) => {
53
+ e.dataTransfer.setData('text/plain', item.id);
54
+ e.dataTransfer.effectAllowed = 'move';
55
+ onDragStart?.(e, item);
56
+ },
57
+ [item, onDragStart],
58
+ );
59
+
60
+ const handleDragEnd = useCallback(
61
+ (e: DragEvent<HTMLDivElement>) => {
62
+ onDragEnd?.(e, item);
63
+ },
64
+ [item, onDragEnd],
65
+ );
66
+
67
+ if (renderCard) {
68
+ return (
69
+ <div
70
+ draggable={!item.disabled}
71
+ onDragStart={handleDragStart}
72
+ onDragEnd={handleDragEnd}
73
+ onClick={handleClick}
74
+ onKeyDown={handleKeyDown}
75
+ role="button"
76
+ tabIndex={0}
77
+ className={`udb-kanban-card${isDragging ? ' is-dragging' : ''}${item.disabled ? ' is-disabled' : ''}${className ? ` ${className}` : ''}`}
78
+ >
79
+ {renderCard(item, column, actions)}
80
+ </div>
81
+ );
82
+ }
83
+
84
+ return (
85
+ <div
86
+ draggable={!item.disabled}
87
+ onDragStart={handleDragStart}
88
+ onDragEnd={handleDragEnd}
89
+ onClick={handleClick}
90
+ onKeyDown={handleKeyDown}
91
+ role="button"
92
+ tabIndex={0}
93
+ className={`udb-kanban-card${isDragging ? ' is-dragging' : ''}${item.disabled ? ' is-disabled' : ''}${className ? ` ${className}` : ''}`}
94
+ >
95
+ <div className="udb-kanban-card-head">
96
+ <div className="udb-kanban-card-title">{item.title}</div>
97
+ {item.badge}
98
+ </div>
99
+
100
+ {item.description && <div className="udb-kanban-card-desc">{item.description}</div>}
101
+
102
+ {item.tags && item.tags.length > 0 && (
103
+ <div className="udb-kanban-card-tags">
104
+ {item.tags.map((tag) => (
105
+ <span key={tag.label} className="udb-kanban-card-tag">
106
+ {tag.label}
107
+ </span>
108
+ ))}
109
+ </div>
110
+ )}
111
+
112
+ {(item.meta || item.assignee || (showStageActions && actions)) && (
113
+ <div className="udb-kanban-card-foot">
114
+ <div className="udb-kanban-card-meta">
115
+ {item.assignee && (
116
+ <span className="udb-kanban-card-assignee">
117
+ <span className="udb-kanban-card-avatar">
118
+ {item.assignee.avatarUrl ? (
119
+ <img src={item.assignee.avatarUrl} alt={item.assignee.name} />
120
+ ) : (
121
+ item.assignee.initials ?? item.assignee.name.slice(0, 2)
122
+ )}
123
+ </span>
124
+ <span>{item.assignee.name}</span>
125
+ </span>
126
+ )}
127
+ {item.meta}
128
+ </div>
129
+
130
+ {showStageActions && actions && (
131
+ <div
132
+ className="udb-kanban-stage-actions"
133
+ onClick={(e) => e.stopPropagation()}
134
+ onKeyDown={(e) => e.stopPropagation()}
135
+ >
136
+ <button
137
+ type="button"
138
+ className="udb-kanban-stage-btn"
139
+ disabled={!actions.canMoveBack}
140
+ onClick={actions.moveBack}
141
+ aria-label="Move backward"
142
+ >
143
+ <ChevronLeft size={13} aria-hidden="true" />
144
+ </button>
145
+ <button
146
+ type="button"
147
+ className="udb-kanban-stage-btn"
148
+ disabled={!actions.canMoveForward}
149
+ onClick={actions.moveForward}
150
+ aria-label="Move forward"
151
+ >
152
+ <ChevronRight size={13} aria-hidden="true" />
153
+ </button>
154
+ </div>
155
+ )}
156
+ </div>
157
+ )}
158
+ </div>
159
+ );
160
+ }
@@ -0,0 +1,163 @@
1
+ import { useCallback, useState, type DragEvent, type ReactNode } from 'react';
2
+ import { Plus } from 'lucide-react';
3
+ import type { KanbanCardActions, KanbanColumn as IKanbanColumn, KanbanItem } from '../types';
4
+ import { KanbanCard } from './KanbanCard';
5
+
6
+ export interface KanbanColumnProps<T = unknown> {
7
+ readonly column: IKanbanColumn<T>;
8
+ readonly items: readonly KanbanItem<T>[];
9
+ readonly draggingItemId?: string | null;
10
+ readonly getCardActions?: (item: KanbanItem<T>, column: IKanbanColumn<T>) => KanbanCardActions;
11
+ readonly onDropItem?: (targetColumnId: string, itemId: string) => void;
12
+ readonly onSelectItem?: (item: KanbanItem<T>) => void;
13
+ readonly onColumnAction?: (columnId: string) => void;
14
+ readonly onDragStartCard?: (e: DragEvent<HTMLDivElement>, item: KanbanItem<T>) => void;
15
+ readonly onDragEndCard?: (e: DragEvent<HTMLDivElement>, item: KanbanItem<T>) => void;
16
+ readonly renderCard?: (
17
+ item: KanbanItem<T>,
18
+ column: IKanbanColumn<T>,
19
+ actions?: KanbanCardActions,
20
+ ) => ReactNode;
21
+ readonly renderColumnHeader?: (
22
+ column: IKanbanColumn<T>,
23
+ items: readonly KanbanItem<T>[],
24
+ ) => ReactNode;
25
+ readonly renderColumnFooter?: (column: IKanbanColumn<T>) => ReactNode;
26
+ readonly renderEmptyColumn?: (column: IKanbanColumn<T>) => ReactNode;
27
+ readonly showStageActions?: boolean;
28
+ readonly emptyText?: string;
29
+ readonly className?: string;
30
+ readonly cardClassName?: string;
31
+ }
32
+
33
+ export function KanbanColumn<T = unknown>({
34
+ column,
35
+ items,
36
+ draggingItemId,
37
+ getCardActions,
38
+ onDropItem,
39
+ onSelectItem,
40
+ onColumnAction,
41
+ onDragStartCard,
42
+ onDragEndCard,
43
+ renderCard,
44
+ renderColumnHeader,
45
+ renderColumnFooter,
46
+ renderEmptyColumn,
47
+ showStageActions,
48
+ emptyText = 'Drop here',
49
+ className,
50
+ cardClassName,
51
+ }: KanbanColumnProps<T>): ReactNode {
52
+ const [isDragOver, setIsDragOver] = useState(false);
53
+
54
+ const handleDragOver = useCallback((e: DragEvent<HTMLDivElement>) => {
55
+ e.preventDefault();
56
+ e.dataTransfer.dropEffect = 'move';
57
+ }, []);
58
+
59
+ const handleDragEnter = useCallback((e: DragEvent<HTMLDivElement>) => {
60
+ e.preventDefault();
61
+ setIsDragOver(true);
62
+ }, []);
63
+
64
+ const handleDragLeave = useCallback((e: DragEvent<HTMLDivElement>) => {
65
+ if (e.currentTarget.contains(e.relatedTarget as Node)) {
66
+ return;
67
+ }
68
+ setIsDragOver(false);
69
+ }, []);
70
+
71
+ const handleDrop = useCallback(
72
+ (e: DragEvent<HTMLDivElement>) => {
73
+ e.preventDefault();
74
+ setIsDragOver(false);
75
+ const itemId = e.dataTransfer.getData('text/plain');
76
+ if (itemId) {
77
+ onDropItem?.(column.id, itemId);
78
+ }
79
+ },
80
+ [column.id, onDropItem],
81
+ );
82
+
83
+ const isLimitExceeded =
84
+ typeof column.limit === 'number' && column.limit > 0 && items.length > column.limit;
85
+
86
+ return (
87
+ <div
88
+ className={`udb-kanban-col${isDragOver ? ' is-drag-over' : ''}${className ? ` ${className}` : ''}`}
89
+ onDragOver={handleDragOver}
90
+ onDragEnter={handleDragEnter}
91
+ onDragLeave={handleDragLeave}
92
+ onDrop={handleDrop}
93
+ data-column-id={column.id}
94
+ >
95
+ {renderColumnHeader ? (
96
+ renderColumnHeader(column, items)
97
+ ) : (
98
+ <div className="udb-kanban-col-head">
99
+ <div className="udb-kanban-col-title-wrap">
100
+ {column.icon}
101
+ {column.tone && (
102
+ <span
103
+ className={`udb-kanban-tone-dot tone-${column.tone}`}
104
+ aria-hidden="true"
105
+ />
106
+ )}
107
+ <span className="udb-kanban-col-title">{column.title}</span>
108
+ <span className="udb-kanban-col-count">{items.length}</span>
109
+ {typeof column.limit === 'number' && column.limit > 0 && (
110
+ <span
111
+ className={`udb-kanban-col-limit${isLimitExceeded ? ' is-exceeded' : ''}`}
112
+ >
113
+ / {column.limit}
114
+ </span>
115
+ )}
116
+ </div>
117
+
118
+ <div className="udb-kanban-col-actions">
119
+ {column.headerActions}
120
+ {onColumnAction && (
121
+ <button
122
+ type="button"
123
+ className="udb-kanban-col-btn"
124
+ onClick={() => onColumnAction(column.id)}
125
+ aria-label={`Add item to ${String(column.title)}`}
126
+ >
127
+ <Plus size={15} aria-hidden="true" />
128
+ </button>
129
+ )}
130
+ </div>
131
+ </div>
132
+ )}
133
+
134
+ <div className="udb-kanban-col-body">
135
+ {items.length === 0 ? (
136
+ renderEmptyColumn ? (
137
+ renderEmptyColumn(column)
138
+ ) : (
139
+ <div className="udb-kanban-empty-col">{emptyText}</div>
140
+ )
141
+ ) : (
142
+ items.map((item) => (
143
+ <KanbanCard<T>
144
+ key={item.id}
145
+ item={item}
146
+ column={column}
147
+ actions={getCardActions?.(item, column)}
148
+ renderCard={renderCard}
149
+ onSelectItem={onSelectItem}
150
+ onDragStart={onDragStartCard}
151
+ onDragEnd={onDragEndCard}
152
+ isDragging={draggingItemId === item.id}
153
+ showStageActions={showStageActions}
154
+ className={cardClassName}
155
+ />
156
+ ))
157
+ )}
158
+ </div>
159
+
160
+ {renderColumnFooter && renderColumnFooter(column)}
161
+ </div>
162
+ );
163
+ }