@gandalan/weblibs 2.0.11 → 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 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) und `NeherApp3I18n`
20
+ `NeherApp3Messages` (In-Realm-Nachrichtenbus), `NeherApp3I18n`
21
21
  (Lokalisierung: `localize` als Funktion *und* Svelte-Action, Modul-Kataloge,
22
- sprachrichtige Sortierung). Die Datei enthaelt nur Typen und wird von Hand
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
 
@@ -85,7 +85,7 @@
85
85
  * @property {(node: HTMLElement, props: NeherApp3SetupContext) => void | function} [mount] - Must return an optional unmount function
86
86
  * @property {string} [embedUrl]
87
87
  * @property {string[]} [extraCSS]
88
- * @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`).
89
89
  */
90
90
 
91
91
  /**
@@ -355,6 +355,43 @@
355
355
  * @property {() => void} clearCache - Discard the cached profiles, so the next lookup asks again.
356
356
  */
357
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
+
358
395
  /**
359
396
  * @typedef {Object} NeherApp3
360
397
  * @property {(menuItem: NeherApp3MenuItem) => void} addMenuItem - Adds a menu item. If an item with the same `id` already exists it is replaced.
@@ -369,6 +406,7 @@
369
406
  * @property {Localize} localize - Shorthand for `i18n.localize` (namespace `shell`): a function for strings, a `use:` action for elements.
370
407
  * @property {NeherApp3Settings} settings - Per-user settings, stored in the database (not `localStorage`).
371
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.
372
410
  * @property {boolean} isEmbedded - Indicates if the app is embedded inside i3
373
411
  */
374
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
 
@@ -2232,6 +2233,22 @@ export type NeherApp3SettingsHandle = {
2232
2233
 
2233
2234
  export type NeherApp3SetupContext = NeherApp3Props & { neherapp3: NeherApp3 };
2234
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
+
2235
2252
  export type NeherMessage = {
2236
2253
  id: string;
2237
2254
  type: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gandalan/weblibs",
3
- "version": "2.0.11",
3
+ "version": "2.0.12",
4
4
  "description": "WebLibs for Gandalan JS/TS projects",
5
5
  "keywords": [
6
6
  "gandalan"