@expcat/tigercat-react 1.0.0 → 1.0.7
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/{chunk-L6WOLPV7.mjs → chunk-32PAZTVF.mjs} +2 -2
- package/dist/{chunk-ZCBKAOAX.mjs → chunk-34VGG7AK.mjs} +1 -1
- package/dist/{chunk-SULHTYSV.js → chunk-4Q4GADHJ.js} +1 -1
- package/dist/{chunk-5CQEXJF2.js → chunk-5MALB34H.js} +2 -2
- package/dist/chunk-7BVXG3Z5.mjs +22 -0
- package/dist/{chunk-DR2DFFNQ.js → chunk-AHF6JE43.js} +1 -1
- package/dist/{chunk-XODGTE2Y.js → chunk-AUW7DCXL.js} +1 -1
- package/dist/{chunk-5BBZBI2V.mjs → chunk-AYDTXJOR.mjs} +1 -1
- package/dist/{chunk-6SDLSIAO.mjs → chunk-B3MNIAM5.mjs} +1 -1
- package/dist/{chunk-EHU3J4B2.mjs → chunk-DBNAL6G6.mjs} +100 -47
- package/dist/{chunk-2H43QM4B.mjs → chunk-EBLAM3YP.mjs} +1 -1
- package/dist/{chunk-QNFSZYTZ.js → chunk-FHE4D56E.js} +1 -1
- package/dist/{chunk-HADBETZG.js → chunk-FNK4ZATV.js} +1 -1
- package/dist/{chunk-WGPUGPYE.js → chunk-H3JAEEEE.js} +99 -46
- package/dist/{chunk-VUD4BU4K.mjs → chunk-H3NLKNR4.mjs} +1 -1
- package/dist/{chunk-VWMVWZMD.js → chunk-HU3VDVH6.js} +1 -2
- package/dist/{chunk-H5CAIMVL.js → chunk-I3CDTF4U.js} +1 -1
- package/dist/{chunk-SJ5GT7Y4.mjs → chunk-J3N24I7A.mjs} +1 -1
- package/dist/{chunk-SVASEF6K.js → chunk-JB33A4S6.js} +2 -2
- package/dist/{chunk-FT6TEMUF.mjs → chunk-LPNHBHS2.mjs} +1 -1
- package/dist/{chunk-RU6YS4LZ.mjs → chunk-MB7CJ32C.mjs} +1 -1
- package/dist/chunk-NG3GA5LF.js +25 -0
- package/dist/{chunk-QVZTZHCJ.mjs → chunk-PNSWIJG3.mjs} +16 -7
- package/dist/{chunk-333325LH.mjs → chunk-QYLNPHKG.mjs} +1 -1
- package/dist/{chunk-JR7L67Q3.mjs → chunk-R3QWJ7GT.mjs} +1 -1
- package/dist/{chunk-45H3JEI3.js → chunk-RFPXIDAK.js} +16 -7
- package/dist/{chunk-SKJXVYYF.js → chunk-RWZIWKZR.js} +2 -2
- package/dist/{chunk-IWTY32AW.mjs → chunk-SWF7GJYT.mjs} +1 -2
- package/dist/{chunk-J23B66DJ.js → chunk-XO6NSGV3.js} +1 -1
- package/dist/{chunk-FRHGRKKT.js → chunk-XR6B2URW.js} +1 -1
- package/dist/{chunk-T6KZ73VM.js → chunk-YHFBPSMF.js} +1 -1
- package/dist/{chunk-AYDPWKSW.mjs → chunk-YJ4W6DMX.mjs} +2 -2
- package/dist/components/ChatWindow.js +3 -3
- package/dist/components/ChatWindow.mjs +1 -1
- package/dist/components/ColorPicker.js +2 -2
- package/dist/components/ColorPicker.mjs +1 -1
- package/dist/components/CropUpload.js +2 -2
- package/dist/components/CropUpload.mjs +1 -1
- package/dist/components/DataTableWithToolbar.js +4 -4
- package/dist/components/DataTableWithToolbar.mjs +2 -2
- package/dist/components/DonutChart.js +3 -3
- package/dist/components/DonutChart.mjs +1 -1
- package/dist/components/FloatButton.js +3 -3
- package/dist/components/FloatButton.mjs +1 -1
- package/dist/components/FunnelChart.js +2 -2
- package/dist/components/FunnelChart.mjs +1 -1
- package/dist/components/InputGroup.js +5 -5
- package/dist/components/InputGroup.mjs +1 -1
- package/dist/components/Kanban.d.mts +3 -2
- package/dist/components/Kanban.d.ts +3 -2
- package/dist/components/Kanban.js +5 -4
- package/dist/components/Kanban.mjs +3 -2
- package/dist/components/NotificationCenter.js +3 -3
- package/dist/components/NotificationCenter.mjs +1 -1
- package/dist/components/QRCode.js +3 -3
- package/dist/components/QRCode.mjs +1 -1
- package/dist/components/Splitter.js +3 -3
- package/dist/components/Splitter.mjs +1 -1
- package/dist/components/SunburstChart.js +2 -2
- package/dist/components/SunburstChart.mjs +1 -1
- package/dist/components/Table.d.mts +1 -1
- package/dist/components/Table.d.ts +1 -1
- package/dist/components/Table.js +2 -2
- package/dist/components/Table.mjs +1 -1
- package/dist/components/TaskBoard.js +3 -3
- package/dist/components/TaskBoard.mjs +1 -1
- package/dist/components/TreeMapChart.js +2 -2
- package/dist/components/TreeMapChart.mjs +1 -1
- package/dist/index.js +37 -37
- package/dist/index.mjs +16 -16
- package/package.json +2 -2
- package/dist/chunk-24RUEJWB.js +0 -293
- package/dist/chunk-YXWRSEP5.mjs +0 -286
package/dist/chunk-24RUEJWB.js
DELETED
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkUKGQ7256_js = require('./chunk-UKGQ7256.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 Kanban = ({
|
|
13
|
-
columns: controlledColumns,
|
|
14
|
-
defaultColumns = [],
|
|
15
|
-
draggable = true,
|
|
16
|
-
columnDraggable = true,
|
|
17
|
-
enforceWipLimit = false,
|
|
18
|
-
beforeCardMove,
|
|
19
|
-
beforeColumnMove,
|
|
20
|
-
filterText = "",
|
|
21
|
-
hiddenColumns,
|
|
22
|
-
showCardCount = true,
|
|
23
|
-
allowAddCard = true,
|
|
24
|
-
allowAddColumn = false,
|
|
25
|
-
onCardMove,
|
|
26
|
-
onColumnMove,
|
|
27
|
-
onColumnsChange,
|
|
28
|
-
onCardAdd,
|
|
29
|
-
onColumnAdd,
|
|
30
|
-
renderCard,
|
|
31
|
-
renderColumnHeader,
|
|
32
|
-
className,
|
|
33
|
-
...restProps
|
|
34
|
-
}) => {
|
|
35
|
-
const boardRef = React.useRef(null);
|
|
36
|
-
const [rawColumns, setInternalColumns, isControlled] = chunkUKGQ7256_js.useControlledState(
|
|
37
|
-
controlledColumns,
|
|
38
|
-
defaultColumns
|
|
39
|
-
);
|
|
40
|
-
const visibleColumns = React.useMemo(
|
|
41
|
-
() => tigercatCore.filterColumns(rawColumns, filterText, hiddenColumns),
|
|
42
|
-
[rawColumns, filterText, hiddenColumns]
|
|
43
|
-
);
|
|
44
|
-
const [dragState, setDragState] = React.useState(null);
|
|
45
|
-
const [dropTargetCol, setDropTargetCol] = React.useState(null);
|
|
46
|
-
const [dropTargetIdx, setDropTargetIdx] = React.useState(-1);
|
|
47
|
-
function updateColumns(cols) {
|
|
48
|
-
if (!isControlled) setInternalColumns(cols);
|
|
49
|
-
onColumnsChange?.(cols);
|
|
50
|
-
}
|
|
51
|
-
function resetDrag() {
|
|
52
|
-
setDragState(null);
|
|
53
|
-
setDropTargetCol(null);
|
|
54
|
-
setDropTargetIdx(-1);
|
|
55
|
-
}
|
|
56
|
-
const handleCardDragStart = React.useCallback(
|
|
57
|
-
(e, card, colId, idx) => {
|
|
58
|
-
if (!draggable) return;
|
|
59
|
-
tigercatCore.setDragData(e.nativeEvent.dataTransfer, tigercatCore.createCardDragData(card.id, colId, idx));
|
|
60
|
-
setDragState({ type: "card", id: card.id, fromColumnId: colId, fromIndex: idx });
|
|
61
|
-
},
|
|
62
|
-
[draggable]
|
|
63
|
-
);
|
|
64
|
-
const handleColumnDragStart = React.useCallback(
|
|
65
|
-
(e, colId, idx) => {
|
|
66
|
-
if (!columnDraggable) return;
|
|
67
|
-
tigercatCore.setDragData(e.nativeEvent.dataTransfer, tigercatCore.createColumnDragData(colId, idx));
|
|
68
|
-
setDragState({ type: "column", id: colId, fromIndex: idx });
|
|
69
|
-
},
|
|
70
|
-
[columnDraggable]
|
|
71
|
-
);
|
|
72
|
-
const handleDragOver = React.useCallback(
|
|
73
|
-
(e, colId) => {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
if (!dragState) return;
|
|
76
|
-
setDropTargetCol(colId);
|
|
77
|
-
if (dragState.type === "card") {
|
|
78
|
-
const colEl = e.currentTarget.querySelector("[data-kanban-body]");
|
|
79
|
-
if (colEl) {
|
|
80
|
-
const cards = Array.from(colEl.querySelectorAll("[data-kanban-card]"));
|
|
81
|
-
const rects = cards.map((c) => c.getBoundingClientRect());
|
|
82
|
-
setDropTargetIdx(tigercatCore.getDropIndex(e.clientY, rects));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
[dragState]
|
|
87
|
-
);
|
|
88
|
-
const handleColumnDragOver = React.useCallback(
|
|
89
|
-
(e) => {
|
|
90
|
-
e.preventDefault();
|
|
91
|
-
if (!dragState || dragState.type !== "column") return;
|
|
92
|
-
const boardEl = boardRef.current;
|
|
93
|
-
if (!boardEl) return;
|
|
94
|
-
const cols = Array.from(boardEl.querySelectorAll("[data-kanban-column]"));
|
|
95
|
-
const rects = cols.map((c) => c.getBoundingClientRect());
|
|
96
|
-
setDropTargetIdx(tigercatCore.getColumnDropIndex(e.clientX, rects));
|
|
97
|
-
},
|
|
98
|
-
[dragState]
|
|
99
|
-
);
|
|
100
|
-
const handleDrop = React.useCallback(
|
|
101
|
-
async (e) => {
|
|
102
|
-
e.preventDefault();
|
|
103
|
-
const data = tigercatCore.parseDragData(e.nativeEvent.dataTransfer);
|
|
104
|
-
if (!data || !dragState) {
|
|
105
|
-
resetDrag();
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (data.type === "card" && dropTargetCol != null) {
|
|
109
|
-
if (beforeCardMove) {
|
|
110
|
-
const evt = {
|
|
111
|
-
cardId: data.cardId,
|
|
112
|
-
fromColumnId: data.columnId,
|
|
113
|
-
toColumnId: dropTargetCol,
|
|
114
|
-
fromIndex: data.index,
|
|
115
|
-
toIndex: dropTargetIdx
|
|
116
|
-
};
|
|
117
|
-
const ok = await beforeCardMove(evt);
|
|
118
|
-
if (!ok) {
|
|
119
|
-
resetDrag();
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
const result = tigercatCore.moveCard(
|
|
124
|
-
rawColumns,
|
|
125
|
-
data.cardId,
|
|
126
|
-
data.columnId,
|
|
127
|
-
dropTargetCol,
|
|
128
|
-
dropTargetIdx,
|
|
129
|
-
{ enforceWipLimit }
|
|
130
|
-
);
|
|
131
|
-
if (result) {
|
|
132
|
-
updateColumns(result.columns);
|
|
133
|
-
onCardMove?.(result.event);
|
|
134
|
-
}
|
|
135
|
-
} else if (data.type === "column") {
|
|
136
|
-
if (beforeColumnMove) {
|
|
137
|
-
const evt = {
|
|
138
|
-
columnId: data.columnId,
|
|
139
|
-
fromIndex: data.index,
|
|
140
|
-
toIndex: dropTargetIdx
|
|
141
|
-
};
|
|
142
|
-
const ok = await beforeColumnMove(evt);
|
|
143
|
-
if (!ok) {
|
|
144
|
-
resetDrag();
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
const result = tigercatCore.reorderColumns(rawColumns, data.index, dropTargetIdx);
|
|
149
|
-
if (result) {
|
|
150
|
-
updateColumns(result.columns);
|
|
151
|
-
onColumnMove?.(result.event);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
resetDrag();
|
|
155
|
-
},
|
|
156
|
-
[
|
|
157
|
-
dragState,
|
|
158
|
-
dropTargetCol,
|
|
159
|
-
dropTargetIdx,
|
|
160
|
-
rawColumns,
|
|
161
|
-
enforceWipLimit,
|
|
162
|
-
beforeCardMove,
|
|
163
|
-
beforeColumnMove,
|
|
164
|
-
onCardMove,
|
|
165
|
-
onColumnMove
|
|
166
|
-
]
|
|
167
|
-
);
|
|
168
|
-
const containerClasses = React.useMemo(
|
|
169
|
-
() => tigercatCore.classNames(tigercatCore.getKanbanContainerClasses(className)),
|
|
170
|
-
[className]
|
|
171
|
-
);
|
|
172
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
173
|
-
"div",
|
|
174
|
-
{
|
|
175
|
-
ref: boardRef,
|
|
176
|
-
className: containerClasses,
|
|
177
|
-
role: "region",
|
|
178
|
-
"aria-label": "Kanban board",
|
|
179
|
-
onDragOver: handleColumnDragOver,
|
|
180
|
-
...restProps,
|
|
181
|
-
children: [
|
|
182
|
-
visibleColumns.map((col, colIdx) => {
|
|
183
|
-
const wipExceeded = tigercatCore.isWipExceeded(col);
|
|
184
|
-
const cardCount = tigercatCore.getColumnCardCount(col);
|
|
185
|
-
const isDragOverCol = dropTargetCol === col.id;
|
|
186
|
-
const isColDragging = dragState?.type === "column" && dragState.id === col.id;
|
|
187
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
188
|
-
"div",
|
|
189
|
-
{
|
|
190
|
-
className: tigercatCore.classNames(
|
|
191
|
-
tigercatCore.taskBoardColumnClasses,
|
|
192
|
-
isDragOverCol && dragState?.type === "card" && tigercatCore.taskBoardColumnDropTargetClasses,
|
|
193
|
-
isColDragging && tigercatCore.taskBoardColumnDraggingClasses
|
|
194
|
-
),
|
|
195
|
-
"data-kanban-column": "",
|
|
196
|
-
draggable: columnDraggable,
|
|
197
|
-
onDragStart: (e) => handleColumnDragStart(e, col.id, colIdx),
|
|
198
|
-
onDragOver: (e) => handleDragOver(e, col.id),
|
|
199
|
-
onDrop: handleDrop,
|
|
200
|
-
onDragEnd: resetDrag,
|
|
201
|
-
children: [
|
|
202
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
203
|
-
"div",
|
|
204
|
-
{
|
|
205
|
-
className: tigercatCore.classNames(
|
|
206
|
-
tigercatCore.taskBoardColumnHeaderClasses,
|
|
207
|
-
wipExceeded && tigercatCore.taskBoardWipExceededClasses
|
|
208
|
-
),
|
|
209
|
-
children: [
|
|
210
|
-
renderColumnHeader ? renderColumnHeader(col) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: col.title }),
|
|
211
|
-
showCardCount && /* @__PURE__ */ jsxRuntime.jsx(
|
|
212
|
-
"span",
|
|
213
|
-
{
|
|
214
|
-
className: tigercatCore.classNames(
|
|
215
|
-
tigercatCore.kanbanCardCountClasses,
|
|
216
|
-
wipExceeded && tigercatCore.taskBoardWipExceededClasses
|
|
217
|
-
),
|
|
218
|
-
children: cardCount.limit ? `${cardCount.count}/${cardCount.limit}` : `${cardCount.count}`
|
|
219
|
-
}
|
|
220
|
-
)
|
|
221
|
-
]
|
|
222
|
-
}
|
|
223
|
-
),
|
|
224
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: tigercatCore.taskBoardColumnBodyClasses, "data-kanban-body": "", children: [
|
|
225
|
-
col.cards.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.taskBoardEmptyClasses, children: "No cards" }) : col.cards.map((card, cardIdx) => {
|
|
226
|
-
const isCardDragging = dragState?.type === "card" && dragState.id === card.id;
|
|
227
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(React__default.default.Fragment, { children: [
|
|
228
|
-
isDragOverCol && dragState?.type === "card" && dropTargetIdx === cardIdx && /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.taskBoardDropIndicatorClasses }),
|
|
229
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
230
|
-
"div",
|
|
231
|
-
{
|
|
232
|
-
className: tigercatCore.classNames(
|
|
233
|
-
tigercatCore.taskBoardCardClasses,
|
|
234
|
-
isCardDragging && tigercatCore.taskBoardCardDraggingClasses
|
|
235
|
-
),
|
|
236
|
-
draggable,
|
|
237
|
-
"data-kanban-card": "",
|
|
238
|
-
onDragStart: (e) => handleCardDragStart(e, card, col.id, cardIdx),
|
|
239
|
-
children: renderCard ? renderCard(card, col.id) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
240
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium text-sm", children: card.title }),
|
|
241
|
-
card.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-[var(--tiger-text-muted,#6b7280)] mt-1", children: card.description })
|
|
242
|
-
] })
|
|
243
|
-
}
|
|
244
|
-
)
|
|
245
|
-
] }, card.id);
|
|
246
|
-
}),
|
|
247
|
-
isDragOverCol && dragState?.type === "card" && dropTargetIdx >= col.cards.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.taskBoardDropIndicatorClasses })
|
|
248
|
-
] }),
|
|
249
|
-
allowAddCard && /* @__PURE__ */ jsxRuntime.jsx(
|
|
250
|
-
"div",
|
|
251
|
-
{
|
|
252
|
-
className: tigercatCore.kanbanAddCardClasses,
|
|
253
|
-
role: "button",
|
|
254
|
-
tabIndex: 0,
|
|
255
|
-
onClick: () => onCardAdd?.(col.id),
|
|
256
|
-
onKeyDown: (e) => {
|
|
257
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
258
|
-
e.preventDefault();
|
|
259
|
-
onCardAdd?.(col.id);
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
children: "+ Add card"
|
|
263
|
-
}
|
|
264
|
-
)
|
|
265
|
-
]
|
|
266
|
-
},
|
|
267
|
-
col.id
|
|
268
|
-
);
|
|
269
|
-
}),
|
|
270
|
-
allowAddColumn && /* @__PURE__ */ jsxRuntime.jsx(
|
|
271
|
-
"div",
|
|
272
|
-
{
|
|
273
|
-
className: tigercatCore.kanbanAddColumnClasses,
|
|
274
|
-
role: "button",
|
|
275
|
-
tabIndex: 0,
|
|
276
|
-
onClick: () => onColumnAdd?.(),
|
|
277
|
-
onKeyDown: (e) => {
|
|
278
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
279
|
-
e.preventDefault();
|
|
280
|
-
onColumnAdd?.();
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
children: "+ Add column"
|
|
284
|
-
}
|
|
285
|
-
)
|
|
286
|
-
]
|
|
287
|
-
}
|
|
288
|
-
);
|
|
289
|
-
};
|
|
290
|
-
var Kanban_default = Kanban;
|
|
291
|
-
|
|
292
|
-
exports.Kanban = Kanban;
|
|
293
|
-
exports.Kanban_default = Kanban_default;
|
package/dist/chunk-YXWRSEP5.mjs
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import { useControlledState } from './chunk-UQMPEMY7.mjs';
|
|
2
|
-
import React, { useRef, useMemo, useState, useCallback } from 'react';
|
|
3
|
-
import { filterColumns, setDragData, createCardDragData, createColumnDragData, getDropIndex, getColumnDropIndex, parseDragData, moveCard, reorderColumns, classNames, getKanbanContainerClasses, isWipExceeded, getColumnCardCount, kanbanCardCountClasses, taskBoardWipExceededClasses, taskBoardColumnHeaderClasses, taskBoardColumnBodyClasses, taskBoardEmptyClasses, taskBoardDropIndicatorClasses, taskBoardCardClasses, taskBoardCardDraggingClasses, kanbanAddCardClasses, taskBoardColumnClasses, taskBoardColumnDropTargetClasses, taskBoardColumnDraggingClasses, kanbanAddColumnClasses } from '@expcat/tigercat-core';
|
|
4
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
|
|
6
|
-
var Kanban = ({
|
|
7
|
-
columns: controlledColumns,
|
|
8
|
-
defaultColumns = [],
|
|
9
|
-
draggable = true,
|
|
10
|
-
columnDraggable = true,
|
|
11
|
-
enforceWipLimit = false,
|
|
12
|
-
beforeCardMove,
|
|
13
|
-
beforeColumnMove,
|
|
14
|
-
filterText = "",
|
|
15
|
-
hiddenColumns,
|
|
16
|
-
showCardCount = true,
|
|
17
|
-
allowAddCard = true,
|
|
18
|
-
allowAddColumn = false,
|
|
19
|
-
onCardMove,
|
|
20
|
-
onColumnMove,
|
|
21
|
-
onColumnsChange,
|
|
22
|
-
onCardAdd,
|
|
23
|
-
onColumnAdd,
|
|
24
|
-
renderCard,
|
|
25
|
-
renderColumnHeader,
|
|
26
|
-
className,
|
|
27
|
-
...restProps
|
|
28
|
-
}) => {
|
|
29
|
-
const boardRef = useRef(null);
|
|
30
|
-
const [rawColumns, setInternalColumns, isControlled] = useControlledState(
|
|
31
|
-
controlledColumns,
|
|
32
|
-
defaultColumns
|
|
33
|
-
);
|
|
34
|
-
const visibleColumns = useMemo(
|
|
35
|
-
() => filterColumns(rawColumns, filterText, hiddenColumns),
|
|
36
|
-
[rawColumns, filterText, hiddenColumns]
|
|
37
|
-
);
|
|
38
|
-
const [dragState, setDragState] = useState(null);
|
|
39
|
-
const [dropTargetCol, setDropTargetCol] = useState(null);
|
|
40
|
-
const [dropTargetIdx, setDropTargetIdx] = useState(-1);
|
|
41
|
-
function updateColumns(cols) {
|
|
42
|
-
if (!isControlled) setInternalColumns(cols);
|
|
43
|
-
onColumnsChange?.(cols);
|
|
44
|
-
}
|
|
45
|
-
function resetDrag() {
|
|
46
|
-
setDragState(null);
|
|
47
|
-
setDropTargetCol(null);
|
|
48
|
-
setDropTargetIdx(-1);
|
|
49
|
-
}
|
|
50
|
-
const handleCardDragStart = useCallback(
|
|
51
|
-
(e, card, colId, idx) => {
|
|
52
|
-
if (!draggable) return;
|
|
53
|
-
setDragData(e.nativeEvent.dataTransfer, createCardDragData(card.id, colId, idx));
|
|
54
|
-
setDragState({ type: "card", id: card.id, fromColumnId: colId, fromIndex: idx });
|
|
55
|
-
},
|
|
56
|
-
[draggable]
|
|
57
|
-
);
|
|
58
|
-
const handleColumnDragStart = useCallback(
|
|
59
|
-
(e, colId, idx) => {
|
|
60
|
-
if (!columnDraggable) return;
|
|
61
|
-
setDragData(e.nativeEvent.dataTransfer, createColumnDragData(colId, idx));
|
|
62
|
-
setDragState({ type: "column", id: colId, fromIndex: idx });
|
|
63
|
-
},
|
|
64
|
-
[columnDraggable]
|
|
65
|
-
);
|
|
66
|
-
const handleDragOver = useCallback(
|
|
67
|
-
(e, colId) => {
|
|
68
|
-
e.preventDefault();
|
|
69
|
-
if (!dragState) return;
|
|
70
|
-
setDropTargetCol(colId);
|
|
71
|
-
if (dragState.type === "card") {
|
|
72
|
-
const colEl = e.currentTarget.querySelector("[data-kanban-body]");
|
|
73
|
-
if (colEl) {
|
|
74
|
-
const cards = Array.from(colEl.querySelectorAll("[data-kanban-card]"));
|
|
75
|
-
const rects = cards.map((c) => c.getBoundingClientRect());
|
|
76
|
-
setDropTargetIdx(getDropIndex(e.clientY, rects));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
[dragState]
|
|
81
|
-
);
|
|
82
|
-
const handleColumnDragOver = useCallback(
|
|
83
|
-
(e) => {
|
|
84
|
-
e.preventDefault();
|
|
85
|
-
if (!dragState || dragState.type !== "column") return;
|
|
86
|
-
const boardEl = boardRef.current;
|
|
87
|
-
if (!boardEl) return;
|
|
88
|
-
const cols = Array.from(boardEl.querySelectorAll("[data-kanban-column]"));
|
|
89
|
-
const rects = cols.map((c) => c.getBoundingClientRect());
|
|
90
|
-
setDropTargetIdx(getColumnDropIndex(e.clientX, rects));
|
|
91
|
-
},
|
|
92
|
-
[dragState]
|
|
93
|
-
);
|
|
94
|
-
const handleDrop = useCallback(
|
|
95
|
-
async (e) => {
|
|
96
|
-
e.preventDefault();
|
|
97
|
-
const data = parseDragData(e.nativeEvent.dataTransfer);
|
|
98
|
-
if (!data || !dragState) {
|
|
99
|
-
resetDrag();
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (data.type === "card" && dropTargetCol != null) {
|
|
103
|
-
if (beforeCardMove) {
|
|
104
|
-
const evt = {
|
|
105
|
-
cardId: data.cardId,
|
|
106
|
-
fromColumnId: data.columnId,
|
|
107
|
-
toColumnId: dropTargetCol,
|
|
108
|
-
fromIndex: data.index,
|
|
109
|
-
toIndex: dropTargetIdx
|
|
110
|
-
};
|
|
111
|
-
const ok = await beforeCardMove(evt);
|
|
112
|
-
if (!ok) {
|
|
113
|
-
resetDrag();
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const result = moveCard(
|
|
118
|
-
rawColumns,
|
|
119
|
-
data.cardId,
|
|
120
|
-
data.columnId,
|
|
121
|
-
dropTargetCol,
|
|
122
|
-
dropTargetIdx,
|
|
123
|
-
{ enforceWipLimit }
|
|
124
|
-
);
|
|
125
|
-
if (result) {
|
|
126
|
-
updateColumns(result.columns);
|
|
127
|
-
onCardMove?.(result.event);
|
|
128
|
-
}
|
|
129
|
-
} else if (data.type === "column") {
|
|
130
|
-
if (beforeColumnMove) {
|
|
131
|
-
const evt = {
|
|
132
|
-
columnId: data.columnId,
|
|
133
|
-
fromIndex: data.index,
|
|
134
|
-
toIndex: dropTargetIdx
|
|
135
|
-
};
|
|
136
|
-
const ok = await beforeColumnMove(evt);
|
|
137
|
-
if (!ok) {
|
|
138
|
-
resetDrag();
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
const result = reorderColumns(rawColumns, data.index, dropTargetIdx);
|
|
143
|
-
if (result) {
|
|
144
|
-
updateColumns(result.columns);
|
|
145
|
-
onColumnMove?.(result.event);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
resetDrag();
|
|
149
|
-
},
|
|
150
|
-
[
|
|
151
|
-
dragState,
|
|
152
|
-
dropTargetCol,
|
|
153
|
-
dropTargetIdx,
|
|
154
|
-
rawColumns,
|
|
155
|
-
enforceWipLimit,
|
|
156
|
-
beforeCardMove,
|
|
157
|
-
beforeColumnMove,
|
|
158
|
-
onCardMove,
|
|
159
|
-
onColumnMove
|
|
160
|
-
]
|
|
161
|
-
);
|
|
162
|
-
const containerClasses = useMemo(
|
|
163
|
-
() => classNames(getKanbanContainerClasses(className)),
|
|
164
|
-
[className]
|
|
165
|
-
);
|
|
166
|
-
return /* @__PURE__ */ jsxs(
|
|
167
|
-
"div",
|
|
168
|
-
{
|
|
169
|
-
ref: boardRef,
|
|
170
|
-
className: containerClasses,
|
|
171
|
-
role: "region",
|
|
172
|
-
"aria-label": "Kanban board",
|
|
173
|
-
onDragOver: handleColumnDragOver,
|
|
174
|
-
...restProps,
|
|
175
|
-
children: [
|
|
176
|
-
visibleColumns.map((col, colIdx) => {
|
|
177
|
-
const wipExceeded = isWipExceeded(col);
|
|
178
|
-
const cardCount = getColumnCardCount(col);
|
|
179
|
-
const isDragOverCol = dropTargetCol === col.id;
|
|
180
|
-
const isColDragging = dragState?.type === "column" && dragState.id === col.id;
|
|
181
|
-
return /* @__PURE__ */ jsxs(
|
|
182
|
-
"div",
|
|
183
|
-
{
|
|
184
|
-
className: classNames(
|
|
185
|
-
taskBoardColumnClasses,
|
|
186
|
-
isDragOverCol && dragState?.type === "card" && taskBoardColumnDropTargetClasses,
|
|
187
|
-
isColDragging && taskBoardColumnDraggingClasses
|
|
188
|
-
),
|
|
189
|
-
"data-kanban-column": "",
|
|
190
|
-
draggable: columnDraggable,
|
|
191
|
-
onDragStart: (e) => handleColumnDragStart(e, col.id, colIdx),
|
|
192
|
-
onDragOver: (e) => handleDragOver(e, col.id),
|
|
193
|
-
onDrop: handleDrop,
|
|
194
|
-
onDragEnd: resetDrag,
|
|
195
|
-
children: [
|
|
196
|
-
/* @__PURE__ */ jsxs(
|
|
197
|
-
"div",
|
|
198
|
-
{
|
|
199
|
-
className: classNames(
|
|
200
|
-
taskBoardColumnHeaderClasses,
|
|
201
|
-
wipExceeded && taskBoardWipExceededClasses
|
|
202
|
-
),
|
|
203
|
-
children: [
|
|
204
|
-
renderColumnHeader ? renderColumnHeader(col) : /* @__PURE__ */ jsx("span", { children: col.title }),
|
|
205
|
-
showCardCount && /* @__PURE__ */ jsx(
|
|
206
|
-
"span",
|
|
207
|
-
{
|
|
208
|
-
className: classNames(
|
|
209
|
-
kanbanCardCountClasses,
|
|
210
|
-
wipExceeded && taskBoardWipExceededClasses
|
|
211
|
-
),
|
|
212
|
-
children: cardCount.limit ? `${cardCount.count}/${cardCount.limit}` : `${cardCount.count}`
|
|
213
|
-
}
|
|
214
|
-
)
|
|
215
|
-
]
|
|
216
|
-
}
|
|
217
|
-
),
|
|
218
|
-
/* @__PURE__ */ jsxs("div", { className: taskBoardColumnBodyClasses, "data-kanban-body": "", children: [
|
|
219
|
-
col.cards.length === 0 ? /* @__PURE__ */ jsx("div", { className: taskBoardEmptyClasses, children: "No cards" }) : col.cards.map((card, cardIdx) => {
|
|
220
|
-
const isCardDragging = dragState?.type === "card" && dragState.id === card.id;
|
|
221
|
-
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
222
|
-
isDragOverCol && dragState?.type === "card" && dropTargetIdx === cardIdx && /* @__PURE__ */ jsx("div", { className: taskBoardDropIndicatorClasses }),
|
|
223
|
-
/* @__PURE__ */ jsx(
|
|
224
|
-
"div",
|
|
225
|
-
{
|
|
226
|
-
className: classNames(
|
|
227
|
-
taskBoardCardClasses,
|
|
228
|
-
isCardDragging && taskBoardCardDraggingClasses
|
|
229
|
-
),
|
|
230
|
-
draggable,
|
|
231
|
-
"data-kanban-card": "",
|
|
232
|
-
onDragStart: (e) => handleCardDragStart(e, card, col.id, cardIdx),
|
|
233
|
-
children: renderCard ? renderCard(card, col.id) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
234
|
-
/* @__PURE__ */ jsx("div", { className: "font-medium text-sm", children: card.title }),
|
|
235
|
-
card.description && /* @__PURE__ */ jsx("div", { className: "text-xs text-[var(--tiger-text-muted,#6b7280)] mt-1", children: card.description })
|
|
236
|
-
] })
|
|
237
|
-
}
|
|
238
|
-
)
|
|
239
|
-
] }, card.id);
|
|
240
|
-
}),
|
|
241
|
-
isDragOverCol && dragState?.type === "card" && dropTargetIdx >= col.cards.length && /* @__PURE__ */ jsx("div", { className: taskBoardDropIndicatorClasses })
|
|
242
|
-
] }),
|
|
243
|
-
allowAddCard && /* @__PURE__ */ jsx(
|
|
244
|
-
"div",
|
|
245
|
-
{
|
|
246
|
-
className: kanbanAddCardClasses,
|
|
247
|
-
role: "button",
|
|
248
|
-
tabIndex: 0,
|
|
249
|
-
onClick: () => onCardAdd?.(col.id),
|
|
250
|
-
onKeyDown: (e) => {
|
|
251
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
252
|
-
e.preventDefault();
|
|
253
|
-
onCardAdd?.(col.id);
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
children: "+ Add card"
|
|
257
|
-
}
|
|
258
|
-
)
|
|
259
|
-
]
|
|
260
|
-
},
|
|
261
|
-
col.id
|
|
262
|
-
);
|
|
263
|
-
}),
|
|
264
|
-
allowAddColumn && /* @__PURE__ */ jsx(
|
|
265
|
-
"div",
|
|
266
|
-
{
|
|
267
|
-
className: kanbanAddColumnClasses,
|
|
268
|
-
role: "button",
|
|
269
|
-
tabIndex: 0,
|
|
270
|
-
onClick: () => onColumnAdd?.(),
|
|
271
|
-
onKeyDown: (e) => {
|
|
272
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
273
|
-
e.preventDefault();
|
|
274
|
-
onColumnAdd?.();
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
children: "+ Add column"
|
|
278
|
-
}
|
|
279
|
-
)
|
|
280
|
-
]
|
|
281
|
-
}
|
|
282
|
-
);
|
|
283
|
-
};
|
|
284
|
-
var Kanban_default = Kanban;
|
|
285
|
-
|
|
286
|
-
export { Kanban, Kanban_default };
|