@design.estate/dees-catalog 21.32.3 → 21.33.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 (73) hide show
  1. package/dist_bundle/bundle.js +1545 -332
  2. package/dist_bundle/bundle.js.map +1 -1
  3. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-ZRD47DC6.js → chunk-B3NM6BL3.js} +3 -3
  4. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-EL3KNDIB.js → chunk-BDUZ7I23.js} +2 -2
  5. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-LDC2GECY.js → chunk-IK5OF7M4.js} +33 -2
  6. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-LDC2GECY.js.map → chunk-IK5OF7M4.js.map} +1 -1
  7. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{de-YOX3NS2W.js → de-PTMMQ5DA.js} +33 -2
  8. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-PTMMQ5DA.js.map +1 -0
  9. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-7LJGK5SK.js → dees-modal-BZIJFVRI.js} +3 -3
  10. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-O3NEQ4DO.js → dees-workspace-terminal-EU377EZY.js} +4 -4
  11. package/dist_ts_web/00_commitinfo_data.js +1 -1
  12. package/dist_ts_web/elements/00group-chart/dees-chart-area/component.d.ts +18 -0
  13. package/dist_ts_web/elements/00group-chart/dees-chart-area/component.js +60 -2
  14. package/dist_ts_web/elements/00group-chart/dees-chart-area/priceaxislabels.d.ts +24 -0
  15. package/dist_ts_web/elements/00group-chart/dees-chart-area/priceaxislabels.js +80 -0
  16. package/dist_ts_web/elements/00group-feedback/dees-hint/dees-hint.d.ts +1 -0
  17. package/dist_ts_web/elements/00group-feedback/dees-hint/dees-hint.js +13 -3
  18. package/dist_ts_web/elements/00group-harness/dees-harness-message-list/dees-harness-message-list.js +7 -5
  19. package/dist_ts_web/elements/00group-harness/dees-harness-permission-card/dees-harness-permission-card.d.ts +0 -3
  20. package/dist_ts_web/elements/00group-harness/dees-harness-permission-card/dees-harness-permission-card.js +10 -182
  21. package/dist_ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.d.ts +64 -1
  22. package/dist_ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.demo.js +221 -22
  23. package/dist_ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.js +544 -66
  24. package/dist_ts_web/elements/00group-harness/harness.helpers.d.ts +16 -1
  25. package/dist_ts_web/elements/00group-harness/harness.helpers.js +25 -1
  26. package/dist_ts_web/elements/00group-harness/harness.records.d.ts +27 -0
  27. package/dist_ts_web/elements/00group-harness/harness.records.js +193 -0
  28. package/dist_ts_web/elements/00group-harness/interfaces.d.ts +93 -4
  29. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.d.ts +39 -0
  30. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.demo.js +22 -8
  31. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.js +265 -25
  32. package/dist_ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.d.ts +5 -0
  33. package/dist_ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.js +70 -11
  34. package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.d.ts +16 -1
  35. package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.js +188 -5
  36. package/dist_ts_web/elements/00group-kanban/interfaces.d.ts +47 -2
  37. package/dist_ts_web/elements/00group-kanban/kanban.demodata.d.ts +7 -1
  38. package/dist_ts_web/elements/00group-kanban/kanban.demodata.js +49 -7
  39. package/dist_ts_web/elements/00group-kanban/kanban.dragcontroller.js +6 -1
  40. package/dist_ts_web/elements/00group-kanban/kanban.helpers.d.ts +15 -1
  41. package/dist_ts_web/elements/00group-kanban/kanban.helpers.js +31 -1
  42. package/dist_ts_web/i18n/de.d.ts +124 -0
  43. package/dist_ts_web/i18n/de.js +32 -1
  44. package/dist_ts_web/i18n/messages.d.ts +124 -0
  45. package/dist_ts_web/i18n/messages.js +32 -1
  46. package/package.json +1 -1
  47. package/readme.md +76 -13
  48. package/ts_web/00_commitinfo_data.ts +1 -1
  49. package/ts_web/elements/00group-chart/dees-chart-area/component.ts +59 -1
  50. package/ts_web/elements/00group-chart/dees-chart-area/priceaxislabels.ts +97 -0
  51. package/ts_web/elements/00group-feedback/dees-hint/dees-hint.ts +16 -3
  52. package/ts_web/elements/00group-harness/dees-harness-message-list/dees-harness-message-list.ts +6 -4
  53. package/ts_web/elements/00group-harness/dees-harness-permission-card/dees-harness-permission-card.ts +16 -186
  54. package/ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.demo.ts +261 -55
  55. package/ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.ts +575 -88
  56. package/ts_web/elements/00group-harness/harness.helpers.ts +39 -0
  57. package/ts_web/elements/00group-harness/harness.records.ts +210 -0
  58. package/ts_web/elements/00group-harness/interfaces.ts +99 -4
  59. package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.demo.ts +21 -5
  60. package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.ts +256 -24
  61. package/ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.ts +67 -6
  62. package/ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.ts +202 -1
  63. package/ts_web/elements/00group-kanban/interfaces.ts +55 -3
  64. package/ts_web/elements/00group-kanban/kanban.demodata.ts +62 -6
  65. package/ts_web/elements/00group-kanban/kanban.dragcontroller.ts +5 -0
  66. package/ts_web/elements/00group-kanban/kanban.helpers.ts +53 -0
  67. package/ts_web/i18n/de.ts +31 -0
  68. package/ts_web/i18n/messages.ts +31 -0
  69. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-YOX3NS2W.js.map +0 -1
  70. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-ZRD47DC6.js.map → chunk-B3NM6BL3.js.map} +0 -0
  71. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-EL3KNDIB.js.map → chunk-BDUZ7I23.js.map} +0 -0
  72. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-7LJGK5SK.js.map → dees-modal-BZIJFVRI.js.map} +0 -0
  73. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-O3NEQ4DO.js.map → dees-workspace-terminal-EU377EZY.js.map} +0 -0
