@selfhelp/shared 1.20.0 → 1.21.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.
@@ -1,132 +0,0 @@
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
- }