@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
|
@@ -4,9 +4,11 @@ import type {
|
|
|
4
4
|
IAppShellStorageErrorEvent,
|
|
5
5
|
IAppTrayTab,
|
|
6
6
|
TAppuiAside,
|
|
7
|
-
TAppuiPane,
|
|
8
7
|
} from '../../interfaces/appconfig.js';
|
|
9
8
|
|
|
9
|
+
/** A pane that has a width of its own: the section menu, and the side panel whichever tool it shows. */
|
|
10
|
+
export type TShellPane = 'secondary' | 'aside';
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* What the shell keeps through a host's storage adapter, one key each, stored
|
|
12
14
|
* as `dees-appui.<key>` with a JSON value.
|
|
@@ -15,7 +17,10 @@ export interface IShellStoredState {
|
|
|
15
17
|
mainMenuCollapsed: boolean;
|
|
16
18
|
secondaryMenuCollapsed: boolean;
|
|
17
19
|
secondaryPaneWidth: number;
|
|
20
|
+
asidePaneWidth: number;
|
|
21
|
+
/** Read only: the activity log's width from before the side panel had one width. */
|
|
18
22
|
activityPaneWidth: number;
|
|
23
|
+
/** Read only: the assistant's width from before the side panel had one width. */
|
|
19
24
|
assistantPaneWidth: number;
|
|
20
25
|
aside: TAppuiAside | null;
|
|
21
26
|
lastView: IAppRoute;
|
|
@@ -24,8 +29,24 @@ export interface IShellStoredState {
|
|
|
24
29
|
|
|
25
30
|
export type TShellStoredKey = keyof IShellStoredState;
|
|
26
31
|
|
|
32
|
+
/** The keys whose values have the shape `V`. */
|
|
33
|
+
type TShellStoredKeyOf<V> = { [K in TShellStoredKey]: IShellStoredState[K] extends V ? K : never }[TShellStoredKey];
|
|
34
|
+
|
|
27
35
|
/** The key a pane's width is kept under. */
|
|
28
|
-
export const paneWidthKey = (pane:
|
|
36
|
+
export const paneWidthKey = (pane: TShellPane) => `${pane}PaneWidth` as const;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Keys a newer key took over from, asked together with it and taken in this
|
|
40
|
+
* order while the newer one holds nothing usable. The first that holds a value
|
|
41
|
+
* is applied and written under the newer key, so it is taken once: the shell
|
|
42
|
+
* writes only the newer key, which answers from then on. Asked in the same
|
|
43
|
+
* round as the newer key, they cost an adapter over a server no extra wait.
|
|
44
|
+
* The side panel's one width starts from the assistant's width a reader left,
|
|
45
|
+
* else the activity log's.
|
|
46
|
+
*/
|
|
47
|
+
const supersededKeys: { [K in TShellStoredKey]?: readonly TShellStoredKeyOf<IShellStoredState[K]>[] } = {
|
|
48
|
+
asidePaneWidth: ['assistantPaneWidth', 'activityPaneWidth'],
|
|
49
|
+
};
|
|
29
50
|
|
|
30
51
|
/** The key the adapter sees: the shell's keys live under one namespace. */
|
|
31
52
|
const storageKey = (key: TShellStoredKey): string => `dees-appui.${key}`;
|
|
@@ -63,6 +84,7 @@ const storedShapes: { [K in TShellStoredKey]: (value: unknown) => value is IShel
|
|
|
63
84
|
mainMenuCollapsed: isBoolean,
|
|
64
85
|
secondaryMenuCollapsed: isBoolean,
|
|
65
86
|
secondaryPaneWidth: isWidth,
|
|
87
|
+
asidePaneWidth: isWidth,
|
|
66
88
|
activityPaneWidth: isWidth,
|
|
67
89
|
assistantPaneWidth: isWidth,
|
|
68
90
|
aside: (value): value is TAppuiAside | null => value === null || value === 'activity' || value === 'assistant',
|
|
@@ -95,20 +117,29 @@ export class ShellStorage {
|
|
|
95
117
|
* Applies a key's stored value. An adapter that answers at once is applied
|
|
96
118
|
* at once, before the render the caller is part of, so nothing shows the
|
|
97
119
|
* value it replaces. A later answer is applied when it arrives, unless
|
|
98
|
-
* another storage took over or the key was written meanwhile.
|
|
99
|
-
* the
|
|
120
|
+
* another storage took over or the key was written meanwhile. The keys it
|
|
121
|
+
* superseded are asked with it; while the key holds nothing usable, the
|
|
122
|
+
* first of them that does is applied and written under the key. Resolves
|
|
123
|
+
* once the answer is applied or dropped.
|
|
100
124
|
*/
|
|
101
125
|
public restore<K extends TShellStoredKey>(key: K, apply: (value: IShellStoredState[K]) => void): Promise<void> {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
126
|
+
// A superseded key holds a value of its successor's shape, which its own guard checks.
|
|
127
|
+
const sources = [key, ...(supersededKeys[key] ?? [])] as K[];
|
|
128
|
+
const settle = (stored: (string | undefined)[]) => {
|
|
129
|
+
for (const [index, source] of sources.entries()) {
|
|
130
|
+
const value = this.decode(source, stored[index]);
|
|
131
|
+
if (value === undefined) continue;
|
|
132
|
+
apply(value);
|
|
133
|
+
if (source !== key) this.write(key, value);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
105
136
|
};
|
|
106
|
-
const
|
|
107
|
-
if (!(answer instanceof Promise)) {
|
|
108
|
-
settle(
|
|
137
|
+
const answers = sources.map((source) => this.readStored(source));
|
|
138
|
+
if (!answers.some((answer) => answer instanceof Promise)) {
|
|
139
|
+
settle(answers as (string | undefined)[]);
|
|
109
140
|
return Promise.resolve();
|
|
110
141
|
}
|
|
111
|
-
return
|
|
142
|
+
return Promise.all(answers).then((stored) => {
|
|
112
143
|
if (!this.retired && !this.written.has(key)) settle(stored);
|
|
113
144
|
});
|
|
114
145
|
}
|
|
@@ -18,6 +18,12 @@ export const demoFunc = () => demoPage('Segmented controls', 'Choose a view, a t
|
|
|
18
18
|
<dees-input-multitoggle label="Managed access" .options=${['Private', 'Team', 'Public']} selectedOption="Team" disabled></dees-input-multitoggle>
|
|
19
19
|
</div>${demoOutput('Change a setting to inspect its value.')}
|
|
20
20
|
`)}
|
|
21
|
+
${demoSection('Toned choices', 'A choice whose state matters takes a tone while it is selected. Unselected, it looks like any other.', html`
|
|
22
|
+
<dees-input-multitoggle label="Permission mode"
|
|
23
|
+
.options=${[{ key: 'ask', label: 'Ask first' }, { key: 'edits', label: 'Accept edits', tone: 'info' }, { key: 'bypass', label: 'Bypass', icon: 'lucide:ShieldOff', tone: 'warning', description: 'Every action runs without asking.' }]}
|
|
24
|
+
.selectedOption=${'bypass'} @change=${changed}></dees-input-multitoggle>
|
|
25
|
+
${demoOutput('bypass')}
|
|
26
|
+
`)}
|
|
21
27
|
${demoSection('Form values', 'The form collects the selected key and the boolean value.', html`
|
|
22
28
|
<dees-form @formData=${(event: CustomEvent) => showDemoResult(event.currentTarget as Element, event.detail)}>
|
|
23
29
|
<dees-input-multitoggle key="view" label="Default view" .options=${[{ key: 'list', label: 'List' }, { key: 'columns', label: 'Columns' }]} selectedOption="list"></dees-input-multitoggle>
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { customElement, type TemplateResult, html, property, css, cssManager } from '@design.estate/dees-element';
|
|
2
2
|
import { DeesInputBase } from '../dees-input-base/dees-input-base.js';
|
|
3
3
|
import { demoFunc } from './dees-input-multitoggle.demo.js';
|
|
4
|
-
import { themeDefaultStyles } from '../../00theme.js';
|
|
4
|
+
import { themeDefaultStyles, type TTone } from '../../00theme.js';
|
|
5
5
|
import '../../00group-utility/dees-icon/dees-icon.js';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* A keyed option's `description` is its tooltip: what choosing it means. Its `tone` colours the
|
|
9
|
+
* option while it is selected, its label and the selected segment, for a choice whose state
|
|
10
|
+
* matters (a permission mode that skips confirmations, say); unselected it looks like any other.
|
|
11
|
+
*/
|
|
12
|
+
export type TMultitoggleOption = string | { key: string; label: string; disabled?: boolean; icon?: string; badge?: string | number; description?: string; tone?: TTone };
|
|
9
13
|
|
|
10
14
|
declare global {
|
|
11
15
|
interface HTMLElementTagNameMap { 'dees-input-multitoggle': DeesInputMultitoggle; }
|
|
@@ -52,17 +56,27 @@ export class DeesInputMultitoggle extends DeesInputBase<DeesInputMultitoggle> {
|
|
|
52
56
|
|
|
53
57
|
public static styles = [themeDefaultStyles, ...DeesInputBase.baseStyles, cssManager.defaultStyles, css`
|
|
54
58
|
:host { display: block; min-width: 0; font-family: var(--dees-font-family); color: var(--dees-color-text-primary); }
|
|
55
|
-
|
|
59
|
+
/* The tone is the component's own: reset inside the shadow tree, so a value set on an ancestor
|
|
60
|
+
never reaches an untoned option, and set only on a toned option and the segment under it. */
|
|
61
|
+
.selections { --multitoggle-tone: initial; position: relative; display: inline-flex; flex-wrap: wrap; align-items: stretch; gap: var(--dees-spacing-2xs); max-width: 100%; padding: var(--dees-spacing-2xs); border-radius: var(--dees-radius-lg); background: var(--dees-color-fill-tertiary); user-select: none; }
|
|
56
62
|
.option { position: relative; display: grid; place-items: center; flex: 1 0 auto; min-width: 0; max-width: 100%; min-height: calc(var(--dees-input-height) - 4px); padding: var(--dees-spacing-2xs) var(--dees-spacing-md); border: 0; border-radius: calc(var(--dees-radius-lg) - 2px); background: transparent; color: var(--dees-color-text-secondary); font: 13px/1.4 var(--dees-font-family); text-align: center; overflow-wrap: anywhere; cursor: pointer; z-index: 1; transition: color var(--dees-transition-fast) var(--dees-ease-standard), background-color var(--dees-transition-fast) var(--dees-ease-standard); }
|
|
57
63
|
.option-content, .option::after { grid-area: 1 / 1; }
|
|
58
64
|
.option-content { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 0; }
|
|
59
65
|
.option-content dees-icon { flex-shrink: 0; }
|
|
60
66
|
.option-badge { padding: 0 5px; border-radius: var(--dees-radius-sm); background: var(--dees-color-fill-tertiary); color: var(--dees-color-text-secondary); font-size: 10px; line-height: 16px; }
|
|
61
67
|
.option::after { content: attr(data-option); visibility: hidden; font-weight: 600; pointer-events: none; }
|
|
62
|
-
.option.selected { color: var(--dees-color-text-primary); font-weight: 600; }
|
|
68
|
+
.option.selected { color: var(--multitoggle-tone, var(--dees-color-text-primary)); font-weight: 600; }
|
|
63
69
|
.option:focus-visible { outline: var(--dees-line-width-focus-ring) solid var(--dees-color-focus-ring); outline-offset: 1px; }
|
|
64
70
|
.option:disabled { opacity: .5; cursor: default; }
|
|
71
|
+
[data-tone='neutral'] { --multitoggle-tone: var(--dees-color-text-secondary); }
|
|
72
|
+
[data-tone='info'] { --multitoggle-tone: var(--dees-color-text-info); }
|
|
73
|
+
[data-tone='success'] { --multitoggle-tone: var(--dees-color-text-success); }
|
|
74
|
+
[data-tone='warning'] { --multitoggle-tone: var(--dees-color-text-warning); }
|
|
75
|
+
[data-tone='error'] { --multitoggle-tone: var(--dees-color-text-error); }
|
|
65
76
|
.indicator { position: absolute; opacity: 0; border-radius: calc(var(--dees-radius-lg) - 2px); background: var(--dees-color-control-thumb); box-shadow: var(--dees-shadow-xs), inset 0 0 0 var(--dees-line-width-hairline) var(--dees-color-surface-highlight); pointer-events: none; transition: transform var(--dees-transition-fast) var(--dees-ease-standard), width var(--dees-transition-fast) var(--dees-ease-standard), height var(--dees-transition-fast) var(--dees-ease-standard); left: 0; top: 0; }
|
|
77
|
+
/* A toned selection: the segment takes a tint of the tone over the surface and a hairline in it;
|
|
78
|
+
the tone's text token reads on the tinted surface in both themes. */
|
|
79
|
+
.indicator:not([data-tone='']) { background: color-mix(in srgb, var(--multitoggle-tone, transparent) 14%, var(--dees-color-bg-primary)); box-shadow: var(--dees-shadow-xs), inset 0 0 0 var(--dees-line-width-hairline) color-mix(in srgb, var(--multitoggle-tone, transparent) 45%, transparent); }
|
|
66
80
|
.selections[aria-disabled='true'] { opacity: .5; }
|
|
67
81
|
.selections[aria-disabled='true'] .option:disabled { opacity: 1; }
|
|
68
82
|
.small .option { min-height: 24px; padding: 1px 10px; font-size: 12px; }
|
|
@@ -74,6 +88,7 @@ export class DeesInputMultitoggle extends DeesInputBase<DeesInputMultitoggle> {
|
|
|
74
88
|
private optionKey(option: TMultitoggleOption): string { return typeof option === 'string' ? option : option.key; }
|
|
75
89
|
private optionLabel(option: TMultitoggleOption): string { return typeof option === 'string' ? option : option.label; }
|
|
76
90
|
private optionDisabled(option: TMultitoggleOption): boolean { return this.disabled || (typeof option === 'object' && !!option.disabled); }
|
|
91
|
+
private optionTone(option: TMultitoggleOption | undefined): TTone | undefined { return typeof option === 'object' ? option.tone : undefined; }
|
|
77
92
|
|
|
78
93
|
protected willUpdate(changed: Map<PropertyKey, unknown>) {
|
|
79
94
|
if (this.type === 'boolean') {
|
|
@@ -91,18 +106,20 @@ export class DeesInputMultitoggle extends DeesInputBase<DeesInputMultitoggle> {
|
|
|
91
106
|
}
|
|
92
107
|
|
|
93
108
|
public render(): TemplateResult {
|
|
109
|
+
const selectedTone = this.optionTone(this.options.find(option => this.optionKey(option) === this.selectedOption));
|
|
94
110
|
const focusKey = this.options.some(option => this.optionKey(option) === this.selectedOption && !this.optionDisabled(option))
|
|
95
111
|
? this.selectedOption : this.options.find(option => !this.optionDisabled(option));
|
|
96
112
|
return html`<div class="input-wrapper">
|
|
97
113
|
${this.labelPosition !== 'none' && this.label ? this.renderLabel() : ''}
|
|
98
114
|
<div class="selections input-container ${this.size === 'sm' ? 'small' : ''}" role="radiogroup" aria-label=${this.label || this.key || 'Options'} aria-disabled=${this.disabled}>
|
|
99
|
-
<div class="indicator" aria-hidden="true"></div>
|
|
115
|
+
<div class="indicator" aria-hidden="true" data-tone=${selectedTone ?? ''}></div>
|
|
100
116
|
${this.options.map(option => {
|
|
101
117
|
const key = this.optionKey(option); const label = this.optionLabel(option); const selected = key === this.selectedOption;
|
|
102
118
|
const icon = typeof option === 'string' ? undefined : option.icon;
|
|
103
119
|
const badge = typeof option === 'string' ? undefined : option.badge;
|
|
104
120
|
const description = typeof option === 'string' ? undefined : option.description;
|
|
105
|
-
|
|
121
|
+
const tone = this.optionTone(option);
|
|
122
|
+
return html`<button type="button" role="radio" class="option ${selected ? 'selected' : ''}" data-option=${label} data-tone=${tone ?? ''} .title=${description ?? ''}
|
|
106
123
|
aria-checked=${selected} ?disabled=${this.optionDisabled(option)} tabindex=${key === (typeof focusKey === 'object' ? focusKey.key : focusKey) ? 0 : -1}
|
|
107
124
|
@click=${() => this.handleSelection(key)} @keydown=${this.handleKeydown}><span class="option-content">${icon ? html`<dees-icon .icon=${icon} iconSize="14" aria-hidden="true"></dees-icon>` : ''}<span class="option-label">${label}</span>${badge !== undefined ? html`<span class="option-badge">${badge}</span>` : ''}</span></button>`;
|
|
108
125
|
})}
|
|
@@ -11,8 +11,8 @@ import { DeesInputBase } from '../dees-input-base/dees-input-base.js';
|
|
|
11
11
|
import '../../00group-utility/dees-icon/dees-icon.js';
|
|
12
12
|
import { demoFunc } from './dees-input-tags.demo.js';
|
|
13
13
|
import { themeDefaultStyles } from '../../00theme.js';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { overlayScrollbarStyles } from '../../00scrollbars.js';
|
|
15
|
+
import { inputSuggestion, SuggestionListController, suggestionListStyles } from '../suggestion-list.js';
|
|
16
16
|
import { dcLocalize } from '../../../i18n/localize.js';
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -52,29 +52,24 @@ export class DeesInputTags extends DeesInputBase<DeesInputTags> {
|
|
|
52
52
|
@state()
|
|
53
53
|
accessor inputValue: string = '';
|
|
54
54
|
|
|
55
|
-
@state()
|
|
56
|
-
accessor showSuggestions: boolean = false;
|
|
57
|
-
|
|
58
|
-
@state()
|
|
59
|
-
accessor highlightedSuggestionIndex: number = -1;
|
|
60
|
-
|
|
61
55
|
@property({ type: String, reflect: true })
|
|
62
56
|
accessor validationText: string = '';
|
|
63
57
|
|
|
64
|
-
/**
|
|
65
|
-
private
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
);
|
|
58
|
+
/** The suggestions under the field, as a combobox list. */
|
|
59
|
+
private readonly suggestionList = new SuggestionListController(this, {
|
|
60
|
+
anchor: () => this.shadowRoot?.querySelector<HTMLElement>('.tags-container'),
|
|
61
|
+
pick: (index) => {
|
|
62
|
+
const suggestion = this.filteredSuggestions[index];
|
|
63
|
+
if (suggestion) this.addTag(suggestion);
|
|
64
|
+
},
|
|
65
|
+
});
|
|
72
66
|
|
|
73
67
|
public static styles = [
|
|
74
68
|
themeDefaultStyles,
|
|
75
69
|
...DeesInputBase.baseStyles,
|
|
76
70
|
cssManager.defaultStyles,
|
|
77
71
|
overlayScrollbarStyles,
|
|
72
|
+
suggestionListStyles,
|
|
78
73
|
css`
|
|
79
74
|
:host {
|
|
80
75
|
display: block;
|
|
@@ -182,58 +177,6 @@ export class DeesInputTags extends DeesInputBase<DeesInputTags> {
|
|
|
182
177
|
cursor: not-allowed;
|
|
183
178
|
}
|
|
184
179
|
|
|
185
|
-
/* Suggestions: a popover in the top layer, placed below the field by placeSuggestions.
|
|
186
|
-
The list scrolls inside it, the frame its scrollbar is placed in. */
|
|
187
|
-
.suggestions-dropdown {
|
|
188
|
-
position: fixed;
|
|
189
|
-
inset: auto;
|
|
190
|
-
margin: 0;
|
|
191
|
-
padding: 0;
|
|
192
|
-
color: inherit;
|
|
193
|
-
background: var(--dees-material-regular-bg-opaque);
|
|
194
|
-
border: var(--dees-line-width-hairline) solid var(--dees-color-border-default);
|
|
195
|
-
border-radius: var(--dees-radius-lg);
|
|
196
|
-
corner-shape: var(--dees-corner-shape);
|
|
197
|
-
box-shadow: var(--dees-shadow-lg);
|
|
198
|
-
overflow: hidden;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.suggestions-list {
|
|
202
|
-
max-height: calc(200px - 2 * var(--dees-line-width-hairline));
|
|
203
|
-
overflow-y: auto;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
|
207
|
-
.suggestions-dropdown {
|
|
208
|
-
background: var(--dees-material-regular-bg-opaque);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
@media (prefers-reduced-transparency: reduce) {
|
|
213
|
-
.suggestions-dropdown {
|
|
214
|
-
background: var(--dees-material-regular-bg-opaque);
|
|
215
|
-
-webkit-backdrop-filter: none;
|
|
216
|
-
backdrop-filter: none;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.suggestion {
|
|
221
|
-
padding: 6px 10px;
|
|
222
|
-
cursor: pointer;
|
|
223
|
-
transition: background-color var(--dees-transition-fast) var(--dees-ease-standard);
|
|
224
|
-
font-size: 14px;
|
|
225
|
-
color: var(--dees-color-text-primary);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.suggestion:hover {
|
|
229
|
-
background: var(--dees-color-hover);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.suggestion.highlighted {
|
|
233
|
-
background: var(--dees-color-active);
|
|
234
|
-
color: var(--dees-color-text-primary);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
180
|
/* Validation styles */
|
|
238
181
|
.validation-message {
|
|
239
182
|
color: var(--dees-color-accent-error);
|
|
@@ -244,13 +187,16 @@ export class DeesInputTags extends DeesInputBase<DeesInputTags> {
|
|
|
244
187
|
`,
|
|
245
188
|
];
|
|
246
189
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
190
|
+
/** The suggestions not yet a tag that hold the typed text. */
|
|
191
|
+
private get filteredSuggestions(): string[] {
|
|
192
|
+
return this.suggestions.filter(
|
|
193
|
+
suggestion =>
|
|
250
194
|
!this.value.includes(suggestion) &&
|
|
251
195
|
suggestion.toLowerCase().includes(this.inputValue.toLowerCase())
|
|
252
196
|
);
|
|
197
|
+
}
|
|
253
198
|
|
|
199
|
+
public render(): TemplateResult {
|
|
254
200
|
return html`
|
|
255
201
|
<div class="input-wrapper">
|
|
256
202
|
${this.renderLabel()}
|
|
@@ -287,22 +233,7 @@ export class DeesInputTags extends DeesInputBase<DeesInputTags> {
|
|
|
287
233
|
` : ''}
|
|
288
234
|
</div>
|
|
289
235
|
|
|
290
|
-
${this.
|
|
291
|
-
<div class="suggestions-dropdown" popover="manual"><div class="suggestions-list">
|
|
292
|
-
${filteredSuggestions.map((suggestion, index) => html`
|
|
293
|
-
<div
|
|
294
|
-
class="suggestion ${index === this.highlightedSuggestionIndex ? 'highlighted' : ''}"
|
|
295
|
-
@mousedown=${(e: Event) => {
|
|
296
|
-
e.preventDefault(); // Prevent blur
|
|
297
|
-
this.addTag(suggestion);
|
|
298
|
-
}}
|
|
299
|
-
@mouseenter=${() => this.highlightedSuggestionIndex = index}
|
|
300
|
-
>
|
|
301
|
-
${suggestion}
|
|
302
|
-
</div>
|
|
303
|
-
`)}
|
|
304
|
-
</div></div>
|
|
305
|
-
` : ''}
|
|
236
|
+
${this.suggestionList.render(this.filteredSuggestions.map(inputSuggestion), this.label)}
|
|
306
237
|
|
|
307
238
|
${this.validationText ? html`
|
|
308
239
|
<div class="validation-message">${this.validationText}</div>
|
|
@@ -315,61 +246,12 @@ export class DeesInputTags extends DeesInputBase<DeesInputTags> {
|
|
|
315
246
|
|
|
316
247
|
updated(changedProperties: Map<string, any>) {
|
|
317
248
|
super.updated(changedProperties);
|
|
318
|
-
const
|
|
319
|
-
if (
|
|
320
|
-
this.
|
|
321
|
-
this.suggestionsTracking = undefined;
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
if (!this.suggestionsTracking) {
|
|
325
|
-
const field = this.shadowRoot!.querySelector<HTMLElement>('.tags-container')!;
|
|
326
|
-
const tracking = new AbortController();
|
|
327
|
-
this.suggestionsTracking = tracking;
|
|
328
|
-
listenForScrollAround(field, this.placeSuggestions, tracking.signal);
|
|
329
|
-
window.addEventListener('resize', this.placeSuggestions, { passive: true, signal: tracking.signal });
|
|
330
|
-
// Tags wrap onto another line as they are added, and the field grows with them.
|
|
331
|
-
const observer = new ResizeObserver(this.placeSuggestions);
|
|
332
|
-
observer.observe(field);
|
|
333
|
-
tracking.signal.addEventListener('abort', () => observer.disconnect());
|
|
249
|
+
const input = this.shadowRoot!.querySelector<HTMLInputElement>('.tag-input');
|
|
250
|
+
if (input) {
|
|
251
|
+
this.suggestionList.applyComboboxAttributes(input, this.filteredSuggestions.length, this.suggestions.length > 0);
|
|
334
252
|
}
|
|
335
|
-
this.placeSuggestions();
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
public async disconnectedCallback(): Promise<void> {
|
|
339
|
-
this.suggestionsTracking?.abort();
|
|
340
|
-
this.suggestionsTracking = undefined;
|
|
341
|
-
await super.disconnectedCallback();
|
|
342
253
|
}
|
|
343
254
|
|
|
344
|
-
/**
|
|
345
|
-
* The open suggestions stand in the top layer, below the field or above it without room there,
|
|
346
|
-
* so no scroll container or clipping ancestor around the field cuts them off. They follow the
|
|
347
|
-
* field as it scrolls or grows and step out of view while none of it shows.
|
|
348
|
-
*/
|
|
349
|
-
private placeSuggestions = () => {
|
|
350
|
-
const list = this.shadowRoot?.querySelector<HTMLElement>('.suggestions-dropdown');
|
|
351
|
-
const field = this.shadowRoot?.querySelector<HTMLElement>('.tags-container');
|
|
352
|
-
if (!list || !field) return;
|
|
353
|
-
const shown = visibleRect(field);
|
|
354
|
-
if (!shown) {
|
|
355
|
-
if (list.matches(':popover-open')) list.hidePopover();
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
if (!list.matches(':popover-open')) list.showPopover();
|
|
359
|
-
const box = field.getBoundingClientRect();
|
|
360
|
-
list.style.width = `${box.width}px`;
|
|
361
|
-
const placed = placeAnchored({
|
|
362
|
-
anchor: { left: box.left, right: box.right, top: shown.top, bottom: shown.bottom },
|
|
363
|
-
width: box.width,
|
|
364
|
-
height: list.offsetHeight,
|
|
365
|
-
placement: 'bottom',
|
|
366
|
-
flip: true,
|
|
367
|
-
gap: 4,
|
|
368
|
-
});
|
|
369
|
-
list.style.left = `${placed.left}px`;
|
|
370
|
-
list.style.top = `${placed.top}px`;
|
|
371
|
-
};
|
|
372
|
-
|
|
373
255
|
private handleContainerClick(e: Event) {
|
|
374
256
|
if (this.disabled) return;
|
|
375
257
|
|
|
@@ -406,56 +288,31 @@ export class DeesInputTags extends DeesInputBase<DeesInputTags> {
|
|
|
406
288
|
|
|
407
289
|
private handleKeyDown(e: KeyboardEvent) {
|
|
408
290
|
if (this.disabled || e.isComposing) return;
|
|
409
|
-
|
|
410
|
-
|
|
291
|
+
if (this.suggestionList.handleKeydown(e, this.filteredSuggestions.length)) return;
|
|
292
|
+
|
|
411
293
|
if (e.key === 'Enter') {
|
|
412
294
|
e.preventDefault();
|
|
413
|
-
if (this.
|
|
414
|
-
const filteredSuggestions = this.suggestions.filter(
|
|
415
|
-
suggestion =>
|
|
416
|
-
!this.value.includes(suggestion) &&
|
|
417
|
-
suggestion.toLowerCase().includes(this.inputValue.toLowerCase())
|
|
418
|
-
);
|
|
419
|
-
if (filteredSuggestions[this.highlightedSuggestionIndex]) {
|
|
420
|
-
this.addTag(filteredSuggestions[this.highlightedSuggestionIndex]);
|
|
421
|
-
}
|
|
422
|
-
} else if (this.inputValue.trim()) {
|
|
295
|
+
if (this.inputValue.trim()) {
|
|
423
296
|
this.addTag(this.inputValue.trim());
|
|
424
297
|
}
|
|
425
298
|
} else if (e.key === 'Backspace' && !this.inputValue && this.value.length > 0) {
|
|
426
299
|
// Remove last tag when backspace is pressed on empty input
|
|
427
300
|
this.removeTag(e, this.value[this.value.length - 1]);
|
|
428
|
-
} else if (e.key === 'ArrowDown' && this.showSuggestions) {
|
|
429
|
-
e.preventDefault();
|
|
430
|
-
const filteredCount = this.suggestions.filter(
|
|
431
|
-
s => !this.value.includes(s) && s.toLowerCase().includes(this.inputValue.toLowerCase())
|
|
432
|
-
).length;
|
|
433
|
-
this.highlightedSuggestionIndex = Math.min(
|
|
434
|
-
this.highlightedSuggestionIndex + 1,
|
|
435
|
-
filteredCount - 1
|
|
436
|
-
);
|
|
437
|
-
} else if (e.key === 'ArrowUp' && this.showSuggestions) {
|
|
438
|
-
e.preventDefault();
|
|
439
|
-
this.highlightedSuggestionIndex = Math.max(this.highlightedSuggestionIndex - 1, 0);
|
|
440
301
|
} else if (e.key === 'Tab') {
|
|
441
302
|
// before the focus moves on, so a host that reads the value on Tab (a table cell) has the text
|
|
442
303
|
this.addPendingInput();
|
|
443
|
-
} else if (e.key === 'Escape') {
|
|
444
|
-
this.showSuggestions = false;
|
|
445
|
-
this.highlightedSuggestionIndex = -1;
|
|
446
304
|
}
|
|
447
305
|
}
|
|
448
306
|
|
|
449
307
|
private handleFocus() {
|
|
450
308
|
if (this.suggestions.length > 0) {
|
|
451
|
-
this.
|
|
309
|
+
this.suggestionList.show();
|
|
452
310
|
}
|
|
453
311
|
}
|
|
454
312
|
|
|
455
313
|
private handleBlur(e: FocusEvent) {
|
|
456
314
|
// Suggestions prevent pointer-down blur; no delayed state change is needed.
|
|
457
|
-
this.
|
|
458
|
-
this.highlightedSuggestionIndex = -1;
|
|
315
|
+
this.suggestionList.hide();
|
|
459
316
|
// The window losing the focus blurs the text but leaves it the active element: the reader has
|
|
460
317
|
// not left the field and comes back to what they were typing.
|
|
461
318
|
const input = e.target as HTMLInputElement;
|
|
@@ -493,8 +350,7 @@ export class DeesInputTags extends DeesInputBase<DeesInputTags> {
|
|
|
493
350
|
if (this.maxTags && this.value.length >= this.maxTags) return;
|
|
494
351
|
|
|
495
352
|
this.value = [...this.value, tag];
|
|
496
|
-
this.
|
|
497
|
-
this.highlightedSuggestionIndex = -1;
|
|
353
|
+
this.suggestionList.hide();
|
|
498
354
|
this.clearInput();
|
|
499
355
|
|
|
500
356
|
this.emitChange();
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { html } from '@design.estate/dees-element';
|
|
2
2
|
import { demoPage, demoSection, demoOutput, demoCode, showDemoResult } from '../../../demos/templates.js';
|
|
3
|
+
import type { DeesInputText, IInputSuggestion } from './dees-input-text.js';
|
|
4
|
+
|
|
5
|
+
/** What a server would answer for a typed path: the paths that continue it. */
|
|
6
|
+
const serverPaths = ['/home/', '/home/alex/', '/home/alex/projects/', '/home/alex/projects/catalog/', '/srv/', '/srv/www/', '/srv/www/site/', '/var/', '/var/log/', '/var/log/nginx/'];
|
|
7
|
+
const completePath = (event: Event) => {
|
|
8
|
+
const field = event.currentTarget as DeesInputText;
|
|
9
|
+
const typed = String(field.value ?? '');
|
|
10
|
+
field.suggestions = serverPaths.filter((path) => path.startsWith(typed) && path !== typed);
|
|
11
|
+
};
|
|
12
|
+
const regions: IInputSuggestion[] = [
|
|
13
|
+
{ value: 'eu-central-1', label: 'Frankfurt', description: 'eu-central-1' },
|
|
14
|
+
{ value: 'eu-west-1', label: 'Ireland', description: 'eu-west-1' },
|
|
15
|
+
{ value: 'us-east-1', label: 'Virginia', description: 'us-east-1' },
|
|
16
|
+
];
|
|
3
17
|
|
|
4
18
|
export const demoFunc = () => demoPage('Text input', 'A compact editor field and a quiet grouped value, with accessible labels, password controls, and validation feedback.', html`
|
|
5
19
|
${demoSection('Everyday entry', 'Labels and descriptions explain what belongs in each field.', html`
|
|
@@ -13,6 +27,9 @@ export const demoFunc = () => demoPage('Text input', 'A compact editor field and
|
|
|
13
27
|
${demoSection('Password visibility', 'A dedicated button reveals or conceals the value and follows the disabled state.', html`
|
|
14
28
|
<div class="dees-demo-grid"><dees-input-text label="Password" value="catalog-preview" .isPasswordBool=${true} autocomplete="new-password"></dees-input-text><dees-input-text label="Visible password" value="catalog-preview" .isPasswordBool=${true} .showPasswordBool=${true}></dees-input-text></div>
|
|
15
29
|
${demoCode('<dees-input-text label="Password" .isPasswordBool=${true}></dees-input-text>')}`)}
|
|
30
|
+
${demoSection('Suggestions', 'The field offers values in a list under it. Arrow keys move through them, Enter or a click picks one, Escape closes the list. The host sends the list for what is typed; the field filters nothing.', html`
|
|
31
|
+
<div class="dees-demo-grid"><dees-input-text label="Working directory" placeholder="/home/" .suggestions=${serverPaths} @input=${completePath} @suggestion-select=${(event: CustomEvent) => showDemoResult(event.currentTarget as Element, event.detail.value)}></dees-input-text><dees-input-text label="Region" .suggestions=${regions} @suggestion-select=${(event: CustomEvent) => showDemoResult(event.currentTarget as Element, event.detail.value)}></dees-input-text></div>${demoOutput('Pick a suggestion to see its value.')}
|
|
32
|
+
${demoCode('<dees-input-text label="Working directory" .suggestions=${paths} @input=${complete} @suggestion-select=${picked}></dees-input-text>')}`)}
|
|
16
33
|
${demoSection('Live value', 'Native input events cross the shadow boundary. The result is rendered as text.', html`
|
|
17
34
|
<dees-input-text class="dees-demo-field" label="Try a workspace name" @input=${(event: Event) => showDemoResult(event.currentTarget as Element, (event.composedPath()[0] as HTMLInputElement).value)}></dees-input-text>${demoOutput()}`)}
|
|
18
35
|
`);
|