@design.estate/dees-catalog 21.46.1 → 21.47.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 (66) hide show
  1. package/dist_bundle/bundle.js +788 -247
  2. package/dist_bundle/bundle.js.map +1 -1
  3. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-FCUX4QGD.js → chunk-Q5VY4AV7.js} +3 -3
  4. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-LWT7IIPZ.js → chunk-QG5BHDQO.js} +2 -2
  5. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-VJVZHESI.js → chunk-UPDBEHU2.js} +16 -3
  6. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-VJVZHESI.js.map → chunk-UPDBEHU2.js.map} +1 -1
  7. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{de-7PGZC4IF.js → de-E2CUVVOP.js} +16 -3
  8. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-E2CUVVOP.js.map +1 -0
  9. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-VOIWY235.js → dees-modal-YOGT7PSU.js} +3 -3
  10. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-EJRHSZ5F.js → dees-workspace-terminal-ORLONA36.js} +4 -4
  11. package/dist_ts_web/00_commitinfo_data.js +1 -1
  12. package/dist_ts_web/elements/00group-dataview/dees-thread/dees-thread.d.ts +9 -1
  13. package/dist_ts_web/elements/00group-dataview/dees-thread/dees-thread.js +42 -5
  14. package/dist_ts_web/elements/00group-dataview/dees-thread/interfaces.d.ts +11 -0
  15. package/dist_ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.d.ts +30 -8
  16. package/dist_ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.js +95 -24
  17. package/dist_ts_web/elements/00group-harness/interfaces.d.ts +14 -3
  18. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.d.ts +17 -5
  19. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.demo.js +6 -2
  20. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.js +76 -20
  21. package/dist_ts_web/elements/00group-kanban/dees-kanban-activity/dees-kanban-activity.js +3 -1
  22. package/dist_ts_web/elements/00group-kanban/dees-kanban-card/dees-kanban-card.d.ts +3 -1
  23. package/dist_ts_web/elements/00group-kanban/dees-kanban-card/dees-kanban-card.js +17 -3
  24. package/dist_ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.d.ts +3 -1
  25. package/dist_ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.js +12 -2
  26. package/dist_ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.d.ts +41 -5
  27. package/dist_ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.js +196 -20
  28. package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.d.ts +25 -2
  29. package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.js +137 -8
  30. package/dist_ts_web/elements/00group-kanban/index.d.ts +1 -0
  31. package/dist_ts_web/elements/00group-kanban/index.js +2 -1
  32. package/dist_ts_web/elements/00group-kanban/interfaces.d.ts +96 -3
  33. package/dist_ts_web/elements/00group-kanban/kanban.demodata.js +119 -3
  34. package/dist_ts_web/elements/00group-kanban/kanban.helpers.d.ts +19 -1
  35. package/dist_ts_web/elements/00group-kanban/kanban.helpers.js +50 -1
  36. package/dist_ts_web/elements/00group-kanban/kanban.styles.js +32 -1
  37. package/dist_ts_web/i18n/de.d.ts +53 -1
  38. package/dist_ts_web/i18n/de.js +15 -2
  39. package/dist_ts_web/i18n/messages.d.ts +53 -1
  40. package/dist_ts_web/i18n/messages.js +15 -2
  41. package/package.json +1 -1
  42. package/readme.md +57 -18
  43. package/ts_web/00_commitinfo_data.ts +1 -1
  44. package/ts_web/elements/00group-dataview/dees-thread/dees-thread.ts +39 -4
  45. package/ts_web/elements/00group-dataview/dees-thread/interfaces.ts +11 -0
  46. package/ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.ts +83 -21
  47. package/ts_web/elements/00group-harness/interfaces.ts +14 -3
  48. package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.demo.ts +5 -1
  49. package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.ts +82 -23
  50. package/ts_web/elements/00group-kanban/dees-kanban-activity/dees-kanban-activity.ts +2 -0
  51. package/ts_web/elements/00group-kanban/dees-kanban-card/dees-kanban-card.ts +11 -2
  52. package/ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.ts +6 -1
  53. package/ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.ts +199 -21
  54. package/ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.ts +144 -6
  55. package/ts_web/elements/00group-kanban/index.ts +1 -0
  56. package/ts_web/elements/00group-kanban/interfaces.ts +101 -4
  57. package/ts_web/elements/00group-kanban/kanban.demodata.ts +126 -2
  58. package/ts_web/elements/00group-kanban/kanban.helpers.ts +70 -0
  59. package/ts_web/elements/00group-kanban/kanban.styles.ts +31 -0
  60. package/ts_web/i18n/de.ts +14 -1
  61. package/ts_web/i18n/messages.ts +14 -1
  62. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-7PGZC4IF.js.map +0 -1
  63. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-FCUX4QGD.js.map → chunk-Q5VY4AV7.js.map} +0 -0
  64. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-LWT7IIPZ.js.map → chunk-QG5BHDQO.js.map} +0 -0
  65. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-VOIWY235.js.map → dees-modal-YOGT7PSU.js.map} +0 -0
  66. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-EJRHSZ5F.js.map → dees-workspace-terminal-ORLONA36.js.map} +0 -0
