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,74 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {followExternalLink, type OpenExternal} from '../externalLink.js';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
/** Where the icon goes. One URL, and main's allow-list holds the same one. */
|
|
6
|
+
href: string;
|
|
7
|
+
/** The accessible name; there is no visible text, only the mark. */
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* Hands the URL to the host, and says whether the host took it. `false` - no host, or a
|
|
11
|
+
* preload that predates the command - lets the browser follow the link itself.
|
|
12
|
+
*/
|
|
13
|
+
openExternal?: OpenExternal | undefined;
|
|
14
|
+
testId?: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let {href, label, openExternal = undefined, testId = undefined}: Props = $props();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A real link, even in Electron: the browser case is the plain one the roadmap asks for, and
|
|
21
|
+
* in Electron the host bridge opens it ({@link followExternalLink}).
|
|
22
|
+
*/
|
|
23
|
+
function open(event: MouseEvent): void {
|
|
24
|
+
followExternalLink(event, href, openExternal);
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<a
|
|
29
|
+
class="hmm-github"
|
|
30
|
+
{href}
|
|
31
|
+
target="_blank"
|
|
32
|
+
rel="noopener noreferrer"
|
|
33
|
+
title={label}
|
|
34
|
+
aria-label={label}
|
|
35
|
+
data-testid={testId}
|
|
36
|
+
onclick={open}
|
|
37
|
+
>
|
|
38
|
+
<!--
|
|
39
|
+
The GitHub mark, inline and monochrome: it takes its colour from the header's own tokens
|
|
40
|
+
like every other control up there, and an inline path needs no network
|
|
41
|
+
and no CSP exception. 16 px, the size of the icons beside it.
|
|
42
|
+
-->
|
|
43
|
+
<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
44
|
+
<path
|
|
45
|
+
fill="currentColor"
|
|
46
|
+
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38
|
|
47
|
+
0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01
|
|
48
|
+
1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95
|
|
49
|
+
0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27
|
|
50
|
+
2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82
|
|
51
|
+
2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0
|
|
52
|
+
.21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"
|
|
53
|
+
/>
|
|
54
|
+
</svg>
|
|
55
|
+
</a>
|
|
56
|
+
|
|
57
|
+
<style>
|
|
58
|
+
/* The same box and the same hover as `ToolbarButton`, so the header's controls line up. */
|
|
59
|
+
.hmm-github {
|
|
60
|
+
display: inline-flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
width: 26px;
|
|
64
|
+
height: 26px;
|
|
65
|
+
border: 1px solid transparent;
|
|
66
|
+
border-radius: var(--hmm-radius);
|
|
67
|
+
color: var(--hmm-fg-muted);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.hmm-github:hover {
|
|
71
|
+
background: var(--hmm-control-bg-hover);
|
|
72
|
+
color: var(--hmm-fg);
|
|
73
|
+
}
|
|
74
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type OpenExternal } from '../externalLink.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Where the icon goes. One URL, and main's allow-list holds the same one. */
|
|
4
|
+
href: string;
|
|
5
|
+
/** The accessible name; there is no visible text, only the mark. */
|
|
6
|
+
label: string;
|
|
7
|
+
/**
|
|
8
|
+
* Hands the URL to the host, and says whether the host took it. `false` - no host, or a
|
|
9
|
+
* preload that predates the command - lets the browser follow the link itself.
|
|
10
|
+
*/
|
|
11
|
+
openExternal?: OpenExternal | undefined;
|
|
12
|
+
testId?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
declare const GithubLink: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type GithubLink = ReturnType<typeof GithubLink>;
|
|
16
|
+
export default GithubLink;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type {Snippet} from 'svelte';
|
|
3
|
+
|
|
4
|
+
import {activeNavId, navItem, type NavItem} from './navigation.js';
|
|
5
|
+
import Tabs from './Tabs.svelte';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The bar on top of an app: its name, its navigation as tabs, and a group of the page's own
|
|
9
|
+
* items at the right - homematic-manager's bar, measured: one flat line of the header height
|
|
10
|
+
* (`--hmm-header-height`, 36 px) on the header ground with a hairline under it, 10 px at the
|
|
11
|
+
* sides, the tabs as tall as the bar and lying on the hairline, everything else in the middle
|
|
12
|
+
* of the line. Nothing wraps inside the line: the tabs give way and scroll in their own strip.
|
|
13
|
+
*
|
|
14
|
+
* Below 64rem (1024 px) the bar is two such lines - the name and the page's items, then the
|
|
15
|
+
* tabs over the whole width; `narrow={false}` keeps the one line, for an app with a minimum
|
|
16
|
+
* width of its own.
|
|
17
|
+
*
|
|
18
|
+
* The navigation is data (`NavItem`), so an app can hand the same items, the same `active`
|
|
19
|
+
* and the same `onnavigate` to another navigation component.
|
|
20
|
+
*/
|
|
21
|
+
interface Props {
|
|
22
|
+
/** The app's name, drawn as the page's `h1`. */
|
|
23
|
+
title?: string | undefined;
|
|
24
|
+
/** Replaces the name: a logo, a control of the app's own. As tall as it likes up to the bar. */
|
|
25
|
+
brand?: Snippet | undefined;
|
|
26
|
+
/** The places of the app. With none the bar has no tabs. */
|
|
27
|
+
items?: readonly NavItem[];
|
|
28
|
+
/** The id of the open place. */
|
|
29
|
+
active?: string;
|
|
30
|
+
/** The user chose a place. Without `bind:active` the app sets `active` itself - after asking, say. */
|
|
31
|
+
onnavigate?: ((id: string, item: NavItem) => void) | undefined;
|
|
32
|
+
/** The accessible name of the navigation; the kit's "Tabs" by default. */
|
|
33
|
+
navLabel?: string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The group at the right: a count, the version, a help link, the theme switch. Controls
|
|
36
|
+
* keep their box; an element with the class `hmm-header-text` is muted, small text that is
|
|
37
|
+
* cut when the line is short (give it a `title`).
|
|
38
|
+
*/
|
|
39
|
+
actions?: Snippet | undefined;
|
|
40
|
+
/** Two lines below 64rem. */
|
|
41
|
+
narrow?: boolean;
|
|
42
|
+
testId?: string | undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let {
|
|
46
|
+
title = undefined,
|
|
47
|
+
brand = undefined,
|
|
48
|
+
items = [],
|
|
49
|
+
active = $bindable(''),
|
|
50
|
+
onnavigate = undefined,
|
|
51
|
+
navLabel = undefined,
|
|
52
|
+
actions = undefined,
|
|
53
|
+
narrow = true,
|
|
54
|
+
testId = undefined,
|
|
55
|
+
}: Props = $props();
|
|
56
|
+
|
|
57
|
+
let root = $state<HTMLElement | undefined>(undefined);
|
|
58
|
+
const shown = $derived(activeNavId(items, active));
|
|
59
|
+
|
|
60
|
+
function select(id: string): void {
|
|
61
|
+
const item = navItem(items, id);
|
|
62
|
+
if (item !== undefined) {
|
|
63
|
+
onnavigate?.(id, item);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// where the tabs scroll in their strip (a narrow window), the open one is brought into it
|
|
68
|
+
$effect(() => {
|
|
69
|
+
const tab = root?.querySelector(`[role="tab"][aria-selected="true"]`);
|
|
70
|
+
void shown;
|
|
71
|
+
tab?.scrollIntoView({block: 'nearest', inline: 'nearest'});
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<header class="hmm-header" class:hmm-header-narrow={narrow} data-testid={testId} bind:this={root}>
|
|
76
|
+
{#if brand}
|
|
77
|
+
<div class="hmm-header-brand">{@render brand()}</div>
|
|
78
|
+
{:else if title !== undefined}
|
|
79
|
+
<h1 class="hmm-header-title">{title}</h1>
|
|
80
|
+
{/if}
|
|
81
|
+
{#if items.length > 0}
|
|
82
|
+
<!--
|
|
83
|
+
The tabs take the choice and hand it on: with `bind:active` on the header the bar
|
|
84
|
+
follows at once, without it the app decides (a page with unsaved changes asks first).
|
|
85
|
+
-->
|
|
86
|
+
<Tabs
|
|
87
|
+
tabs={[...items]}
|
|
88
|
+
bind:active={() => shown, (id) => (active = id)}
|
|
89
|
+
onselect={select}
|
|
90
|
+
label={navLabel}
|
|
91
|
+
testId={testId === undefined ? undefined : `${testId}-nav`}
|
|
92
|
+
/>
|
|
93
|
+
{/if}
|
|
94
|
+
{#if actions}
|
|
95
|
+
<div class="hmm-header-actions" data-testid={testId === undefined ? undefined : `${testId}-actions`}>
|
|
96
|
+
{@render actions()}
|
|
97
|
+
</div>
|
|
98
|
+
{/if}
|
|
99
|
+
</header>
|
|
100
|
+
|
|
101
|
+
<style>
|
|
102
|
+
.hmm-header {
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
gap: 8px;
|
|
106
|
+
box-sizing: border-box;
|
|
107
|
+
height: var(--hmm-header-height);
|
|
108
|
+
padding: 0 10px;
|
|
109
|
+
background: var(--hmm-header-bg);
|
|
110
|
+
border-bottom: 1px solid var(--hmm-border);
|
|
111
|
+
flex: 0 0 auto;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.hmm-header-title {
|
|
115
|
+
flex: none;
|
|
116
|
+
font-size: 1.05rem;
|
|
117
|
+
font-weight: 600;
|
|
118
|
+
line-height: 1;
|
|
119
|
+
margin: 0 4px 0 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.hmm-header-brand {
|
|
123
|
+
display: flex;
|
|
124
|
+
align-items: center;
|
|
125
|
+
flex: none;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* The tabs give way before the bar grows, and scroll: a scroll bar would take its height from them. */
|
|
129
|
+
.hmm-header > :global(.hmm-tabs) {
|
|
130
|
+
flex: 0 1 auto;
|
|
131
|
+
min-width: 0;
|
|
132
|
+
overflow-x: auto;
|
|
133
|
+
scrollbar-width: none;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.hmm-header > :global(.hmm-tabs > .hmm-tab) {
|
|
137
|
+
flex: none;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.hmm-header-actions {
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
gap: 8px;
|
|
144
|
+
/* gives way before the bar grows: a text is cut (its tooltip says it), a control keeps its box */
|
|
145
|
+
flex: 0 1 auto;
|
|
146
|
+
min-width: 0;
|
|
147
|
+
margin-left: auto;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.hmm-header-actions > :global(:not(.hmm-header-text)) {
|
|
151
|
+
flex: none;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.hmm-header-actions > :global(.hmm-header-text) {
|
|
155
|
+
flex: 0 1 auto;
|
|
156
|
+
min-width: 0;
|
|
157
|
+
max-width: 11rem;
|
|
158
|
+
overflow: hidden;
|
|
159
|
+
text-overflow: ellipsis;
|
|
160
|
+
white-space: nowrap;
|
|
161
|
+
color: var(--hmm-fg-muted);
|
|
162
|
+
font-size: var(--hmm-font-size-small);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* Two lines of the bar's height: the name and the page's items, then the tabs over the whole width. */
|
|
166
|
+
@media (max-width: 64rem) {
|
|
167
|
+
.hmm-header-narrow {
|
|
168
|
+
flex-wrap: wrap;
|
|
169
|
+
height: auto;
|
|
170
|
+
row-gap: 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.hmm-header-narrow > .hmm-header-title,
|
|
174
|
+
.hmm-header-narrow > .hmm-header-brand,
|
|
175
|
+
.hmm-header-narrow > .hmm-header-actions {
|
|
176
|
+
display: flex;
|
|
177
|
+
align-items: center;
|
|
178
|
+
height: calc(var(--hmm-header-height) - 1px);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* the group takes what the name leaves and never a line of its own: its texts are cut first */
|
|
182
|
+
.hmm-header-narrow > .hmm-header-actions {
|
|
183
|
+
flex: 1 1 0;
|
|
184
|
+
justify-content: flex-end;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.hmm-header-narrow > :global(.hmm-tabs) {
|
|
188
|
+
order: 3;
|
|
189
|
+
flex: 0 0 100%;
|
|
190
|
+
/* the hairline between the two lines, then tabs as tall as the bar's */
|
|
191
|
+
height: calc(var(--hmm-header-height) + 1px);
|
|
192
|
+
box-sizing: border-box;
|
|
193
|
+
border-top: 1px solid var(--hmm-border);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type NavItem } from './navigation.js';
|
|
3
|
+
/**
|
|
4
|
+
* The bar on top of an app: its name, its navigation as tabs, and a group of the page's own
|
|
5
|
+
* items at the right - homematic-manager's bar, measured: one flat line of the header height
|
|
6
|
+
* (`--hmm-header-height`, 36 px) on the header ground with a hairline under it, 10 px at the
|
|
7
|
+
* sides, the tabs as tall as the bar and lying on the hairline, everything else in the middle
|
|
8
|
+
* of the line. Nothing wraps inside the line: the tabs give way and scroll in their own strip.
|
|
9
|
+
*
|
|
10
|
+
* Below 64rem (1024 px) the bar is two such lines - the name and the page's items, then the
|
|
11
|
+
* tabs over the whole width; `narrow={false}` keeps the one line, for an app with a minimum
|
|
12
|
+
* width of its own.
|
|
13
|
+
*
|
|
14
|
+
* The navigation is data (`NavItem`), so an app can hand the same items, the same `active`
|
|
15
|
+
* and the same `onnavigate` to another navigation component.
|
|
16
|
+
*/
|
|
17
|
+
interface Props {
|
|
18
|
+
/** The app's name, drawn as the page's `h1`. */
|
|
19
|
+
title?: string | undefined;
|
|
20
|
+
/** Replaces the name: a logo, a control of the app's own. As tall as it likes up to the bar. */
|
|
21
|
+
brand?: Snippet | undefined;
|
|
22
|
+
/** The places of the app. With none the bar has no tabs. */
|
|
23
|
+
items?: readonly NavItem[];
|
|
24
|
+
/** The id of the open place. */
|
|
25
|
+
active?: string;
|
|
26
|
+
/** The user chose a place. Without `bind:active` the app sets `active` itself - after asking, say. */
|
|
27
|
+
onnavigate?: ((id: string, item: NavItem) => void) | undefined;
|
|
28
|
+
/** The accessible name of the navigation; the kit's "Tabs" by default. */
|
|
29
|
+
navLabel?: string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* The group at the right: a count, the version, a help link, the theme switch. Controls
|
|
32
|
+
* keep their box; an element with the class `hmm-header-text` is muted, small text that is
|
|
33
|
+
* cut when the line is short (give it a `title`).
|
|
34
|
+
*/
|
|
35
|
+
actions?: Snippet | undefined;
|
|
36
|
+
/** Two lines below 64rem. */
|
|
37
|
+
narrow?: boolean;
|
|
38
|
+
testId?: string | undefined;
|
|
39
|
+
}
|
|
40
|
+
declare const Header: import("svelte").Component<Props, {}, "active">;
|
|
41
|
+
type Header = ReturnType<typeof Header>;
|
|
42
|
+
export default Header;
|
|
@@ -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;
|