@object-ui/plugin-kanban 3.1.2 → 3.1.4

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.
@@ -1,908 +0,0 @@
1
- import { c as U, j as a, C as Q, P as X } from "./index-CyNcIIS1.js";
2
- import * as v from "react";
3
- import { flushSync as Z } from "react-dom";
4
- import { u as ee, a as te, D as se, c as ne, b as ie, d as re, P as oe, e as Y, S as le, v as ae, C as ce } from "./sortable.esm-CNNHgHk5.js";
5
- import { Button as G, Badge as L, Card as de, CardHeader as he, CardTitle as ue, CardDescription as fe, CardContent as me, Input as ge } from "@object-ui/components";
6
- const pe = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], ve = U("chevron-right", pe);
7
- const xe = [
8
- [
9
- "path",
10
- {
11
- d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
12
- key: "wmoenq"
13
- }
14
- ],
15
- ["path", { d: "M12 9v4", key: "juzpu7" }],
16
- ["path", { d: "M12 17h.01", key: "p32p05" }]
17
- ], be = U("triangle-alert", xe);
18
- function A(n, l, e) {
19
- let s = e.initialDeps ?? [], t, i = !0;
20
- function o() {
21
- var r, d, h;
22
- let u;
23
- e.key && ((r = e.debug) != null && r.call(e)) && (u = Date.now());
24
- const m = n();
25
- if (!(m.length !== s.length || m.some((w, p) => s[p] !== w)))
26
- return t;
27
- s = m;
28
- let g;
29
- if (e.key && ((d = e.debug) != null && d.call(e)) && (g = Date.now()), t = l(...m), e.key && ((h = e.debug) != null && h.call(e))) {
30
- const w = Math.round((Date.now() - u) * 100) / 100, p = Math.round((Date.now() - g) * 100) / 100, E = p / 16, z = (C, D) => {
31
- for (C = String(C); C.length < D; )
32
- C = " " + C;
33
- return C;
34
- };
35
- console.info(
36
- `%c⏱ ${z(p, 5)} /${z(w, 5)} ms`,
37
- `
38
- font-size: .6rem;
39
- font-weight: bold;
40
- color: hsl(${Math.max(
41
- 0,
42
- Math.min(120 - 120 * E, 120)
43
- )}deg 100% 31%);`,
44
- e?.key
45
- );
46
- }
47
- return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(t), i = !1, t;
48
- }
49
- return o.updateDeps = (r) => {
50
- s = r;
51
- }, o;
52
- }
53
- function P(n, l) {
54
- if (n === void 0)
55
- throw new Error("Unexpected undefined");
56
- return n;
57
- }
58
- const Ce = (n, l) => Math.abs(n - l) < 1.01, ye = (n, l, e) => {
59
- let s;
60
- return function(...t) {
61
- n.clearTimeout(s), s = n.setTimeout(() => l.apply(this, t), e);
62
- };
63
- }, H = (n) => {
64
- const { offsetWidth: l, offsetHeight: e } = n;
65
- return { width: l, height: e };
66
- }, we = (n) => n, Se = (n) => {
67
- const l = Math.max(n.startIndex - n.overscan, 0), e = Math.min(n.endIndex + n.overscan, n.count - 1), s = [];
68
- for (let t = l; t <= e; t++)
69
- s.push(t);
70
- return s;
71
- }, Ee = (n, l) => {
72
- const e = n.scrollElement;
73
- if (!e)
74
- return;
75
- const s = n.targetWindow;
76
- if (!s)
77
- return;
78
- const t = (o) => {
79
- const { width: r, height: d } = o;
80
- l({ width: Math.round(r), height: Math.round(d) });
81
- };
82
- if (t(H(e)), !s.ResizeObserver)
83
- return () => {
84
- };
85
- const i = new s.ResizeObserver((o) => {
86
- const r = () => {
87
- const d = o[0];
88
- if (d?.borderBoxSize) {
89
- const h = d.borderBoxSize[0];
90
- if (h) {
91
- t({ width: h.inlineSize, height: h.blockSize });
92
- return;
93
- }
94
- }
95
- t(H(e));
96
- };
97
- n.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(r) : r();
98
- });
99
- return i.observe(e, { box: "border-box" }), () => {
100
- i.unobserve(e);
101
- };
102
- }, $ = {
103
- passive: !0
104
- }, q = typeof window > "u" ? !0 : "onscrollend" in window, Ie = (n, l) => {
105
- const e = n.scrollElement;
106
- if (!e)
107
- return;
108
- const s = n.targetWindow;
109
- if (!s)
110
- return;
111
- let t = 0;
112
- const i = n.options.useScrollendEvent && q ? () => {
113
- } : ye(
114
- s,
115
- () => {
116
- l(t, !1);
117
- },
118
- n.options.isScrollingResetDelay
119
- ), o = (u) => () => {
120
- const { horizontal: m, isRtl: c } = n.options;
121
- t = m ? e.scrollLeft * (c && -1 || 1) : e.scrollTop, i(), l(t, u);
122
- }, r = o(!0), d = o(!1);
123
- e.addEventListener("scroll", r, $);
124
- const h = n.options.useScrollendEvent && q;
125
- return h && e.addEventListener("scrollend", d, $), () => {
126
- e.removeEventListener("scroll", r), h && e.removeEventListener("scrollend", d);
127
- };
128
- }, ze = (n, l, e) => {
129
- if (l?.borderBoxSize) {
130
- const s = l.borderBoxSize[0];
131
- if (s)
132
- return Math.round(
133
- s[e.options.horizontal ? "inlineSize" : "blockSize"]
134
- );
135
- }
136
- return n[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
137
- }, Me = (n, {
138
- adjustments: l = 0,
139
- behavior: e
140
- }, s) => {
141
- var t, i;
142
- const o = n + l;
143
- (i = (t = s.scrollElement) == null ? void 0 : t.scrollTo) == null || i.call(t, {
144
- [s.options.horizontal ? "left" : "top"]: o,
145
- behavior: e
146
- });
147
- };
148
- class Oe {
149
- constructor(l) {
150
- this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.currentScrollToIndex = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.prevLanes = void 0, this.lanesChangedFlag = !1, this.lanesSettling = !1, this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
151
- let e = null;
152
- const s = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((t) => {
153
- t.forEach((i) => {
154
- const o = () => {
155
- this._measureElement(i.target, i);
156
- };
157
- this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(o) : o();
158
- });
159
- }));
160
- return {
161
- disconnect: () => {
162
- var t;
163
- (t = s()) == null || t.disconnect(), e = null;
164
- },
165
- observe: (t) => {
166
- var i;
167
- return (i = s()) == null ? void 0 : i.observe(t, { box: "border-box" });
168
- },
169
- unobserve: (t) => {
170
- var i;
171
- return (i = s()) == null ? void 0 : i.unobserve(t);
172
- }
173
- };
174
- })(), this.range = null, this.setOptions = (e) => {
175
- Object.entries(e).forEach(([s, t]) => {
176
- typeof t > "u" && delete e[s];
177
- }), this.options = {
178
- debug: !1,
179
- initialOffset: 0,
180
- overscan: 1,
181
- paddingStart: 0,
182
- paddingEnd: 0,
183
- scrollPaddingStart: 0,
184
- scrollPaddingEnd: 0,
185
- horizontal: !1,
186
- getItemKey: we,
187
- rangeExtractor: Se,
188
- onChange: () => {
189
- },
190
- measureElement: ze,
191
- initialRect: { width: 0, height: 0 },
192
- scrollMargin: 0,
193
- gap: 0,
194
- indexAttribute: "data-index",
195
- initialMeasurementsCache: [],
196
- lanes: 1,
197
- isScrollingResetDelay: 150,
198
- enabled: !0,
199
- isRtl: !1,
200
- useScrollendEvent: !1,
201
- useAnimationFrameWithResizeObserver: !1,
202
- ...e
203
- };
204
- }, this.notify = (e) => {
205
- var s, t;
206
- (t = (s = this.options).onChange) == null || t.call(s, this, e);
207
- }, this.maybeNotify = A(
208
- () => (this.calculateRange(), [
209
- this.isScrolling,
210
- this.range ? this.range.startIndex : null,
211
- this.range ? this.range.endIndex : null
212
- ]),
213
- (e) => {
214
- this.notify(e);
215
- },
216
- {
217
- key: process.env.NODE_ENV !== "production" && "maybeNotify",
218
- debug: () => this.options.debug,
219
- initialDeps: [
220
- this.isScrolling,
221
- this.range ? this.range.startIndex : null,
222
- this.range ? this.range.endIndex : null
223
- ]
224
- }
225
- ), this.cleanup = () => {
226
- this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
227
- }, this._didMount = () => () => {
228
- this.cleanup();
229
- }, this._willUpdate = () => {
230
- var e;
231
- const s = this.options.enabled ? this.options.getScrollElement() : null;
232
- if (this.scrollElement !== s) {
233
- if (this.cleanup(), !s) {
234
- this.maybeNotify();
235
- return;
236
- }
237
- this.scrollElement = s, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((e = this.scrollElement) == null ? void 0 : e.window) ?? null, this.elementsCache.forEach((t) => {
238
- this.observer.observe(t);
239
- }), this.unsubs.push(
240
- this.options.observeElementRect(this, (t) => {
241
- this.scrollRect = t, this.maybeNotify();
242
- })
243
- ), this.unsubs.push(
244
- this.options.observeElementOffset(this, (t, i) => {
245
- this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < t ? "forward" : "backward" : null, this.scrollOffset = t, this.isScrolling = i, this.maybeNotify();
246
- })
247
- ), this._scrollToOffset(this.getScrollOffset(), {
248
- adjustments: void 0,
249
- behavior: void 0
250
- });
251
- }
252
- }, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (e, s) => {
253
- const t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
254
- for (let o = s - 1; o >= 0; o--) {
255
- const r = e[o];
256
- if (t.has(r.lane))
257
- continue;
258
- const d = i.get(
259
- r.lane
260
- );
261
- if (d == null || r.end > d.end ? i.set(r.lane, r) : r.end < d.end && t.set(r.lane, !0), t.size === this.options.lanes)
262
- break;
263
- }
264
- return i.size === this.options.lanes ? Array.from(i.values()).sort((o, r) => o.end === r.end ? o.index - r.index : o.end - r.end)[0] : void 0;
265
- }, this.getMeasurementOptions = A(
266
- () => [
267
- this.options.count,
268
- this.options.paddingStart,
269
- this.options.scrollMargin,
270
- this.options.getItemKey,
271
- this.options.enabled,
272
- this.options.lanes
273
- ],
274
- (e, s, t, i, o, r) => (this.prevLanes !== void 0 && this.prevLanes !== r && (this.lanesChangedFlag = !0), this.prevLanes = r, this.pendingMeasuredCacheIndexes = [], {
275
- count: e,
276
- paddingStart: s,
277
- scrollMargin: t,
278
- getItemKey: i,
279
- enabled: o,
280
- lanes: r
281
- }),
282
- {
283
- key: !1
284
- }
285
- ), this.getMeasurements = A(
286
- () => [this.getMeasurementOptions(), this.itemSizeCache],
287
- ({ count: e, paddingStart: s, scrollMargin: t, getItemKey: i, enabled: o, lanes: r }, d) => {
288
- if (!o)
289
- return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
290
- if (this.laneAssignments.size > e)
291
- for (const c of this.laneAssignments.keys())
292
- c >= e && this.laneAssignments.delete(c);
293
- this.lanesChangedFlag && (this.lanesChangedFlag = !1, this.lanesSettling = !0, this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), this.pendingMeasuredCacheIndexes = []), this.measurementsCache.length === 0 && !this.lanesSettling && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((c) => {
294
- this.itemSizeCache.set(c.key, c.size);
295
- }));
296
- const h = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
297
- this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
298
- const u = this.measurementsCache.slice(0, h), m = new Array(r).fill(
299
- void 0
300
- );
301
- for (let c = 0; c < h; c++) {
302
- const g = u[c];
303
- g && (m[g.lane] = c);
304
- }
305
- for (let c = h; c < e; c++) {
306
- const g = i(c), w = this.laneAssignments.get(c);
307
- let p, E;
308
- if (w !== void 0 && this.options.lanes > 1) {
309
- p = w;
310
- const S = m[p], f = S !== void 0 ? u[S] : void 0;
311
- E = f ? f.end + this.options.gap : s + t;
312
- } else {
313
- const S = this.options.lanes === 1 ? u[c - 1] : this.getFurthestMeasurement(u, c);
314
- E = S ? S.end + this.options.gap : s + t, p = S ? S.lane : c % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(c, p);
315
- }
316
- const z = d.get(g), C = typeof z == "number" ? z : this.options.estimateSize(c), D = E + C;
317
- u[c] = {
318
- index: c,
319
- start: E,
320
- size: C,
321
- end: D,
322
- key: g,
323
- lane: p
324
- }, m[p] = c;
325
- }
326
- return this.measurementsCache = u, u;
327
- },
328
- {
329
- key: process.env.NODE_ENV !== "production" && "getMeasurements",
330
- debug: () => this.options.debug
331
- }
332
- ), this.calculateRange = A(
333
- () => [
334
- this.getMeasurements(),
335
- this.getSize(),
336
- this.getScrollOffset(),
337
- this.options.lanes
338
- ],
339
- (e, s, t, i) => this.range = e.length > 0 && s > 0 ? je({
340
- measurements: e,
341
- outerSize: s,
342
- scrollOffset: t,
343
- lanes: i
344
- }) : null,
345
- {
346
- key: process.env.NODE_ENV !== "production" && "calculateRange",
347
- debug: () => this.options.debug
348
- }
349
- ), this.getVirtualIndexes = A(
350
- () => {
351
- let e = null, s = null;
352
- const t = this.calculateRange();
353
- return t && (e = t.startIndex, s = t.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, s]), [
354
- this.options.rangeExtractor,
355
- this.options.overscan,
356
- this.options.count,
357
- e,
358
- s
359
- ];
360
- },
361
- (e, s, t, i, o) => i === null || o === null ? [] : e({
362
- startIndex: i,
363
- endIndex: o,
364
- overscan: s,
365
- count: t
366
- }),
367
- {
368
- key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
369
- debug: () => this.options.debug
370
- }
371
- ), this.indexFromElement = (e) => {
372
- const s = this.options.indexAttribute, t = e.getAttribute(s);
373
- return t ? parseInt(t, 10) : (console.warn(
374
- `Missing attribute name '${s}={index}' on measured element.`
375
- ), -1);
376
- }, this._measureElement = (e, s) => {
377
- const t = this.indexFromElement(e), i = this.measurementsCache[t];
378
- if (!i)
379
- return;
380
- const o = i.key, r = this.elementsCache.get(o);
381
- r !== e && (r && this.observer.unobserve(r), this.observer.observe(e), this.elementsCache.set(o, e)), e.isConnected && this.resizeItem(t, this.options.measureElement(e, s, this));
382
- }, this.resizeItem = (e, s) => {
383
- const t = this.measurementsCache[e];
384
- if (!t)
385
- return;
386
- const i = this.itemSizeCache.get(t.key) ?? t.size, o = s - i;
387
- o !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(t, o, this) : t.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", o), this._scrollToOffset(this.getScrollOffset(), {
388
- adjustments: this.scrollAdjustments += o,
389
- behavior: void 0
390
- })), this.pendingMeasuredCacheIndexes.push(t.index), this.itemSizeCache = new Map(this.itemSizeCache.set(t.key, s)), this.notify(!1));
391
- }, this.measureElement = (e) => {
392
- if (!e) {
393
- this.elementsCache.forEach((s, t) => {
394
- s.isConnected || (this.observer.unobserve(s), this.elementsCache.delete(t));
395
- });
396
- return;
397
- }
398
- this._measureElement(e, void 0);
399
- }, this.getVirtualItems = A(
400
- () => [this.getVirtualIndexes(), this.getMeasurements()],
401
- (e, s) => {
402
- const t = [];
403
- for (let i = 0, o = e.length; i < o; i++) {
404
- const r = e[i], d = s[r];
405
- t.push(d);
406
- }
407
- return t;
408
- },
409
- {
410
- key: process.env.NODE_ENV !== "production" && "getVirtualItems",
411
- debug: () => this.options.debug
412
- }
413
- ), this.getVirtualItemForOffset = (e) => {
414
- const s = this.getMeasurements();
415
- if (s.length !== 0)
416
- return P(
417
- s[J(
418
- 0,
419
- s.length - 1,
420
- (t) => P(s[t]).start,
421
- e
422
- )]
423
- );
424
- }, this.getMaxScrollOffset = () => {
425
- if (!this.scrollElement) return 0;
426
- if ("scrollHeight" in this.scrollElement)
427
- return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
428
- {
429
- const e = this.scrollElement.document.documentElement;
430
- return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
431
- }
432
- }, this.getOffsetForAlignment = (e, s, t = 0) => {
433
- if (!this.scrollElement) return 0;
434
- const i = this.getSize(), o = this.getScrollOffset();
435
- s === "auto" && (s = e >= o + i ? "end" : "start"), s === "center" ? e += (t - i) / 2 : s === "end" && (e -= i);
436
- const r = this.getMaxScrollOffset();
437
- return Math.max(Math.min(r, e), 0);
438
- }, this.getOffsetForIndex = (e, s = "auto") => {
439
- e = Math.max(0, Math.min(e, this.options.count - 1));
440
- const t = this.measurementsCache[e];
441
- if (!t)
442
- return;
443
- const i = this.getSize(), o = this.getScrollOffset();
444
- if (s === "auto")
445
- if (t.end >= o + i - this.options.scrollPaddingEnd)
446
- s = "end";
447
- else if (t.start <= o + this.options.scrollPaddingStart)
448
- s = "start";
449
- else
450
- return [o, s];
451
- if (s === "end" && e === this.options.count - 1)
452
- return [this.getMaxScrollOffset(), s];
453
- const r = s === "end" ? t.end + this.options.scrollPaddingEnd : t.start - this.options.scrollPaddingStart;
454
- return [
455
- this.getOffsetForAlignment(r, s, t.size),
456
- s
457
- ];
458
- }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: s = "start", behavior: t } = {}) => {
459
- t === "smooth" && this.isDynamicMode() && console.warn(
460
- "The `smooth` scroll behavior is not fully supported with dynamic size."
461
- ), this._scrollToOffset(this.getOffsetForAlignment(e, s), {
462
- adjustments: void 0,
463
- behavior: t
464
- });
465
- }, this.scrollToIndex = (e, { align: s = "auto", behavior: t } = {}) => {
466
- t === "smooth" && this.isDynamicMode() && console.warn(
467
- "The `smooth` scroll behavior is not fully supported with dynamic size."
468
- ), e = Math.max(0, Math.min(e, this.options.count - 1)), this.currentScrollToIndex = e;
469
- let i = 0;
470
- const o = 10, r = (h) => {
471
- if (!this.targetWindow) return;
472
- const u = this.getOffsetForIndex(e, h);
473
- if (!u) {
474
- console.warn("Failed to get offset for index:", e);
475
- return;
476
- }
477
- const [m, c] = u;
478
- this._scrollToOffset(m, { adjustments: void 0, behavior: t }), this.targetWindow.requestAnimationFrame(() => {
479
- if (!this.targetWindow) return;
480
- const g = () => {
481
- if (this.currentScrollToIndex !== e) return;
482
- const w = this.getScrollOffset(), p = this.getOffsetForIndex(e, c);
483
- if (!p) {
484
- console.warn("Failed to get offset for index:", e);
485
- return;
486
- }
487
- Ce(p[0], w) || d(c);
488
- };
489
- this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(g) : g();
490
- });
491
- }, d = (h) => {
492
- this.targetWindow && this.currentScrollToIndex === e && (i++, i < o ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", i, o), this.targetWindow.requestAnimationFrame(() => r(h))) : console.warn(
493
- `Failed to scroll to index ${e} after ${o} attempts.`
494
- ));
495
- };
496
- r(s);
497
- }, this.scrollBy = (e, { behavior: s } = {}) => {
498
- s === "smooth" && this.isDynamicMode() && console.warn(
499
- "The `smooth` scroll behavior is not fully supported with dynamic size."
500
- ), this._scrollToOffset(this.getScrollOffset() + e, {
501
- adjustments: void 0,
502
- behavior: s
503
- });
504
- }, this.getTotalSize = () => {
505
- var e;
506
- const s = this.getMeasurements();
507
- let t;
508
- if (s.length === 0)
509
- t = this.options.paddingStart;
510
- else if (this.options.lanes === 1)
511
- t = ((e = s[s.length - 1]) == null ? void 0 : e.end) ?? 0;
512
- else {
513
- const i = Array(this.options.lanes).fill(null);
514
- let o = s.length - 1;
515
- for (; o >= 0 && i.some((r) => r === null); ) {
516
- const r = s[o];
517
- i[r.lane] === null && (i[r.lane] = r.end), o--;
518
- }
519
- t = Math.max(...i.filter((r) => r !== null));
520
- }
521
- return Math.max(
522
- t - this.options.scrollMargin + this.options.paddingEnd,
523
- 0
524
- );
525
- }, this._scrollToOffset = (e, {
526
- adjustments: s,
527
- behavior: t
528
- }) => {
529
- this.options.scrollToFn(e, { behavior: t, adjustments: s }, this);
530
- }, this.measure = () => {
531
- this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
532
- }, this.setOptions(l);
533
- }
534
- }
535
- const J = (n, l, e, s) => {
536
- for (; n <= l; ) {
537
- const t = (n + l) / 2 | 0, i = e(t);
538
- if (i < s)
539
- n = t + 1;
540
- else if (i > s)
541
- l = t - 1;
542
- else
543
- return t;
544
- }
545
- return n > 0 ? n - 1 : 0;
546
- };
547
- function je({
548
- measurements: n,
549
- outerSize: l,
550
- scrollOffset: e,
551
- lanes: s
552
- }) {
553
- const t = n.length - 1, i = (d) => n[d].start;
554
- if (n.length <= s)
555
- return {
556
- startIndex: 0,
557
- endIndex: t
558
- };
559
- let o = J(
560
- 0,
561
- t,
562
- i,
563
- e
564
- ), r = o;
565
- if (s === 1)
566
- for (; r < t && n[r].end < e + l; )
567
- r++;
568
- else if (s > 1) {
569
- const d = Array(s).fill(0);
570
- for (; r < t && d.some((u) => u < e + l); ) {
571
- const u = n[r];
572
- d[u.lane] = u.end, r++;
573
- }
574
- const h = Array(s).fill(e + l);
575
- for (; o >= 0 && h.some((u) => u >= e); ) {
576
- const u = n[o];
577
- h[u.lane] = u.start, o--;
578
- }
579
- o = Math.max(0, o - o % s), r = Math.min(t, r + (s - 1 - r % s));
580
- }
581
- return { startIndex: o, endIndex: r };
582
- }
583
- const K = typeof document < "u" ? v.useLayoutEffect : v.useEffect;
584
- function Ne({
585
- useFlushSync: n = !0,
586
- ...l
587
- }) {
588
- const e = v.useReducer(() => ({}), {})[1], s = {
589
- ...l,
590
- onChange: (i, o) => {
591
- var r;
592
- n && o ? Z(e) : e(), (r = l.onChange) == null || r.call(l, i, o);
593
- }
594
- }, [t] = v.useState(
595
- () => new Oe(s)
596
- );
597
- return t.setOptions(s), K(() => t._didMount(), []), K(() => t._willUpdate()), t;
598
- }
599
- function ke(n) {
600
- return Ne({
601
- observeElementRect: Ee,
602
- observeElementOffset: Ie,
603
- scrollToFn: Me,
604
- ...n
605
- });
606
- }
607
- const V = (...n) => n.filter(Boolean).join(" ");
608
- function Ae(n, l) {
609
- if (!l || l.length === 0) return {};
610
- for (const e of l) {
611
- const s = n[e.field];
612
- if (s == null) continue;
613
- let t = !1;
614
- const i = String(s);
615
- switch (e.operator) {
616
- case "equals":
617
- t = i === String(e.value);
618
- break;
619
- case "not_equals":
620
- t = i !== String(e.value);
621
- break;
622
- case "contains":
623
- t = i.toLowerCase().includes(String(e.value).toLowerCase());
624
- break;
625
- case "in":
626
- t = Array.isArray(e.value) && e.value.includes(i);
627
- break;
628
- }
629
- if (t)
630
- return {
631
- ...e.backgroundColor ? { backgroundColor: e.backgroundColor } : {},
632
- ...e.borderColor ? { borderColor: e.borderColor } : {}
633
- };
634
- }
635
- return {};
636
- }
637
- function W({ card: n, conditionalFormatting: l }) {
638
- const {
639
- attributes: e,
640
- listeners: s,
641
- setNodeRef: t,
642
- transform: i,
643
- transition: o,
644
- isDragging: r
645
- } = Y({ id: n.id }), d = {
646
- transform: ce.Transform.toString(i),
647
- transition: o,
648
- opacity: r ? 0.5 : void 0
649
- }, h = Ae(n, l);
650
- return /* @__PURE__ */ a.jsx("div", { ref: t, style: d, ...e, ...s, children: /* @__PURE__ */ a.jsxs(de, { className: "mb-2 cursor-grab active:cursor-grabbing border-border bg-card/60 hover:border-primary/40 hover:shadow-lg hover:shadow-primary/10 transition-all duration-300 group", style: h, children: [
651
- n.coverImage && /* @__PURE__ */ a.jsx("div", { className: "w-full h-32 overflow-hidden rounded-t-lg", children: /* @__PURE__ */ a.jsx(
652
- "img",
653
- {
654
- src: n.coverImage,
655
- alt: "",
656
- className: "w-full h-full object-cover",
657
- loading: "lazy"
658
- }
659
- ) }),
660
- /* @__PURE__ */ a.jsxs(he, { className: "p-4", children: [
661
- /* @__PURE__ */ a.jsx(ue, { className: "text-sm font-medium font-mono tracking-tight text-foreground group-hover:text-primary transition-colors", children: n.title }),
662
- n.description && /* @__PURE__ */ a.jsx(fe, { className: "text-xs text-muted-foreground font-mono", children: n.description })
663
- ] }),
664
- n.badges && n.badges.length > 0 && /* @__PURE__ */ a.jsx(me, { className: "p-4 pt-0", children: /* @__PURE__ */ a.jsx("div", { className: "flex flex-wrap gap-1", children: n.badges.map((u, m) => /* @__PURE__ */ a.jsx(L, { variant: u.variant || "default", className: "text-xs", children: u.label }, m)) }) })
665
- ] }) });
666
- }
667
- function De({ cards: n, parentRef: l, conditionalFormatting: e }) {
668
- const s = ke({
669
- count: n.length,
670
- getScrollElement: () => l.current,
671
- estimateSize: () => 120,
672
- overscan: 5
673
- });
674
- return /* @__PURE__ */ a.jsx(
675
- "div",
676
- {
677
- style: {
678
- height: `${s.getTotalSize()}px`,
679
- width: "100%",
680
- position: "relative"
681
- },
682
- children: s.getVirtualItems().map((t) => {
683
- const i = n[t.index];
684
- return /* @__PURE__ */ a.jsx(
685
- "div",
686
- {
687
- style: {
688
- position: "absolute",
689
- top: 0,
690
- left: 0,
691
- width: "100%",
692
- transform: `translateY(${t.start}px)`
693
- },
694
- children: /* @__PURE__ */ a.jsx(W, { card: i, conditionalFormatting: e })
695
- },
696
- i.id
697
- );
698
- })
699
- }
700
- );
701
- }
702
- function Re({ columnId: n, onAdd: l }) {
703
- const [e, s] = v.useState(!1), [t, i] = v.useState(""), o = v.useRef(null), r = () => {
704
- const h = t.trim();
705
- h && (l(n, h), i("")), s(!1);
706
- }, d = (h) => {
707
- h.key === "Enter" ? (h.preventDefault(), r()) : h.key === "Escape" && (i(""), s(!1));
708
- };
709
- return e ? /* @__PURE__ */ a.jsx("div", { className: "mt-2 space-y-2", children: /* @__PURE__ */ a.jsx(
710
- ge,
711
- {
712
- ref: o,
713
- value: t,
714
- onChange: (h) => i(h.target.value),
715
- onKeyDown: d,
716
- onBlur: r,
717
- placeholder: "Enter card title...",
718
- className: "text-sm",
719
- autoFocus: !0
720
- }
721
- ) }) : /* @__PURE__ */ a.jsxs(
722
- G,
723
- {
724
- variant: "ghost",
725
- size: "sm",
726
- className: "w-full mt-2 text-muted-foreground hover:text-foreground",
727
- onClick: () => {
728
- s(!0), setTimeout(() => o.current?.focus(), 0);
729
- },
730
- children: [
731
- /* @__PURE__ */ a.jsx(X, { className: "h-4 w-4 mr-1" }),
732
- "Add Card"
733
- ]
734
- }
735
- );
736
- }
737
- function _e({
738
- column: n,
739
- cards: l,
740
- onToggle: e,
741
- enableVirtual: s,
742
- quickAdd: t,
743
- onQuickAdd: i,
744
- conditionalFormatting: o
745
- }) {
746
- const r = l || [], d = v.useRef(null), { setNodeRef: h } = Y({
747
- id: n.id,
748
- data: {
749
- type: "column"
750
- }
751
- }), u = n.limit && r.length >= n.limit, m = n.limit && r.length >= n.limit * 0.8;
752
- return /* @__PURE__ */ a.jsxs(
753
- "div",
754
- {
755
- ref: h,
756
- className: V(
757
- "flex flex-col flex-shrink-0 rounded-lg border border-border bg-card/20 backdrop-blur-sm shadow-xl transition-all",
758
- n.collapsed ? "w-16" : "w-80",
759
- n.className
760
- ),
761
- children: [
762
- /* @__PURE__ */ a.jsxs("div", { className: "p-4 border-b border-border/50 bg-muted/20 flex items-center justify-between", children: [
763
- /* @__PURE__ */ a.jsxs("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
764
- /* @__PURE__ */ a.jsx(
765
- G,
766
- {
767
- variant: "ghost",
768
- size: "sm",
769
- className: "h-6 w-6 p-0",
770
- onClick: () => e(!n.collapsed),
771
- children: n.collapsed ? /* @__PURE__ */ a.jsx(ve, { className: "h-4 w-4" }) : /* @__PURE__ */ a.jsx(Q, { className: "h-4 w-4" })
772
- }
773
- ),
774
- !n.collapsed && /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
775
- /* @__PURE__ */ a.jsx("h3", { className: "font-mono text-sm font-semibold tracking-wider text-primary/90 uppercase truncate", children: n.title }),
776
- /* @__PURE__ */ a.jsxs("div", { className: "flex items-center gap-2", children: [
777
- /* @__PURE__ */ a.jsxs("span", { className: V(
778
- "font-mono text-xs",
779
- u ? "text-destructive" : m ? "text-yellow-500" : "text-muted-foreground"
780
- ), children: [
781
- r.length,
782
- n.limit && ` / ${n.limit}`
783
- ] }),
784
- u && /* @__PURE__ */ a.jsx(L, { variant: "destructive", className: "text-xs", children: "Full" }),
785
- m && !u && /* @__PURE__ */ a.jsx(be, { className: "h-3 w-3 text-yellow-500" })
786
- ] })
787
- ] })
788
- ] }),
789
- n.collapsed && /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col items-center gap-1", children: [
790
- /* @__PURE__ */ a.jsx("span", { className: "font-mono text-xs font-bold text-primary/90 [writing-mode:vertical-rl] rotate-180", children: n.title }),
791
- /* @__PURE__ */ a.jsx(L, { variant: "secondary", className: "text-xs", children: r.length })
792
- ] })
793
- ] }),
794
- !n.collapsed && /* @__PURE__ */ a.jsxs("div", { ref: d, className: "flex-1 p-4 overflow-y-auto", style: { maxHeight: "600px" }, children: [
795
- /* @__PURE__ */ a.jsx(
796
- le,
797
- {
798
- items: r.map((c) => c.id),
799
- strategy: ae,
800
- children: s ? /* @__PURE__ */ a.jsx(De, { cards: r, parentRef: d, conditionalFormatting: o }) : /* @__PURE__ */ a.jsx("div", { className: "space-y-2", children: r.map((c) => /* @__PURE__ */ a.jsx(W, { card: c, conditionalFormatting: o }, c.id)) })
801
- }
802
- ),
803
- t && i && /* @__PURE__ */ a.jsx(Re, { columnId: n.id, onAdd: i })
804
- ] })
805
- ]
806
- }
807
- );
808
- }
809
- function We({
810
- columns: n,
811
- onCardMove: l,
812
- onColumnToggle: e,
813
- enableVirtualScrolling: s = !1,
814
- virtualScrollThreshold: t = 50,
815
- className: i,
816
- quickAdd: o,
817
- onQuickAdd: r,
818
- conditionalFormatting: d
819
- }) {
820
- const [h, u] = v.useState(null), m = v.useMemo(() => (n || []).map((f) => ({
821
- ...f,
822
- cards: f.cards || []
823
- })), [n]), [c, g] = v.useState(m);
824
- v.useEffect(() => {
825
- g(m);
826
- }, [m]);
827
- const w = ee(
828
- te(oe, {
829
- activationConstraint: {
830
- distance: 8
831
- }
832
- })
833
- ), p = (f) => {
834
- const { active: x } = f, b = z(x.id);
835
- u(b);
836
- }, E = (f) => {
837
- const { active: x, over: b } = f;
838
- if (u(null), !b) return;
839
- const y = x.id, j = b.id;
840
- if (y === j) return;
841
- const M = C(y), N = C(j) || D(j);
842
- if (!(!M || !N))
843
- if (M.id === N.id) {
844
- const O = [...M.cards], k = O.findIndex((I) => I.id === y), T = O.findIndex((I) => I.id === j), B = re(O, k, T);
845
- g(
846
- (I) => I.map(
847
- (R) => R.id === M.id ? { ...R, cards: B } : R
848
- )
849
- );
850
- } else {
851
- const O = [...M.cards], k = [...N.cards], T = O.findIndex((_) => _.id === y), I = j === N.id ? k.length : k.findIndex((_) => _.id === j), [R] = O.splice(T, 1);
852
- k.splice(I, 0, R), g(
853
- (_) => _.map((F) => F.id === M.id ? { ...F, cards: O } : F.id === N.id ? { ...F, cards: k } : F)
854
- ), l && l(y, M.id, N.id, I);
855
- }
856
- }, z = v.useCallback(
857
- (f) => {
858
- for (const x of c) {
859
- const b = x.cards.find((y) => y.id === f);
860
- if (b) return b;
861
- }
862
- return null;
863
- },
864
- [c]
865
- ), C = v.useCallback(
866
- (f) => c.find((x) => x.cards.some((b) => b.id === f)) || null,
867
- [c]
868
- ), D = v.useCallback(
869
- (f) => c.find((x) => x.id === f) || null,
870
- [c]
871
- ), S = v.useCallback((f, x) => {
872
- g(
873
- (b) => b.map((y) => y.id === f ? { ...y, collapsed: x } : y)
874
- ), e?.(f, x);
875
- }, [e]);
876
- return /* @__PURE__ */ a.jsxs(
877
- se,
878
- {
879
- sensors: w,
880
- collisionDetection: ne,
881
- onDragStart: p,
882
- onDragEnd: E,
883
- children: [
884
- /* @__PURE__ */ a.jsx("div", { className: V("flex gap-4 overflow-x-auto p-4", i), children: c.map((f) => {
885
- const x = s && f.cards.length > t;
886
- return /* @__PURE__ */ a.jsx(
887
- _e,
888
- {
889
- column: f,
890
- cards: f.cards,
891
- onToggle: (b) => S(f.id, b),
892
- enableVirtual: x,
893
- quickAdd: o,
894
- onQuickAdd: r,
895
- conditionalFormatting: d
896
- },
897
- f.id
898
- );
899
- }) }),
900
- /* @__PURE__ */ a.jsx(ie, { children: h ? /* @__PURE__ */ a.jsx(W, { card: h, conditionalFormatting: d }) : null })
901
- ]
902
- }
903
- );
904
- }
905
- export {
906
- We as KanbanEnhanced,
907
- We as default
908
- };