@selfhelp/shared 1.18.0 → 1.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.
@@ -0,0 +1,106 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ import { describe, it, expect } from 'vitest';
6
+ import type { IPageItem } from '../../types/pages';
7
+ import {
8
+ DEFAULT_MOBILE_NAV_RENDER,
9
+ DEFAULT_WEB_NAV_RENDER,
10
+ isMobileNavRender,
11
+ isWebNavRender,
12
+ MOBILE_NAV_RENDER_OPTIONS,
13
+ resolveMobileNavRender,
14
+ resolveWebNavRender,
15
+ WEB_NAV_RENDER_OPTIONS,
16
+ } from '../navRender';
17
+ import { DEFAULT_MOBILE_ICON, isMobileIconName, MOBILE_ICON_SET, resolveMobileIcon } from '../mobileIcons';
18
+ import { getMenuVisibleChildren, isMenuVisible, isNavigationPage } from '../menuVisibility';
19
+
20
+ function page(partial: Partial<IPageItem>): IPageItem {
21
+ return {
22
+ id: 0,
23
+ keyword: 'k',
24
+ url: null,
25
+ parent_page_id: null,
26
+ is_headless: false,
27
+ navPosition: null,
28
+ footerPosition: null,
29
+ ...partial,
30
+ };
31
+ }
32
+
33
+ describe('navRender', () => {
34
+ it('validates web/mobile render values', () => {
35
+ expect(isWebNavRender('tabs')).toBe(true);
36
+ expect(isWebNavRender('bottom-tabs')).toBe(false); // mobile-only value
37
+ expect(isMobileNavRender('bottom-tabs')).toBe(true);
38
+ expect(isMobileNavRender('header-dropdown')).toBe(false); // web-only value
39
+ expect(isWebNavRender(null)).toBe(false);
40
+ });
41
+
42
+ it('resolves to the value when valid and falls back otherwise', () => {
43
+ expect(resolveWebNavRender('hero-cards')).toBe('hero-cards');
44
+ expect(resolveWebNavRender('nope')).toBe(DEFAULT_WEB_NAV_RENDER);
45
+ expect(resolveWebNavRender(null, 'header-dropdown')).toBe('header-dropdown');
46
+ expect(resolveMobileNavRender('drawer')).toBe('drawer');
47
+ expect(resolveMobileNavRender(undefined)).toBe(DEFAULT_MOBILE_NAV_RENDER);
48
+ });
49
+
50
+ it('option metadata covers every value with a label + description', () => {
51
+ for (const opt of WEB_NAV_RENDER_OPTIONS) {
52
+ expect(isWebNavRender(opt.value)).toBe(true);
53
+ expect(opt.label.length).toBeGreaterThan(0);
54
+ expect(opt.description.length).toBeGreaterThan(0);
55
+ }
56
+ for (const opt of MOBILE_NAV_RENDER_OPTIONS) {
57
+ expect(isMobileNavRender(opt.value)).toBe(true);
58
+ expect(opt.label.length).toBeGreaterThan(0);
59
+ expect(opt.description.length).toBeGreaterThan(0);
60
+ }
61
+ });
62
+ });
63
+
64
+ describe('mobileIcons', () => {
65
+ it('exposes a non-empty curated set with unique names', () => {
66
+ expect(MOBILE_ICON_SET.length).toBeGreaterThan(10);
67
+ const names = MOBILE_ICON_SET.map((entry) => entry.name);
68
+ expect(new Set(names).size).toBe(names.length);
69
+ });
70
+
71
+ it('validates and resolves icon names with a default fallback', () => {
72
+ expect(isMobileIconName('House')).toBe(true);
73
+ expect(isMobileIconName('NotAnIcon')).toBe(false);
74
+ expect(resolveMobileIcon('Users')).toBe('Users');
75
+ expect(resolveMobileIcon('NotAnIcon')).toBe(DEFAULT_MOBILE_ICON);
76
+ expect(resolveMobileIcon(null)).toBe(DEFAULT_MOBILE_ICON);
77
+ });
78
+ });
79
+
80
+ describe('menuVisibility', () => {
81
+ it('treats a page with a nav position and not headless as a menu page', () => {
82
+ expect(isMenuVisible(page({ navPosition: 1 }))).toBe(true);
83
+ expect(isMenuVisible(page({ navPosition: null }))).toBe(false);
84
+ expect(isMenuVisible(page({ navPosition: 1, is_headless: true }))).toBe(false);
85
+ });
86
+
87
+ it('returns only menu-visible children in nav order', () => {
88
+ const parent = page({
89
+ keyword: 'team',
90
+ navPosition: 1,
91
+ children: [
92
+ page({ keyword: 'b', navPosition: 2 }),
93
+ page({ keyword: 'a', navPosition: 1 }),
94
+ page({ keyword: 'hidden', navPosition: null }),
95
+ page({ keyword: 'headless', navPosition: 3, is_headless: true }),
96
+ ],
97
+ });
98
+ const visible = getMenuVisibleChildren(parent);
99
+ expect(visible.map((child) => child.keyword)).toEqual(['a', 'b']);
100
+ expect(isNavigationPage(parent)).toBe(true);
101
+ });
102
+
103
+ it('a leaf page (no menu-visible children) is not a navigation page', () => {
104
+ expect(isNavigationPage(page({ navPosition: 1, children: [] }))).toBe(false);
105
+ });
106
+ });
@@ -0,0 +1,12 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * Navigation contract: render types + option metadata, the curated mobile icon
7
+ * set, and the shared menu-visibility predicate. Imported by the web frontend
8
+ * (admin selects + renderers) and the mobile app (renderers).
9
+ */
10
+ export * from './navRender';
11
+ export * from './mobileIcons';
12
+ export * from './menuVisibility';
@@ -0,0 +1,38 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * The single "is this page on the menu?" predicate, shared by web + mobile menu
7
+ * renderers AND by the automatic virtual-navigation decision. A page is on the
8
+ * menu when the author placed it there (`navPosition != null`) and it is not a
9
+ * headless content-only fragment.
10
+ *
11
+ * Footer-only pages (`footerPosition != null && navPosition == null`), headless
12
+ * pages, and ACL-pruned pages (never in the tree to begin with) are NOT menu
13
+ * pages, so they never appear in a navigation block.
14
+ */
15
+
16
+ import type { IPageItem } from '../types/pages';
17
+
18
+ export function isMenuVisible(page: Pick<IPageItem, 'is_headless' | 'navPosition'>): boolean {
19
+ if (page.is_headless) return false;
20
+ return page.navPosition !== null && page.navPosition !== undefined;
21
+ }
22
+
23
+ /** Children of `page` that should appear in a navigation block, in nav order. */
24
+ export function getMenuVisibleChildren(page: IPageItem): IPageItem[] {
25
+ const children = page.children ?? [];
26
+ return children
27
+ .filter(isMenuVisible)
28
+ .sort((a, b) => (a.navPosition ?? 0) - (b.navPosition ?? 0));
29
+ }
30
+
31
+ /**
32
+ * A "navigation page" is a page whose children act as its menu. The hybrid
33
+ * auto-render rule additionally requires the page to have no visible body
34
+ * sections (decided by the caller, which has the resolved page content).
35
+ */
36
+ export function isNavigationPage(page: IPageItem): boolean {
37
+ return getMenuVisibleChildren(page).length > 0;
38
+ }
@@ -0,0 +1,86 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * Curated mobile icon set — the SINGLE source of truth shared by the admin
7
+ * `select-icon-mobile` picker (web frontend, drawn with `lucide-react`) and the
8
+ * mobile menu renderers (drawn with `lucide-react-native`).
9
+ *
10
+ * Storing the lucide PascalCase export name keeps the contract stable: both
11
+ * `lucide-react` and `lucide-react-native` expose identical named exports, so a
12
+ * renderer maps `name -> (LucideIcons as Record<string, Component>)[name]`.
13
+ *
14
+ * Keep this list to icons that read well at small sizes in a tab bar / drawer
15
+ * and that exist in BOTH lucide packages. Add entries here (never per-app) so
16
+ * the picker and the renderer never drift.
17
+ */
18
+
19
+ export interface IMobileIconEntry {
20
+ /** lucide PascalCase export name, e.g. `Home`, `Users`, `LayoutDashboard`. */
21
+ name: string;
22
+ /** Friendly label for the admin picker. */
23
+ label: string;
24
+ }
25
+
26
+ export const MOBILE_ICON_SET: readonly IMobileIconEntry[] = [
27
+ { name: 'House', label: 'Home' },
28
+ { name: 'LayoutDashboard', label: 'Dashboard' },
29
+ { name: 'User', label: 'User' },
30
+ { name: 'Users', label: 'Users / Team' },
31
+ { name: 'Settings', label: 'Settings' },
32
+ { name: 'FileText', label: 'Document' },
33
+ { name: 'Files', label: 'Files' },
34
+ { name: 'Folder', label: 'Folder' },
35
+ { name: 'Info', label: 'Info' },
36
+ { name: 'CircleQuestionMark', label: 'Help' },
37
+ { name: 'Mail', label: 'Mail' },
38
+ { name: 'Phone', label: 'Phone' },
39
+ { name: 'Calendar', label: 'Calendar' },
40
+ { name: 'Bell', label: 'Notifications' },
41
+ { name: 'Search', label: 'Search' },
42
+ { name: 'Star', label: 'Star' },
43
+ { name: 'Heart', label: 'Heart' },
44
+ { name: 'Bookmark', label: 'Bookmark' },
45
+ { name: 'Map', label: 'Map' },
46
+ { name: 'MapPin', label: 'Location' },
47
+ { name: 'Image', label: 'Image' },
48
+ { name: 'Video', label: 'Video' },
49
+ { name: 'Music', label: 'Music' },
50
+ { name: 'ShoppingCart', label: 'Shopping cart' },
51
+ { name: 'CreditCard', label: 'Payment' },
52
+ { name: 'ChartBar', label: 'Bar chart' },
53
+ { name: 'ChartPie', label: 'Pie chart' },
54
+ { name: 'Activity', label: 'Activity' },
55
+ { name: 'Shield', label: 'Shield' },
56
+ { name: 'Lock', label: 'Lock' },
57
+ { name: 'Globe', label: 'Globe' },
58
+ { name: 'Compass', label: 'Compass' },
59
+ { name: 'Flag', label: 'Flag' },
60
+ { name: 'Award', label: 'Award' },
61
+ { name: 'Briefcase', label: 'Work' },
62
+ { name: 'Building', label: 'Building' },
63
+ { name: 'BookOpen', label: 'Book' },
64
+ { name: 'MessageSquare', label: 'Messages' },
65
+ { name: 'ClipboardList', label: 'Tasks' },
66
+ { name: 'CircleCheck', label: 'Check' },
67
+ { name: 'List', label: 'List' },
68
+ { name: 'LayoutGrid', label: 'Grid' },
69
+ { name: 'Menu', label: 'Menu' },
70
+ { name: 'Database', label: 'Data' },
71
+ ] as const;
72
+
73
+ /** All valid mobile icon names (for validation / membership checks). */
74
+ export const MOBILE_ICON_NAMES: readonly string[] = MOBILE_ICON_SET.map((entry) => entry.name);
75
+
76
+ /** Neutral fallback used when a page has no `mobile_icon` or an unknown value. */
77
+ export const DEFAULT_MOBILE_ICON = 'Circle';
78
+
79
+ export function isMobileIconName(value: unknown): value is string {
80
+ return typeof value === 'string' && MOBILE_ICON_NAMES.includes(value);
81
+ }
82
+
83
+ /** Resolve a stored `mobile_icon` to a drawable name, falling back to the default. */
84
+ export function resolveMobileIcon(value: unknown): string {
85
+ return isMobileIconName(value) ? value : DEFAULT_MOBILE_ICON;
86
+ }
@@ -0,0 +1,132 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * Navigation rendering contract (shared by web + mobile).
7
+ *
8
+ * The page TREE defines navigation STRUCTURE (parent/child + `nav_position`).
9
+ * A per-page render type controls PRESENTATION only — it never changes the
10
+ * structure or the URLs. Web and mobile each pick their own renderer from the
11
+ * stored value, so the same subtree can render differently per platform.
12
+ *
13
+ * - `web_nav_render` selects the web renderer for a page's children.
14
+ * - `mobile_nav_render` selects the mobile renderer for a page's children.
15
+ *
16
+ * Both fields are OPTIONAL on a page; when unset the platform applies its
17
+ * default (web `tabs`, mobile `segmented-tabs` for a navigation page's
18
+ * children; the GLOBAL app menu defaults to web `header-dropdown` and mobile
19
+ * `bottom-tabs`).
20
+ */
21
+
22
+ export type TWebNavRender = 'header-dropdown' | 'tabs' | 'sidebar-drawer' | 'hero-cards';
23
+
24
+ export type TMobileNavRender = 'segmented-tabs' | 'bottom-tabs' | 'drawer' | 'hero-cards';
25
+
26
+ export const WEB_NAV_RENDER_VALUES: readonly TWebNavRender[] = [
27
+ 'header-dropdown',
28
+ 'tabs',
29
+ 'sidebar-drawer',
30
+ 'hero-cards',
31
+ ] as const;
32
+
33
+ export const MOBILE_NAV_RENDER_VALUES: readonly TMobileNavRender[] = [
34
+ 'segmented-tabs',
35
+ 'bottom-tabs',
36
+ 'drawer',
37
+ 'hero-cards',
38
+ ] as const;
39
+
40
+ /** Default renderer for a navigation page's CHILDREN. */
41
+ export const DEFAULT_WEB_NAV_RENDER: TWebNavRender = 'tabs';
42
+ export const DEFAULT_MOBILE_NAV_RENDER: TMobileNavRender = 'segmented-tabs';
43
+
44
+ /** Default renderer for the GLOBAL app menu (header / shell). */
45
+ export const DEFAULT_WEB_GLOBAL_NAV_RENDER: TWebNavRender = 'header-dropdown';
46
+ export const DEFAULT_MOBILE_GLOBAL_NAV_RENDER: TMobileNavRender = 'bottom-tabs';
47
+
48
+ export interface INavRenderOption<T extends string> {
49
+ value: T;
50
+ /** Friendly label for the admin select. */
51
+ label: string;
52
+ /** Short, plain-language explanation shown under the select. */
53
+ description: string;
54
+ }
55
+
56
+ /** Option metadata for the admin "Web menu style" select. */
57
+ export const WEB_NAV_RENDER_OPTIONS: readonly INavRenderOption<TWebNavRender>[] = [
58
+ {
59
+ value: 'header-dropdown',
60
+ label: 'Header dropdown',
61
+ description: 'Classic top menu; child pages appear in a dropdown. Best for the global website menu.',
62
+ },
63
+ {
64
+ value: 'tabs',
65
+ label: 'Tabs',
66
+ description: 'Show child pages as horizontal tabs. Best for a navigation page with a few children.',
67
+ },
68
+ {
69
+ value: 'sidebar-drawer',
70
+ label: 'Sidebar drawer',
71
+ description: 'Side drawer / hamburger menu. Best for large or deep navigation.',
72
+ },
73
+ {
74
+ value: 'hero-cards',
75
+ label: 'Hero cards',
76
+ description: 'Dashboard-style card grid. Best for landing pages and CMS app dashboards.',
77
+ },
78
+ ] as const;
79
+
80
+ /** Option metadata for the admin "Mobile menu style" select. */
81
+ export const MOBILE_NAV_RENDER_OPTIONS: readonly INavRenderOption<TMobileNavRender>[] = [
82
+ {
83
+ value: 'segmented-tabs',
84
+ label: 'Segmented tabs',
85
+ description: 'Top segmented control for first-level children. Best for a few child pages.',
86
+ },
87
+ {
88
+ value: 'bottom-tabs',
89
+ label: 'Bottom tabs',
90
+ description: 'Bottom tab bar for 3–5 main app-like destinations.',
91
+ },
92
+ {
93
+ value: 'drawer',
94
+ label: 'Drawer',
95
+ description: 'Hamburger / side drawer for larger navigation.',
96
+ },
97
+ {
98
+ value: 'hero-cards',
99
+ label: 'Hero cards',
100
+ description: 'Card grid for dashboards and CMS app pages.',
101
+ },
102
+ ] as const;
103
+
104
+ export function isWebNavRender(value: unknown): value is TWebNavRender {
105
+ return typeof value === 'string' && (WEB_NAV_RENDER_VALUES as readonly string[]).includes(value);
106
+ }
107
+
108
+ export function isMobileNavRender(value: unknown): value is TMobileNavRender {
109
+ return typeof value === 'string' && (MOBILE_NAV_RENDER_VALUES as readonly string[]).includes(value);
110
+ }
111
+
112
+ /**
113
+ * Resolve a stored `web_nav_render` value to a concrete renderer, falling back
114
+ * to the supplied default (page-children default by default).
115
+ */
116
+ export function resolveWebNavRender(
117
+ value: unknown,
118
+ fallback: TWebNavRender = DEFAULT_WEB_NAV_RENDER,
119
+ ): TWebNavRender {
120
+ return isWebNavRender(value) ? value : fallback;
121
+ }
122
+
123
+ /**
124
+ * Resolve a stored `mobile_nav_render` value to a concrete renderer, falling
125
+ * back to the supplied default (page-children default by default).
126
+ */
127
+ export function resolveMobileNavRender(
128
+ value: unknown,
129
+ fallback: TMobileNavRender = DEFAULT_MOBILE_NAV_RENDER,
130
+ ): TMobileNavRender {
131
+ return isMobileNavRender(value) ? value : fallback;
132
+ }
@@ -4,6 +4,7 @@ SPDX-License-Identifier: MPL-2.0
4
4
  */
