@djangocfg/layouts 2.1.652 → 2.1.653

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/layouts",
3
- "version": "2.1.652",
3
+ "version": "2.1.653",
4
4
  "description": "Simple, straightforward layout components for Next.js - import and use with props",
5
5
  "keywords": [
6
6
  "layouts",
@@ -91,11 +91,11 @@
91
91
  "test": "vitest run"
92
92
  },
93
93
  "peerDependencies": {
94
- "@djangocfg/analytics": "^2.1.652",
95
- "@djangocfg/api": "^2.1.652",
96
- "@djangocfg/devtools": "^2.1.652",
97
- "@djangocfg/i18n": "^2.1.652",
98
- "@djangocfg/ui-core": "^2.1.652",
94
+ "@djangocfg/analytics": "^2.1.653",
95
+ "@djangocfg/api": "^2.1.653",
96
+ "@djangocfg/devtools": "^2.1.653",
97
+ "@djangocfg/i18n": "^2.1.653",
98
+ "@djangocfg/ui-core": "^2.1.653",
99
99
  "@hookform/resolvers": "^5.2.2 || ^7.0.2",
100
100
  "consola": "^3.4.2",
101
101
  "lucide-react": "^1.68.0",
@@ -123,12 +123,12 @@
123
123
  "qrcode.react": "^4.2.0"
124
124
  },
