@selfhelp/shared 1.21.3 → 1.21.6

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 (53) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/README.md +2 -1
  3. package/dist/index.d.mts +519 -24
  4. package/dist/index.d.ts +519 -24
  5. package/dist/index.js +723 -18
  6. package/dist/index.mjs +674 -18
  7. package/dist/plugin-sdk/index.d.mts +1 -1
  8. package/dist/plugin-sdk/index.d.ts +1 -1
  9. package/dist/plugin-sdk/index.js +2 -1
  10. package/dist/plugin-sdk/index.mjs +2 -1
  11. package/dist/registry/index.d.mts +2 -2
  12. package/dist/registry/index.d.ts +2 -2
  13. package/dist/registry/index.js +2 -1
  14. package/dist/registry/index.mjs +2 -1
  15. package/dist/{styles.registry-DEDEZ8l3.d.ts → styles.registry-DX79oirw.d.ts} +93 -16
  16. package/dist/{styles.registry-DHM4M77N.d.mts → styles.registry-ffw0MH3r.d.mts} +93 -16
  17. package/package.json +1 -1
  18. package/src/api/__tests__/endpoints.test.ts +37 -12
  19. package/src/api/endpoints.ts +5 -5
  20. package/src/api/index.ts +1 -0
  21. package/src/api/pagesResolve.ts +78 -0
  22. package/src/content/__tests__/fieldsMapLabels.test.ts +55 -0
  23. package/src/content/__tests__/formRecordPrefill.test.ts +104 -0
  24. package/src/content/__tests__/optionLabels.test.ts +100 -0
  25. package/src/content/fieldsMapLabels.ts +103 -0
  26. package/src/content/formRecordPrefill.ts +191 -0
  27. package/src/content/index.ts +3 -0
  28. package/src/content/optionLabels.ts +200 -0
  29. package/src/navigation/__tests__/navigation.test.ts +296 -6
  30. package/src/navigation/activeTrail.ts +99 -0
  31. package/src/navigation/branchNav.ts +155 -6
  32. package/src/navigation/footerPreset.ts +109 -0
  33. package/src/navigation/headerLayers.ts +56 -0
  34. package/src/navigation/headerPreset.ts +9 -2
  35. package/src/navigation/index.ts +4 -0
  36. package/src/navigation/menuDepth.ts +73 -37
  37. package/src/navigation/mobileRoute.ts +25 -0
  38. package/src/navigation/navLinks.ts +0 -4
  39. package/src/navigation/navigationBundle.ts +81 -0
  40. package/src/navigation/navigationPayload.ts +96 -17
  41. package/src/registry/__tests__/platform.test.ts +11 -10
  42. package/src/registry/styles.registry.ts +2 -1
  43. package/src/types/__tests__/preview-bridge.test.ts +7 -0
  44. package/src/types/auth.ts +4 -0
  45. package/src/types/cms-app.ts +74 -0
  46. package/src/types/index.ts +1 -0
  47. package/src/types/mobile-adapters.ts +1 -0
  48. package/src/types/pages.ts +6 -0
  49. package/src/types/preview-bridge.ts +22 -2
  50. package/src/types/styles/composite.ts +21 -0
  51. package/src/types/styles/forms.ts +57 -10
  52. package/src/types/styles/interactive.ts +1 -1
  53. package/src/types/styles/unknown.ts +2 -2
