@expcat/tigercat-react 0.3.70 → 0.4.2

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 (40) hide show
  1. package/dist/{chunk-ZTVATZB6.js → chunk-6OVVMHZJ.js} +137 -70
  2. package/dist/{chunk-ZGQOYCQT.mjs → chunk-FX2IBA4W.mjs} +1 -1
  3. package/dist/{chunk-PWZB45Z7.js → chunk-JQK354YN.js} +11 -9
  4. package/dist/chunk-JWFEJ4XG.js +543 -0
  5. package/dist/chunk-PEGJ2KHC.js +273 -0
  6. package/dist/{chunk-3577FW3I.mjs → chunk-PJ7NS7NX.mjs} +139 -72
  7. package/dist/chunk-PJCY45UP.mjs +536 -0
  8. package/dist/{chunk-IRH2ZVD3.js → chunk-Q7GUWWG5.js} +2 -2
  9. package/dist/chunk-RCNTRSUA.mjs +271 -0
  10. package/dist/chunk-SHT4TU3T.mjs +26 -0
  11. package/dist/{chunk-OUAZM7NY.mjs → chunk-SMC2RV3V.mjs} +12 -10
  12. package/dist/{chunk-OESNOOOT.js → chunk-YWTZALG5.js} +8 -4
  13. package/dist/components/ActivityFeed.js +4 -4
  14. package/dist/components/ActivityFeed.mjs +2 -2
  15. package/dist/components/DataTableWithToolbar.js +4 -4
  16. package/dist/components/DataTableWithToolbar.mjs +2 -2
  17. package/dist/components/InputNumber.d.mts +24 -0
  18. package/dist/components/InputNumber.d.ts +24 -0
  19. package/dist/components/InputNumber.js +10 -0
  20. package/dist/components/InputNumber.mjs +1 -0
  21. package/dist/components/Sidebar.js +2 -2
  22. package/dist/components/Sidebar.mjs +1 -1
  23. package/dist/components/SubMenu.js +2 -2
  24. package/dist/components/SubMenu.mjs +1 -1
  25. package/dist/components/Table.d.mts +5 -1
  26. package/dist/components/Table.d.ts +5 -1
  27. package/dist/components/Table.js +2 -2
  28. package/dist/components/Table.mjs +1 -1
  29. package/dist/components/TaskBoard.d.mts +13 -0
  30. package/dist/components/TaskBoard.d.ts +13 -0
  31. package/dist/components/TaskBoard.js +17 -0
  32. package/dist/components/TaskBoard.mjs +2 -0
  33. package/dist/index.d.mts +2 -0
  34. package/dist/index.d.ts +2 -0
  35. package/dist/index.js +50 -40
  36. package/dist/index.mjs +13 -11
  37. package/package.json +2 -2
  38. package/dist/chunk-RITTIFCJ.mjs +0 -22
  39. package/dist/{chunk-IOM7DWWQ.js → chunk-J3HKED4B.js} +1 -1
  40. package/dist/{chunk-FTY2W4L2.mjs → chunk-MTL2QUM3.mjs} +1 -1