@@ -13,15 +13,18 @@ import { visuallyHidden } from '../../00visuallyhidden.js';
13
13
  import { insetInlineStyles } from '../../00theme.js';
14
14
  import type {
15
15
  IKanbanActivity,
16
+ IKanbanAutoLabel,
16
17
  IKanbanColumn,
17
- IKanbanComment,
18
18
  IKanbanEditConflict,
19
19
  IKanbanPerson,
20
20
  IKanbanProject,
21
21
  IKanbanProvider,
22
+ IKanbanQuestion,
22
23
  IKanbanSource,
23
24
  IKanbanTicket,
24
25
  IKanbanTicketDraft,
26
+ TKanbanActivityAction,
27
+ TKanbanDiscussionItem,
25
28
  TKanbanDraftField,
26
29
  TKanbanLink,
27
30
  TKanbanPriority,
@@ -32,6 +35,7 @@ import type {
32
35
  } from '../../00group-input/dees-input-reference/interfaces.js';
33
36
  import { kanbanStyles } from '../kanban.styles.js';
34
37
  import {
38
+ isKanbanQuestion,
35
39
  kanbanDraftFields,
36
40
  kanbanEvent,
37
41
  kanbanHref,
@@ -43,12 +47,14 @@ import {
43
47
  kanbanProjectName,
44
48
  kanbanProjects,
45
49
  kanbanShortSha,
50
+ renderKanbanAutoLabels,
46
51
  sortKanbanTickets,
47
52
  ticketDraft,
48
53
  ticketLabel,
49
54
  } from '../kanban.helpers.js';
50
55
  import type { DeesInputText } from '../../00group-input/dees-input-text/dees-input-text.js';
51
56
  import type { DeesInputTextarea } from '../../00group-input/dees-input-textarea/dees-input-textarea.js';
57
+ import type { DeesKanbanDiscussion } from '../dees-kanban-discussion/dees-kanban-discussion.js';
52
58
  import '../../00group-input/dees-input-text/dees-input-text.js';
53
59
  import '../../00group-input/dees-input-textarea/dees-input-textarea.js';
54
60
  import '../../00group-input/dees-input-dropdown/dees-input-dropdown.js';
@@ -60,6 +66,9 @@ import '../../00group-feedback/dees-hint/dees-hint.js';
60
66
  import '../dees-kanban-discussion/dees-kanban-discussion.js';
61
67
  import '../dees-kanban-activity/dees-kanban-activity.js';
62
68
 
69
+ /** What the discussion shows, so the history leaves it out. */
70
+ const discussionActions: ReadonlySet<TKanbanActivityAction> = new Set(['commented', 'asked', 'answered']);
71
+
63
72
  declare global {
64
73
  interface HTMLElementTagNameMap {
65
74
  'dees-kanban-ticket-detail': DeesKanbanTicketDetail;
@@ -95,8 +104,13 @@ export class DeesKanbanTicketDetail extends DeesElement {
95
104
  @property({ attribute: false })
96
105
  accessor commentDraft: TReferenceContent = [];
97
106
 
107
+ /** The ticket's comments and questions. */
108
+ @property({ attribute: false })
109
+ accessor comments: TKanbanDiscussionItem[] = [];
110
+
111
+ /** What the host's AutoLabels are called and how they look; see the board's `autoLabelDefinitions`. */
98
112
  @property({ attribute: false })
99
- accessor comments: IKanbanComment[] = [];
113
+ accessor autoLabelDefinitions: IKanbanAutoLabel[] = [];
100
114
 
101
115
  @property({ attribute: false })
102
116
  accessor searchTickets: TReferenceSearch | undefined;
@@ -154,6 +168,13 @@ export class DeesKanbanTicketDetail extends DeesElement {
154
168
  @state()
155
169
  private accessor feed: 'comments' | 'history' = 'comments';
156
170
 
171
+ /**
172
+ * The pinned composer covers the foot of the main column: its height is the column's scroll
173
+ * padding, so what scrolls into view there, such as a question the hint shows, is not under it.
174
+ */
175
+ private composerObserver?: ResizeObserver;
176
+ private observedComposer: Element | null = null;
177
+
157
178
  public static styles = [
158
179
  ...kanbanStyles,
159
180
  insetInlineStyles('--detail-inset-inline'),
@@ -198,6 +219,11 @@ export class DeesKanbanTicketDetail extends DeesElement {
198
219
  scrollbar-width: thin;
199
220
  }
200
221
 
222
+ /* What scrolls into view, a revealed question or a focused control, stops short of the composer. */
223
+ .main {
224
+ scroll-padding-bottom: calc(var(--detail-composer-block-size, 0px) + var(--dees-spacing-md));
225
+ }
226
+
201
227
  /* Positioned content of the main column is placed in it, so it scrolls with it, not over the panes. */
202
228
  .main > :not(aside) {
203
229
  position: relative;
@@ -633,6 +659,27 @@ export class DeesKanbanTicketDetail extends DeesElement {
633
659
  gap: 14px;
634
660
  }
635
661
 
662
+ .open-questions {
663
+ margin-bottom: 16px;
664
+ }
665
+
666
+ .open-questions-row {
667
+ display: flex;
668
+ flex-wrap: wrap;
669
+ align-items: center;
670
+ justify-content: space-between;
671
+ gap: 8px 12px;
672
+ }
673
+
674
+ .open-questions-row p {
675
+ color: var(--dees-color-text-primary);
676
+ font-weight: 600;
677
+ }
678
+
679
+ .auto-row {
680
+ margin-top: 8px;
681
+ }
682
+
636
683
  .conflict p + p,
637
684
  .conflict p + dees-button {
638
685
  margin-top: 8px;
@@ -719,10 +766,15 @@ export class DeesKanbanTicketDetail extends DeesElement {
719
766
  overflow: visible;
720
767
  }
721
768
  .main > .error,
769
+ .main > .open-questions,
722
770
  .lead,
723
771
  .body {
724
772
  padding-inline: var(--detail-inset-inline, 16px);
725
773
  }
774
+ .main > .open-questions {
775
+ margin: 0;
776
+ padding-block: 12px 0;
777
+ }
726
778
  .main > .error {
727
779
  padding-block: 10px 0;
728
780
  }
@@ -793,6 +845,35 @@ export class DeesKanbanTicketDetail extends DeesElement {
793
845
  // A button this render added draws its face, which takes the focus, in its own first update.
794
846
  void target?.updateComplete.then(() => target.focus());
795
847
  }
848
+ this.observeComposer();
849
+ }
850
+
851
+ public async disconnectedCallback(): Promise<void> {
852
+ this.composerObserver?.disconnect();
853
+ this.observedComposer = null;
854
+ await super.disconnectedCallback();
855
+ }
856
+
857
+ public async connectedCallback(): Promise<void> {
858
+ const connection = super.connectedCallback();
859
+ // Back in the page after leaving it: its composer is watched again.
860
+ if (this.hasUpdated) this.observeComposer();
861
+ await connection;
862
+ }
863
+
864
+ private observeComposer(): void {
865
+ const composer = this.shadowRoot?.querySelector('.main > .composer') ?? null;
866
+ if (composer === this.observedComposer) return;
867
+ this.composerObserver ??= new ResizeObserver(([entry]) => this.padForComposer(entry?.borderBoxSize[0]?.blockSize ?? 0));
868
+ if (this.observedComposer) this.composerObserver.unobserve(this.observedComposer);
869
+ if (composer) this.composerObserver.observe(composer);
870
+ else this.padForComposer(0);
871
+ this.observedComposer = composer;
872
+ }
873
+
874
+ /** Makes the composer's height the main column's scroll padding. */
875
+ private padForComposer(blockSize: number): void {
876
+ this.shadowRoot?.querySelector<HTMLElement>('.main')?.style.setProperty('--detail-composer-block-size', `${blockSize}px`);
796
877
  }
797
878
 
798
879
  /**
@@ -914,6 +995,50 @@ export class DeesKanbanTicketDetail extends DeesElement {
914
995
  private addComment = (input: Parameters<NonNullable<IKanbanProvider['addComment']>>[0]) =>
915
996
  this.provider.addComment!(input);
916
997
 
998
+ private askQuestion = (input: Parameters<NonNullable<IKanbanProvider['askQuestion']>>[0]) =>
999
+ this.provider.askQuestion!(input);
1000
+
1001
+ private answerQuestion = (input: Parameters<NonNullable<IKanbanProvider['answerQuestion']>>[0]) =>
1002
+ this.provider.answerQuestion!(input);
1003
+
1004
+ /**
1005
+ * Shows the ticket's first unanswered question in the discussion, ready for an answer where the
1006
+ * reader may give one.
1007
+ */
1008
+ private async revealOpenQuestion(questionId: string): Promise<void> {
1009
+ this.feed = 'comments';
1010
+ await this.updateComplete;
1011
+ // The observer reports a composer's height a frame after it comes; the scroll needs it now.
1012
+ const composer = this.shadowRoot?.querySelector<HTMLElement>('.main > .composer');
1013
+ if (composer) this.padForComposer(composer.getBoundingClientRect().height);
1014
+ await this.shadowRoot?.querySelector<DeesKanbanDiscussion>('dees-kanban-discussion:not(.composer)')
1015
+ ?.revealQuestion(questionId);
1016
+ }
1017
+
1018
+ /** Says how many questions wait for an answer, with a button to the first. */
1019
+ private renderOpenQuestions(ticket: IKanbanTicket): TemplateResult | '' {
1020
+ const open = this.comments.filter(
1021
+ (item): item is IKanbanQuestion => isKanbanQuestion(item) && item.ticketId === ticket.id && !item.answer,
1022
+ );
1023
+ if (!open.length) return '';
1024
+ const first = open.reduce((oldest, item) =>
1025
+ Date.parse(item.createdAt) < Date.parse(oldest.createdAt) ? item : oldest);
1026
+ const canAnswer = Boolean(this.provider.answerQuestion) && ticket.permissions?.answer !== false;
1027
+ return html`<div class="open-questions">
1028
+ <dees-hint type="warning">
1029
+ <div class="open-questions-row">
1030
+ <p>${this.t('kanban.openQuestions', { count: open.length })}</p>
1031
+ <dees-button
1032
+ size="sm"
1033
+ type=${canAnswer ? 'accent' : 'secondary'}
1034
+ text=${this.t(canAnswer ? 'kanban.answerQuestion' : 'kanban.showQuestion')}
1035
+ @clicked=${() => this.revealOpenQuestion(first.id)}
1036
+ ></dees-button>
1037
+ </div>
1038
+ </dees-hint>
1039
+ </div>`;
1040
+ }
1041
+
917
1042
  /** Keeps the comment the reader is writing, so that the next render gives the composer it back, not an older one. */
918
1043
  private keepCommentDraft = (event: CustomEvent<{ ticketId: string; body: TReferenceContent }>) => {
919
1044
  if (event.detail.ticketId === this.ticket?.id) this.commentDraft = event.detail.body;
@@ -958,6 +1083,7 @@ export class DeesKanbanTicketDetail extends DeesElement {
958
1083
  <div class="panes">
959
1084
  <div class="main">
960
1085
  ${this.error ? html`<p class="error" role="alert">${this.error}</p>` : ''}
1086
+ ${this.renderOpenQuestions(ticket)}
961
1087
  <section class="lead">
962
1088
  ${this.editing && editable
963
1089
  ? html`<div class="edit">
@@ -1145,12 +1271,18 @@ export class DeesKanbanTicketDetail extends DeesElement {
1145
1271
  }}
1146
1272
  @input=${(event: Event) => event.stopPropagation()}
1147
1273
  ></dees-input-tags>
1274
+ ${ticket.autoLabels?.length
1275
+ ? html`<div class="row auto-row">
1276
+ ${renderKanbanAutoLabels(this.t, this.autoLabelDefinitions, ticket.autoLabels)}
1277
+ </div>`
1278
+ : ''}
1148
1279
  </div>`
1149
1280
  : html`<div class="labels">
1150
1281
  <label class="caption">${this.t('kanban.labels')}</label>
1151
- ${ticket.labels?.length
1282
+ ${ticket.labels?.length || ticket.autoLabels?.length
1152
1283
  ? html`<div class="row value">
1153
- ${ticket.labels.map(label => html`<span class="badge">${label}</span>`)}
1284
+ ${renderKanbanAutoLabels(this.t, this.autoLabelDefinitions, ticket.autoLabels)}
1285
+ ${ticket.labels?.map(label => html`<span class="badge">${label}</span>`)}
1154
1286
  </div>`
1155
1287
  : this.renderUnset(this.t('kanban.noLabels'))}
1156
1288
  </div>`}
@@ -1240,6 +1372,9 @@ export class DeesKanbanTicketDetail extends DeesElement {
1240
1372
  .view=${'entries'}
1241
1373
  .ticketId=${ticket.id}
1242
1374
  .comments=${this.comments}
1375
+ .answerQuestion=${this.provider.answerQuestion && ticket.permissions?.answer !== false
1376
+ ? this.answerQuestion
1377
+ : undefined}
1243
1378
  .loading=${this.loadingComments}
1244
1379
  .error=${this.commentsError}
1245
1380
  .showHeader=${!inFeed}
@@ -1258,6 +1393,9 @@ export class DeesKanbanTicketDetail extends DeesElement {
1258
1393
  .searchTickets=${this.searchTickets}
1259
1394
  .currentPerson=${this.currentPerson}
1260
1395
  .addComment=${this.provider.addComment ? this.addComment : undefined}
1396
+ .askQuestion=${this.provider.askQuestion && ticket.permissions?.ask !== false
1397
+ ? this.askQuestion
1398
+ : undefined}
1261
1399
  ?hidden=${!!this.provider.loadActivity && this.feed !== 'comments'}
1262
1400
  @kanban-comment-draft=${this.keepCommentDraft}
1263
1401
  ></dees-kanban-discussion>`;
@@ -1269,9 +1407,9 @@ export class DeesKanbanTicketDetail extends DeesElement {
1269
1407
  */
1270
1408
  private renderFeed(ticket: IKanbanTicket): TemplateResult {
1271
1409
  const comments = this.comments.filter(comment => comment.ticketId === ticket.id).length;
1272
- // The discussion shows the comments; the history shows the changes.
1410
+ // The discussion shows the comments and questions; the history shows the changes.
1273
1411
  const changes = this.activity.filter(
1274
- entry => entry.ticketId === ticket.id && entry.action !== 'commented',
1412
+ entry => entry.ticketId === ticket.id && !discussionActions.has(entry.action),
1275
1413
  );
1276
1414
  const history = this.feed === 'history';
1277
1415
  return html`<section class="feed">
@@ -1,4 +1,5 @@
1
1
  export * from './interfaces.js';
2
+ export { kanbanOpenQuestionLabel } from './kanban.helpers.js';
2
3
  export * from './dees-kanban/dees-kanban.js';
3
4
  export * from './dees-kanban-card/dees-kanban-card.js';
4
5
  export * from './dees-kanban-column/dees-kanban-column.js';
@@ -58,6 +58,11 @@ export interface IKanbanTicket {
58
58
  priority?: TKanbanPriority;
59
59
  assignee?: IKanbanPerson;
60
60
  labels?: string[];
61
+ /**
62
+ * Labels the host derives from the ticket's state and sets itself, such as `openQuestion` while a
63
+ * question on it waits for an answer: shown beside the labels, never edited, filtered apart.
64
+ */
65
+ autoLabels?: string[];
61
66
  /** The `id` of the project the ticket belongs to (`IKanbanProject`). */
62
67
  project?: string;
63
68
  links?: TKanbanLink[];
@@ -69,10 +74,22 @@ export interface IKanbanTicket {
69
74
  updatedBy?: IKanbanPerson;
70
75
  /** The ticket's server revision, advanced by every change to it. */
71
76
  revision?: number;
72
- /** UI capabilities; the provider must enforce authorization independently. */
73
- permissions?: { edit?: boolean; move?: boolean; comment?: boolean; createChild?: boolean };
77
+ /**
78
+ * UI capabilities; the provider must enforce authorization independently. `ask` offers asking a
79
+ * question from the composer, `answer` lets the reader answer the ticket's questions.
80
+ */
81
+ permissions?: {
82
+ edit?: boolean;
83
+ move?: boolean;
84
+ comment?: boolean;
85
+ createChild?: boolean;
86
+ ask?: boolean;
87
+ answer?: boolean;
88
+ };
74
89
  }
75
90
  export interface IKanbanComment {
91
+ /** Tells a comment from a question in a ticket's discussion; unset means a comment. */
92
+ kind?: 'comment';
76
93
  id: string;
77
94
  ticketId: string;
78
95
  author: IKanbanPerson;
@@ -80,13 +97,79 @@ export interface IKanbanComment {
80
97
  createdAt: string;
81
98
  body: TReferenceContent;
82
99
  }
100
+ /** A choice a ticket's question offers. */
101
+ export interface IKanbanQuestionOption {
102
+ /** Names the option in an answer's `choices`. */
103
+ id: string;
104
+ label: string;
105
+ description?: string;
106
+ }
107
+ /** The answer a ticket's question was given. */
108
+ export interface IKanbanQuestionAnswer {
109
+ /** The chosen options' ids, in the order the question lists them; empty for an answer in words only. */
110
+ choices: string[];
111
+ /** The answer in the person's own words. */
112
+ text?: string;
113
+ answeredBy: IKanbanPerson;
114
+ /** ISO 8601 timestamp. */
115
+ answeredAt: string;
116
+ }
117
+ /**
118
+ * A question asked on a ticket, in its discussion, such as an agent working it asking the owner:
119
+ * shown as a question card the reader answers by its options, in their own words, or both. Without
120
+ * `answer` it waits for one.
121
+ */
122
+ export interface IKanbanQuestion {
123
+ kind: 'question';
124
+ id: string;
125
+ ticketId: string;
126
+ /** Who asked. */
127
+ author: IKanbanPerson;
128
+ /** ISO 8601 timestamp. */
129
+ createdAt: string;
130
+ /** Markdown, as the composer writes it; the card shows it as text, a linked ticket by its label. */
131
+ question: string;
132
+ /** The choices; none, the question takes an answer in words only. */
133
+ options?: IKanbanQuestionOption[];
134
+ /** More than one option may be chosen. */
135
+ multiSelect?: boolean;
136
+ /** The reader may answer in their own words; `true` when unset. */
137
+ allowCustom?: boolean;
138
+ answer?: IKanbanQuestionAnswer;
139
+ }
140
+ /** An item of a ticket's discussion: a comment or a question, told apart by `kind`. */
141
+ export type TKanbanDiscussionItem = IKanbanComment | IKanbanQuestion;
142
+ /** What the person answered a question with, as the provider's `answerQuestion` receives it. */
143
+ export interface IKanbanQuestionAnswerInput {
144
+ ticketId: string;
145
+ questionId: string;
146
+ /** The chosen options' ids, in the order the question lists them. */
147
+ choices: string[];
148
+ /** The answer in the person's own words, when they wrote any. */
149
+ text?: string;
150
+ }
151
+ /**
152
+ * A label the host sets on tickets itself (`IKanbanTicket.autoLabels`): its `label` as tickets
153
+ * carry it, and what the board shows for it ("Open question") and says of it in its tooltip.
154
+ */
155
+ export interface IKanbanAutoLabel {
156
+ label: string;
157
+ name?: string;
158
+ description?: string;
159
+ /** A Lucide icon before its name; a sparkle when unset. */
160
+ iconName?: string;
161
+ /** `warning` outlines it in the warning colour, for a label that asks for someone; `neutral` when unset. */
162
+ tone?: 'neutral' | 'warning';
163
+ }
83
164
  export type TKanbanActivityAction =
84
165
  | 'created'
85
166
  | 'updated'
86
167
  | 'moved'
87
168
  | 'reordered'
88
169
  | 'commented'
89
- | 'linked';
170
+ | 'linked'
171
+ | 'asked'
172
+ | 'answered';
90
173
  /** One entry of a ticket's history. */
91
174
  export interface IKanbanActivity {
92
175
  id: string;
@@ -180,6 +263,8 @@ export interface IKanbanFilterValues {
180
263
  /** A person's `id`; `'none'` for unassigned tasks. */
181
264
  assignee?: string;
182
265
  label?: string;
266
+ /** A label the host sets itself (`IKanbanTicket.autoLabels`), such as `openQuestion`. */
267
+ autoLabel?: string;
183
268
  /** An epic's ticket `id`. */
184
269
  epic?: string;
185
270
  /** Only tasks assigned to `currentPersonId`. */
@@ -196,12 +281,24 @@ export interface IKanbanBoardSnapshot {
196
281
  export interface IKanbanProvider {
197
282
  getTicket?: (id: string, signal: AbortSignal) => Promise<IKanbanTicket>;
198
283
  searchTickets?: (query: string, signal: AbortSignal) => Promise<IKanbanTicket[]>;
199
- loadComments?: (ticketId: string, signal: AbortSignal) => Promise<IKanbanComment[]>;
284
+ /** A ticket's discussion: its comments and, for a host with questions, its questions. */
285
+ loadComments?: (ticketId: string, signal: AbortSignal) => Promise<TKanbanDiscussionItem[]>;
200
286
  /** A ticket's history, oldest first. Without it the detail shows no history. */
201
287
  loadActivity?: (ticketId: string, signal: AbortSignal) => Promise<IKanbanActivity[]>;
202
288
  /** The whole board again, for `refresh()`. */
203
289
  loadBoard?: (signal: AbortSignal) => Promise<IKanbanBoardSnapshot>;
204
290
  addComment?: (input: { ticketId: string; body: TReferenceContent }) => Promise<IKanbanComment>;
291
+ /**
292
+ * Asks the composer's text, in Markdown, as a question on the ticket, answered in words; resolves
293
+ * to the question the server saved. A rejection's message shows under the composer, which keeps
294
+ * the text.
295
+ */
296
+ askQuestion?: (input: { ticketId: string; question: string }) => Promise<IKanbanQuestion>;
297
+ /**
298
+ * Saves the person's answer to a question; resolves to the question with its `answer`. A
299
+ * rejection's message shows on the question, which waits for an answer again.
300
+ */
301
+ answerQuestion?: (input: IKanbanQuestionAnswerInput) => Promise<IKanbanQuestion>;
205
302
  /**
206
303
  * `expectedRevision` is the ticket's `revision` the edit started from; a provider that checks it
207
304
  * refuses a stale edit with an `IKanbanRevisionConflict`.
@@ -5,9 +5,11 @@ import type {
5
5
  IKanbanPerson,
6
6
  IKanbanProject,
7
7
  IKanbanProvider,
8
+ IKanbanQuestion,
8
9
  IKanbanTicket,
9
10
  TKanbanActivityAction,
10
11
  } from './interfaces.js';
12
+ import { kanbanOpenQuestionLabel } from './kanban.helpers.js';
11
13
 
12
14
  export const kanbanDemoPeople: IKanbanPerson[] = [
13
15
  { id: 'mara', name: 'Mara Chen' },
@@ -64,6 +66,9 @@ export interface IKanbanDemo {
64
66
  actAs: (person: IKanbanPerson) => void;
65
67
  }
66
68
 
69
+ /** Refuses an answer the way a server does, with its `code`. */
70
+ const refusal = (code: string, message: string): Error => Object.assign(new Error(message), { code });
71
+
67
72
  /** Shipped tasks, one release each, the newest last. */
68
73
  const releasedTickets = (): IKanbanTicket[] =>
69
74
  [
@@ -378,7 +383,50 @@ export const createKanbanDemo = (options: IKanbanDemoOptions = {}): IKanbanDemo
378
383
  ...options.released ? releasedTickets() : [],
379
384
  ...options.workflow ? workflowTickets() : [],
380
385
  ];
381
- let tickets = seeded.map(revised);
386
+ // Alex, who works CAT-103, asks Mara: one question she answered, one that waits for her.
387
+ let questions: IKanbanQuestion[] = [
388
+ {
389
+ kind: 'question',
390
+ id: 'Q1',
391
+ ticketId: 'task-3',
392
+ author: alex,
393
+ createdAt: '2026-09-16T10:20:00Z',
394
+ question: 'Should the arrow keys move a focused card between columns as well?',
395
+ options: [
396
+ { id: '1', label: 'Within its column only' },
397
+ { id: '2', label: 'Between columns too', description: 'Left and right change the column.' },
398
+ ],
399
+ multiSelect: false,
400
+ allowCustom: true,
401
+ answer: {
402
+ choices: ['2'],
403
+ text: 'Up and down stay in the column.',
404
+ answeredBy: mara,
405
+ answeredAt: '2026-09-16T10:48:00Z',
406
+ },
407
+ },
408
+ {
409
+ kind: 'question',
410
+ id: 'Q2',
411
+ ticketId: 'task-3',
412
+ author: alex,
413
+ createdAt: '2026-09-16T11:05:00Z',
414
+ question: 'Which keys should open the focused card?',
415
+ options: [
416
+ { id: '1', label: 'Enter' },
417
+ { id: '2', label: 'Space' },
418
+ { id: '3', label: 'O', description: 'As in the list views.' },
419
+ ],
420
+ multiSelect: true,
421
+ allowCustom: true,
422
+ },
423
+ ];
424
+ /** The ticket with the AutoLabels the server derives: `openQuestion` while a question on it waits. */
425
+ const labelled = ({ autoLabels: _, ...ticket }: IKanbanTicket): IKanbanTicket =>
426
+ questions.some(question => question.ticketId === ticket.id && !question.answer)
427
+ ? { ...ticket, autoLabels: [kanbanOpenQuestionLabel] }
428
+ : ticket;
429
+ let tickets = seeded.map(ticket => revised(labelled(ticket)));
382
430
  let comments: IKanbanComment[] = [
383
431
  {
384
432
  id: 'comment-1',
@@ -465,6 +513,27 @@ export const createKanbanDemo = (options: IKanbanDemoOptions = {}): IKanbanDemo
465
513
  createdAt: '2026-09-18T09:42:00Z',
466
514
  action: 'commented',
467
515
  },
516
+ {
517
+ id: 'activity-7',
518
+ ticketId: 'task-3',
519
+ actor: alex,
520
+ createdAt: '2026-09-16T10:20:00Z',
521
+ action: 'asked',
522
+ },
523
+ {
524
+ id: 'activity-8',
525
+ ticketId: 'task-3',
526
+ actor: mara,
527
+ createdAt: '2026-09-16T10:48:00Z',
528
+ action: 'answered',
529
+ },
530
+ {
531
+ id: 'activity-9',
532
+ ticketId: 'task-3',
533
+ actor: alex,
534
+ createdAt: '2026-09-16T11:05:00Z',
535
+ action: 'asked',
536
+ },
468
537
  ];
469
538
  let nextKey = 300;
470
539
  let revision = 1;
@@ -483,6 +552,12 @@ export const createKanbanDemo = (options: IKanbanDemoOptions = {}): IKanbanDemo
483
552
  revision++;
484
553
  return createdAt;
485
554
  };
555
+ /** Saves a question as asked or answered: the ticket's next revision carries its AutoLabels. */
556
+ const saveQuestion = (question: IKanbanQuestion): IKanbanQuestion => {
557
+ questions = [...questions.filter(other => other.id !== question.id), question];
558
+ tickets = tickets.map(ticket => ticket.id === question.ticketId ? revised(labelled(ticket)) : ticket);
559
+ return question;
560
+ };
486
561
  // Demo-only in-memory provider. Applications persist through their own authorized APIs.
487
562
  const provider: IKanbanProvider = {
488
563
  getTicket: async id => {
@@ -494,7 +569,10 @@ export const createKanbanDemo = (options: IKanbanDemoOptions = {}): IKanbanDemo
494
569
  tickets.filter(ticket =>
495
570
  `${ticket.key} ${ticket.title}`.toLowerCase().includes(query.toLowerCase()),
496
571
  ),
497
- loadComments: async id => comments.filter(comment => comment.ticketId === id),
572
+ loadComments: async id =>
573
+ [...comments, ...questions]
574
+ .filter(item => item.ticketId === id)
575
+ .sort((a, b) => a.createdAt.localeCompare(b.createdAt)),
498
576
  loadActivity: async id => activity.filter(entry => entry.ticketId === id),
499
577
  loadBoard: async () => ({ tickets, revision }),
500
578
  addComment: async input => {
@@ -508,6 +586,52 @@ export const createKanbanDemo = (options: IKanbanDemoOptions = {}): IKanbanDemo
508
586
  record(input.ticketId, 'commented');
509
587
  return comment;
510
588
  },
589
+ askQuestion: async ({ ticketId, question }) => {
590
+ return saveQuestion({
591
+ kind: 'question',
592
+ id: `Q${questions.length + 1}`,
593
+ ticketId,
594
+ author: actor,
595
+ createdAt: record(ticketId, 'asked'),
596
+ question,
597
+ options: [],
598
+ multiSelect: false,
599
+ allowCustom: true,
600
+ });
601
+ },
602
+ // Like a server: one answer per question, an identical second one changes nothing.
603
+ answerQuestion: async ({ ticketId, questionId, choices, text }) => {
604
+ const question = questions.find(item => item.id === questionId && item.ticketId === ticketId);
605
+ if (!question) throw refusal('ticket_question_not_found', 'This question is no longer on the ticket.');
606
+ const options = question.options ?? [];
607
+ const ordered = options.filter(option => choices.includes(option.id)).map(option => option.id);
608
+ const words = text?.trim() || undefined;
609
+ if (question.answer) {
610
+ if (JSON.stringify([question.answer.choices, question.answer.text]) === JSON.stringify([ordered, words]))
611
+ return question;
612
+ throw refusal(
613
+ 'ticket_question_answered',
614
+ `${question.answer.answeredBy.name} answered this question already. Ask a new one to change course.`,
615
+ );
616
+ }
617
+ // An unknown or repeated option, two for a single choice, words where none are taken, or nothing.
618
+ if (
619
+ ordered.length !== choices.length ||
620
+ (!question.multiSelect && ordered.length > 1) ||
621
+ (words && question.allowCustom === false) ||
622
+ (!ordered.length && !words)
623
+ )
624
+ throw refusal('ticket_answer_invalid', 'This answer does not fit the question.');
625
+ return saveQuestion({
626
+ ...question,
627
+ answer: {
628
+ choices: ordered,
629
+ ...words ? { text: words } : {},
630
+ answeredBy: actor,
631
+ answeredAt: record(ticketId, 'answered'),
632
+ },
633
+ });
634
+ },
511
635
  updateTicket: async ({ ticketId, changes, expectedRevision }) => {
512
636
  const previous = tickets.find(ticket => ticket.id === ticketId)!;
513
637
  // A server refuses an edit that started from an older revision, so it cannot undo a teammate's.