@@ -11,9 +11,29 @@ import {
11
11
  } from '@design.estate/dees-element';
12
12
  import { dcLocalize } from '../../../i18n/localize.js';
13
13
  import { themeDefaultStyles } from '../../00theme.js';
14
- import { harnessControlStyles } from '../harness.styles.js';
15
- import type { IHarnessQuestionRequest, IHarnessQuestionViewState } from '../interfaces.js';
14
+ import { harnessActivityStyles, harnessControlStyles } from '../harness.styles.js';
15
+ import { harnessProposalState, harnessQuestionSeverity, harnessWithoutCredentials } from '../harness.helpers.js';
16
+ import {
17
+ harnessShownRecords,
18
+ harnessRecordStyles,
19
+ renderHarnessChanges,
20
+ renderHarnessMoreRecords,
21
+ renderHarnessOutcome,
22
+ routeHarnessRecordLink,
23
+ } from '../harness.records.js';
24
+ import type {
25
+ IHarnessProposalItem,
26
+ IHarnessQuestionLinkDetail,
27
+ IHarnessQuestionRequest,
28
+ IHarnessQuestionResponseDetail,
29
+ IHarnessQuestionViewState,
30
+ THarnessProposalState,
31
+ THarnessQuestionSeverity,
32
+ } from '../interfaces.js';
33
+ import type { IActionFooterAction } from '../../00group-button/dees-actionfooter/dees-actionfooter.js';
34
+ import '../../00group-button/dees-actionfooter/dees-actionfooter.js';
16
35
  import '../../00group-button/dees-button/dees-button.js';
36
+ import '../../00group-feedback/dees-badge/dees-badge.js';
17
37
  import '../../00group-utility/dees-icon/dees-icon.js';
18
38
 
19
39
  declare global {
@@ -22,12 +42,53 @@ declare global {
22
42
  }
23
43
  }
24
44
 
45
+ /** The title's icon: the kind's own for `info`, a warning sign for `warning`, a stop sign for `danger`. */
46
+ const titleIcon = (kindArg: IHarnessQuestionRequest['kind'], severityArg: THarnessQuestionSeverity): string =>
47
+ severityArg === 'danger' ? 'lucide:OctagonAlert'
48
+ : severityArg === 'warning' ? 'lucide:TriangleAlert'
49
+ : kindArg === 'proposal' ? 'lucide:ListChecks' : 'lucide:MessageCircleQuestionMark';
50
+
51
+ /** A change's marker for `warning` and `danger`; an `info` change has none. */
52
+ const ITEM_ICON: Record<Exclude<THarnessQuestionSeverity, 'info'>, string> = {
53
+ warning: 'lucide:TriangleAlert',
54
+ danger: 'lucide:OctagonAlert',
55
+ };
56
+
57
+ /** A credential's value while hidden: the same length for every secret, so it tells nothing of it. */
58
+ const CREDENTIAL_MASK = '••••••••••••';
59
+
60
+ /** The badge of each decided state. */
61
+ const STATE_BADGE: Record<Exclude<THarnessProposalState, 'pending'>, 'success' | 'default' | 'error'> = {
62
+ confirmed: 'success',
63
+ declined: 'default',
64
+ expired: 'default',
65
+ failed: 'error',
66
+ };
67
+
25
68
  /**
26
69
  * A question the agent asks mid-run: option buttons (single-select answers
27
70
  * immediately, multi-select collects then confirms) plus an optional
28
71
  * free-text answer. Emits `harness-question-response` (bubbles, composed).
29
72
  * Answered cards persist showing the chosen answer(s) — the host sets
30
73
  * `response`/`respondedAt` on the request and keeps it in the array.
74
+ *
75
+ * A proposal (`kind: 'proposal'`) asks the reader to confirm changes the
76
+ * agent would make: one or several `items`, each what will happen, the
77
+ * record it acts on, its fields before and after, and what came of it.
78
+ * Confirm (the primary, red for `danger`) and Decline stand in an action
79
+ * footer and answer `['confirm']` or `['decline']`. A decided proposal is
80
+ * read-only and shows its state (confirmed, declined, or the host's
81
+ * `expired` or `failed`) and the host's `outcome`. A record's link emits the
82
+ * cancelable `harness-question-link` first: a host that routes it itself
83
+ * cancels it. `severity` (`warning` orange, `danger` red) shows in the
84
+ * title's icon and the card's border, and is named to assistive technology;
85
+ * a proposal takes the highest of its own and its changes', and marks each
86
+ * change that asks for care. With `itemsDeclinable`, the reader may leave
87
+ * changes of a proposal of two or more out: the confirmation names them in
88
+ * `declinedItemIds`. The card answers once: it locks with the first answer,
89
+ * while `busy`, and once its changes are under way. A change's `credential`
90
+ * (a secret it issued) shows to the reader only, masked until asked for;
91
+ * no event the card emits carries it.
31
92
  */
