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