@design.estate/dees-catalog 21.34.0 → 21.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_bundle/bundle.js +848 -241
- package/dist_bundle/bundle.js.map +1 -1
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-P3H4LK6R.js → chunk-3YTKY5IS.js} +7 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-P3H4LK6R.js.map → chunk-3YTKY5IS.js.map} +1 -1
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-Y4JW5Y72.js → chunk-5UGXWLMH.js} +3 -3
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-22Q5WLXW.js → chunk-ZCZ72OW4.js} +2 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{de-7LG7TVSW.js → de-PERXVUIS.js} +7 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-PERXVUIS.js.map +1 -0
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-TUZWVVOC.js → dees-modal-4QORKLGX.js} +3 -3
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-FZU6LDKJ.js → dees-workspace-terminal-7SYZG2AB.js} +4 -4
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/dist_ts_web/elements/00group-harness/dees-harness-chat/dees-harness-chat.d.ts +5 -1
- package/dist_ts_web/elements/00group-harness/dees-harness-chat/dees-harness-chat.js +11 -1
- package/dist_ts_web/elements/00group-harness/dees-harness-message-list/dees-harness-message-list.d.ts +28 -1
- package/dist_ts_web/elements/00group-harness/dees-harness-message-list/dees-harness-message-list.js +78 -1
- package/dist_ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.d.ts +75 -3
- package/dist_ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.demo.js +140 -44
- package/dist_ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.js +500 -16
- package/dist_ts_web/elements/00group-harness/interfaces.d.ts +72 -0
- package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.d.ts +8 -1
- package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.js +32 -5
- package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.js +225 -179
- package/dist_ts_web/i18n/de.d.ts +20 -0
- package/dist_ts_web/i18n/de.js +6 -1
- package/dist_ts_web/i18n/messages.d.ts +20 -0
- package/dist_ts_web/i18n/messages.js +6 -1
- package/package.json +1 -1
- package/readme.md +51 -2
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/elements/00group-harness/dees-harness-chat/dees-harness-chat.ts +17 -0
- package/ts_web/elements/00group-harness/dees-harness-message-list/dees-harness-message-list.ts +83 -0
- package/ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.demo.ts +106 -2
- package/ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.ts +484 -14
- package/ts_web/elements/00group-harness/interfaces.ts +77 -0
- package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.ts +24 -3
- package/ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.ts +240 -194
- package/ts_web/i18n/de.ts +5 -0
- package/ts_web/i18n/messages.ts +5 -0
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-7LG7TVSW.js.map +0 -1
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-Y4JW5Y72.js.map → chunk-5UGXWLMH.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-22Q5WLXW.js.map → chunk-ZCZ72OW4.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-TUZWVVOC.js.map → dees-modal-4QORKLGX.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-FZU6LDKJ.js.map → dees-workspace-terminal-7SYZG2AB.js.map} +0 -0
package/ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { themeDefaultStyles } from '../../00theme.js';
|
|
|
14
14
|
import { harnessActivityStyles, harnessControlStyles } from '../harness.styles.js';
|
|
15
15
|
import { harnessProposalState, harnessQuestionSeverity, harnessWithoutCredentials } from '../harness.helpers.js';
|
|
16
16
|
import {
|
|
17
|
+
harnessRecordsShown,
|
|
17
18
|
harnessShownRecords,
|
|
18
19
|
harnessRecordStyles,
|
|
19
20
|
renderHarnessChanges,
|
|
@@ -24,6 +25,10 @@ import {
|
|
|
24
25
|
import type {
|
|
25
26
|
IHarnessProposalItem,
|
|
26
27
|
IHarnessQuestionLinkDetail,
|
|
28
|
+
IHarnessQuestionPersonField,
|
|
29
|
+
IHarnessQuestionPersonResult,
|
|
30
|
+
IHarnessQuestionPersonValue,
|
|
31
|
+
IHarnessQuestionRejection,
|
|
27
32
|
IHarnessQuestionRequest,
|
|
28
33
|
IHarnessQuestionResponseDetail,
|
|
29
34
|
IHarnessQuestionViewState,
|
|
@@ -57,6 +62,21 @@ const ITEM_ICON: Record<Exclude<THarnessQuestionSeverity, 'info'>, string> = {
|
|
|
57
62
|
/** A credential's value while hidden: the same length for every secret, so it tells nothing of it. */
|
|
58
63
|
const CREDENTIAL_MASK = '••••••••••••';
|
|
59
64
|
|
|
65
|
+
/** A person field's value by its change and its own id, which is unique within the change only. */
|
|
66
|
+
const personKey = (itemIdArg: string, fieldIdArg: string): string => `${itemIdArg}\u0000${fieldIdArg}`;
|
|
67
|
+
|
|
68
|
+
const NO_PERSON_RESULTS: readonly IHarnessQuestionPersonResult[] = [];
|
|
69
|
+
|
|
70
|
+
/** A link result's address, where it is an http or https one; any other is shown as text. */
|
|
71
|
+
const httpHref = (valueArg: string): string | undefined => {
|
|
72
|
+
try {
|
|
73
|
+
const url = new URL(valueArg);
|
|
74
|
+
return url.protocol === 'http:' || url.protocol === 'https:' ? url.href : undefined;
|
|
75
|
+
} catch {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
60
80
|
/** The badge of each decided state. */
|
|
61
81
|
const STATE_BADGE: Record<Exclude<THarnessProposalState, 'pending'>, 'success' | 'default' | 'error'> = {
|
|
62
82
|
confirmed: 'success',
|
|
@@ -89,6 +109,19 @@ const STATE_BADGE: Record<Exclude<THarnessProposalState, 'pending'>, 'success' |
|
|
|
89
109
|
* while `busy`, and once its changes are under way. A change's `credential`
|
|
90
110
|
* (a secret it issued) shows to the reader only, masked until asked for;
|
|
91
111
|
* no event the card emits carries it.
|
|
112
|
+
*
|
|
113
|
+
* A change may need values from the person and from nobody else
|
|
114
|
+
* (`personFields`): entered under the change while the proposal waits, a
|
|
115
|
+
* secret one masked until shown, and sent with the confirmation only, as its
|
|
116
|
+
* `personValues`. A required field left empty or a value over its
|
|
117
|
+
* `maxLength` holds Confirm back; a decline sends none. The card keeps them
|
|
118
|
+
* neither in its view state nor once it answered, was given another request
|
|
119
|
+
* or left the page. What the confirmed changes return to the person, the host
|
|
120
|
+
* hands to the card as `personResults`, shown under their change (a secret
|
|
121
|
+
* masked until shown, a link only to an http or https address) and kept as
|
|
122
|
+
* briefly. A host that refuses a confirmation it was sent asks again with
|
|
123
|
+
* `rejectResponse()`: the card waits once more, keeps the changes the reader
|
|
124
|
+
* left out, and says why at each value the host named.
|
|
92
125
|
*/
|
|
93
126
|
@customElement('dees-harness-question-card')
|
|
94
127
|
export class DeesHarnessQuestionCard extends DeesElement {
|
|
@@ -128,7 +161,30 @@ export class DeesHarnessQuestionCard extends DeesElement {
|
|
|
128
161
|
accessor credentialsShown: ReadonlySet<string> = new Set<string>();
|
|
129
162
|
|
|
130
163
|
@state()
|
|
131
|
-
accessor copyFeedback: {
|
|
164
|
+
accessor copyFeedback: { key: string; text: string; failed: boolean } | undefined = undefined;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* What the confirmed changes returned to the person, from the host after its own confirmation:
|
|
168
|
+
* kept by this element alone, until it is given another request or leaves the page.
|
|
169
|
+
*/
|
|
170
|
+
@property({ attribute: false })
|
|
171
|
+
accessor personResults: readonly IHarnessQuestionPersonResult[] = NO_PERSON_RESULTS;
|
|
172
|
+
|
|
173
|
+
/** what the person entered in `personFields`, by `personKey`; never in the view state, and gone with the answer */
|
|
174
|
+
@state()
|
|
175
|
+
accessor personValues: ReadonlyMap<string, string> = new Map<string, string>();
|
|
176
|
+
|
|
177
|
+
/** the secret fields the person shows as typed, by `personKey` */
|
|
178
|
+
@state()
|
|
179
|
+
accessor personFieldsShown: ReadonlySet<string> = new Set<string>();
|
|
180
|
+
|
|
181
|
+
/** the secret results the person asked to see, by result id */
|
|
182
|
+
@state()
|
|
183
|
+
accessor personResultsShown: ReadonlySet<string> = new Set<string>();
|
|
184
|
+
|
|
185
|
+
/** why the host refused the last confirmation, until the next answer; the view state keeps it over a remount */
|
|
186
|
+
@state()
|
|
187
|
+
accessor rejection: IHarnessQuestionRejection | undefined = undefined;
|
|
132
188
|
|
|
133
189
|
private copyRequest = 0;
|
|
134
190
|
private copyResetTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -174,6 +230,35 @@ export class DeesHarnessQuestionCard extends DeesElement {
|
|
|
174
230
|
return new Set((this.request.items ?? []).filter((item) => chosen.has(item.id)).map((item) => item.id));
|
|
175
231
|
}
|
|
176
232
|
|
|
233
|
+
/** A change's person fields, those of a proposal only. */
|
|
234
|
+
private personFieldsOf(itemIdArg: string): readonly IHarnessQuestionPersonField[] {
|
|
235
|
+
if (this.request.kind !== 'proposal') return [];
|
|
236
|
+
return (this.request.personFields ?? []).filter((field) => field.itemId === itemIdArg);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** The person fields a confirmation sends: those of the changes it includes. */
|
|
240
|
+
private get includedPersonFields(): readonly IHarnessQuestionPersonField[] {
|
|
241
|
+
if (this.request.kind !== 'proposal' || !this.request.personFields?.length) return [];
|
|
242
|
+
const leftOut = this.effectiveLeftOut;
|
|
243
|
+
const included = new Set((this.request.items ?? []).filter((item) => !leftOut.has(item.id)).map((item) => item.id));
|
|
244
|
+
return this.request.personFields.filter((field) => included.has(field.itemId));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
private personValueOf(fieldArg: IHarnessQuestionPersonField): string {
|
|
248
|
+
return this.personValues.get(personKey(fieldArg.itemId, fieldArg.id)) ?? '';
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Whether a required field of an included change is still empty. */
|
|
252
|
+
private get personFieldsMissing(): boolean {
|
|
253
|
+
return this.includedPersonFields.some((field) => field.required === true && this.personValueOf(field).trim() === '');
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** Whether the included changes have every value they need, none of them too long. */
|
|
257
|
+
private get personFieldsComplete(): boolean {
|
|
258
|
+
return !this.personFieldsMissing
|
|
259
|
+
&& this.includedPersonFields.every((field) => this.personValueOf(field).length <= field.maxLength);
|
|
260
|
+
}
|
|
261
|
+
|
|
177
262
|
/** Whether the card takes no answer: answered, waiting for the host (`busy`), or its changes under way or decided. */
|
|
178
263
|
private get locked(): boolean {
|
|
179
264
|
return this.busy || this.effectiveResponse !== undefined || this.proposalState !== 'pending';
|
|
@@ -479,6 +564,130 @@ export class DeesHarnessQuestionCard extends DeesElement {
|
|
|
479
564
|
color: var(--dees-color-text-secondary);
|
|
480
565
|
font-size: var(--dees-font-caption1-size, 11px);
|
|
481
566
|
}
|
|
567
|
+
|
|
568
|
+
.personResultText {
|
|
569
|
+
flex: 1 1 12em;
|
|
570
|
+
min-width: 0;
|
|
571
|
+
color: var(--dees-color-text-primary);
|
|
572
|
+
overflow-wrap: anywhere;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
.personResultLink {
|
|
576
|
+
flex: 1 1 12em;
|
|
577
|
+
min-width: 0;
|
|
578
|
+
color: var(--dees-color-accent-primary);
|
|
579
|
+
overflow-wrap: anywhere;
|
|
580
|
+
border-radius: var(--dees-radius-xs);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
.personResultLink:focus-visible {
|
|
584
|
+
outline: var(--dees-line-width-focus-ring) solid var(--dees-color-focus-ring);
|
|
585
|
+
outline-offset: 2px;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.personFields {
|
|
589
|
+
display: grid;
|
|
590
|
+
gap: var(--dees-spacing-sm);
|
|
591
|
+
margin-top: 4px;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
.personField {
|
|
595
|
+
display: grid;
|
|
596
|
+
gap: 4px;
|
|
597
|
+
min-width: 0;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.personLabel {
|
|
601
|
+
justify-self: start;
|
|
602
|
+
color: var(--dees-color-text-secondary);
|
|
603
|
+
font-weight: 500;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
.personLabel .required {
|
|
607
|
+
margin-left: var(--dees-spacing-2xs);
|
|
608
|
+
color: var(--dees-color-accent-error);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
.personInputRow {
|
|
612
|
+
display: flex;
|
|
613
|
+
align-items: center;
|
|
614
|
+
gap: var(--dees-spacing-sm);
|
|
615
|
+
min-width: 0;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
.personInput {
|
|
619
|
+
flex: 1;
|
|
620
|
+
min-width: 0;
|
|
621
|
+
height: var(--dees-control-height-md);
|
|
622
|
+
padding: 0 var(--dees-spacing-sm);
|
|
623
|
+
border: var(--dees-line-width-hairline) solid var(--dees-color-border-default);
|
|
624
|
+
border-radius: var(--dees-radius-md);
|
|
625
|
+
corner-shape: var(--dees-corner-shape);
|
|
626
|
+
background: var(--dees-color-bg-primary);
|
|
627
|
+
color: var(--dees-color-text-primary);
|
|
628
|
+
font-family: inherit;
|
|
629
|
+
font-size: var(--dees-font-control-size-sm, 12px);
|
|
630
|
+
outline: none;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.personInput.secret {
|
|
634
|
+
font-family: var(--dees-font-family-mono);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
textarea.personInput {
|
|
638
|
+
height: auto;
|
|
639
|
+
min-height: calc(var(--dees-control-height-md) * 2);
|
|
640
|
+
padding: 6px var(--dees-spacing-sm);
|
|
641
|
+
line-height: 1.4;
|
|
642
|
+
resize: vertical;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/* a secret of several lines has no password input: it is masked as one is */
|
|
646
|
+
textarea.personInput.masked {
|
|
647
|
+
-webkit-text-security: disc;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
.personInput:focus {
|
|
651
|
+
border-color: var(--dees-color-accent-primary);
|
|
652
|
+
box-shadow: 0 0 0 var(--dees-line-width-focus-ring) var(--dees-color-focus-ring);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
.personInput[aria-invalid='true'] {
|
|
656
|
+
border-color: var(--dees-color-accent-error);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
.personInput:disabled {
|
|
660
|
+
cursor: default;
|
|
661
|
+
opacity: 0.6;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
.personHint,
|
|
665
|
+
.personError,
|
|
666
|
+
.personNote {
|
|
667
|
+
margin: 0;
|
|
668
|
+
color: var(--dees-color-text-secondary);
|
|
669
|
+
font-size: var(--dees-font-caption1-size, 11px);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
.personError {
|
|
673
|
+
color: var(--dees-color-text-error);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
.personNote + .personNote {
|
|
677
|
+
margin-top: var(--dees-spacing-2xs);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
.rejection {
|
|
681
|
+
margin: 0 0 12px;
|
|
682
|
+
padding: 8px 12px;
|
|
683
|
+
border: var(--dees-line-width-hairline) solid var(--dees-color-accent-error);
|
|
684
|
+
border-radius: var(--dees-radius-lg);
|
|
685
|
+
corner-shape: var(--dees-corner-shape);
|
|
686
|
+
background: var(--dees-color-badge-error-bg);
|
|
687
|
+
color: var(--dees-color-badge-error-fg);
|
|
688
|
+
font-size: var(--dees-font-control-size-sm, 12px);
|
|
689
|
+
overflow-wrap: anywhere;
|
|
690
|
+
}
|
|
482
691
|
`,
|
|
483
692
|
];
|
|
484
693
|
|
|
@@ -589,8 +798,17 @@ export class DeesHarnessQuestionCard extends DeesElement {
|
|
|
589
798
|
/** The proposed changes and, once decided, the state and what came of it. */
|
|
590
799
|
private renderProposal(): TemplateResult {
|
|
591
800
|
const items = this.request.items ?? [];
|
|
592
|
-
const expanded = this.effectiveItemsExpanded;
|
|
593
801
|
const proposalState = this.proposalState;
|
|
802
|
+
const pending = proposalState === 'pending';
|
|
803
|
+
// a change that asks the person for values, or returned some, is never folded away
|
|
804
|
+
const personItems = new Set([
|
|
805
|
+
...(pending ? (this.request.personFields ?? []).map((field) => field.itemId) : []),
|
|
806
|
+
...this.personResults.map((result) => result.itemId),
|
|
807
|
+
]);
|
|
808
|
+
const unfolded = !this.effectiveItemsExpanded && items.slice(harnessRecordsShown).some((item) => personItems.has(item.id));
|
|
809
|
+
const expanded = this.effectiveItemsExpanded || unfolded;
|
|
810
|
+
const itemIds = new Set(items.map((item) => item.id));
|
|
811
|
+
const otherResults = this.personResults.filter((result) => !itemIds.has(result.itemId));
|
|
594
812
|
// the reader chooses while the proposal waits; a confirmed one names what was left out
|
|
595
813
|
const choosing = this.itemsDeclinable && proposalState === 'pending';
|
|
596
814
|
const leftOut = choosing || proposalState === 'confirmed' || proposalState === 'failed'
|
|
@@ -633,14 +851,22 @@ export class DeesHarnessQuestionCard extends DeesElement {
|
|
|
633
851
|
: html`<span class="itemLabel">${item.label}</span>`
|
|
634
852
|
: ''}
|
|
635
853
|
${item.changes?.length ? renderHarnessChanges(this.t, item.changes) : ''}
|
|
854
|
+
${pending && !isLeftOut && this.personFieldsOf(item.id).length
|
|
855
|
+
? this.renderPersonFields(this.personFieldsOf(item.id))
|
|
856
|
+
: ''}
|
|
636
857
|
${item.credential ? this.renderCredential(item) : ''}
|
|
858
|
+
${this.personResults.some((result) => result.itemId === item.id)
|
|
859
|
+
? this.renderPersonResults(this.personResults.filter((result) => result.itemId === item.id))
|
|
860
|
+
: ''}
|
|
637
861
|
</li>
|
|
638
862
|
`;
|
|
639
863
|
})}
|
|
640
864
|
</ul>
|
|
641
|
-
${renderHarnessMoreRecords(this.t, items.length, expanded, this.toggleItems)}
|
|
865
|
+
${unfolded ? '' : renderHarnessMoreRecords(this.t, items.length, expanded, this.toggleItems)}
|
|
642
866
|
`
|
|
643
867
|
: ''}
|
|
868
|
+
${otherResults.length ? this.renderPersonResults(otherResults) : ''}
|
|
869
|
+
${pending ? this.renderPersonNotes() : ''}
|
|
644
870
|
${proposalState === 'pending'
|
|
645
871
|
? ''
|
|
646
872
|
: html`
|
|
@@ -659,7 +885,7 @@ export class DeesHarnessQuestionCard extends DeesElement {
|
|
|
659
885
|
private renderCredential(itemArg: IHarnessProposalItem): TemplateResult {
|
|
660
886
|
const credential = itemArg.credential!;
|
|
661
887
|
const shown = this.credentialsShown.has(itemArg.id);
|
|
662
|
-
const feedback = this.copyFeedback?.
|
|
888
|
+
const feedback = this.copyFeedback?.key === `credential:${itemArg.id}` ? this.copyFeedback : undefined;
|
|
663
889
|
return html`
|
|
664
890
|
<div class="credential">
|
|
665
891
|
<div class="credentialRow">
|
|
@@ -677,7 +903,7 @@ export class DeesHarnessQuestionCard extends DeesElement {
|
|
|
677
903
|
class="credentialAction"
|
|
678
904
|
type="button"
|
|
679
905
|
aria-label=${this.t('question.credentialCopy', { label: credential.label })}
|
|
680
|
-
@click=${() => this.
|
|
906
|
+
@click=${() => this.copySecret(`credential:${itemArg.id}`, credential.label, credential.value)}
|
|
681
907
|
>${this.t('common.copy')}</button>
|
|
682
908
|
<span class="credentialFeedback ${feedback?.failed ? 'failed' : ''}" role="status" aria-live="polite">${feedback?.text ?? ''}</span>
|
|
683
909
|
</div>
|
|
@@ -686,31 +912,178 @@ export class DeesHarnessQuestionCard extends DeesElement {
|
|
|
686
912
|
`;
|
|
687
913
|
}
|
|
688
914
|
|
|
915
|
+
/** The values a change needs from the person, under it while the proposal waits. */
|
|
916
|
+
private renderPersonFields(fieldsArg: readonly IHarnessQuestionPersonField[]): TemplateResult {
|
|
917
|
+
return html`<div class="personFields">${fieldsArg.map((field) => this.renderPersonField(field))}</div>`;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* One value for the person to enter: labelled, a secret masked until shown, its hint, and what
|
|
922
|
+
* holds it back: too long, or refused by the host. It is not cut at its `maxLength`: a pasted
|
|
923
|
+
* secret cut short would be a wrong one.
|
|
924
|
+
*/
|
|
925
|
+
private renderPersonField(fieldArg: IHarnessQuestionPersonField): TemplateResult {
|
|
926
|
+
const key = personKey(fieldArg.itemId, fieldArg.id);
|
|
927
|
+
const domId = `person-field-${(this.request.personFields ?? []).indexOf(fieldArg)}`;
|
|
928
|
+
const value = this.personValues.get(key) ?? '';
|
|
929
|
+
const secret = fieldArg.input === 'secret';
|
|
930
|
+
const shown = this.personFieldsShown.has(key);
|
|
931
|
+
const error = value.length > fieldArg.maxLength
|
|
932
|
+
? this.t('question.personTooLong', { max: fieldArg.maxLength, count: value.length })
|
|
933
|
+
: this.effectiveRejection?.fieldErrors?.find((entry) => entry.itemId === fieldArg.itemId && entry.fieldId === fieldArg.id)?.message;
|
|
934
|
+
const describedBy = [fieldArg.hint ? `${domId}-hint` : '', error ? `${domId}-error` : ''].filter(Boolean).join(' ');
|
|
935
|
+
const input = (eventArg: Event) => this.setPersonValue(fieldArg, (eventArg.currentTarget as HTMLInputElement | HTMLTextAreaElement).value);
|
|
936
|
+
return html`
|
|
937
|
+
<div class="personField">
|
|
938
|
+
<label class="personLabel" for=${domId}>${fieldArg.label}${fieldArg.required
|
|
939
|
+
? html`<span class="required" aria-hidden="true">*</span>`
|
|
940
|
+
: ''}</label>
|
|
941
|
+
<div class="personInputRow">
|
|
942
|
+
${fieldArg.multiline
|
|
943
|
+
? html`
|
|
944
|
+
<textarea
|
|
945
|
+
id=${domId}
|
|
946
|
+
class="personInput ${secret ? 'secret' : ''} ${secret && !shown ? 'masked' : ''}"
|
|
947
|
+
rows="3"
|
|
948
|
+
autocomplete="off"
|
|
949
|
+
spellcheck=${secret ? 'false' : 'true'}
|
|
950
|
+
aria-required=${fieldArg.required ? 'true' : 'false'}
|
|
951
|
+
aria-invalid=${error ? 'true' : 'false'}
|
|
952
|
+
aria-describedby=${describedBy}
|
|
953
|
+
.value=${value}
|
|
954
|
+
?disabled=${this.locked}
|
|
955
|
+
@input=${input}
|
|
956
|
+
></textarea>
|
|
957
|
+
`
|
|
958
|
+
: html`
|
|
959
|
+
<input
|
|
960
|
+
id=${domId}
|
|
961
|
+
class="personInput ${secret ? 'secret' : ''}"
|
|
962
|
+
type=${secret && !shown ? 'password' : 'text'}
|
|
963
|
+
autocomplete="off"
|
|
964
|
+
spellcheck=${secret ? 'false' : 'true'}
|
|
965
|
+
aria-required=${fieldArg.required ? 'true' : 'false'}
|
|
966
|
+
aria-invalid=${error ? 'true' : 'false'}
|
|
967
|
+
aria-describedby=${describedBy}
|
|
968
|
+
.value=${value}
|
|
969
|
+
?disabled=${this.locked}
|
|
970
|
+
@input=${input}
|
|
971
|
+
/>
|
|
972
|
+
`}
|
|
973
|
+
${secret
|
|
974
|
+
? html`
|
|
975
|
+
<button
|
|
976
|
+
class="credentialAction"
|
|
977
|
+
type="button"
|
|
978
|
+
aria-controls=${domId}
|
|
979
|
+
aria-label=${this.t(shown ? 'question.credentialHide' : 'question.credentialShow', { label: fieldArg.label })}
|
|
980
|
+
@click=${() => this.togglePersonField(key)}
|
|
981
|
+
>${this.t(shown ? 'question.credentialHideShort' : 'question.credentialShowShort')}</button>
|
|
982
|
+
`
|
|
983
|
+
: ''}
|
|
984
|
+
</div>
|
|
985
|
+
${fieldArg.hint ? html`<p class="personHint" id="${domId}-hint">${fieldArg.hint}</p>` : ''}
|
|
986
|
+
${error ? html`<p class="personError" id="${domId}-error">${error}</p>` : ''}
|
|
987
|
+
</div>
|
|
988
|
+
`;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Under the changes of a waiting proposal: the host's refusal of the last confirmation, that
|
|
993
|
+
* what the person enters goes nowhere but with the confirmation, and what still holds it back.
|
|
994
|
+
*/
|
|
995
|
+
private renderPersonNotes(): TemplateResult {
|
|
996
|
+
const rejection = this.effectiveRejection;
|
|
997
|
+
const rejectionText = rejection?.message ?? (rejection?.fieldErrors?.length ? this.t('question.rejected') : '');
|
|
998
|
+
const fields = this.includedPersonFields.length > 0;
|
|
999
|
+
return html`
|
|
1000
|
+
${rejectionText ? html`<p class="rejection" role="alert">${rejectionText}</p>` : ''}
|
|
1001
|
+
${fields ? html`<p class="personNote">${this.t('question.personFieldsNote')}</p>` : ''}
|
|
1002
|
+
${fields && !this.locked && this.personFieldsMissing
|
|
1003
|
+
? html`<p class="personNote personMissing">${this.t('question.personFieldsMissing')}</p>`
|
|
1004
|
+
: ''}
|
|
1005
|
+
`;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/** What the confirmed changes returned to the person: a secret masked until shown, a link to an http or https address only. */
|
|
1009
|
+
private renderPersonResults(resultsArg: readonly IHarnessQuestionPersonResult[]): TemplateResult {
|
|
1010
|
+
return html`
|
|
1011
|
+
<div class="credential personResults">
|
|
1012
|
+
${resultsArg.map((result) => html`
|
|
1013
|
+
<div class="credentialRow">
|
|
1014
|
+
<span class="credentialLabel">${result.label}</span>
|
|
1015
|
+
${this.renderPersonResultValue(result)}
|
|
1016
|
+
</div>
|
|
1017
|
+
`)}
|
|
1018
|
+
<p class="credentialNote">${this.t('question.credentialNote')}</p>
|
|
1019
|
+
</div>
|
|
1020
|
+
`;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
private renderPersonResultValue(resultArg: IHarnessQuestionPersonResult): TemplateResult {
|
|
1024
|
+
if (resultArg.display === 'link') {
|
|
1025
|
+
const href = httpHref(resultArg.value);
|
|
1026
|
+
return href
|
|
1027
|
+
? html`<a class="personResultLink" href=${href} target="_blank" rel="noopener noreferrer" referrerpolicy="no-referrer">${resultArg.value}</a>`
|
|
1028
|
+
: html`<span class="personResultText">${resultArg.value}</span>`;
|
|
1029
|
+
}
|
|
1030
|
+
if (resultArg.display !== 'secret') return html`<span class="personResultText">${resultArg.value}</span>`;
|
|
1031
|
+
const shown = this.personResultsShown.has(resultArg.id);
|
|
1032
|
+
const feedback = this.copyFeedback?.key === `result:${resultArg.id}` ? this.copyFeedback : undefined;
|
|
1033
|
+
return html`
|
|
1034
|
+
<code class="credentialValue">${shown
|
|
1035
|
+
? resultArg.value
|
|
1036
|
+
: html`<span aria-hidden="true">${CREDENTIAL_MASK}</span><span class="srOnly">${this.t('question.credentialHidden')}</span>`}</code>
|
|
1037
|
+
<button
|
|
1038
|
+
class="credentialAction"
|
|
1039
|
+
type="button"
|
|
1040
|
+
aria-label=${this.t(shown ? 'question.credentialHide' : 'question.credentialShow', { label: resultArg.label })}
|
|
1041
|
+
@click=${() => this.togglePersonResult(resultArg.id)}
|
|
1042
|
+
>${this.t(shown ? 'question.credentialHideShort' : 'question.credentialShowShort')}</button>
|
|
1043
|
+
<button
|
|
1044
|
+
class="credentialAction"
|
|
1045
|
+
type="button"
|
|
1046
|
+
aria-label=${this.t('question.credentialCopy', { label: resultArg.label })}
|
|
1047
|
+
@click=${() => this.copySecret(`result:${resultArg.id}`, resultArg.label, resultArg.value)}
|
|
1048
|
+
>${this.t('common.copy')}</button>
|
|
1049
|
+
<span class="credentialFeedback ${feedback?.failed ? 'failed' : ''}" role="status" aria-live="polite">${feedback?.text ?? ''}</span>
|
|
1050
|
+
`;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
689
1053
|
/** 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
1054
|
private get proposalActions(): IActionFooterAction[] {
|
|
691
1055
|
const confirm = this.request.confirmLabel ?? this.t('question.proposalConfirm');
|
|
692
1056
|
const decline = this.request.declineLabel ?? this.t('question.proposalDecline');
|
|
693
|
-
// a proposal whose every change is left out has nothing to confirm
|
|
1057
|
+
// a proposal whose every change is left out has nothing to confirm, and one short of a value cannot be confirmed yet
|
|
694
1058
|
const nothingIncluded = this.itemsDeclinable && this.effectiveLeftOut.size === (this.request.items?.length ?? 0);
|
|
1059
|
+
const held = !this.personFieldsComplete;
|
|
695
1060
|
if (
|
|
696
1061
|
this.footerActions?.confirm !== confirm
|
|
697
1062
|
|| this.footerActions.decline !== decline
|
|
698
1063
|
|| this.footerActions.nothingIncluded !== nothingIncluded
|
|
1064
|
+
|| this.footerActions.held !== held
|
|
699
1065
|
) {
|
|
700
1066
|
this.footerActions = {
|
|
701
1067
|
confirm,
|
|
702
1068
|
decline,
|
|
703
1069
|
nothingIncluded,
|
|
1070
|
+
held,
|
|
704
1071
|
actions: [
|
|
705
1072
|
{ name: decline, action: async () => this.respond(['decline']) },
|
|
706
|
-
{ name: confirm, primary: true, disabled: nothingIncluded, action: async () => this.respond(['confirm']) },
|
|
1073
|
+
{ name: confirm, primary: true, disabled: nothingIncluded || held, action: async () => this.respond(['confirm']) },
|
|
707
1074
|
],
|
|
708
1075
|
};
|
|
709
1076
|
}
|
|
710
1077
|
return this.footerActions.actions;
|
|
711
1078
|
}
|
|
712
1079
|
|
|
713
|
-
private footerActions: {
|
|
1080
|
+
private footerActions: {
|
|
1081
|
+
confirm: string;
|
|
1082
|
+
decline: string;
|
|
1083
|
+
nothingIncluded: boolean;
|
|
1084
|
+
held: boolean;
|
|
1085
|
+
actions: IActionFooterAction[];
|
|
1086
|
+
} | undefined;
|
|
714
1087
|
|
|
715
1088
|
/** The reader includes a change in the proposal, or leaves it out. */
|
|
716
1089
|
private setIncluded(itemIdArg: string, includedArg: boolean): void {
|
|
@@ -729,18 +1102,72 @@ export class DeesHarnessQuestionCard extends DeesElement {
|
|
|
729
1102
|
this.credentialsShown = next;
|
|
730
1103
|
}
|
|
731
1104
|
|
|
732
|
-
private
|
|
733
|
-
const
|
|
1105
|
+
private togglePersonField(keyArg: string): void {
|
|
1106
|
+
const next = new Set(this.personFieldsShown);
|
|
1107
|
+
if (next.has(keyArg)) next.delete(keyArg);
|
|
1108
|
+
else next.add(keyArg);
|
|
1109
|
+
this.personFieldsShown = next;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
private togglePersonResult(resultIdArg: string): void {
|
|
1113
|
+
const next = new Set(this.personResultsShown);
|
|
1114
|
+
if (next.has(resultIdArg)) next.delete(resultIdArg);
|
|
1115
|
+
else next.add(resultIdArg);
|
|
1116
|
+
this.personResultsShown = next;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
/** The person enters a value; one the host refused is answered by the edit. */
|
|
1120
|
+
private setPersonValue(fieldArg: IHarnessQuestionPersonField, valueArg: string): void {
|
|
1121
|
+
if (this.locked) return;
|
|
1122
|
+
const next = new Map(this.personValues);
|
|
1123
|
+
if (valueArg) next.set(personKey(fieldArg.itemId, fieldArg.id), valueArg);
|
|
1124
|
+
else next.delete(personKey(fieldArg.itemId, fieldArg.id));
|
|
1125
|
+
this.personValues = next;
|
|
1126
|
+
const refused = (entryArg: { itemId: string; fieldId: string }) => entryArg.itemId === fieldArg.itemId && entryArg.fieldId === fieldArg.id;
|
|
1127
|
+
const rejection = this.effectiveRejection;
|
|
1128
|
+
if (rejection?.fieldErrors?.some(refused)) {
|
|
1129
|
+
this.setRejection({ ...rejection, fieldErrors: rejection.fieldErrors.filter((entry) => !refused(entry)) });
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/** The host's refusal the card shows: its own, or the one the view state kept over a remount. */
|
|
1134
|
+
private get effectiveRejection(): IHarnessQuestionRejection | undefined {
|
|
1135
|
+
return this.rejection ?? this.viewState?.rejection;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
private setRejection(rejectionArg: IHarnessQuestionRejection | undefined): void {
|
|
1139
|
+
this.rejection = rejectionArg;
|
|
1140
|
+
if (!this.viewState) return;
|
|
1141
|
+
if (rejectionArg) this.viewState.rejection = rejectionArg;
|
|
1142
|
+
else delete this.viewState.rejection;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
/** Forgets what the person entered and showed, and the host's refusal of it. */
|
|
1146
|
+
private clearPersonEntries(): void {
|
|
1147
|
+
this.personValues = new Map<string, string>();
|
|
1148
|
+
this.personFieldsShown = new Set<string>();
|
|
1149
|
+
this.rejection = undefined;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/** Forgets everything person-only: what was entered, and what the changes returned. */
|
|
1153
|
+
private clearPersonState(): void {
|
|
1154
|
+
this.clearPersonEntries();
|
|
1155
|
+
this.personResults = NO_PERSON_RESULTS;
|
|
1156
|
+
this.personResultsShown = new Set<string>();
|
|
1157
|
+
if (this.copyFeedback?.key.startsWith('result:')) this.copyFeedback = undefined;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
private async copySecret(keyArg: string, labelArg: string, valueArg: string): Promise<void> {
|
|
734
1161
|
const request = ++this.copyRequest;
|
|
735
1162
|
clearTimeout(this.copyResetTimeout);
|
|
736
1163
|
this.copyFeedback = undefined;
|
|
737
1164
|
try {
|
|
738
|
-
await navigator.clipboard.writeText(
|
|
1165
|
+
await navigator.clipboard.writeText(valueArg);
|
|
739
1166
|
if (!this.isConnected || request !== this.copyRequest) return;
|
|
740
|
-
this.copyFeedback = {
|
|
1167
|
+
this.copyFeedback = { key: keyArg, text: this.t('question.credentialCopied', { label: labelArg }), failed: false };
|
|
741
1168
|
} catch {
|
|
742
1169
|
if (!this.isConnected || request !== this.copyRequest) return;
|
|
743
|
-
this.copyFeedback = {
|
|
1170
|
+
this.copyFeedback = { key: keyArg, text: this.t('question.credentialCopyFailed'), failed: true };
|
|
744
1171
|
}
|
|
745
1172
|
this.copyResetTimeout = setTimeout(() => {
|
|
746
1173
|
this.copyFeedback = undefined;
|
|
@@ -780,12 +1207,20 @@ export class DeesHarnessQuestionCard extends DeesElement {
|
|
|
780
1207
|
private respond(answers: string[]): void {
|
|
781
1208
|
if (this.locked || !answers.length) return;
|
|
782
1209
|
const items = this.request.items ?? [];
|
|
783
|
-
const
|
|
1210
|
+
const confirming = answers[0] === 'confirm';
|
|
1211
|
+
const leftOut = confirming && this.itemsDeclinable ? this.effectiveLeftOut : new Set<string>();
|
|
784
1212
|
if (leftOut.size > 0 && leftOut.size === items.length) return;
|
|
1213
|
+
if (confirming && !this.personFieldsComplete) return;
|
|
1214
|
+
const personValues: IHarnessQuestionPersonValue[] = confirming
|
|
1215
|
+
? this.includedPersonFields
|
|
1216
|
+
.map((field) => ({ itemId: field.itemId, fieldId: field.id, value: this.personValueOf(field) }))
|
|
1217
|
+
.filter((entry) => entry.value !== '')
|
|
1218
|
+
: [];
|
|
785
1219
|
// the footer leaves with the answer: its focus moves to the decision that takes its place
|
|
786
1220
|
const footerFocused = this.shadowRoot?.activeElement?.localName === 'dees-actionfooter';
|
|
787
1221
|
this.answered = answers;
|
|
788
1222
|
if (this.viewState) this.viewState.answered = answers;
|
|
1223
|
+
this.setRejection(undefined);
|
|
789
1224
|
if (footerFocused) {
|
|
790
1225
|
void this.updateComplete.then(() => this.shadowRoot?.querySelector<HTMLElement>('.decision')?.focus());
|
|
791
1226
|
}
|
|
@@ -795,11 +1230,42 @@ export class DeesHarnessQuestionCard extends DeesElement {
|
|
|
795
1230
|
request: harnessWithoutCredentials(this.request),
|
|
796
1231
|
};
|
|
797
1232
|
if (leftOut.size > 0) detail.declinedItemIds = items.filter((item) => leftOut.has(item.id)).map((item) => item.id);
|
|
1233
|
+
if (personValues.length) detail.personValues = personValues;
|
|
798
1234
|
this.dispatchEvent(new CustomEvent<IHarnessQuestionResponseDetail>('harness-question-response', {
|
|
799
1235
|
detail,
|
|
800
1236
|
bubbles: true,
|
|
801
1237
|
composed: true,
|
|
802
1238
|
}));
|
|
1239
|
+
// what the person entered leaves with this answer alone: nothing keeps it for another
|
|
1240
|
+
this.clearPersonEntries();
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* The host refused the answer it was sent, such as a confirmation its server turned down: the
|
|
1245
|
+
* card waits for an answer again, keeps the changes the reader left out, and shows the host's
|
|
1246
|
+
* `message` and the error of each value it names. What the person entered went with the answer
|
|
1247
|
+
* and is entered anew. The refusal stands until the next answer, in the view state as well, so a
|
|
1248
|
+
* card the transcript remounts still shows it. A question that is not a proposal, a card whose
|
|
1249
|
+
* request carries the host's `response`, and one the host decided otherwise stay as they are: `false`.
|
|
1250
|
+
*/
|
|
1251
|
+
public rejectResponse(rejectionArg: IHarnessQuestionRejection = {}): boolean {
|
|
1252
|
+
if (this.request.kind !== 'proposal' || this.request.response !== undefined) return false;
|
|
1253
|
+
if (harnessProposalState(this.request, undefined) !== 'pending') return false;
|
|
1254
|
+
this.answered = undefined;
|
|
1255
|
+
if (this.viewState) this.viewState.answered = undefined;
|
|
1256
|
+
this.setRejection(rejectionArg);
|
|
1257
|
+
return true;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
public willUpdate(changedProperties: Map<PropertyKey, unknown>): void {
|
|
1261
|
+
super.willUpdate(changedProperties);
|
|
1262
|
+
const previous = changedProperties.get('request') as IHarnessQuestionRequest | undefined;
|
|
1263
|
+
// another request: nothing entered for the last one, refused of it or returned by it carries over
|
|
1264
|
+
if (previous && previous.id !== this.request.id) {
|
|
1265
|
+
this.clearPersonEntries();
|
|
1266
|
+
this.personResultsShown = new Set<string>();
|
|
1267
|
+
if (!changedProperties.has('personResults')) this.personResults = NO_PERSON_RESULTS;
|
|
1268
|
+
}
|
|
803
1269
|
}
|
|
804
1270
|
|
|
805
1271
|
public async disconnectedCallback(): Promise<void> {
|
|
@@ -808,6 +1274,10 @@ export class DeesHarnessQuestionCard extends DeesElement {
|
|
|
808
1274
|
this.copyResetTimeout = undefined;
|
|
809
1275
|
this.copyFeedback = undefined;
|
|
810
1276
|
this.credentialsShown = new Set<string>();
|
|
1277
|
+
// a card a keyed list moves is connected again before this runs, and keeps what it shows
|
|
1278
|
+
queueMicrotask(() => {
|
|
1279
|
+
if (!this.isConnected) this.clearPersonState();
|
|
1280
|
+
});
|
|
811
1281
|
await super.disconnectedCallback();
|
|
812
1282
|
}
|
|
813
1283
|
}
|