@@ -0,0 +1,109 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * Global web footer presentation presets (menu-builder `web_footer` menu).
7
+ *
8
+ * Footer layout uses the same preset mechanism as the web header: the value is
9
+ * stored on `navigation_menus.id_preset` and switching presets never mutates
10
+ * menu items — `inline` flattens groups at render time only, so switching back
11
+ * to `columns` restores the exact same groups.
12
+ */
13
+ import type { INavigationMenuItem } from './navigationPayload';
14
+
15
+ export type TWebFooterPreset = 'columns' | 'inline';
16
+
17
+ export const WEB_FOOTER_PRESET_VALUES: readonly TWebFooterPreset[] = [
18
+ 'columns',
19
+ 'inline',
20
+ ] as const;
21
+
22
+ export const DEFAULT_WEB_FOOTER_PRESET: TWebFooterPreset = 'columns';
23
+
24
+ export interface IWebFooterPresetOption {
25
+ value: TWebFooterPreset;
26
+ label: string;
27
+ description: string;
28
+ }
29
+
30
+ export const WEB_FOOTER_PRESET_OPTIONS: readonly IWebFooterPresetOption[] = [
31
+ {
32
+ value: 'columns',
33
+ label: 'Columns (grouped)',
34
+ description: 'Group headings become footer columns with their links below.',
35
+ },
36
+ {
37
+ value: 'inline',
38
+ label: 'Inline links',
39
+ description: 'One flat centered link row; group links are shown inline, headings hidden. Groups are kept and restored when switching back.',
40
+ },
41
+ ] as const;
42
+
43
+ export function isWebFooterPreset(value: unknown): value is TWebFooterPreset {
44
+ return typeof value === 'string' && (WEB_FOOTER_PRESET_VALUES as readonly string[]).includes(value);
45
+ }
46
+
47
+ export function resolveWebFooterPreset(
48
+ value: unknown,
49
+ fallback: TWebFooterPreset = DEFAULT_WEB_FOOTER_PRESET,
50
+ ): TWebFooterPreset {
51
+ return isWebFooterPreset(value) ? value : fallback;
52
+ }
53
+
54
+ function isRenderableFooterLeaf(item: INavigationMenuItem): boolean {
55
+ if (!item.is_active) {
56
+ return false;
57
+ }
58
+ if (item.item_type === 'external_url') {
59
+ return item.external_url != null && item.external_url !== '';
60
+ }
61
+ return item.item_type === 'page' && item.page != null;
62
+ }
63
+
64
+ /**
65
+ * Flatten a footer tree for the `inline` preset: active page/external links are
66
+ * kept in order, group children are promoted in place of their heading, and
67
+ * inactive items or empty groups are dropped. Data is never mutated.
68
+ */
69
+ export function flattenFooterItems(items: INavigationMenuItem[]): INavigationMenuItem[] {
70
+ const out: INavigationMenuItem[] = [];
71
+ for (const item of items) {
72
+ if (!item.is_active) {
73
+ continue;
74
+ }
75
+ if (item.item_type === 'group') {
76
+ out.push(...flattenFooterItems(item.children));
77
+ continue;
78
+ }
79
+ if (isRenderableFooterLeaf(item)) {
80
+ out.push(item);
81
+ // Non-group items may still carry nested links; promote them too.
82
+ out.push(...flattenFooterItems(item.children));
83
+ }
84
+ }
85
+ return out;
86
+ }
87
+
88
+ /**
89
+ * Footer columns for the `columns` preset: top-level groups that contain at
90
+ * least one renderable link. Standalone (non-group) top-level links are not
91
+ * columns — render them separately via {@link footerStandaloneItems}.
92
+ */
93
+ export function footerColumnItems(items: INavigationMenuItem[]): INavigationMenuItem[] {
94
+ return items.filter(
95
+ (item) => item.is_active
96
+ && item.item_type === 'group'
97
+ && item.children.some(isRenderableFooterLeaf),
98
+ );
99
+ }
100
+
101
+ /** Active top-level non-group links (rendered as a trailing meta row in `columns` mode). */
102
+ export function footerStandaloneItems(items: INavigationMenuItem[]): INavigationMenuItem[] {
103
+ return items.filter((item) => item.item_type !== 'group' && isRenderableFooterLeaf(item));
104
+ }
105
+
106
+ /** Renderable links inside one footer column/group. */
107
+ export function footerGroupLinks(group: INavigationMenuItem): INavigationMenuItem[] {
108
+ return group.children.filter(isRenderableFooterLeaf);
109
+ }
@@ -0,0 +1,56 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * Web header layer helpers for double-header presets.
7
+ *
8
+ * `web_header` root items carry `layer: 'top' | null` (`null` = main row).
9
+ * Double presets render two rows; single presets ignore the layer and merge
10
+ * every root item into one row. Layer assignments are data, never destroyed by
11
+ * switching presets — switching back to a double preset restores the split.
12
+ */
13
+ import type { INavigationMenuItem, TNavigationHeaderLayer } from './navigationPayload';
14
+
15
+ export const NAVIGATION_HEADER_LAYER_TOP: TNavigationHeaderLayer = 'top';
16
+
17
+ export interface IHeaderLayerSplit {
18
+ /** Flat links for the top utility row (double presets only). */
19
+ top: INavigationMenuItem[];
20
+ /** Main navigation row items (preset-specific children rendering). */
21
+ main: INavigationMenuItem[];
22
+ }
23
+
24
+ function byPosition(a: INavigationMenuItem, b: INavigationMenuItem): number {
25
+ return a.position - b.position || a.id - b.id;
26
+ }
27
+
28
+ /**
29
+ * Split root header items into top and main rows for double presets.
30
+ * Top-row items are rendered as flat links; their children are ignored by design.
31
+ */
32
+ export function splitHeaderLayers(items: INavigationMenuItem[]): IHeaderLayerSplit {
33
+ const top: INavigationMenuItem[] = [];
34
+ const main: INavigationMenuItem[] = [];
35
+ for (const item of items) {
36
+ if (item.layer === NAVIGATION_HEADER_LAYER_TOP) {
37
+ top.push(item);
38
+ } else {
39
+ main.push(item);
40
+ }
41
+ }
42
+ top.sort(byPosition);
43
+ main.sort(byPosition);
44
+ return { top, main };
45
+ }
46
+
47
+ /**
48
+ * Merge root header items into one ordered row for single-layer presets:
49
+ * main-row items first (position order), then top-row items appended
50
+ * (position order). Deterministic and non-destructive — `layer` values stay
51
+ * on the items so switching back to a double preset restores the split.
52
+ */
53
+ export function mergeHeaderLayers(items: INavigationMenuItem[]): INavigationMenuItem[] {
54
+ const { top, main } = splitHeaderLayers(items);
55
+ return [...main, ...top];
56
+ }
@@ -36,14 +36,21 @@ export const WEB_HEADER_PRESET_OPTIONS: readonly IWebHeaderPresetOption[] = [
36
36
  { value: 'dropdown', label: 'Dropdown', description: 'Default — nested dropdown menus.' },
37
37
  { value: 'mega-menu', label: 'Mega menu', description: 'Rich sections with descriptions and icons.' },
38
38
  { value: 'tabs', label: 'Tabs', description: 'Top-level sections as tabs.' },
39
- { value: 'double-dropdown', label: 'Double header (dropdown)', description: 'Utility row plus main dropdown nav.' },
40
- { value: 'double-mega-menu', label: 'Double header (mega menu)', description: 'Utility row plus mega menu.' },
39
+ { value: 'double-dropdown', label: 'Double header (dropdown)', description: 'Top row with flat links and utilities above the main dropdown nav.' },
40
+ { value: 'double-mega-menu', label: 'Double header (mega menu)', description: 'Top row with flat links and utilities above the mega menu.' },
41
41
  ] as const;