125
125
  "devDependencies": {
126
- "@djangocfg/analytics": "^2.1.652",
127
- "@djangocfg/api": "^2.1.652",
128
- "@djangocfg/devtools": "^2.1.652",
129
- "@djangocfg/i18n": "^2.1.652",
130
- "@djangocfg/typescript-config": "^2.1.652",
131
- "@djangocfg/ui-core": "^2.1.652",
126
+ "@djangocfg/analytics": "^2.1.653",
127
+ "@djangocfg/api": "^2.1.653",
128
+ "@djangocfg/devtools": "^2.1.653",
129
+ "@djangocfg/i18n": "^2.1.653",
130
+ "@djangocfg/typescript-config": "^2.1.653",
131
+ "@djangocfg/ui-core": "^2.1.653",
132
132
  "@storybook/react-vite": "^10.6.5",
133
133
  "@types/node": "^25.9.5",
134
134
  "@types/react": "19.3.0",
@@ -12,6 +12,7 @@
12
12
  import React, { ReactNode } from 'react';
13
13
 
14
14
  import { Link, useSidebar } from '@djangocfg/ui-core/components';
15
+ import { settleShellScroll } from '@djangocfg/ui-core/hooks';
15
16
  import { cn } from '@djangocfg/ui-core/lib';
16
17
 
17
18
  import type { LayoutVisualConfig } from '../../types';
@@ -74,6 +75,8 @@ export function PrivateContent({
74
75
  if (lastPath.current === pathname) return;
75
76
  lastPath.current = pathname;
76
77
  scrollRef.current?.scrollTo?.({ top: 0 });
78
+ // The shell itself may have been displaced by the page we left (a closed call, a drawer); put it back with the content.
79
+ settleShellScroll('route');
77
80
  }, [pathname]);
78
81
 
79
82
  const { isMobile, state } = useSidebar();
@@ -8,6 +8,7 @@ export const ar: SettingsCopy = {
8
8
  preferences: "التفضيلات",
9
9
  apiKeys: "مفاتيح API",
10
10
  apiKeysDescription: "أنشئ المفاتيح وأدرها للوصول البرمجي.",
11
+ debug: "تصحيح الأخطاء",
11
12
  },
12
13
  prefs: {
13
14
  general: "عام",
@@ -21,6 +22,13 @@ export const ar: SettingsCopy = {
21
22
  deleteAccountDescription: "احذف حسابك وجميع البيانات المرتبطة به نهائيًا.",
22
23
  changeAvatar: "تغيير الصورة الرمزية",
23
24
  },
25
+ debug: {
26
+ description: "تشخيص منطقة العرض لتتبع تطبيق منزاح.",
27
+ hud: "طبقة منطقة العرض",
28
+ hudHint: "تعرض قيم التمرير ومنطقة العرض مباشرة فوق التطبيق كله.",
29
+ resetNow: "إعادة تعيين التمرير الآن",
30
+ readout: "القيم المباشرة",
31
+ },
24
32
  search: {
25
33
  clear: "مسح البحث",
26
34
  },
@@ -8,6 +8,7 @@ export const da: SettingsCopy = {
8
8
  preferences: "Indstillinger",
9
9
  apiKeys: "API-nøgler",
10
10
  apiKeysDescription: "Opret og administrer nøgler til programmatisk adgang.",
11
+ debug: "Fejlfinding",
11
12
  },
12
13
  prefs: {
13
14
  general: "Generelt",
@@ -21,6 +22,13 @@ export const da: SettingsCopy = {
21
22
  deleteAccountDescription: "Slet din konto og alle tilknyttede data permanent.",
22
23
  changeAvatar: "Skift avatar",
23
24
  },
25
+ debug: {
26
+ description: "Viewport-diagnostik til at spore en forskudt app.",
27
+ hud: "Viewport-overlay",
28
+ hudHint: "Viser scroll- og viewportværdier live over hele appen.",
29
+ resetNow: "Nulstil scroll nu",
30
+ readout: "Live-værdier",
31
+ },
24
32
  search: {
25
33
  clear: "Ryd søgning",
26
34
  },
@@ -8,6 +8,7 @@ export const de: SettingsCopy = {
8
8
  preferences: "Einstellungen",
9
9
  apiKeys: "API-Schlüssel",
10
10
  apiKeysDescription: "Schlüssel für den programmatischen Zugriff erstellen und verwalten.",
11
+ debug: "Debug",
11
12
  },
12
13
  prefs: {
13
14
  general: "Allgemein",
@@ -21,6 +22,13 @@ export const de: SettingsCopy = {
21
22
  deleteAccountDescription: "Konto und alle zugehörigen Daten dauerhaft löschen.",
22
23
  changeAvatar: "Avatar ändern",
23
24
  },
25
+ debug: {
26
+ description: "Viewport-Diagnose, um eine verschobene App aufzuspüren.",
27
+ hud: "Viewport-Overlay",
28
+ hudHint: "Zeigt Scroll- und Viewport-Werte live über der ganzen App.",
29
+ resetNow: "Scroll jetzt zurücksetzen",
30
+ readout: "Live-Werte",
31
+ },
24
32
  search: {
25
33
  clear: "Suche löschen",
26
34
  },
@@ -8,6 +8,7 @@ export const en: SettingsCopy = {
8
8
  preferences: "Preferences",
9
9
  apiKeys: "API keys",
10
10
  apiKeysDescription: "Create and manage keys for programmatic access.",
11
+ debug: "Debug",
11
12
  },
12
13
  prefs: {
13
14
  general: "General",
@@ -21,6 +22,13 @@ export const en: SettingsCopy = {
21
22
  deleteAccountDescription: "Permanently remove your account and all associated data.",
22
23
  changeAvatar: "Change avatar",
23
24
  },
25
+ debug: {
26
+ description: "Viewport diagnostics for chasing a displaced app.",
27
+ hud: "Viewport overlay",
28
+ hudHint: "Shows live scroll and viewport values over the whole app.",
29
+ resetNow: "Reset scroll now",
30
+ readout: "Live values",
31
+ },
24
32
  search: {
25
33
  clear: "Clear search",
26
34
  },
@@ -8,6 +8,7 @@ export const es: SettingsCopy = {
8
8
  preferences: "Preferencias",
9
9
  apiKeys: "Claves API",
10
10
  apiKeysDescription: "Crea y gestiona claves para el acceso programático.",
11
+ debug: "Depuración",
11
12
  },
12
13
  prefs: {
13
14
  general: "General",
@@ -21,6 +22,13 @@ export const es: SettingsCopy = {
21
22
  deleteAccountDescription: "Elimina de forma permanente tu cuenta y todos los datos asociados.",
22
23
  changeAvatar: "Cambiar avatar",
23
24
  },
25
+ debug: {
26
+ description: "Diagnóstico del viewport para rastrear una app desplazada.",
27
+ hud: "Superposición del viewport",
28
+ hudHint: "Muestra en vivo los valores de scroll y viewport sobre toda la app.",
29
+ resetNow: "Restablecer scroll ahora",
30
+ readout: "Valores en vivo",
31
+ },
24
32
  search: {
25
33
  clear: "Borrar búsqueda",
26
34
  },
@@ -8,6 +8,7 @@ export const fr: SettingsCopy = {
8
8
  preferences: "Préférences",
9
9
  apiKeys: "Clés API",
10
10
  apiKeysDescription: "Créez et gérez des clés pour l'accès programmatique.",
11
+ debug: "Débogage",
11
12
  },
12
13
  prefs: {
13
14
  general: "Général",
@@ -21,6 +22,13 @@ export const fr: SettingsCopy = {
21
22
  deleteAccountDescription: "Supprimer définitivement votre compte et toutes les données associées.",
22
23
  changeAvatar: "Changer d'avatar",
23
24
  },
25
+ debug: {
26
+ description: "Diagnostic du viewport pour traquer une app décalée.",
27
+ hud: "Surcouche viewport",
28
+ hudHint: "Affiche en direct les valeurs de défilement et de viewport sur toute l'app.",
29
+ resetNow: "Réinitialiser le défilement",
30
+ readout: "Valeurs en direct",
31
+ },
24
32
  search: {
25
33
  clear: "Effacer la recherche",
26
34
  },
@@ -8,6 +8,7 @@ export const it: SettingsCopy = {
8
8
  preferences: "Preferenze",
9
9
  apiKeys: "Chiavi API",
10
10
  apiKeysDescription: "Crea e gestisci le chiavi per l'accesso programmatico.",
11
+ debug: "Debug",
11
12
  },
12
13
  prefs: {
13
14
  general: "Generali",
@@ -21,6 +22,13 @@ export const it: SettingsCopy = {
21
22
  deleteAccountDescription: "Elimina definitivamente il tuo account e tutti i dati associati.",
22
23
  changeAvatar: "Cambia avatar",
23
24
  },
25
+ debug: {
26
+ description: "Diagnostica del viewport per rintracciare un'app spostata.",
27
+ hud: "Overlay viewport",
28
+ hudHint: "Mostra in tempo reale i valori di scorrimento e viewport sull'intera app.",
29
+ resetNow: "Reimposta lo scorrimento",
30
+ readout: "Valori in tempo reale",
31
+ },
24
32
  search: {
25
33
  clear: "Cancella ricerca",
26
34
  },
@@ -8,6 +8,7 @@ export const ja: SettingsCopy = {
8
8
  preferences: "設定",
9
9
  apiKeys: "APIキー",
10
10
  apiKeysDescription: "プログラムからアクセスするためのキーを作成・管理します。",
11
+ debug: "デバッグ",
11
12
  },
12
13
  prefs: {
13
14
  general: "一般",
@@ -21,6 +22,13 @@ export const ja: SettingsCopy = {
21
22
  deleteAccountDescription: "アカウントと関連するすべてのデータを完全に削除します。",
22
23
  changeAvatar: "アバターを変更",
23
24
  },
25
+ debug: {
26
+ description: "画面のずれを調べるためのビューポート診断。",
27
+ hud: "ビューポートオーバーレイ",
28
+ hudHint: "スクロールとビューポートの値をアプリ全体に重ねて表示します。",
29
+ resetNow: "今すぐスクロールをリセット",
30
+ readout: "現在の値",
31
+ },
24
32
  search: {
25
33
  clear: "検索をクリア",
26
34
  },
@@ -8,6 +8,7 @@ export const ko: SettingsCopy = {
8
8
  preferences: "환경설정",
9
9
  apiKeys: "API 키",
10
10
  apiKeysDescription: "프로그래밍 방식 접근을 위한 키를 만들고 관리하세요.",
11
+ debug: "디버그",
11
12
  },
12
13
  prefs: {
13
14
  general: "일반",
@@ -21,6 +22,13 @@ export const ko: SettingsCopy = {
21
22
  deleteAccountDescription: "계정과 관련된 모든 데이터를 영구적으로 삭제합니다.",
22
23
  changeAvatar: "아바타 변경",
23
24
  },
25
+ debug: {
26
+ description: "화면이 밀리는 문제를 추적하는 뷰포트 진단.",
27
+ hud: "뷰포트 오버레이",
28
+ hudHint: "앱 전체 위에 스크롤과 뷰포트 값을 실시간으로 표시합니다.",
29
+ resetNow: "스크롤 지금 초기화",
30
+ readout: "실시간 값",
31
+ },
24
32
  search: {
25
33
  clear: "검색어 지우기",
26
34
  },
@@ -8,6 +8,7 @@ export const nl: SettingsCopy = {
8
8
  preferences: "Voorkeuren",
9
9
  apiKeys: "API-sleutels",
10
10
  apiKeysDescription: "Maak en beheer sleutels voor programmatische toegang.",
11
+ debug: "Debug",
11
12
  },
12
13
  prefs: {
13
14
  general: "Algemeen",
@@ -21,6 +22,13 @@ export const nl: SettingsCopy = {
21
22
  deleteAccountDescription: "Verwijder je account en alle bijbehorende gegevens definitief.",
22
23
  changeAvatar: "Avatar wijzigen",
23
24
  },
25
+ debug: {
26
+ description: "Viewport-diagnose om een verschoven app op te sporen.",
27
+ hud: "Viewport-overlay",
28
+ hudHint: "Toont live scroll- en viewportwaarden over de hele app.",
29
+ resetNow: "Scroll nu resetten",
30
+ readout: "Live waarden",
31
+ },
24
32
  search: {
25
33
  clear: "Zoekopdracht wissen",
26
34
  },
@@ -8,6 +8,7 @@ export const no: SettingsCopy = {
8
8
  preferences: "Innstillinger",
9
9
  apiKeys: "API-nøkler",
10
10
  apiKeysDescription: "Opprett og administrer nøkler for programmatisk tilgang.",
11
+ debug: "Feilsøking",
11
12
  },
12
13
  prefs: {
13
14
  general: "Generelt",
@@ -21,6 +22,13 @@ export const no: SettingsCopy = {
21
22
  deleteAccountDescription: "Slett kontoen din og alle tilknyttede data permanent.",
22
23
  changeAvatar: "Bytt avatar",
23
24
  },
25
+ debug: {
26
+ description: "Viewport-diagnostikk for å spore en forskjøvet app.",
27
+ hud: "Viewport-overlegg",
28
+ hudHint: "Viser scroll- og viewportverdier live over hele appen.",
29
+ resetNow: "Nullstill scroll nå",
30
+ readout: "Live-verdier",
31
+ },
24
32
  search: {
25
33
  clear: "Tøm søk",
26
34
  },
@@ -8,6 +8,7 @@ export const pl: SettingsCopy = {
8
8
  preferences: "Preferencje",
9
9
  apiKeys: "Klucze API",
10
10
  apiKeysDescription: "Twórz klucze dostępu programistycznego i zarządzaj nimi.",
11
+ debug: "Debugowanie",
11
12
  },
12
13
  prefs: {
13
14
  general: "Ogólne",
@@ -21,6 +22,13 @@ export const pl: SettingsCopy = {
21
22
  deleteAccountDescription: "Trwale usuń konto i wszystkie powiązane dane.",
22
23
  changeAvatar: "Zmień awatar",
23
24
  },
25
+ debug: {
26
+ description: "Diagnostyka viewportu do śledzenia przesuniętej aplikacji.",
27
+ hud: "Nakładka viewportu",
28
+ hudHint: "Pokazuje na żywo wartości przewijania i viewportu nad całą aplikacją.",
29
+ resetNow: "Zresetuj przewijanie",
30
+ readout: "Wartości na żywo",
31
+ },
24
32
  search: {
25
33
  clear: "Wyczyść wyszukiwanie",
26
34
  },
@@ -8,6 +8,7 @@ export const ptBR: SettingsCopy = {
8
8
  preferences: "Preferências",
9
9
  apiKeys: "Chaves de API",
10
10
  apiKeysDescription: "Crie e gerencie chaves para acesso programático.",
11
+ debug: "Depuração",
11
12
  },
12
13
  prefs: {
13
14
  general: "Geral",
@@ -21,6 +22,13 @@ export const ptBR: SettingsCopy = {
21
22
  deleteAccountDescription: "Exclua permanentemente sua conta e todos os dados associados.",
22
23
  changeAvatar: "Alterar avatar",
23
24
  },
25
+ debug: {
26
+ description: "Diagnóstico do viewport para rastrear um app deslocado.",
27
+ hud: "Sobreposição do viewport",
28
+ hudHint: "Mostra ao vivo os valores de rolagem e viewport sobre todo o app.",
29
+ resetNow: "Redefinir rolagem agora",
30
+ readout: "Valores ao vivo",
31
+ },
24
32
  search: {
25
33
  clear: "Limpar pesquisa",
26
34
  },
@@ -8,6 +8,7 @@ export const ru: SettingsCopy = {
8
8
  preferences: "Параметры",
9
9
  apiKeys: "API-ключи",
10
10
  apiKeysDescription: "Создавайте ключи и управляйте ими для программного доступа.",
11
+ debug: "Отладка",
11
12
  },
12
13
  prefs: {
13
14
  general: "Общие",
@@ -21,6 +22,13 @@ export const ru: SettingsCopy = {
21
22
  deleteAccountDescription: "Безвозвратно удалить аккаунт и все связанные данные.",
22
23
  changeAvatar: "Сменить аватар",
23
24
  },
25
+ debug: {
26
+ description: "Диагностика вьюпорта для поиска смещённого экрана.",
27
+ hud: "Оверлей вьюпорта",
28
+ hudHint: "Показывает значения прокрутки и вьюпорта поверх всего приложения.",
29
+ resetNow: "Сбросить прокрутку",
30
+ readout: "Текущие значения",
31
+ },
24
32
  search: {
25
33
  clear: "Очистить поиск",
26
34
  },
@@ -8,6 +8,7 @@ export const sv: SettingsCopy = {
8
8
  preferences: "Inställningar",
9
9
  apiKeys: "API-nycklar",
10
10
  apiKeysDescription: "Skapa och hantera nycklar för programmatisk åtkomst.",
11
+ debug: "Felsökning",
11
12
  },
12
13
  prefs: {
13
14
  general: "Allmänt",
@@ -21,6 +22,13 @@ export const sv: SettingsCopy = {
21
22
  deleteAccountDescription: "Radera ditt konto och all tillhörande data permanent.",
22
23
  changeAvatar: "Byt avatar",
23
24
  },
25
+ debug: {
26
+ description: "Viewport-diagnostik för att spåra en förskjuten app.",
27
+ hud: "Viewport-överlägg",
28
+ hudHint: "Visar scroll- och viewportvärden live över hela appen.",
29
+ resetNow: "Återställ scroll nu",
30
+ readout: "Live-värden",
31
+ },
24
32
  search: {
25
33
  clear: "Rensa sökning",
26
34
  },
@@ -8,6 +8,7 @@ export const tr: SettingsCopy = {
8
8
  preferences: "Tercihler",
9
9
  apiKeys: "API anahtarları",
10
10
  apiKeysDescription: "Programatik erişim için anahtarlar oluşturun ve yönetin.",
11
+ debug: "Hata ayıklama",
11
12
  },
12
13
  prefs: {
13
14
  general: "Genel",
@@ -21,6 +22,13 @@ export const tr: SettingsCopy = {
21
22
  deleteAccountDescription: "Hesabınızı ve ilişkili tüm verileri kalıcı olarak silin.",
22
23
  changeAvatar: "Avatarı değiştir",
23
24
  },
25
+ debug: {
26
+ description: "Kayan bir uygulamayı izlemek için görünüm alanı tanılaması.",
27
+ hud: "Görünüm alanı katmanı",
28
+ hudHint: "Kaydırma ve görünüm alanı değerlerini tüm uygulamanın üzerinde canlı gösterir.",
29
+ resetNow: "Kaydırmayı şimdi sıfırla",
30
+ readout: "Canlı değerler",
31
+ },
24
32
  search: {
25
33
  clear: "Aramayı temizle",
26
34
  },
@@ -8,6 +8,7 @@ export const zh: SettingsCopy = {
8
8
  preferences: "偏好设置",
9
9
  apiKeys: "API 密钥",
10
10
  apiKeysDescription: "创建并管理用于程序化访问的密钥。",
11
+ debug: "调试",
11
12
  },
12
13
  prefs: {
13
14
  general: "常规",
@@ -21,6 +22,13 @@ export const zh: SettingsCopy = {
21
22
  deleteAccountDescription: "永久删除您的账户及所有相关数据。",
22
23
  changeAvatar: "更换头像",
23
24
  },
25
+ debug: {
26
+ description: "用于排查应用错位的视口诊断。",
27
+ hud: "视口悬浮层",
28
+ hudHint: "在整个应用上实时显示滚动和视口数值。",
29
+ resetNow: "立即重置滚动",
30
+ readout: "实时数值",
31
+ },
24
32
  search: {
25
33
  clear: "清除搜索",
26
34
  },
@@ -7,6 +7,14 @@ export interface SettingsCopy {
7
7
  preferences: string;
8
8
  apiKeys: string;
9
9
  apiKeysDescription: string;
10
+ debug: string;
11
+ };
12
+ debug: {
13
+ description: string;
14
+ hud: string;
15
+ hudHint: string;
16
+ resetNow: string;
17
+ readout: string;
10
18
  };
11
19
  prefs: {
12
20
  general: string;
@@ -0,0 +1,65 @@
1
+ // @vitest-environment jsdom
2
+ import React, { act } from 'react';
3
+ import { createRoot, type Root } from 'react-dom/client';
4
+ import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
5
+
6
+ import { en } from '../i18n/locales/en';
7
+ import { buildBuiltinSections } from './builtins';
8
+ import { DebugSection } from './DebugSection';
9
+
10
+ vi.mock('@djangocfg/api/auth', () => ({ useTimezone: () => ({}), useAuth: () => ({}) }));
11
+
12
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
13
+
14
+ let host: HTMLElement | null = null;
15
+ let root: Root | null = null;
16
+
17
+ beforeAll(() => {
18
+ window.matchMedia = ((q: string) => ({ matches: false, media: q, addEventListener() {}, removeEventListener() {}, addListener() {}, removeListener() {}, dispatchEvent: () => false })) as typeof window.matchMedia;
19
+ });
20
+
21
+ afterEach(() => {
22
+ act(() => root?.unmount());
23
+ host?.remove();
24
+ host = root = null;
25
+ localStorage.clear();
26
+ });
27
+
28
+ describe('builtins.debug', () => {
29
+ const ids = (debug?: boolean) =>
30
+ buildBuiltinSections({ builtins: debug === undefined ? {} : { debug }, enableDeleteAccount: true, copy: en }).map((s) => s.id);
31
+
32
+ it('is off by default, in development and production alike, and on only for an explicit true', () => {
33
+ for (const nodeEnv of ['development', 'production']) {
34
+ vi.stubEnv('NODE_ENV', nodeEnv);
35
+ expect(ids()).not.toContain('debug');
36
+ expect(ids(false)).not.toContain('debug');
37
+ expect(ids(true)).toContain('debug');
38
+ }
39
+ vi.unstubAllEnvs();
40
+ });
41
+ });
42
+
43
+ describe('DebugSection', () => {
44
+ it('shows the live readout, flips the HUD switch (persisted) and resets the scroll on demand', async () => {
45
+ host = document.createElement('div');
46
+ document.body.appendChild(host);
47
+ root = createRoot(host);
48
+ await act(async () => root!.render(<DebugSection />));
49
+
50
+ const readout = host.querySelector('[data-testid=viewport-readout]')!;
51
+ expect(readout.textContent).toContain('innerHeight');
52
+ expect(readout.textContent).toContain('--app-height');
53
+
54
+ const toggle = host.querySelector<HTMLElement>('[role=switch]')!;
55
+ expect(toggle.getAttribute('aria-checked')).toBe('false');
56
+ await act(async () => toggle.click());
57
+ expect(localStorage.getItem('viewportdebug')).toBe('1');
58
+ expect(document.querySelector('[data-viewport-debug]')).toBeNull(); // drawn by UiProviders, not by the dialog
59
+ expect(host.querySelector('[role=switch]')!.getAttribute('aria-checked')).toBe('true');
60
+
61
+ const reset = [...host.querySelectorAll('button')].find((b) => b.textContent === en.debug.resetNow)!;
62
+ expect(reset).toBeTruthy();
63
+ await act(async () => reset.click());
64
+ });
65
+ });
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+
5
+ import { Button, SettingRow, SettingsBlock } from '@djangocfg/ui-core/components';
6
+ import {
7
+ getViewportDebug,
8
+ resetShellScroll,
9
+ setViewportDebug,
10
+ subscribeViewportDebug,
11
+ viewportSnapshot,
12
+ } from '@djangocfg/ui-core/hooks';
13
+
14
+ import { useSettingsCopy } from '../i18n';
15
+
16
+ /** Re-reads `viewportSnapshot()` twice a second while the section is open. */
17
+ function useSnapshot(): string {
18
+ const [text, setText] = React.useState('');
19
+ React.useEffect(() => {
20
+ const read = () => setText(viewportSnapshot());
21
+ read();
22
+ const id = window.setInterval(read, 500);
23
+ return () => window.clearInterval(id);
24
+ }, []);
25
+ return text;
26
+ }
27
+
28
+ /**
29
+ * Built-in "Debug" section (`builtins.debug`). The switch turns the on-screen viewport HUD on or off (kept in
30
+ * localStorage); the HUD itself is drawn by `UiProviders` over the whole app, so it stays when this dialog closes.
31
+ */
32
+ export const DebugSection: React.FC = () => {
33
+ const copy = useSettingsCopy();
34
+ const on = React.useSyncExternalStore(subscribeViewportDebug, getViewportDebug, () => false);
35
+ const snapshot = useSnapshot();
36
+ const [, bump] = React.useReducer((n: number) => n + 1, 0);
37
+
38
+ return (
39
+ <div className="space-y-8">
40
+ <SettingsBlock>
41
+ <SettingRow
42
+ label={copy.debug.hud}
43
+ description={copy.debug.hudHint}
44
+ toggle
45
+ checked={on}
46
+ onToggle={setViewportDebug}
47
+ />
48
+ <SettingRow
49
+ label={copy.debug.resetNow}
50
+ action={<Button variant="outline" size="sm" onClick={() => { resetShellScroll('manual'); bump(); }}>{copy.debug.resetNow}</Button>}
51
+ />
52
+ </SettingsBlock>
53
+ <SettingsBlock title={copy.debug.readout}>
54
+ <pre data-testid="viewport-readout" className="whitespace-pre-wrap break-all font-mono text-xs">{snapshot}</pre>
55
+ </SettingsBlock>
56
+ </div>
57
+ );
58
+ };
@@ -2,12 +2,13 @@
2
2
 
3
3
  import React from 'react';
4
4
 
5
- import { KeyRound, Settings as SettingsIcon, UserRound } from 'lucide-react';
5
+ import { Bug, KeyRound, Settings as SettingsIcon, UserRound } from 'lucide-react';
6
6
 
7
7
  import type { SettingsBuiltins, SettingsGroup, SettingsSection } from '../types';
8
8
  import { AccountSection } from './AccountSection';
9
9
  import { GeneralSection } from './GeneralSection';
10
10
  import { ApiKeysSection } from './ApiKeysSection';
11
+ import { DebugSection } from './DebugSection';
11
12
  import type { SettingsCopy } from '../i18n';
12
13
 
13
14
  /**
@@ -40,7 +41,7 @@ export function buildBuiltinSections({
40
41
  generalRows,
41
42
  copy,
42
43
  }: BuildBuiltinArgs): SettingsSection[] {
43
- const { general = true, account = true, security = true, apiKeys = true } = builtins;
44
+ const { general = true, account = true, security = true, apiKeys = true, debug = false } = builtins;
44
45
  const sections: SettingsSection[] = [];
45
46
 
46
47
  if (account) {
@@ -80,6 +81,18 @@ export function buildBuiltinSections({
80
81
  });
81
82
  }
82
83
 
84
+ if (debug) {
85
+ sections.push({
86
+ id: 'debug',
87
+ label: copy.nav.debug,
88
+ icon: Bug,
89
+ group: PLATFORM_GROUP.id,
90
+ title: copy.nav.debug,
91
+ description: copy.debug.description,
92
+ keywords: ['viewport', 'scroll', 'hud', 'diagnostics'],
93
+ content: <DebugSection />,
94
+ });
95
+ }
83
96
 
84
97
  return sections;
85
98
  }
@@ -73,6 +73,11 @@ export interface SettingsBuiltins {
73
73
  security?: boolean;
74
74
  /** API keys. Default: true. */
75
75
  apiKeys?: boolean;
76
+ /**
77
+ * Debug: a switch for the on-screen viewport HUD, a live readout of scroll/viewport values and a "Reset scroll now"
78
+ * button, for chasing a displaced installed app. Default: false, in development too: shown only when the host passes `true`.
79
+ */
80
+ debug?: boolean;
76
81
  }
77
82
 
78
83
  /** Shared configuration consumed by both the dialog and the inline form. */