@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
@@ -1,8 +1,11 @@
1
1
  <script lang="ts">import { getContext } from "svelte";
2
+ import { dateToString } from "@svar-ui/lib-dom";
2
3
  import Avatar from "./Avatar.svelte";
4
+ import CardMenuButton from "./CardMenuButton.svelte";
3
5
  import { getPriorityOptions } from "../defaults.js";
4
6
  let { card, cardShape } = $props();
5
- const _ = getContext("wx-i18n").getGroup("kanban");
7
+ const i18n = getContext("wx-i18n");
8
+ const _ = i18n.getGroup("kanban");
6
9
  function countOf(v) {
7
10
  if (typeof v === "number") return v;
8
11
  if (Array.isArray(v)) return v.length;
@@ -40,22 +43,12 @@ function resolveItems(values, collection, max) {
40
43
  const items = values.map((value) => resolveItem(value, collection)).filter((item) => item !== null);
41
44
  return typeof max === "number" && Number.isFinite(max) ? items.slice(0, Math.max(0, max)) : items;
42
45
  }
43
- function toDate(value) {
44
- if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : value;
45
- if (typeof value === "string" || typeof value === "number") {
46
- const d = new Date(value);
47
- return Number.isNaN(d.getTime()) ? null : d;
48
- }
49
- return null;
50
- }
51
- function pad2(n) {
52
- return n < 10 ? "0" + n : String(n);
53
- }
46
+ // string formats use the wx locale tokens ("%m/%d/%Y"); default is the locale dateFormat
54
47
  function formatDeadline(value, format) {
55
- const d = toDate(value);
56
- if (!d) return null;
57
- if (!format) return d.toLocaleDateString();
58
- return format.replace(/YYYY/g, String(d.getFullYear())).replace(/MM/g, pad2(d.getMonth() + 1)).replace(/DD/g, pad2(d.getDate())).replace(/HH/g, pad2(d.getHours())).replace(/mm/g, pad2(d.getMinutes()));
48
+ if (!(value instanceof Date)) return null;
49
+ if (typeof format === "function") return format(value);
50
+ const { calendar, formats } = i18n.getRaw();
51
+ return dateToString(format || formats.dateFormat, calendar)(value);
59
52
  }
60
53
  let priorityConfig = $derived(configOf(cardShape.priority));
61
54
  let tagConfig = $derived(configOf(cardShape.tags));
@@ -75,37 +68,23 @@ let deadline = $derived(cardShape.deadline ? formatDeadline(card.deadline, deadl
75
68
  </script>
76
69
 
77
70
  {#if card.cover && cardShape.cover}
78
- <div
79
- class="wx-cover"
80
- style="background-image: url({card.cover});"
81
- ></div>
71
+ <div class="wx-cover" style="background-image: url({card.cover});"></div>
82
72
  {/if}
83
73
 
84
-
85
74
  {#if priority || deadline}
86
75
  <div class="wx-header">
87
76
  {#if priority}
88
- <span class="wx-priority {priority.css ?? ''}"
89
- >{_(priority.label)}</span
90
- >
77
+ <span class="wx-priority {priority.css ?? ''}">{_(priority.label)}</span>
91
78
  {/if}
92
79
  {#if deadline}
93
80
  <span class="wx-deadline">{deadline}</span>
94
81
  {/if}
95
82
  {#if cardShape.menu}
96
- <button
97
- type="button"
98
- class="wx-menu"
99
- data-action="menu"
100
- aria-label={_("Card menu")}
101
- >
102
- <i class="wx-icon wxi-dots-h"></i>
103
- </button>
83
+ <CardMenuButton {card} />
104
84
  {/if}
105
85
  </div>
106
86
  {/if}
107
87
 
108
-
109
88
  <div class="wx-body">
110
89
  <div class="wx-title-row">
111
90
  {#if card.label}
@@ -113,14 +92,7 @@ let deadline = $derived(cardShape.deadline ? formatDeadline(card.deadline, deadl
113
92
  {card.label}
114
93
 
115
94
  {#if cardShape.menu && !priority && !deadline}
116
- <button
117
- type="button"
118
- class="wx-menu"
119
- data-action="menu"
120
- aria-label={_("Card menu")}
121
- >
122
- <i class="wx-icon wxi-dots-h"></i>
123
- </button>
95
+ <CardMenuButton {card} />
124
96
  {/if}
125
97
  </div>
126
98
  {/if}
@@ -138,10 +110,7 @@ let deadline = $derived(cardShape.deadline ? formatDeadline(card.deadline, deadl
138
110
  {#if card.progress > 0 && cardShape.progress}
139
111
  <div class="wx-progress-row">
140
112
  <div class="wx-progress" aria-label={_("Progress")}>
141
- <div
142
- class="wx-progress-fill"
143
- style="width: {progressPercent}%;"
144
- ></div>
113
+ <div class="wx-progress-fill" style="width: {progressPercent}%;"></div>
145
114
  </div>
146
115
  {#if progressConfig?.showLabel}
147
116
  <span class="wx-progress-label">{progressPercent}%</span>
@@ -150,7 +119,6 @@ let deadline = $derived(cardShape.deadline ? formatDeadline(card.deadline, deadl
150
119
  {/if}
151
120
  </div>
152
121
 
153
-
154
122
  {#if users.length > 0 || (countOf(card.attachments) > 0 && cardShape.attachments) || (countOf(card.comments) > 0 && cardShape.comments)}
155
123
  <div class="wx-footer">
156
124
  {#if avatarUsers.length > 0}
@@ -219,35 +187,10 @@ let deadline = $derived(cardShape.deadline ? formatDeadline(card.deadline, deadl
219
187
  color: var(--wx-color-font-alt);
220
188
  }
221
189
 
222
- .wx-menu {
223
- display: inline-flex;
224
- align-items: center;
225
- justify-content: center;
226
- background: none;
227
- border: none;
228
- padding: 0;
229
- width: 22px;
230
- height: 22px;
231
- border-radius: var(--wx-icon-border-radius);
232
- cursor: pointer;
233
- color: var(--wx-color-font-alt);
234
- font-size: 16px;
235
- }
236
-
237
- .wx-title .wx-menu {
190
+ .wx-title :global(.wx-menu) {
238
191
  float: right;
239
192
  }
240
193
 
241
- .wx-menu:hover {
242
- background: var(--wx-background-hover);
243
- color: var(--wx-color-font);
244
- }
245
-
246
- .wx-menu:focus-visible {
247
- outline: none;
248
- border: 1px solid var(--wx-color-primary);
249
- }
250
-
251
194
  .wx-body {
252
195
  display: flex;
253
196
  flex-direction: column;
@@ -1,343 +1,10 @@
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 } from "../context.js";
5
- import { DndState } from "./useDrag.svelte.js";
6
- import { dblclick } from "../directives/dblclick.js";
7
- let { column, readonly = false, cardContent, cardShape, contentVisible, virtualizeCards, estimatedCardHeight, cardOverscan, fixedColumnWidth, cardCss } = $props();
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 = $derived(store.getState().columnAccessor);
15
- let container = $state();
16
- let range = $state({
17
- start: 0,
18
- end: -1,
19
- top: 0,
20
- bottom: 0,
21
- total: 0
22
- });
23
- let cardGap = $state(8);
24
- let frame = 0;
25
- let previousVirtualizeCards = false;
26
- const heightCache = new Map();
27
- const measuredNodes = new Map();
28
- let cardObserver;
29
- const isDropColumn = $derived(dnd?.active && dnd.target?.column === column.id);
30
- const renderStart = $derived(virtualizeCards ? range.start : 0);
31
- const renderEnd = $derived(virtualizeCards ? range.end : column.cards.length - 1);
32
- const renderedCards = $derived(contentVisible ? column.cards.slice(renderStart, Math.max(renderStart, renderEnd + 1)) : []);
33
- const hiddenHeight = $derived(range.total || estimateTotalHeight(column.cards.length));
34
- const topSpacerHeight = $derived(range.start > 0 ? Math.max(0, range.top - cardGap) : 0);
35
- const bottomSpacerHeight = $derived(range.bottom > 0 ? Math.max(0, range.bottom - cardGap) : 0);
36
- const afterRenderedBeforeId = $derived(contentVisible && virtualizeCards && renderEnd >= 0 && renderEnd < column.cards.length - 1 ? column.cards[renderEnd + 1]?.id : undefined);
37
- const trailingPlaceholder = $derived(isDropColumn && (dnd.target.beforeId == null || dnd.target.beforeId === afterRenderedBeforeId));
38
- function estimateTotalHeight(count) {
39
- if (!count) return 0;
40
- const height = Math.max(1, estimatedCardHeight || 1);
41
- return count * height + Math.max(0, count - 1) * cardGap;
42
- }
43
- function readGap() {
44
- if (!container) return;
45
- const styles = getComputedStyle(container);
46
- const configuredGap = styles.getPropertyValue("--wx-card-gap").trim();
47
- const raw = configuredGap || styles.rowGap || styles.gap;
48
- const next = Number.parseFloat(raw);
49
- cardGap = Number.isFinite(next) ? next : 8;
50
- }
51
- function getCardHeight(card) {
52
- return card.id != null ? heightCache.get(card.id) ?? Math.max(1, estimatedCardHeight || 1) : Math.max(1, estimatedCardHeight || 1);
53
- }
54
- function buildOffsets() {
55
- const offsets = [0];
56
- let total = 0;
57
- for (let i = 0; i < column.cards.length; i++) {
58
- total += getCardHeight(column.cards[i]);
59
- if (i < column.cards.length - 1) total += cardGap;
60
- offsets.push(total);
61
- }
62
- return {
63
- offsets,
64
- total
65
- };
66
- }
67
- function upperBound(values, value) {
68
- let low = 0;
69
- let high = values.length;
70
- while (low < high) {
71
- const mid = Math.floor((low + high) / 2);
72
- if (values[mid] <= value) low = mid + 1;
73
- else high = mid;
74
- }
75
- return low;
76
- }
77
- function recalculate() {
78
- if (!container) return;
79
- readGap();
80
- if (!contentVisible || !virtualizeCards) {
81
- range = {
82
- start: 0,
83
- end: contentVisible ? column.cards.length - 1 : -1,
84
- top: 0,
85
- bottom: 0,
86
- total: estimateTotalHeight(column.cards.length)
87
- };
88
- return;
89
- }
90
- const count = column.cards.length;
91
- if (!count) {
92
- range = {
93
- start: 0,
94
- end: -1,
95
- top: 0,
96
- bottom: 0,
97
- total: 0
98
- };
99
- return;
100
- }
101
- const { offsets, total } = buildOffsets();
102
- const boardScroll = getScrollContainer?.() ?? null;
103
- let viewportTop = 0;
104
- let viewportBottom = 0;
105
- if (boardScroll) {
106
- const boardRect = boardScroll.getBoundingClientRect();
107
- const containerRect = container.getBoundingClientRect();
108
- viewportTop = Math.max(0, boardRect.top - containerRect.top);
109
- viewportBottom = Math.min(total, boardRect.bottom - containerRect.top);
110
- } else {
111
- viewportTop = container.scrollTop;
112
- viewportBottom = viewportTop + container.clientHeight;
113
- }
114
- const safeOverscan = Math.max(0, Math.floor(cardOverscan || 0));
115
- let start = Math.max(0, upperBound(offsets, viewportTop) - 1);
116
- let end = Math.max(start, upperBound(offsets, viewportBottom) - 1);
117
- start = Math.max(0, start - safeOverscan);
118
- end = Math.min(count - 1, end + safeOverscan);
119
- range = {
120
- start,
121
- end,
122
- top: offsets[start],
123
- bottom: Math.max(0, total - offsets[end + 1]),
124
- total
125
- };
126
- }
127
- function scheduleRecalculate(..._tracked) {
128
- if (frame) return;
129
- frame = requestAnimationFrame(() => {
130
- frame = 0;
131
- recalculate();
132
- });
133
- }
134
- function pruneHeightCache() {
135
- const ids = new Set(column.cards.map((card) => card.id));
136
- for (const id of heightCache.keys()) {
137
- if (!ids.has(id)) heightCache.delete(id);
138
- }
139
- while (heightCache.size > 1e4) {
140
- const first = heightCache.keys().next().value;
141
- if (first === undefined) break;
142
- heightCache.delete(first);
143
- }
144
- }
145
- function ensureCardObserver() {
146
- if (cardObserver || typeof ResizeObserver === "undefined") return;
147
- cardObserver = new ResizeObserver((entries) => {
148
- let changed = false;
149
- for (const entry of entries) {
150
- const id = measuredNodes.get(entry.target);
151
- if (id == null) continue;
152
- const height = Math.ceil(entry.target.offsetHeight);
153
- if (height > 0 && heightCache.get(id) !== height) {
154
- heightCache.delete(id);
155
- heightCache.set(id, height);
156
- changed = true;
157
- }
158
- }
159
- if (changed) scheduleRecalculate();
160
- });
161
- }
162
- function measureCard(node, card) {
163
- if (card.id != null) {
164
- ensureCardObserver();
165
- measuredNodes.set(node, card.id);
166
- cardObserver?.observe(node);
167
- }
168
- return {
169
- update(next) {
170
- cardObserver?.unobserve(node);
171
- if (next.id != null) {
172
- measuredNodes.set(node, next.id);
173
- cardObserver?.observe(node);
174
- } else {
175
- measuredNodes.delete(node);
176
- }
177
- },
178
- destroy() {
179
- cardObserver?.unobserve(node);
180
- measuredNodes.delete(node);
181
- }
182
- };
183
- }
184
- $effect(() => {
185
- if (virtualizeCards && !previousVirtualizeCards) {
186
- heightCache.clear();
187
- }
188
- previousVirtualizeCards = virtualizeCards;
189
- pruneHeightCache();
190
- scheduleRecalculate(column.cards, contentVisible, estimatedCardHeight, cardOverscan);
191
- });
192
- $effect(() => {
193
- if (!container || !contentVisible || !virtualizeCards) return;
194
- const scrollElement = getScrollContainer?.() ?? container;
195
- const onScroll = () => scheduleRecalculate();
196
- scrollElement.addEventListener("scroll", onScroll, { passive: true });
197
- window.addEventListener("resize", onScroll);
198
- scheduleRecalculate();
199
- return () => {
200
- scrollElement.removeEventListener("scroll", onScroll);
201
- window.removeEventListener("resize", onScroll);
202
- };
203
- });
204
- $effect(() => {
205
- if (!container || !contentVisible || !virtualizeCards || fixedColumnWidth || typeof ResizeObserver === "undefined") {
206
- return;
207
- }
208
- let width = container.clientWidth;
209
- const observer = new ResizeObserver(() => {
210
- const next = container?.clientWidth ?? 0;
211
- if (next && next !== width) {
212
- width = next;
213
- heightCache.clear();
214
- scheduleRecalculate();
215
- }
216
- });
217
- observer.observe(container);
218
- return () => observer.disconnect();
219
- });
220
- onDestroy(() => {
221
- if (frame) cancelAnimationFrame(frame);
222
- cardObserver?.disconnect();
223
- });
1
+ <script lang="ts">import StackCardList from "./StackCardList.svelte";
2
+ const FlowCardList = StackCardList;
3
+ let props = $props();
224
4
  </script>
225
5
 
226
- <div
227
- class="wx-column-cards"
228
- data-kanban-column-cards={setID(column.id)}
229
- data-kanban-render-start={renderStart}
230
- data-kanban-render-end={renderEnd}
231
- data-kanban-card-count={column.cards.length}
232
- data-kanban-after-rendered-before-id={afterRenderedBeforeId == null
233
- ? undefined
234
- : setID(afterRenderedBeforeId)}
235
- bind:this={container}
236
- use:dblclick={{
237
- store,
238
- column: column.id,
239
- columnAccessor,
240
- readonly,
241
- }}
242
- >
243
- {#if contentVisible}
244
- {#if virtualizeCards}
245
- {#if topSpacerHeight > 0}
246
- <div
247
- class="wx-virtual-spacer"
248
- style:height="{topSpacerHeight}px"
249
- ></div>
250
- {/if}
251
- {#each renderedCards as cardItem (cardItem.id)}
252
- {#if isDropColumn && dnd.target!.beforeId === cardItem.id}
253
- <div
254
- class="wx-drop-placeholder"
255
- style:height="{dnd.height}px"
256
- ></div>
257
- {/if}
258
- {@const extraCss = getCardExtraCss(cardItem)}
259
- <div
260
- class="wx-card-row {cardItem.css ?? ''} {extraCss}"
261
- data-kanban-card-id={cardItem.id == null
262
- ? undefined
263
- : setID(cardItem.id)}
264
- use:measureCard={cardItem}
265
- class:wx-dragging={dnd?.active &&
266
- dnd.cardId === cardItem.id}
267
- >
268
- <CardWrapper card={cardItem} {cardContent} {cardShape} {extraCss} />
269
- </div>
270
- {/each}
271
- {#if trailingPlaceholder}
272
- <div
273
- class="wx-drop-placeholder"
274
- style:height="{dnd.height}px"
275
- ></div>
276
- {/if}
277
- {#if bottomSpacerHeight > 0}
278
- <div
279
- class="wx-virtual-spacer"
280
- style:height="{bottomSpacerHeight}px"
281
- ></div>
282
- {/if}
283
- {:else}
284
- {#each column.cards as cardItem (cardItem.id)}
285
- {#if isDropColumn && dnd.target!.beforeId === cardItem.id}
286
- <div
287
- class="wx-drop-placeholder"
288
- style:height="{dnd.height}px"
289
- ></div>
290
- {/if}
291
- {@const extraCss = getCardExtraCss(cardItem)}
292
- <div
293
- class="wx-card-row {cardItem.css ?? ''} {extraCss}"
294
- data-kanban-card-id={cardItem.id == null
295
- ? undefined
296
- : setID(cardItem.id)}
297
- class:wx-dragging={dnd?.active &&
298
- dnd.cardId === cardItem.id}
299
- >
300
- <CardWrapper card={cardItem} {cardContent} {cardShape} {extraCss} />
301
- </div>
302
- {/each}
303
- {#if trailingPlaceholder}
304
- <div
305
- class="wx-drop-placeholder"
306
- style:height="{dnd.height}px"
307
- ></div>
308
- {/if}
309
- {/if}
310
- {:else if hiddenHeight > 0}
311
- <div
312
- class="wx-virtual-spacer"
313
- style:height="{hiddenHeight}px"
314
- ></div>
315
- {/if}
316
- </div>
317
-
318
- <style>
319
- .wx-column-cards {
320
- display: flex;
321
- flex-direction: column;
322
- gap: 8px;
323
- padding: 8px;
324
- overflow-y: auto;
325
- flex: 1;
326
- min-height: 0;
327
- }
328
-
329
- .wx-column-cards > :global(div) {
330
- flex-shrink: 0;
331
- }
332
-
333
- .wx-drop-placeholder {
334
- border: 1px dashed var(--wx-kanban-border-color);
335
- border-radius: var(--wx-border-radius);
336
- background: var(--wx-kanban-drop-placeholder-bg);
337
- box-sizing: border-box;
338
- }
339
-
340
- .wx-dragging {
341
- display: none;
342
- }
343
- </style>
6
+ {#if props.column.cardWidth !== undefined}
7
+ <FlowCardList {...props} />
8
+ {:else}
9
+ <StackCardList {...props} />
10
+ {/if}
@@ -1,21 +1,23 @@
1
- import type { Component } from "svelte";
2
- import type { ColumnView, KanbanCard } from "@svar-ui/kanban-store";
3
- import type { CardShape, CardCssFn } from "../types.js";
4
- type Props = {
5
- column: ColumnView;
1
+ declare const CardList: import("svelte").Component<{
2
+ column: import("@svar-ui/kanban-store").ColumnView;
3
+ cards?: import("@svar-ui/kanban-store").KanbanCard[];
4
+ swimlane?: import("@svar-ui/kanban-store").SwimlaneID;
5
+ swimlaneView?: import("..").CardListSlotProps["swimlane"];
6
+ active?: boolean;
6
7
  readonly?: boolean;
7
- cardContent?: Component<{
8
- card: KanbanCard;
9
- cardShape: CardShape;
8
+ cardContent?: import("svelte").Component<{
9
+ card: import("@svar-ui/kanban-store").KanbanCard;
10
+ cardShape: import("..").CardShape;
10
11
  }>;
11
- cardShape: CardShape;
12
+ cardShape: import("..").CardShape;
12
13
  contentVisible: boolean;
13
14
  virtualizeCards: boolean;
14
15
  estimatedCardHeight: number;
15
16
  cardOverscan: number;
16
17
  fixedColumnWidth: boolean;
17
- cardCss?: CardCssFn;
18
- };
19
- declare const CardList: Component<Props, {}, "">;
18
+ cardListStart?: import("svelte").Component<import("..").CardListSlotProps>;
19
+ cardListEnd?: import("svelte").Component<import("..").CardListSlotProps>;
20
+ cardCss?: import("..").CardCssFn;
21
+ }, {}, "">;
20
22
  type CardList = ReturnType<typeof CardList>;
21
23
  export default CardList;
@@ -0,0 +1,47 @@
1
+ <!-- @component Card ⋯ button that opens an outer CardActionMenu; usable inside a custom `cardContent`. -->
2
+ <script lang="ts">import { getContext } from "svelte";
3
+ import { locale, setID } from "@svar-ui/lib-dom";
4
+ import { en } from "@svar-ui/kanban-locales";
5
+ let { card, css = "" } = $props();
6
+ // rendered inside <Kanban> the kanban locale is in context; fall back for standalone use
7
+ const _ = (getContext("wx-i18n") ?? locale({ ...en })).getGroup("kanban");
8
+ </script>
9
+
10
+ <!-- data-action="menu" keeps the click from selecting the card -->
11
+ <button
12
+ type="button"
13
+ class="wx-menu {css}"
14
+ data-action="menu"
15
+ data-card-menu={setID(card.id)}
16
+ aria-label={_("Card menu")}
17
+ aria-haspopup="menu"
18
+ >
19
+ <i class="wx-icon wxi-dots-h"></i>
20
+ </button>
21
+
22
+ <style>
23
+ .wx-menu {
24
+ display: inline-flex;
25
+ align-items: center;
26
+ justify-content: center;
27
+ background: none;
28
+ border: none;
29
+ padding: 0;
30
+ width: 22px;
31
+ height: 22px;
32
+ border-radius: var(--wx-icon-border-radius);
33
+ cursor: pointer;
34
+ color: var(--wx-color-font-alt);
35
+ font-size: 16px;
36
+ }
37
+
38
+ .wx-menu:hover {
39
+ background: var(--wx-background-hover);
40
+ color: var(--wx-color-font);
41
+ }
42
+
43
+ .wx-menu:focus-visible {
44
+ outline: none;
45
+ border: 1px solid var(--wx-color-primary);
46
+ }
47
+ </style>
@@ -0,0 +1,10 @@
1
+ import type { KanbanCard } from "@svar-ui/kanban-store";
2
+ type Props = {
3
+ card: KanbanCard;
4
+ /** Extra class names for the button. */
5
+ css?: string;
6
+ };
7
+ /** Card ⋯ button that opens an outer CardActionMenu; usable inside a custom `cardContent`. */
8
+ declare const CardMenuButton: import("svelte").Component<Props, {}, "">;
9
+ type CardMenuButton = ReturnType<typeof CardMenuButton>;
10
+ export default CardMenuButton;
@@ -14,12 +14,9 @@ const _ = getContext("wx-i18n").getGroup("kanban");
14
14
  aria-label={card.label ?? `${_("Card")} ${card.id}`}
15
15
  >
16
16
  {#if CardContent}
17
- <CardContent
18
- {card}
19
- {cardShape}
20
- ></CardContent>
17
+ <CardContent {card} {cardShape}></CardContent>
21
18
  {:else}
22
- <Card card={card} {cardShape} />
19
+ <Card {card} {cardShape} />
23
20
  {/if}
24
21
  </article>
25
22