@adea-ai/app-framework 0.30.0 → 0.31.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 (43) hide show
  1. package/dist/app/application.js +4 -2
  2. package/dist/appearance/appearance-host.js +6 -0
  3. package/dist/appearance/appearance-preferences.js +6 -2
  4. package/dist/appearance/composition.d.ts +1 -1
  5. package/dist/appearance/custom-theme-import.js +12 -19
  6. package/dist/appearance/custom-theme-library.d.ts +5 -4
  7. package/dist/appearance/custom-theme-library.js +20 -2
  8. package/dist/appearance/editor.js +4 -1
  9. package/dist/appearance/legacy-imported-theme-token-projection.d.ts +84 -0
  10. package/dist/appearance/legacy-imported-theme-token-projection.js +142 -0
  11. package/dist/appearance/theme-record-adapter.js +37 -9
  12. package/dist/framework-source.json +1 -1
  13. package/dist/shell/app-shell.js +76 -48
  14. package/dist/shell/app-utilities.d.ts +5 -3
  15. package/dist/shell/app-utilities.js +15 -7
  16. package/dist/shell/help-shortcuts.d.ts +4 -0
  17. package/dist/shell/help-shortcuts.js +38 -7
  18. package/dist/shell/keyboard-target.d.ts +2 -0
  19. package/dist/shell/keyboard-target.js +54 -0
  20. package/dist/shell/settings-sections.d.ts +5 -0
  21. package/dist/shell/settings-shortcuts.d.ts +10 -0
  22. package/dist/shell/settings-shortcuts.js +67 -0
  23. package/dist/views/app-help.js +2 -1
  24. package/dist/views/app-settings.js +5 -2
  25. package/dist/views/appearance-surface.js +33 -19
  26. package/package.json +6 -4
  27. package/src/app/application.tsx +3 -1
  28. package/src/appearance/appearance-host.tsx +6 -0
  29. package/src/appearance/appearance-preferences.ts +7 -1
  30. package/src/appearance/composition.ts +3 -1
  31. package/src/appearance/custom-theme-import.ts +21 -37
  32. package/src/appearance/custom-theme-library.ts +21 -5
  33. package/src/appearance/editor.ts +7 -6
  34. package/src/appearance/legacy-imported-theme-token-projection.ts +51 -0
  35. package/src/appearance/theme-record-adapter.ts +58 -11
  36. package/src/shell/app-shell.tsx +88 -58
  37. package/src/shell/app-utilities.tsx +29 -17
  38. package/src/shell/help-shortcuts.ts +77 -6
  39. package/src/shell/keyboard-target.ts +74 -0
  40. package/src/shell/settings-sections.ts +5 -0
  41. package/src/shell/settings-shortcuts.ts +116 -0
  42. package/src/views/app-settings.tsx +5 -3
  43. package/src/views/appearance-surface.tsx +63 -27
@@ -1,5 +1,6 @@
1
+ import { hasEditableKeyboardTarget } from "./keyboard-target.js";
1
2
  import { className, createComponent, effect, insert, memo, mergeProps, template } from "solid-js/web";
2
- import { For, Show, Suspense, createEffect, createSignal, lazy, onCleanup, onMount } from "solid-js";
3
+ import { For, Show, Suspense, createComputed, createEffect, createSignal, lazy, onCleanup, onMount, untrack } from "solid-js";
3
4
  import { AppShell, AppShellBody, AppShellContent, AppShellMain, SkipLink } from "@adea-ai/ui/components/layout/app-shell";
4
5
  import { ContextualSidebar } from "@adea-ai/ui/components/layout/contextual-sidebar";
5
6
  import { PixelPane } from "@adea-ai/ui/components/layout/pixel-pane";
@@ -26,52 +27,72 @@ function createNarrow(query) {
26
27
  });
27
28
  return narrow;
28
29
  }
