@svar-ui/svelte-kanban 2.6.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/components/Card.svelte +15 -72
  2. package/dist/components/CardList.svelte +8 -341
  3. package/dist/components/CardList.svelte.d.ts +14 -12
  4. package/dist/components/CardMenuButton.svelte +47 -0
  5. package/dist/components/CardMenuButton.svelte.d.ts +10 -0
  6. package/dist/components/CardWrapper.svelte +2 -5
  7. package/dist/components/Column.svelte +85 -53
  8. package/dist/components/Column.svelte.d.ts +4 -0
  9. package/dist/components/DragGhost.svelte +4 -0
  10. package/dist/components/Kanban.svelte +19 -20
  11. package/dist/components/Kanban.svelte.d.ts +117 -12
  12. package/dist/components/Layout.svelte +103 -51
  13. package/dist/components/Layout.svelte.d.ts +5 -1
  14. package/dist/components/Stack.svelte +383 -0
  15. package/dist/components/Stack.svelte.d.ts +26 -0
  16. package/dist/components/StackCardList.svelte +434 -0
  17. package/dist/components/StackCardList.svelte.d.ts +28 -0
  18. package/dist/components/useDrag.svelte.d.ts +7 -5
  19. package/dist/components/useDrag.svelte.js +6 -0
  20. package/dist/context.d.ts +6 -0
  21. package/dist/context.js +1 -0
  22. package/dist/directives/dblclick.d.ts +2 -1
  23. package/dist/directives/dblclick.js +5 -4
  24. package/dist/directives/drag.d.ts +2 -0
  25. package/dist/directives/drag.js +99 -43
  26. package/dist/index.d.ts +10 -4
  27. package/dist/index.js +9 -3
  28. package/dist/layout/stack.d.ts +19 -0
  29. package/dist/layout/stack.js +37 -0
  30. package/dist/layout/target.d.ts +18 -0
  31. package/dist/layout/target.js +74 -0
  32. package/dist/menus/CardActionMenu.svelte +20 -0
  33. package/dist/menus/CardActionMenu.svelte.d.ts +7 -0
  34. package/dist/menus/CardContextMenu.svelte +20 -0
  35. package/dist/menus/CardContextMenu.svelte.d.ts +7 -0
  36. package/dist/menus/ColumnActionMenu.svelte +20 -0
  37. package/dist/menus/ColumnActionMenu.svelte.d.ts +7 -0
  38. package/dist/menus/ColumnContextMenu.svelte +20 -0
  39. package/dist/menus/ColumnContextMenu.svelte.d.ts +7 -0
  40. package/dist/menus/KanbanMenu.svelte +65 -0
  41. package/dist/menus/KanbanMenu.svelte.d.ts +37 -0
  42. package/dist/menus/helpers.d.ts +23 -0
  43. package/dist/menus/helpers.js +80 -0
  44. package/dist/themes/Print.svelte +1 -8
  45. package/dist/themes/PrintBW.svelte +1 -8
  46. package/dist/themes/Willow.svelte +1 -1
  47. package/dist/themes/WillowDark.svelte +1 -1
  48. package/dist/types.d.ts +71 -9
  49. package/package.json +25 -11
  50. package/readme.md +16 -8
  51. package/dist/components/ContextMenu.svelte +0 -111
  52. package/dist/components/ContextMenu.svelte.d.ts +0 -18
  53. package/dist/components/ExportLayout.svelte +0 -52
  54. package/dist/components/ExportLayout.svelte.d.ts +0 -15
  55. package/dist/export/Card.svelte +0 -5
  56. package/dist/export/Card.svelte.d.ts +0 -11
  57. package/dist/export/Kanban.svelte +0 -30
  58. package/dist/export/Kanban.svelte.d.ts +0 -16
  59. package/dist/export.d.ts +0 -3
  60. package/dist/export.js +0 -15
