occulite-ui 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +290 -2
- package/THIRD_PARTY_NOTICES.md +36 -0
- package/dist/clipboard.d.ts +26 -0
- package/dist/clipboard.js +70 -0
- package/dist/components/ContextMenu.svelte +158 -0
- package/dist/components/ContextMenu.svelte.d.ts +14 -0
- package/dist/components/DataTable.svelte +1990 -0
- package/dist/components/DataTable.svelte.d.ts +154 -0
- package/dist/components/Dialog.svelte +420 -0
- package/dist/components/Dialog.svelte.d.ts +55 -0
- package/dist/components/GithubLink.svelte +74 -0
- package/dist/components/GithubLink.svelte.d.ts +16 -0
- package/dist/components/Header.svelte +196 -0
- package/dist/components/Header.svelte.d.ts +42 -0
- package/dist/components/Icon.svelte +51 -0
- package/dist/components/Icon.svelte.d.ts +12 -0
- package/dist/components/LanguageSwitch.svelte +63 -0
- package/dist/components/LanguageSwitch.svelte.d.ts +17 -0
- package/dist/components/Loader.svelte +65 -0
- package/dist/components/Loader.svelte.d.ts +9 -0
- package/dist/components/MultiSelect.svelte +467 -0
- package/dist/components/MultiSelect.svelte.d.ts +28 -0
- package/dist/components/Notices.svelte +146 -0
- package/dist/components/Notices.svelte.d.ts +16 -0
- package/dist/components/PrimaryToolbarButton.svelte +189 -0
- package/dist/components/PrimaryToolbarButton.svelte.d.ts +34 -0
- package/dist/components/Tabs.svelte +118 -0
- package/dist/components/Tabs.svelte.d.ts +16 -0
- package/dist/components/ThemeSwitch.svelte +46 -0
- package/dist/components/ThemeSwitch.svelte.d.ts +11 -0
- package/dist/components/Toolbar.svelte +57 -0
- package/dist/components/Toolbar.svelte.d.ts +11 -0
- package/dist/components/ToolbarButton.svelte +126 -0
- package/dist/components/ToolbarButton.svelte.d.ts +22 -0
- package/dist/components/Tooltip.svelte +106 -0
- package/dist/components/Tooltip.svelte.d.ts +31 -0
- package/dist/components/TooltipBubble.svelte +65 -0
- package/dist/components/TooltipBubble.svelte.d.ts +18 -0
- package/dist/components/contextMenu.d.ts +19 -0
- package/dist/components/contextMenu.js +6 -0
- package/dist/components/dialogGeometry.d.ts +91 -0
- package/dist/components/dialogGeometry.js +140 -0
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +22 -0
- package/dist/components/multiSelect.d.ts +27 -0
- package/dist/components/multiSelect.js +26 -0
- package/dist/components/navigation.d.ts +34 -0
- package/dist/components/navigation.js +19 -0
- package/dist/components/tooltip.d.ts +29 -0
- package/dist/components/tooltip.js +27 -0
- package/dist/css/app.css +3 -0
- package/dist/css/base.css +84 -0
- package/dist/css/tokens.css +170 -0
- package/dist/dialog/index.d.ts +6 -0
- package/dist/dialog/index.js +6 -0
- package/dist/embedding/ShellEmbedding.svelte.d.ts +27 -0
- package/dist/embedding/ShellEmbedding.svelte.js +79 -0
- package/dist/embedding/constants.d.ts +23 -0
- package/dist/embedding/constants.js +54 -0
- package/dist/embedding/index.d.ts +2 -0
- package/dist/embedding/index.js +2 -0
- package/dist/externalLink.d.ts +15 -0
- package/dist/externalLink.js +20 -0
- package/dist/format.d.ts +6 -0
- package/dist/format.js +16 -0
- package/dist/i18n/i18n.svelte.d.ts +112 -0
- package/dist/i18n/i18n.svelte.js +211 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/messages.d.ts +9 -0
- package/dist/i18n/messages.js +58 -0
- package/dist/i18n/translator.d.ts +65 -0
- package/dist/i18n/translator.js +99 -0
- package/dist/icons/index.d.ts +17 -0
- package/dist/icons/index.js +11 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/notices/NoticesStore.svelte.d.ts +64 -0
- package/dist/notices/NoticesStore.svelte.js +127 -0
- package/dist/notices/index.d.ts +1 -0
- package/dist/notices/index.js +1 -0
- package/dist/storage.d.ts +11 -0
- package/dist/storage.js +27 -0
- package/dist/table/LocalColumnWidths.svelte.d.ts +32 -0
- package/dist/table/LocalColumnWidths.svelte.js +91 -0
- package/dist/table/columnMeasure.d.ts +24 -0
- package/dist/table/columnMeasure.js +82 -0
- package/dist/table/columnWidths.d.ts +60 -0
- package/dist/table/columnWidths.js +86 -0
- package/dist/table/dataTableContext.d.ts +26 -0
- package/dist/table/dataTableContext.js +16 -0
- package/dist/table/index.d.ts +6 -0
- package/dist/table/index.js +6 -0
- package/dist/table/metrics.d.ts +10 -0
- package/dist/table/metrics.js +10 -0
- package/dist/table/tableModel.d.ts +306 -0
- package/dist/table/tableModel.js +437 -0
- package/dist/theme/choices.d.ts +8 -0
- package/dist/theme/choices.js +6 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/theme.svelte.d.ts +60 -0
- package/dist/theme/theme.svelte.js +108 -0
- package/package.json +137 -4
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {t as kitT} from '../i18n/i18n.svelte.js';
|
|
3
|
+
import {filterOptions, step, type MultiSelectOption} from './multiSelect.js';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
options: MultiSelectOption[];
|
|
7
|
+
selected?: string[];
|
|
8
|
+
/** Single selection, which is what the 2.x interface picker used the widget for. */
|
|
9
|
+
multiple?: boolean;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
filterLabel?: string | undefined;
|
|
12
|
+
checkAllLabel?: string | undefined;
|
|
13
|
+
uncheckAllLabel?: string | undefined;
|
|
14
|
+
/** `{count} channels selected` - a message key is not assumed, the caller formats it. */
|
|
15
|
+
summary?: ((selected: string[], options: MultiSelectOption[]) => string) | undefined;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
label?: string | undefined;
|
|
18
|
+
onchange?: ((selected: string[]) => void) | undefined;
|
|
19
|
+
testId?: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The open list takes its place in the page instead of floating over it, so a dialog
|
|
22
|
+
* that is as tall as its content grows while the list is open rather than scrolling it away.
|
|
23
|
+
* The widget's box dissolves into its parent (`display: contents`): the parent is a wrapping
|
|
24
|
+
* flex row, the trigger sits in it with whatever follows, and the list claims a line of its
|
|
25
|
+
* own under them.
|
|
26
|
+
*/
|
|
27
|
+
inline?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let {
|
|
31
|
+
options,
|
|
32
|
+
selected = $bindable([]),
|
|
33
|
+
multiple = true,
|
|
34
|
+
placeholder = '',
|
|
35
|
+
filterLabel: filterLabelProp = undefined,
|
|
36
|
+
checkAllLabel: checkAllLabelProp = undefined,
|
|
37
|
+
uncheckAllLabel: uncheckAllLabelProp = undefined,
|
|
38
|
+
summary = undefined,
|
|
39
|
+
disabled = false,
|
|
40
|
+
label = undefined,
|
|
41
|
+
onchange = undefined,
|
|
42
|
+
testId = undefined,
|
|
43
|
+
inline = false,
|
|
44
|
+
}: Props = $props();
|
|
45
|
+
|
|
46
|
+
// the kit's catalogue, read reactively: a language switch re-renders it
|
|
47
|
+
const filterLabel = $derived(filterLabelProp ?? kitT('Filter'));
|
|
48
|
+
const checkAllLabel = $derived(checkAllLabelProp ?? kitT('Check all'));
|
|
49
|
+
const uncheckAllLabel = $derived(uncheckAllLabelProp ?? kitT('Uncheck all'));
|
|
50
|
+
|
|
51
|
+
let open = $state(false);
|
|
52
|
+
let filter = $state('');
|
|
53
|
+
let root = $state<HTMLDivElement | undefined>(undefined);
|
|
54
|
+
let trigger = $state<HTMLButtonElement | undefined>(undefined);
|
|
55
|
+
let list = $state<HTMLUListElement | undefined>(undefined);
|
|
56
|
+
// the keyboard's row (openccu-lite's port of this widget brought it back, one kit): ↑/↓ move
|
|
57
|
+
// it, Enter chooses it, aria-activedescendant names it
|
|
58
|
+
let highlight = $state(0);
|
|
59
|
+
const uid = `hmm-multiselect-${Math.random().toString(36).slice(2, 8)}`;
|
|
60
|
+
|
|
61
|
+
const selectedSet = $derived(new Set(selected));
|
|
62
|
+
const shown = $derived(filterOptions(options, filter));
|
|
63
|
+
const activeId = $derived(open && shown[highlight] ? `${uid}-${highlight}` : undefined);
|
|
64
|
+
const buttonText = $derived.by(() => {
|
|
65
|
+
if (selected.length === 0) {
|
|
66
|
+
return placeholder;
|
|
67
|
+
}
|
|
68
|
+
if (summary) {
|
|
69
|
+
return summary(selected, options);
|
|
70
|
+
}
|
|
71
|
+
if (selected.length === 1) {
|
|
72
|
+
return options.find((option) => option.value === selected[0])?.label ?? selected[0] ?? '';
|
|
73
|
+
}
|
|
74
|
+
return `${selected.length}`;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
function apply(next: string[]): void {
|
|
78
|
+
selected = next;
|
|
79
|
+
onchange?.(next);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function show(): void {
|
|
83
|
+
const first = shown.findIndex((option) => selectedSet.has(option.value));
|
|
84
|
+
highlight = first < 0 ? 0 : first;
|
|
85
|
+
open = true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Closes; `refocus` puts the focus back on the trigger (Escape, a choice). */
|
|
89
|
+
function hide(refocus: boolean): void {
|
|
90
|
+
open = false;
|
|
91
|
+
if (refocus) {
|
|
92
|
+
trigger?.focus();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function toggle(option: MultiSelectOption): void {
|
|
97
|
+
if (option.disabled === true) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (!multiple) {
|
|
101
|
+
apply([option.value]);
|
|
102
|
+
hide(true);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
apply(
|
|
106
|
+
selectedSet.has(option.value)
|
|
107
|
+
? selected.filter((value) => value !== option.value)
|
|
108
|
+
: [...selected, option.value],
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function checkAll(): void {
|
|
113
|
+
apply(shown.filter((option) => option.disabled !== true).map((option) => option.value));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function uncheckAll(): void {
|
|
117
|
+
apply([]);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Replaces jquery-ui-multiselect-widget, which is unmaintained since 2018 and was the reason
|
|
122
|
+
* the interface picker and the "which channels do I write to" list needed jQuery UI at all.
|
|
123
|
+
* Same three affordances: a filter box, check all / uncheck all, and a summary on the button.
|
|
124
|
+
*/
|
|
125
|
+
function onWindowPointerDown(event: MouseEvent): void {
|
|
126
|
+
if (open && root && event.target instanceof Node && !root.contains(event.target)) {
|
|
127
|
+
open = false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// the filter narrows the list; the highlight goes back to its top
|
|
132
|
+
$effect(() => {
|
|
133
|
+
void filter;
|
|
134
|
+
highlight = 0;
|
|
135
|
+
});
|
|
136
|
+
// the highlighted row stays in view while the arrow keys walk a long list
|
|
137
|
+
$effect(() => {
|
|
138
|
+
if (!open || !list) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const row = list.querySelector<HTMLElement>(`#${uid}-${highlight}`);
|
|
142
|
+
if (typeof row?.scrollIntoView === 'function') {
|
|
143
|
+
row.scrollIntoView({block: 'nearest'});
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
/** Keys on the filter input: ↑/↓ move the highlight, Enter chooses, Escape closes without
|
|
148
|
+
* choosing and returns the focus to the trigger, Tab closes. */
|
|
149
|
+
function onKey(event: KeyboardEvent): void {
|
|
150
|
+
switch (event.key) {
|
|
151
|
+
case 'ArrowDown':
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
highlight = step(shown, highlight, 1);
|
|
154
|
+
break;
|
|
155
|
+
case 'ArrowUp':
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
highlight = step(shown, highlight, -1);
|
|
158
|
+
break;
|
|
159
|
+
case 'Enter': {
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
const option = shown[highlight];
|
|
162
|
+
if (option) {
|
|
163
|
+
toggle(option);
|
|
164
|
+
}
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case 'Escape':
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
event.stopPropagation();
|
|
170
|
+
hide(true);
|
|
171
|
+
break;
|
|
172
|
+
case 'Tab':
|
|
173
|
+
hide(false);
|
|
174
|
+
break;
|
|
175
|
+
default:
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ↓ on the closed trigger opens, as a native select does
|
|
180
|
+
function onTriggerKey(event: KeyboardEvent): void {
|
|
181
|
+
if (!open && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
show();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function onWindowKey(event: KeyboardEvent): void {
|
|
188
|
+
if (event.key === 'Escape' && open) {
|
|
189
|
+
hide(true);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Only an entry that brings a hint or a description is drawn on two lines. */
|
|
194
|
+
function twoLines(option: MultiSelectOption): boolean {
|
|
195
|
+
return Boolean(option.hint) || Boolean(option.description);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function autofocus(element: HTMLInputElement): void {
|
|
199
|
+
element.focus();
|
|
200
|
+
}
|
|
201
|
+
</script>
|
|
202
|
+
|
|
203
|
+
<svelte:window onmousedown={onWindowPointerDown} onkeydown={onWindowKey} />
|
|
204
|
+
|
|
205
|
+
<div class="hmm-multiselect" class:hmm-multiselect-inline={inline} bind:this={root} data-testid={testId}>
|
|
206
|
+
<button
|
|
207
|
+
type="button"
|
|
208
|
+
class="hmm-button hmm-multiselect-button"
|
|
209
|
+
bind:this={trigger}
|
|
210
|
+
aria-haspopup="listbox"
|
|
211
|
+
aria-expanded={open}
|
|
212
|
+
aria-controls={`${uid}-list`}
|
|
213
|
+
aria-label={label}
|
|
214
|
+
{disabled}
|
|
215
|
+
onclick={() => (open ? hide(true) : show())}
|
|
216
|
+
onkeydown={onTriggerKey}
|
|
217
|
+
>
|
|
218
|
+
<span class="hmm-multiselect-text">{buttonText}</span>
|
|
219
|
+
<span class="hmm-multiselect-arrow" aria-hidden="true">▾</span>
|
|
220
|
+
</button>
|
|
221
|
+
|
|
222
|
+
{#if open}
|
|
223
|
+
<div class="hmm-multiselect-menu">
|
|
224
|
+
<div class="hmm-multiselect-head">
|
|
225
|
+
<input
|
|
226
|
+
class="hmm-input hmm-multiselect-filter"
|
|
227
|
+
type="search"
|
|
228
|
+
bind:value={filter}
|
|
229
|
+
placeholder={filterLabel}
|
|
230
|
+
aria-label={filterLabel}
|
|
231
|
+
aria-controls={`${uid}-list`}
|
|
232
|
+
aria-activedescendant={activeId}
|
|
233
|
+
autocomplete="off"
|
|
234
|
+
use:autofocus
|
|
235
|
+
onkeydown={onKey}
|
|
236
|
+
/>
|
|
237
|
+
{#if multiple}
|
|
238
|
+
<button type="button" class="hmm-multiselect-link" onclick={checkAll}>{checkAllLabel}</button>
|
|
239
|
+
<button type="button" class="hmm-multiselect-link" onclick={uncheckAll}>{uncheckAllLabel}</button>
|
|
240
|
+
{/if}
|
|
241
|
+
</div>
|
|
242
|
+
<ul
|
|
243
|
+
class="hmm-multiselect-list"
|
|
244
|
+
role="listbox"
|
|
245
|
+
aria-multiselectable={multiple}
|
|
246
|
+
id={`${uid}-list`}
|
|
247
|
+
aria-label={label}
|
|
248
|
+
bind:this={list}
|
|
249
|
+
>
|
|
250
|
+
{#each shown as option, i (option.value)}
|
|
251
|
+
<li>
|
|
252
|
+
<button
|
|
253
|
+
type="button"
|
|
254
|
+
id={`${uid}-${i}`}
|
|
255
|
+
class="hmm-multiselect-option"
|
|
256
|
+
class:hmm-multiselect-two-lines={twoLines(option)}
|
|
257
|
+
class:hmm-multiselect-selected={selectedSet.has(option.value)}
|
|
258
|
+
class:hmm-multiselect-highlight={i === highlight}
|
|
259
|
+
role="option"
|
|
260
|
+
aria-selected={selectedSet.has(option.value)}
|
|
261
|
+
disabled={option.disabled === true}
|
|
262
|
+
tabindex="-1"
|
|
263
|
+
onmousedown={(event) => event.preventDefault()}
|
|
264
|
+
onmousemove={() => (highlight = i)}
|
|
265
|
+
onclick={() => toggle(option)}
|
|
266
|
+
>
|
|
267
|
+
{#if multiple}
|
|
268
|
+
<span class="hmm-multiselect-check" aria-hidden="true"
|
|
269
|
+
>{selectedSet.has(option.value) ? '☑' : '☐'}</span
|
|
270
|
+
>
|
|
271
|
+
{/if}
|
|
272
|
+
{#if twoLines(option)}
|
|
273
|
+
<span class="hmm-multiselect-lines">
|
|
274
|
+
<span
|
|
275
|
+
class="hmm-multiselect-line"
|
|
276
|
+
title={[option.label, option.hint].filter(Boolean).join(' ')}
|
|
277
|
+
>
|
|
278
|
+
<span class="hmm-multiselect-label">{option.label}</span>
|
|
279
|
+
{#if option.hint}
|
|
280
|
+
<span class="hmm-multiselect-hint">{option.hint}</span>
|
|
281
|
+
{/if}
|
|
282
|
+
</span>
|
|
283
|
+
{#if option.description}
|
|
284
|
+
<span class="hmm-multiselect-description" title={option.description}
|
|
285
|
+
>{option.description}</span
|
|
286
|
+
>
|
|
287
|
+
{/if}
|
|
288
|
+
</span>
|
|
289
|
+
{:else}
|
|
290
|
+
<span>{option.label}</span>
|
|
291
|
+
{/if}
|
|
292
|
+
</button>
|
|
293
|
+
</li>
|
|
294
|
+
{/each}
|
|
295
|
+
{#if shown.length === 0}
|
|
296
|
+
<li class="hmm-multiselect-empty">—</li>
|
|
297
|
+
{/if}
|
|
298
|
+
</ul>
|
|
299
|
+
</div>
|
|
300
|
+
{/if}
|
|
301
|
+
</div>
|
|
302
|
+
|
|
303
|
+
<style>
|
|
304
|
+
.hmm-multiselect {
|
|
305
|
+
position: relative;
|
|
306
|
+
display: inline-block;
|
|
307
|
+
max-width: 100%;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/* The summary can be arbitrarily long (it is a list of names); the button ellipsises it
|
|
311
|
+
instead of widening the row it sits in. */
|
|
312
|
+
.hmm-multiselect-button {
|
|
313
|
+
display: inline-flex;
|
|
314
|
+
align-items: center;
|
|
315
|
+
gap: 6px;
|
|
316
|
+
min-width: 120px;
|
|
317
|
+
max-width: 100%;
|
|
318
|
+
justify-content: space-between;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.hmm-multiselect-text {
|
|
322
|
+
overflow: hidden;
|
|
323
|
+
text-overflow: ellipsis;
|
|
324
|
+
white-space: nowrap;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.hmm-multiselect-menu {
|
|
328
|
+
position: absolute;
|
|
329
|
+
z-index: 50;
|
|
330
|
+
top: calc(100% + 2px);
|
|
331
|
+
left: 0;
|
|
332
|
+
/* a caller whose entries need more room says so through the properties */
|
|
333
|
+
min-width: var(--hmm-multiselect-menu-min-width, 220px);
|
|
334
|
+
max-width: var(--hmm-multiselect-menu-max-width, 360px);
|
|
335
|
+
border: 1px solid var(--hmm-border-strong);
|
|
336
|
+
border-radius: var(--hmm-radius);
|
|
337
|
+
background: var(--hmm-bg);
|
|
338
|
+
box-shadow: var(--hmm-shadow-menu);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/* See the `inline` property. The trigger and the list become items of the parent's
|
|
342
|
+
wrapping flex row; the list comes last and fills a line of its own. */
|
|
343
|
+
.hmm-multiselect-inline {
|
|
344
|
+
display: contents;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.hmm-multiselect-inline .hmm-multiselect-menu {
|
|
348
|
+
position: static;
|
|
349
|
+
order: 1;
|
|
350
|
+
flex: 1 0 100%;
|
|
351
|
+
box-shadow: none;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.hmm-multiselect-head {
|
|
355
|
+
display: flex;
|
|
356
|
+
gap: 4px;
|
|
357
|
+
align-items: center;
|
|
358
|
+
padding: 4px;
|
|
359
|
+
border-bottom: 1px solid var(--hmm-border-muted);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.hmm-multiselect-filter {
|
|
363
|
+
flex: 1 1 auto;
|
|
364
|
+
min-width: 60px;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.hmm-multiselect-link {
|
|
368
|
+
border: none;
|
|
369
|
+
background: none;
|
|
370
|
+
color: var(--hmm-link);
|
|
371
|
+
cursor: pointer;
|
|
372
|
+
text-decoration: underline;
|
|
373
|
+
font-size: var(--hmm-font-size-small);
|
|
374
|
+
padding: 0 2px;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.hmm-multiselect-list {
|
|
378
|
+
list-style: none;
|
|
379
|
+
margin: 0;
|
|
380
|
+
padding: 0;
|
|
381
|
+
/* a dialog with room for more rows says so through the property */
|
|
382
|
+
max-height: var(--hmm-multiselect-list-height, 260px);
|
|
383
|
+
overflow: auto;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.hmm-multiselect-option {
|
|
387
|
+
display: flex;
|
|
388
|
+
gap: 6px;
|
|
389
|
+
align-items: center;
|
|
390
|
+
width: 100%;
|
|
391
|
+
padding: 2px 6px;
|
|
392
|
+
border: none;
|
|
393
|
+
background: none;
|
|
394
|
+
font: inherit;
|
|
395
|
+
text-align: left;
|
|
396
|
+
cursor: pointer;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/* Label and hint on the first line, the description under them. The checkbox stays
|
|
400
|
+
centred on both lines through the row's own `align-items`. Every line is cut with an
|
|
401
|
+
ellipsis rather than wrapped, and the hint gives way before the label does. */
|
|
402
|
+
.hmm-multiselect-two-lines {
|
|
403
|
+
padding: 4px 8px;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.hmm-multiselect-lines {
|
|
407
|
+
display: flex;
|
|
408
|
+
flex-direction: column;
|
|
409
|
+
flex: 1 1 auto;
|
|
410
|
+
min-width: 0;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.hmm-multiselect-line {
|
|
414
|
+
display: flex;
|
|
415
|
+
align-items: baseline;
|
|
416
|
+
gap: 6px;
|
|
417
|
+
min-width: 0;
|
|
418
|
+
white-space: nowrap;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.hmm-multiselect-label {
|
|
422
|
+
flex: 0 1 auto;
|
|
423
|
+
min-width: 0;
|
|
424
|
+
overflow: hidden;
|
|
425
|
+
text-overflow: ellipsis;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/* The hint only gets what the label leaves: a basis of 0 means the channel name is cut only
|
|
429
|
+
when it alone is wider than the line. */
|
|
430
|
+
.hmm-multiselect-hint {
|
|
431
|
+
flex: 1 1 0;
|
|
432
|
+
min-width: 0;
|
|
433
|
+
overflow: hidden;
|
|
434
|
+
text-overflow: ellipsis;
|
|
435
|
+
font-size: var(--hmm-font-size-small);
|
|
436
|
+
color: var(--hmm-fg-muted);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.hmm-multiselect-description {
|
|
440
|
+
overflow: hidden;
|
|
441
|
+
text-overflow: ellipsis;
|
|
442
|
+
white-space: nowrap;
|
|
443
|
+
font-family: var(--hmm-font-mono);
|
|
444
|
+
font-size: var(--hmm-font-size-small);
|
|
445
|
+
color: var(--hmm-fg-muted);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.hmm-multiselect-option:hover:not(:disabled),
|
|
449
|
+
.hmm-multiselect-highlight:not(:disabled) {
|
|
450
|
+
background: var(--hmm-row-hover);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
.hmm-multiselect-selected {
|
|
454
|
+
background: var(--hmm-row-selected);
|
|
455
|
+
color: var(--hmm-row-selected-text);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.hmm-multiselect-option:disabled {
|
|
459
|
+
opacity: 0.45;
|
|
460
|
+
cursor: default;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.hmm-multiselect-empty {
|
|
464
|
+
padding: 4px 6px;
|
|
465
|
+
color: var(--hmm-fg-muted);
|
|
466
|
+
}
|
|
467
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type MultiSelectOption } from './multiSelect.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
options: MultiSelectOption[];
|
|
4
|
+
selected?: string[];
|
|
5
|
+
/** Single selection, which is what the 2.x interface picker used the widget for. */
|
|
6
|
+
multiple?: boolean;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
filterLabel?: string | undefined;
|
|
9
|
+
checkAllLabel?: string | undefined;
|
|
10
|
+
uncheckAllLabel?: string | undefined;
|
|
11
|
+
/** `{count} channels selected` - a message key is not assumed, the caller formats it. */
|
|
12
|
+
summary?: ((selected: string[], options: MultiSelectOption[]) => string) | undefined;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
label?: string | undefined;
|
|
15
|
+
onchange?: ((selected: string[]) => void) | undefined;
|
|
16
|
+
testId?: string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The open list takes its place in the page instead of floating over it, so a dialog
|
|
19
|
+
* that is as tall as its content grows while the list is open rather than scrolling it away.
|
|
20
|
+
* The widget's box dissolves into its parent (`display: contents`): the parent is a wrapping
|
|
21
|
+
* flex row, the trigger sits in it with whatever follows, and the list claims a line of its
|
|
22
|
+
* own under them.
|
|
23
|
+
*/
|
|
24
|
+
inline?: boolean;
|
|
25
|
+
}
|
|
26
|
+
declare const MultiSelect: import("svelte").Component<Props, {}, "selected">;
|
|
27
|
+
type MultiSelect = ReturnType<typeof MultiSelect>;
|
|
28
|
+
export default MultiSelect;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {t as kitT} from '../i18n/i18n.svelte.js';
|
|
3
|
+
import {VISIBLE_NOTICES, type Notice} from '../notices/NoticesStore.svelte.js';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
/** Every notice the store holds, oldest first. */
|
|
7
|
+
notices: Notice[];
|
|
8
|
+
ondismiss?: ((id: number) => void) | undefined;
|
|
9
|
+
dismissLabel?: string | undefined;
|
|
10
|
+
/** How many are drawn before the rest collapse into the counter. */
|
|
11
|
+
visibleCount?: number;
|
|
12
|
+
/** `(n) => '3 more'`; the caller formats it, so plurals stay with the translator. */
|
|
13
|
+
moreLabel?: ((count: number) => string) | undefined;
|
|
14
|
+
lessLabel?: string | undefined;
|
|
15
|
+
testId?: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
notices,
|
|
20
|
+
ondismiss = undefined,
|
|
21
|
+
dismissLabel: dismissLabelProp = undefined,
|
|
22
|
+
visibleCount = VISIBLE_NOTICES,
|
|
23
|
+
moreLabel: moreLabelProp = undefined,
|
|
24
|
+
lessLabel: lessLabelProp = undefined,
|
|
25
|
+
testId = undefined,
|
|
26
|
+
}: Props = $props();
|
|
27
|
+
|
|
28
|
+
// the kit's catalogue, read reactively: a language switch re-renders it
|
|
29
|
+
const dismissLabel = $derived(dismissLabelProp ?? kitT('Dismiss'));
|
|
30
|
+
const moreLabel = $derived(moreLabelProp ?? ((count: number) => kitT('{count} more', {}, count)));
|
|
31
|
+
const lessLabel = $derived(lessLabelProp ?? kitT('Show fewer'));
|
|
32
|
+
|
|
33
|
+
let expanded = $state(false);
|
|
34
|
+
|
|
35
|
+
const hidden = $derived(Math.max(0, notices.length - visibleCount));
|
|
36
|
+
const shown = $derived(expanded ? notices : notices.slice(notices.length - Math.min(notices.length, visibleCount)));
|
|
37
|
+
|
|
38
|
+
// Nothing left to expand: fold the stack back rather than leaving an empty toggle behind.
|
|
39
|
+
$effect(() => {
|
|
40
|
+
if (hidden === 0 && expanded) {
|
|
41
|
+
expanded = false;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<!--
|
|
47
|
+
The toasts that replace 2.x's `dialogAlert()`. That one was modal and closed every other dialog
|
|
48
|
+
on the way in, so an error while a paramset dialog was open threw the edit away.
|
|
49
|
+
|
|
50
|
+
At most `visibleCount` of them are on screen. The older ones are not thrown away - an
|
|
51
|
+
error never expires and must not be able to disappear behind five status messages - they
|
|
52
|
+
collapse into a counter that opens the whole stack.
|
|
53
|
+
-->
|
|
54
|
+
<div class="hmm-notices" role="log" aria-live="polite" data-testid={testId}>
|
|
55
|
+
{#if hidden > 0}
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
class="hmm-notices-more"
|
|
59
|
+
data-testid={testId === undefined ? undefined : `${testId}-more`}
|
|
60
|
+
aria-expanded={expanded}
|
|
61
|
+
onclick={() => (expanded = !expanded)}
|
|
62
|
+
>
|
|
63
|
+
{expanded ? lessLabel : moreLabel(hidden)}
|
|
64
|
+
</button>
|
|
65
|
+
{/if}
|
|
66
|
+
{#each shown as notice (notice.id)}
|
|
67
|
+
<div
|
|
68
|
+
class="hmm-notice"
|
|
69
|
+
class:hmm-notice-warn={notice.level === 'warn'}
|
|
70
|
+
class:hmm-notice-error={notice.level === 'error'}
|
|
71
|
+
>
|
|
72
|
+
<span class="hmm-notice-text">
|
|
73
|
+
{#if notice.source !== undefined}<strong>{notice.source}</strong>{/if}
|
|
74
|
+
{notice.message}
|
|
75
|
+
</span>
|
|
76
|
+
<button
|
|
77
|
+
type="button"
|
|
78
|
+
class="hmm-notice-close"
|
|
79
|
+
aria-label={dismissLabel}
|
|
80
|
+
onclick={() => ondismiss?.(notice.id)}>✕</button
|
|
81
|
+
>
|
|
82
|
+
</div>
|
|
83
|
+
{/each}
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<style>
|
|
87
|
+
.hmm-notices {
|
|
88
|
+
position: fixed;
|
|
89
|
+
right: 10px;
|
|
90
|
+
bottom: 10px;
|
|
91
|
+
z-index: 400;
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: column;
|
|
94
|
+
align-items: stretch;
|
|
95
|
+
gap: 6px;
|
|
96
|
+
max-width: 460px;
|
|
97
|
+
/* An expanded stack must not grow past the window; the oldest scroll out of reach instead. */
|
|
98
|
+
max-height: calc(100vh - 20px);
|
|
99
|
+
overflow-y: auto;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.hmm-notices-more {
|
|
103
|
+
align-self: flex-end;
|
|
104
|
+
padding: 2px 8px;
|
|
105
|
+
border: 1px solid var(--hmm-border-strong);
|
|
106
|
+
border-radius: var(--hmm-radius);
|
|
107
|
+
background: var(--hmm-bg);
|
|
108
|
+
color: var(--hmm-fg-muted);
|
|
109
|
+
font: inherit;
|
|
110
|
+
font-size: var(--hmm-font-size-small);
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.hmm-notice {
|
|
115
|
+
display: flex;
|
|
116
|
+
gap: 8px;
|
|
117
|
+
align-items: flex-start;
|
|
118
|
+
padding: 6px 8px;
|
|
119
|
+
border: 1px solid var(--hmm-border-strong);
|
|
120
|
+
border-left-width: 4px;
|
|
121
|
+
border-radius: var(--hmm-radius);
|
|
122
|
+
background: var(--hmm-bg);
|
|
123
|
+
box-shadow: var(--hmm-shadow-toast);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.hmm-notice-warn {
|
|
127
|
+
border-left-color: var(--hmm-warn);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.hmm-notice-error {
|
|
131
|
+
border-left-color: var(--hmm-error);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.hmm-notice-text {
|
|
135
|
+
flex: 1 1 auto;
|
|
136
|
+
overflow-wrap: anywhere;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.hmm-notice-close {
|
|
140
|
+
border: none;
|
|
141
|
+
background: none;
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
line-height: 1;
|
|
144
|
+
padding: 0 2px;
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Notice } from '../notices/NoticesStore.svelte.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Every notice the store holds, oldest first. */
|
|
4
|
+
notices: Notice[];
|
|
5
|
+
ondismiss?: ((id: number) => void) | undefined;
|
|
6
|
+
dismissLabel?: string | undefined;
|
|
7
|
+
/** How many are drawn before the rest collapse into the counter. */
|
|
8
|
+
visibleCount?: number;
|
|
9
|
+
/** `(n) => '3 more'`; the caller formats it, so plurals stay with the translator. */
|
|
10
|
+
moreLabel?: ((count: number) => string) | undefined;
|
|
11
|
+
lessLabel?: string | undefined;
|
|
12
|
+
testId?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
declare const Notices: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type Notices = ReturnType<typeof Notices>;
|
|
16
|
+
export default Notices;
|