5
5
  import type { IContentField } from './styles/base';
6
6
  import type { TStyleName } from './styles/unknown';
7
+ import type { TWebNavRender, TMobileNavRender } from '../navigation/navRender';
7
8
 
8
9
  /**
9
10
  * Comprehensive page type system, single source of truth for both apps.
@@ -62,6 +63,14 @@ export interface IPageItem extends IBasePageInfo {
62
63
  id_page_access_types?: number;
63
64
  title?: string | null;
64
65
  description?: string | null;
66
+ /** Web menu icon (Tabler component name, e.g. `IconHome`). Page property field `icon`. */
67
+ icon?: string | null;
68
+ /** Mobile menu icon (curated lucide name, e.g. `Home`). Page property field `mobile_icon`. */
69
+ mobile_icon?: string | null;
70
+ /** How this page renders its children as navigation on web. Page property field `web_nav_render`. */
71
+ web_nav_render?: TWebNavRender | null;
72
+ /** How this page renders its children as navigation on mobile. Page property field `mobile_nav_render`. */
73
+ mobile_nav_render?: TMobileNavRender | null;
65
74
  children?: IPageItem[];
66
75
  }
67
76
 
@@ -71,10 +80,40 @@ export interface IPageContent {
71
80
  url: string | null;
72
81
  parent_page_id: number | null;
73
82
  is_headless: boolean;
83
+ /**
84
+ * When true, the web frontend renders this page's content inside a modal
85
+ * overlay (the page title becomes the modal header, with a close button)
86
+ * instead of a full page. Used to open CMS-in-CMS create/edit/detail pages
87
+ * from a list. Web-only — the mobile app renders the page as a normal
88
+ * screen. Mirrors the `open_in_modal` page property field.
89
+ */
90
+ open_in_modal?: boolean;
91
+ /**
92
+ * Optional modal width applied when `open_in_modal` is true (web only). A CSS
93
+ * length (e.g. `'80%'`, `'640px'`) or `'auto'` (fit content, capped at 90% of
94
+ * the viewport). `null`/absent means the frontend default (80%). Mirrors the
95
+ * `modal_width` page property field.
96
+ */
97
+ modal_width?: string | null;
98
+ /**
99
+ * Optional modal height applied when `open_in_modal` is true (web only). A CSS
100
+ * length (e.g. `'80%'`, `'600px'`) or `'auto'` (fit content, capped at 90% of
101
+ * the viewport). `null`/absent means the frontend default (80%). Mirrors the
102
+ * `modal_height` page property field.
103
+ */
104
+ modal_height?: string | null;
74
105
  nav_position: number | null;
75
106
  footer_position: number | null;
76
107
  title?: string | null;
77
108
  description?: string | null;
109
+ /** Web menu icon (Tabler component name). Mirrors the `icon` page property field. */
110
+ icon?: string | null;
111
+ /** Mobile menu icon (curated lucide name). Mirrors the `mobile_icon` page property field. */
112
+ mobile_icon?: string | null;
113
+ /** Web child-navigation render type. Mirrors the `web_nav_render` page property field. */
114
+ web_nav_render?: TWebNavRender | null;
115
+ /** Mobile child-navigation render type. Mirrors the `mobile_nav_render` page property field. */
116
+ mobile_nav_render?: TMobileNavRender | null;
78
117
  /**
79
118
  * Snake_case route params extracted from the matched public URL pattern
80
119
  * (e.g. `{ user_id: '42', token: 'abc' }` or `{ record_id: '7' }`). Present
@@ -42,6 +42,16 @@ export interface IFormStyle extends IStyleWithSpacing {
42
42
  confirm_submit?: IContentField<string>;
43
43
  /** Message shown in the confirmation dialog before submit. */
44
44
  confirm_message?: IContentField<string>;
45
+ /**
46
+ * When '1', a successful submit closes the surrounding web modal (only has
47
+ * an effect when the form's page is opened with `open_in_modal`). Web-only.
48
+ */
49
+ close_modal_on_save?: IContentField<string>;
50
+ /**
51
+ * Optional URL to navigate to after a successful submit (the parent list is
52
+ * refreshed). Empty = stay / close the modal. Web-only.
53
+ */
54
+ redirect_on_save?: IContentField<string>;
45
55
  // RF-21: button knobs are portable to the mobile custom form (not a 1:1
46
56
  // component map). Promoted web_* -> shared_* so both renderers read them.
47
57
  buttons_size?: IContentField<string>;
@@ -488,6 +498,18 @@ export interface IShowUserInputStyle extends IBaseStyle {
488
498
  csv_export?: IContentField<string>;
489
499
  delete_entry?: IContentField<string>;
490
500
  fields_map?: IContentField<string>;
501
+ /**
502
+ * Optional URL of a create form. When set, the web table shows an "Add new"
503
+ * button above it (e.g. opens the create form modal). Web-only.
504
+ */
505
+ add_url?: IContentField<string>;
506
+ /**
507
+ * Optional URL template for opening a row's detail (e.g.
508
+ * `/cms/team/{record_id}`). When set, each row gets an open/view action
509
+ * (eye icon) with the single-brace `{record_id}` placeholder substituted by
510
+ * the renderer at click time. Web-only.
511
+ */
512
+ edit_url?: IContentField<string>;
491
513
  delete_modal_title?: IContentField<string>;
492
514
  delete_modal_body?: IContentField<string>;
493
515
  spacing?: IContentField<string>;
@@ -48,6 +48,29 @@ describe('transformPageData', () => {
48
48
  expect(result.children[0].navPosition).toBe(5);
49
49
  });
50
50
 
51
+ it('passes through the navigation icon + render fields', () => {
52
+ const result = transformPageData({
53
+ id: 1,
54
+ keyword: 'team',
55
+ icon: 'IconUsers',
56
+ mobile_icon: 'Users',
57
+ web_nav_render: 'hero-cards',
58
+ mobile_nav_render: 'bottom-tabs',
59
+ });
60
+ expect(result.icon).toBe('IconUsers');
61
+ expect(result.mobile_icon).toBe('Users');
62
+ expect(result.web_nav_render).toBe('hero-cards');
63
+ expect(result.mobile_nav_render).toBe('bottom-tabs');
64
+ });
65
+
66
+ it('defaults the navigation fields to null when absent', () => {
67
+ const result = transformPageData({ id: 1, keyword: 'plain' });
68
+ expect(result.icon).toBeNull();
69
+ expect(result.mobile_icon).toBeNull();
70
+ expect(result.web_nav_render).toBeNull();
71
+ expect(result.mobile_nav_render).toBeNull();
72
+ });
73
+
51
74
  it('defaults missing id/keyword safely', () => {
52
75
  const result = transformPageData({});
53
76
  expect(result.id).toBe(0);
@@ -19,9 +19,18 @@ SPDX-License-Identifier: MPL-2.0
19
19
  * removed all legacy aliases (`parent`, `id_type`,
20
20
  * `id_pageAccessTypes`). The backend is the single source of canonical
21
21
  * keys; the transformer no longer accepts the legacy shapes.
22
+ *
23
+ * ROUTE METADATA (issue #30): this transformer deliberately does NOT carry
24
+ * `route_params` / `matched_url_pattern` / `canonical_url`. Those are
25
+ * resolve-time fields of a single page's full content (`IPageContent`, returned
26
+ * by `GET /pages/resolve`) and are consumed directly off that type. `IPageItem`
27
+ * is the navigation/menu projection of the page tree (keyword, url,
28
+ * nav/footer position, parent/children) and never participates in URL
29
+ * resolution, so adding a route passthrough here would be dead weight.
22
30
  */
23
31
 
24
32
  import type { IPageItem } from '../types/pages';
33
+ import type { TWebNavRender, TMobileNavRender } from '../navigation/navRender';
25
34
 
26
35
  interface IRawPage {
27
36
  id?: number;
@@ -39,6 +48,10 @@ interface IRawPage {
39
48
  is_open_access?: number | boolean | null;
40
49
  title?: string | null;
41
50
  description?: string | null;
51
+ icon?: string | null;
52
+ mobile_icon?: string | null;
53
+ web_nav_render?: TWebNavRender | string | null;
54
+ mobile_nav_render?: TMobileNavRender | string | null;
42
55
  id_users?: number;
43
56
  acl_select?: 0 | 1;
44
57
  acl_insert?: 0 | 1;
@@ -76,6 +89,10 @@ export function transformPageData(apiPage: IRawPage): IPageItem {
76
89
  is_system: apiPage.is_system !== undefined ? toBool(apiPage.is_system) : undefined,
77
90
  title: apiPage.title ?? null,
78
91
  description: apiPage.description ?? null,
92
+ icon: apiPage.icon ?? null,
93
+ mobile_icon: apiPage.mobile_icon ?? null,
94
+ web_nav_render: (apiPage.web_nav_render as TWebNavRender | null) ?? null,
95
+ mobile_nav_render: (apiPage.mobile_nav_render as TMobileNavRender | null) ?? null,
79
96
  children: apiPage.children?.map(transformPageData) ?? [],
80
97
 
81
98
  id_users: apiPage.id_users,