@design.estate/dees-catalog 23.2.0 → 23.4.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 +3033 -2785
- package/dist_bundle/bundle.js.map +1 -1
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-T6MJ73SK.js → chunk-6M55MVYH.js} +3 -3
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-I4IO5H5N.js → chunk-CM67HGUE.js} +2 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-74TRVA7N.js → chunk-QVHO2EIW.js} +3 -3
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-74TRVA7N.js.map → chunk-QVHO2EIW.js.map} +1 -1
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{de-OOMCZNLC.js → de-ZWMPLB5K.js} +3 -3
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-ZWMPLB5K.js.map +1 -0
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-HUKGQIM3.js → dees-modal-75MIWWY2.js} +3 -3
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-OISBUFI7.js → dees-workspace-terminal-6V4DLJS3.js} +4 -4
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/dist_ts_web/contextmenu.d.ts +7 -0
- package/dist_ts_web/contextmenu.js +8 -0
- package/dist_ts_web/elements/00group-harness/dees-harness-composer/dees-harness-composer.d.ts +9 -39
- package/dist_ts_web/elements/00group-harness/dees-harness-composer/dees-harness-composer.js +85 -419
- package/dist_ts_web/elements/00group-input/dees-picker-fold/dees-picker-fold.d.ts +133 -0
- package/dist_ts_web/elements/00group-input/dees-picker-fold/dees-picker-fold.demo.d.ts +1 -0
- package/dist_ts_web/elements/00group-input/dees-picker-fold/dees-picker-fold.demo.js +71 -0
- package/dist_ts_web/elements/00group-input/dees-picker-fold/dees-picker-fold.js +600 -0
- package/dist_ts_web/elements/00group-input/dees-picker-fold/index.d.ts +1 -0
- package/dist_ts_web/elements/00group-input/dees-picker-fold/index.js +2 -0
- package/dist_ts_web/elements/00group-input/index.d.ts +1 -0
- package/dist_ts_web/elements/00group-input/index.js +2 -1
- package/dist_ts_web/i18n/de.d.ts +4 -4
- package/dist_ts_web/i18n/de.js +2 -2
- package/dist_ts_web/i18n/messages.d.ts +4 -4
- package/dist_ts_web/i18n/messages.js +2 -2
- package/package.json +5 -1
- package/readme.md +55 -1
- package/scripts/check-packed-consumer.mjs +8 -1
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/contextmenu.ts +7 -0
- package/ts_web/elements/00group-harness/dees-harness-composer/dees-harness-composer.ts +82 -403
- package/ts_web/elements/00group-input/dees-picker-fold/dees-picker-fold.demo.ts +77 -0
- package/ts_web/elements/00group-input/dees-picker-fold/dees-picker-fold.ts +559 -0
- package/ts_web/elements/00group-input/dees-picker-fold/index.ts +1 -0
- package/ts_web/elements/00group-input/index.ts +1 -0
- package/ts_web/i18n/de.ts +1 -1
- package/ts_web/i18n/messages.ts +1 -1
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-OOMCZNLC.js.map +0 -1
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-T6MJ73SK.js.map → chunk-6M55MVYH.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-I4IO5H5N.js.map → chunk-CM67HGUE.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-HUKGQIM3.js.map → dees-modal-75MIWWY2.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-OISBUFI7.js.map → dees-workspace-terminal-6V4DLJS3.js.map} +0 -0
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeesElement,
|
|
3
|
+
html,
|
|
4
|
+
css,
|
|
5
|
+
customElement,
|
|
6
|
+
type TemplateResult,
|
|
7
|
+
property,
|
|
8
|
+
state,
|
|
9
|
+
cssManager,
|
|
10
|
+
directives,
|
|
11
|
+
} from '@design.estate/dees-element';
|
|
12
|
+
import { demoFunc } from './dees-picker-fold.demo.js';
|
|
13
|
+
import { dcLocalize } from '../../../i18n/localize.js';
|
|
14
|
+
import { themeDefaultStyles } from '../../00theme.js';
|
|
15
|
+
import { DeesInputDropdown } from '../dees-input-dropdown/dees-input-dropdown.js';
|
|
16
|
+
import type { IDropdownOption } from '../dees-input-dropdown/dees-input-dropdown-popup.js';
|
|
17
|
+
import '../../00group-overlay/dees-popover/dees-popover.js';
|
|
18
|
+
import type { DeesPopover } from '../../00group-overlay/dees-popover/dees-popover.js';
|
|
19
|
+
import '../../00group-utility/dees-icon/dees-icon.js';
|
|
20
|
+
|
|
21
|
+
declare global {
|
|
22
|
+
interface HTMLElementTagNameMap {
|
|
23
|
+
'dees-picker-fold': DeesPickerFold;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* When the pickers fold into the button: `'auto'` where they do not fit at their smallest widths,
|
|
29
|
+
* `'always'` for a cell too narrow to hold them.
|
|
30
|
+
*/
|
|
31
|
+
export type TPickerFoldMode = 'auto' | 'always';
|
|
32
|
+
|
|
33
|
+
/** One picker: a dropdown on the row, or under its name in the bubble while folded. */
|
|
34
|
+
export interface IPickerFoldPicker {
|
|
35
|
+
/** Names the picker in `picker-change` and `openPicker()`. */
|
|
36
|
+
key: string;
|
|
37
|
+
/** Its name, shown above it in the bubble; on the row its choice speaks for it. */
|
|
38
|
+
label: string;
|
|
39
|
+
options: IDropdownOption[];
|
|
40
|
+
/** The choice it shows; `null` shows `placeholder`. */
|
|
41
|
+
selectedOption: IDropdownOption | null;
|
|
42
|
+
/** What it says while nothing is chosen, best the choice it asks for; empty, the dropdown's word. */
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
/** Its smallest width on the row in px: the row lays it out from it, and the fold decides from it. */
|
|
45
|
+
minWidth: number;
|
|
46
|
+
/** Its widest on the row in px; absent, it grows into what the row leaves. */
|
|
47
|
+
maxWidth?: number;
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
/** A line under it in the bubble, such as why it cannot be chosen now. */
|
|
50
|
+
description?: string;
|
|
51
|
+
/** Whether its list has a search field; the dropdown's default (on) when absent. */
|
|
52
|
+
enableSearch?: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface IPickerFoldChangeDetail {
|
|
56
|
+
key: string;
|
|
57
|
+
option: IDropdownOption;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Where the focus was when the pickers folded or unfolded, so it lands on what stands in for it. */
|
|
61
|
+
type TFoldFocus = { on: 'button' } | { on: 'picker'; key: string };
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Pickers that fold into one button where they do not fit: a row of dropdowns, each at least its
|
|
65
|
+
* `minWidth`, and where they do not fit beside the other items of their row, one button that says
|
|
66
|
+
* the choices and opens the same dropdowns, one under another with their names, in a speech bubble
|
|
67
|
+
* (`dees-popover`). `fold="always"` keeps them folded, for a cell too narrow to hold them.
|
|
68
|
+
*
|
|
69
|
+
* It is controlled: a choice emits `picker-change` with the picker's `key` and the option, and the
|
|
70
|
+
* pickers show what the host passes in `pickers` again, so a host that refuses a choice passes its
|
|
71
|
+
* own again (new option objects) and the dropdown shows it. The control takes its row's free space;
|
|
72
|
+
* the fold reads the row's other items, never its own content, so it never flips back and forth.
|
|
73
|
+
*/
|
|
74
|
+
@customElement('dees-picker-fold')
|
|
75
|
+
export class DeesPickerFold extends DeesElement {
|
|
76
|
+
public static demo = demoFunc;
|
|
77
|
+
public static demoGroups = ['Input'];
|
|
78
|
+
|
|
79
|
+
private readonly t = dcLocalize(this);
|
|
80
|
+
|
|
81
|
+
/** The pickers, in row order. */
|
|
82
|
+
@property({ attribute: false })
|
|
83
|
+
accessor pickers: IPickerFoldPicker[] = [];
|
|
84
|
+
|
|
85
|
+
/** `'auto'` folds where the pickers do not fit, `'always'` keeps them folded. */
|
|
86
|
+
@property({ reflect: true })
|
|
87
|
+
accessor fold: TPickerFoldMode = 'auto';
|
|
88
|
+
|
|
89
|
+
/** What the pickers set, as "Model settings": the bubble's name, and with the summary the button's. */
|
|
90
|
+
@property({ reflect: true })
|
|
91
|
+
accessor label: string = '';
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* What the folded button says. Empty, every picker's choice joined with " · ", where the primary
|
|
95
|
+
* picker's gives way first on a tight button.
|
|
96
|
+
*/
|
|
97
|
+
@property({ reflect: true })
|
|
98
|
+
accessor summary: string = '';
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The key of the picker the button speaks for: its choice gives way first in the summary, the
|
|
102
|
+
* focus lands on it when the pickers unfold from the button, and `openPicker()` opens it. Empty,
|
|
103
|
+
* the first picker.
|
|
104
|
+
*/
|
|
105
|
+
@property({ reflect: true })
|
|
106
|
+
accessor primary: string = '';
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Something wrong with the choices, such as a saved choice no longer offered: the folded button
|
|
110
|
+
* takes the warning tone and says it in its tooltip and description. Empty, none.
|
|
111
|
+
*/
|
|
112
|
+
@property({ reflect: true })
|
|
113
|
+
accessor warning: string = '';
|
|
114
|
+
|
|
115
|
+
@property({ type: Boolean, reflect: true })
|
|
116
|
+
accessor disabled: boolean = false;
|
|
117
|
+
|
|
118
|
+
/** Whether the button stands in for the pickers now. Read it; the control sets it. */
|
|
119
|
+
@state()
|
|
120
|
+
accessor folded: boolean = false;
|
|
121
|
+
|
|
122
|
+
/** The bubble shows. */
|
|
123
|
+
@state()
|
|
124
|
+
private accessor bubbleOpen: boolean = false;
|
|
125
|
+
|
|
126
|
+
/** Watches the control's width; set while it is in the page. */
|
|
127
|
+
private sizeObserver: ResizeObserver | undefined;
|
|
128
|
+
|
|
129
|
+
private focusBeforeFold: TFoldFocus | undefined;
|
|
130
|
+
|
|
131
|
+
/** The smallest widths the last fit read, so a host's render that keeps them fits nothing again. */
|
|
132
|
+
private fittedWidths = '';
|
|
133
|
+
|
|
134
|
+
constructor() {
|
|
135
|
+
super();
|
|
136
|
+
this.registerStartupFunction(async (signal) => {
|
|
137
|
+
await this.updateComplete;
|
|
138
|
+
if (signal.aborted) return;
|
|
139
|
+
const sizer = this.shadowRoot?.querySelector('.sizer');
|
|
140
|
+
this.sizeObserver = new ResizeObserver(() => this.fit());
|
|
141
|
+
if (sizer) this.sizeObserver.observe(sizer);
|
|
142
|
+
signal.addEventListener('abort', () => {
|
|
143
|
+
this.sizeObserver?.disconnect();
|
|
144
|
+
this.sizeObserver = undefined;
|
|
145
|
+
}, { once: true });
|
|
146
|
+
// A web font that arrives later sets the row's items wider or narrower.
|
|
147
|
+
document.fonts.addEventListener('loadingdone', () => this.fit(), { signal });
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public static styles = [
|
|
152
|
+
themeDefaultStyles,
|
|
153
|
+
cssManager.defaultStyles,
|
|
154
|
+
css`
|
|
155
|
+
:host {
|
|
156
|
+
position: relative;
|
|
157
|
+
display: flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
min-width: 0;
|
|
160
|
+
font-family: var(--dees-font-family);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/*
|
|
164
|
+
* In a row it takes the free space, and no less than the folded button at its smallest (its
|
|
165
|
+
* padding and two icons), whether folded or not: what it takes never depends on the fold.
|
|
166
|
+
*/
|
|
167
|
+
:host([fold='auto']) {
|
|
168
|
+
flex: 1 1 0;
|
|
169
|
+
min-width: calc(2 * var(--dees-spacing-sm) + 2 * var(--dees-icon-size-sm) + 2 * var(--dees-spacing-xs));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/*
|
|
173
|
+
* As wide as the control and never taller: the fold reads its width. The control itself is not
|
|
174
|
+
* observed, since a fold may change its height while the observer delivers.
|
|
175
|
+
*/
|
|
176
|
+
.sizer {
|
|
177
|
+
position: absolute;
|
|
178
|
+
inset-inline: 0;
|
|
179
|
+
top: 0;
|
|
180
|
+
height: 0;
|
|
181
|
+
pointer-events: none;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.foldPickers {
|
|
185
|
+
display: flex;
|
|
186
|
+
gap: var(--dees-spacing-xs);
|
|
187
|
+
flex: 1 1 auto;
|
|
188
|
+
min-width: 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/*
|
|
192
|
+
* The pickers size from their widths, never from their labels (inline-size containment): a long
|
|
193
|
+
* label truncates instead of asking the row for room.
|
|
194
|
+
*/
|
|
195
|
+
.foldPickers > dees-input-dropdown {
|
|
196
|
+
margin: 0;
|
|
197
|
+
flex: 1 1 var(--picker-min-width);
|
|
198
|
+
min-width: var(--picker-min-width);
|
|
199
|
+
max-width: var(--picker-max-width, none);
|
|
200
|
+
contain: inline-size;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/*
|
|
204
|
+
* The button stands in for the pickers and looks like them: the field's height, fill and
|
|
205
|
+
* border, which a host sets for both through the dropdown's own custom properties.
|
|
206
|
+
*/
|
|
207
|
+
.foldButton {
|
|
208
|
+
display: inline-flex;
|
|
209
|
+
align-items: center;
|
|
210
|
+
gap: var(--dees-spacing-xs);
|
|
211
|
+
box-sizing: border-box;
|
|
212
|
+
height: var(--dees-input-control-height, var(--dees-control-height-lg));
|
|
213
|
+
padding: 0 var(--dees-spacing-sm);
|
|
214
|
+
border: 0;
|
|
215
|
+
border-radius: var(--dees-radius-lg);
|
|
216
|
+
corner-shape: var(--dees-corner-shape);
|
|
217
|
+
background: var(--dees-input-control-bg, var(--dees-color-control-bg));
|
|
218
|
+
box-shadow: inset 0 0 0 var(--dees-line-width-hairline) var(--dees-input-control-border, var(--dees-color-control-border));
|
|
219
|
+
color: var(--dees-color-text-primary);
|
|
220
|
+
cursor: pointer;
|
|
221
|
+
font-family: inherit;
|
|
222
|
+
font-size: var(--dees-font-control-size);
|
|
223
|
+
transition: background var(--dees-transition-fast) var(--dees-ease-standard);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* Folded on a row, it takes the room the row has left, up to the primary picker's widest. */
|
|
227
|
+
:host([fold='auto']) .foldButton {
|
|
228
|
+
flex: 1 1 0;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Always folded, it is as wide as what it says, and gives way to the control's width. */
|
|
232
|
+
:host([fold='always']) .foldButton {
|
|
233
|
+
flex: 0 1 auto;
|
|
234
|
+
min-width: 0;
|
|
235
|
+
max-width: 100%;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.foldButton dees-icon {
|
|
239
|
+
flex: 0 0 auto;
|
|
240
|
+
color: var(--dees-color-text-secondary);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.foldSummary {
|
|
244
|
+
display: flex;
|
|
245
|
+
min-width: 0;
|
|
246
|
+
overflow: hidden;
|
|
247
|
+
text-align: start;
|
|
248
|
+
white-space: nowrap;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/* No width of its own on a row, so the button's smallest width is its icons and padding. */
|
|
252
|
+
:host([fold='auto']) .foldSummary {
|
|
253
|
+
flex: 1 1 auto;
|
|
254
|
+
width: 0;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
:host([fold='always']) .foldSummary {
|
|
258
|
+
flex: 0 1 auto;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* Kept as written, so the space before a " · " survives at the start of its part. */
|
|
262
|
+
.summaryPart {
|
|
263
|
+
flex: none;
|
|
264
|
+
white-space: pre;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/* The primary picker's choice gives way first. */
|
|
268
|
+
.summaryPart.primary {
|
|
269
|
+
flex: 0 1 auto;
|
|
270
|
+
min-width: 0;
|
|
271
|
+
overflow: hidden;
|
|
272
|
+
text-overflow: ellipsis;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.foldButton:hover:not(:disabled) {
|
|
276
|
+
background: var(--dees-color-fill-secondary);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.foldButton:focus-visible {
|
|
280
|
+
outline: var(--dees-line-width-focus-ring) solid var(--dees-color-focus-ring);
|
|
281
|
+
outline-offset: 2px;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.foldButton:disabled {
|
|
285
|
+
cursor: default;
|
|
286
|
+
opacity: 0.5;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.foldButton.warning {
|
|
290
|
+
box-shadow: inset 0 0 0 var(--dees-line-width-hairline) var(--dees-color-accent-warning);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.foldButton.warning .warningIcon {
|
|
294
|
+
color: var(--dees-color-text-warning);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
@media (prefers-reduced-motion: reduce) {
|
|
298
|
+
.foldButton { transition: none; }
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/*
|
|
302
|
+
* The bubble's pickers, one under another with their names, at the panel's padding. The bubble
|
|
303
|
+
* is a surface of its own: its fields take the catalog's look, whatever a host gave the row's.
|
|
304
|
+
*/
|
|
305
|
+
.bubblePickers {
|
|
306
|
+
display: grid;
|
|
307
|
+
gap: var(--dees-spacing-md);
|
|
308
|
+
padding: var(--dees-spacing-lg);
|
|
309
|
+
--dees-input-control-height: initial;
|
|
310
|
+
--dees-input-control-bg: initial;
|
|
311
|
+
--dees-input-control-border: initial;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.bubblePickers dees-input-dropdown {
|
|
315
|
+
margin: 0;
|
|
316
|
+
}
|
|
317
|
+
`,
|
|
318
|
+
];
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Focuses a picker and opens its list: the primary one, or the one `keyArg` names. Folded, it
|
|
322
|
+
* opens the bubble first, where the list can anchor. False when there is no such picker or it is
|
|
323
|
+
* disabled.
|
|
324
|
+
*/
|
|
325
|
+
public async openPicker(keyArg?: string): Promise<boolean> {
|
|
326
|
+
await this.updateComplete;
|
|
327
|
+
const picker = keyArg === undefined ? this.primaryPicker : this.pickers.find((candidate) => candidate.key === keyArg);
|
|
328
|
+
if (!picker || this.disabled) return false;
|
|
329
|
+
if (this.folded && !this.bubbleOpen) {
|
|
330
|
+
this.bubbleOpen = true;
|
|
331
|
+
await this.updateComplete;
|
|
332
|
+
await this.bubble?.updateComplete;
|
|
333
|
+
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
|
|
334
|
+
if (!this.bubbleOpen) return false;
|
|
335
|
+
}
|
|
336
|
+
const dropdown = this.dropdownOf(picker.key);
|
|
337
|
+
if (!dropdown || dropdown.disabled) return false;
|
|
338
|
+
dropdown.focus();
|
|
339
|
+
if (!dropdown.isOpened) await dropdown.toggleSelectionBox();
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
public willUpdate(changedProperties: Map<PropertyKey, unknown>): void {
|
|
344
|
+
super.willUpdate(changedProperties);
|
|
345
|
+
if (!this.pickers.length) this.folded = false;
|
|
346
|
+
else if (this.fold === 'always') this.folded = true;
|
|
347
|
+
if (changedProperties.has('folded') && changedProperties.get('folded') !== undefined) {
|
|
348
|
+
this.focusBeforeFold = this.focusedPart;
|
|
349
|
+
// Unfolded, the pickers are back on the row: the bubble that held them has nothing to show.
|
|
350
|
+
if (!this.folded) this.bubbleOpen = false;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
public updated(changedProperties: Map<PropertyKey, unknown>): void {
|
|
355
|
+
super.updated(changedProperties);
|
|
356
|
+
// Pickers added or removed change what the row needs without a size the observer sees.
|
|
357
|
+
const widths = this.pickers.map((picker) => picker.minWidth).join(',');
|
|
358
|
+
if (widths !== this.fittedWidths || changedProperties.has('fold')) {
|
|
359
|
+
this.fittedWidths = widths;
|
|
360
|
+
queueMicrotask(() => this.fit());
|
|
361
|
+
}
|
|
362
|
+
const bubble = this.bubble;
|
|
363
|
+
const button = this.shadowRoot?.querySelector<HTMLElement>('.foldButton') ?? null;
|
|
364
|
+
if (bubble && bubble.anchor !== button) bubble.anchor = button;
|
|
365
|
+
if (this.focusBeforeFold) this.refocusAfterFold(this.focusBeforeFold);
|
|
366
|
+
this.focusBeforeFold = undefined;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
public render(): TemplateResult {
|
|
370
|
+
return html`
|
|
371
|
+
<div class="sizer" aria-hidden="true"></div>
|
|
372
|
+
${this.pickers.length
|
|
373
|
+
? this.folded
|
|
374
|
+
? this.renderButton()
|
|
375
|
+
: html`<div class="foldPickers">${this.renderPickers(false)}</div>`
|
|
376
|
+
: ''}
|
|
377
|
+
${this.pickers.length ? html`
|
|
378
|
+
<!--
|
|
379
|
+
Rendered, closed, whenever there are pickers: a fold only moves them in. A bubble made by a
|
|
380
|
+
fold would start observing its content while the fold's own observer delivers.
|
|
381
|
+
-->
|
|
382
|
+
<dees-popover
|
|
383
|
+
class="foldBubble"
|
|
384
|
+
.label=${this.label}
|
|
385
|
+
.open=${this.folded && this.bubbleOpen}
|
|
386
|
+
.dismissOnTab=${false}
|
|
387
|
+
@dees-popover-close=${this.closeBubble}
|
|
388
|
+
><div class="bubblePickers">${this.folded ? this.renderPickers(true) : ''}</div></dees-popover>
|
|
389
|
+
` : ''}
|
|
390
|
+
`;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* The pickers: on the row, or one under another with their names in the bubble while folded.
|
|
395
|
+
* Either way they are the same dropdowns, with the same choices and the same event.
|
|
396
|
+
*/
|
|
397
|
+
private renderPickers(stackedArg: boolean): TemplateResult {
|
|
398
|
+
return html`${directives.repeat(this.pickers, (picker) => picker.key, (picker) => html`
|
|
399
|
+
<dees-input-dropdown
|
|
400
|
+
data-key=${picker.key}
|
|
401
|
+
style=${stackedArg ? '' : `--picker-min-width: ${picker.minWidth}px;${picker.maxWidth === undefined ? '' : ` --picker-max-width: ${picker.maxWidth}px;`}`}
|
|
402
|
+
.label=${stackedArg ? picker.label : undefined}
|
|
403
|
+
.description=${stackedArg ? picker.description : undefined}
|
|
404
|
+
placeholder=${picker.placeholder ?? ''}
|
|
405
|
+
.options=${picker.options}
|
|
406
|
+
.selectedOption=${picker.selectedOption}
|
|
407
|
+
.enableSearch=${picker.enableSearch ?? true}
|
|
408
|
+
.disabled=${this.disabled || picker.disabled === true}
|
|
409
|
+
@selectedOption=${(eventArg: CustomEvent<IDropdownOption>) => this.choose(picker.key, eventArg.detail)}
|
|
410
|
+
></dees-input-dropdown>
|
|
411
|
+
`)}`;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** The button that stands in for the folded pickers: it says their choices and opens them. */
|
|
415
|
+
private renderButton(): TemplateResult {
|
|
416
|
+
const parts = this.summaryParts;
|
|
417
|
+
const said = parts.map((part) => part.text).join(' · ');
|
|
418
|
+
const primaryWidth = this.primaryPicker?.maxWidth;
|
|
419
|
+
return html`
|
|
420
|
+
<button
|
|
421
|
+
class="foldButton ${this.warning ? 'warning' : ''}"
|
|
422
|
+
type="button"
|
|
423
|
+
style=${this.fold === 'auto' && primaryWidth ? `max-width: ${primaryWidth}px` : ''}
|
|
424
|
+
aria-label=${this.label ? this.t('pickerFold.named', { label: this.label, value: said }) : said}
|
|
425
|
+
title=${[this.details, this.warning].filter(Boolean).join('\n')}
|
|
426
|
+
.ariaHasPopup=${'dialog'}
|
|
427
|
+
.ariaDescription=${this.warning || null}
|
|
428
|
+
?disabled=${this.disabled}
|
|
429
|
+
@click=${() => {
|
|
430
|
+
if (this.bubbleOpen) this.closeBubble();
|
|
431
|
+
else this.bubbleOpen = true;
|
|
432
|
+
}}
|
|
433
|
+
>
|
|
434
|
+
${this.warning
|
|
435
|
+
? html`<dees-icon class="warningIcon" icon="lucide:TriangleAlert" iconSize="14" aria-hidden="true"></dees-icon>`
|
|
436
|
+
: html`<dees-icon icon="lucide:SlidersHorizontal" iconSize="14" aria-hidden="true"></dees-icon>`}
|
|
437
|
+
<span class="foldSummary">${parts.map((part, index) => html`<span
|
|
438
|
+
class="summaryPart ${part.primary ? 'primary' : ''}">${index ? ` · ${part.text}` : part.text}</span>`)}</span>
|
|
439
|
+
<dees-icon icon="lucide:ChevronDown" iconSize="14" aria-hidden="true"></dees-icon>
|
|
440
|
+
</button>
|
|
441
|
+
`;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
private choose(keyArg: string, optionArg: IDropdownOption | undefined): void {
|
|
445
|
+
if (this.disabled || !optionArg) return;
|
|
446
|
+
this.dispatchEvent(new CustomEvent<IPickerFoldChangeDetail>('picker-change', {
|
|
447
|
+
detail: { key: keyArg, option: optionArg },
|
|
448
|
+
bubbles: true,
|
|
449
|
+
}));
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** The bubble closed: the pickers it held may fit on the row again. */
|
|
453
|
+
private closeBubble = (): void => {
|
|
454
|
+
this.bubbleOpen = false;
|
|
455
|
+
queueMicrotask(() => this.fit());
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
private get primaryPicker(): IPickerFoldPicker | undefined {
|
|
459
|
+
return this.pickers.find((picker) => picker.key === this.primary) ?? this.pickers[0];
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/** What a picker shows: its choice, else what it asks for. */
|
|
463
|
+
private choiceOf(pickerArg: IPickerFoldPicker): string {
|
|
464
|
+
return pickerArg.selectedOption?.option || pickerArg.placeholder || this.t('dropdown.placeholder');
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/** What the button says: the host's summary, else every choice, the primary one giving way first. */
|
|
468
|
+
private get summaryParts(): Array<{ text: string; primary: boolean }> {
|
|
469
|
+
if (this.summary) return [{ text: this.summary, primary: true }];
|
|
470
|
+
const primary = this.primaryPicker;
|
|
471
|
+
return this.pickers.map((picker) => ({ text: this.choiceOf(picker), primary: picker === primary }));
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/** Every choice the pickers hold, for the button's tooltip. */
|
|
475
|
+
private get details(): string {
|
|
476
|
+
return this.pickers.map((picker) => this.choiceOf(picker)).join(' · ');
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
private get bubble(): DeesPopover | null {
|
|
480
|
+
return this.shadowRoot?.querySelector<DeesPopover>('dees-popover.foldBubble') ?? null;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
private dropdownOf(keyArg: string): DeesInputDropdown | null {
|
|
484
|
+
const dropdown = this.shadowRoot?.querySelector(`dees-input-dropdown[data-key="${CSS.escape(keyArg)}"]`);
|
|
485
|
+
return dropdown instanceof DeesInputDropdown ? dropdown : null;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* The width the pickers have. Among the items of a flex row it is the row's width less the other
|
|
490
|
+
* items at their widths and the gaps between them, whichever line they wrapped onto; anywhere else,
|
|
491
|
+
* the control's own width. Undefined while nothing is laid out.
|
|
492
|
+
*/
|
|
493
|
+
private get room(): number | undefined {
|
|
494
|
+
const row = this.parentElement;
|
|
495
|
+
const rowStyle = row ? getComputedStyle(row) : undefined;
|
|
496
|
+
if (!row || !rowStyle?.display.includes('flex') || rowStyle.flexDirection.startsWith('column')) {
|
|
497
|
+
return this.clientWidth || undefined;
|
|
498
|
+
}
|
|
499
|
+
const available = row.clientWidth - parseFloat(rowStyle.paddingLeft) - parseFloat(rowStyle.paddingRight);
|
|
500
|
+
if (!(available > 0)) return undefined;
|
|
501
|
+
const others = Array.from(row.children).filter((child) => {
|
|
502
|
+
if (child === this) return false;
|
|
503
|
+
const style = getComputedStyle(child);
|
|
504
|
+
return style.display !== 'none' && style.position !== 'absolute' && style.position !== 'fixed';
|
|
505
|
+
});
|
|
506
|
+
// A shrunk item still asks for its whole width.
|
|
507
|
+
const widthOf = (elementArg: Element): number => Math.max(elementArg.getBoundingClientRect().width, elementArg.scrollWidth);
|
|
508
|
+
const gap = parseFloat(rowStyle.columnGap) || 0;
|
|
509
|
+
return available - others.reduce((sum, other) => sum + widthOf(other), 0) - others.length * gap;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Folds the pickers into the button when they do not fit at their smallest widths. Nothing it
|
|
514
|
+
* reads changes with the answer, so the row never flips back and forth.
|
|
515
|
+
*/
|
|
516
|
+
private fit(): void {
|
|
517
|
+
const widths = this.pickers.map((picker) => picker.minWidth);
|
|
518
|
+
if (!widths.length) {
|
|
519
|
+
this.folded = false;
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
if (this.fold === 'always') {
|
|
523
|
+
this.folded = true;
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
const room = this.room;
|
|
527
|
+
// Not laid out (hidden, or not yet in the page): nothing to fit.
|
|
528
|
+
if (room === undefined) return;
|
|
529
|
+
// An open bubble keeps its pickers until it closes, so nothing moves under the reader; closing it
|
|
530
|
+
// here, in the observer's delivery, would also resize what the bubble's own observers watch.
|
|
531
|
+
if (this.folded && this.bubbleOpen) return;
|
|
532
|
+
const gap = parseFloat(getComputedStyle(this).getPropertyValue('--dees-spacing-xs')) || 0;
|
|
533
|
+
const needed = widths.reduce((sum, width) => sum + width, 0) + (widths.length - 1) * gap;
|
|
534
|
+
this.folded = needed > room + 0.5;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/** The picker, or the button, the focus is on. */
|
|
538
|
+
private get focusedPart(): TFoldFocus | undefined {
|
|
539
|
+
const active = this.shadowRoot?.activeElement;
|
|
540
|
+
if (!active) return undefined;
|
|
541
|
+
if (active.classList.contains('foldButton')) return { on: 'button' };
|
|
542
|
+
if (active instanceof DeesInputDropdown && active.dataset.key !== undefined) return { on: 'picker', key: active.dataset.key };
|
|
543
|
+
return undefined;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/** A fold took the focused control away: the focus goes to what stands in for it. */
|
|
547
|
+
private refocusAfterFold(fromArg: TFoldFocus): void {
|
|
548
|
+
const root = this.shadowRoot;
|
|
549
|
+
if (this.folded) {
|
|
550
|
+
root?.querySelector<HTMLElement>('.foldButton')?.focus();
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
// The button, or a picker in the bubble, went away: the row's picker takes the focus.
|
|
554
|
+
const key = fromArg.on === 'picker' ? fromArg.key : this.primaryPicker?.key;
|
|
555
|
+
const picker = (key !== undefined ? root?.querySelector<HTMLElement>(`.foldPickers > [data-key="${CSS.escape(key)}"]`) : null)
|
|
556
|
+
?? root?.querySelector<HTMLElement>('.foldPickers > dees-input-dropdown');
|
|
557
|
+
picker?.focus();
|
|
558
|
+
}
|
|
559
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dees-picker-fold.js';
|
package/ts_web/i18n/de.ts
CHANGED
|
@@ -400,6 +400,7 @@ export default dcMessages.translation('de', {
|
|
|
400
400
|
'dropdown.empty': 'Keine Optionen gefunden',
|
|
401
401
|
'dropdown.searchFailed': 'Die Suche ist fehlgeschlagen. Versuchen Sie es erneut.',
|
|
402
402
|
'dropdown.placeholder': 'Option auswählen',
|
|
403
|
+
'pickerFold.named': '{label}: {value}',
|
|
403
404
|
|
|
404
405
|
// dees-input-fileupload
|
|
405
406
|
'fileupload.multiple': 'Mehrere Dateien möglich',
|
|
@@ -1284,7 +1285,6 @@ export default dcMessages.translation('de', {
|
|
|
1284
1285
|
'composer.model': 'Modell',
|
|
1285
1286
|
'composer.effort': 'Denkaufwand',
|
|
1286
1287
|
'composer.modelSettings': 'Modelleinstellungen',
|
|
1287
|
-
'composer.modelSettingsNamed': 'Modelleinstellungen: {value}',
|
|
1288
1288
|
'composer.queued': '{count, number} in der Warteschlange',
|
|
1289
1289
|
'composer.stopRun': 'Aktuellen Lauf stoppen',
|
|
1290
1290
|
'composer.stopUnavailable': 'Stoppen ist nicht verfügbar.',
|
package/ts_web/i18n/messages.ts
CHANGED
|
@@ -426,6 +426,7 @@ export const dcMessages = plugins.smarti18n.defineCatalog({
|
|
|
426
426
|
'dropdown.empty': { message: 'No options found', description: 'Said when no option matches.' },
|
|
427
427
|
'dropdown.searchFailed': { message: 'Search failed. Try again.', description: 'Said when a remote search failed for a reason nobody named.' },
|
|
428
428
|
'dropdown.placeholder': { message: 'Select an option', description: 'The dropdown while nothing is chosen.' },
|
|
429
|
+
'pickerFold.named': { message: '{label}: {value}', description: 'The name of the button that stands in for folded pickers; {label} is what the pickers set ("Model settings"), {value} what the button shows.' },
|
|
429
430
|
|
|
430
431
|
// dees-input-fileupload
|
|
431
432
|
'fileupload.multiple': { message: 'Multiple files supported', description: 'A hint: the field takes several files.' },
|
|
@@ -1342,7 +1343,6 @@ export const dcMessages = plugins.smarti18n.defineCatalog({
|
|
|
1342
1343
|
'composer.model': { message: 'Model', description: 'The model select\'s name in the model settings popover.' },
|
|
1343
1344
|
'composer.effort': { message: 'Reasoning effort', description: 'The reasoning effort select\'s name in the model settings popover.' },
|
|
1344
1345
|
'composer.modelSettings': { message: 'Model settings', description: 'The popover that holds the account, model and effort selects when they do not fit beside the other controls (its name).' },
|
|
1345
|
-
'composer.modelSettingsNamed': { message: 'Model settings: {value}', description: 'The name of the button that opens that popover; {value} is what the button shows, the model or the first choice still to make.' },
|
|
1346
1346
|
'composer.queued': { message: '{count, number} queued', description: 'The number of messages waiting to be sent.' },
|
|
1347
1347
|
'composer.stopRun': { message: 'Stop current run', description: 'The stop button\'s name and tooltip.' },
|
|
1348
1348
|
'composer.stopUnavailable': { message: 'Stopping is unavailable.', description: 'Why the stop button is disabled, while the host names no reason.' },
|