occulite-ui 0.0.0-stage → 0.1.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.
Files changed (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +171 -2
  3. package/THIRD_PARTY_NOTICES.md +36 -0
  4. package/dist/clipboard.d.ts +26 -0
  5. package/dist/clipboard.js +70 -0
  6. package/dist/components/ContextMenu.svelte +158 -0
  7. package/dist/components/ContextMenu.svelte.d.ts +14 -0
  8. package/dist/components/DataTable.svelte +1872 -0
  9. package/dist/components/DataTable.svelte.d.ts +122 -0
  10. package/dist/components/Dialog.svelte +420 -0
  11. package/dist/components/Dialog.svelte.d.ts +55 -0
  12. package/dist/components/GithubLink.svelte +74 -0
  13. package/dist/components/GithubLink.svelte.d.ts +16 -0
  14. package/dist/components/Icon.svelte +51 -0
  15. package/dist/components/Icon.svelte.d.ts +12 -0
  16. package/dist/components/LanguageSwitch.svelte +63 -0
  17. package/dist/components/LanguageSwitch.svelte.d.ts +17 -0
  18. package/dist/components/Loader.svelte +65 -0
  19. package/dist/components/Loader.svelte.d.ts +9 -0
  20. package/dist/components/MultiSelect.svelte +467 -0
  21. package/dist/components/MultiSelect.svelte.d.ts +28 -0
  22. package/dist/components/Notices.svelte +146 -0
  23. package/dist/components/Notices.svelte.d.ts +16 -0
  24. package/dist/components/PrimaryToolbarButton.svelte +189 -0
  25. package/dist/components/PrimaryToolbarButton.svelte.d.ts +34 -0
  26. package/dist/components/Tabs.svelte +118 -0
  27. package/dist/components/Tabs.svelte.d.ts +16 -0
  28. package/dist/components/ThemeSwitch.svelte +46 -0
  29. package/dist/components/ThemeSwitch.svelte.d.ts +11 -0
  30. package/dist/components/Toolbar.svelte +57 -0
  31. package/dist/components/Toolbar.svelte.d.ts +11 -0
  32. package/dist/components/ToolbarButton.svelte +126 -0
  33. package/dist/components/ToolbarButton.svelte.d.ts +22 -0
  34. package/dist/components/Tooltip.svelte +106 -0
  35. package/dist/components/Tooltip.svelte.d.ts +31 -0
  36. package/dist/components/TooltipBubble.svelte +65 -0
  37. package/dist/components/TooltipBubble.svelte.d.ts +18 -0
  38. package/dist/components/contextMenu.d.ts +19 -0
  39. package/dist/components/contextMenu.js +6 -0
  40. package/dist/components/dialogGeometry.d.ts +91 -0
  41. package/dist/components/dialogGeometry.js +140 -0
  42. package/dist/components/index.d.ts +20 -0
  43. package/dist/components/index.js +20 -0
  44. package/dist/components/multiSelect.d.ts +27 -0
  45. package/dist/components/multiSelect.js +26 -0
  46. package/dist/components/tooltip.d.ts +29 -0
  47. package/dist/components/tooltip.js +27 -0
  48. package/dist/css/app.css +3 -0
  49. package/dist/css/base.css +84 -0
  50. package/dist/css/tokens.css +170 -0
  51. package/dist/dialog/index.d.ts +6 -0
  52. package/dist/dialog/index.js +6 -0
  53. package/dist/embedding/ShellEmbedding.svelte.d.ts +27 -0
  54. package/dist/embedding/ShellEmbedding.svelte.js +79 -0
  55. package/dist/embedding/constants.d.ts +23 -0
  56. package/dist/embedding/constants.js +54 -0
  57. package/dist/embedding/index.d.ts +2 -0
  58. package/dist/embedding/index.js +2 -0
  59. package/dist/externalLink.d.ts +15 -0
  60. package/dist/externalLink.js +20 -0
  61. package/dist/format.d.ts +6 -0
  62. package/dist/format.js +16 -0
  63. package/dist/i18n/i18n.svelte.d.ts +112 -0
  64. package/dist/i18n/i18n.svelte.js +211 -0
  65. package/dist/i18n/index.d.ts +3 -0
  66. package/dist/i18n/index.js +3 -0
  67. package/dist/i18n/messages.d.ts +9 -0
  68. package/dist/i18n/messages.js +57 -0
  69. package/dist/i18n/translator.d.ts +65 -0
  70. package/dist/i18n/translator.js +99 -0
  71. package/dist/icons/index.d.ts +17 -0
  72. package/dist/icons/index.js +11 -0
  73. package/dist/index.d.ts +16 -0
  74. package/dist/index.js +16 -0
  75. package/dist/notices/NoticesStore.svelte.d.ts +64 -0
  76. package/dist/notices/NoticesStore.svelte.js +127 -0
  77. package/dist/notices/index.d.ts +1 -0
  78. package/dist/notices/index.js +1 -0
  79. package/dist/storage.d.ts +11 -0
  80. package/dist/storage.js +27 -0
  81. package/dist/table/LocalColumnWidths.svelte.d.ts +32 -0
  82. package/dist/table/LocalColumnWidths.svelte.js +91 -0
  83. package/dist/table/columnMeasure.d.ts +24 -0
  84. package/dist/table/columnMeasure.js +82 -0
  85. package/dist/table/columnWidths.d.ts +60 -0
  86. package/dist/table/columnWidths.js +86 -0
  87. package/dist/table/dataTableContext.d.ts +26 -0
  88. package/dist/table/dataTableContext.js +16 -0
  89. package/dist/table/index.d.ts +6 -0
  90. package/dist/table/index.js +6 -0
  91. package/dist/table/metrics.d.ts +10 -0
  92. package/dist/table/metrics.js +10 -0
  93. package/dist/table/tableModel.d.ts +245 -0
  94. package/dist/table/tableModel.js +367 -0
  95. package/dist/theme/choices.d.ts +8 -0
  96. package/dist/theme/choices.js +6 -0
  97. package/dist/theme/index.d.ts +2 -0
  98. package/dist/theme/index.js +2 -0
  99. package/dist/theme/theme.svelte.d.ts +60 -0
  100. package/dist/theme/theme.svelte.js +108 -0
  101. package/package.json +137 -4
@@ -0,0 +1,51 @@
1
+ <script lang="ts">
2
+ import type {IconData} from '../icons/index.js';
3
+
4
+ interface Props {
5
+ icon: IconData;
6
+ /** Width and height in pixels. */
7
+ size?: number;
8
+ /** The accessible name; absent, the icon is decoration and hidden from assistive technology. */
9
+ label?: string | undefined;
10
+ testId?: string | undefined;
11
+ }
12
+
13
+ let {icon, size = 16, label = undefined, testId = undefined}: Props = $props();
14
+
15
+ const stroked = $derived(icon.mode === 'stroke');
16
+ </script>
17
+
18
+ <svg
19
+ class="hmm-icon"
20
+ width={size}
21
+ height={size}
22
+ viewBox={icon.viewBox ?? '0 0 24 24'}
23
+ role={label === undefined ? undefined : 'img'}
24
+ aria-label={label}
25
+ aria-hidden={label === undefined ? 'true' : undefined}
26
+ focusable="false"
27
+ data-testid={testId}
28
+ >
29
+ {#each icon.paths as d, index (index)}
30
+ {#if stroked}
31
+ <path
32
+ {d}
33
+ fill="none"
34
+ stroke="currentColor"
35
+ stroke-width={icon.strokeWidth ?? 2}
36
+ stroke-linecap="round"
37
+ stroke-linejoin="round"
38
+ />
39
+ {:else}
40
+ <path {d} fill="currentColor" />
41
+ {/if}
42
+ {/each}
43
+ </svg>
44
+
45
+ <style>
46
+ .hmm-icon {
47
+ display: inline-block;
48
+ flex: none;
49
+ vertical-align: middle;
50
+ }
51
+ </style>
@@ -0,0 +1,12 @@
1
+ import type { IconData } from '../icons/index.js';
2
+ interface Props {
3
+ icon: IconData;
4
+ /** Width and height in pixels. */
5
+ size?: number;
6
+ /** The accessible name; absent, the icon is decoration and hidden from assistive technology. */
7
+ label?: string | undefined;
8
+ testId?: string | undefined;
9
+ }
10
+ declare const Icon: import("svelte").Component<Props, {}, "">;
11
+ type Icon = ReturnType<typeof Icon>;
12
+ export default Icon;
@@ -0,0 +1,63 @@
1
+ <script lang="ts">
2
+ import {LANGUAGE_LABELS, t as kitT, UI_LANGUAGES} from '../i18n/i18n.svelte.js';
3
+ import type {LanguageChoice, LanguageCode} from '../i18n/translator.js';
4
+
5
+ interface Props {
6
+ /**
7
+ * The stored choice, not the resolved language: `auto` is one of the entries. An app may
8
+ * keep a code the switch does not offer (a fallback locale); the switch then shows none of
9
+ * its entries as selected until the user picks one.
10
+ */
11
+ language?: LanguageChoice | LanguageCode;
12
+ label?: string | undefined;
13
+ /** The first entry - "Browser language", or whatever the caller's catalogue calls it. */
14
+ autoLabel?: string | undefined;
15
+ onchange?: ((language: LanguageChoice) => void) | undefined;
16
+ testId?: string | undefined;
17
+ }
18
+
19
+ let {
20
+ language = $bindable('auto'),
21
+ label: labelProp = undefined,
22
+ autoLabel: autoLabelProp = undefined,
23
+ onchange = undefined,
24
+ testId = undefined,
25
+ }: Props = $props();
26
+
27
+ const label = $derived(labelProp ?? kitT('Language'));
28
+ const autoLabel = $derived(autoLabelProp ?? kitT('Browser language'));
29
+ </script>
30
+
31
+ <!--
32
+ This used to sit in the header, next to the theme switch, where it was one of
33
+ the two controls a user touches once and never again. It lives in the settings dialog now, and
34
+ the entry above the languages is the default - the browser's own order, with English behind it -
35
+ so "I never chose" and "I chose German" stay two different answers.
36
+ -->
37
+ <select
38
+ class="hmm-select hmm-language"
39
+ aria-label={label}
40
+ title={label}
41
+ data-testid={testId}
42
+ value={language}
43
+ onchange={(event) => {
44
+ const chosen = event.currentTarget.value as LanguageChoice;
45
+ language = chosen;
46
+ onchange?.(chosen);
47
+ }}
48
+ >
49
+ <option value="auto">{autoLabel}</option>
50
+ {#each UI_LANGUAGES as candidate (candidate)}
51
+ <option value={candidate}>{LANGUAGE_LABELS[candidate]}</option>
52
+ {/each}
53
+ </select>
54
+
55
+ <style>
56
+ /*
57
+ No width of its own any more: in the settings dialog it is one of the rows, and every other
58
+ control there fills the row's `minmax(0, 1fr)` track.
59
+ */
60
+ .hmm-language {
61
+ min-width: 0;
62
+ }
63
+ </style>
@@ -0,0 +1,17 @@
1
+ import type { LanguageChoice, LanguageCode } from '../i18n/translator.js';
2
+ interface Props {
3
+ /**
4
+ * The stored choice, not the resolved language: `auto` is one of the entries. An app may
5
+ * keep a code the switch does not offer (a fallback locale); the switch then shows none of
6
+ * its entries as selected until the user picks one.
7
+ */
8
+ language?: LanguageChoice | LanguageCode;
9
+ label?: string | undefined;
10
+ /** The first entry - "Browser language", or whatever the caller's catalogue calls it. */
11
+ autoLabel?: string | undefined;
12
+ onchange?: ((language: LanguageChoice) => void) | undefined;
13
+ testId?: string | undefined;
14
+ }
15
+ declare const LanguageSwitch: import("svelte").Component<Props, {}, "language">;
16
+ type LanguageSwitch = ReturnType<typeof LanguageSwitch>;
17
+ export default LanguageSwitch;
@@ -0,0 +1,65 @@
1
+ <script lang="ts">
2
+ import {t as kitT} from '../i18n/i18n.svelte.js';
3
+ interface Props {
4
+ /** Covers its positioned parent while true - the 2.x `#loader` over the whole window. */
5
+ visible?: boolean;
6
+ text?: string | undefined;
7
+ testId?: string | undefined;
8
+ }
9
+
10
+ let {visible = false, text: textProp = undefined, testId = undefined}: Props = $props();
11
+
12
+ const text = $derived(textProp ?? `${kitT('Loading')}…`);
13
+ </script>
14
+
15
+ {#if visible}
16
+ <div class="hmm-loader" role="status" aria-live="polite" data-testid={testId}>
17
+ <div class="hmm-loader-box">
18
+ <div class="hmm-loader-spinner" aria-hidden="true"></div>
19
+ <div class="hmm-loader-text">{text}</div>
20
+ </div>
21
+ </div>
22
+ {/if}
23
+
24
+ <style>
25
+ .hmm-loader {
26
+ position: absolute;
27
+ inset: 0;
28
+ z-index: 500;
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ background: var(--hmm-overlay);
33
+ }
34
+
35
+ .hmm-loader-box {
36
+ text-align: center;
37
+ }
38
+
39
+ .hmm-loader-spinner {
40
+ width: 28px;
41
+ height: 28px;
42
+ margin: 0 auto 10px;
43
+ border: 3px solid var(--hmm-border);
44
+ border-top-color: var(--hmm-accent);
45
+ border-radius: 50%;
46
+ animation: hmm-spin 900ms linear infinite;
47
+ }
48
+
49
+ .hmm-loader-text {
50
+ font-size: 14px;
51
+ color: var(--hmm-fg-muted);
52
+ }
53
+
54
+ @keyframes hmm-spin {
55
+ to {
56
+ transform: rotate(360deg);
57
+ }
58
+ }
59
+
60
+ @media (prefers-reduced-motion: reduce) {
61
+ .hmm-loader-spinner {
62
+ animation-duration: 3s;
63
+ }
64
+ }
65
+ </style>
@@ -0,0 +1,9 @@
1
+ interface Props {
2
+ /** Covers its positioned parent while true - the 2.x `#loader` over the whole window. */
3
+ visible?: boolean;
4
+ text?: string | undefined;
5
+ testId?: string | undefined;
6
+ }
7
+ declare const Loader: import("svelte").Component<Props, {}, "">;
8
+ type Loader = ReturnType<typeof Loader>;
9
+ export default Loader;
@@ -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>