@gravionlabs/helix-app 0.0.1 → 22.20.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.md +21 -0
- package/README.md +147 -1
- package/fesm2022/gravionlabs-helix-app-frame.mjs +1633 -0
- package/fesm2022/gravionlabs-helix-app-frame.mjs.map +1 -0
- package/fesm2022/gravionlabs-helix-app-tauri.mjs +493 -0
- package/fesm2022/gravionlabs-helix-app-tauri.mjs.map +1 -0
- package/fesm2022/gravionlabs-helix-app.mjs +1023 -0
- package/fesm2022/gravionlabs-helix-app.mjs.map +1 -0
- package/frame/package.json +5 -0
- package/frame.css +540 -0
- package/package.json +61 -5
- package/styles.css +12 -0
- package/tauri/package.json +5 -0
- package/types/gravionlabs-helix-app-frame.d.ts +636 -0
- package/types/gravionlabs-helix-app-tauri.d.ts +208 -0
- package/types/gravionlabs-helix-app.d.ts +360 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { EnvironmentProviders, InjectionToken, Provider } from "@angular/core";
|
|
3
|
+
import { HxOs } from "@gravionlabs/helix-app";
|
|
4
|
+
import { HxStatusTone } from "@gravionlabs/helix-app/frame";
|
|
5
|
+
/** `stable`, or `rc` for a release candidate. */
|
|
6
|
+
export type HxChannel = 'stable' | 'rc';
|
|
7
|
+
export interface HxAppInfo {
|
|
8
|
+
readonly version: string;
|
|
9
|
+
readonly channel: HxChannel;
|
|
10
|
+
}
|
|
11
|
+
/** The app version and channel. Without `provideHxAppInfo()` it is an empty stable version. */
|
|
12
|
+
export declare const HX_APP_INFO: InjectionToken<HxAppInfo>;
|
|
13
|
+
/** `1.4.0-rc.1` is `rc`; everything else is `stable`. */
|
|
14
|
+
export declare function channelOfVersion(version: string): HxChannel;
|
|
15
|
+
/** Provide the version and, when not given, the channel derived from it. */
|
|
16
|
+
export declare function provideHxAppInfo(info: {
|
|
17
|
+
version: string;
|
|
18
|
+
channel?: HxChannel;
|
|
19
|
+
}): Provider;
|
|
20
|
+
/** Read the version from Tauri (`getVersion`); outside Tauri it resolves to `fallback`. */
|
|
21
|
+
export declare function readTauriVersion(fallback?: string): Promise<string>;
|
|
22
|
+
/** Detect the operating system from the user agent; `web` outside Tauri. */
|
|
23
|
+
export declare function detectHxOs(ua?: string, tauri?: boolean): HxOs;
|
|
24
|
+
/** Set `data-platform` on the root element at startup: macos, windows, linux, ios, android or web. */
|
|
25
|
+
export declare function providePlatform(os?: HxOs): EnvironmentProviders;
|
|
26
|
+
/** The app version with the `RC` badge on a release candidate; reads `provideHxAppInfo()`. */
|
|
27
|
+
export declare class HxStatusAppVersion {
|
|
28
|
+
protected readonly info: HxAppInfo;
|
|
29
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HxStatusAppVersion, never>;
|
|
30
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<HxStatusAppVersion, "hx-status-app-version", never, {}, {}, never, never, true, never>;
|
|
31
|
+
}
|
|
32
|
+
/** What the updater found: a newer version. */
|
|
33
|
+
export interface HxUpdateInfo {
|
|
34
|
+
readonly version: string;
|
|
35
|
+
readonly notes: string | null;
|
|
36
|
+
readonly date: string | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The plugin calls behind an interface, so tests and web builds need no Tauri. The Tauri implementation
|
|
40
|
+
* is `tauriUpdateBackend()`; outside Tauri the service uses `noopUpdateBackend`.
|
|
41
|
+
*/
|
|
42
|
+
export interface HxUpdateBackend {
|
|
43
|
+
/** `null` when the app is current. */
|
|
44
|
+
check(): Promise<HxUpdateInfo | null>;
|
|
45
|
+
/**
|
|
46
|
+
* Download and install the update found by the last `check()`. `onProgress` gets the percent (0 to 100)
|
|
47
|
+
* while it downloads, or `null` when the size is unknown.
|
|
48
|
+
*/
|
|
49
|
+
install(onProgress?: (percent: number | null) => void): Promise<void>;
|
|
50
|
+
/** Restart into the new version. */
|
|
51
|
+
relaunch(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/** The backend of a web build: never finds an update, never throws. */
|
|
54
|
+
export declare const noopUpdateBackend: HxUpdateBackend;
|
|
55
|
+
/** True inside a Tauri webview. */
|
|
56
|
+
export declare function isTauri(): boolean;
|
|
57
|
+
/** The backend on `@tauri-apps/plugin-updater` and `plugin-process`, loaded on first use. */
|
|
58
|
+
export declare function tauriUpdateBackend(): HxUpdateBackend;
|
|
59
|
+
/** The backend for the current environment. */
|
|
60
|
+
export declare function defaultUpdateBackend(): HxUpdateBackend;
|
|
61
|
+
/** The step that failed. */
|
|
62
|
+
export type HxUpdateStep = 'check' | 'install' | 'relaunch';
|
|
63
|
+
export type HxUpdateState = {
|
|
64
|
+
readonly status: 'idle';
|
|
65
|
+
} | {
|
|
66
|
+
readonly status: 'checking';
|
|
67
|
+
} | {
|
|
68
|
+
readonly status: 'current';
|
|
69
|
+
} | {
|
|
70
|
+
readonly status: 'available';
|
|
71
|
+
readonly update: HxUpdateInfo;
|
|
72
|
+
} | {
|
|
73
|
+
readonly status: 'installing';
|
|
74
|
+
readonly update: HxUpdateInfo;
|
|
75
|
+
/** The download progress, 0 to 100; `null` while the size is unknown. */
|
|
76
|
+
readonly percent: number | null;
|
|
77
|
+
} | {
|
|
78
|
+
readonly status: 'error';
|
|
79
|
+
readonly step: HxUpdateStep;
|
|
80
|
+
readonly message: string;
|
|
81
|
+
};
|
|
82
|
+
/** The backend of the update service; override it in tests. */
|
|
83
|
+
export declare const HX_UPDATE_BACKEND: InjectionToken<HxUpdateBackend>;
|
|
84
|
+
/**
|
|
85
|
+
* A hook that runs after the state is `installing` and before the install, for example to save the open
|
|
86
|
+
* document. When it throws, the state is `error` (step `install`) and the update stays available for a retry.
|
|
87
|
+
*/
|
|
88
|
+
export type HxUpdateBeforeInstall = (update: HxUpdateInfo) => void | Promise<void>;
|
|
89
|
+
/** The hook before the install; `null` (the default) means none. */
|
|
90
|
+
export declare const HX_UPDATE_BEFORE_INSTALL: InjectionToken<HxUpdateBeforeInstall | null>;
|
|
91
|
+
/** How long a manual check shows "Up to date", in milliseconds. */
|
|
92
|
+
export declare const HX_UPDATE_CURRENT_MS = 3000;
|
|
93
|
+
/**
|
|
94
|
+
* The update state machine: idle, checking, current, available, installing, error (with the failed step).
|
|
95
|
+
* An RC build never checks by itself: `start()` does nothing there, `check()` still works on request.
|
|
96
|
+
*/
|
|
97
|
+
export declare class HxUpdateService {
|
|
98
|
+
private readonly backend;
|
|
99
|
+
private readonly beforeInstall;
|
|
100
|
+
private readonly info;
|
|
101
|
+
private readonly _currentShown;
|
|
102
|
+
private retryUpdate;
|
|
103
|
+
private currentTimer;
|
|
104
|
+
private readonly _state;
|
|
105
|
+
readonly state: import("@angular/core").Signal<HxUpdateState>;
|
|
106
|
+
/** True while a manual check shows its "up to date" result. */
|
|
107
|
+
readonly currentShown: import("@angular/core").Signal<boolean>;
|
|
108
|
+
readonly version: string;
|
|
109
|
+
readonly channel: HxChannel;
|
|
110
|
+
/** The found update, while available or installing. */
|
|
111
|
+
readonly update: import("@angular/core").Signal<HxUpdateInfo | null>;
|
|
112
|
+
/** The automatic check at startup; skipped for an RC build. */
|
|
113
|
+
start(): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Check for an update. With `manual: true` a result of "current" stays visible for a moment
|
|
116
|
+
* (`HX_UPDATE_CURRENT_MS`), then the state goes back to `idle`.
|
|
117
|
+
*/
|
|
118
|
+
check(options?: {
|
|
119
|
+
readonly manual?: boolean;
|
|
120
|
+
}): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Download, install and restart. Also the retry after a failed install step: the update stays available.
|
|
123
|
+
*/
|
|
124
|
+
installAndRestart(): Promise<void>;
|
|
125
|
+
private fail;
|
|
126
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HxUpdateService, never>;
|
|
127
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The update state as a status item; the version, the notes and "Install and restart" are in its popover.
|
|
131
|
+
* Not rendered on mobile and while there is nothing to show (idle, current), unless `alwaysVisible` is set:
|
|
132
|
+
* then it shows "Check for updates" and a click runs a manual check, whose result "Up to date" stays visible
|
|
133
|
+
* for a moment. While installing it shows the download percent.
|
|
134
|
+
*/
|
|
135
|
+
export declare class HxStatusUpdate {
|
|
136
|
+
protected readonly service: HxUpdateService;
|
|
137
|
+
private readonly root;
|
|
138
|
+
readonly checkingLabel: import("@angular/core").InputSignal<string>;
|
|
139
|
+
readonly availableLabel: import("@angular/core").InputSignal<string>;
|
|
140
|
+
readonly installingLabel: import("@angular/core").InputSignal<string>;
|
|
141
|
+
readonly errorLabel: import("@angular/core").InputSignal<string>;
|
|
142
|
+
readonly installLabel: import("@angular/core").InputSignal<string>;
|
|
143
|
+
readonly retryLabel: import("@angular/core").InputSignal<string>;
|
|
144
|
+
readonly checkLabel: import("@angular/core").InputSignal<string>;
|
|
145
|
+
readonly upToDateLabel: import("@angular/core").InputSignal<string>;
|
|
146
|
+
/** Show the item in `idle` and `current` too, as "Check for updates"; a click runs a manual check. */
|
|
147
|
+
readonly alwaysVisible: import("@angular/core").InputSignal<boolean>;
|
|
148
|
+
protected readonly open: import("@angular/core").WritableSignal<boolean>;
|
|
149
|
+
protected readonly state: import("@angular/core").Signal<HxUpdateState>;
|
|
150
|
+
protected readonly visible: import("@angular/core").Signal<boolean>;
|
|
151
|
+
/** An item that only starts a check (idle, current): no popover. */
|
|
152
|
+
protected readonly checkOnly: import("@angular/core").Signal<boolean>;
|
|
153
|
+
protected checkNow(): void;
|
|
154
|
+
/** A failed install step retries the install, any other error the check. */
|
|
155
|
+
protected retry(): void;
|
|
156
|
+
protected readonly label: import("@angular/core").Signal<string>;
|
|
157
|
+
protected readonly tone: import("@angular/core").Signal<HxStatusTone>;
|
|
158
|
+
protected readonly errorText: import("@angular/core").Signal<string>;
|
|
159
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HxStatusUpdate, never>;
|
|
160
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<HxStatusUpdate, "hx-status-update", never, {
|
|
161
|
+
"checkingLabel": {
|
|
162
|
+
"alias": "checkingLabel";
|
|
163
|
+
"required": false;
|
|
164
|
+
"isSignal": true;
|
|
165
|
+
};
|
|
166
|
+
"availableLabel": {
|
|
167
|
+
"alias": "availableLabel";
|
|
168
|
+
"required": false;
|
|
169
|
+
"isSignal": true;
|
|
170
|
+
};
|
|
171
|
+
"installingLabel": {
|
|
172
|
+
"alias": "installingLabel";
|
|
173
|
+
"required": false;
|
|
174
|
+
"isSignal": true;
|
|
175
|
+
};
|
|
176
|
+
"errorLabel": {
|
|
177
|
+
"alias": "errorLabel";
|
|
178
|
+
"required": false;
|
|
179
|
+
"isSignal": true;
|
|
180
|
+
};
|
|
181
|
+
"installLabel": {
|
|
182
|
+
"alias": "installLabel";
|
|
183
|
+
"required": false;
|
|
184
|
+
"isSignal": true;
|
|
185
|
+
};
|
|
186
|
+
"retryLabel": {
|
|
187
|
+
"alias": "retryLabel";
|
|
188
|
+
"required": false;
|
|
189
|
+
"isSignal": true;
|
|
190
|
+
};
|
|
191
|
+
"checkLabel": {
|
|
192
|
+
"alias": "checkLabel";
|
|
193
|
+
"required": false;
|
|
194
|
+
"isSignal": true;
|
|
195
|
+
};
|
|
196
|
+
"upToDateLabel": {
|
|
197
|
+
"alias": "upToDateLabel";
|
|
198
|
+
"required": false;
|
|
199
|
+
"isSignal": true;
|
|
200
|
+
};
|
|
201
|
+
"alwaysVisible": {
|
|
202
|
+
"alias": "alwaysVisible";
|
|
203
|
+
"required": false;
|
|
204
|
+
"isSignal": true;
|
|
205
|
+
};
|
|
206
|
+
}, {}, never, never, true, never>;
|
|
207
|
+
}
|
|
208
|
+
export declare const HELIX_DESKTOP_TAURI = true;
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { EnvironmentProviders, TemplateRef, Type } from "@angular/core";
|
|
3
|
+
import { HxButtonSeverity, HxColorMode, HxDensity, HxTree, HxTreeNode, HxTreeSelection } from "@gravionlabs/helix-ui";
|
|
4
|
+
/** The operating system a Tauri app runs on, or `web` outside Tauri. */
|
|
5
|
+
export type HxOs = 'macos' | 'windows' | 'linux' | 'ios' | 'android' | 'web';
|
|
6
|
+
/**
|
|
7
|
+
* The platform an app runs on (ADR 0005): decides the shell, not the viewport width. `data-platform`
|
|
8
|
+
* holds an {@link HxOs} (set by `providePlatform()` of the tauri entry) or the coarse `desktop` / `mobile`.
|
|
9
|
+
*/
|
|
10
|
+
export type HxPlatform = 'desktop' | 'mobile' | HxOs;
|
|
11
|
+
/** The shell kind of a platform: `mobile` for ios, android and mobile, `web` for web, else `desktop`. */
|
|
12
|
+
export declare function getHxPlatformKind(platform: HxPlatform): 'desktop' | 'mobile' | 'web';
|
|
13
|
+
/** Read `data-platform` of the root element; `web` when it is absent or unknown. */
|
|
14
|
+
export declare function getHxPlatform(root?: HTMLElement): HxPlatform;
|
|
15
|
+
/** Set `data-platform` on the root element, before the first render. */
|
|
16
|
+
export declare function setHxPlatform(platform: HxPlatform, root?: HTMLElement): void;
|
|
17
|
+
/** A group of the settings tree. */
|
|
18
|
+
export interface HxSettingsGroup {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly title: string;
|
|
21
|
+
/** Groups are listed by this number (default 100), then by title. */
|
|
22
|
+
readonly order?: number;
|
|
23
|
+
}
|
|
24
|
+
/** A registered group together with its pages, both in their listed order. */
|
|
25
|
+
export interface HxSettingsGroupWithPages extends HxSettingsGroup {
|
|
26
|
+
readonly pages: readonly HxSettingsPage[];
|
|
27
|
+
}
|
|
28
|
+
/** One page of a group. */
|
|
29
|
+
export interface HxSettingsPage {
|
|
30
|
+
readonly id: string;
|
|
31
|
+
/** The id of the group the page belongs to. */
|
|
32
|
+
readonly group: string;
|
|
33
|
+
readonly title: string;
|
|
34
|
+
/** Pages are listed by this number (default 100), then by title. */
|
|
35
|
+
readonly order?: number;
|
|
36
|
+
/** The page uses the full width of the view, for example for a table or an editor. */
|
|
37
|
+
readonly wide?: boolean;
|
|
38
|
+
/** Read whenever the page is shown or searched, so signals stay reactive. */
|
|
39
|
+
readonly sections: () => readonly HxSettingsSection[];
|
|
40
|
+
}
|
|
41
|
+
/** A block of items on a page. */
|
|
42
|
+
export interface HxSettingsSection {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly title?: string;
|
|
45
|
+
readonly description?: string;
|
|
46
|
+
readonly items: readonly HxSettingItem[];
|
|
47
|
+
/** Dependent fields that are saved together, with one Save button for the section. */
|
|
48
|
+
readonly form?: HxSettingsForm;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Saves the dependent fields of a section together. The `set` of its items only stages a value, which `get`
|
|
52
|
+
* returns from then on; `save` stores the staged values.
|
|
53
|
+
*/
|
|
54
|
+
export interface HxSettingsForm {
|
|
55
|
+
readonly dirty: () => boolean;
|
|
56
|
+
readonly save: () => void | Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/** One choice of a `select` or `segmented` item. */
|
|
59
|
+
export interface HxSettingOption {
|
|
60
|
+
readonly value: string;
|
|
61
|
+
readonly label: string;
|
|
62
|
+
}
|
|
63
|
+
export interface HxSettingItemBase {
|
|
64
|
+
readonly id: string;
|
|
65
|
+
readonly label: string;
|
|
66
|
+
readonly description?: string;
|
|
67
|
+
/** Extra words the search matches. */
|
|
68
|
+
readonly keywords?: readonly string[];
|
|
69
|
+
readonly disabled?: () => boolean;
|
|
70
|
+
}
|
|
71
|
+
/** An item with a value. `set` saves it. */
|
|
72
|
+
export interface HxSettingValueItem<T> extends HxSettingItemBase {
|
|
73
|
+
readonly get: () => T;
|
|
74
|
+
readonly set: (value: T) => void | Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
export interface HxToggleSettingItem extends HxSettingValueItem<boolean> {
|
|
77
|
+
readonly kind: 'toggle';
|
|
78
|
+
}
|
|
79
|
+
export interface HxSelectSettingItem extends HxSettingValueItem<string> {
|
|
80
|
+
readonly kind: 'select';
|
|
81
|
+
readonly options: readonly HxSettingOption[];
|
|
82
|
+
}
|
|
83
|
+
export interface HxSegmentedSettingItem extends HxSettingValueItem<string> {
|
|
84
|
+
readonly kind: 'segmented';
|
|
85
|
+
readonly options: readonly HxSettingOption[];
|
|
86
|
+
}
|
|
87
|
+
export interface HxTextSettingItem extends HxSettingValueItem<string> {
|
|
88
|
+
readonly kind: 'text';
|
|
89
|
+
readonly placeholder?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface HxNumberSettingItem extends HxSettingValueItem<number> {
|
|
92
|
+
readonly kind: 'number';
|
|
93
|
+
readonly min?: number;
|
|
94
|
+
readonly max?: number;
|
|
95
|
+
readonly step?: number;
|
|
96
|
+
}
|
|
97
|
+
/** A button that runs something. */
|
|
98
|
+
export interface HxActionSettingItem extends HxSettingItemBase {
|
|
99
|
+
readonly kind: 'action';
|
|
100
|
+
readonly buttonLabel: string;
|
|
101
|
+
readonly run: () => void | Promise<void>;
|
|
102
|
+
readonly severity?: HxButtonSeverity;
|
|
103
|
+
}
|
|
104
|
+
/** A value the app only shows. */
|
|
105
|
+
export interface HxReadonlySettingItem extends HxSettingItemBase {
|
|
106
|
+
readonly kind: 'readonly';
|
|
107
|
+
readonly value: () => string;
|
|
108
|
+
/** Shown as a secondary line, for example the file the value comes from. */
|
|
109
|
+
readonly source?: () => string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A control the app renders itself, in the row of the item. The template gets the item as `$implicit`; it
|
|
113
|
+
* applies `disabled` itself.
|
|
114
|
+
*/
|
|
115
|
+
export interface HxCustomSettingItem extends HxSettingItemBase {
|
|
116
|
+
readonly kind: 'custom';
|
|
117
|
+
readonly template: TemplateRef<unknown>;
|
|
118
|
+
/** Required: the search cannot read the texts the template renders. */
|
|
119
|
+
readonly keywords: readonly string[];
|
|
120
|
+
}
|
|
121
|
+
/** One setting; `kind` selects how it is shown. */
|
|
122
|
+
export type HxSettingItem = HxToggleSettingItem | HxSelectSettingItem | HxSegmentedSettingItem | HxTextSettingItem | HxNumberSettingItem | HxActionSettingItem | HxReadonlySettingItem | HxCustomSettingItem;
|
|
123
|
+
export type HxSettingKind = HxSettingItem['kind'];
|
|
124
|
+
/** The id of the page "Appearance" in the group "Appearance & Behavior". */
|
|
125
|
+
export declare const HX_SETTINGS_PAGE_APPEARANCE = "appearance";
|
|
126
|
+
/**
|
|
127
|
+
* Where the values of the Appearance page are kept, for an app with a settings file of its own. The getters are
|
|
128
|
+
* signals, so a change from outside (the file is loaded again) updates the page and the theme.
|
|
129
|
+
*/
|
|
130
|
+
export interface HxAppearanceStore {
|
|
131
|
+
readonly mode: () => HxColorMode;
|
|
132
|
+
setMode(mode: HxColorMode): void | Promise<void>;
|
|
133
|
+
/** An empty string: the font of the app. */
|
|
134
|
+
readonly uiFontFamily: () => string;
|
|
135
|
+
setUiFontFamily(family: string): void | Promise<void>;
|
|
136
|
+
/** The root font size in px, applied from 10 to 24. */
|
|
137
|
+
readonly uiFontSize: () => number;
|
|
138
|
+
setUiFontSize(size: number): void | Promise<void>;
|
|
139
|
+
/** `null`: the density of the theme preset. Without `density` and `setDensity` the page has no density item. */
|
|
140
|
+
readonly density?: () => HxDensity | null;
|
|
141
|
+
setDensity?(density: HxDensity): void | Promise<void>;
|
|
142
|
+
}
|
|
143
|
+
export interface HxAppearanceOptions {
|
|
144
|
+
/**
|
|
145
|
+
* Keeps the values instead of `HxTheme`: the page reads and writes only the store, its values are applied to
|
|
146
|
+
* `HxTheme` and the font variables, and nothing is written to `HxTheme`'s `storageKey`.
|
|
147
|
+
*/
|
|
148
|
+
readonly store?: HxAppearanceStore;
|
|
149
|
+
/** Sections of the app on the Appearance page, after "Theme" and "Fonts". Read like `HxSettingsPage.sections`. */
|
|
150
|
+
readonly extraSections?: () => readonly HxSettingsSection[];
|
|
151
|
+
/** `false` hides the density item. */
|
|
152
|
+
readonly density?: boolean;
|
|
153
|
+
}
|
|
154
|
+
export interface HxSettingsOptions {
|
|
155
|
+
readonly appearance?: HxAppearanceOptions;
|
|
156
|
+
/**
|
|
157
|
+
* Where the font settings are remembered (localStorage) without a `store`; by default the `storageKey` of
|
|
158
|
+
* `HxTheme`. Without either, they are not remembered.
|
|
159
|
+
*/
|
|
160
|
+
readonly fontStorageKey?: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Registers the shared settings (ADR 0014): the page "Appearance" (theme, density, UI font) in the group
|
|
164
|
+
* "Appearance & Behavior". The group "General" has no page of its own; apps add pages to it. The remembered
|
|
165
|
+
* values are applied at start-up.
|
|
166
|
+
*
|
|
167
|
+
* ```ts
|
|
168
|
+
* providers: [provideHxTheme({ storageKey: 'my-app-theme' }), provideHxSettings()]
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export declare function provideHxSettings(options?: HxSettingsOptions): EnvironmentProviders;
|
|
172
|
+
/** The id of the shared group "Appearance & Behavior", listed first. */
|
|
173
|
+
export declare const HX_SETTINGS_GROUP_APPEARANCE = "appearance-behavior";
|
|
174
|
+
/** The id of the shared group "General", listed last. */
|
|
175
|
+
export declare const HX_SETTINGS_GROUP_GENERAL = "general";
|
|
176
|
+
/**
|
|
177
|
+
* The settings of the app (ADR 0014). The shared groups are registered from the start; apps and features
|
|
178
|
+
* register their own groups and pages.
|
|
179
|
+
*/
|
|
180
|
+
export declare class HxSettingsRegistry {
|
|
181
|
+
private readonly registeredGroups;
|
|
182
|
+
private readonly registeredPages;
|
|
183
|
+
private readonly retired;
|
|
184
|
+
/** Every group with its pages, each sorted by order, then title. */
|
|
185
|
+
readonly groups: import("@angular/core").Signal<readonly HxSettingsGroupWithPages[]>;
|
|
186
|
+
/**
|
|
187
|
+
* Registers a group, replacing one with the same id; its pages stay. Returns a function that removes this
|
|
188
|
+
* registration. The pages of a removed group are not listed until the group is registered again.
|
|
189
|
+
*/
|
|
190
|
+
registerGroup(group: HxSettingsGroup): () => void;
|
|
191
|
+
/**
|
|
192
|
+
* Registers a page, replacing one with the same id. Returns a function that removes this registration.
|
|
193
|
+
* Throws when the group of the page is not registered.
|
|
194
|
+
*/
|
|
195
|
+
registerPage(page: HxSettingsPage): () => void;
|
|
196
|
+
/** Maps a retired page id to its replacement, so a persisted id or an old deep link still opens a page. */
|
|
197
|
+
retire(oldId: string, newId: string): void;
|
|
198
|
+
/**
|
|
199
|
+
* The page to show for `pageId`: retired ids are followed; an unknown id gives the first listed page.
|
|
200
|
+
* `undefined` only while no page is registered.
|
|
201
|
+
*/
|
|
202
|
+
resolve(pageId: string): HxSettingsPage | undefined;
|
|
203
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HxSettingsRegistry, never>;
|
|
204
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The groups, pages, sections and items that match `query`. Every word has to appear, ignoring case, in the
|
|
208
|
+
* group title, page title, section title, item label, description or keywords. A page whose title matches
|
|
209
|
+
* keeps all its items. An empty query keeps everything.
|
|
210
|
+
*/
|
|
211
|
+
export declare function hxFilterSettings(groups: readonly HxSettingsGroupWithPages[], query: string): readonly HxSettingsGroupWithPages[];
|
|
212
|
+
/**
|
|
213
|
+
* The content slot of `hx-settings-view`: the template renders one item of the current page. Without it the
|
|
214
|
+
* view renders each item as an `hx-field` row with the control of its kind.
|
|
215
|
+
*
|
|
216
|
+
* ```html
|
|
217
|
+
* <hx-settings-view [(page)]="page">
|
|
218
|
+
* <ng-template hxSettingItem let-item>{{ item.label }}</ng-template>
|
|
219
|
+
* </hx-settings-view>
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
export declare class HxSettingItemTemplate {
|
|
223
|
+
readonly template: TemplateRef<{
|
|
224
|
+
$implicit: HxSettingItem;
|
|
225
|
+
}>;
|
|
226
|
+
static ngTemplateContextGuard(_directive: HxSettingItemTemplate, _context: unknown): _context is {
|
|
227
|
+
$implicit: HxSettingItem;
|
|
228
|
+
};
|
|
229
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HxSettingItemTemplate, never>;
|
|
230
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<HxSettingItemTemplate, "ng-template[hxSettingItem]", never, {}, {}, never, never, true, never>;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The frame of the settings (ADR 0014): a search field and the tree of groups and pages beside the current
|
|
234
|
+
* page with its breadcrumb. It shows what `HxSettingsRegistry` holds; groups without pages are not listed.
|
|
235
|
+
* The app decides where it appears, and persists the two models: `page` (set it to open a deep link; a retired
|
|
236
|
+
* or unknown id is resolved by the registry) and `collapsed` (the ids of the closed groups).
|
|
237
|
+
*
|
|
238
|
+
* ```html
|
|
239
|
+
* <hx-settings-view [(page)]="pageId" [(collapsed)]="closedGroups" />
|
|
240
|
+
* ```
|
|
241
|
+
*
|
|
242
|
+
* The tree is an `hx-tree`, so it has its keyboard support; Enter, Space or a click on a group opens or closes
|
|
243
|
+
* it. Ctrl+F (Command+F on Apple) focuses the search, Escape clears it. A search lists the matching pages with
|
|
244
|
+
* every group open, highlights the matching rows of the current page and leaves `collapsed` as it is.
|
|
245
|
+
*
|
|
246
|
+
* Each item is an `hx-field` row with the label, the description and the control of its kind. A change calls
|
|
247
|
+
* `set` (a text field on change or blur). A section with a `form` has a Save button, enabled while `dirty()`;
|
|
248
|
+
* there `set` only stages the value, and what `set` or `save` throw is shown in the section. Outside a form,
|
|
249
|
+
* what `set` throws goes to the `ErrorHandler`.
|
|
250
|
+
*/
|
|
251
|
+
export declare class HxSettingsView {
|
|
252
|
+
private readonly registry;
|
|
253
|
+
private readonly searchShortcut;
|
|
254
|
+
/** The id of the current page. */
|
|
255
|
+
readonly page: import("@angular/core").ModelSignal<string>;
|
|
256
|
+
/** The ids of the collapsed groups. */
|
|
257
|
+
readonly collapsed: import("@angular/core").ModelSignal<readonly string[]>;
|
|
258
|
+
protected readonly itemTemplate: import("@angular/core").Signal<HxSettingItemTemplate | undefined>;
|
|
259
|
+
private readonly search;
|
|
260
|
+
private readonly tree;
|
|
261
|
+
protected readonly idPrefix: string;
|
|
262
|
+
protected readonly query: import("@angular/core").WritableSignal<string>;
|
|
263
|
+
private readonly searching;
|
|
264
|
+
protected readonly visibleGroups: import("@angular/core").Signal<HxSettingsGroupWithPages[]>;
|
|
265
|
+
/** The page shown, with its group; `undefined` while no page is registered. */
|
|
266
|
+
protected readonly current: import("@angular/core").Signal<{
|
|
267
|
+
page: HxSettingsPage;
|
|
268
|
+
group: HxSettingsGroupWithPages;
|
|
269
|
+
} | undefined>;
|
|
270
|
+
protected readonly sections: import("@angular/core").Signal<readonly HxSettingsSection[]>;
|
|
271
|
+
/** The groups as tree nodes with their pages as leaves; the keys are `g:<group id>` and `p:<page id>`. */
|
|
272
|
+
protected readonly nodes: import("@angular/core").Signal<HxTreeNode<unknown>[]>;
|
|
273
|
+
/** The tree key of the current page. */
|
|
274
|
+
protected readonly selection: import("@angular/core").Signal<string | null>;
|
|
275
|
+
constructor();
|
|
276
|
+
/**
|
|
277
|
+
* The ids of the items of a section to highlight during a search: every word is in the titles around the
|
|
278
|
+
* item or in its own texts, and at least one is in its own texts, so a matching title alone marks no row.
|
|
279
|
+
*/
|
|
280
|
+
protected hits(group: string, page: string, section: HxSettingsSection): ReadonlySet<string>;
|
|
281
|
+
protected sectionKey(section: HxSettingsSection): string;
|
|
282
|
+
protected setQuery(event: Event): void;
|
|
283
|
+
/** A page becomes the current one; a group opens or closes, and the current page stays selected. */
|
|
284
|
+
protected onSelect(tree: HxTree, selection: HxTreeSelection): void;
|
|
285
|
+
protected groupOpened(key: string): void;
|
|
286
|
+
/** During a search every group stays open. */
|
|
287
|
+
protected groupClosed(tree: HxTree, key: string): void;
|
|
288
|
+
/** Ctrl+F (Command+F on Apple) anywhere in the view moves to the search field. */
|
|
289
|
+
protected onKeydown(event: KeyboardEvent): void;
|
|
290
|
+
/** Escape in the search field clears it. */
|
|
291
|
+
protected onSearchKeydown(event: KeyboardEvent): void;
|
|
292
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HxSettingsView, never>;
|
|
293
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<HxSettingsView, "hx-settings-view", never, {
|
|
294
|
+
"page": {
|
|
295
|
+
"alias": "page";
|
|
296
|
+
"required": false;
|
|
297
|
+
"isSignal": true;
|
|
298
|
+
};
|
|
299
|
+
"collapsed": {
|
|
300
|
+
"alias": "collapsed";
|
|
301
|
+
"required": false;
|
|
302
|
+
"isSignal": true;
|
|
303
|
+
};
|
|
304
|
+
}, {
|
|
305
|
+
"page": "pageChange";
|
|
306
|
+
"collapsed": "collapsedChange";
|
|
307
|
+
}, ["itemTemplate"], never, true, never>;
|
|
308
|
+
}
|
|
309
|
+
/** The most items a bottom bar shows; more do not fit a phone. */
|
|
310
|
+
export declare const HX_BOTTOM_BAR_MAX_ITEMS = 5;
|
|
311
|
+
/** Where a view opens: in the sidebar or as a tab (ADR 0005). */
|
|
312
|
+
export type HelixViewPlacement = 'sidebar' | 'tab';
|
|
313
|
+
/** The end of the activity bar a view sits at. */
|
|
314
|
+
export type HelixViewPosition = 'top' | 'bottom';
|
|
315
|
+
/** Where a view sits in the mobile shell: the bottom bar or the drawer. */
|
|
316
|
+
export type HelixViewMobilePlacement = 'bar' | 'drawer';
|
|
317
|
+
/** The content of a view: a component type or a lazy loader of one. */
|
|
318
|
+
export type HelixViewContent = Type<unknown> | (() => Promise<Type<unknown>>);
|
|
319
|
+
/**
|
|
320
|
+
* One view of the app, declared once for the desktop and the mobile shell (ADR 0005). The content is
|
|
321
|
+
* supplied by the app for the `id`.
|
|
322
|
+
*/
|
|
323
|
+
export interface HelixView {
|
|
324
|
+
readonly id: string;
|
|
325
|
+
readonly label: string;
|
|
326
|
+
/** An inline SVG template, or an icon name the app resolves through its own icon registry. */
|
|
327
|
+
readonly icon: TemplateRef<unknown> | string;
|
|
328
|
+
readonly placement: HelixViewPlacement;
|
|
329
|
+
readonly position: HelixViewPosition;
|
|
330
|
+
/** The platforms the view exists on (a platform or its kind); absent means all. */
|
|
331
|
+
readonly platforms?: readonly HxPlatform[];
|
|
332
|
+
/** Where the view sits on mobile; absent means the drawer. `placement` is the one on desktop and web. */
|
|
333
|
+
readonly mobilePlacement?: HelixViewMobilePlacement;
|
|
334
|
+
/** The order in the bottom bar; views without one come after those with one. */
|
|
335
|
+
readonly barOrder?: number;
|
|
336
|
+
/** The content on every platform without an entry in `platformContent`. */
|
|
337
|
+
readonly content?: HelixViewContent;
|
|
338
|
+
/** The content per platform kind. */
|
|
339
|
+
readonly platformContent?: Partial<Record<'desktop' | 'mobile' | 'web', HelixViewContent>>;
|
|
340
|
+
}
|
|
341
|
+
/** The views that exist on the platform, in list order. */
|
|
342
|
+
export declare function hxViewsFor<V extends HelixView>(views: readonly V[], platform?: HxPlatform): V[];
|
|
343
|
+
/**
|
|
344
|
+
* Split the views of the platform into the bottom bar (`mobilePlacement: 'bar'`, by `barOrder`, at most
|
|
345
|
+
* `HX_BOTTOM_BAR_MAX_ITEMS`) and the drawer (the rest, in list order).
|
|
346
|
+
*/
|
|
347
|
+
export declare function hxMobileViews<V extends HelixView>(views: readonly V[], platform?: HxPlatform): {
|
|
348
|
+
bar: V[];
|
|
349
|
+
drawer: V[];
|
|
350
|
+
};
|
|
351
|
+
/** The content of a view on the platform: `platformContent` of its kind, else `content`. */
|
|
352
|
+
export declare function hxViewContent(view: HelixView, platform?: HxPlatform): HelixViewContent | undefined;
|
|
353
|
+
/**
|
|
354
|
+
* The smallest width of a desktop window in CSS px. From this width up `hx-app-shell`, with the sidebar at its
|
|
355
|
+
* default width, lays out without horizontal scroll. A Tauri app sets at least this as `minWidth` of its main window.
|
|
356
|
+
*/
|
|
357
|
+
export declare const HX_WINDOW_MIN_WIDTH = 720;
|
|
358
|
+
/** The smallest height of a desktop window in CSS px: at least the `minHeight` of a Tauri app's main window. */
|
|
359
|
+
export declare const HX_WINDOW_MIN_HEIGHT = 480;
|
|
360
|
+
export declare const HELIX_DESKTOP_VERSION = "0.1.0";
|