@gandalan/weblibs 2.0.10 → 2.0.12
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/README.md +3 -2
- package/api/neherApp3Types.js +40 -1
- package/index.d.ts +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
### NeherApp3-Hosttypen
|
|
18
18
|
`api/neherApp3Types.js` ist die Master-Referenz fuer die Vertraege der
|
|
19
19
|
NeherApp3-Rahmen-App: `NeherApp3` (Host-API), `NeherApp3Module` (Modul-Einstieg),
|
|
20
|
-
`NeherApp3Messages` (In-Realm-Nachrichtenbus)
|
|
20
|
+
`NeherApp3Messages` (In-Realm-Nachrichtenbus), `NeherApp3I18n`
|
|
21
21
|
(Lokalisierung: `localize` als Funktion *und* Svelte-Action, Modul-Kataloge,
|
|
22
|
-
sprachrichtige Sortierung)
|
|
22
|
+
sprachrichtige Sortierung) und `NeherApp3Theme` (Hell-/Dunkel-Modus; Module im
|
|
23
|
+
Shadow DOM liefern beide Themes mit, das `data-theme` setzt die Rahmen-App). Die Datei enthaelt nur Typen und wird von Hand
|
|
23
24
|
gepflegt; die Leitfaeden liegen im NeherApp3-Repository
|
|
24
25
|
(`docs/MODULE.md`, `docs/MESSAGING.md`, `docs/I18N.md`).
|
|
25
26
|
|
package/api/neherApp3Types.js
CHANGED
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
* @property {string | null} [parent] - Parent menu item (optional). If not set, the item will be added to the top level menu.
|
|
71
71
|
* @property {boolean} [hidden] - If true, the menu item will not be displayed
|
|
72
72
|
* @property {boolean} [separator] - If true, renders as a non-interactive divider between items (text/icon/url are ignored). Use `parent` to place the separator inside a sub-menu.
|
|
73
|
+
* @property {boolean} [heading] - If true, renders `text` as a non-interactive group heading inside a sub-menu (ALL CAPS, bold, extra space above; icon/url are ignored). Requires `parent`; ignored on the top level. `text` is translated like any other entry.
|
|
73
74
|
* @property {string} [i18nNamespace] - Catalog in which `text` is translated. Set automatically to the registering module's name; only pass it explicitly for items added outside `setup`. See `NeherApp3I18n`.
|
|
74
75
|
*/
|
|
75
76
|
|
|
@@ -84,7 +85,7 @@
|
|
|
84
85
|
* @property {(node: HTMLElement, props: NeherApp3SetupContext) => void | function} [mount] - Must return an optional unmount function
|
|
85
86
|
* @property {string} [embedUrl]
|
|
86
87
|
* @property {string[]} [extraCSS]
|
|
87
|
-
* @property {boolean} [useShadowDom] - If true, the app will be embedded in a shadow DOM. This is required for CSS isolation.
|
|
88
|
+
* @property {boolean} [useShadowDom] - If true, the app will be embedded in a shadow DOM. This is required for CSS isolation. The module then ships all of its styles itself — including **both** themes (`neher`, `neher-dark`), because the shell mirrors `data-theme` onto the module's root inside the shadow root (see `NeherApp3Theme`).
|
|
88
89
|
*/
|
|
89
90
|
|
|
90
91
|
/**
|
|
@@ -354,6 +355,43 @@
|
|
|
354
355
|
* @property {() => void} clearCache - Discard the cached profiles, so the next lookup asks again.
|
|
355
356
|
*/
|
|
356
357
|
|
|
358
|
+
/**
|
|
359
|
+
* Theme handle, exposed at `neherapp3.theme`.
|
|
360
|
+
*
|
|
361
|
+
* The shell writes the resolved theme name to `data-theme` on `<html>`, so
|
|
362
|
+
* anything in the light DOM follows it by inheritance. **Inside a Shadow DOM
|
|
363
|
+
* module it does not**: an attribute selector never crosses the shadow
|
|
364
|
+
* boundary, and the module's own `:host` rules override the inherited custom
|
|
365
|
+
* properties — a module built with the shell's daisyUI setup would stay light
|
|
366
|
+
* forever. The shell therefore mirrors `data-theme` onto the module's root
|
|
367
|
+
* element inside the shadow root and keeps it in sync; a module only needs to
|
|
368
|
+
* ship both themes (`neher`, `neher-dark`) in its stylesheet.
|
|
369
|
+
*
|
|
370
|
+
* `subscribe` is for consumers without Svelte reactivity (and for reacting to
|
|
371
|
+
* a switch, e.g. to repaint a canvas or reload a themed asset).
|
|
372
|
+
* @typedef {Object} NeherApp3Theme
|
|
373
|
+
* @property {NeherApp3ThemeName} current - Active, resolved theme name (reactive).
|
|
374
|
+
* @property {NeherApp3ThemePreference} preference - Stored choice, including `"system"` (reactive).
|
|
375
|
+
* @property {boolean} isDark - Shorthand for `current === "neher-dark"` (reactive).
|
|
376
|
+
* @property {(preference: NeherApp3ThemePreference) => void} set - Store a preference and apply it.
|
|
377
|
+
* @property {() => void} toggle - Switch light/dark as an explicit choice (replaces `"system"`).
|
|
378
|
+
* @property {(listener: (theme: NeherApp3ThemeName) => void) => (() => void)} subscribe - Listen for theme changes; called immediately with the current theme, returns an unsubscribe function.
|
|
379
|
+
* @property {"neher"} LIGHT - Theme name of the light mode.
|
|
380
|
+
* @property {"neher-dark"} DARK - Theme name of the dark mode.
|
|
381
|
+
* @property {"system"} SYSTEM - Preference "follow the operating system".
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Resolved theme name — the value of the `data-theme` attribute.
|
|
386
|
+
* @typedef {"neher" | "neher-dark"} NeherApp3ThemeName
|
|
387
|
+
*/
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Stored theme choice: a theme name, or `"system"` to follow
|
|
391
|
+
* `prefers-color-scheme` live.
|
|
392
|
+
* @typedef {NeherApp3ThemeName | "system"} NeherApp3ThemePreference
|
|
393
|
+
*/
|
|
394
|
+
|
|
357
395
|
/**
|
|
358
396
|
* @typedef {Object} NeherApp3
|
|
359
397
|
* @property {(menuItem: NeherApp3MenuItem) => void} addMenuItem - Adds a menu item. If an item with the same `id` already exists it is replaced.
|
|
@@ -368,6 +406,7 @@
|
|
|
368
406
|
* @property {Localize} localize - Shorthand for `i18n.localize` (namespace `shell`): a function for strings, a `use:` action for elements.
|
|
369
407
|
* @property {NeherApp3Settings} settings - Per-user settings, stored in the database (not `localStorage`).
|
|
370
408
|
* @property {NeherApp3Profile} profile - The signed-in user: identity from the IDAS token plus the platform's own profile fields (avatar, job title, …).
|
|
409
|
+
* @property {NeherApp3Theme} theme - Light/dark mode: the active theme, the stored preference, and a subscription for theme changes.
|
|
371
410
|
* @property {boolean} isEmbedded - Indicates if the app is embedded inside i3
|
|
372
411
|
*/
|
|
373
412
|
|
package/index.d.ts
CHANGED
|
@@ -2079,6 +2079,7 @@ export type NeherApp3 = {
|
|
|
2079
2079
|
localize: Localize;
|
|
2080
2080
|
settings: NeherApp3Settings;
|
|
2081
2081
|
profile: NeherApp3Profile;
|
|
2082
|
+
theme: NeherApp3Theme;
|
|
2082
2083
|
isEmbedded: boolean;
|
|
2083
2084
|
};
|
|
2084
2085
|
|
|
@@ -2144,6 +2145,7 @@ export type NeherApp3MenuItem = {
|
|
|
2144
2145
|
parent?: string | null;
|
|
2145
2146
|
hidden?: boolean;
|
|
2146
2147
|
separator?: boolean;
|
|
2148
|
+
heading?: boolean;
|
|
2147
2149
|
i18nNamespace?: string;
|
|
2148
2150
|
};
|
|
2149
2151
|
|
|
@@ -2231,6 +2233,22 @@ export type NeherApp3SettingsHandle = {
|
|
|
2231
2233
|
|
|
2232
2234
|
export type NeherApp3SetupContext = NeherApp3Props & { neherapp3: NeherApp3 };
|
|
2233
2235
|
|
|
2236
|
+
export type NeherApp3Theme = {
|
|
2237
|
+
current: NeherApp3ThemeName;
|
|
2238
|
+
preference: NeherApp3ThemePreference;
|
|
2239
|
+
isDark: boolean;
|
|
2240
|
+
set: (preference: NeherApp3ThemePreference) => void;
|
|
2241
|
+
toggle: () => void;
|
|
2242
|
+
subscribe: (listener: (theme: NeherApp3ThemeName) => void) => (() => void);
|
|
2243
|
+
LIGHT: "neher";
|
|
2244
|
+
DARK: "neher-dark";
|
|
2245
|
+
SYSTEM: "system";
|
|
2246
|
+
};
|
|
2247
|
+
|
|
2248
|
+
export type NeherApp3ThemeName = "neher" | "neher-dark";
|
|
2249
|
+
|
|
2250
|
+
export type NeherApp3ThemePreference = NeherApp3ThemeName | "system";
|
|
2251
|
+
|
|
2234
2252
|
export type NeherMessage = {
|
|
2235
2253
|
id: string;
|
|
2236
2254
|
type: string;
|