@@ -0,0 +1,434 @@
1
+ <script lang="ts">import { getContext, onDestroy } from "svelte";
2
+ import { setID } from "@svar-ui/lib-dom";
3
+ import CardWrapper from "./CardWrapper.svelte";
4
+ import { KANBAN_API_CONTEXT, DND_CONTEXT, SCROLL_CONTAINER_CONTEXT, CELL_VIEWPORT_CONTEXT } from "../context.js";
5
+ import { dblclick } from "../directives/dblclick.js";
6
+ let { column, cards: cellCards, swimlane, swimlaneView, active = true, readonly = false, cardContent, cardShape, contentVisible, virtualizeCards, estimatedCardHeight, cardOverscan, fixedColumnWidth, cardListStart, cardListEnd, cardCss } = $props();
7
+ const cards = $derived(cellCards ?? column.cards);
8
+ function getCardExtraCss(card) {
9
+ return cardCss ? cardCss(card, column) ?? "" : "";
10
+ }
11
+ const store = getContext(KANBAN_API_CONTEXT);
12
+ const dnd = getContext(DND_CONTEXT);
13
+ const getScrollContainer = getContext(SCROLL_CONTAINER_CONTEXT);
14
+ const { columnAccessor } = store.getReactiveState();
15
+ const viewport = getContext(CELL_VIEWPORT_CONTEXT);
16
+ let container = $state();
17
+ let range = $state({
18
+ start: 0,
19
+ end: -1,
20
+ top: 0,
21
+ bottom: 0,
22
+ total: 0
23
+ });
24
+ let cardGap = $state(8);
25
+ let frame = 0;
26
+ let previousVirtualizeCards = false;
27
+ let offsetsCache;
28
+ let previousCards = new Map();
29
+ let previousTemplate;
30
+ let previousShape;
31
+ let measuredWidth = 0;
32
+ let startHeight = 0;
33
+ let paddingTop = 0;
34
+ const HEIGHT_CACHE_LIMIT = 1e4;
35
+ const heightCache = new Map();
36
+ const measuredNodes = new Map();
37
+ let cardObserver;
38
+ const dropTarget = $derived(dnd?.preview ?? null);
39
+ const isDropColumn = $derived(dropTarget?.column === column.id && dropTarget.swimlane === swimlane);
40
+ // External projections have no measured source card.
41
+ const placeholderHeight = $derived(dnd?.active ? dnd.height : Math.max(1, estimatedCardHeight || 1));
42
+ const renderStart = $derived(virtualizeCards ? range.start : 0);
43
+ const renderEnd = $derived(virtualizeCards ? range.end : cards.length - 1);
44
+ const renderedCards = $derived(contentVisible && active ? cards.slice(renderStart, Math.max(renderStart, renderEnd + 1)) : []);
45
+ const hiddenHeight = $derived(range.total || estimateTotalHeight(cards.length));
46
+ const topSpacerHeight = $derived(range.start > 0 ? Math.max(0, range.top - cardGap) : 0);
47
+ const bottomSpacerHeight = $derived(Math.max(0, range.bottom));
48
+ const afterRenderedBeforeId = $derived(contentVisible && virtualizeCards && renderEnd >= 0 && renderEnd < cards.length - 1 ? cards[renderEnd + 1]?.id : undefined);
49
+ const trailingPlaceholder = $derived(isDropColumn && (dropTarget.before == null || dropTarget.before === afterRenderedBeforeId));
50
+ // An append target belongs after the full list extent, below the bottom spacer.
51
+ const appendAfterSpacer = $derived(isDropColumn && dropTarget.before == null && bottomSpacerHeight > 0);
52
+ function estimateTotalHeight(count) {
53
+ if (!count) return 0;
54
+ const height = Math.max(1, estimatedCardHeight || 1);
55
+ return count * height + Math.max(0, count - 1) * cardGap;
56
+ }
57
+ function readGap() {
58
+ if (!container) return;
59
+ const styles = getComputedStyle(container);
60
+ paddingTop = Number.parseFloat(styles.paddingTop) || 0;
61
+ const configuredGap = styles.getPropertyValue("--wx-card-gap").trim();
62
+ const raw = configuredGap || styles.rowGap || styles.gap;
63
+ const next = Number.parseFloat(raw);
64
+ const gap = Number.isFinite(next) ? next : 8;
65
+ if (cardGap !== gap) {
66
+ cardGap = gap;
67
+ offsetsCache = undefined;
68
+ }
69
+ }
70
+ function getCardHeight(card) {
71
+ return card.id != null ? heightCache.get(card.id) ?? Math.max(1, estimatedCardHeight || 1) : Math.max(1, estimatedCardHeight || 1);
72
+ }
73
+ function updateMeasuredWidth(width) {
74
+ if (!width || measuredWidth === width) return false;
75
+ if (measuredWidth) heightCache.clear();
76
+ measuredWidth = width;
77
+ offsetsCache = undefined;
78
+ return true;
79
+ }
80
+ function buildOffsets() {
81
+ if (offsetsCache) return offsetsCache;
82
+ const offsets = [0];
83
+ let total = 0;
84
+ for (let i = 0; i < cards.length; i++) {
85
+ total += getCardHeight(cards[i]);
86
+ if (i < cards.length - 1) total += cardGap;
87
+ offsets.push(total);
88
+ }
89
+ return offsetsCache = {
90
+ offsets,
91
+ total
92
+ };
93
+ }
94
+ function upperBound(values, value) {
95
+ let low = 0;
96
+ let high = values.length;
97
+ while (low < high) {
98
+ const mid = Math.floor((low + high) / 2);
99
+ if (values[mid] <= value) low = mid + 1;
100
+ else high = mid;
101
+ }
102
+ return low;
103
+ }
104
+ function recalculate() {
105
+ if (!container) return;
106
+ readGap();
107
+ const contentTop = paddingTop + (active && cardListStart ? startHeight + cardGap : 0);
108
+ if (typeof ResizeObserver === "undefined") updateMeasuredWidth(container.clientWidth);
109
+ if (!active || !contentVisible || !virtualizeCards) {
110
+ range = {
111
+ start: 0,
112
+ end: active && contentVisible ? cards.length - 1 : -1,
113
+ top: 0,
114
+ bottom: 0,
115
+ total: buildOffsets().total
116
+ };
117
+ return;
118
+ }
119
+ const count = cards.length;
120
+ if (!count) {
121
+ range = {
122
+ start: 0,
123
+ end: -1,
124
+ top: 0,
125
+ bottom: 0,
126
+ total: 0
127
+ };
128
+ return;
129
+ }
130
+ const { offsets, total } = buildOffsets();
131
+ const boardScroll = getScrollContainer?.() ?? null;
132
+ let viewportTop = 0;
133
+ let viewportBottom = 0;
134
+ if (boardScroll) {
135
+ const boardRect = boardScroll.getBoundingClientRect();
136
+ const containerRect = container.getBoundingClientRect();
137
+ viewportTop = Math.max(0, boardRect.top + (viewport?.inset() ?? 0) - containerRect.top - contentTop);
138
+ viewportBottom = Math.min(total, boardRect.bottom - containerRect.top - contentTop);
139
+ } else {
140
+ viewportTop = Math.max(0, container.scrollTop - contentTop);
141
+ viewportBottom = container.scrollTop + container.clientHeight - contentTop;
142
+ }
143
+ if (viewportBottom < 0 || viewportTop > total) {
144
+ range = {
145
+ start: 0,
146
+ end: -1,
147
+ top: 0,
148
+ bottom: total,
149
+ total
150
+ };
151
+ return;
152
+ }
153
+ const safeOverscan = Math.max(0, Math.floor(cardOverscan || 0));
154
+ let start = Math.max(0, upperBound(offsets, viewportTop) - 1);
155
+ let end = Math.max(start, upperBound(offsets, viewportBottom) - 1);
156
+ start = Math.max(0, start - safeOverscan);
157
+ end = Math.min(count - 1, end + safeOverscan);
158
+ range = {
159
+ start,
160
+ end,
161
+ top: offsets[start],
162
+ bottom: Math.max(0, total - offsets[end + 1]),
163
+ total
164
+ };
165
+ }
166
+ function scheduleRecalculate(..._tracked) {
167
+ if (viewport) {
168
+ viewport.schedule();
169
+ return;
170
+ }
171
+ if (frame) return;
172
+ frame = requestAnimationFrame(() => {
173
+ frame = 0;
174
+ recalculate();
175
+ });
176
+ }
177
+ function pruneHeightCache() {
178
+ const ids = new Set(cards.map((card) => card.id));
179
+ for (const id of heightCache.keys()) {
180
+ if (!ids.has(id)) heightCache.delete(id);
181
+ }
182
+ capHeightCache();
183
+ }
184
+ function capHeightCache() {
185
+ while (heightCache.size > HEIGHT_CACHE_LIMIT) {
186
+ const first = heightCache.keys().next().value;
187
+ if (first === undefined) break;
188
+ heightCache.delete(first);
189
+ }
190
+ }
191
+ function ensureCardObserver() {
192
+ if (cardObserver || typeof ResizeObserver === "undefined") return;
193
+ cardObserver = new ResizeObserver((entries) => {
194
+ let changed = false;
195
+ for (const entry of entries) {
196
+ const id = measuredNodes.get(entry.target);
197
+ if (id == null) continue;
198
+ const height = Math.ceil(entry.target.offsetHeight);
199
+ if (height > 0 && heightCache.get(id) !== height) {
200
+ heightCache.delete(id);
201
+ heightCache.set(id, height);
202
+ capHeightCache();
203
+ offsetsCache = undefined;
204
+ changed = true;
205
+ }
206
+ }
207
+ if (changed) scheduleRecalculate();
208
+ });
209
+ }
210
+ function measureCard(node, card) {
211
+ if (card.id != null) {
212
+ ensureCardObserver();
213
+ measuredNodes.set(node, card.id);
214
+ cardObserver?.observe(node);
215
+ }
216
+ return {
217
+ update(next) {
218
+ cardObserver?.unobserve(node);
219
+ if (next.id != null) {
220
+ measuredNodes.set(node, next.id);
221
+ cardObserver?.observe(node);
222
+ } else {
223
+ measuredNodes.delete(node);
224
+ }
225
+ },
226
+ destroy() {
227
+ cardObserver?.unobserve(node);
228
+ measuredNodes.delete(node);
229
+ }
230
+ };
231
+ }
232
+ $effect(() => {
233
+ if (virtualizeCards && !previousVirtualizeCards) {
234
+ heightCache.clear();
235
+ }
236
+ previousVirtualizeCards = virtualizeCards;
237
+ for (const card of cards) {
238
+ if (previousCards.get(card.id) !== card) heightCache.delete(card.id);
239
+ }
240
+ previousCards = new Map(cards.map((card) => [card.id, card]));
241
+ if (previousTemplate !== cardContent || previousShape !== cardShape) heightCache.clear();
242
+ previousShape = cardShape;
243
+ previousTemplate = cardContent;
244
+ offsetsCache = undefined;
245
+ pruneHeightCache();
246
+ scheduleRecalculate(cards, contentVisible, estimatedCardHeight, cardOverscan, active, cardShape, fixedColumnWidth);
247
+ });
248
+ $effect(() => {
249
+ if (!container) return;
250
+ if (viewport) return viewport.subscribe(recalculate);
251
+ if (!contentVisible || !virtualizeCards) return;
252
+ const scrollElement = getScrollContainer?.() ?? container;
253
+ const onScroll = () => scheduleRecalculate();
254
+ scrollElement.addEventListener("scroll", onScroll, { passive: true });
255
+ window.addEventListener("resize", onScroll);
256
+ scheduleRecalculate();
257
+ return () => {
258
+ scrollElement.removeEventListener("scroll", onScroll);
259
+ window.removeEventListener("resize", onScroll);
260
+ };
261
+ });
262
+ $effect(() => {
263
+ if (!container || !contentVisible || !virtualizeCards || typeof ResizeObserver === "undefined") {
264
+ return;
265
+ }
266
+ updateMeasuredWidth(container.clientWidth);
267
+ const observer = new ResizeObserver(() => {
268
+ const next = container?.clientWidth ?? 0;
269
+ if (updateMeasuredWidth(next)) scheduleRecalculate();
270
+ });
271
+ observer.observe(container);
272
+ return () => observer.disconnect();
273
+ });
274
+ onDestroy(() => {
275
+ if (frame) cancelAnimationFrame(frame);
276
+ cardObserver?.disconnect();
277
+ });
278
+ function measureStart(node) {
279
+ const measure = () => {
280
+ startHeight = node.getBoundingClientRect().height;
281
+ scheduleRecalculate();
282
+ };
283
+ measure();
284
+ const observer = new ResizeObserver(measure);
285
+ observer.observe(node);
286
+ return { destroy() {
287
+ observer.disconnect();
288
+ startHeight = 0;
289
+ scheduleRecalculate();
290
+ } };
291
+ }
292
+ </script>
293
+
294
+ <div
295
+ class="wx-column-cards"
296
+ data-kanban-column-cards={active ? setID(column.id) : undefined}
297
+ data-kanban-swimlane={swimlane === undefined ? undefined : setID(swimlane)}
298
+ data-kanban-render-start={renderStart}
299
+ data-kanban-render-end={renderEnd}
300
+ data-kanban-card-count={cards.length}
301
+ data-kanban-after-rendered-before-id={afterRenderedBeforeId == null
302
+ ? undefined
303
+ : setID(afterRenderedBeforeId)}
304
+ bind:this={container}
305
+ use:dblclick={{
306
+ store,
307
+ column: column.id,
308
+ columnAccessor: $columnAccessor,
309
+ swimlane,
310
+ readonly,
311
+ }}
312
+ >
313
+ {#if active && cardListStart}
314
+ {@const Slot = cardListStart}
315
+ <div class="wx-card-list-start" use:measureStart>
316
+ <Slot {column} swimlane={swimlaneView} {cards} {readonly} />
317
+ </div>
318
+ {/if}
319
+ {#if contentVisible && active}
320
+ {#if virtualizeCards}
321
+ {#if topSpacerHeight > 0}
322
+ <div class="wx-virtual-spacer" style:height="{topSpacerHeight}px"></div>
323
+ {/if}
324
+ {#each renderedCards as cardItem (cardItem.id)}
325
+ {#if isDropColumn && dropTarget!.before === cardItem.id}
326
+ <div
327
+ class="wx-drop-placeholder"
328
+ aria-hidden="true"
329
+ style:height="{placeholderHeight}px"
330
+ ></div>
331
+ {/if}
332
+ {@const extraCss = getCardExtraCss(cardItem)}
333
+ <div
334
+ class="wx-card-row {cardItem.css ?? ''} {extraCss}"
335
+ data-kanban-card-id={cardItem.id == null
336
+ ? undefined
337
+ : setID(cardItem.id)}
338
+ use:measureCard={cardItem}
339
+ class:wx-dragging={dnd?.active && dnd.cardId === cardItem.id}
340
+ >
341
+ <CardWrapper card={cardItem} {cardContent} {cardShape} {extraCss} />
342
+ </div>
343
+ {/each}
344
+ {#if trailingPlaceholder && !appendAfterSpacer}
345
+ <div
346
+ class="wx-drop-placeholder"
347
+ aria-hidden="true"
348
+ style:height="{placeholderHeight}px"
349
+ ></div>
350
+ {/if}
351
+ {#if bottomSpacerHeight > 0}
352
+ <div
353
+ class="wx-virtual-spacer"
354
+ style:height="{bottomSpacerHeight}px"
355
+ ></div>
356
+ {/if}
357
+ {#if appendAfterSpacer}
358
+ <div
359
+ class="wx-drop-placeholder"
360
+ aria-hidden="true"
361
+ style:height="{placeholderHeight}px"
362
+ ></div>
363
+ {/if}
364
+ {:else}
365
+ {#each cards as cardItem (cardItem.id)}
366
+ {#if isDropColumn && dropTarget!.before === cardItem.id}
367
+ <div
368
+ class="wx-drop-placeholder"
369
+ aria-hidden="true"
370
+ style:height="{placeholderHeight}px"
371
+ ></div>
372
+ {/if}
373
+ {@const extraCss = getCardExtraCss(cardItem)}
374
+ <div
375
+ class="wx-card-row {cardItem.css ?? ''} {extraCss}"
376
+ data-kanban-card-id={cardItem.id == null
377
+ ? undefined
378
+ : setID(cardItem.id)}
379
+ use:measureCard={cardItem}
380
+ class:wx-dragging={dnd?.active && dnd.cardId === cardItem.id}
381
+ >
382
+ <CardWrapper card={cardItem} {cardContent} {cardShape} {extraCss} />
383
+ </div>
384
+ {/each}
385
+ {#if trailingPlaceholder}
386
+ <div
387
+ class="wx-drop-placeholder"
388
+ aria-hidden="true"
389
+ style:height="{placeholderHeight}px"
390
+ ></div>
391
+ {/if}
392
+ {/if}
393
+ {:else if hiddenHeight > 0 && active}
394
+ <div class="wx-virtual-spacer" style:height="{hiddenHeight}px"></div>
395
+ {/if}
396
+ {#if active && cardListEnd}
397
+ {@const Slot = cardListEnd}
398
+ <div class="wx-card-list-end">
399
+ <Slot {column} swimlane={swimlaneView} {cards} {readonly} />
400
+ </div>
401
+ {/if}
402
+ </div>
403
+
404
+ <style>
405
+ .wx-card-list-start,
406
+ .wx-card-list-end {
407
+ display: flow-root;
408
+ }
409
+ .wx-column-cards {
410
+ display: flex;
411
+ flex-direction: column;
412
+ gap: var(--wx-card-gap, 8px);
413
+ padding: 8px;
414
+ overflow-y: auto;
415
+ flex: 1;
416
+ min-height: 0;
417
+ }
418
+
419
+ .wx-column-cards > :global(div) {
420
+ flex-shrink: 0;
421
+ }
422
+
423
+ .wx-drop-placeholder {
424
+ border: 1px dashed var(--wx-kanban-border-color);
425
+ border-radius: var(--wx-border-radius);
426
+ background: var(--wx-kanban-drop-placeholder-bg);
427
+ box-sizing: border-box;
428
+ pointer-events: none;
429
+ }
430
+
431
+ .wx-dragging {
432
+ display: none;
433
+ }
434
+ </style>
@@ -0,0 +1,28 @@
1
+ import type { CardListSlotProps } from "../types.js";
2
+ import type { Component } from "svelte";
3
+ import type { ColumnView, KanbanCard } from "@svar-ui/kanban-store";
4
+ import type { CardShape, CardCssFn } from "../types.js";
5
+ type Props = {
6
+ column: ColumnView;
7
+ cards?: KanbanCard[];
8
+ swimlane?: import("@svar-ui/kanban-store").SwimlaneID;
9
+ swimlaneView?: CardListSlotProps["swimlane"];
10
+ active?: boolean;
11
+ readonly?: boolean;
12
+ cardContent?: Component<{
13
+ card: KanbanCard;
14
+ cardShape: CardShape;
15
+ }>;
16
+ cardShape: CardShape;
17
+ contentVisible: boolean;
18
+ virtualizeCards: boolean;
19
+ estimatedCardHeight: number;
20
+ cardOverscan: number;
21
+ fixedColumnWidth: boolean;
22
+ cardListStart?: Component<CardListSlotProps>;
23
+ cardListEnd?: Component<CardListSlotProps>;
24
+ cardCss?: CardCssFn;
25
+ };
26
+ declare const StackCardList: Component<Props, {}, "">;
27
+ type StackCardList = ReturnType<typeof StackCardList>;
28
+ export default StackCardList;
@@ -1,8 +1,6 @@
1
1
  import type { CardID, ColumnID } from "@svar-ui/kanban-store";
2
- export type DndTarget = {
3
- column: ColumnID;
4
- beforeId: CardID | null;
5
- };
2
+ import type { CardProjectionTarget } from "../types.js";
3
+ export type DndTarget = CardProjectionTarget;
6
4
  export declare class DndState {
7
5
  active: boolean;
8
6
  cardId: CardID | null;
@@ -17,6 +15,10 @@ export declare class DndState {
17
15
  x: number;
18
16
  y: number;
19
17
  };
20
- target: DndTarget | null;
18
+ target: CardProjectionTarget | null;
19
+ /** Target of the external `cardProjection`; never touched by internal drag. */
20
+ external: CardProjectionTarget | null;
21
+ /** Placeholder target: an active internal drag wins even without a target. */
22
+ get preview(): DndTarget | null;
21
23
  reset(): void;
22
24
  }
@@ -7,6 +7,12 @@ export class DndState {
7
7
  pointer = $state({ x: 0, y: 0 });
8
8
  offset = $state({ x: 0, y: 0 });
9
9
  target = $state(null);
10
+ /** Target of the external `cardProjection`; never touched by internal drag. */
11
+ external = $state(null);
12
+ /** Placeholder target: an active internal drag wins even without a target. */
13
+ get preview() {
14
+ return this.active ? this.target : this.external;
15
+ }
10
16
  reset() {
11
17
  this.active = false;
12
18
  this.cardId = null;
package/dist/context.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ export type CellViewport = {
2
+ subscribe: (callback: () => void) => () => void;
3
+ schedule: () => void;
4
+ inset: () => number;
5
+ };
6
+ export declare const CELL_VIEWPORT_CONTEXT: unique symbol;
1
7
  export declare const SCROLL_CONTAINER_CONTEXT: unique symbol;
2
8
  export declare const KANBAN_API_CONTEXT: unique symbol;
3
9
  export declare const DND_CONTEXT: unique symbol;
package/dist/context.js CHANGED
@@ -1,3 +1,4 @@
1
+ export const CELL_VIEWPORT_CONTEXT = Symbol("wx/kanban-cell-viewport");
1
2
  export const SCROLL_CONTAINER_CONTEXT = Symbol("wx/kanban-scroll-container");
2
3
  export const KANBAN_API_CONTEXT = Symbol("kanban-api");
3
4
  export const DND_CONTEXT = Symbol("wx/kanban-dnd");
@@ -5,9 +5,10 @@ export type DblClickAddCardParams = {
5
5
  column: ColumnID;
6
6
  columnAccessor: ColumnAccessor;
7
7
  readonly?: boolean;
8
+ swimlane?: ColumnID;
8
9
  };
9
10
  export declare function dblclick(node: HTMLElement, initial: DblClickAddCardParams): {
10
11
  update(next: DblClickAddCardParams): void;
11
12
  destroy(): void;
12
13
  };
13
- export declare function createColumnCard(card: KanbanCard, accessor: ColumnAccessor, column: ColumnID): KanbanCard;
14
+ export declare function createColumnCard(card: Partial<KanbanCard>, accessor: ColumnAccessor, column: ColumnID): Partial<KanbanCard>;
@@ -1,3 +1,4 @@
1
+ import { writeMembership } from "@svar-ui/kanban-store";
1
2
  export function dblclick(node, initial) {
2
3
  let params = initial;
3
4
  function onDblClick(e) {
@@ -6,7 +7,9 @@ export function dblclick(node, initial) {
6
7
  if (e.target !== node)
7
8
  return;
8
9
  const base = { label: "New card" };
9
- const card = createColumnCard(base, params.columnAccessor, params.column);
10
+ let card = createColumnCard(base, params.columnAccessor, params.column);
11
+ if (params.swimlane !== undefined)
12
+ card = createColumnCard(card, params.store.getState().swimlaneAccessor, params.swimlane);
10
13
  void params.store.exec("add-card", { card });
11
14
  }
12
15
  node.addEventListener("dblclick", onDblClick);
@@ -20,7 +23,5 @@ export function dblclick(node, initial) {
20
23
  };
21
24
  }
22
25
  export function createColumnCard(card, accessor, column) {
23
- return typeof accessor === "string"
24
- ? { ...card, [accessor]: column }
25
- : accessor.set(card, column);
26
+ return writeMembership(card, accessor, column);
26
27
  }
@@ -4,6 +4,8 @@ export type CardDragParams = {
4
4
  dnd: DndState | undefined;
5
5
  store: KanbanContextApi;
6
6
  readonly?: boolean;
7
+ /** No drag starts and an active drag is cancelled, e.g. in the stack layout. */
8
+ disabled?: boolean;
7
9
  };
8
10
  export declare function cardDrag(node: HTMLElement, initial: CardDragParams): {
9
11
  update(next: CardDragParams): void;