@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.
- package/dist/components/Card.svelte +15 -72
- package/dist/components/CardList.svelte +8 -341
- package/dist/components/CardList.svelte.d.ts +14 -12
- package/dist/components/CardMenuButton.svelte +47 -0
- package/dist/components/CardMenuButton.svelte.d.ts +10 -0
- package/dist/components/CardWrapper.svelte +2 -5
- package/dist/components/Column.svelte +85 -53
- package/dist/components/Column.svelte.d.ts +4 -0
- package/dist/components/DragGhost.svelte +4 -0
- package/dist/components/Kanban.svelte +19 -20
- package/dist/components/Kanban.svelte.d.ts +117 -12
- package/dist/components/Layout.svelte +103 -51
- package/dist/components/Layout.svelte.d.ts +5 -1
- package/dist/components/Stack.svelte +383 -0
- package/dist/components/Stack.svelte.d.ts +26 -0
- package/dist/components/StackCardList.svelte +434 -0
- package/dist/components/StackCardList.svelte.d.ts +28 -0
- package/dist/components/useDrag.svelte.d.ts +7 -5
- package/dist/components/useDrag.svelte.js +6 -0
- package/dist/context.d.ts +6 -0
- package/dist/context.js +1 -0
- package/dist/directives/dblclick.d.ts +2 -1
- package/dist/directives/dblclick.js +5 -4
- package/dist/directives/drag.d.ts +2 -0
- package/dist/directives/drag.js +99 -43
- package/dist/index.d.ts +10 -4
- package/dist/index.js +9 -3
- package/dist/layout/stack.d.ts +19 -0
- package/dist/layout/stack.js +37 -0
- package/dist/layout/target.d.ts +18 -0
- package/dist/layout/target.js +74 -0
- package/dist/menus/CardActionMenu.svelte +20 -0
- package/dist/menus/CardActionMenu.svelte.d.ts +7 -0
- package/dist/menus/CardContextMenu.svelte +20 -0
- package/dist/menus/CardContextMenu.svelte.d.ts +7 -0
- package/dist/menus/ColumnActionMenu.svelte +20 -0
- package/dist/menus/ColumnActionMenu.svelte.d.ts +7 -0
- package/dist/menus/ColumnContextMenu.svelte +20 -0
- package/dist/menus/ColumnContextMenu.svelte.d.ts +7 -0
- package/dist/menus/KanbanMenu.svelte +65 -0
- package/dist/menus/KanbanMenu.svelte.d.ts +37 -0
- package/dist/menus/helpers.d.ts +23 -0
- package/dist/menus/helpers.js +80 -0
- package/dist/themes/Print.svelte +1 -8
- package/dist/themes/PrintBW.svelte +1 -8
- package/dist/themes/Willow.svelte +1 -1
- package/dist/themes/WillowDark.svelte +1 -1
- package/dist/types.d.ts +71 -9
- package/package.json +25 -11
- package/readme.md +16 -8
- package/dist/components/ContextMenu.svelte +0 -111
- package/dist/components/ContextMenu.svelte.d.ts +0 -18
- package/dist/components/ExportLayout.svelte +0 -52
- package/dist/components/ExportLayout.svelte.d.ts +0 -15
- package/dist/export/Card.svelte +0 -5
- package/dist/export/Card.svelte.d.ts +0 -11
- package/dist/export/Kanban.svelte +0 -30
- package/dist/export/Kanban.svelte.d.ts +0 -16
- package/dist/export.d.ts +0 -3
- package/dist/export.js +0 -15
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
import { delegateClick, hotkeys, locate, locateID } from "@svar-ui/lib-dom";
|
|
3
3
|
import { Popup } from "@svar-ui/svelte-core";
|
|
4
4
|
import Column from "./Column.svelte";
|
|
5
|
-
import
|
|
5
|
+
import Stack from "./Stack.svelte";
|
|
6
|
+
const Swimlanes = Column;
|
|
7
|
+
const useCardProjection = (_) => {};
|
|
6
8
|
import DragGhost from "./DragGhost.svelte";
|
|
7
9
|
import { cardDrag } from "../directives/drag.js";
|
|
8
10
|
import { KANBAN_API_CONTEXT, SCROLL_CONTAINER_CONTEXT, DND_CONTEXT } from "../context.js";
|
|
9
11
|
import { useCardOverlay } from "./useCardOverlay.svelte.js";
|
|
10
|
-
let { readonly = false, render, cardContent, cardShape, tooltip, cardPopup, cardCss, columnCss } = $props();
|
|
11
|
-
const
|
|
12
|
+
let { readonly = false, render, cardContent, cardShape, tooltip, cardPopup, cardListStart, cardListEnd, cardCss, columnCss, cardProjection = null } = $props();
|
|
13
|
+
const stack = $derived(render?.layout === "stack");
|
|
12
14
|
const fixedColumnWidth = $derived(render?.fixedColumnWidth ?? true);
|
|
13
15
|
const virtualizeCards = $derived(render?.virtualizeCards ?? false);
|
|
14
16
|
const virtualizeColumns = $derived(render?.virtualizeColumns ?? false);
|
|
@@ -17,10 +19,15 @@ const cardOverscan = $derived(render?.cardOverscan ?? 5);
|
|
|
17
19
|
const columnOverscan = $derived(render?.columnOverscan ?? 1);
|
|
18
20
|
const store = getContext(KANBAN_API_CONTEXT);
|
|
19
21
|
const { viewData } = store.getReactiveState();
|
|
22
|
+
const hasSwimlanes = $derived($viewData.swimlanes.length > 0);
|
|
23
|
+
// Lanes and the stack layout override the effective scroll mode without
|
|
24
|
+
// touching the caller's value, so leaving either restores the preference.
|
|
25
|
+
const columnScroll = $derived(!stack && !hasSwimlanes && (render?.columnScroll ?? true));
|
|
20
26
|
const brandmark = store.getBrandmark();
|
|
21
27
|
const _ = getContext("wx-i18n").getGroup("kanban");
|
|
22
28
|
const dnd = getContext(DND_CONTEXT);
|
|
23
29
|
let root = $state();
|
|
30
|
+
let board = $state();
|
|
24
31
|
let scroll = $state();
|
|
25
32
|
let visibleColumnIds = $state(new Set());
|
|
26
33
|
let visibilityFrame = 0;
|
|
@@ -39,6 +46,7 @@ function setVisibleColumns(next) {
|
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
function updateColumnVisibility() {
|
|
49
|
+
if (stack) return;
|
|
42
50
|
if (!virtualizeColumns || !scroll) {
|
|
43
51
|
setVisibleColumns(new Set());
|
|
44
52
|
return;
|
|
@@ -74,7 +82,7 @@ function updateColumnVisibility() {
|
|
|
74
82
|
setVisibleColumns(next);
|
|
75
83
|
}
|
|
76
84
|
function scheduleColumnVisibility(..._tracked) {
|
|
77
|
-
if (visibilityFrame) return;
|
|
85
|
+
if (stack || visibilityFrame) return;
|
|
78
86
|
visibilityFrame = requestAnimationFrame(() => {
|
|
79
87
|
visibilityFrame = 0;
|
|
80
88
|
updateColumnVisibility();
|
|
@@ -123,8 +131,9 @@ function handleCardClick(id, ev) {
|
|
|
123
131
|
}
|
|
124
132
|
function handleCardKey(e) {
|
|
125
133
|
if (readonly) return;
|
|
126
|
-
e?.preventDefault();
|
|
127
134
|
const active = document.activeElement;
|
|
135
|
+
if (!(active instanceof HTMLElement) || !active.matches(".wx-card")) return;
|
|
136
|
+
e?.preventDefault();
|
|
128
137
|
const id = active ? locateID(active) : null;
|
|
129
138
|
if (cardPopup && id != null && active) {
|
|
130
139
|
overlay.handleCardPopup({
|
|
@@ -135,17 +144,10 @@ function handleCardKey(e) {
|
|
|
135
144
|
}
|
|
136
145
|
selectCard(id);
|
|
137
146
|
}
|
|
138
|
-
const cardMenuConfig = $derived(cardShape?.menu ? typeof cardShape.menu === "object" ? cardShape.menu : {} : null);
|
|
139
|
-
let cardMenu = $state();
|
|
140
|
-
function handleCardMenu(id, ev) {
|
|
141
|
-
if (readonly || id == null || !cardMenu) return;
|
|
142
|
-
ev.stopPropagation();
|
|
143
|
-
cardMenu.show(ev, id);
|
|
144
|
-
}
|
|
145
147
|
function delegateCardClick(node) {
|
|
146
148
|
delegateClick(node, {
|
|
147
149
|
click: handleCardClick,
|
|
148
|
-
menu:
|
|
150
|
+
menu: () => {}
|
|
149
151
|
});
|
|
150
152
|
}
|
|
151
153
|
function cardHotkeys(node) {
|
|
@@ -161,7 +163,7 @@ $effect(() => {
|
|
|
161
163
|
scheduleColumnVisibility(virtualizeColumns, columnOverscan, fixedColumnWidth, $viewData.columns);
|
|
162
164
|
});
|
|
163
165
|
$effect(() => {
|
|
164
|
-
if (!scroll || !virtualizeColumns || typeof ResizeObserver === "undefined") return;
|
|
166
|
+
if (stack || !scroll || !virtualizeColumns || typeof ResizeObserver === "undefined") return;
|
|
165
167
|
const observer = new ResizeObserver(() => scheduleColumnVisibility());
|
|
166
168
|
observer.observe(scroll);
|
|
167
169
|
return () => observer.disconnect();
|
|
@@ -180,6 +182,13 @@ $effect(() => {
|
|
|
180
182
|
window.removeEventListener("resize", updateScrollHeightVar);
|
|
181
183
|
};
|
|
182
184
|
});
|
|
185
|
+
useCardProjection({
|
|
186
|
+
board: () => board,
|
|
187
|
+
projection: () => stack ? null : cardProjection,
|
|
188
|
+
model: () => $viewData,
|
|
189
|
+
store,
|
|
190
|
+
dnd
|
|
191
|
+
});
|
|
183
192
|
onDestroy(() => {
|
|
184
193
|
if (visibilityFrame) cancelAnimationFrame(visibilityFrame);
|
|
185
194
|
});
|
|
@@ -195,8 +204,11 @@ onDestroy(() => {
|
|
|
195
204
|
<div
|
|
196
205
|
class="wx-board"
|
|
197
206
|
class:wx-scroll-board={!columnScroll}
|
|
198
|
-
class:wx-layout-flex={!fixedColumnWidth}
|
|
199
|
-
|
|
207
|
+
class:wx-layout-flex={!stack && !fixedColumnWidth}
|
|
208
|
+
class:wx-layout-stack={stack}
|
|
209
|
+
class:wx-lanes={!stack && hasSwimlanes}
|
|
210
|
+
bind:this={board}
|
|
211
|
+
use:cardDrag={{ dnd, store, readonly, disabled: stack }}
|
|
200
212
|
use:delegateCardClick
|
|
201
213
|
use:cardHotkeys
|
|
202
214
|
onmousemove={tooltip ? overlay.handleTooltipMove : undefined}
|
|
@@ -207,25 +219,64 @@ onDestroy(() => {
|
|
|
207
219
|
bind:this={scroll}
|
|
208
220
|
onscroll={scheduleColumnVisibility}
|
|
209
221
|
>
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
222
|
+
{#if stack}
|
|
223
|
+
<Stack
|
|
224
|
+
model={$viewData}
|
|
225
|
+
{scroll}
|
|
226
|
+
{readonly}
|
|
227
|
+
{cardContent}
|
|
228
|
+
{cardShape}
|
|
229
|
+
{virtualizeCards}
|
|
230
|
+
{estimatedCardHeight}
|
|
231
|
+
{cardOverscan}
|
|
232
|
+
{virtualizeColumns}
|
|
233
|
+
{cardListStart}
|
|
234
|
+
{cardListEnd}
|
|
235
|
+
{cardCss}
|
|
236
|
+
{columnCss}
|
|
237
|
+
/>
|
|
238
|
+
{:else if hasSwimlanes}
|
|
239
|
+
<Swimlanes
|
|
240
|
+
model={$viewData}
|
|
241
|
+
{scroll}
|
|
242
|
+
{readonly}
|
|
243
|
+
{cardContent}
|
|
244
|
+
{cardShape}
|
|
245
|
+
{virtualizeCards}
|
|
246
|
+
{estimatedCardHeight}
|
|
247
|
+
{cardOverscan}
|
|
248
|
+
{fixedColumnWidth}
|
|
249
|
+
{registerColumn}
|
|
250
|
+
{cardListStart}
|
|
251
|
+
{cardListEnd}
|
|
252
|
+
{cardCss}
|
|
253
|
+
{columnCss}
|
|
254
|
+
contentVisible={isColumnContentVisible}
|
|
255
|
+
requestVisible={isColumnRequestVisible}
|
|
256
|
+
/>
|
|
257
|
+
{:else}
|
|
258
|
+
<div class="wx-content">
|
|
259
|
+
{#each $viewData.columns as column (column.id)}
|
|
260
|
+
<Column
|
|
261
|
+
{column}
|
|
262
|
+
{readonly}
|
|
263
|
+
{cardContent}
|
|
264
|
+
{cardShape}
|
|
265
|
+
contentVisible={isColumnContentVisible(column.id)}
|
|
266
|
+
requestVisible={isColumnRequestVisible(column.id)}
|
|
267
|
+
{virtualizeCards}
|
|
268
|
+
{estimatedCardHeight}
|
|
269
|
+
{cardOverscan}
|
|
270
|
+
{fixedColumnWidth}
|
|
271
|
+
{registerColumn}
|
|
272
|
+
{cardListStart}
|
|
273
|
+
{cardListEnd}
|
|
274
|
+
{cardCss}
|
|
275
|
+
{columnCss}
|
|
276
|
+
/>
|
|
277
|
+
{/each}
|
|
278
|
+
</div>
|
|
279
|
+
{/if}
|
|
229
280
|
</div>
|
|
230
281
|
</div>
|
|
231
282
|
{#if brandmark}
|
|
@@ -235,22 +286,12 @@ onDestroy(() => {
|
|
|
235
286
|
{/if}
|
|
236
287
|
<DragGhost {root} {cardContent} {cardShape} />
|
|
237
288
|
|
|
238
|
-
{#if cardMenuConfig}
|
|
239
|
-
<ContextMenu
|
|
240
|
-
options={cardMenuConfig.options}
|
|
241
|
-
filter={cardMenuConfig.filter}
|
|
242
|
-
onclick={cardMenuConfig.onclick}
|
|
243
|
-
bind:this={cardMenu}
|
|
244
|
-
/>
|
|
245
|
-
{/if}
|
|
246
|
-
|
|
247
289
|
{#if overlay.tooltipState && tooltip}
|
|
248
290
|
{@const TooltipCmp = tooltip}
|
|
249
291
|
<div
|
|
250
292
|
class="wx-tooltip"
|
|
251
|
-
style="position:fixed;left:{overlay.mousePos.x +
|
|
252
|
-
|
|
253
|
-
16}px;z-index:10000;pointer-events:none"
|
|
293
|
+
style="position:fixed;left:{overlay.mousePos.x + 12}px;top:{overlay
|
|
294
|
+
.mousePos.y + 16}px;z-index:10000;pointer-events:none"
|
|
254
295
|
aria-hidden="true"
|
|
255
296
|
>
|
|
256
297
|
<TooltipCmp card={overlay.tooltipState.card} />
|
|
@@ -291,8 +332,8 @@ onDestroy(() => {
|
|
|
291
332
|
min-height: 0;
|
|
292
333
|
}
|
|
293
334
|
|
|
294
|
-
/*
|
|
295
|
-
|
|
335
|
+
/* The scroll wrapper sits inside the padded board, so the padding stays at
|
|
336
|
+
the edges and never scrolls away. */
|
|
296
337
|
.wx-scroll {
|
|
297
338
|
height: 100%;
|
|
298
339
|
overflow-x: auto;
|
|
@@ -332,7 +373,7 @@ onDestroy(() => {
|
|
|
332
373
|
overflow: visible;
|
|
333
374
|
}
|
|
334
375
|
|
|
335
|
-
.wx-scroll-board :global(.wx-column.wx-collapsed) {
|
|
376
|
+
.wx-scroll-board:not(.wx-lanes) :global(.wx-column.wx-collapsed) {
|
|
336
377
|
position: sticky;
|
|
337
378
|
top: 0;
|
|
338
379
|
z-index: 1;
|
|
@@ -347,13 +388,24 @@ onDestroy(() => {
|
|
|
347
388
|
flex: none;
|
|
348
389
|
}
|
|
349
390
|
|
|
350
|
-
.wx-scroll-board :global(.wx-column-header) {
|
|
391
|
+
.wx-scroll-board:not(.wx-lanes) :global(.wx-column-header) {
|
|
351
392
|
position: sticky;
|
|
352
393
|
top: 0;
|
|
353
394
|
z-index: 1;
|
|
354
395
|
background: var(--wx-kanban-column-bg);
|
|
355
396
|
}
|
|
356
397
|
|
|
398
|
+
/* single vertical column of groups (layout: "stack"): one scroll axis */
|
|
399
|
+
.wx-layout-stack .wx-scroll {
|
|
400
|
+
overflow-x: hidden;
|
|
401
|
+
overflow-y: auto;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/* Without drag, a finger starting on a card must scroll the board. */
|
|
405
|
+
.wx-layout-stack :global(.wx-card) {
|
|
406
|
+
touch-action: auto;
|
|
407
|
+
}
|
|
408
|
+
|
|
357
409
|
/* flexible columns sharing viewport width (fixedColumnWidth: false) */
|
|
358
410
|
.wx-layout-flex :global(.wx-column:not(.wx-collapsed)) {
|
|
359
411
|
flex: 1 1 0;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { CardListSlotProps } from "../types.js";
|
|
1
2
|
import type { Component } from "svelte";
|
|
2
3
|
import type { KanbanCard } from "@svar-ui/kanban-store";
|
|
3
|
-
import type { CardShape, RenderConfig, CardCssFn, ColumnCssFn } from "../types.js";
|
|
4
|
+
import type { CardShape, RenderConfig, CardCssFn, ColumnCssFn, CardProjection } from "../types.js";
|
|
4
5
|
type Props = {
|
|
5
6
|
cardShape: CardShape;
|
|
6
7
|
readonly?: boolean;
|
|
@@ -11,8 +12,11 @@ type Props = {
|
|
|
11
12
|
}>;
|
|
12
13
|
tooltip?: any;
|
|
13
14
|
cardPopup?: any;
|
|
15
|
+
cardListStart?: Component<CardListSlotProps>;
|
|
16
|
+
cardListEnd?: Component<CardListSlotProps>;
|
|
14
17
|
cardCss?: CardCssFn;
|
|
15
18
|
columnCss?: ColumnCssFn;
|
|
19
|
+
cardProjection?: CardProjection | null;
|
|
16
20
|
};
|
|
17
21
|
declare const Layout: Component<Props, {}, "">;
|
|
18
22
|
type Layout = ReturnType<typeof Layout>;
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
<script lang="ts">import { flushSync, getContext, onDestroy, setContext } from "svelte";
|
|
2
|
+
import { setID } from "@svar-ui/lib-dom";
|
|
3
|
+
import { KANBAN_API_CONTEXT, CELL_VIEWPORT_CONTEXT } from "../context.js";
|
|
4
|
+
import { stackGroups } from "../layout/stack.js";
|
|
5
|
+
import CardList from "./CardList.svelte";
|
|
6
|
+
let { model, scroll, readonly, cardContent, cardShape, virtualizeCards, estimatedCardHeight, cardOverscan, virtualizeColumns, cardListStart, cardListEnd, cardCss, columnCss } = $props();
|
|
7
|
+
const store = getContext(KANBAN_API_CONTEXT);
|
|
8
|
+
const _ = getContext("wx-i18n").getGroup("kanban");
|
|
9
|
+
const groups = $derived(stackGroups(model));
|
|
10
|
+
const byColumn = $derived.by(() => {
|
|
11
|
+
const map = new Map();
|
|
12
|
+
for (const column of model.columns) map.set(column.id, []);
|
|
13
|
+
for (const group of groups) map.get(group.column.id).push(group);
|
|
14
|
+
return map;
|
|
15
|
+
});
|
|
16
|
+
// Request visibility only. Rendering never depends on it.
|
|
17
|
+
const pendingColumns = $derived(model.columns.filter((column) => !column.collapsed && column.dataStatus === "unknown"));
|
|
18
|
+
const sections = new Map();
|
|
19
|
+
const marks = new Map();
|
|
20
|
+
let visible = $state(new Set());
|
|
21
|
+
let frame = 0;
|
|
22
|
+
function register(map) {
|
|
23
|
+
return (node, key) => {
|
|
24
|
+
let current = key;
|
|
25
|
+
map.set(current, node);
|
|
26
|
+
scheduleVisibility();
|
|
27
|
+
return {
|
|
28
|
+
update(next) {
|
|
29
|
+
if (map.get(current) === node) map.delete(current);
|
|
30
|
+
current = next;
|
|
31
|
+
map.set(current, node);
|
|
32
|
+
scheduleVisibility();
|
|
33
|
+
},
|
|
34
|
+
destroy() {
|
|
35
|
+
if (map.get(current) === node) map.delete(current);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const section = register(sections);
|
|
41
|
+
const mark = register(marks);
|
|
42
|
+
/**
|
|
43
|
+
* A column is near the viewport when one of its expanded groups is within one
|
|
44
|
+
* viewport height of it. A column without groups is located by its marker, a
|
|
45
|
+
* zero-height element where its groups would be, so an unloaded empty column
|
|
46
|
+
* can still request its data.
|
|
47
|
+
*/
|
|
48
|
+
function updateVisibility() {
|
|
49
|
+
if (!scroll || !virtualizeColumns || !pendingColumns.length) return;
|
|
50
|
+
const rect = scroll.getBoundingClientRect();
|
|
51
|
+
const top = rect.top - rect.height;
|
|
52
|
+
const bottom = rect.bottom + rect.height;
|
|
53
|
+
const near = (node) => {
|
|
54
|
+
if (!node) return false;
|
|
55
|
+
const box = node.getBoundingClientRect();
|
|
56
|
+
return box.bottom >= top && box.top <= bottom;
|
|
57
|
+
};
|
|
58
|
+
const next = new Set();
|
|
59
|
+
for (const column of pendingColumns) {
|
|
60
|
+
const own = byColumn.get(column.id) ?? [];
|
|
61
|
+
const hit = own.length ? own.some((g) => !g.collapsed && near(sections.get(g.key))) : near(marks.get(column.id));
|
|
62
|
+
if (hit) next.add(column.id);
|
|
63
|
+
}
|
|
64
|
+
if (next.size !== visible.size || [...next].some((id) => !visible.has(id))) visible = next;
|
|
65
|
+
}
|
|
66
|
+
// A newly mounted virtual list has no height until its own first frame commits
|
|
67
|
+
// its spacers. Measuring in that frame would see every later column at the
|
|
68
|
+
// top and request them all, so measure one frame later.
|
|
69
|
+
function scheduleVisibility(..._tracked) {
|
|
70
|
+
if (!virtualizeColumns || !pendingColumns.length || frame) return;
|
|
71
|
+
frame = requestAnimationFrame(() => {
|
|
72
|
+
frame = requestAnimationFrame(() => {
|
|
73
|
+
frame = 0;
|
|
74
|
+
updateVisibility();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
$effect(() => {
|
|
79
|
+
scheduleVisibility(groups, virtualizeColumns);
|
|
80
|
+
});
|
|
81
|
+
// One range scheduler for every group list. A group moves when an earlier
|
|
82
|
+
// group or the scroll viewport changes size, without any change of its own,
|
|
83
|
+
// so lists refresh together from the shared scroll and resize signals.
|
|
84
|
+
let root = $state();
|
|
85
|
+
const callbacks = new Set();
|
|
86
|
+
let rangeFrame = 0;
|
|
87
|
+
function scheduleRanges() {
|
|
88
|
+
if (rangeFrame) return;
|
|
89
|
+
rangeFrame = requestAnimationFrame(() => {
|
|
90
|
+
rangeFrame = 0;
|
|
91
|
+
// Groups are stacked, so each list's position depends on the spacers of
|
|
92
|
+
// the lists above it. Commit every range before the next list measures;
|
|
93
|
+
// a fresh list has no height yet and would put every later group in view.
|
|
94
|
+
callbacks.forEach((callback) => flushSync(callback));
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
setContext(CELL_VIEWPORT_CONTEXT, {
|
|
98
|
+
subscribe(callback) {
|
|
99
|
+
callbacks.add(callback);
|
|
100
|
+
scheduleRanges();
|
|
101
|
+
return () => {
|
|
102
|
+
callbacks.delete(callback);
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
schedule: scheduleRanges,
|
|
106
|
+
inset: () => 0
|
|
107
|
+
});
|
|
108
|
+
$effect(() => {
|
|
109
|
+
if (!scroll || !root) return;
|
|
110
|
+
const element = scroll;
|
|
111
|
+
const onChange = () => {
|
|
112
|
+
scheduleRanges();
|
|
113
|
+
scheduleVisibility();
|
|
114
|
+
};
|
|
115
|
+
element.addEventListener("scroll", onChange, { passive: true });
|
|
116
|
+
// The root grows or shrinks with any group, including committed spacers.
|
|
117
|
+
const observer = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(onChange);
|
|
118
|
+
observer?.observe(element);
|
|
119
|
+
observer?.observe(root);
|
|
120
|
+
if (!observer) window.addEventListener("resize", onChange);
|
|
121
|
+
return () => {
|
|
122
|
+
element.removeEventListener("scroll", onChange);
|
|
123
|
+
observer?.disconnect();
|
|
124
|
+
window.removeEventListener("resize", onChange);
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
function toggleColumn(column) {
|
|
128
|
+
store.exec("update-column", {
|
|
129
|
+
id: column.id,
|
|
130
|
+
column: { collapsed: !column.collapsed },
|
|
131
|
+
skipProvider: true
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function toggleLane(id, collapsed) {
|
|
135
|
+
store.exec("update-swimlane", {
|
|
136
|
+
id,
|
|
137
|
+
swimlane: { collapsed: !collapsed }
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
onDestroy(() => {
|
|
141
|
+
if (frame) cancelAnimationFrame(frame);
|
|
142
|
+
if (rangeFrame) cancelAnimationFrame(rangeFrame);
|
|
143
|
+
});
|
|
144
|
+
</script>
|
|
145
|
+
|
|
146
|
+
<div class="wx-stack" bind:this={root}>
|
|
147
|
+
{#each model.columns as column (column.id)}
|
|
148
|
+
<div class="wx-stack-mark" use:mark={column.id}></div>
|
|
149
|
+
{#each byColumn.get(column.id) ?? [] as group (group.key)}
|
|
150
|
+
{@const lane = group.swimlane}
|
|
151
|
+
<section
|
|
152
|
+
class="wx-stack-group {column.css ?? ''} {columnCss?.(
|
|
153
|
+
group.cards,
|
|
154
|
+
column
|
|
155
|
+
) ?? ''}"
|
|
156
|
+
class:wx-collapsed={group.collapsed}
|
|
157
|
+
data-stack-column={setID(column.id)}
|
|
158
|
+
data-stack-lane={lane ? setID(lane.id) : undefined}
|
|
159
|
+
use:section={group.key}
|
|
160
|
+
>
|
|
161
|
+
<header
|
|
162
|
+
class="wx-stack-header"
|
|
163
|
+
data-column-id={setID(column.id)}
|
|
164
|
+
data-lane-id={lane ? setID(lane.id) : undefined}
|
|
165
|
+
>
|
|
166
|
+
<button
|
|
167
|
+
type="button"
|
|
168
|
+
class="wx-toggle"
|
|
169
|
+
onclick={() => toggleColumn(column)}
|
|
170
|
+
aria-expanded={!column.collapsed}
|
|
171
|
+
aria-label={column.collapsed
|
|
172
|
+
? `${_("Expand column")} ${column.label}`
|
|
173
|
+
: _("Collapse column")}
|
|
174
|
+
>
|
|
175
|
+
<i
|
|
176
|
+
class="wx-icon {column.collapsed
|
|
177
|
+
? 'wxi-angle-right'
|
|
178
|
+
: 'wxi-angle-down'}"
|
|
179
|
+
></i>
|
|
180
|
+
</button>
|
|
181
|
+
<h3 class="wx-title">{column.label}</h3>
|
|
182
|
+
{#if lane}
|
|
183
|
+
<button
|
|
184
|
+
type="button"
|
|
185
|
+
class="wx-lane-toggle"
|
|
186
|
+
aria-expanded={!lane.collapsed}
|
|
187
|
+
aria-label={`${_(lane.collapsed ? "Expand swimlane" : "Collapse swimlane")} ${lane.label}`}
|
|
188
|
+
onclick={() => toggleLane(lane.id, !!lane.collapsed)}
|
|
189
|
+
>
|
|
190
|
+
<i
|
|
191
|
+
class="wx-icon {lane.collapsed
|
|
192
|
+
? 'wxi-angle-right'
|
|
193
|
+
: 'wxi-angle-down'}"
|
|
194
|
+
></i>
|
|
195
|
+
<span class="wx-lane-label">{lane.label}</span>
|
|
196
|
+
</button>
|
|
197
|
+
{/if}
|
|
198
|
+
{#if column.summaries.length}
|
|
199
|
+
<div class="wx-column-summaries">
|
|
200
|
+
{#each column.summaries as summary (summary.id)}
|
|
201
|
+
<span
|
|
202
|
+
class="wx-column-summary {summary.css ?? ''}"
|
|
203
|
+
title={summary.text}>{summary.text}</span
|
|
204
|
+
>
|
|
205
|
+
{/each}
|
|
206
|
+
</div>
|
|
207
|
+
{/if}
|
|
208
|
+
{#if column.menu}
|
|
209
|
+
<button
|
|
210
|
+
type="button"
|
|
211
|
+
class="wx-column-menu"
|
|
212
|
+
data-column-menu={setID(column.id)}
|
|
213
|
+
aria-label="{_('Column menu')} {column.label}"
|
|
214
|
+
aria-haspopup="menu"
|
|
215
|
+
>
|
|
216
|
+
<i class="wx-icon wxi-dots-h"></i>
|
|
217
|
+
</button>
|
|
218
|
+
{/if}
|
|
219
|
+
</header>
|
|
220
|
+
<div class="wx-stack-body">
|
|
221
|
+
<CardList
|
|
222
|
+
{column}
|
|
223
|
+
cards={group.cards}
|
|
224
|
+
swimlane={lane?.id}
|
|
225
|
+
swimlaneView={lane}
|
|
226
|
+
active={!group.collapsed}
|
|
227
|
+
{readonly}
|
|
228
|
+
{cardContent}
|
|
229
|
+
{cardShape}
|
|
230
|
+
contentVisible={true}
|
|
231
|
+
{virtualizeCards}
|
|
232
|
+
{estimatedCardHeight}
|
|
233
|
+
{cardOverscan}
|
|
234
|
+
fixedColumnWidth={true}
|
|
235
|
+
{cardListStart}
|
|
236
|
+
{cardListEnd}
|
|
237
|
+
{cardCss}
|
|
238
|
+
/>
|
|
239
|
+
</div>
|
|
240
|
+
</section>
|
|
241
|
+
{/each}
|
|
242
|
+
{/each}
|
|
243
|
+
</div>
|
|
244
|
+
|
|
245
|
+
<style>
|
|
246
|
+
.wx-stack {
|
|
247
|
+
min-width: 0;
|
|
248
|
+
overflow-anchor: none;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.wx-stack-mark {
|
|
252
|
+
height: 0;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.wx-stack-group {
|
|
256
|
+
margin-bottom: 12px;
|
|
257
|
+
background: var(--wx-kanban-column-bg);
|
|
258
|
+
border-radius: var(--wx-radius-major);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* The one sticky level: scoped to its own section, so consecutive headers push
|
|
262
|
+
each other out with no coordination and no measured offset. */
|
|
263
|
+
.wx-stack-header {
|
|
264
|
+
position: sticky;
|
|
265
|
+
top: 0;
|
|
266
|
+
z-index: 1;
|
|
267
|
+
display: flex;
|
|
268
|
+
align-items: center;
|
|
269
|
+
gap: 8px;
|
|
270
|
+
padding: 10px 12px;
|
|
271
|
+
background: var(--wx-kanban-column-bg);
|
|
272
|
+
border-bottom: 1px solid var(--wx-kanban-border-color);
|
|
273
|
+
border-radius: var(--wx-radius-major) var(--wx-radius-major) 0 0;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.wx-collapsed .wx-stack-header {
|
|
277
|
+
border-bottom-color: transparent;
|
|
278
|
+
border-radius: var(--wx-radius-major);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/* Flow tracks never shrink; clip rather than scroll so no horizontal axis
|
|
282
|
+
appears. `clip` creates no scroll container, so sticky is unaffected. */
|
|
283
|
+
.wx-stack-body {
|
|
284
|
+
min-width: 0;
|
|
285
|
+
overflow-x: clip;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.wx-collapsed .wx-stack-body {
|
|
289
|
+
display: none;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.wx-title {
|
|
293
|
+
flex: 1;
|
|
294
|
+
min-width: 0;
|
|
295
|
+
margin: 0;
|
|
296
|
+
font-weight: var(--wx-font-weight-md);
|
|
297
|
+
overflow: hidden;
|
|
298
|
+
text-overflow: ellipsis;
|
|
299
|
+
white-space: nowrap;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.wx-icon {
|
|
303
|
+
font-size: var(--wx-icon-size);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.wx-toggle,
|
|
307
|
+
.wx-column-menu {
|
|
308
|
+
display: inline-flex;
|
|
309
|
+
align-items: center;
|
|
310
|
+
justify-content: center;
|
|
311
|
+
background: none;
|
|
312
|
+
border: none;
|
|
313
|
+
border-radius: var(--wx-icon-border-radius);
|
|
314
|
+
padding: 0;
|
|
315
|
+
flex: 0 0 18px;
|
|
316
|
+
width: 18px;
|
|
317
|
+
height: 18px;
|
|
318
|
+
cursor: pointer;
|
|
319
|
+
font-size: var(--wx-font-size-sm);
|
|
320
|
+
color: var(--wx-color-font-alt);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.wx-toggle:hover,
|
|
324
|
+
.wx-column-menu:hover,
|
|
325
|
+
.wx-lane-toggle:hover {
|
|
326
|
+
background: var(--wx-background-hover);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.wx-toggle:focus,
|
|
330
|
+
.wx-column-menu:focus {
|
|
331
|
+
outline: none;
|
|
332
|
+
border: 1px solid var(--wx-color-primary);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.wx-lane-toggle {
|
|
336
|
+
display: inline-flex;
|
|
337
|
+
align-items: center;
|
|
338
|
+
gap: 4px;
|
|
339
|
+
min-width: 0;
|
|
340
|
+
max-width: 40%;
|
|
341
|
+
padding: 0 4px;
|
|
342
|
+
border: 1px solid transparent;
|
|
343
|
+
border-radius: var(--wx-icon-border-radius);
|
|
344
|
+
background: transparent;
|
|
345
|
+
color: var(--wx-color-font-alt);
|
|
346
|
+
cursor: pointer;
|
|
347
|
+
font: inherit;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.wx-lane-toggle:focus-visible {
|
|
351
|
+
outline: none;
|
|
352
|
+
border-color: var(--wx-color-primary);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.wx-lane-label {
|
|
356
|
+
overflow: hidden;
|
|
357
|
+
text-overflow: ellipsis;
|
|
358
|
+
white-space: nowrap;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.wx-column-summaries {
|
|
362
|
+
display: flex;
|
|
363
|
+
align-items: center;
|
|
364
|
+
gap: 4px;
|
|
365
|
+
min-width: 0;
|
|
366
|
+
max-width: 40%;
|
|
367
|
+
overflow: hidden;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.wx-column-summary {
|
|
371
|
+
min-width: 0;
|
|
372
|
+
overflow: hidden;
|
|
373
|
+
text-overflow: ellipsis;
|
|
374
|
+
white-space: nowrap;
|
|
375
|
+
padding: 1px 6px;
|
|
376
|
+
border: 1px solid var(--wx-kanban-border-color);
|
|
377
|
+
border-radius: var(--wx-border-radius);
|
|
378
|
+
background: var(--wx-kanban-tag-bg);
|
|
379
|
+
font-size: var(--wx-font-size-sm);
|
|
380
|
+
line-height: var(--wx-line-height-sm);
|
|
381
|
+
color: var(--wx-color-font-alt);
|
|
382
|
+
}
|
|
383
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CardListSlotProps } from "../types.js";
|
|
2
|
+
import type { Component } from "svelte";
|
|
3
|
+
import type { KanbanModel, KanbanCard } from "@svar-ui/kanban-store";
|
|
4
|
+
import type { CardShape, CardCssFn, ColumnCssFn } from "../types.js";
|
|
5
|
+
type Props = {
|
|
6
|
+
model: KanbanModel;
|
|
7
|
+
scroll?: HTMLElement;
|
|
8
|
+
readonly: boolean;
|
|
9
|
+
cardContent?: Component<{
|
|
10
|
+
card: KanbanCard;
|
|
11
|
+
cardShape: CardShape;
|
|
12
|
+
}>;
|
|
13
|
+
cardShape: CardShape;
|
|
14
|
+
virtualizeCards: boolean;
|
|
15
|
+
estimatedCardHeight: number;
|
|
16
|
+
cardOverscan: number;
|
|
17
|
+
/** Gates `request-data` on vertical visibility, as in the board layout. */
|
|
18
|
+
virtualizeColumns: boolean;
|
|
19
|
+
cardListStart?: Component<CardListSlotProps>;
|
|
20
|
+
cardListEnd?: Component<CardListSlotProps>;
|
|
21
|
+
cardCss?: CardCssFn;
|
|
22
|
+
columnCss?: ColumnCssFn;
|
|
23
|
+
};
|
|
24
|
+
declare const Stack: Component<Props, {}, "">;
|
|
25
|
+
type Stack = ReturnType<typeof Stack>;
|
|
26
|
+
export default Stack;
|