@@ -0,0 +1,543 @@
1
+ 'use strict';
2
+
3
+ var chunkQL6UEG3U_js = require('./chunk-QL6UEG3U.js');
4
+ var React = require('react');
5
+ var tigercatCore = require('@expcat/tigercat-core');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefault(React);
11
+
12
+ var CardItem = React__default.default.memo(
13
+ ({
14
+ card,
15
+ column,
16
+ isDragging,
17
+ isKbGrabbed,
18
+ draggable,
19
+ dragHintText,
20
+ renderCard,
21
+ onDragStart,
22
+ onDragEnd,
23
+ onTouchStart,
24
+ onTouchMove,
25
+ onTouchEnd,
26
+ onKeyDown
27
+ }) => {
28
+ const cardClasses = tigercatCore.classNames(
29
+ tigercatCore.taskBoardCardClasses,
30
+ isDragging && tigercatCore.taskBoardCardDraggingClasses,
31
+ isKbGrabbed && "ring-2 ring-[var(--tiger-primary,#2563eb)]"
32
+ );
33
+ return /* @__PURE__ */ jsxRuntime.jsx(
34
+ "div",
35
+ {
36
+ className: cardClasses,
37
+ draggable,
38
+ tabIndex: 0,
39
+ role: "listitem",
40
+ "aria-roledescription": dragHintText,
41
+ "aria-grabbed": isKbGrabbed ? "true" : void 0,
42
+ "data-tiger-taskboard-card": "",
43
+ "data-tiger-taskboard-card-id": String(card.id),
44
+ onDragStart: (e) => onDragStart(e, card, column),
45
+ onDragEnd,
46
+ onTouchStart: (e) => onTouchStart(e, card, column),
47
+ onTouchMove,
48
+ onTouchEnd,
49
+ onKeyDown: (e) => onKeyDown(e, card, column),
50
+ children: renderCard ? renderCard(card, column.id) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
51
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium text-sm text-[var(--tiger-text,#1f2937)]", children: card.title }),
52
+ card.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-xs text-[var(--tiger-text-muted,#6b7280)] line-clamp-2", children: card.description })
53
+ ] })
54
+ }
55
+ );
56
+ },
57
+ (prev, next) => prev.card.id === next.card.id && prev.isDragging === next.isDragging && prev.isKbGrabbed === next.isKbGrabbed && prev.draggable === next.draggable && prev.card === next.card
58
+ );
59
+ CardItem.displayName = "TaskBoardCardItem";
60
+ var ColumnItem = React__default.default.memo(
61
+ ({
62
+ column,
63
+ colIndex,
64
+ isDropTarget,
65
+ isColDragging,
66
+ dropIdx,
67
+ draggable,
68
+ columnDraggable,
69
+ labels,
70
+ renderCardProp,
71
+ renderColumnHeader,
72
+ renderColumnFooter,
73
+ renderEmptyColumn,
74
+ onCardAdd,
75
+ dragType,
76
+ onCardDragStart,
77
+ onCardDragOver,
78
+ onCardDrop,
79
+ onDragEnd,
80
+ onDragLeave,
81
+ onColumnDragStart,
82
+ onColumnDragOver,
83
+ onColumnDrop,
84
+ onCardTouchStart,
85
+ onCardTouchMove,
86
+ onCardTouchEnd,
87
+ onColumnTouchStart,
88
+ onColumnTouchMove,
89
+ onColumnTouchEnd,
90
+ onCardKeyDown,
91
+ dragStateId,
92
+ kbDragStateId
93
+ }) => {
94
+ const wipOver = tigercatCore.isWipExceeded(column);
95
+ const colClasses = tigercatCore.classNames(
96
+ tigercatCore.taskBoardColumnClasses,
97
+ isDropTarget && tigercatCore.taskBoardColumnDropTargetClasses,
98
+ isColDragging && tigercatCore.taskBoardColumnDraggingClasses
99
+ );
100
+ let cardsContent;
101
+ if (column.cards.length > 0) {
102
+ const nodes = [];
103
+ column.cards.forEach((card, i) => {
104
+ if (isDropTarget && dropIdx === i) {
105
+ nodes.push(/* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.taskBoardDropIndicatorClasses }, `drop-${i}`));
106
+ }
107
+ const isDragging = dragStateId === card.id;
108
+ const isKbGrabbed = kbDragStateId === card.id;
109
+ nodes.push(
110
+ /* @__PURE__ */ jsxRuntime.jsx(
111
+ CardItem,
112
+ {
113
+ card,
114
+ column,
115
+ isDragging,
116
+ isKbGrabbed,
117
+ draggable,
118
+ dragHintText: labels.dragHintText,
119
+ renderCard: renderCardProp,
120
+ onDragStart: onCardDragStart,
121
+ onDragEnd,
122
+ onTouchStart: onCardTouchStart,
123
+ onTouchMove: onCardTouchMove,
124
+ onTouchEnd: onCardTouchEnd,
125
+ onKeyDown: onCardKeyDown
126
+ },
127
+ String(card.id)
128
+ )
129
+ );
130
+ });
131
+ if (isDropTarget && dropIdx >= column.cards.length) {
132
+ nodes.push(/* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.taskBoardDropIndicatorClasses }, "drop-end"));
133
+ }
134
+ cardsContent = nodes;
135
+ } else {
136
+ cardsContent = isDropTarget ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.taskBoardDropIndicatorClasses }, "drop-empty") : renderEmptyColumn ? renderEmptyColumn(column) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.taskBoardEmptyClasses, children: tigercatCore.resolveLocaleText(labels.emptyColumnText) });
137
+ }
138
+ const wipTitle = column.wipLimit != null ? tigercatCore.resolveLocaleText(labels.wipLimitText.replace("{limit}", String(column.wipLimit))) : void 0;
139
+ return /* @__PURE__ */ jsxRuntime.jsxs(
140
+ "div",
141
+ {
142
+ className: colClasses,
143
+ "data-tiger-taskboard-column": "",
144
+ "data-tiger-taskboard-column-id": String(column.id),
145
+ onDragOver: dragType === "column" ? onColumnDragOver : void 0,
146
+ onDrop: dragType === "column" ? onColumnDrop : void 0,
147
+ children: [
148
+ /* @__PURE__ */ jsxRuntime.jsx(
149
+ "div",
150
+ {
151
+ className: tigercatCore.taskBoardColumnHeaderClasses,
152
+ draggable: columnDraggable,
153
+ onDragStart: (e) => onColumnDragStart(e, column, colIndex),
154
+ onDragEnd,
155
+ onTouchStart: (e) => onColumnTouchStart(e, column, colIndex),
156
+ onTouchMove: onColumnTouchMove,
157
+ onTouchEnd: onColumnTouchEnd,
158
+ style: columnDraggable ? { cursor: "grab" } : void 0,
159
+ children: renderColumnHeader ? renderColumnHeader(column) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
160
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: wipOver ? tigercatCore.taskBoardWipExceededClasses : void 0, children: [
161
+ column.title,
162
+ column.wipLimit != null ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-2 text-xs font-normal opacity-70", title: wipTitle, children: [
163
+ "(",
164
+ column.cards.length,
165
+ "/",
166
+ column.wipLimit,
167
+ ")"
168
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 text-xs font-normal opacity-50", children: column.cards.length })
169
+ ] }),
170
+ column.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-normal text-[var(--tiger-text-muted,#6b7280)] truncate max-w-[120px]", children: column.description })
171
+ ] })
172
+ }
173
+ ),
174
+ /* @__PURE__ */ jsxRuntime.jsx(
175
+ "div",
176
+ {
177
+ className: tigercatCore.taskBoardColumnBodyClasses,
178
+ role: "list",
179
+ "aria-label": column.title,
180
+ onDragOver: (e) => onCardDragOver(e, column),
181
+ onDrop: (e) => onCardDrop(e, column),
182
+ onDragLeave,
183
+ children: cardsContent
184
+ }
185
+ ),
186
+ renderColumnFooter ? renderColumnFooter(column) : onCardAdd ? /* @__PURE__ */ jsxRuntime.jsxs(
187
+ "div",
188
+ {
189
+ className: tigercatCore.classNames(
190
+ "border-t border-[var(--tiger-border,#e5e7eb)]",
191
+ tigercatCore.taskBoardAddCardClasses
192
+ ),
193
+ onClick: () => onCardAdd(column.id),
194
+ children: [
195
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "+" }),
196
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: tigercatCore.resolveLocaleText(labels.addCardText) })
197
+ ]
198
+ }
199
+ ) : null
200
+ ]
201
+ }
202
+ );
203
+ },
204
+ (prev, next) => prev.column === next.column && prev.colIndex === next.colIndex && prev.isDropTarget === next.isDropTarget && prev.isColDragging === next.isColDragging && prev.dropIdx === next.dropIdx && prev.draggable === next.draggable && prev.columnDraggable === next.columnDraggable && prev.dragType === next.dragType && prev.dragStateId === next.dragStateId && prev.kbDragStateId === next.kbDragStateId && prev.onCardAdd === next.onCardAdd
205
+ );
206
+ ColumnItem.displayName = "TaskBoardColumnItem";
207
+ var TaskBoard = ({
208
+ columns: controlledColumns,
209
+ defaultColumns = [],
210
+ draggable = true,
211
+ columnDraggable = true,
212
+ enforceWipLimit = false,
213
+ beforeCardMove,
214
+ beforeColumnMove,
215
+ onCardMove,
216
+ onColumnMove,
217
+ onColumnsChange,
218
+ onCardAdd,
219
+ renderCard: renderCardProp,
220
+ renderColumnHeader,
221
+ renderColumnFooter,
222
+ renderEmptyColumn,
223
+ locale,
224
+ className,
225
+ style,
226
+ ...rest
227
+ }) => {
228
+ const config = chunkQL6UEG3U_js.useTigerConfig();
229
+ const mergedLocale = React.useMemo(
230
+ () => tigercatCore.mergeTigerLocale(config.locale, locale),
231
+ [config.locale, locale]
232
+ );
233
+ const labels = React.useMemo(() => tigercatCore.getTaskBoardLabels(mergedLocale), [mergedLocale]);
234
+ const [innerColumns, setInnerColumns] = React.useState(defaultColumns);
235
+ React.useEffect(() => {
236
+ if (controlledColumns !== void 0) setInnerColumns(controlledColumns);
237
+ }, [controlledColumns]);
238
+ const currentColumns = controlledColumns ?? innerColumns;
239
+ const columnsRef = React.useRef(currentColumns);
240
+ columnsRef.current = currentColumns;
241
+ const updateColumns = React.useCallback(
242
+ (next) => {
243
+ setInnerColumns(next);
244
+ onColumnsChange?.(next);
245
+ },
246
+ [onColumnsChange]
247
+ );
248
+ const [dragState, setDragState] = React.useState(null);
249
+ const [dropTargetColumnId, setDropTargetColumnId] = React.useState(null);
250
+ const [dropIdx, setDropIdx] = React.useState(-1);
251
+ const [kbDragState, setKbDragState] = React.useState(null);
252
+ const boardRef = React.useRef(null);
253
+ const touchTrackerRef = React.useRef(null);
254
+ const touchRafRef = React.useRef(0);
255
+ const beforeCardMoveRef = React.useRef(beforeCardMove);
256
+ beforeCardMoveRef.current = beforeCardMove;
257
+ const beforeColumnMoveRef = React.useRef(beforeColumnMove);
258
+ beforeColumnMoveRef.current = beforeColumnMove;
259
+ const onCardMoveRef = React.useRef(onCardMove);
260
+ onCardMoveRef.current = onCardMove;
261
+ const onColumnMoveRef = React.useRef(onColumnMove);
262
+ onColumnMoveRef.current = onColumnMove;
263
+ const enforceWipLimitRef = React.useRef(enforceWipLimit);
264
+ enforceWipLimitRef.current = enforceWipLimit;
265
+ React.useEffect(() => {
266
+ if (typeof window !== "undefined" && ("ontouchstart" in window || navigator.maxTouchPoints > 0)) {
267
+ touchTrackerRef.current = tigercatCore.createTouchDragTracker();
268
+ }
269
+ return () => cancelAnimationFrame(touchRafRef.current);
270
+ }, []);
271
+ const resetDrag = React.useCallback(() => {
272
+ setDragState(null);
273
+ setDropTargetColumnId(null);
274
+ setDropIdx(-1);
275
+ }, []);
276
+ const applyCardMove = React.useCallback(
277
+ async (cardId, fromColumnId, toColumnId, toIdx) => {
278
+ const result = tigercatCore.moveCard(columnsRef.current, cardId, fromColumnId, toColumnId, toIdx, {
279
+ enforceWipLimit: enforceWipLimitRef.current
280
+ });
281
+ if (!result) return;
282
+ if (beforeCardMoveRef.current) {
283
+ const ok = await beforeCardMoveRef.current(result.event);
284
+ if (!ok) return;
285
+ }
286
+ updateColumns(result.columns);
287
+ onCardMoveRef.current?.(result.event);
288
+ },
289
+ [updateColumns]
290
+ );
291
+ const applyColumnMove = React.useCallback(
292
+ async (fromIdx, toIdx) => {
293
+ const cols = columnsRef.current;
294
+ const result = tigercatCore.reorderColumns(cols, fromIdx, Math.min(toIdx, cols.length - 1));
295
+ if (!result) return;
296
+ if (beforeColumnMoveRef.current) {
297
+ const ok = await beforeColumnMoveRef.current(result.event);
298
+ if (!ok) return;
299
+ }
300
+ updateColumns(result.columns);
301
+ onColumnMoveRef.current?.(result.event);
302
+ },
303
+ [updateColumns]
304
+ );
305
+ const handleCardDragStart = React.useCallback(
306
+ (e, card, column) => {
307
+ if (!draggable) return;
308
+ const idx = column.cards.findIndex((c) => c.id === card.id);
309
+ tigercatCore.setDragData(e.dataTransfer, tigercatCore.createCardDragData(card.id, column.id, idx));
310
+ setDragState({ type: "card", id: card.id, fromColumnId: column.id, fromIndex: idx });
311
+ },
312
+ [draggable]
313
+ );
314
+ const handleCardDragOver = React.useCallback(
315
+ (e, column) => {
316
+ e.preventDefault();
317
+ if (!dragState || dragState.type !== "card") return;
318
+ setDropTargetColumnId(column.id);
319
+ const target = e.currentTarget;
320
+ const cardEls = target.querySelectorAll("[data-tiger-taskboard-card]");
321
+ const rects = [];
322
+ cardEls.forEach((el) => rects.push(el.getBoundingClientRect()));
323
+ setDropIdx(tigercatCore.getDropIndex(e.clientY, rects));
324
+ },
325
+ [dragState]
326
+ );
327
+ const handleCardDrop = React.useCallback(
328
+ (e, column) => {
329
+ e.preventDefault();
330
+ const data = tigercatCore.parseDragData(e.dataTransfer);
331
+ if (!data || data.type !== "card") return;
332
+ applyCardMove(
333
+ data.cardId,
334
+ data.columnId,
335
+ column.id,
336
+ dropIdx >= 0 ? dropIdx : column.cards.length
337
+ );
338
+ resetDrag();
339
+ },
340
+ [dropIdx, applyCardMove, resetDrag]
341
+ );
342
+ const handleColumnDragStart = React.useCallback(
343
+ (e, column, index) => {
344
+ if (!columnDraggable) return;
345
+ tigercatCore.setDragData(e.dataTransfer, tigercatCore.createColumnDragData(column.id, index));
346
+ setDragState({ type: "column", id: column.id, fromIndex: index });
347
+ },
348
+ [columnDraggable]
349
+ );
350
+ const handleColumnDragOver = React.useCallback(
351
+ (e) => {
352
+ if (!dragState || dragState.type !== "column") return;
353
+ e.preventDefault();
354
+ },
355
+ [dragState]
356
+ );
357
+ const handleColumnDrop = React.useCallback(
358
+ (e) => {
359
+ e.preventDefault();
360
+ const data = tigercatCore.parseDragData(e.dataTransfer);
361
+ if (!data || data.type !== "column") return;
362
+ const colEls = boardRef.current?.querySelectorAll("[data-tiger-taskboard-column]");
363
+ if (!colEls) return;
364
+ const rects = [];
365
+ colEls.forEach((el) => rects.push(el.getBoundingClientRect()));
366
+ const toIdx = tigercatCore.getColumnDropIndex(e.clientX, rects);
367
+ applyColumnMove(data.index, toIdx);
368
+ resetDrag();
369
+ },
370
+ [applyColumnMove, resetDrag]
371
+ );
372
+ const handleDragEnd = React.useCallback(() => resetDrag(), [resetDrag]);
373
+ const handleDragLeave = React.useCallback(
374
+ (e) => {
375
+ const related = e.relatedTarget;
376
+ if (!related || !e.currentTarget.contains(related)) {
377
+ if (dragState?.type === "card") {
378
+ setDropTargetColumnId(null);
379
+ setDropIdx(-1);
380
+ }
381
+ }
382
+ },
383
+ [dragState]
384
+ );
385
+ const handleTouchStart = React.useCallback(
386
+ (e, card, column) => {
387
+ if (!draggable || !touchTrackerRef.current) return;
388
+ const idx = column.cards.findIndex((c) => c.id === card.id);
389
+ touchTrackerRef.current.onTouchStart(e.nativeEvent, e.currentTarget);
390
+ setDragState({ type: "card", id: card.id, fromColumnId: column.id, fromIndex: idx });
391
+ },
392
+ [draggable]
393
+ );
394
+ const handleTouchMove = React.useCallback(
395
+ (e) => {
396
+ if (!touchTrackerRef.current || !dragState) return;
397
+ touchTrackerRef.current.onTouchMove(e.nativeEvent);
398
+ cancelAnimationFrame(touchRafRef.current);
399
+ touchRafRef.current = requestAnimationFrame(() => {
400
+ const st = touchTrackerRef.current.getState();
401
+ if (dragState?.type === "card") {
402
+ const colEl = tigercatCore.findColumnFromPoint(st.currentX, st.currentY, boardRef.current);
403
+ if (colEl) {
404
+ const colId = colEl.getAttribute("data-tiger-taskboard-column-id");
405
+ setDropTargetColumnId(colId ?? null);
406
+ const cardEls = colEl.querySelectorAll("[data-tiger-taskboard-card]");
407
+ const rects = [];
408
+ cardEls.forEach((el) => rects.push(el.getBoundingClientRect()));
409
+ setDropIdx(tigercatCore.getDropIndex(st.currentY, rects));
410
+ }
411
+ }
412
+ });
413
+ },
414
+ [dragState]
415
+ );
416
+ const handleTouchEnd = React.useCallback(() => {
417
+ if (!touchTrackerRef.current || !dragState) return;
418
+ touchTrackerRef.current.onTouchEnd();
419
+ if (dragState.type === "card" && dropTargetColumnId != null) {
420
+ applyCardMove(
421
+ dragState.id,
422
+ dragState.fromColumnId,
423
+ dropTargetColumnId,
424
+ dropIdx >= 0 ? dropIdx : 0
425
+ );
426
+ }
427
+ resetDrag();
428
+ }, [dragState, dropIdx, dropTargetColumnId, applyCardMove, resetDrag]);
429
+ const handleColumnTouchStart = React.useCallback(
430
+ (e, column, index) => {
431
+ if (!columnDraggable || !touchTrackerRef.current) return;
432
+ touchTrackerRef.current.onTouchStart(e.nativeEvent, e.currentTarget);
433
+ setDragState({ type: "column", id: column.id, fromIndex: index });
434
+ },
435
+ [columnDraggable]
436
+ );
437
+ const handleColumnTouchMove = React.useCallback(
438
+ (e) => {
439
+ if (!touchTrackerRef.current || !dragState || dragState.type !== "column") return;
440
+ touchTrackerRef.current.onTouchMove(e.nativeEvent);
441
+ },
442
+ [dragState]
443
+ );
444
+ const handleColumnTouchEnd = React.useCallback(() => {
445
+ if (!touchTrackerRef.current || !dragState || dragState.type !== "column") return;
446
+ const st = touchTrackerRef.current.onTouchEnd();
447
+ const colEls = boardRef.current?.querySelectorAll("[data-tiger-taskboard-column]");
448
+ if (!colEls) {
449
+ resetDrag();
450
+ return;
451
+ }
452
+ const rects = [];
453
+ colEls.forEach((el) => rects.push(el.getBoundingClientRect()));
454
+ const toIdx = tigercatCore.getColumnDropIndex(st.currentX, rects);
455
+ applyColumnMove(dragState.fromIndex, Math.min(toIdx, columnsRef.current.length - 1));
456
+ resetDrag();
457
+ }, [dragState, applyColumnMove, resetDrag]);
458
+ const handleCardKeyDown = React.useCallback(
459
+ (e, card, column) => {
460
+ if (!draggable) return;
461
+ if (e.key === "Enter" || e.key === " ") {
462
+ e.preventDefault();
463
+ if (!kbDragState) {
464
+ const idx = column.cards.findIndex((c) => c.id === card.id);
465
+ setKbDragState({ type: "card", id: card.id, fromColumnId: column.id, fromIndex: idx });
466
+ } else {
467
+ const cardIdx = column.cards.findIndex((c) => c.id === card.id);
468
+ if (kbDragState.fromColumnId !== void 0) {
469
+ applyCardMove(kbDragState.id, kbDragState.fromColumnId, column.id, cardIdx);
470
+ }
471
+ setKbDragState(null);
472
+ }
473
+ return;
474
+ }
475
+ if (e.key === "Escape" && kbDragState) {
476
+ e.preventDefault();
477
+ setKbDragState(null);
478
+ }
479
+ },
480
+ [draggable, kbDragState, applyCardMove]
481
+ );
482
+ const wrapperClasses = React.useMemo(() => tigercatCore.classNames(tigercatCore.taskBoardBaseClasses, className), [className]);
483
+ const dragType = dragState?.type ?? null;
484
+ const dragStateId = dragState?.type === "card" ? dragState.id : null;
485
+ const kbDragStateId = kbDragState?.id ?? null;
486
+ return /* @__PURE__ */ jsxRuntime.jsx(
487
+ "div",
488
+ {
489
+ ref: boardRef,
490
+ className: wrapperClasses,
491
+ style,
492
+ role: "region",
493
+ "aria-label": tigercatCore.resolveLocaleText(labels.boardAriaLabel),
494
+ "data-tiger-task-board": "",
495
+ ...rest,
496
+ children: currentColumns.map((col, i) => {
497
+ const isDropTarget = dragState?.type === "card" && dropTargetColumnId === col.id;
498
+ const isColDragging = dragState?.type === "column" && dragState.id === col.id;
499
+ return /* @__PURE__ */ jsxRuntime.jsx(
500
+ ColumnItem,
501
+ {
502
+ column: col,
503
+ colIndex: i,
504
+ isDropTarget,
505
+ isColDragging,
506
+ dropIdx: isDropTarget ? dropIdx : -1,
507
+ draggable,
508
+ columnDraggable,
509
+ labels,
510
+ renderCardProp,
511
+ renderColumnHeader,
512
+ renderColumnFooter,
513
+ renderEmptyColumn,
514
+ onCardAdd,
515
+ dragType,
516
+ onCardDragStart: handleCardDragStart,
517
+ onCardDragOver: handleCardDragOver,
518
+ onCardDrop: handleCardDrop,
519
+ onDragEnd: handleDragEnd,
520
+ onDragLeave: handleDragLeave,
521
+ onColumnDragStart: handleColumnDragStart,
522
+ onColumnDragOver: handleColumnDragOver,
523
+ onColumnDrop: handleColumnDrop,
524
+ onCardTouchStart: handleTouchStart,
525
+ onCardTouchMove: handleTouchMove,
526
+ onCardTouchEnd: handleTouchEnd,
527
+ onColumnTouchStart: handleColumnTouchStart,
528
+ onColumnTouchMove: handleColumnTouchMove,
529
+ onColumnTouchEnd: handleColumnTouchEnd,
530
+ onCardKeyDown: handleCardKeyDown,
531
+ dragStateId,
532
+ kbDragStateId
533
+ },
534
+ String(col.id)
535
+ );
536
+ })
537
+ }
538
+ );
539
+ };
540
+ var TaskBoard_default = TaskBoard;
541
+
542
+ exports.TaskBoard = TaskBoard;
543
+ exports.TaskBoard_default = TaskBoard_default;