42
42
 
43
+ const DOUBLE_WEB_HEADER_PRESETS: readonly TWebHeaderPreset[] = ['double-dropdown', 'double-mega-menu'];
44
+
43
45
  export function isWebHeaderPreset(value: unknown): value is TWebHeaderPreset {
44
46
  return typeof value === 'string' && (WEB_HEADER_PRESET_VALUES as readonly string[]).includes(value);
45
47
  }
46
48
 
49
+ /** True for presets that render the two-row (top layer + main layer) header. */
50
+ export function isDoubleWebHeaderPreset(value: unknown): boolean {
51
+ return isWebHeaderPreset(value) && (DOUBLE_WEB_HEADER_PRESETS as readonly string[]).includes(value);
52
+ }
53
+
47
54
  export function resolveWebHeaderPreset(
48
55
  value: unknown,
49
56
  fallback: TWebHeaderPreset = DEFAULT_WEB_HEADER_PRESET,
@@ -3,7 +3,10 @@ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
3
  SPDX-License-Identifier: MPL-2.0
4
4
  */
5
5
  export * from './headerPreset';
6
+ export * from './footerPreset';
7
+ export * from './headerLayers';
6
8
  export * from './navigationPayload';
9
+ export * from './navigationBundle';
7
10
  export * from './menuMembership';
8
11
  export * from './branchNav';
9
12
  export * from './navLinks';
@@ -13,3 +16,4 @@ export * from './mobileIcons';
13
16
  export * from './startup';
14
17
  export * from './menuSearch';
15
18
  export * from './menuDepth';
19
+ export * from './activeTrail';
@@ -1,37 +1,73 @@
1
- /*
2
- SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
- SPDX-License-Identifier: MPL-2.0
4
- */
5
- import type { INavigationMenuItem } from './navigationPayload';
6
-
7
- /**
8
- * Normalises menu max_depth: null/undefined/0 means unlimited.
9
- */
10
- export function resolveMenuMaxDepth(maxDepth: number | null | undefined): number | null {
11
- if (maxDepth === null || maxDepth === undefined || maxDepth <= 0) {
12
- return null;
13
- }
14
-
15
- return maxDepth;
16
- }
17
-
18
- /**
19
- * Strips nested children beyond the configured depth so renderers do not
20
- * expand deeper levels in dropdown/mega panels.
21
- */
22
- export function clampMenuItemsAtDepth(
23
- items: INavigationMenuItem[],
24
- maxDepth: number | null,
25
- depth = 0,
26
- ): INavigationMenuItem[] {
27
- return items.map((item) => {
28
- const atLimit = maxDepth !== null && depth >= maxDepth;
29
- const children = item.children ?? [];
30
-
31
- return {
32
- ...item,
33
- children: atLimit ? [] : clampMenuItemsAtDepth(children, maxDepth, depth + 1),
34
- };
35
- });
36
- }
37
-
1
+ /*
2
+
3
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
4
+
5
+ SPDX-License-Identifier: MPL-2.0
6
+
7
+ */
8
+
9
+ import type { INavigationMenuItem } from './navigationPayload';
10
+
11
+
12
+
13
+ /**
14
+
15
+ * Normalises menu max_depth: null/undefined/0 means unlimited.
16
+
17
+ */
18
+
19
+ export function resolveMenuMaxDepth(maxDepth: number | null | undefined): number | null {
20
+
21
+ if (maxDepth === null || maxDepth === undefined || maxDepth <= 0) {
22
+
23
+ return null;
24
+
25
+ }
26
+
27
+
28
+
29
+ return maxDepth;
30
+
31
+ }
32
+
33
+
34
+
35
+ /**
36
+
37
+ * Strips nested children beyond the configured depth so renderers do not
38
+
39
+ * expand deeper levels in dropdown/mega panels.
40
+
41
+ */
42
+
43
+ export function clampMenuItemsAtDepth(
44
+
45
+ items: INavigationMenuItem[],
46
+
47
+ maxDepth: number | null,
48
+
49
+ depth = 0,
50
+
51
+ ): INavigationMenuItem[] {
52
+
53
+ return items.map((item) => {
54
+
55
+ const atLimit = maxDepth !== null && depth >= maxDepth;
56
+
57
+ const children = item.children ?? [];
58
+
59
+
60
+
61
+ return {
62
+
63
+ ...item,
64
+
65
+ children: atLimit ? [] : clampMenuItemsAtDepth(children, maxDepth, depth + 1),
66
+
67
+ };
68
+
69
+ });
70
+
71
+ }
72
+
73
+
@@ -8,6 +8,31 @@ SPDX-License-Identifier: MPL-2.0
8
8
  * Wave 1 uses keyword-based routes (`[keyword].tsx`), not file `[...slug]`
9
9
  * segments. Nested public URLs (`/parent/child`) still navigate by keyword.
10
10
  */
11
+ /**
12
+ * Substitute `{param}` placeholders in a CMS page URL template using route
13
+ * params (snake_case keys). Returns null when the template or params are
14
+ * incomplete.
15
+ */
16
+ export function buildPublicPathFromRoute(
17
+ urlTemplate: string | null | undefined,
18
+ routeParams: Record<string, string | undefined>,
19
+ ): string | null {
20
+ if (!urlTemplate || !urlTemplate.includes('{')) {
21
+ return null;
22
+ }
23
+ let path = urlTemplate;
24
+ for (const [key, value] of Object.entries(routeParams)) {
25
+ if (value === undefined || value === '') {
26
+ continue;
27
+ }
28
+ path = path.replaceAll(`{${key}}`, value);
29
+ }
30
+ if (path.includes('{')) {
31
+ return null;
32
+ }
33
+ return path.replace(/\/+$/, '') || '/';
34
+ }
35
+
11
36
  export function pageUrlToMobileRoute(url: string | null | undefined, keyword: string): string {
12
37
  const normalizedKeyword = keyword.trim().toLowerCase();
13
38
  if (normalizedKeyword === 'profile') {
@@ -9,10 +9,6 @@ export function getNavigationItemLabel(item: INavigationMenuItem): string {
9
9
  }
10
10
 
11
11
  export function getNavigationItemAriaLabel(item: INavigationMenuItem): string | undefined {
12
- const aria = item.aria_label?.trim();
13
- if (aria) {
14
- return aria;
15
- }
16
12
  const label = getNavigationItemLabel(item);
17
13
  return label || undefined;
18
14
  }
@@ -0,0 +1,81 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * `selfhelp/navigation-bundle` v2.0 — the only supported navigation bundle
7
+ * schema. Bundles are an authoring/transfer format: optional keys mean "not
8
+ * set" (unlike the strict runtime payload where every key is present).
9
+ *
10
+ * v2.0 replaces v1.0 entirely: menu `config` is gone (footer layout is a
11
+ * preset), items carry `layer`, and translations use `aria_label` (the legacy
12
+ * `n` key is not accepted). Imports reject any other version.
13
+ */
14
+ import type {
15
+ TNavigationHeaderLayer,
16
+ TNavigationMenuItemType,
17
+ TNavigationMenuKey,
18
+ } from './navigationPayload';
19
+
20
+ export const NAVIGATION_BUNDLE_FORMAT = 'selfhelp/navigation-bundle';
21
+ export const NAVIGATION_BUNDLE_VERSION = '2.0';
22
+
23
+ export interface INavigationBundleItemTranslation {
24
+ locale: string;
25
+ label: string;
26
+ description?: string | null;
27
+ aria_label?: string | null;
28
+ }
29
+
30
+ export interface INavigationBundleItem {
31
+ /** Stable in-bundle reference used by children via `parent_ref`. */
32
+ ref: string;
33
+ parent_ref: string | null;
34
+ item_type: TNavigationMenuItemType;
35
+ position: number;
36
+ is_active?: boolean;
37
+ /** Top header row assignment (`web_header` root items only). */
38
+ layer?: TNavigationHeaderLayer | null;
39
+ /** Page items: target page keyword (resolved on import). */
40
+ page_keyword?: string | null;
41
+ /** External items: absolute URL. */
42
+ external_url?: string | null;
43
+ icon?: string | null;
44
+ mobile_icon?: string | null;
45
+ /** Default-language label cache for group/external items. */
46
+ label?: string | null;
47
+ translations?: INavigationBundleItemTranslation[];
48
+ }
49
+
50
+ export interface INavigationBundleMenu {
51
+ preset?: string | null;
52
+ max_depth?: number | null;
53
+ item_limit?: number | null;
54
+ items: INavigationBundleItem[];
55
+ }
56
+
57
+ export type TNavigationBundleExportMode = 'full_snapshot' | 'branch';
58
+
59
+ export interface INavigationBundleImportHints {
60
+ default_keyword_prefix?: string;
61
+ default_route_prefix?: string;
62
+ }
63
+
64
+ export interface INavigationBundle {
65
+ format: typeof NAVIGATION_BUNDLE_FORMAT;
66
+ version: string;
67
+ title?: string;
68
+ description?: string;
69
+ min_core_version?: string;
70
+ exported_at?: string;
71
+ core_version?: string;
72
+ export_mode?: TNavigationBundleExportMode;
73
+ import_hints?: INavigationBundleImportHints;
74
+ menus: Partial<Record<TNavigationMenuKey, INavigationBundleMenu>>;
75
+ /** Optional embedded `selfhelp/page-bundle` pages payload. */
76
+ pages?: unknown[];
77
+ }
78
+
79
+ export function isNavigationBundleVersionSupported(version: unknown): boolean {
80
+ return version === NAVIGATION_BUNDLE_VERSION;
81
+ }
@@ -3,6 +3,7 @@ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
3
  SPDX-License-Identifier: MPL-2.0
4
4
  */
5
5
  import type { TWebHeaderPreset } from './headerPreset';
6
+ import type { TWebFooterPreset } from './footerPreset';
6
7
 
7
8
  export type TNavigationMenuKey =
8
9
  | 'web_header'
@@ -12,7 +13,17 @@ export type TNavigationMenuKey =
12
13
 
13
14
  export type TNavigationMenuItemType = 'page' | 'external_url' | 'group';
14
15
 
15
- export type TNavigationChildSource = 'manual' | 'page_children' | 'manual_plus_suggestions';
16
+ /** Header row assignment for `web_header` root items (`null` = main row). */
17
+ export type TNavigationHeaderLayer = 'top';
18
+
19
+ /**
20
+ * How a web page presents its menu branch (children/siblings):
21
+ * `sidebar` = left sidebar + prev/next pager, `pills` = compact pill strip,
22
+ * `none` = only the page content. Menu-level default (NULL resolves to
23
+ * `sidebar`), overridable per parent item. Mobile menus have native
24
+ * presentation and always carry `null`.
25
+ */
26
+ export type TNavigationChildrenNavMode = 'sidebar' | 'pills' | 'none';
16
27
 
17
28
  export type TNavigationSearchMode = 'off' | 'menu_pages' | 'searchable_pages' | 'content_index';
18
29
 
@@ -25,36 +36,49 @@ export interface INavigationResolvedPageRef {
25
36
  keyword: string;
26
37
  url: string | null;
27
38
  title: string | null;
28
- icon?: string | null;
29
- mobile_icon?: string | null;
30
39
  has_content?: boolean;
31
40
  section_count?: number;
32
41
  }
33
42
 
43
+ /**
44
+ * Resolved public menu item (`GET /navigation`). Strict contract: every key is
45
+ * always present; absence of a value is expressed as `null`, never a missing key.
46
+ */
34
47
  export interface INavigationMenuItem {
35
- id: number | string;
48
+ id: number;
36
49
  item_type: TNavigationMenuItemType;
37
50
  label: string;
38
- description?: string | null;
39
- aria_label?: string | null;
40
- icon?: string | null;
51
+ description: string | null;
52
+ aria_label: string | null;
53
+ icon: string | null;
54
+ mobile_icon: string | null;
41
55
  position: number;
42
- external_url?: string | null;
43
- page?: INavigationResolvedPageRef | null;
44
- is_virtual?: boolean;
45
- is_active?: boolean;
46
- child_source?: TNavigationChildSource;
47
- children?: INavigationMenuItem[];
56
+ /** Only meaningful on `web_header` root items; `null` everywhere else. */
57
+ layer: TNavigationHeaderLayer | null;
58
+ /** Per-parent-item override of the menu's `children_nav` default (web menus only). */
59
+ children_nav: TNavigationChildrenNavMode | null;
60
+ /** Per-parent-item override of the menu's `show_pager` default; `null` = inherit. */
61
+ show_pager?: boolean | null;
62
+ external_url: string | null;
63
+ page: INavigationResolvedPageRef | null;
64
+ is_active: boolean;
65
+ children: INavigationMenuItem[];
48
66
  }
49
67
 
50
68
  export interface INavigationMenu {
51
69
  key: TNavigationMenuKey;
52
70
  platform: 'web' | 'mobile';
53
71
  surface: 'header' | 'footer' | 'drawer' | 'bottom_tabs';
54
- preset?: TWebHeaderPreset | string | null;
55
- max_depth?: number | null;
56
- item_limit?: number | null;
57
- config?: Record<string, unknown> | null;
72
+ /** Header presets for `web_header`, footer presets for `web_footer`, `null` for mobile menus. */
73
+ preset: TWebHeaderPreset | TWebFooterPreset | null;
74
+ max_depth: number | null;
75
+ item_limit: number | null;
76
+ /** Resolved branch presentation default; `sidebar`/`pills`/`none` on web menus, `null` on mobile menus. */
77
+ children_nav: TNavigationChildrenNavMode | null;
78
+ /** Breadcrumb trail above nested web pages; always `false` on mobile menus. */
79
+ show_breadcrumbs: boolean;
80
+ /** Prev/next pager on nested web pages; always `false` on mobile menus. */
81
+ show_pager?: boolean;
58
82
  items: INavigationMenuItem[];
59
83
  }
60
84
 
@@ -78,8 +102,63 @@ export interface INavigationSearchConfig {
78
102
  field_policy: string;
79
103
  }
80
104
 
105
+ /** Brand block size step; maps to logo heights 24/32/44/56px on web. */
106
+ export type TNavigationBrandingSize = 'sm' | 'md' | 'lg' | 'xl';
107
+
108
+ /** Brand block layout: image + site name, image alone, or text alone. */
109
+ export type TNavigationBrandingVariant = 'logo-and-name' | 'logo-only' | 'name-only';
110
+
111
+ /**
112
+ * Global branding block shared by the web header and the mobile drawer:
113
+ * `logo_url` = public path of the logo asset (null = text fallback),
114
+ * `logo_alt` = accessible alt / brand text, `link_url` = logo click target
115
+ * (null = home), `logo_size` + `logo_variant` = presentation options
116
+ * (default `md` / `logo-and-name` when omitted by older backends).
117
+ */
118
+ export interface INavigationBranding {
119
+ logo_url: string | null;
120
+ logo_alt: string | null;
121
+ link_url: string | null;
122
+ logo_size?: TNavigationBrandingSize;
123
+ logo_variant?: TNavigationBrandingVariant;
124
+ }
125
+
126
+ /** Logo pixel heights per brand size step (shared by web header + mobile drawer). */
127
+ export const NAVIGATION_BRANDING_LOGO_HEIGHTS: Record<TNavigationBrandingSize, number> = {
128
+ sm: 24,
129
+ md: 32,
130
+ lg: 44,
131
+ xl: 56,
132
+ };
133
+
134
+ /**
135
+ * Resolve the branding presentation with cross-platform defaults: older
136
+ * backends omit `logo_size` / `logo_variant`, and a missing logo image
137
+ * degrades `logo-and-name` / `logo-only` to the text fallback.
138
+ */
139
+ export function resolveBrandingPresentation(branding?: INavigationBranding | null): {
140
+ size: TNavigationBrandingSize;
141
+ variant: TNavigationBrandingVariant;
142
+ logoHeight: number;
143
+ showLogo: boolean;
144
+ showName: boolean;
145
+ } {
146
+ const size: TNavigationBrandingSize = branding?.logo_size ?? 'md';
147
+ const requestedVariant: TNavigationBrandingVariant = branding?.logo_variant ?? 'logo-and-name';
148
+ const hasLogo = Boolean(branding?.logo_url);
149
+ const variant: TNavigationBrandingVariant = hasLogo ? requestedVariant : 'name-only';
150
+ return {
151
+ size,
152
+ variant,
153
+ logoHeight: NAVIGATION_BRANDING_LOGO_HEIGHTS[size],
154
+ showLogo: variant !== 'name-only',
155
+ showName: variant !== 'logo-only',
156
+ };
157
+ }
158
+
81
159
  export interface INavigationPayload {
82
160
  menus: Record<TNavigationMenuKey, INavigationMenu>;
83
161
  startup: INavigationStartupConfig;
84
162
  search: INavigationSearchConfig;
163
+ branding?: INavigationBranding;
85
164
  }
@@ -39,7 +39,7 @@ describe('style render-target targeting', () => {
39
39
  it('defaults the eight established system/data styles to both', () => {
40
40
  for (const name of [
41
41
  'no-access', 'missing', 'not-found', 'version',
42
- 'ref-container', 'data-container', 'show-user-input', 'timeline-item',
42
+ 'ref-container', 'data-container', 'entry-table', 'timeline-item',
43
43
  ]) {
44
44
  expect(getStylePlatforms(name)).toEqual(['web', 'mobile']);
45
45
  }
@@ -145,18 +145,18 @@ describe('style placement targeting', () => {
145
145
  });
146
146
 
147
147
  /**
148
- * Catalog parity (mobile rendering plan, milestone one). The core registry must
149
- * be the established 90-style backend catalog: the eight previously-missing
150
- * system/data/reference styles are present, and the sixteen deferred
151
- * speculative styles are absent. Drift here means the shared contract and the
152
- * backend catalog have diverged.
148
+ * Catalog parity (mobile rendering plan, milestone one + entry-record-form).
149
+ * The core registry must match the established backend catalog (91 styles):
150
+ * the eight previously-missing system/data/reference styles are present, and
151
+ * the sixteen deferred speculative styles are absent. Drift here means the
152
+ * shared contract and the backend catalog have diverged.
153
153
  */
154
- describe('core catalog parity (90 established styles)', () => {
154
+ describe('core catalog parity (91 established styles)', () => {
155
155
  const CORE_NAMES = Object.keys(BASE_STYLE_REGISTRY);
156
156
 
157
157
  const PREVIOUSLY_MISSING = [
158
158
  'data-container', 'timeline-item', 'version', 'no-access',
159
- 'missing', 'not-found', 'ref-container', 'show-user-input',
159
+ 'missing', 'not-found', 'ref-container', 'entry-table',
160
160
  ];
161
161
 
162
162
  const DEFERRED_SPECULATIVE = [
@@ -165,8 +165,9 @@ describe('core catalog parity (90 established styles)', () => {
165
165
  'input-otp', 'search-field', 'fab-button', 'biometric-login-button',
166
166
  ];
167
167
 
168
- it('contains exactly the 90 established core styles', () => {
169
- expect(CORE_NAMES).toHaveLength(90);
168
+ it('contains exactly the 91 established core styles', () => {
169
+ expect(CORE_NAMES).toHaveLength(91);
170
+ expect(CORE_NAMES).toContain('entry-record-form');
170
171
  });
171
172
 
172
173
  it('includes every previously-missing established style', () => {
@@ -182,6 +182,7 @@ export const BASE_STYLE_REGISTRY = {
182
182
  // ===== forms =====
183
183
  'form-log': { description: 'Append-only form (one row per submit)', category: 'forms', canHaveChildren: true },
184
184
  'form-record': { description: 'Per-user record form', category: 'forms', canHaveChildren: true },
185
+ 'entry-record-form': { description: 'Route-aware create/edit form', category: 'forms', canHaveChildren: true },
185
186
  input: { description: 'Plain HTML input', category: 'forms', canHaveChildren: false },
186
187
  'text-input': { description: 'Mantine TextInput', category: 'forms', canHaveChildren: false },
187
188
  textarea: { description: 'Mantine Textarea', category: 'forms', canHaveChildren: false },
@@ -225,7 +226,7 @@ export const BASE_STYLE_REGISTRY = {
225
226
  version: { description: 'Build/version diagnostic surface', category: 'auth', canHaveChildren: false },
226
227
  'ref-container': { description: 'Renders content referenced from another section', category: 'layout', canHaveChildren: true },
227
228
  'data-container': { description: 'Data-scoped container (renders subtree against a data scope)', category: 'layout', canHaveChildren: true },
228
- 'show-user-input': { description: 'Displays previously submitted user input as a list/card view', category: 'forms', canHaveChildren: false },
229
+ 'entry-table': { description: 'Built-in admin CRUD grid over a form\'s records (search/sort/paginate/CSV, add / edit / delete actions)', category: 'forms', canHaveChildren: false },
229
230
  } as const satisfies Record<string, IStyleRegistryEntry>;
230
231
 
231
232
  /**