32
93
  @customElement('dees-harness-question-card')
33
94
  export class DeesHarnessQuestionCard extends DeesElement {
@@ -55,10 +116,32 @@ export class DeesHarnessQuestionCard extends DeesElement {
55
116
  @state()
56
117
  accessor customText: string = '';
57
118
 
119
+ @state()
120
+ accessor itemsExpanded: boolean | undefined = undefined;
121
+
122
+ /** the changes the reader left out, by item id; unset, the view state's */
123
+ @state()
124
+ accessor leftOut: ReadonlySet<string> | undefined = undefined;
125
+
126
+ /** the credentials the reader asked to see, by item id; never kept beyond this element */
127
+ @state()
128
+ accessor credentialsShown: ReadonlySet<string> = new Set<string>();
129
+
130
+ @state()
131
+ accessor copyFeedback: { itemId: string; text: string; failed: boolean } | undefined = undefined;
132
+
133
+ private copyRequest = 0;
134
+ private copyResetTimeout: ReturnType<typeof setTimeout> | undefined;
135
+
58
136
  public get effectiveResponse(): string[] | undefined {
59
137
  return this.request.response ?? this.answered ?? this.viewState?.answered;
60
138
  }
61
139
 
140
+ /** Where a proposal stands, the reader's answer counted before the host echoes it; a question is never more than `pending`. */
141
+ public get proposalState(): THarnessProposalState {
142
+ return this.request.kind === 'proposal' ? harnessProposalState(this.request, this.effectiveResponse) : 'pending';
143
+ }
144
+
62
145
  private get effectiveSelected(): ReadonlySet<string> {
63
146
  return this.selected.size > 0
64
147
  ? this.selected
@@ -69,10 +152,39 @@ export class DeesHarnessQuestionCard extends DeesElement {
69
152
  return this.customText || this.viewState?.customText || '';
70
153
  }
71
154
 
155
+ private get effectiveItemsExpanded(): boolean {
156
+ return this.itemsExpanded ?? this.viewState?.itemsExpanded ?? false;
157
+ }
158
+
159
+ /** Whether the reader may leave single changes out: a declinable proposal of two or more. */
160
+ private get itemsDeclinable(): boolean {
161
+ return this.request.kind === 'proposal' && this.request.itemsDeclinable === true && (this.request.items?.length ?? 0) >= 2;
162
+ }
163
+
164
+ /**
165
+ * The changes left out, by item id, of those the proposal still has: while it waits, the
166
+ * reader's choice; once confirmed, the host's echo of the answer, else the reader's choice.
167
+ */
168
+ private get effectiveLeftOut(): ReadonlySet<string> {
169
+ if (!this.itemsDeclinable) return new Set<string>();
170
+ const ids = this.proposalState === 'pending'
171
+ ? this.leftOut ?? this.viewState?.declinedItemIds ?? []
172
+ : this.request.declinedItemIds ?? this.leftOut ?? this.viewState?.declinedItemIds ?? [];
173
+ const chosen = new Set(ids);
174
+ return new Set((this.request.items ?? []).filter((item) => chosen.has(item.id)).map((item) => item.id));
175
+ }
176
+
177
+ /** Whether the card takes no answer: answered, waiting for the host (`busy`), or its changes under way or decided. */
178
+ private get locked(): boolean {
179
+ return this.busy || this.effectiveResponse !== undefined || this.proposalState !== 'pending';
180
+ }
181
+
72
182
  public static styles = [
73
183
  themeDefaultStyles,
74
184
  cssManager.defaultStyles,
75
185
  harnessControlStyles,
186
+ harnessActivityStyles,
187
+ harnessRecordStyles,
76
188
  css`
77
189
  :host {
78
190
  display: block;
@@ -81,13 +193,34 @@ export class DeesHarnessQuestionCard extends DeesElement {
81
193
  }
82
194
 
83
195
  .card {
84
- padding: 16px;
196
+ overflow: clip;
85
197
  border: var(--dees-line-width-hairline) solid var(--dees-color-border-subtle);
86
198
  border-radius: var(--dees-radius-xl);
87
199
  corner-shape: var(--dees-corner-shape);
88
200
  background: var(--dees-color-bg-secondary);
89
201
  }
90
202
 
203
+ /* the border asks for attention while the card waits; a decided card keeps only its icon */
204
+ .card.waiting.severity-warning {
205
+ border-color: var(--dees-color-accent-warning);
206
+ }
207
+
208
+ .card.waiting.severity-danger {
209
+ border-color: var(--dees-color-accent-error);
210
+ }
211
+
212
+ .body {
213
+ padding: 16px;
214
+ }
215
+
216
+ .body > :last-child {
217
+ margin-bottom: 0;
218
+ }
219
+
220
+ dees-actionfooter {
221
+ --dees-actionfooter-inset: 16px;
222
+ }
223
+
91
224
  .titleRow {
92
225
  display: flex;
93
226
  align-items: flex-start;
@@ -103,6 +236,16 @@ export class DeesHarnessQuestionCard extends DeesElement {
103
236
  color: var(--dees-color-accent-primary);
104
237
  }
105
238
 
239
+ .severity-warning .titleRow dees-icon {
240
+ background: var(--dees-color-badge-warning-bg);
241
+ color: var(--dees-color-badge-warning-fg);
242
+ }
243
+
244
+ .severity-danger .titleRow dees-icon {
245
+ background: var(--dees-color-badge-error-bg);
246
+ color: var(--dees-color-badge-error-fg);
247
+ }
248
+
106
249
  .questionText {
107
250
  min-width: 0;
108
251
  color: var(--dees-color-text-primary);
@@ -208,94 +351,421 @@ export class DeesHarnessQuestionCard extends DeesElement {
208
351
  font-weight: 500;
209
352
  overflow-wrap: anywhere;
210
353
  }
354
+
355
+ .itemSummary {
356
+ flex: 1;
357
+ min-width: 0;
358
+ color: var(--dees-color-text-primary);
359
+ overflow-wrap: anywhere;
360
+ }
361
+
362
+ .item .itemLabel {
363
+ flex: none;
364
+ justify-self: start;
365
+ font-size: var(--dees-font-caption1-size, 11px);
366
+ }
367
+
368
+ .decision {
369
+ display: flex;
370
+ flex-wrap: wrap;
371
+ align-items: center;
372
+ gap: var(--dees-spacing-sm);
373
+ border-radius: var(--dees-radius-xs);
374
+ }
375
+
376
+ .decision:focus {
377
+ outline: none;
378
+ }
379
+
380
+ .decision:focus-visible {
381
+ outline: var(--dees-line-width-focus-ring) solid var(--dees-color-focus-ring);
382
+ outline-offset: 2px;
383
+ }
384
+
385
+ .include {
386
+ flex: none;
387
+ width: 16px;
388
+ height: 16px;
389
+ margin: 0;
390
+ accent-color: var(--dees-color-accent-primary);
391
+ cursor: pointer;
392
+ }
393
+
394
+ .itemMarker {
395
+ flex: none;
396
+ }
397
+
398
+ .itemMarker.severity-warning {
399
+ color: var(--dees-color-badge-warning-fg);
400
+ }
401
+
402
+ .itemMarker.severity-danger {
403
+ color: var(--dees-color-badge-error-fg);
404
+ }
405
+
406
+ .item.leftOut .itemSummary {
407
+ color: var(--dees-color-text-secondary);
408
+ }
409
+
410
+ .leftOutNote {
411
+ flex: none;
412
+ color: var(--dees-color-text-secondary);
413
+ font-size: var(--dees-font-caption1-size, 11px);
414
+ }
415
+
416
+ .credential {
417
+ display: grid;
418
+ gap: 4px;
419
+ margin-top: 4px;
420
+ padding: 8px 10px;
421
+ border: var(--dees-line-width-hairline) solid var(--dees-color-border-subtle);
422
+ border-radius: var(--dees-radius-md);
423
+ corner-shape: var(--dees-corner-shape);
424
+ background: var(--dees-color-bg-secondary);
425
+ }
426
+
427
+ .credentialRow {
428
+ display: flex;
429
+ flex-wrap: wrap;
430
+ align-items: baseline;
431
+ gap: 4px var(--dees-spacing-sm);
432
+ min-width: 0;
433
+ }
434
+
435
+ .credentialLabel {
436
+ color: var(--dees-color-text-secondary);
437
+ }
438
+
439
+ .credentialValue {
440
+ flex: 1 1 12em;
441
+ min-width: 0;
442
+ color: var(--dees-color-text-primary);
443
+ font-family: var(--dees-font-family-mono);
444
+ overflow-wrap: anywhere;
445
+ user-select: all;
446
+ }
447
+
448
+ .credentialAction {
449
+ padding: 0;
450
+ border: none;
451
+ background: none;
452
+ color: var(--dees-color-accent-primary);
453
+ font: inherit;
454
+ font-size: var(--dees-font-caption1-size, 11px);
455
+ cursor: pointer;
456
+ border-radius: var(--dees-radius-xs);
457
+ }
458
+
459
+ .credentialAction:hover {
460
+ text-decoration: underline;
461
+ }
462
+
463
+ .credentialAction:focus-visible {
464
+ outline: var(--dees-line-width-focus-ring) solid var(--dees-color-focus-ring);
465
+ outline-offset: 2px;
466
+ }
467
+
468
+ .credentialFeedback {
469
+ color: var(--dees-color-text-secondary);
470
+ font-size: var(--dees-font-caption1-size, 11px);
471
+ }
472
+
473
+ .credentialFeedback.failed {
474
+ color: var(--dees-color-text-error);
475
+ }
476
+
477
+ .credentialNote {
478
+ margin: 0;
479
+ color: var(--dees-color-text-secondary);
480
+ font-size: var(--dees-font-caption1-size, 11px);
481
+ }
211
482
  `,
212
483
  ];
213
484
 
214
485
  public render(): TemplateResult {
215
486
  const request = this.request;
216
- const response = this.effectiveResponse;
217
- const disabled = this.busy || response !== undefined;
487
+ const severity = harnessQuestionSeverity(request);
488
+ const waiting = request.kind === 'proposal' ? this.proposalState === 'pending' : this.effectiveResponse === undefined;
218
489
  return html`
219
- <div class="card">
220
- <div class="titleRow">
221
- <dees-icon icon="lucide:MessageCircleQuestionMark" iconSize="15"></dees-icon>
222
- <span class="questionText">${request.question}</span>
490
+ <div class="card severity-${severity} ${waiting ? 'waiting' : ''}">
491
+ <div class="body">
492
+ <div class="titleRow">
493
+ <dees-icon icon=${titleIcon(request.kind, severity)} iconSize="15" aria-hidden="true"></dees-icon>
494
+ <span class="questionText">${severity === 'info'
495
+ ? ''
496
+ : html`<span class="srOnly">${this.t(severity === 'danger' ? 'question.danger' : 'question.warning')} </span>`}${request.question}</span>
497
+ </div>
498
+ ${request.kind === 'proposal' ? this.renderProposal() : this.renderQuestion()}
223
499
  </div>
224
- ${response
500
+ ${request.kind === 'proposal' && waiting
225
501
  ? html`
226
- <div class="answeredNote">
227
- ${this.t('question.answered')}
228
- <span class="answerText">${this.t.format.list(response, 'unit') || '—'}</span>
229
- </div>
502
+ <dees-actionfooter
503
+ source="harness-question-card"
504
+ .actions=${this.proposalActions}
505
+ .primaryActionType=${severity === 'danger' ? 'destructive' : 'accent'}
506
+ .disabled=${this.busy}
507
+ ></dees-actionfooter>
230
508
  `
231
- : html`
232
- ${request.options?.length
233
- ? html`
234
- <div class="options" role=${request.multiSelect ? 'group' : 'radiogroup'}>
235
- ${request.options.map((option) => html`
236
- <button
237
- class="option ${this.effectiveSelected.has(option.label) ? 'selected' : ''}"
238
- type="button"
239
- ?disabled=${disabled}
240
- @click=${() => this.handleOptionClick(option.label)}
241
- >
242
- <div class="optionLabel">${option.label}</div>
243
- ${option.description
244
- ? html`<div class="optionDescription">${option.description}</div>`
245
- : ''}
246
- </button>
247
- `)}
248
- </div>
249
- `
250
- : ''}
251
- ${request.allowCustom !== false
252
- ? html`
253
- <div class="customRow">
254
- <input
255
- placeholder=${this.t('question.custom')}
256
- .value=${this.effectiveCustomText}
257
- ?disabled=${disabled}
258
- @input=${(event: Event) => {
259
- this.customText = (event.currentTarget as HTMLInputElement).value;
260
- if (this.viewState) this.viewState.customText = this.customText;
261
- }}
262
- @keydown=${(event: KeyboardEvent) => {
263
- if (event.key === 'Enter' && this.effectiveCustomText.trim()) {
264
- this.respond([...this.effectiveSelected, this.effectiveCustomText.trim()]);
265
- }
266
- }}
267
- />
268
- <dees-button
269
- size="sm"
270
- ?disabled=${disabled || (!this.effectiveCustomText.trim() && !this.effectiveSelected.size)}
271
- @clicked=${() => {
272
- const answers = [...this.effectiveSelected];
273
- if (this.effectiveCustomText.trim()) answers.push(this.effectiveCustomText.trim());
274
- this.respond(answers);
275
- }}
276
- >${this.t('question.send')}</dees-button>
277
- </div>
278
- `
279
- : ''}
280
- ${request.multiSelect && request.allowCustom === false
281
- ? html`
282
- <div class="confirmRow">
283
- <dees-button
284
- type="accent"
285
- size="sm"
286
- ?disabled=${disabled || !this.effectiveSelected.size}
287
- @clicked=${() => this.respond([...this.effectiveSelected])}
288
- >${this.t('question.confirm')}</dees-button>
509
+ : ''}
510
+ </div>
511
+ `;
512
+ }
513
+
514
+ private renderQuestion(): TemplateResult {
515
+ const request = this.request;
516
+ const response = this.effectiveResponse;
517
+ const disabled = this.busy || response !== undefined;
518
+ return response
519
+ ? html`
520
+ <div class="answeredNote">
521
+ ${this.t('question.answered')}
522
+ <span class="answerText">${this.t.format.list(response, 'unit') || '—'}</span>
523
+ </div>
524
+ `
525
+ : html`
526
+ ${request.options?.length
527
+ ? html`
528
+ <div class="options" role=${request.multiSelect ? 'group' : 'radiogroup'}>
529
+ ${request.options.map((option) => html`
530
+ <button
531
+ class="option ${this.effectiveSelected.has(option.label) ? 'selected' : ''}"
532
+ type="button"
533
+ ?disabled=${disabled}
534
+ @click=${() => this.handleOptionClick(option.label)}
535
+ >
536
+ <div class="optionLabel">${option.label}</div>
537
+ ${option.description
538
+ ? html`<div class="optionDescription">${option.description}</div>`
539
+ : ''}
540
+ </button>
541
+ `)}
542
+ </div>
543
+ `
544
+ : ''}
545
+ ${request.allowCustom !== false
546
+ ? html`
547
+ <div class="customRow">
548
+ <input
549
+ placeholder=${this.t('question.custom')}
550
+ .value=${this.effectiveCustomText}
551
+ ?disabled=${disabled}
552
+ @input=${(event: Event) => {
553
+ this.customText = (event.currentTarget as HTMLInputElement).value;
554
+ if (this.viewState) this.viewState.customText = this.customText;
555
+ }}
556
+ @keydown=${(event: KeyboardEvent) => {
557
+ if (event.key === 'Enter' && this.effectiveCustomText.trim()) {
558
+ this.respond([...this.effectiveSelected, this.effectiveCustomText.trim()]);
559
+ }
560
+ }}
561
+ />
562
+ <dees-button
563
+ size="sm"
564
+ ?disabled=${disabled || (!this.effectiveCustomText.trim() && !this.effectiveSelected.size)}
565
+ @clicked=${() => {
566
+ const answers = [...this.effectiveSelected];
567
+ if (this.effectiveCustomText.trim()) answers.push(this.effectiveCustomText.trim());
568
+ this.respond(answers);
569
+ }}
570
+ >${this.t('question.send')}</dees-button>
571
+ </div>
572
+ `
573
+ : ''}
574
+ ${request.multiSelect && request.allowCustom === false
575
+ ? html`
576
+ <div class="confirmRow">
577
+ <dees-button
578
+ type="accent"
579
+ size="sm"
580
+ ?disabled=${disabled || !this.effectiveSelected.size}
581
+ @clicked=${() => this.respond([...this.effectiveSelected])}
582
+ >${this.t('question.confirm')}</dees-button>
583
+ </div>
584
+ `
585
+ : ''}
586
+ `;
587
+ }
588
+
589
+ /** The proposed changes and, once decided, the state and what came of it. */
590
+ private renderProposal(): TemplateResult {
591
+ const items = this.request.items ?? [];
592
+ const expanded = this.effectiveItemsExpanded;
593
+ const proposalState = this.proposalState;
594
+ // the reader chooses while the proposal waits; a confirmed one names what was left out
595
+ const choosing = this.itemsDeclinable && proposalState === 'pending';
596
+ const leftOut = choosing || proposalState === 'confirmed' || proposalState === 'failed'
597
+ ? this.effectiveLeftOut
598
+ : new Set<string>();
599
+ return html`
600
+ ${items.length
601
+ ? html`
602
+ <ul class="items" aria-label=${this.t('question.items')}>
603
+ ${harnessShownRecords(items, expanded).map((item) => {
604
+ const severity = item.severity ?? 'info';
605
+ const isLeftOut = leftOut.has(item.id);
606
+ return html`
607
+ <li class="item ${isLeftOut ? 'leftOut' : ''}">
608
+ <div class="itemHead">
609
+ ${choosing
610
+ ? html`
611
+ <input
612
+ class="include"
613
+ type="checkbox"
614
+ aria-label=${this.t('question.includeItem', { summary: item.summary })}
615
+ .checked=${!isLeftOut}
616
+ ?disabled=${this.locked}
617
+ @change=${(event: Event) => this.setIncluded(item.id, (event.currentTarget as HTMLInputElement).checked)}
618
+ />
619
+ `
620
+ : ''}
621
+ ${severity === 'info'
622
+ ? ''
623
+ : html`<dees-icon class="itemMarker severity-${severity}" icon=${ITEM_ICON[severity]} iconSize="13" aria-hidden="true"></dees-icon>`}
624
+ <span class="itemSummary">${severity === 'info'
625
+ ? ''
626
+ : html`<span class="srOnly">${this.t(severity === 'danger' ? 'question.danger' : 'question.warning')} </span>`}${item.summary}</span>
627
+ ${isLeftOut ? html`<span class="leftOutNote">${this.t('question.leftOut')}</span>` : ''}
628
+ ${item.outcome ? renderHarnessOutcome(item.outcome) : ''}
289
629
  </div>
290
- `
291
- : ''}
292
- `}
630
+ ${item.label
631
+ ? item.href
632
+ ? html`<a class="itemLabel" href=${item.href} @click=${(event: MouseEvent) => this.openItem(event, item)}>${item.label}</a>`
633
+ : html`<span class="itemLabel">${item.label}</span>`
634
+ : ''}
635
+ ${item.changes?.length ? renderHarnessChanges(this.t, item.changes) : ''}
636
+ ${item.credential ? this.renderCredential(item) : ''}
637
+ </li>
638
+ `;
639
+ })}
640
+ </ul>
641
+ ${renderHarnessMoreRecords(this.t, items.length, expanded, this.toggleItems)}
642
+ `
643
+ : ''}
644
+ ${proposalState === 'pending'
645
+ ? ''
646
+ : html`
647
+ <div class="decision" tabindex="-1">
648
+ <dees-badge type=${STATE_BADGE[proposalState]} .text=${this.t(`question.${proposalState}`)} rounded></dees-badge>
649
+ ${this.request.outcome ? renderHarnessOutcome(this.request.outcome) : ''}
650
+ </div>
651
+ `}
652
+ `;
653
+ }
654
+
655
+ /**
656
+ * A secret a change issued, for the reader's eyes: masked (its value not in the page) until
657
+ * shown, and copied on request with a word on how that went.
658
+ */
659
+ private renderCredential(itemArg: IHarnessProposalItem): TemplateResult {
660
+ const credential = itemArg.credential!;
661
+ const shown = this.credentialsShown.has(itemArg.id);
662
+ const feedback = this.copyFeedback?.itemId === itemArg.id ? this.copyFeedback : undefined;
663
+ return html`
664
+ <div class="credential">
665
+ <div class="credentialRow">
666
+ <span class="credentialLabel">${credential.label}</span>
667
+ <code class="credentialValue">${shown
668
+ ? credential.value
669
+ : html`<span aria-hidden="true">${CREDENTIAL_MASK}</span><span class="srOnly">${this.t('question.credentialHidden')}</span>`}</code>
670
+ <button
671
+ class="credentialAction"
672
+ type="button"
673
+ aria-label=${this.t(shown ? 'question.credentialHide' : 'question.credentialShow', { label: credential.label })}
674
+ @click=${() => this.toggleCredential(itemArg.id)}
675
+ >${this.t(shown ? 'question.credentialHideShort' : 'question.credentialShowShort')}</button>
676
+ <button
677
+ class="credentialAction"
678
+ type="button"
679
+ aria-label=${this.t('question.credentialCopy', { label: credential.label })}
680
+ @click=${() => this.copyCredential(itemArg)}
681
+ >${this.t('common.copy')}</button>
682
+ <span class="credentialFeedback ${feedback?.failed ? 'failed' : ''}" role="status" aria-live="polite">${feedback?.text ?? ''}</span>
683
+ </div>
684
+ <p class="credentialNote">${credential.note ?? this.t('question.credentialNote')}</p>
293
685
  </div>
294
686
  `;
295
687
  }
296
688
 
689
+ /** Decline, and Confirm as the primary; kept while their words and Confirm's availability stay, so the footer knows a running one by its object. */
690
+ private get proposalActions(): IActionFooterAction[] {
691
+ const confirm = this.request.confirmLabel ?? this.t('question.proposalConfirm');
692
+ const decline = this.request.declineLabel ?? this.t('question.proposalDecline');
693
+ // a proposal whose every change is left out has nothing to confirm
694
+ const nothingIncluded = this.itemsDeclinable && this.effectiveLeftOut.size === (this.request.items?.length ?? 0);
695
+ if (
696
+ this.footerActions?.confirm !== confirm
697
+ || this.footerActions.decline !== decline
698
+ || this.footerActions.nothingIncluded !== nothingIncluded
699
+ ) {
700
+ this.footerActions = {
701
+ confirm,
702
+ decline,
703
+ nothingIncluded,
704
+ actions: [
705
+ { name: decline, action: async () => this.respond(['decline']) },
706
+ { name: confirm, primary: true, disabled: nothingIncluded, action: async () => this.respond(['confirm']) },
707
+ ],
708
+ };
709
+ }
710
+ return this.footerActions.actions;
711
+ }
712
+
713
+ private footerActions: { confirm: string; decline: string; nothingIncluded: boolean; actions: IActionFooterAction[] } | undefined;
714
+
715
+ /** The reader includes a change in the proposal, or leaves it out. */
716
+ private setIncluded(itemIdArg: string, includedArg: boolean): void {
717
+ if (this.locked) return;
718
+ const next = new Set(this.effectiveLeftOut);
719
+ if (includedArg) next.delete(itemIdArg);
720
+ else next.add(itemIdArg);
721
+ this.leftOut = next;
722
+ if (this.viewState) this.viewState.declinedItemIds = [...next];
723
+ }
724
+
725
+ private toggleCredential(itemIdArg: string): void {
726
+ const next = new Set(this.credentialsShown);
727
+ if (next.has(itemIdArg)) next.delete(itemIdArg);
728
+ else next.add(itemIdArg);
729
+ this.credentialsShown = next;
730
+ }
731
+
732
+ private async copyCredential(itemArg: IHarnessProposalItem): Promise<void> {
733
+ const credential = itemArg.credential!;
734
+ const request = ++this.copyRequest;
735
+ clearTimeout(this.copyResetTimeout);
736
+ this.copyFeedback = undefined;
737
+ try {
738
+ await navigator.clipboard.writeText(credential.value);
739
+ if (!this.isConnected || request !== this.copyRequest) return;
740
+ this.copyFeedback = { itemId: itemArg.id, text: this.t('question.credentialCopied', { label: credential.label }), failed: false };
741
+ } catch {
742
+ if (!this.isConnected || request !== this.copyRequest) return;
743
+ this.copyFeedback = { itemId: itemArg.id, text: this.t('question.credentialCopyFailed'), failed: true };
744
+ }
745
+ this.copyResetTimeout = setTimeout(() => {
746
+ this.copyFeedback = undefined;
747
+ this.copyResetTimeout = undefined;
748
+ }, 3000);
749
+ }
750
+
751
+ private readonly toggleItems = (): void => {
752
+ this.itemsExpanded = !this.effectiveItemsExpanded;
753
+ if (this.viewState) this.viewState.itemsExpanded = this.itemsExpanded;
754
+ };
755
+
756
+ /** A proposed change's link: the host may route it itself (it cancels the event); a plain or modified click otherwise follows it. */
757
+ private openItem(eventArg: MouseEvent, itemArg: IHarnessProposalItem): void {
758
+ const { credential: _credential, ...item } = itemArg;
759
+ routeHarnessRecordLink(eventArg, () => this.dispatchEvent(new CustomEvent<IHarnessQuestionLinkDetail>('harness-question-link', {
760
+ detail: { requestId: this.request.id, item, request: harnessWithoutCredentials(this.request) },
761
+ bubbles: true,
762
+ composed: true,
763
+ cancelable: true,
764
+ })));
765
+ }
766
+
297
767
  private handleOptionClick(label: string): void {
298
- if (this.busy || this.effectiveResponse !== undefined) return;
768
+ if (this.locked) return;
299
769
  if (this.request.multiSelect) {
300
770
  const next = new Set(this.effectiveSelected);
301
771
  if (next.has(label)) next.delete(label);
@@ -308,19 +778,36 @@ export class DeesHarnessQuestionCard extends DeesElement {
308
778
  }
309
779
 
310
780
  private respond(answers: string[]): void {
311
- if (this.busy || this.effectiveResponse !== undefined || !answers.length) return;
781
+ if (this.locked || !answers.length) return;
782
+ const items = this.request.items ?? [];
783
+ const leftOut = answers[0] === 'confirm' && this.itemsDeclinable ? this.effectiveLeftOut : new Set<string>();
784
+ if (leftOut.size > 0 && leftOut.size === items.length) return;
785
+ // the footer leaves with the answer: its focus moves to the decision that takes its place
786
+ const footerFocused = this.shadowRoot?.activeElement?.localName === 'dees-actionfooter';
312
787
  this.answered = answers;
313
788
  if (this.viewState) this.viewState.answered = answers;
314
- this.dispatchEvent(
315
- new CustomEvent('harness-question-response', {
316
- detail: {
317
- requestId: this.request.id,
318
- answers,
319
- request: this.request,
320
- },
321
- bubbles: true,
322
- composed: true,
323
- }),
324
- );
789
+ if (footerFocused) {
790
+ void this.updateComplete.then(() => this.shadowRoot?.querySelector<HTMLElement>('.decision')?.focus());
791
+ }
792
+ const detail: IHarnessQuestionResponseDetail = {
793
+ requestId: this.request.id,
794
+ answers,
795
+ request: harnessWithoutCredentials(this.request),
796
+ };
797
+ if (leftOut.size > 0) detail.declinedItemIds = items.filter((item) => leftOut.has(item.id)).map((item) => item.id);
798
+ this.dispatchEvent(new CustomEvent<IHarnessQuestionResponseDetail>('harness-question-response', {
799
+ detail,
800
+ bubbles: true,
801
+ composed: true,
802
+ }));
803
+ }
804
+
805
+ public async disconnectedCallback(): Promise<void> {
806
+ ++this.copyRequest;
807
+ clearTimeout(this.copyResetTimeout);
808
+ this.copyResetTimeout = undefined;
809
+ this.copyFeedback = undefined;
810
+ this.credentialsShown = new Set<string>();
811
+ await super.disconnectedCallback();
325
812
  }
326
813
  }