29
- var nonTextInputTypes = /* @__PURE__ */ new Set([
30
- "button",
31
- "checkbox",
32
- "color",
33
- "file",
34
- "hidden",
35
- "image",
36
- "radio",
37
- "range",
38
- "reset",
39
- "submit"
40
- ]);
41
- /** Whether an element or an ancestor in its composed path accepts text editing. */
42
- function isEditableElementPath(path) {
43
- let inheritedEditable = false;
44
- for (const target of path) {
45
- if (!(target instanceof Element)) continue;
46
- if (target instanceof HTMLInputElement) {
47
- if (!target.disabled && !target.readOnly && !nonTextInputTypes.has(target.type)) return true;
48
- } else if (target instanceof HTMLTextAreaElement) {
49
- if (!target.disabled && !target.readOnly) return true;
50
- }
51
- const contentEditable = target.getAttribute("contenteditable")?.toLowerCase();
52
- if (contentEditable === "false") return false;
53
- if (contentEditable === "" || contentEditable === "true" || contentEditable === "plaintext-only") return true;
54
- if (target instanceof HTMLElement && target.isContentEditable) inheritedEditable = true;
55
- if (target.ownerDocument.designMode?.toLowerCase() === "on") inheritedEditable = true;
56
- }
57
- return inheritedEditable;
58
- }
59
- function hasEditableTarget(event) {
60
- const path = event.composedPath();
61
- if (path.some((target) => target instanceof Element)) return isEditableElementPath(path);
62
- const activePath = [];
63
- let activeElement = document.activeElement;
64
- while (activeElement) {
65
- activePath.push(activeElement);
66
- activeElement = activeElement.shadowRoot?.activeElement ?? null;
30
+ function getSidebarResponsiveMode(sidebar) {
31
+ if (sidebar && "responsiveMode" in sidebar) {
32
+ const mode = sidebar.responsiveMode;
33
+ if (mode === "auto" || mode === "desktop" || mode === "mobile") return mode;
67
34
  }
68
- return isEditableElementPath(activePath);
69
35
  }
70
36
  /** Shared chrome and navigation composition; applications own routes and services. */
71
37
  function ApplicationShell(props) {
72
38
  let sidebarToggle;
73
39
  const narrow = createNarrow(() => props.drawer ? props.narrowQuery ?? "(max-width: 799px)" : void 0);
74
40
  const sidebarMobile = createNarrow(() => !props.drawer && props.sidebar ? "(max-width: 48rem)" : void 0);
41
+ const [sidebarElementMobile, setSidebarElementMobile] = createSignal();
42
+ const sidebarElements = /* @__PURE__ */ new Map();
43
+ const sidebarElementCallbacks = /* @__PURE__ */ new Map();
44
+ createEffect(() => {
45
+ const nextCallback = props.sidebar?.onSidebarElement;
46
+ for (const [mobile, element] of sidebarElements) {
47
+ const previousCallback = sidebarElementCallbacks.get(mobile);
48
+ if (previousCallback === nextCallback) continue;
49
+ previousCallback?.(void 0, mobile);
50
+ nextCallback?.(element, mobile);
51
+ sidebarElementCallbacks.set(mobile, nextCallback);
52
+ }
53
+ });
54
+ const isSidebarMobile = () => {
55
+ const mountedMode = sidebarElementMobile();
56
+ if (mountedMode !== void 0) return mountedMode;
57
+ const mode = getSidebarResponsiveMode(props.sidebar);
58
+ if (mode === "mobile") return true;
59
+ if (mode === "desktop") return false;
60
+ return sidebarMobile();
61
+ };
62
+ const restoreSidebarFocus = (sidebar) => {
63
+ const active = sidebar?.ownerDocument.activeElement;
64
+ if (!props.sidebar || sidebar?.dataset.open !== "true" || !sidebar.isConnected || !active || !sidebar.contains(active)) return;
65
+ const target = props.sidebar.restoreFocusRef ? props.sidebar.restoreFocusRef() : sidebarToggle;
66
+ if (target?.isConnected) target.focus({ preventScroll: true });
67
+ };
68
+ let requestedModeInitialized = false;
69
+ let previousRequestedMode;
70
+ createComputed(() => {
71
+ const next = getSidebarResponsiveMode(props.sidebar);
72
+ const shouldRestore = requestedModeInitialized && next === "mobile" && previousRequestedMode !== "mobile";
73
+ previousRequestedMode = next;
74
+ requestedModeInitialized = true;
75
+ if (shouldRestore) untrack(() => restoreSidebarFocus(sidebarElements.get(false)));
76
+ });
77
+ const handleSidebarModeTransition = (event) => {
78
+ props.sidebar?.onResponsiveModeTransition?.(event);
79
+ if (event.phase === "before" && event.from === "desktop" && event.to === "mobile") restoreSidebarFocus(event.desktopSidebar);
80
+ };
81
+ const handleSidebarElement = (element, mobile) => {
82
+ if (element) {
83
+ sidebarElements.set(mobile, element);
84
+ const callback = props.sidebar?.onSidebarElement;
85
+ sidebarElementCallbacks.set(mobile, callback);
86
+ setSidebarElementMobile(mobile);
87
+ callback?.(element, mobile);
88
+ return;
89
+ }
90
+ const callback = sidebarElementCallbacks.get(mobile);
91
+ sidebarElements.delete(mobile);
92
+ sidebarElementCallbacks.delete(mobile);
93
+ setSidebarElementMobile(void 0);
94
+ callback?.(void 0, mobile);
95
+ };
75
96
  const [drawerOpen, setDrawerOpen] = createSignal(false);
76
97
  const [drawerMounted, setDrawerMounted] = createSignal(false);
77
98
  createEffect(() => {
@@ -92,14 +113,14 @@ function ApplicationShell(props) {
92
113
  current?.onOpenChange(!current.open);
93
114
  };
94
115
  const handleToggle = (event) => {
95
- if (event.defaultPrevented || !toggleVisible() || !(event.metaKey || event.ctrlKey) || event.altKey || event.shiftKey || event.key.toLowerCase() !== "b" || hasEditableTarget(event)) return;
116
+ if (event.defaultPrevented || !toggleVisible() || !(event.metaKey || event.ctrlKey) || event.altKey || event.shiftKey || event.key.toLowerCase() !== "b" || hasEditableKeyboardTarget(event)) return;
96
117
  event.preventDefault();
97
- toggle();
118
+ if (!event.repeat) toggle();
98
119
  };
99
120
  const handleSearch = (event) => {
100
121
  if (!props.onSearch || event.defaultPrevented || !(event.metaKey || event.ctrlKey) || event.altKey || event.shiftKey || event.key.toLowerCase() !== "k") return;
101
122
  event.preventDefault();
102
- props.onSearch();
123
+ if (!event.repeat) props.onSearch();
103
124
  };
104
125
  onMount(() => {
105
126
  window.addEventListener("keydown", handleSearch);
@@ -130,7 +151,10 @@ function ApplicationShell(props) {
130
151
  return props.workspace;
131
152
  },
132
153
  get sidebarOpen() {
133
- return memo(() => !!!narrow())() && leading()?.open;
154
+ return memo(() => !!(!narrow() && leading()?.open))() && !isSidebarMobile();
155
+ },
156
+ get alignSidebarAtNarrow() {
157
+ return getSidebarResponsiveMode(props.sidebar) === "desktop";
134
158
  },
135
159
  get sidebarWidth() {
136
160
  return leading()?.width;
@@ -287,7 +311,7 @@ function ApplicationShell(props) {
287
311
  children: (sidebar) => createComponent(PixelPane, {
288
312
  "class": "overflow-visible",
289
313
  get hidden() {
290
- return narrow() || sidebarMobile();
314
+ return narrow() || isSidebarMobile();
291
315
  },
292
316
  get width() {
293
317
  return memo(() => !!sidebar().open)() ? sidebar().width : 0;
@@ -298,9 +322,13 @@ function ApplicationShell(props) {
298
322
  return !props.drawer || !narrow();
299
323
  },
300
324
  get children() {
301
- return createComponent(ContextualSidebar, mergeProps(sidebar, { get restoreFocusRef() {
302
- return sidebar().restoreFocusRef ?? (() => sidebarToggle);
303
- } }));
325
+ return createComponent(ContextualSidebar, mergeProps(sidebar, {
326
+ onSidebarElement: handleSidebarElement,
327
+ onResponsiveModeTransition: handleSidebarModeTransition,
328
+ get restoreFocusRef() {
329
+ return sidebar().restoreFocusRef ?? (() => sidebarToggle);
330
+ }
331
+ }));
304
332
  }
305
333
  });
306
334
  }
@@ -2,7 +2,7 @@ import { type AccountMenuItem } from '@adea-ai/ui/components/composites/account-
2
2
  import type { UpdateAdapter, UpdateState } from '@adea-ai/ui/components/composites/update-dialog';
3
3
  import { type ThemeProviderProps } from '@adea-ai/ui/components/theme/lazy';
4
4
  import { type JSX } from 'solid-js';
5
- import type { HelpLink, HelpShortcut } from './help-shortcuts';
5
+ import { type HelpLink, type HelpShortcut } from './help-shortcuts';
6
6
  import { type ApplicationSettingsSection } from './settings-sections';
7
7
  import { type ShortcutPlatform } from './shortcut-platform';
8
8
  import { type UpdateChannelSource } from '../updates/update-adapter';
@@ -64,8 +64,10 @@ export type ApplicationHelpConfig = Readonly<{
64
64
  links: readonly HelpLink[];
65
65
  /** App-specific shortcuts, listed before the ones the framework binds. */
66
66
  shortcuts?: readonly HelpShortcut[];
67
- /** Whether the host binds the framework search chord. */
67
+ /** Whether Help lists Open search; defaults to whether the Application binds it. */
68
68
  search?: boolean;
69
+ /** Whether the enclosing Application shell consumes Meta/Ctrl+K despite hiding its help row. */
70
+ searchBinding?: boolean;
69
71
  }>;
70
72
  export type ApplicationAccountMenuConfig = Readonly<{
71
73
  /** The trigger's accessible name; defaults to `Application settings`. */
@@ -76,7 +78,7 @@ export type ApplicationAccountMenuConfig = Readonly<{
76
78
  onIntent?(): void;
77
79
  /** A chord drawn on the Settings row, e.g. `settingsShortcutLabel('mac')`. */
78
80
  settingsShortcut?: string;
79
- /** The parseable chord behind `settingsShortcut`; defaults to `Meta+, Control+,`. */
81
+ /** Space-separated ARIA chords behind `settingsShortcut`; defaults to `Meta+, Control+,`. */
80
82
  settingsKeyshortcuts?: string;
81
83
  /** Show the Appearance item (the default). Apps with their own control can hide it. */
82
84
  appearance?: boolean;
@@ -1,5 +1,7 @@
1
- import { defineSettingsSections, settingsSectionFromHash } from "./settings-sections.js";
1
+ import { hasEditableKeyboardTarget } from "./keyboard-target.js";
2
2
  import { detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey } from "./shortcut-platform.js";
3
+ import { matchesSettingsKeyshortcuts, parseSettingsKeyshortcuts } from "./settings-shortcuts.js";
4
+ import { defineSettingsSections, settingsSectionFromHash } from "./settings-sections.js";
3
5
  import { browserUpdateAdapter } from "../updates/update-adapter.js";
4
6
  import { createComponent, memo, mergeProps, template } from "solid-js/web";
5
7
  import { Show, Suspense, createEffect, createMemo, createSignal, lazy, on, onCleanup, onMount } from "solid-js";
@@ -21,10 +23,6 @@ function ApplicationThemeProvider(props) {
21
23
  } }));
22
24
  }
23
25
  var appearanceSectionId = "appearance";
24
- var settingsKeyshortcuts = "Meta+, Control+,";
25
- function isSettingsChord(event) {
26
- return !event.defaultPrevented && (event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey && event.key === ",";
27
- }
28
26
  function placeAppearance(sections, appearance, position) {
29
27
  const index = position === "end" ? sections.length : typeof position === "number" ? Math.max(0, Math.min(sections.length, Math.trunc(position))) : 0;
30
28
  return [
@@ -119,8 +117,16 @@ function ApplicationUtilities(props) {
119
117
  openHelp: () => open("help"),
120
118
  openUpdates: () => openUpdates()
121
119
  }));
120
+ const settingsKeyshortcuts = createMemo(() => {
121
+ const value = props.accountMenu?.settingsKeyshortcuts ?? "Meta+, Control+,";
122
+ return {
123
+ value,
124
+ chords: parseSettingsKeyshortcuts(value)
125
+ };
126
+ });
122
127
  const onKeyDown = (event) => {
123
- if (!props.settings || !isSettingsChord(event)) return;
128
+ const { value, chords } = settingsKeyshortcuts();
129
+ if (!props.settings || !matchesSettingsKeyshortcuts(event, chords, value === "Meta+, Control+,", hasEditableKeyboardTarget)) return;
124
130
  event.preventDefault();
125
131
  if (!event.repeat) openSettings();
126
132
  };
@@ -153,7 +159,7 @@ function ApplicationUtilities(props) {
153
159
  }).map((item) => {
154
160
  if (item.id === "settings" && item.shortcut) return {
155
161
  ...item,
156
- keyshortcuts: menu?.settingsKeyshortcuts ?? settingsKeyshortcuts
162
+ keyshortcuts: menu?.settingsKeyshortcuts ?? "Meta+, Control+,"
157
163
  };
158
164
  if (item.id === "updates" && updatesAlways()) return {
159
165
  ...item,
@@ -265,7 +271,9 @@ function ApplicationUtilities(props) {
265
271
  get standard() {
266
272
  return {
267
273
  search: help().search,
274
+ searchBinding: help().searchBinding,
268
275
  settings: Boolean(props.settings),
276
+ settingsKeyshortcuts: props.accountMenu?.settingsKeyshortcuts ?? "Meta+, Control+,",
269
277
  shortcutPlatform: resolveShortcutPlatform(props.identity)
270
278
  };
271
279
  },
@@ -4,9 +4,13 @@ export type { HelpLink, HelpShortcut };
4
4
  /** Shortcuts the framework binds itself, drawn with the running platform's modifier. */
5
5
  export declare function standardShortcuts(options: {
6
6
  search?: boolean;
7
+ /** Whether the enclosing application shell actually consumes its search chord. */
8
+ searchBinding?: boolean;
7
9
  settings?: boolean;
10
+ settingsKeyshortcuts?: string;
8
11
  /** A navigator-style platform string; ignored when `shortcutPlatform` is supplied. */
9
12
  platform?: string;
10
13
  shortcutPlatform?: ShortcutPlatform;
11
14
  }): HelpShortcut[];
15
+ export { DEFAULT_SETTINGS_KEYSHORTCUTS } from './settings-shortcuts';
12
16
  export * from './shortcut-platform';
@@ -1,22 +1,53 @@
1
1
  import { detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey } from "./shortcut-platform.js";
2
- import { platformModifierKey } from "@adea-ai/ui/components/ui/kbd";
2
+ import { DEFAULT_SETTINGS_KEYSHORTCUTS, parseSettingsKeyshortcuts } from "./settings-shortcuts.js";
3
3
  // src/shell/help-shortcuts.ts
4
+ function shortcutKeyLabel(key) {
5
+ if (key === "Space") return "Space";
6
+ if (key === "Plus") return "+";
7
+ return /^[a-z]$/i.test(key) ? key.toUpperCase() : key;
8
+ }
9
+ function modifierKeyLabel(modifier, platform) {
10
+ switch (modifier) {
11
+ case "Meta": return platform === "mac" ? shortcutModifierKey(platform) : "Meta";
12
+ case "Control": return "Ctrl";
13
+ case "Alt": return platform === "mac" ? "⌥" : "Alt";
14
+ case "Shift": return platform === "mac" ? "⇧" : "Shift";
15
+ case "AltGraph": return "AltGr";
16
+ case "FnLock": return "Fn Lock";
17
+ case "NumLock": return "Num Lock";
18
+ case "ScrollLock": return "Scroll Lock";
19
+ case "SymbolLock": return "Symbol Lock";
20
+ default: return modifier;
21
+ }
22
+ }
23
+ function settingsShortcuts(keyshortcuts, platform, searchBinding) {
24
+ const seen = /* @__PURE__ */ new Set();
25
+ return parseSettingsKeyshortcuts(keyshortcuts).flatMap(({ key, modifiers }) => {
26
+ if (key.toLowerCase() === "k" && searchBinding && modifiers.some((modifier) => modifier === "Meta" || modifier === "Control") && !modifiers.includes("Alt") && !modifiers.includes("Shift")) return [];
27
+ const keys = [...modifiers.map((modifier) => modifierKeyLabel(modifier, platform)), shortcutKeyLabel(key)];
28
+ const identity = JSON.stringify([modifiers.toSorted(), shortcutKeyLabel(key)]);
29
+ if (seen.has(identity)) return [];
30
+ seen.add(identity);
31
+ return [{
32
+ label: "Open settings",
33
+ keys
34
+ }];
35
+ });
36
+ }
4
37
  /** Shortcuts the framework binds itself, drawn with the running platform's modifier. */
5
38
  function standardShortcuts(options) {
6
- const mod = options.shortcutPlatform ? shortcutModifierKey(options.shortcutPlatform) : platformModifierKey(options.platform);
39
+ const platform = resolveShortcutPlatform(options);
40
+ const mod = shortcutModifierKey(platform);
7
41
  return [
8
42
  ...options.search ? [{
9
43
  label: "Open search",
10
44
  keys: [mod, "K"]
11
45
  }] : [],
12
- ...options.settings ? [{
13
- label: "Open settings",
14
- keys: [mod, ","]
15
- }] : [],
46
+ ...options.settings ? settingsShortcuts(options.settingsKeyshortcuts ?? "Meta+, Control+,", platform, options.searchBinding ?? Boolean(options.search)) : [],
16
47
  {
17
48
  label: "Close panels and dialogs",
18
49
  keys: ["Esc"]
19
50
  }
20
51
  ];
21
52
  }
22
- export { detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey, standardShortcuts };
53
+ export { DEFAULT_SETTINGS_KEYSHORTCUTS, detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey, standardShortcuts };
@@ -0,0 +1,2 @@
1
+ /** Whether a keyboard event originated in a control that accepts text editing. */
2
+ export declare function hasEditableKeyboardTarget(event: KeyboardEvent): boolean;
@@ -0,0 +1,54 @@
1
+ // src/shell/keyboard-target.ts
2
+ var nonTextInputTypes = /* @__PURE__ */ new Set([
3
+ "button",
4
+ "checkbox",
5
+ "color",
6
+ "file",
7
+ "hidden",
8
+ "image",
9
+ "radio",
10
+ "range",
11
+ "reset",
12
+ "submit"
13
+ ]);
14
+ var textEntryRoles = /* @__PURE__ */ new Set([
15
+ "combobox",
16
+ "searchbox",
17
+ "spinbutton",
18
+ "textbox"
19
+ ]);
20
+ /** Whether an element or an ancestor in its composed path accepts text editing. */
21
+ function isEditableElementPath(path) {
22
+ let inheritedEditable = false;
23
+ for (const target of path) {
24
+ if (!(target instanceof Element)) continue;
25
+ if (target instanceof HTMLInputElement) {
26
+ if (!target.disabled && !target.readOnly && !nonTextInputTypes.has(target.type)) return true;
27
+ } else if (target instanceof HTMLTextAreaElement) {
28
+ if (!target.disabled && !target.readOnly) return true;
29
+ }
30
+ const contentEditable = target.getAttribute("contenteditable")?.toLowerCase();
31
+ if (contentEditable === "false") return false;
32
+ if (contentEditable === "" || contentEditable === "true" || contentEditable === "plaintext-only") return true;
33
+ const role = target.getAttribute("role")?.trim().toLowerCase().split(/\s+/)[0];
34
+ if (role && textEntryRoles.has(role) && target.getAttribute("aria-readonly")?.toLowerCase() !== "true" && target.getAttribute("aria-disabled")?.toLowerCase() !== "true") return true;
35
+ if (target instanceof HTMLElement && target.isContentEditable) inheritedEditable = true;
36
+ if (target.ownerDocument.designMode?.toLowerCase() === "on") inheritedEditable = true;
37
+ }
38
+ return inheritedEditable;
39
+ }
40
+ /** Whether a keyboard event originated in a control that accepts text editing. */
41
+ function hasEditableKeyboardTarget(event) {
42
+ const path = event.composedPath();
43
+ if (path.some((target) => target instanceof Element)) return isEditableElementPath(path);
44
+ const activePath = [];
45
+ let activeElement = document.activeElement;
46
+ while (activeElement?.shadowRoot?.activeElement) activeElement = activeElement.shadowRoot.activeElement;
47
+ while (activeElement) {
48
+ activePath.push(activeElement);
49
+ const root = activeElement.getRootNode();
50
+ activeElement = activeElement.assignedSlot ?? activeElement.parentElement ?? (root instanceof ShadowRoot ? root.host : null);
51
+ }
52
+ return isEditableElementPath(activePath);
53
+ }
54
+ export { hasEditableKeyboardTarget };
@@ -7,6 +7,11 @@ export type ApplicationSettingsSection = Readonly<{
7
7
  group: string;
8
8
  icon?: JSX.Element;
9
9
  description?: string;
10
+ /**
11
+ * Creates the active panel. Rebuilding the section list with the same id keeps
12
+ * that panel mounted and does not invoke a replacement renderer. Pass changing
13
+ * context through reactive values in the returned view.
14
+ */
10
15
  render(): JSX.Element;
11
16
  }>;
12
17
  /** Validate section identifiers, labels and groups before the dialog mounts. */
@@ -0,0 +1,10 @@
1
+ export declare const DEFAULT_SETTINGS_KEYSHORTCUTS = "Meta+, Control+,";
2
+ declare const settingsShortcutModifiers: readonly ['Alt', 'AltGraph', 'CapsLock', 'Control', 'Fn', 'FnLock', 'Hyper', 'Meta', 'NumLock', 'ScrollLock', 'Shift', 'Super', 'Symbol', 'SymbolLock'];
3
+ type SettingsShortcutModifier = (typeof settingsShortcutModifiers)[number];
4
+ export type ParsedSettingsShortcut = Readonly<{
5
+ key: string;
6
+ modifiers: readonly SettingsShortcutModifier[];
7
+ }>;
8
+ export declare function parseSettingsKeyshortcuts(value: string): ParsedSettingsShortcut[];
9
+ export declare function matchesSettingsKeyshortcuts(event: KeyboardEvent, value: string | readonly ParsedSettingsShortcut[], allowDefaultMetaControlOverlap: boolean, hasEditableTarget: (event: KeyboardEvent) => boolean): boolean;
10
+ export {};
@@ -0,0 +1,67 @@
1
+ // src/shell/settings-shortcuts.ts
2
+ var DEFAULT_SETTINGS_KEYSHORTCUTS = "Meta+, Control+,";
3
+ var supportedModifiers = /* @__PURE__ */ new Set([
4
+ "Alt",
5
+ "AltGraph",
6
+ "CapsLock",
7
+ "Control",
8
+ "Fn",
9
+ "FnLock",
10
+ "Hyper",
11
+ "Meta",
12
+ "NumLock",
13
+ "ScrollLock",
14
+ "Shift",
15
+ "Super",
16
+ "Symbol",
17
+ "SymbolLock"
18
+ ]);
19
+ var exactSettingsShortcutModifiers = [
20
+ "Alt",
21
+ "AltGraph",
22
+ "Control",
23
+ "Fn",
24
+ "Hyper",
25
+ "Meta",
26
+ "Shift",
27
+ "Super",
28
+ "Symbol"
29
+ ];
30
+ function parseSettingsShortcutChord(chord) {
31
+ const parts = chord.split("+");
32
+ const key = parts.pop();
33
+ if (!key || key.trim() !== key || supportedModifiers.has(key)) return;
34
+ const modifiers = [];
35
+ for (const part of parts) {
36
+ if (!supportedModifiers.has(part) || modifiers.includes(part)) return;
37
+ modifiers.push(part);
38
+ }
39
+ return {
40
+ key,
41
+ modifiers
42
+ };
43
+ }
44
+ function parseSettingsKeyshortcuts(value) {
45
+ return value.trim().split(/\s+/).filter(Boolean).flatMap((chord) => {
46
+ const parsed = parseSettingsShortcutChord(chord);
47
+ return parsed ? [parsed] : [];
48
+ });
49
+ }
50
+ function normalizeShortcutKey(key) {
51
+ if (key === "Space") return " ";
52
+ if (key === "Plus") return "+";
53
+ return /^[a-z]$/i.test(key) ? key.toLowerCase() : key;
54
+ }
55
+ function matchesSettingsShortcut(event, chord, allowDefaultMetaControlOverlap, hasEditableTarget) {
56
+ if (normalizeShortcutKey(event.key) !== normalizeShortcutKey(chord.key)) return false;
57
+ const requiredModifiers = new Set(chord.modifiers);
58
+ const allowMetaControlOverlap = allowDefaultMetaControlOverlap && event.metaKey && event.ctrlKey && (requiredModifiers.has("Meta") || requiredModifiers.has("Control"));
59
+ if (exactSettingsShortcutModifiers.some((modifier) => !(allowMetaControlOverlap && (modifier === "Meta" || modifier === "Control")) && event.getModifierState(modifier) !== requiredModifiers.has(modifier))) return false;
60
+ if (chord.modifiers.some((modifier) => !exactSettingsShortcutModifiers.includes(modifier) && !event.getModifierState(modifier))) return false;
61
+ if (requiredModifiers.size === 0 && hasEditableTarget(event)) return false;
62
+ return true;
63
+ }
64
+ function matchesSettingsKeyshortcuts(event, value, allowDefaultMetaControlOverlap, hasEditableTarget) {
65
+ return !event.defaultPrevented && (typeof value === "string" ? parseSettingsKeyshortcuts(value) : value).some((chord) => matchesSettingsShortcut(event, chord, allowDefaultMetaControlOverlap, hasEditableTarget));
66
+ }
67
+ export { DEFAULT_SETTINGS_KEYSHORTCUTS, matchesSettingsKeyshortcuts, parseSettingsKeyshortcuts };
@@ -1,4 +1,5 @@
1
1
  import { detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey } from "../shell/shortcut-platform.js";
2
+ import { DEFAULT_SETTINGS_KEYSHORTCUTS } from "../shell/settings-shortcuts.js";
2
3
  import { standardShortcuts } from "../shell/help-shortcuts.js";
3
4
  import { createComponent } from "solid-js/web";
4
5
  import { ModalDialog } from "@adea-ai/ui/components/ui/modal-dialog";
@@ -39,4 +40,4 @@ function ApplicationHelp(props) {
39
40
  }
40
41
  });
41
42
  }
42
- export { ApplicationHelp, detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey, standardShortcuts };
43
+ export { ApplicationHelp, DEFAULT_SETTINGS_KEYSHORTCUTS, detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey, standardShortcuts };
@@ -1,6 +1,6 @@
1
1
  import { defineSettingsSections, isSettingsHash, settingsGroups, settingsHash, settingsSectionFromHash } from "../shell/settings-sections.js";
2
2
  import { createComponent, insert, memo, template } from "solid-js/web";
3
- import { For, Show, untrack } from "solid-js";
3
+ import { For, Show, createMemo, untrack } from "solid-js";
4
4
  import { ModalDialog } from "@adea-ai/ui/components/ui/modal-dialog";
5
5
  import { SettingsLayout } from "@adea-ai/ui/components/composites/settings";
6
6
  import { TabsContent } from "@adea-ai/ui/components/ui/tabs";
@@ -12,7 +12,10 @@ var _tmpl$ = /*#__PURE__*/ template(`<div class="flex min-w-0 flex-col gap-4">`)
12
12
  * settings as a page. `ApplicationSettings` shows the same panel in a dialog.
13
13
  */
14
14
  function ApplicationSettingsPanel(props) {
15
- const active = () => props.sections.find((section) => section.id === props.section) ?? props.sections[0];
15
+ const active = createMemo(() => {
16
+ const selected = props.section;
17
+ return props.sections.find((section) => section.id === selected) ?? props.sections[0];
18
+ });
16
19
  const panels = () => createComponent(For, {
17
20
  get each() {
18
21
  return props.sections.map((section) => section.id);
@@ -8,7 +8,7 @@ import { createThemeLibraryActionFence } from "../appearance/theme-library-actio
8
8
  import { DEFAULT_CUSTOM_ACCENT, allThemeRecords, appearanceThemeForPreview, normalizeCustomAccent } from "../appearance/theme-record-adapter.js";
9
9
  import { mirrorWindowSurface } from "../appearance/window-surface.js";
10
10
  import { createComponent, effect, insert, mergeProps, setAttribute, template } from "solid-js/web";
11
- import { For, Show, createEffect, createMemo, createSignal, onCleanup, onMount, untrack } from "solid-js";
11
+ import { For, Show, batch, createEffect, createMemo, createSignal, onCleanup, onMount, untrack } from "solid-js";
12
12
  import { MonitorCog } from "lucide-solid";
13
13
  import { defaultPreferenceStorage } from "@adea-ai/ui/lib/preference-store";
14
14
  import { isThemeAccentId } from "@adea-ai/ui/lib/themes";
@@ -55,16 +55,24 @@ function AppearanceHost(props) {
55
55
  const [rawCustomAccent, setRawCustomAccent] = createSignal("");
56
56
  const [accentStatus, setAccentStatus] = createSignal("");
57
57
  const [libraryOpen, setLibraryOpen] = createSignal(false);
58
- const miniatures = createMemo(() => draftVariants(editor.draft()));
59
58
  const [library, setLibrary] = createSignal(readCustomThemeLibrary(defaultPreferenceStorage()));
60
59
  onMount(() => {
61
60
  setLibrary(readCustomThemeLibrary(defaultPreferenceStorage()));
62
61
  onCleanup(subscribeCustomThemes(() => setLibrary(readCustomThemeLibrary(defaultPreferenceStorage()))));
63
62
  });
64
- const themes = () => {
63
+ const themes = createMemo(() => {
65
64
  library();
66
65
  return allThemeRecords();
67
- };
66
+ });
67
+ const lightThemeId = createMemo(() => editor.draft().lightThemeId);
68
+ const darkThemeId = createMemo(() => editor.draft().darkThemeId);
69
+ const miniatures = createMemo(() => {
70
+ library();
71
+ return draftVariants({
72
+ lightThemeId: lightThemeId(),
73
+ darkThemeId: darkThemeId()
74
+ });
75
+ });
68
76
  const [importStatus, setImportStatus] = createSignal("");
69
77
  const [importPending, setImportPending] = createSignal(false);
70
78
  const themeActionFence = createThemeLibraryActionFence(setImportStatus);
@@ -106,10 +114,11 @@ function AppearanceHost(props) {
106
114
  themeImporter.importFile(file);
107
115
  };
108
116
  const themeAccentOptions = createMemo(() => {
109
- const draft = editor.draft();
110
117
  const records = themes();
111
- const light = records.find((record) => record.id === draft.lightThemeId);
112
- const dark = records.find((record) => record.id === draft.darkThemeId);
118
+ const lightId = lightThemeId();
119
+ const darkId = darkThemeId();
120
+ const light = records.find((record) => record.id === lightId);
121
+ const dark = records.find((record) => record.id === darkId);
113
122
  return light && dark ? themeAccentsForRecords(light, dark) : [];
114
123
  });
115
124
  const publishedDraft = createMemo(() => {
@@ -125,7 +134,7 @@ function AppearanceHost(props) {
125
134
  const mode = editor.draft().mode;
126
135
  if (mode === "light") return variants.light;
127
136
  if (mode === "dark") return variants.dark;
128
- return untrack(() => document.documentElement.classList.contains("dark")) ? variants.dark : variants.light;
137
+ return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches ? variants.dark : variants.light;
129
138
  };
130
139
  const preview = () => appearance.preview(editor.draft());
131
140
  const revertDraft = () => {
@@ -140,7 +149,9 @@ function AppearanceHost(props) {
140
149
  editor.set(patch);
141
150
  preview();
142
151
  };
143
- const setAccent = (value) => {
152
+ const setAccent = (value, otherChanges) => {
153
+ const before = editor.draft();
154
+ editor.set(otherChanges);
144
155
  if (value === "theme" || getAccent(value) || isThemeAccentId(value)) {
145
156
  setCustomAccent("");
146
157
  setRawCustomAccent("");
@@ -152,6 +163,7 @@ function AppearanceHost(props) {
152
163
  if (validation.value === void 0) {
153
164
  setRawCustomAccent(value);
154
165
  setAccentStatus(validation.error ?? "Invalid custom accent.");
166
+ if (editor.draft() !== before) preview();
155
167
  return;
156
168
  }
157
169
  setCustomAccent(validation.value);
@@ -159,17 +171,18 @@ function AppearanceHost(props) {
159
171
  setAccentStatus("");
160
172
  setDraft({ accent: validation.value });
161
173
  };
162
- const onChange = (patch) => {
163
- if (patch.accent !== void 0) {
164
- setAccent(patch.accent);
165
- return;
166
- }
167
- if (patch.surface !== void 0) {
168
- setDraft({ surface: patch.surface === "theme" ? "translucent" : patch.surface });
174
+ const onChange = (patch) => batch(() => {
175
+ const { accent, surface, ...rest } = patch;
176
+ const otherChanges = {
177
+ ...rest,
178
+ ...surface === void 0 ? {} : { surface: surface === "theme" ? "translucent" : surface }
179
+ };
180
+ if (accent !== void 0) {
181
+ setAccent(accent, otherChanges);
169
182
  return;
170
183
  }
171
- setDraft(patch);
172
- };
184
+ setDraft(otherChanges);
185
+ });
173
186
  const save = () => {
174
187
  if (accentStatus()) return;
175
188
  if (!editor.dirty()) {
@@ -211,7 +224,8 @@ function AppearanceHost(props) {
211
224
  return appearanceThemeForPreview(miniatures().dark, editor.draft().accent, editor.draft());
212
225
  },
213
226
  get resolvedAppearance() {
214
- return appearance.resolvedAppearance();
227
+ const shownAppearance = appearance.shownAppearance;
228
+ return shownAppearance?.() ?? appearance.resolvedAppearance();
215
229
  },
216
230
  get themes() {
217
231
  return themes();