@design.estate/dees-catalog 24.4.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 +60 -174
- 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-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/package.json +1 -1
- package/readme.md +27 -1
- package/scripts/token-baseline.json +1 -1
- package/ts_web/00_commitinfo_data.ts +1 -1
- 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/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
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { css, html } from '@design.estate/dees-element';
|
|
2
|
+
import { listenForScrollAround, placeAnchored, visibleRect } from '../00anchorplacement.js';
|
|
3
|
+
import { OverlayScrollbarController } from '../00scrollbars.js';
|
|
4
|
+
/** A suggestion in its object form. */
|
|
5
|
+
export const inputSuggestion = (suggestionArg) => typeof suggestionArg === 'string' ? { value: suggestionArg } : suggestionArg;
|
|
6
|
+
/**
|
|
7
|
+
* The suggestions an editable field offers in a list under it, as a WAI-ARIA combobox: the field
|
|
8
|
+
* keeps the focus, the arrow keys move the highlighted option, Enter or a press picks it, Escape
|
|
9
|
+
* closes the list. The host owns the suggestions and what a pick does; the controller owns whether
|
|
10
|
+
* the list is open, the highlighted option, the list's markup and its place.
|
|
11
|
+
*
|
|
12
|
+
* The open list stands in the top layer (`popover="manual"`), below the field or above it without
|
|
13
|
+
* room there, so no scroll container, clipping ancestor or dialog around the field cuts it off. It
|
|
14
|
+
* follows the field as it scrolls or grows and steps out of view while none of the field shows.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* public static styles = [themeDefaultStyles, overlayScrollbarStyles, suggestionListStyles, css`…`];
|
|
18
|
+
* private readonly suggestionList = new SuggestionListController(this, {
|
|
19
|
+
* anchor: () => this.shadowRoot?.querySelector('input'),
|
|
20
|
+
* pick: (index) => this.choose(this.suggestions[index]),
|
|
21
|
+
* });
|
|
22
|
+
* public render() {
|
|
23
|
+
* return html`<input @keydown=${(e) => this.suggestionList.handleKeydown(e, this.suggestions.length)}>
|
|
24
|
+
* ${this.suggestionList.render(this.suggestions.map(inputSuggestion), this.label)}`;
|
|
25
|
+
* }
|
|
26
|
+
* public updated() {
|
|
27
|
+
* this.suggestionList.applyComboboxAttributes(this.shadowRoot!.querySelector('input')!, this.suggestions.length);
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export class SuggestionListController {
|
|
32
|
+
host;
|
|
33
|
+
options;
|
|
34
|
+
/** The id of the list in the host's shadow root, for the field's `aria-controls`. */
|
|
35
|
+
static listboxId = 'suggestion-listbox';
|
|
36
|
+
/** Whether the list shows while there are suggestions. */
|
|
37
|
+
expanded = false;
|
|
38
|
+
/** The highlighted option, -1 for none. */
|
|
39
|
+
highlightedIndex = -1;
|
|
40
|
+
/** The name the last render gave the list; empty for none. */
|
|
41
|
+
listLabel = '';
|
|
42
|
+
/** Ends the listeners that keep the open list beside the field. */
|
|
43
|
+
tracking;
|
|
44
|
+
/** The list's scrollbar, shown while it scrolls. */
|
|
45
|
+
scrollbars;
|
|
46
|
+
constructor(host, options) {
|
|
47
|
+
this.host = host;
|
|
48
|
+
this.options = options;
|
|
49
|
+
host.addController(this);
|
|
50
|
+
this.scrollbars = new OverlayScrollbarController(host, () => this.popup()?.querySelector('.suggestions-list'));
|
|
51
|
+
}
|
|
52
|
+
/** The id of the option at `indexArg`, for the field's `aria-activedescendant`. */
|
|
53
|
+
static optionId(indexArg) {
|
|
54
|
+
return `suggestion-option-${indexArg}`;
|
|
55
|
+
}
|
|
56
|
+
/** Whether the list shows `countArg` suggestions now. */
|
|
57
|
+
isOpen(countArg) {
|
|
58
|
+
return this.expanded && countArg > 0;
|
|
59
|
+
}
|
|
60
|
+
/** Opens the list; it shows while there are suggestions. */
|
|
61
|
+
show() {
|
|
62
|
+
if (this.expanded)
|
|
63
|
+
return;
|
|
64
|
+
this.expanded = true;
|
|
65
|
+
this.host.requestUpdate();
|
|
66
|
+
}
|
|
67
|
+
/** Closes the list and lets go of the highlighted option. */
|
|
68
|
+
hide() {
|
|
69
|
+
if (!this.expanded && this.highlightedIndex === -1)
|
|
70
|
+
return;
|
|
71
|
+
this.expanded = false;
|
|
72
|
+
this.highlightedIndex = -1;
|
|
73
|
+
this.host.requestUpdate();
|
|
74
|
+
}
|
|
75
|
+
/** Highlights the option at `indexArg`, -1 for none. */
|
|
76
|
+
highlight(indexArg) {
|
|
77
|
+
if (indexArg === this.highlightedIndex)
|
|
78
|
+
return;
|
|
79
|
+
this.highlightedIndex = indexArg;
|
|
80
|
+
this.host.requestUpdate();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Answers the list's keys in the field while the list shows: ArrowDown and ArrowUp move the
|
|
84
|
+
* highlighted option, Enter picks the highlighted one, Escape closes the list. Returns whether it
|
|
85
|
+
* answered the key; a key it answers in a showing list is prevented, so a form does not take Enter
|
|
86
|
+
* and a dialog does not take Escape. A list with no suggestions shows nothing and answers none of
|
|
87
|
+
* them: the arrows move the caret and Enter is the host's or the form's. Tab is the host's: it
|
|
88
|
+
* leaves the field without a pick.
|
|
89
|
+
*/
|
|
90
|
+
handleKeydown(eventArg, countArg) {
|
|
91
|
+
if (eventArg.isComposing)
|
|
92
|
+
return false;
|
|
93
|
+
const open = this.isOpen(countArg);
|
|
94
|
+
switch (eventArg.key) {
|
|
95
|
+
case 'ArrowDown':
|
|
96
|
+
if (!open)
|
|
97
|
+
return false;
|
|
98
|
+
eventArg.preventDefault();
|
|
99
|
+
this.highlight(Math.min(this.highlightedIndex + 1, countArg - 1));
|
|
100
|
+
return true;
|
|
101
|
+
case 'ArrowUp':
|
|
102
|
+
if (!open)
|
|
103
|
+
return false;
|
|
104
|
+
eventArg.preventDefault();
|
|
105
|
+
this.highlight(Math.min(Math.max(this.highlightedIndex - 1, 0), countArg - 1));
|
|
106
|
+
return true;
|
|
107
|
+
case 'Enter':
|
|
108
|
+
if (!open || this.highlightedIndex < 0 || this.highlightedIndex >= countArg)
|
|
109
|
+
return false;
|
|
110
|
+
eventArg.preventDefault();
|
|
111
|
+
this.options.pick(this.highlightedIndex);
|
|
112
|
+
return true;
|
|
113
|
+
case 'Escape': {
|
|
114
|
+
if (!this.expanded)
|
|
115
|
+
return false;
|
|
116
|
+
if (open)
|
|
117
|
+
eventArg.preventDefault();
|
|
118
|
+
this.hide();
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
default:
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Writes the combobox state onto the field: `role="combobox"`, `aria-autocomplete="list"`,
|
|
127
|
+
* `aria-expanded`, and while the list shows `aria-controls` and the highlighted option's
|
|
128
|
+
* `aria-activedescendant`. With `activeArg` false it removes all of them, for a field that offers
|
|
129
|
+
* no suggestions and is a plain text field.
|
|
130
|
+
*/
|
|
131
|
+
applyComboboxAttributes(fieldArg, countArg, activeArg = true) {
|
|
132
|
+
const open = this.isOpen(countArg);
|
|
133
|
+
const highlighted = open && this.highlightedIndex >= 0 && this.highlightedIndex < countArg;
|
|
134
|
+
const attributes = {
|
|
135
|
+
role: activeArg ? 'combobox' : null,
|
|
136
|
+
'aria-autocomplete': activeArg ? 'list' : null,
|
|
137
|
+
'aria-expanded': activeArg ? String(open) : null,
|
|
138
|
+
'aria-controls': activeArg && open ? SuggestionListController.listboxId : null,
|
|
139
|
+
'aria-activedescendant': activeArg && highlighted ? SuggestionListController.optionId(this.highlightedIndex) : null,
|
|
140
|
+
};
|
|
141
|
+
for (const [name, value] of Object.entries(attributes)) {
|
|
142
|
+
if (value === null)
|
|
143
|
+
fieldArg.removeAttribute(name);
|
|
144
|
+
else if (fieldArg.getAttribute(name) !== value)
|
|
145
|
+
fieldArg.setAttribute(name, value);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The open list, or nothing while it is closed or has no suggestions. `labelArg` names it; an
|
|
150
|
+
* empty one leaves it without an `aria-label`.
|
|
151
|
+
*/
|
|
152
|
+
render(itemsArg, labelArg = '') {
|
|
153
|
+
this.listLabel = labelArg;
|
|
154
|
+
if (!this.isOpen(itemsArg.length))
|
|
155
|
+
return '';
|
|
156
|
+
return html `
|
|
157
|
+
<div class="suggestions-dropdown" popover="manual"><div
|
|
158
|
+
class="suggestions-list"
|
|
159
|
+
id=${SuggestionListController.listboxId}
|
|
160
|
+
role="listbox"
|
|
161
|
+
>
|
|
162
|
+
${itemsArg.map((item, index) => html `
|
|
163
|
+
<div
|
|
164
|
+
class="suggestion ${index === this.highlightedIndex ? 'highlighted' : ''}"
|
|
165
|
+
id=${SuggestionListController.optionId(index)}
|
|
166
|
+
role="option"
|
|
167
|
+
aria-selected=${index === this.highlightedIndex ? 'true' : 'false'}
|
|
168
|
+
@mousedown=${(event) => {
|
|
169
|
+
event.preventDefault(); // the field keeps the focus
|
|
170
|
+
this.options.pick(index);
|
|
171
|
+
}}
|
|
172
|
+
@mouseenter=${() => this.highlight(index)}
|
|
173
|
+
>
|
|
174
|
+
${item.label ?? item.value}
|
|
175
|
+
${item.description ? html `<div class="suggestion-description">${item.description}</div>` : ''}
|
|
176
|
+
</div>
|
|
177
|
+
`)}
|
|
178
|
+
</div></div>
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
/** The open list follows the field from the render that shows it until the render that removes it. */
|
|
182
|
+
hostUpdated() {
|
|
183
|
+
const popup = this.popup();
|
|
184
|
+
if (!popup) {
|
|
185
|
+
this.stopTracking();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
// Applied here, not bound, so a list without a name carries no empty `aria-label`.
|
|
189
|
+
const listbox = popup.querySelector('[role="listbox"]');
|
|
190
|
+
if (this.listLabel)
|
|
191
|
+
listbox.setAttribute('aria-label', this.listLabel);
|
|
192
|
+
else
|
|
193
|
+
listbox.removeAttribute('aria-label');
|
|
194
|
+
const field = this.options.anchor();
|
|
195
|
+
if (!field)
|
|
196
|
+
return;
|
|
197
|
+
if (!this.tracking) {
|
|
198
|
+
const tracking = new AbortController();
|
|
199
|
+
this.tracking = tracking;
|
|
200
|
+
listenForScrollAround(field, this.place, tracking.signal);
|
|
201
|
+
window.addEventListener('resize', this.place, { passive: true, signal: tracking.signal });
|
|
202
|
+
// A field can grow as the reader works in it (tags wrap onto another line).
|
|
203
|
+
const observer = new ResizeObserver(this.place);
|
|
204
|
+
observer.observe(field);
|
|
205
|
+
tracking.signal.addEventListener('abort', () => observer.disconnect());
|
|
206
|
+
}
|
|
207
|
+
this.place();
|
|
208
|
+
}
|
|
209
|
+
hostDisconnected() {
|
|
210
|
+
this.stopTracking();
|
|
211
|
+
}
|
|
212
|
+
popup() {
|
|
213
|
+
return this.host.shadowRoot?.querySelector('.suggestions-dropdown');
|
|
214
|
+
}
|
|
215
|
+
stopTracking() {
|
|
216
|
+
this.tracking?.abort();
|
|
217
|
+
this.tracking = undefined;
|
|
218
|
+
}
|
|
219
|
+
/** Places the open list below the field, or above it without room there, as wide as the field. */
|
|
220
|
+
place = () => {
|
|
221
|
+
const popup = this.popup();
|
|
222
|
+
const field = this.options.anchor();
|
|
223
|
+
if (!popup || !field)
|
|
224
|
+
return;
|
|
225
|
+
const shown = visibleRect(field);
|
|
226
|
+
if (!shown) {
|
|
227
|
+
if (popup.matches(':popover-open'))
|
|
228
|
+
popup.hidePopover();
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (!popup.matches(':popover-open'))
|
|
232
|
+
popup.showPopover();
|
|
233
|
+
const box = field.getBoundingClientRect();
|
|
234
|
+
popup.style.width = `${box.width}px`;
|
|
235
|
+
const placed = placeAnchored({
|
|
236
|
+
anchor: { left: box.left, right: box.right, top: shown.top, bottom: shown.bottom },
|
|
237
|
+
width: box.width,
|
|
238
|
+
height: popup.offsetHeight,
|
|
239
|
+
placement: 'bottom',
|
|
240
|
+
flip: true,
|
|
241
|
+
gap: 4,
|
|
242
|
+
});
|
|
243
|
+
popup.style.left = `${placed.left}px`;
|
|
244
|
+
popup.style.top = `${placed.top}px`;
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/** The open list's look; a host adds `overlayScrollbarStyles` beside it. */
|
|
248
|
+
export const suggestionListStyles = css `
|
|
249
|
+
/* A popover in the top layer, placed by the controller. The list scrolls inside it, the frame
|
|
250
|
+
its scrollbar is placed in. */
|
|
251
|
+
.suggestions-dropdown {
|
|
252
|
+
position: fixed;
|
|
253
|
+
inset: auto;
|
|
254
|
+
margin: 0;
|
|
255
|
+
padding: 0;
|
|
256
|
+
color: inherit;
|
|
257
|
+
background: var(--dees-material-regular-bg-opaque);
|
|
258
|
+
border: var(--dees-line-width-hairline) solid var(--dees-color-border-default);
|
|
259
|
+
border-radius: var(--dees-radius-lg);
|
|
260
|
+
corner-shape: var(--dees-corner-shape);
|
|
261
|
+
box-shadow: var(--dees-shadow-lg);
|
|
262
|
+
overflow: hidden;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.suggestions-list {
|
|
266
|
+
max-height: calc(200px - 2 * var(--dees-line-width-hairline));
|
|
267
|
+
overflow-y: auto;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
271
|
+
.suggestions-dropdown {
|
|
272
|
+
-webkit-backdrop-filter: none;
|
|
273
|
+
backdrop-filter: none;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.suggestion {
|
|
278
|
+
padding: var(--dees-spacing-xs-plus) var(--dees-spacing-sm-plus);
|
|
279
|
+
cursor: pointer;
|
|
280
|
+
transition: background-color var(--dees-transition-fast) var(--dees-ease-standard);
|
|
281
|
+
font-size: 14px;
|
|
282
|
+
color: var(--dees-color-text-primary);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.suggestion:hover {
|
|
286
|
+
background: var(--dees-color-hover);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.suggestion.highlighted {
|
|
290
|
+
background: var(--dees-color-active);
|
|
291
|
+
color: var(--dees-color-text-primary);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.suggestion-description {
|
|
295
|
+
color: var(--dees-color-text-secondary);
|
|
296
|
+
font-size: var(--dees-font-footnote-size);
|
|
297
|
+
line-height: var(--dees-font-footnote-line);
|
|
298
|
+
}
|
|
299
|
+
`;
|
|
300
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3VnZ2VzdGlvbi1saXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vdHNfd2ViL2VsZW1lbnRzLzAwZ3JvdXAtaW5wdXQvc3VnZ2VzdGlvbi1saXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxHQUFHLEVBQUUsSUFBSSxFQUF5RCxNQUFNLDZCQUE2QixDQUFDO0FBQy9HLE9BQU8sRUFBRSxxQkFBcUIsRUFBRSxhQUFhLEVBQUUsV0FBVyxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFNUYsT0FBTyxFQUFFLDBCQUEwQixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFjaEUsdUNBQXVDO0FBQ3ZDLE1BQU0sQ0FBQyxNQUFNLGVBQWUsR0FBRyxDQUFDLGFBQStCLEVBQW9CLEVBQUUsQ0FDbkYsT0FBTyxhQ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VMsRUFBRSxRQUFRO1lBQ25CLElBQUksRUFBRSxJQUFJO1lBQ1YsR0FBRyxFQUFFLENBQUM7U0FDUCxDQUFDLENBQUM7UUFDSCxLQUFLLENBQUMsS0FBSyxDQUFDLElBQUksR0FBRyxHQUFHLE1BQU0sQ0FBQyxJQUFJLElBQUksQ0FBQztRQUN0QyxLQUFLLENBQUMsS0FBSyxDQUFDLEdBQUcsR0FBRyxHQUFHLE1BQU0sQ0FBQyxHQUFHLElBQUksQ0FBQztJQUN0QyxDQUFDLENBQUM7Q0FDSDtBQUVELDRFQUE0RTtBQUM1RSxNQUFNLENBQUMsTUFBTSxvQkFBb0IsR0FBYyxHQUFHLENBQUE7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztDQW1EakQsQ0FBQyJ9
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@design.estate/dees-catalog",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.",
|
|
6
6
|
"main": "dist_ts_web/index.js",
|
package/readme.md
CHANGED
|
@@ -1894,6 +1894,32 @@ Text input field with validation, info tooltips, description text, and context m
|
|
|
1894
1894
|
- `validationFunction` always receives the value as text, whatever the type.
|
|
1895
1895
|
- [`frameless`](#frameless-components) sheds the field chrome — border, label and validation
|
|
1896
1896
|
row — so the input blends into a host that owns them, the way `dees-table` edits a cell.
|
|
1897
|
+
- `suggestions: TInputSuggestion[] | null` offers values in a list under the focused field. A
|
|
1898
|
+
suggestion is the value itself or `{ value, label?, description? }` (`IInputSuggestion`): `label`
|
|
1899
|
+
is shown instead of the value, `description` as a quieter second line. The field shows the list
|
|
1900
|
+
as the host gives it and filters nothing, so a host that completes the typed text — paths on a
|
|
1901
|
+
server, say — answers `input` with the list for it. The list is a WAI-ARIA combobox: the input is
|
|
1902
|
+
`role="combobox"` with `aria-autocomplete="list"`, `aria-expanded`, `aria-controls` and
|
|
1903
|
+
`aria-activedescendant`; the list is a `role="listbox"` of `role="option"`s with `aria-selected`.
|
|
1904
|
+
ArrowDown and ArrowUp move the highlighted option (ArrowDown also opens a closed list), Enter or a
|
|
1905
|
+
press picks it, Escape closes the list and Tab leaves the field without a pick; typing opens it
|
|
1906
|
+
again. The keys act only while the list shows; with no suggestions the arrows move the caret and
|
|
1907
|
+
Enter is the form's. A key the open list answers is prevented, so Enter does not reach a
|
|
1908
|
+
`dees-form` and Escape does not close a `dees-modal`. A pick sets the value, runs `validationFunction`, reports `input`
|
|
1909
|
+
and `change` (leaving the field afterwards reports no second `change`) and fires `suggestion-select` (bubbling, composed) with
|
|
1910
|
+
`{ value, suggestion }` (`IInputTextSuggestionSelectDetail`). The list stands in the top layer
|
|
1911
|
+
below the field, or above it without room there, as `dees-input-tags`' does. `null`, the default,
|
|
1912
|
+
is a plain text field with none of the combobox attributes; an empty array keeps the combobox
|
|
1913
|
+
with its list closed.
|
|
1914
|
+
|
|
1915
|
+
```typescript
|
|
1916
|
+
html`<dees-input-text
|
|
1917
|
+
label="Working directory"
|
|
1918
|
+
.suggestions=${this.paths}
|
|
1919
|
+
@input=${(event: Event) => this.completePath((event.currentTarget as DeesInputText).value)}
|
|
1920
|
+
@suggestion-select=${(event: CustomEvent<IInputTextSuggestionSelectDetail>) => this.open(event.detail.value)}
|
|
1921
|
+
></dees-input-text>`;
|
|
1922
|
+
```
|
|
1897
1923
|
|
|
1898
1924
|
> 💡 **All input components** share these common properties from `DeesInputBase`: `key`, `label`, `required`, `disabled`, `infoText`, `description`, `layoutMode`, `labelPosition`.
|
|
1899
1925
|
|
|
@@ -2127,7 +2153,7 @@ html`<dees-input-multitoggle
|
|
|
2127
2153
|
|
|
2128
2154
|
| Property/API | Behavior |
|
|
2129
2155
|
| --- | --- |
|
|
2130
|
-
| `options: TMultitoggleOption[]` | Strings or `{ key, label, disabled?, icon?, badge?, description? }` objects; `description` is the segment's tooltip. |
|
|
2156
|
+
| `options: TMultitoggleOption[]` | Strings or `{ key, label, disabled?, icon?, badge?, description?, tone? }` objects; `description` is the segment's tooltip. `tone` (a `TTone`: `neutral`, `info`, `success`, `warning`, `error`) colours the option while it is selected: its label takes the tone's `--dees-color-text-*` token and the selected segment a tint of the tone with a hairline in it, readable at 4.5:1 in both themes. Unselected, and without a tone, an option looks as before. |
|
|
2131
2157
|
| `selectedOption` | Selected string/key; bind with `.selectedOption` in Lit. |
|
|
2132
2158
|
| `value`, `getValue()`, `setValue(value)` | String key, or boolean in boolean mode. `value` is a JavaScript property, not a `value` HTML attribute. |
|
|
2133
2159
|
| `type="boolean"` | Two alternatives named by `booleanTrueName` / `booleanFalseName`; `.boolValue` supplies a boolean selection. |
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"ts_web/elements/00group-input/dees-input-quantityselector/dees-input-quantityselector.ts": 1,
|
|
68
68
|
"ts_web/elements/00group-input/dees-input-reference/dees-input-reference.ts": 1,
|
|
69
69
|
"ts_web/elements/00group-input/dees-input-richtext/styles.ts": 22,
|
|
70
|
-
"ts_web/elements/00group-input/dees-input-tags/dees-input-tags.ts":
|
|
70
|
+
"ts_web/elements/00group-input/dees-input-tags/dees-input-tags.ts": 7,
|
|
71
71
|
"ts_web/elements/00group-input/dees-input-typelist/dees-input-typelist.ts": 8,
|
|
72
72
|
"ts_web/elements/00group-input/dees-input-wysiwyg/blocks/block.styles.ts": 4,
|
|
73
73
|
"ts_web/elements/00group-input/dees-input-wysiwyg/blocks/content/divider.block.ts": 2,
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@design.estate/dees-catalog',
|
|
6
|
-
version: '24.
|
|
6
|
+
version: '24.5.0',
|
|
7
7
|
description: 'A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.'
|
|
8
8
|
}
|
|
@@ -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
|
})}
|