@design.estate/dees-catalog 24.3.0 → 24.5.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 +161 -259
- package/dist_bundle/bundle.js.map +1 -1
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-7CM7S6EQ.js → chunk-LRGVCS7F.js} +2 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-R6EBIDCM.js → chunk-PKH6IGY6.js} +347 -4
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-R6EBIDCM.js.map → chunk-PKH6IGY6.js.map} +1 -1
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-Z3DSEMNI.js → dees-modal-ORXOZADW.js} +2 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-KPB3RVGL.js → dees-workspace-terminal-MUU2HDU3.js} +3 -3
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/dist_ts_web/elements/00group-appui/dees-appui/dees-appui.d.ts +42 -23
- package/dist_ts_web/elements/00group-appui/dees-appui/dees-appui.demo.js +2 -3
- package/dist_ts_web/elements/00group-appui/dees-appui/dees-appui.js +93 -81
- package/dist_ts_web/elements/00group-appui/dees-appui/shell.storage.d.ts +11 -4
- package/dist_ts_web/elements/00group-appui/dees-appui/shell.storage.js +32 -9
- package/dist_ts_web/elements/00group-input/dees-input-multitoggle/dees-input-multitoggle.d.ts +8 -1
- package/dist_ts_web/elements/00group-input/dees-input-multitoggle/dees-input-multitoggle.demo.js +7 -1
- package/dist_ts_web/elements/00group-input/dees-input-multitoggle/dees-input-multitoggle.js +18 -5
- package/dist_ts_web/elements/00group-input/dees-input-tags/dees-input-tags.d.ts +4 -13
- package/dist_ts_web/elements/00group-input/dees-input-tags/dees-input-tags.js +29 -174
- package/dist_ts_web/elements/00group-input/dees-input-text/dees-input-text.d.ts +41 -0
- package/dist_ts_web/elements/00group-input/dees-input-text/dees-input-text.demo.js +16 -1
- package/dist_ts_web/elements/00group-input/dees-input-text/dees-input-text.js +103 -3
- package/dist_ts_web/elements/00group-input/suggestion-list.d.ts +102 -0
- package/dist_ts_web/elements/00group-input/suggestion-list.js +300 -0
- package/dist_ts_web/elements/interfaces/appconfig.d.ts +28 -10
- package/package.json +1 -1
- package/readme.md +36 -7
- package/scripts/token-baseline.json +1 -1
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/elements/00group-appui/dees-appui/dees-appui.demo.ts +1 -2
- package/ts_web/elements/00group-appui/dees-appui/dees-appui.ts +102 -89
- package/ts_web/elements/00group-appui/dees-appui/readme.md +42 -26
- package/ts_web/elements/00group-appui/dees-appui/shell.storage.ts +42 -11
- package/ts_web/elements/00group-input/dees-input-multitoggle/dees-input-multitoggle.demo.ts +6 -0
- package/ts_web/elements/00group-input/dees-input-multitoggle/dees-input-multitoggle.ts +24 -7
- package/ts_web/elements/00group-input/dees-input-tags/dees-input-tags.ts +27 -171
- package/ts_web/elements/00group-input/dees-input-text/dees-input-text.demo.ts +17 -0
- package/ts_web/elements/00group-input/dees-input-text/dees-input-text.ts +106 -1
- package/ts_web/elements/00group-input/suggestion-list.ts +323 -0
- package/ts_web/elements/interfaces/appconfig.ts +29 -10
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-7CM7S6EQ.js.map → chunk-LRGVCS7F.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-Z3DSEMNI.js.map → dees-modal-ORXOZADW.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-KPB3RVGL.js.map → dees-workspace-terminal-MUU2HDU3.js.map} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DeesInputBase } from '../dees-input-base/dees-input-base.js';
|
|
2
2
|
import { textInputContextMenuItems } from '../text-input-contextmenu.js';
|
|
3
|
+
import { inputSuggestion, SuggestionListController, suggestionListStyles, type TInputSuggestion } from '../suggestion-list.js';
|
|
3
4
|
import { demoFunc } from './dees-input-text.demo.js';
|
|
4
5
|
|
|
5
6
|
import {
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
css,
|
|
13
14
|
} from '@design.estate/dees-element';
|
|
14
15
|
import { insetInlineStyles, themeDefaultStyles } from '../../00theme.js';
|
|
16
|
+
import { overlayScrollbarStyles } from '../../00scrollbars.js';
|
|
15
17
|
import '../../00group-overlay/dees-contextmenu/dees-contextmenu.js';
|
|
16
18
|
import { dcLocalize } from '../../../i18n/localize.js';
|
|
17
19
|
|
|
@@ -21,6 +23,14 @@ declare global {
|
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
export type { IInputSuggestion, TInputSuggestion } from '../suggestion-list.js';
|
|
27
|
+
|
|
28
|
+
/** The detail of `suggestion-select`: the value the pick set, and the suggestion as the host gave it. */
|
|
29
|
+
export interface IInputTextSuggestionSelectDetail {
|
|
30
|
+
value: string;
|
|
31
|
+
suggestion: TInputSuggestion;
|
|
32
|
+
}
|
|
33
|
+
|
|
24
34
|
/** Native input types this field maps to. Anything richer has its own element. */
|
|
25
35
|
export type TTextInputType = 'text' | 'number' | 'date' | 'email' | 'url' | 'tel' | 'password';
|
|
26
36
|
|
|
@@ -135,6 +145,34 @@ export class DeesInputText extends DeesInputBase {
|
|
|
135
145
|
@property({ type: Number, reflect: true })
|
|
136
146
|
accessor maxLength = -1;
|
|
137
147
|
|
|
148
|
+
/**
|
|
149
|
+
* Values to offer in a list under the field while it has the focus, as a WAI-ARIA combobox: the
|
|
150
|
+
* arrow keys move through them, Enter or a press picks one, Escape closes the list and Tab leaves
|
|
151
|
+
* the field without a pick. A suggestion is the value itself or `{ value, label?, description? }`.
|
|
152
|
+
* The field shows the list as the host gives it and filters nothing: a host that completes the
|
|
153
|
+
* typed text (a path on a server, say) answers `input` with the list for it. A pick sets the
|
|
154
|
+
* value, reports `input` and `change` as typing and leaving the field would, and fires
|
|
155
|
+
* `suggestion-select` with `{ value, suggestion }`.
|
|
156
|
+
*
|
|
157
|
+
* `null`, the default, makes no combobox: the field is a plain text field. An array, even an
|
|
158
|
+
* empty one, makes the field a combobox whose list shows while the array has entries.
|
|
159
|
+
*/
|
|
160
|
+
@property({ attribute: false })
|
|
161
|
+
accessor suggestions: TInputSuggestion[] | null = null;
|
|
162
|
+
|
|
163
|
+
/** The suggestions under the field. */
|
|
164
|
+
private readonly suggestionList = new SuggestionListController(this, {
|
|
165
|
+
anchor: () => this.shadowRoot?.querySelector<HTMLElement>('input'),
|
|
166
|
+
pick: (index) => this.pickSuggestion(index),
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The text a pick committed, until the reader edits again. The browser keeps its own `change`
|
|
171
|
+
* baseline, which a value set by script does not move: after typing and a pick it fires `change`
|
|
172
|
+
* again on leaving the field, for the commit the pick already reported.
|
|
173
|
+
*/
|
|
174
|
+
private pickedText: string | null = null;
|
|
175
|
+
|
|
138
176
|
private validTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
139
177
|
|
|
140
178
|
public static styles = [
|
|
@@ -142,6 +180,8 @@ export class DeesInputText extends DeesInputBase {
|
|
|
142
180
|
...DeesInputBase.baseStyles,
|
|
143
181
|
cssManager.defaultStyles,
|
|
144
182
|
insetInlineStyles('--text-inset-inline'),
|
|
183
|
+
overlayScrollbarStyles,
|
|
184
|
+
suggestionListStyles,
|
|
145
185
|
css`
|
|
146
186
|
/* TODO: Migrate hardcoded values to --dees-* CSS variables */
|
|
147
187
|
* {
|
|
@@ -373,7 +413,10 @@ export class DeesInputText extends DeesInputBase {
|
|
|
373
413
|
type="${this.nativeInputType}"
|
|
374
414
|
.value=${this.valueAsText}
|
|
375
415
|
@input="${this.updateValue}"
|
|
376
|
-
@change=${this.
|
|
416
|
+
@change=${this.handleNativeChange}
|
|
417
|
+
@keydown=${this.handleSuggestionKeydown}
|
|
418
|
+
@focus=${this.handleSuggestionFocus}
|
|
419
|
+
@blur=${this.handleSuggestionBlur}
|
|
377
420
|
.disabled=${this.disabled}
|
|
378
421
|
?required=${this.required}
|
|
379
422
|
aria-label=${this.label}
|
|
@@ -393,6 +436,7 @@ export class DeesInputText extends DeesInputBase {
|
|
|
393
436
|
<div class="validIcon ${this.validConfirmed ? 'show' : ''}">
|
|
394
437
|
<dees-icon .icon=${'lucide:Check'}></dees-icon>
|
|
395
438
|
</div>
|
|
439
|
+
${this.suggestions ? this.suggestionList.render(this.suggestions.map(inputSuggestion), this.label) : ''}
|
|
396
440
|
</div>
|
|
397
441
|
${this.validationText || this.description ? html`<div class="field-messages">
|
|
398
442
|
${this.validationText
|
|
@@ -436,6 +480,8 @@ export class DeesInputText extends DeesInputBase {
|
|
|
436
480
|
|
|
437
481
|
public willUpdate(changedProperties: Map<PropertyKey, unknown>): void {
|
|
438
482
|
super.willUpdate(changedProperties);
|
|
483
|
+
// A new list highlights nothing: the option at the old index is another suggestion now.
|
|
484
|
+
if (changedProperties.has('suggestions')) this.suggestionList.highlight(-1);
|
|
439
485
|
if (!changedProperties.has('value') && !changedProperties.has('type')) return;
|
|
440
486
|
const normalized = this.normalizeValue(this.value);
|
|
441
487
|
if (normalized !== this.value) this.value = normalized;
|
|
@@ -466,6 +512,7 @@ export class DeesInputText extends DeesInputBase {
|
|
|
466
512
|
} else {
|
|
467
513
|
input.removeAttribute('maxlength');
|
|
468
514
|
}
|
|
515
|
+
this.suggestionList.applyComboboxAttributes(input, this.suggestions?.length ?? 0, this.suggestions !== null);
|
|
469
516
|
}
|
|
470
517
|
|
|
471
518
|
firstUpdated() {
|
|
@@ -486,6 +533,18 @@ export class DeesInputText extends DeesInputBase {
|
|
|
486
533
|
public async updateValue(eventArg: Event) {
|
|
487
534
|
const target = eventArg.target as HTMLInputElement;
|
|
488
535
|
this.value = this.normalizeValue(target.value);
|
|
536
|
+
this.pickedText = null;
|
|
537
|
+
if (this.suggestions) {
|
|
538
|
+
// Typing opens a list Escape or a pick closed, and highlights nothing in it.
|
|
539
|
+
this.suggestionList.show();
|
|
540
|
+
this.suggestionList.highlight(-1);
|
|
541
|
+
}
|
|
542
|
+
this.runValidationFunction();
|
|
543
|
+
this.changeSubject.next(this);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/** Runs `validationFunction` on the value, as each edit of the reader does. */
|
|
547
|
+
private runValidationFunction(): void {
|
|
489
548
|
if (this.validationFunction) {
|
|
490
549
|
const result = this.validationFunction(this.valueAsText);
|
|
491
550
|
this.validationState = result.valid ? 'valid' : 'invalid';
|
|
@@ -502,7 +561,53 @@ export class DeesInputText extends DeesInputBase {
|
|
|
502
561
|
this.validConfirmed = false;
|
|
503
562
|
}
|
|
504
563
|
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** Reports the native field's `change`, unless it repeats the commit of a pick. */
|
|
567
|
+
private handleNativeChange = (eventArg: Event): void => {
|
|
568
|
+
const repeatsPick = this.pickedText !== null && this.pickedText === this.valueAsText;
|
|
569
|
+
this.pickedText = null;
|
|
570
|
+
if (repeatsPick) {
|
|
571
|
+
eventArg.stopPropagation();
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
this.forwardNativeChange(eventArg);
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
private handleSuggestionKeydown = (eventArg: KeyboardEvent): void => {
|
|
578
|
+
if (!this.suggestions || this.disabled) return;
|
|
579
|
+
// ArrowDown opens a list Escape or a pick closed, and moves to its first option.
|
|
580
|
+
if (eventArg.key === 'ArrowDown' && !eventArg.isComposing && this.suggestions.length) this.suggestionList.show();
|
|
581
|
+
this.suggestionList.handleKeydown(eventArg, this.suggestions.length);
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
private handleSuggestionFocus = (): void => {
|
|
585
|
+
if (this.suggestions) this.suggestionList.show();
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
private handleSuggestionBlur = (): void => {
|
|
589
|
+
this.suggestionList.hide();
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Sets the value of the suggestion at `indexArg`, as the reader's own edit: `validationFunction`
|
|
594
|
+
* runs, `input` and `change` report it, and `suggestion-select` names the suggestion. The list
|
|
595
|
+
* closes; typing or ArrowDown opens it again.
|
|
596
|
+
*/
|
|
597
|
+
private pickSuggestion(indexArg: number): void {
|
|
598
|
+
const suggestion = this.suggestions?.[indexArg];
|
|
599
|
+
if (suggestion === undefined || this.disabled) return;
|
|
600
|
+
const value = inputSuggestion(suggestion).value;
|
|
601
|
+
this.value = this.normalizeValue(value);
|
|
602
|
+
const input = this.shadowRoot?.querySelector('input');
|
|
603
|
+
if (input) input.value = this.valueAsText;
|
|
604
|
+
this.pickedText = this.valueAsText;
|
|
605
|
+
this.suggestionList.hide();
|
|
606
|
+
this.runValidationFunction();
|
|
505
607
|
this.changeSubject.next(this);
|
|
608
|
+
this.reportValueCommit();
|
|
609
|
+
const detail: IInputTextSuggestionSelectDetail = { value, suggestion };
|
|
610
|
+
this.dispatchEvent(new CustomEvent('suggestion-select', { detail, bubbles: true, composed: true }));
|
|
506
611
|
}
|
|
507
612
|
|
|
508
613
|
public getContextMenuItems() {
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { css, html, type CSSResult, type DeesElement, type TemplateResult } from '@design.estate/dees-element';
|
|
2
|
+
import { listenForScrollAround, placeAnchored, visibleRect } from '../00anchorplacement.js';
|
|
3
|
+
import type { TReactiveController } from '../00controller.js';
|
|
4
|
+
import { OverlayScrollbarController } from '../00scrollbars.js';
|
|
5
|
+
|
|
6
|
+
/** A suggestion with a label of its own, or a second line under it. `value` is what a pick sets. */
|
|
7
|
+
export interface IInputSuggestion {
|
|
8
|
+
value: string;
|
|
9
|
+
/** Shown instead of `value`. */
|
|
10
|
+
label?: string;
|
|
11
|
+
/** A second, quieter line under the label. */
|
|
12
|
+
description?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** A suggestion a host offers a field: the value itself, or the value with a label and a description. */
|
|
16
|
+
export type TInputSuggestion = string | IInputSuggestion;
|
|
17
|
+
|
|
18
|
+
/** A suggestion in its object form. */
|
|
19
|
+
export const inputSuggestion = (suggestionArg: TInputSuggestion): IInputSuggestion =>
|
|
20
|
+
typeof suggestionArg === 'string' ? { value: suggestionArg } : suggestionArg;
|
|
21
|
+
|
|
22
|
+
export interface ISuggestionListOptions {
|
|
23
|
+
/** The field the list stands under, as wide as it is. */
|
|
24
|
+
anchor: () => HTMLElement | null | undefined;
|
|
25
|
+
/** What a pick by pointer or Enter does, given the index of the picked suggestion. */
|
|
26
|
+
pick: (indexArg: number) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The suggestions an editable field offers in a list under it, as a WAI-ARIA combobox: the field
|
|
31
|
+
* keeps the focus, the arrow keys move the highlighted option, Enter or a press picks it, Escape
|
|
32
|
+
* closes the list. The host owns the suggestions and what a pick does; the controller owns whether
|
|
33
|
+
* the list is open, the highlighted option, the list's markup and its place.
|
|
34
|
+
*
|
|
35
|
+
* The open list stands in the top layer (`popover="manual"`), below the field or above it without
|
|
36
|
+
* room there, so no scroll container, clipping ancestor or dialog around the field cuts it off. It
|
|
37
|
+
* follows the field as it scrolls or grows and steps out of view while none of the field shows.
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* public static styles = [themeDefaultStyles, overlayScrollbarStyles, suggestionListStyles, css`…`];
|
|
41
|
+
* private readonly suggestionList = new SuggestionListController(this, {
|
|
42
|
+
* anchor: () => this.shadowRoot?.querySelector('input'),
|
|
43
|
+
* pick: (index) => this.choose(this.suggestions[index]),
|
|
44
|
+
* });
|
|
45
|
+
* public render() {
|
|
46
|
+
* return html`<input @keydown=${(e) => this.suggestionList.handleKeydown(e, this.suggestions.length)}>
|
|
47
|
+
* ${this.suggestionList.render(this.suggestions.map(inputSuggestion), this.label)}`;
|
|
48
|
+
* }
|
|
49
|
+
* public updated() {
|
|
50
|
+
* this.suggestionList.applyComboboxAttributes(this.shadowRoot!.querySelector('input')!, this.suggestions.length);
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export class SuggestionListController implements TReactiveController {
|
|
55
|
+
/** The id of the list in the host's shadow root, for the field's `aria-controls`. */
|
|
56
|
+
public static readonly listboxId = 'suggestion-listbox';
|
|
57
|
+
|
|
58
|
+
/** Whether the list shows while there are suggestions. */
|
|
59
|
+
public expanded = false;
|
|
60
|
+
|
|
61
|
+
/** The highlighted option, -1 for none. */
|
|
62
|
+
public highlightedIndex = -1;
|
|
63
|
+
|
|
64
|
+
/** The name the last render gave the list; empty for none. */
|
|
65
|
+
private listLabel = '';
|
|
66
|
+
|
|
67
|
+
/** Ends the listeners that keep the open list beside the field. */
|
|
68
|
+
private tracking?: AbortController;
|
|
69
|
+
|
|
70
|
+
/** The list's scrollbar, shown while it scrolls. */
|
|
71
|
+
private readonly scrollbars: OverlayScrollbarController;
|
|
72
|
+
|
|
73
|
+
constructor(
|
|
74
|
+
private readonly host: DeesElement,
|
|
75
|
+
private readonly options: ISuggestionListOptions,
|
|
76
|
+
) {
|
|
77
|
+
host.addController(this);
|
|
78
|
+
this.scrollbars = new OverlayScrollbarController(host, () => this.popup()?.querySelector<HTMLElement>('.suggestions-list'));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The id of the option at `indexArg`, for the field's `aria-activedescendant`. */
|
|
82
|
+
public static optionId(indexArg: number): string {
|
|
83
|
+
return `suggestion-option-${indexArg}`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Whether the list shows `countArg` suggestions now. */
|
|
87
|
+
public isOpen(countArg: number): boolean {
|
|
88
|
+
return this.expanded && countArg > 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Opens the list; it shows while there are suggestions. */
|
|
92
|
+
public show(): void {
|
|
93
|
+
if (this.expanded) return;
|
|
94
|
+
this.expanded = true;
|
|
95
|
+
this.host.requestUpdate();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Closes the list and lets go of the highlighted option. */
|
|
99
|
+
public hide(): void {
|
|
100
|
+
if (!this.expanded && this.highlightedIndex === -1) return;
|
|
101
|
+
this.expanded = false;
|
|
102
|
+
this.highlightedIndex = -1;
|
|
103
|
+
this.host.requestUpdate();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Highlights the option at `indexArg`, -1 for none. */
|
|
107
|
+
public highlight(indexArg: number): void {
|
|
108
|
+
if (indexArg === this.highlightedIndex) return;
|
|
109
|
+
this.highlightedIndex = indexArg;
|
|
110
|
+
this.host.requestUpdate();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Answers the list's keys in the field while the list shows: ArrowDown and ArrowUp move the
|
|
115
|
+
* highlighted option, Enter picks the highlighted one, Escape closes the list. Returns whether it
|
|
116
|
+
* answered the key; a key it answers in a showing list is prevented, so a form does not take Enter
|
|
117
|
+
* and a dialog does not take Escape. A list with no suggestions shows nothing and answers none of
|
|
118
|
+
* them: the arrows move the caret and Enter is the host's or the form's. Tab is the host's: it
|
|
119
|
+
* leaves the field without a pick.
|
|
120
|
+
*/
|
|
121
|
+
public handleKeydown(eventArg: KeyboardEvent, countArg: number): boolean {
|
|
122
|
+
if (eventArg.isComposing) return false;
|
|
123
|
+
const open = this.isOpen(countArg);
|
|
124
|
+
switch (eventArg.key) {
|
|
125
|
+
case 'ArrowDown':
|
|
126
|
+
if (!open) return false;
|
|
127
|
+
eventArg.preventDefault();
|
|
128
|
+
this.highlight(Math.min(this.highlightedIndex + 1, countArg - 1));
|
|
129
|
+
return true;
|
|
130
|
+
case 'ArrowUp':
|
|
131
|
+
if (!open) return false;
|
|
132
|
+
eventArg.preventDefault();
|
|
133
|
+
this.highlight(Math.min(Math.max(this.highlightedIndex - 1, 0), countArg - 1));
|
|
134
|
+
return true;
|
|
135
|
+
case 'Enter':
|
|
136
|
+
if (!open || this.highlightedIndex < 0 || this.highlightedIndex >= countArg) return false;
|
|
137
|
+
eventArg.preventDefault();
|
|
138
|
+
this.options.pick(this.highlightedIndex);
|
|
139
|
+
return true;
|
|
140
|
+
case 'Escape': {
|
|
141
|
+
if (!this.expanded) return false;
|
|
142
|
+
if (open) eventArg.preventDefault();
|
|
143
|
+
this.hide();
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
default:
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Writes the combobox state onto the field: `role="combobox"`, `aria-autocomplete="list"`,
|
|
153
|
+
* `aria-expanded`, and while the list shows `aria-controls` and the highlighted option's
|
|
154
|
+
* `aria-activedescendant`. With `activeArg` false it removes all of them, for a field that offers
|
|
155
|
+
* no suggestions and is a plain text field.
|
|
156
|
+
*/
|
|
157
|
+
public applyComboboxAttributes(fieldArg: HTMLElement, countArg: number, activeArg = true): void {
|
|
158
|
+
const open = this.isOpen(countArg);
|
|
159
|
+
const highlighted = open && this.highlightedIndex >= 0 && this.highlightedIndex < countArg;
|
|
160
|
+
const attributes: Record<string, string | null> = {
|
|
161
|
+
role: activeArg ? 'combobox' : null,
|
|
162
|
+
'aria-autocomplete': activeArg ? 'list' : null,
|
|
163
|
+
'aria-expanded': activeArg ? String(open) : null,
|
|
164
|
+
'aria-controls': activeArg && open ? SuggestionListController.listboxId : null,
|
|
165
|
+
'aria-activedescendant': activeArg && highlighted ? SuggestionListController.optionId(this.highlightedIndex) : null,
|
|
166
|
+
};
|
|
167
|
+
for (const [name, value] of Object.entries(attributes)) {
|
|
168
|
+
if (value === null) fieldArg.removeAttribute(name);
|
|
169
|
+
else if (fieldArg.getAttribute(name) !== value) fieldArg.setAttribute(name, value);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The open list, or nothing while it is closed or has no suggestions. `labelArg` names it; an
|
|
175
|
+
* empty one leaves it without an `aria-label`.
|
|
176
|
+
*/
|
|
177
|
+
public render(itemsArg: IInputSuggestion[], labelArg = ''): TemplateResult | string {
|
|
178
|
+
this.listLabel = labelArg;
|
|
179
|
+
if (!this.isOpen(itemsArg.length)) return '';
|
|
180
|
+
return html`
|
|
181
|
+
<div class="suggestions-dropdown" popover="manual"><div
|
|
182
|
+
class="suggestions-list"
|
|
183
|
+
id=${SuggestionListController.listboxId}
|
|
184
|
+
role="listbox"
|
|
185
|
+
>
|
|
186
|
+
${itemsArg.map((item, index) => html`
|
|
187
|
+
<div
|
|
188
|
+
class="suggestion ${index === this.highlightedIndex ? 'highlighted' : ''}"
|
|
189
|
+
id=${SuggestionListController.optionId(index)}
|
|
190
|
+
role="option"
|
|
191
|
+
aria-selected=${index === this.highlightedIndex ? 'true' : 'false'}
|
|
192
|
+
@mousedown=${(event: Event) => {
|
|
193
|
+
event.preventDefault(); // the field keeps the focus
|
|
194
|
+
this.options.pick(index);
|
|
195
|
+
}}
|
|
196
|
+
@mouseenter=${() => this.highlight(index)}
|
|
197
|
+
>
|
|
198
|
+
${item.label ?? item.value}
|
|
199
|
+
${item.description ? html`<div class="suggestion-description">${item.description}</div>` : ''}
|
|
200
|
+
</div>
|
|
201
|
+
`)}
|
|
202
|
+
</div></div>
|
|
203
|
+
`;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** The open list follows the field from the render that shows it until the render that removes it. */
|
|
207
|
+
public hostUpdated(): void {
|
|
208
|
+
const popup = this.popup();
|
|
209
|
+
if (!popup) {
|
|
210
|
+
this.stopTracking();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
// Applied here, not bound, so a list without a name carries no empty `aria-label`.
|
|
214
|
+
const listbox = popup.querySelector<HTMLElement>('[role="listbox"]')!;
|
|
215
|
+
if (this.listLabel) listbox.setAttribute('aria-label', this.listLabel);
|
|
216
|
+
else listbox.removeAttribute('aria-label');
|
|
217
|
+
const field = this.options.anchor();
|
|
218
|
+
if (!field) return;
|
|
219
|
+
if (!this.tracking) {
|
|
220
|
+
const tracking = new AbortController();
|
|
221
|
+
this.tracking = tracking;
|
|
222
|
+
listenForScrollAround(field, this.place, tracking.signal);
|
|
223
|
+
window.addEventListener('resize', this.place, { passive: true, signal: tracking.signal });
|
|
224
|
+
// A field can grow as the reader works in it (tags wrap onto another line).
|
|
225
|
+
const observer = new ResizeObserver(this.place);
|
|
226
|
+
observer.observe(field);
|
|
227
|
+
tracking.signal.addEventListener('abort', () => observer.disconnect());
|
|
228
|
+
}
|
|
229
|
+
this.place();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public hostDisconnected(): void {
|
|
233
|
+
this.stopTracking();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
private popup(): HTMLElement | null | undefined {
|
|
237
|
+
return this.host.shadowRoot?.querySelector<HTMLElement>('.suggestions-dropdown');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
private stopTracking(): void {
|
|
241
|
+
this.tracking?.abort();
|
|
242
|
+
this.tracking = undefined;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Places the open list below the field, or above it without room there, as wide as the field. */
|
|
246
|
+
private place = (): void => {
|
|
247
|
+
const popup = this.popup();
|
|
248
|
+
const field = this.options.anchor();
|
|
249
|
+
if (!popup || !field) return;
|
|
250
|
+
const shown = visibleRect(field);
|
|
251
|
+
if (!shown) {
|
|
252
|
+
if (popup.matches(':popover-open')) popup.hidePopover();
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (!popup.matches(':popover-open')) popup.showPopover();
|
|
256
|
+
const box = field.getBoundingClientRect();
|
|
257
|
+
popup.style.width = `${box.width}px`;
|
|
258
|
+
const placed = placeAnchored({
|
|
259
|
+
anchor: { left: box.left, right: box.right, top: shown.top, bottom: shown.bottom },
|
|
260
|
+
width: box.width,
|
|
261
|
+
height: popup.offsetHeight,
|
|
262
|
+
placement: 'bottom',
|
|
263
|
+
flip: true,
|
|
264
|
+
gap: 4,
|
|
265
|
+
});
|
|
266
|
+
popup.style.left = `${placed.left}px`;
|
|
267
|
+
popup.style.top = `${placed.top}px`;
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** The open list's look; a host adds `overlayScrollbarStyles` beside it. */
|
|
272
|
+
export const suggestionListStyles: CSSResult = css`
|
|
273
|
+
/* A popover in the top layer, placed by the controller. The list scrolls inside it, the frame
|
|
274
|
+
its scrollbar is placed in. */
|
|
275
|
+
.suggestions-dropdown {
|
|
276
|
+
position: fixed;
|
|
277
|
+
inset: auto;
|
|
278
|
+
margin: 0;
|
|
279
|
+
padding: 0;
|
|
280
|
+
color: inherit;
|
|
281
|
+
background: var(--dees-material-regular-bg-opaque);
|
|
282
|
+
border: var(--dees-line-width-hairline) solid var(--dees-color-border-default);
|
|
283
|
+
border-radius: var(--dees-radius-lg);
|
|
284
|
+
corner-shape: var(--dees-corner-shape);
|
|
285
|
+
box-shadow: var(--dees-shadow-lg);
|
|
286
|
+
overflow: hidden;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.suggestions-list {
|
|
290
|
+
max-height: calc(200px - 2 * var(--dees-line-width-hairline));
|
|
291
|
+
overflow-y: auto;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
295
|
+
.suggestions-dropdown {
|
|
296
|
+
-webkit-backdrop-filter: none;
|
|
297
|
+
backdrop-filter: none;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.suggestion {
|
|
302
|
+
padding: var(--dees-spacing-xs-plus) var(--dees-spacing-sm-plus);
|
|
303
|
+
cursor: pointer;
|
|
304
|
+
transition: background-color var(--dees-transition-fast) var(--dees-ease-standard);
|
|
305
|
+
font-size: 14px;
|
|
306
|
+
color: var(--dees-color-text-primary);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.suggestion:hover {
|
|
310
|
+
background: var(--dees-color-hover);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.suggestion.highlighted {
|
|
314
|
+
background: var(--dees-color-active);
|
|
315
|
+
color: var(--dees-color-text-primary);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.suggestion-description {
|
|
319
|
+
color: var(--dees-color-text-secondary);
|
|
320
|
+
font-size: var(--dees-font-footnote-size);
|
|
321
|
+
line-height: var(--dees-font-footnote-line);
|
|
322
|
+
}
|
|
323
|
+
`;
|
|
@@ -109,11 +109,13 @@ export interface IBottomBarAPI {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
* A pane a reader can resize: `secondary` is the section menu, `
|
|
113
|
-
*
|
|
114
|
-
*
|
|
112
|
+
* A pane a reader can resize: `secondary` is the section menu, `aside` the
|
|
113
|
+
* side panel, which has one width whichever tool it shows. `activity` and
|
|
114
|
+
* `assistant` are deprecated names of `aside`, from when each tool had a width
|
|
115
|
+
* of its own: they size and read the same one width. The main menu is not
|
|
116
|
+
* one: it is either a rail or expanded.
|
|
115
117
|
*/
|
|
116
|
-
export type TAppuiPane = 'secondary' | 'activity' | 'assistant';
|
|
118
|
+
export type TAppuiPane = 'secondary' | 'aside' | 'activity' | 'assistant';
|
|
117
119
|
|
|
118
120
|
/**
|
|
119
121
|
* A tool the side panel on the content's end edge shows, one at a time:
|
|
@@ -463,9 +465,10 @@ export interface IActivityLogConfig {
|
|
|
463
465
|
*/
|
|
464
466
|
toggle?: boolean;
|
|
465
467
|
/**
|
|
466
|
-
* The
|
|
467
|
-
*
|
|
468
|
-
*
|
|
468
|
+
* The side panel's first width in CSS pixels, as `IAppConfig.asideWidth`
|
|
469
|
+
* sets it, which wins, as does `IAppAssistantConfig.width`.
|
|
470
|
+
* @deprecated The side panel has one width whichever tool it shows: set
|
|
471
|
+
* `IAppConfig.asideWidth`.
|
|
469
472
|
*/
|
|
470
473
|
width?: number;
|
|
471
474
|
}
|
|
@@ -485,9 +488,10 @@ export interface IAppAssistantConfig {
|
|
|
485
488
|
/** The icon of the app bar button and the palette command (default: `lucide:Sparkles`). */
|
|
486
489
|
iconName?: string;
|
|
487
490
|
/**
|
|
488
|
-
* The
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
+
* The side panel's first width in CSS pixels, as `IAppConfig.asideWidth`
|
|
492
|
+
* sets it, which wins; this wins over `IActivityLogConfig.width`.
|
|
493
|
+
* @deprecated The side panel has one width whichever tool it shows: set
|
|
494
|
+
* `IAppConfig.asideWidth`.
|
|
491
495
|
*/
|
|
492
496
|
width?: number;
|
|
493
497
|
/**
|
|
@@ -609,6 +613,15 @@ export interface IAppConfig {
|
|
|
609
613
|
*/
|
|
610
614
|
aside?: TAppuiAside | null;
|
|
611
615
|
|
|
616
|
+
/**
|
|
617
|
+
* The side panel's width in CSS pixels, clamped to 320–640, the same
|
|
618
|
+
* whichever tool it shows: opening, switching and closing a tool never
|
|
619
|
+
* change it. Unset keeps the width the panel has: 400 at first. A width the
|
|
620
|
+
* reader left it at, read from `storage`, wins. Wins over the deprecated
|
|
621
|
+
* `assistant.width`, which wins over the deprecated `activityLog.width`.
|
|
622
|
+
*/
|
|
623
|
+
asideWidth?: number;
|
|
624
|
+
|
|
612
625
|
/** Bottom bar configuration */
|
|
613
626
|
bottomBar?: IBottomBarConfig;
|
|
614
627
|
|
|
@@ -671,6 +684,12 @@ export interface IViewChangeEvent {
|
|
|
671
684
|
* new width, in CSS pixels — at the end of a drag, or with a key.
|
|
672
685
|
*/
|
|
673
686
|
export interface IPaneResizeEvent {
|
|
687
|
+
/**
|
|
688
|
+
* `secondary`, or for the side panel the tool it showed, `activity` or
|
|
689
|
+
* `assistant`, as hosts written while each tool had a width of its own
|
|
690
|
+
* expect. Either is a deprecated name of `aside`: `width` is the panel's one
|
|
691
|
+
* width, whichever tool it shows.
|
|
692
|
+
*/
|
|
674
693
|
pane: TAppuiPane;
|
|
675
694
|
width: number;
|
|
676
695
|
}
|
/package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-7CM7S6EQ.js.map → chunk-LRGVCS7F.js.map}
RENAMED
|
File without changes
|
|
File without changes
|