@selfhelp/shared 1.0.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.
- package/CHANGELOG.md +39 -0
- package/LICENSE +381 -0
- package/README.md +266 -0
- package/dist/common-B96dASgu.d.mts +80 -0
- package/dist/common-B96dASgu.d.ts +80 -0
- package/dist/index-Bg60YTsF.d.mts +1743 -0
- package/dist/index-DEOVT86P.d.ts +1743 -0
- package/dist/index.d.mts +597 -0
- package/dist/index.d.ts +597 -0
- package/dist/index.js +796 -0
- package/dist/index.mjs +718 -0
- package/dist/registry/index.d.mts +2 -0
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.js +134 -0
- package/dist/registry/index.mjs +105 -0
- package/dist/theme/index.d.mts +63 -0
- package/dist/theme/index.d.ts +63 -0
- package/dist/theme/index.js +202 -0
- package/dist/theme/index.mjs +162 -0
- package/dist/theme/tailwind.d.mts +36 -0
- package/dist/theme/tailwind.d.ts +36 -0
- package/dist/theme/tailwind.js +125 -0
- package/dist/theme/tailwind.mjs +97 -0
- package/package.json +69 -0
- package/src/api/endpoints.ts +58 -0
- package/src/api/index.ts +5 -0
- package/src/assets/index.ts +5 -0
- package/src/assets/resolveAssetUrl.ts +44 -0
- package/src/cms-classes/allow-list.ts +158 -0
- package/src/cms-classes/classify.ts +90 -0
- package/src/cms-classes/index.ts +7 -0
- package/src/cms-classes/remap.ts +44 -0
- package/src/condition/evaluate.ts +121 -0
- package/src/condition/index.ts +5 -0
- package/src/index.ts +25 -0
- package/src/interpolation/index.ts +5 -0
- package/src/interpolation/replaceCalcedValues.ts +27 -0
- package/src/registry/index.ts +37 -0
- package/src/registry/styles.registry.ts +158 -0
- package/src/theme/index.ts +6 -0
- package/src/theme/tailwind.ts +73 -0
- package/src/theme/tokens.ts +177 -0
- package/src/types/api/auth.ts +46 -0
- package/src/types/api/envelope.ts +34 -0
- package/src/types/api/forms.ts +38 -0
- package/src/types/api/index.ts +9 -0
- package/src/types/api/language.ts +12 -0
- package/src/types/api/page.ts +9 -0
- package/src/types/auth.ts +110 -0
- package/src/types/index.ts +17 -0
- package/src/types/mantine/common.ts +142 -0
- package/src/types/pages.ts +107 -0
- package/src/types/styles/auth.ts +165 -0
- package/src/types/styles/base.ts +72 -0
- package/src/types/styles/composite.ts +131 -0
- package/src/types/styles/forms.ts +439 -0
- package/src/types/styles/interactive.ts +165 -0
- package/src/types/styles/layout.ts +184 -0
- package/src/types/styles/media.ts +68 -0
- package/src/types/styles/typography.ts +118 -0
- package/src/types/styles/unknown.ts +220 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/spacing.ts +64 -0
- package/src/utils/transformPageData.ts +93 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* STYLE_REGISTRY — single source of truth for every supported user-facing
|
|
7
|
+
* style. Both the web and mobile renderers import this map and TypeScript
|
|
8
|
+
* forces them to provide an implementation for each key (see
|
|
9
|
+
* `createStyleImplMap` in `index.ts`).
|
|
10
|
+
*
|
|
11
|
+
* Adding a new style:
|
|
12
|
+
* 1. Add the per-style interface in `src/types/styles/<group>.ts`.
|
|
13
|
+
* 2. Extend `TStyle` in `src/types/styles/unknown.ts`.
|
|
14
|
+
* 3. Add the entry below.
|
|
15
|
+
* 4. Both apps will fail to compile until they add an impl.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { TStyleName } from '../types/styles/unknown';
|
|
19
|
+
|
|
20
|
+
export interface IStyleRegistryEntry {
|
|
21
|
+
/** Human description for docs / tooling. */
|
|
22
|
+
description: string;
|
|
23
|
+
/** UX category for grouping in tools / cookbook. */
|
|
24
|
+
category:
|
|
25
|
+
| 'auth'
|
|
26
|
+
| 'layout'
|
|
27
|
+
| 'typography'
|
|
28
|
+
| 'media'
|
|
29
|
+
| 'interactive'
|
|
30
|
+
| 'forms'
|
|
31
|
+
| 'composite';
|
|
32
|
+
/**
|
|
33
|
+
* Whether the style is intended for end-user pages. Mobile renders
|
|
34
|
+
* only `frontendOnly: true` styles. Today every entry below is true;
|
|
35
|
+
* if/when an admin-only style is added it must be marked false.
|
|
36
|
+
*/
|
|
37
|
+
frontendOnly: true;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the style can have child sections (mirrors backend
|
|
40
|
+
* `styles.can_have_children`). Renderers use this to short-circuit
|
|
41
|
+
* children traversal.
|
|
42
|
+
*/
|
|
43
|
+
canHaveChildren: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Single-source registry. Keys here drive `TStyleName` (declared in
|
|
48
|
+
* `types/styles/unknown.ts`); both files must stay in sync.
|
|
49
|
+
*/
|
|
50
|
+
export const STYLE_REGISTRY = {
|
|
51
|
+
// ===== auth =====
|
|
52
|
+
login: { description: 'User login form', category: 'auth', frontendOnly: true, canHaveChildren: false },
|
|
53
|
+
register: { description: 'User registration form', category: 'auth', frontendOnly: true, canHaveChildren: false },
|
|
54
|
+
validate: { description: 'Email/account validation flow', category: 'auth', frontendOnly: true, canHaveChildren: true },
|
|
55
|
+
resetPassword: { description: 'Reset password form', category: 'auth', frontendOnly: true, canHaveChildren: false },
|
|
56
|
+
twoFactorAuth: { description: 'Two-factor auth code form', category: 'auth', frontendOnly: true, canHaveChildren: false },
|
|
57
|
+
profile: { description: 'User profile management', category: 'auth', frontendOnly: true, canHaveChildren: false },
|
|
58
|
+
|
|
59
|
+
// ===== layout =====
|
|
60
|
+
container: { description: 'Mantine Container with responsive max-width', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
61
|
+
box: { description: 'Generic Mantine Box wrapper', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
62
|
+
flex: { description: 'Mantine Flex layout', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
63
|
+
group: { description: 'Mantine Group horizontal layout', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
64
|
+
stack: { description: 'Mantine Stack vertical layout', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
65
|
+
'simple-grid': { description: 'Mantine SimpleGrid', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
66
|
+
grid: { description: 'Mantine Grid', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
67
|
+
'grid-column': { description: 'Mantine Grid.Col', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
68
|
+
space: { description: 'Mantine Space spacer', category: 'layout', frontendOnly: true, canHaveChildren: false },
|
|
69
|
+
divider: { description: 'Mantine Divider', category: 'layout', frontendOnly: true, canHaveChildren: false },
|
|
70
|
+
paper: { description: 'Mantine Paper surface', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
71
|
+
center: { description: 'Mantine Center alignment', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
72
|
+
'scroll-area': { description: 'Mantine ScrollArea', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
73
|
+
card: { description: 'Mantine Card', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
74
|
+
'card-segment': { description: 'Mantine Card.Section', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
75
|
+
'aspect-ratio': { description: 'Mantine AspectRatio wrapper', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
76
|
+
'background-image': { description: 'Mantine BackgroundImage', category: 'layout', frontendOnly: true, canHaveChildren: true },
|
|
77
|
+
|
|
78
|
+
// ===== typography =====
|
|
79
|
+
title: { description: 'Mantine Title', category: 'typography', frontendOnly: true, canHaveChildren: false },
|
|
80
|
+
text: { description: 'Mantine Text', category: 'typography', frontendOnly: true, canHaveChildren: false },
|
|
81
|
+
code: { description: 'Mantine Code (inline / block)', category: 'typography', frontendOnly: true, canHaveChildren: false },
|
|
82
|
+
highlight: { description: 'Mantine Highlight', category: 'typography', frontendOnly: true, canHaveChildren: false },
|
|
83
|
+
blockquote: { description: 'Mantine Blockquote', category: 'typography', frontendOnly: true, canHaveChildren: false },
|
|
84
|
+
'html-tag': { description: 'Generic HTML tag wrapper (web), maps to View on RN', category: 'typography', frontendOnly: true, canHaveChildren: true },
|
|
85
|
+
kbd: { description: 'Mantine Kbd', category: 'typography', frontendOnly: true, canHaveChildren: false },
|
|
86
|
+
typography: { description: 'Mantine Typography wrapper', category: 'typography', frontendOnly: true, canHaveChildren: true },
|
|
87
|
+
fieldset: { description: 'Mantine Fieldset', category: 'typography', frontendOnly: true, canHaveChildren: true },
|
|
88
|
+
spoiler: { description: 'Mantine Spoiler reveal', category: 'typography', frontendOnly: true, canHaveChildren: true },
|
|
89
|
+
|
|
90
|
+
// ===== media =====
|
|
91
|
+
image: { description: 'Mantine Image / RN Image', category: 'media', frontendOnly: true, canHaveChildren: false },
|
|
92
|
+
video: { description: 'HTML5 video / expo-video', category: 'media', frontendOnly: true, canHaveChildren: false },
|
|
93
|
+
audio: { description: 'HTML5 audio / expo-audio', category: 'media', frontendOnly: true, canHaveChildren: false },
|
|
94
|
+
figure: { description: 'Figure with caption', category: 'media', frontendOnly: true, canHaveChildren: true },
|
|
95
|
+
carousel: { description: 'Embla on web, reanimated-carousel on RN', category: 'media', frontendOnly: true, canHaveChildren: true },
|
|
96
|
+
|
|
97
|
+
// ===== interactive =====
|
|
98
|
+
button: { description: 'Mantine Button / HeroUI Button', category: 'interactive', frontendOnly: true, canHaveChildren: false },
|
|
99
|
+
link: { description: 'Anchor / Pressable navigation', category: 'interactive', frontendOnly: true, canHaveChildren: false },
|
|
100
|
+
'action-icon': { description: 'Mantine ActionIcon', category: 'interactive', frontendOnly: true, canHaveChildren: false },
|
|
101
|
+
alert: { description: 'Mantine Alert', category: 'interactive', frontendOnly: true, canHaveChildren: true },
|
|
102
|
+
badge: { description: 'Mantine Badge', category: 'interactive', frontendOnly: true, canHaveChildren: false },
|
|
103
|
+
avatar: { description: 'Mantine Avatar', category: 'interactive', frontendOnly: true, canHaveChildren: false },
|
|
104
|
+
chip: { description: 'Mantine Chip', category: 'interactive', frontendOnly: true, canHaveChildren: false },
|
|
105
|
+
indicator: { description: 'Mantine Indicator dot', category: 'interactive', frontendOnly: true, canHaveChildren: true },
|
|
106
|
+
'theme-icon': { description: 'Mantine ThemeIcon', category: 'interactive', frontendOnly: true, canHaveChildren: false },
|
|
107
|
+
notification: { description: 'Mantine Notification', category: 'interactive', frontendOnly: true, canHaveChildren: false },
|
|
108
|
+
|
|
109
|
+
// ===== forms =====
|
|
110
|
+
'form-log': { description: 'Append-only form (one row per submit)', category: 'forms', frontendOnly: true, canHaveChildren: true },
|
|
111
|
+
'form-record': { description: 'Per-user record form', category: 'forms', frontendOnly: true, canHaveChildren: true },
|
|
112
|
+
input: { description: 'Plain HTML input', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
113
|
+
'text-input': { description: 'Mantine TextInput', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
114
|
+
textarea: { description: 'Mantine Textarea', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
115
|
+
'rich-text-editor': { description: 'Tiptap editor on web; READ-ONLY viewer on mobile v1', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
116
|
+
select: { description: 'HTML select / Mantine Select', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
117
|
+
radio: { description: 'Mantine Radio / RadioGroup', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
118
|
+
checkbox: { description: 'Mantine Checkbox', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
119
|
+
slider: { description: 'Mantine Slider', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
120
|
+
'range-slider': { description: 'Mantine RangeSlider', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
121
|
+
datepicker: { description: 'Mantine DatePicker', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
122
|
+
switch: { description: 'Mantine Switch', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
123
|
+
combobox: { description: 'Mantine Combobox', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
124
|
+
'color-input': { description: 'Mantine ColorInput', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
125
|
+
'color-picker': { description: 'Mantine ColorPicker', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
126
|
+
'file-input': { description: 'Mantine FileInput / DocumentPicker on RN', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
127
|
+
'number-input': { description: 'Mantine NumberInput', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
128
|
+
'segmented-control': { description: 'Mantine SegmentedControl', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
129
|
+
rating: { description: 'Mantine Rating', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
130
|
+
progress: { description: 'Mantine Progress', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
131
|
+
'progress-root': { description: 'Mantine Progress.Root', category: 'forms', frontendOnly: true, canHaveChildren: true },
|
|
132
|
+
'progress-section': { description: 'Mantine Progress.Section', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
133
|
+
|
|
134
|
+
// ===== composite =====
|
|
135
|
+
accordion: { description: 'Mantine Accordion', category: 'composite', frontendOnly: true, canHaveChildren: true },
|
|
136
|
+
'accordion-item': { description: 'Mantine Accordion.Item', category: 'composite', frontendOnly: true, canHaveChildren: true },
|
|
137
|
+
tabs: { description: 'Mantine Tabs', category: 'composite', frontendOnly: true, canHaveChildren: true },
|
|
138
|
+
tab: { description: 'Mantine Tabs.Tab + Tabs.Panel pair', category: 'composite', frontendOnly: true, canHaveChildren: true },
|
|
139
|
+
timeline: { description: 'Mantine Timeline', category: 'composite', frontendOnly: true, canHaveChildren: true },
|
|
140
|
+
list: { description: 'Mantine List', category: 'composite', frontendOnly: true, canHaveChildren: true },
|
|
141
|
+
'list-item': { description: 'Mantine List.Item', category: 'composite', frontendOnly: true, canHaveChildren: true },
|
|
142
|
+
entryList: { description: 'Data-driven list of entries (form-log table)', category: 'composite', frontendOnly: true, canHaveChildren: true },
|
|
143
|
+
entryRecord: { description: 'Single-record container', category: 'composite', frontendOnly: true, canHaveChildren: true },
|
|
144
|
+
entryRecordDelete: { description: 'Inline delete confirmation for an entry', category: 'composite', frontendOnly: true, canHaveChildren: false },
|
|
145
|
+
loop: { description: 'Loop / repeater over backend-provided rows', category: 'composite', frontendOnly: true, canHaveChildren: true },
|
|
146
|
+
} as const satisfies Record<string, IStyleRegistryEntry>;
|
|
147
|
+
|
|
148
|
+
export type TStyleRegistryKey = keyof typeof STYLE_REGISTRY;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Compile-time guard: every key in the registry must be a valid TStyleName,
|
|
152
|
+
* and every TStyleName must be a registry key.
|
|
153
|
+
*/
|
|
154
|
+
export type _AssertRegistryMatchesStyleName = TStyleName extends TStyleRegistryKey
|
|
155
|
+
? TStyleRegistryKey extends TStyleName
|
|
156
|
+
? true
|
|
157
|
+
: never
|
|
158
|
+
: never;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Shared Tailwind preset extended by both the web frontend (Tailwind v4)
|
|
7
|
+
* and the mobile app (Uniwind v4 inside HeroUI Native). Anchors the same
|
|
8
|
+
* scale values that drive `mantine_size`, `mantine_radius`,
|
|
9
|
+
* `mantine_spacing`, and the color palette so a class like `p-md` or
|
|
10
|
+
* `text-blue-6` resolves identically on web and mobile.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { COLOR_SCALES, RADIUS_PX, SPACING_PX, FONT_SIZE_PX, LINE_HEIGHT } from './tokens';
|
|
14
|
+
|
|
15
|
+
const px = (n: number | undefined): string => (n === undefined ? '0px' : `${n}px`);
|
|
16
|
+
|
|
17
|
+
const colorScaleToTailwind = (scale: readonly string[]): Record<string, string> => {
|
|
18
|
+
const out: Record<string, string> = {};
|
|
19
|
+
scale.forEach((value, idx) => {
|
|
20
|
+
out[String(idx)] = value;
|
|
21
|
+
});
|
|
22
|
+
return out;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const colors: Record<string, Record<string, string>> = {};
|
|
26
|
+
for (const [name, scale] of Object.entries(COLOR_SCALES)) {
|
|
27
|
+
colors[name] = colorScaleToTailwind(scale);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const spacing: Record<string, string> = {
|
|
31
|
+
none: px(SPACING_PX.none),
|
|
32
|
+
xs: px(SPACING_PX.xs),
|
|
33
|
+
sm: px(SPACING_PX.sm),
|
|
34
|
+
md: px(SPACING_PX.md),
|
|
35
|
+
lg: px(SPACING_PX.lg),
|
|
36
|
+
xl: px(SPACING_PX.xl),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const borderRadius: Record<string, string> = {
|
|
40
|
+
xs: px(RADIUS_PX.xs),
|
|
41
|
+
sm: px(RADIUS_PX.sm),
|
|
42
|
+
md: px(RADIUS_PX.md),
|
|
43
|
+
lg: px(RADIUS_PX.lg),
|
|
44
|
+
xl: px(RADIUS_PX.xl),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const fontSize: Record<string, [string, { lineHeight: string }]> = {
|
|
48
|
+
xs: [px(FONT_SIZE_PX.xs), { lineHeight: String(LINE_HEIGHT.xs) }],
|
|
49
|
+
sm: [px(FONT_SIZE_PX.sm), { lineHeight: String(LINE_HEIGHT.sm) }],
|
|
50
|
+
md: [px(FONT_SIZE_PX.md), { lineHeight: String(LINE_HEIGHT.md) }],
|
|
51
|
+
lg: [px(FONT_SIZE_PX.lg), { lineHeight: String(LINE_HEIGHT.lg) }],
|
|
52
|
+
xl: [px(FONT_SIZE_PX.xl), { lineHeight: String(LINE_HEIGHT.xl) }],
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Tailwind theme `extend` block. Apps spread this into their own
|
|
57
|
+
* tailwind config (`theme.extend`).
|
|
58
|
+
*/
|
|
59
|
+
export const sharedTailwindExtend = {
|
|
60
|
+
colors,
|
|
61
|
+
spacing,
|
|
62
|
+
borderRadius,
|
|
63
|
+
fontSize,
|
|
64
|
+
} as const;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Convenience preset object that fits both Tailwind v3 and v4 / Uniwind.
|
|
68
|
+
*/
|
|
69
|
+
export const sharedTailwindPreset = {
|
|
70
|
+
theme: {
|
|
71
|
+
extend: sharedTailwindExtend,
|
|
72
|
+
},
|
|
73
|
+
} as const;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Mantine semantic token tables. Both the web Mantine theme and the
|
|
7
|
+
* mobile HeroUI Native theme extend these so a `mantine_size: 'md'` on a
|
|
8
|
+
* section renders identical sizing regardless of platform.
|
|
9
|
+
*
|
|
10
|
+
* Pixel values come straight from Mantine v9 defaults:
|
|
11
|
+
* https://mantine.dev/theming/sizes/
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { TMantineSize } from '../types/mantine/common';
|
|
15
|
+
|
|
16
|
+
/** Canonical spacing tokens (without the `string` escape hatch). */
|
|
17
|
+
export type TCanonicalSpacing = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
18
|
+
export type TCanonicalRadius = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
19
|
+
export type TCanonicalColor =
|
|
20
|
+
| 'gray'
|
|
21
|
+
| 'red'
|
|
22
|
+
| 'pink'
|
|
23
|
+
| 'grape'
|
|
24
|
+
| 'violet'
|
|
25
|
+
| 'indigo'
|
|
26
|
+
| 'blue'
|
|
27
|
+
| 'cyan'
|
|
28
|
+
| 'teal'
|
|
29
|
+
| 'green'
|
|
30
|
+
| 'lime'
|
|
31
|
+
| 'yellow'
|
|
32
|
+
| 'orange'
|
|
33
|
+
| 'dark';
|
|
34
|
+
|
|
35
|
+
/** xs..xl -> font-size px (Mantine `theme.fontSizes`). */
|
|
36
|
+
export const FONT_SIZE_PX: Record<TMantineSize, number> = {
|
|
37
|
+
xs: 12,
|
|
38
|
+
sm: 14,
|
|
39
|
+
md: 16,
|
|
40
|
+
lg: 18,
|
|
41
|
+
xl: 20,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** xs..xl -> line-height. */
|
|
45
|
+
export const LINE_HEIGHT: Record<TMantineSize, number> = {
|
|
46
|
+
xs: 1.4,
|
|
47
|
+
sm: 1.45,
|
|
48
|
+
md: 1.55,
|
|
49
|
+
lg: 1.6,
|
|
50
|
+
xl: 1.65,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** xs..xl -> spacing px (Mantine `theme.spacing`). */
|
|
54
|
+
export const SPACING_PX: Record<TCanonicalSpacing, number> = {
|
|
55
|
+
none: 0,
|
|
56
|
+
xs: 10,
|
|
57
|
+
sm: 12,
|
|
58
|
+
md: 16,
|
|
59
|
+
lg: 20,
|
|
60
|
+
xl: 32,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** Mantine spacing -> Tailwind spacing class suffix. */
|
|
64
|
+
export const SPACING_TO_TAILWIND: Record<TCanonicalSpacing, string> = {
|
|
65
|
+
none: '0',
|
|
66
|
+
xs: '2.5',
|
|
67
|
+
sm: '3',
|
|
68
|
+
md: '4',
|
|
69
|
+
lg: '5',
|
|
70
|
+
xl: '8',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** xs..xl -> border-radius px. */
|
|
74
|
+
export const RADIUS_PX: Record<TCanonicalRadius, number> = {
|
|
75
|
+
xs: 2,
|
|
76
|
+
sm: 4,
|
|
77
|
+
md: 8,
|
|
78
|
+
lg: 16,
|
|
79
|
+
xl: 32,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** Mantine container size -> max-width px. */
|
|
83
|
+
export const CONTAINER_SIZE_PX: Record<TMantineSize, number> = {
|
|
84
|
+
xs: 540,
|
|
85
|
+
sm: 720,
|
|
86
|
+
md: 960,
|
|
87
|
+
lg: 1140,
|
|
88
|
+
xl: 1320,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Mantine palette base colors (color-6 from each scale). Each renderer
|
|
93
|
+
* maps these to its own theme tokens. For HeroUI Native we feed these
|
|
94
|
+
* into the theme builder so `mantine_color: 'blue'` resolves to the
|
|
95
|
+
* same Mantine-blue look on mobile.
|
|
96
|
+
*/
|
|
97
|
+
export const COLOR_PALETTE: Record<TCanonicalColor, string> = {
|
|
98
|
+
gray: '#868e96',
|
|
99
|
+
red: '#fa5252',
|
|
100
|
+
pink: '#e64980',
|
|
101
|
+
grape: '#be4bdb',
|
|
102
|
+
violet: '#7950f2',
|
|
103
|
+
indigo: '#4c6ef5',
|
|
104
|
+
blue: '#228be6',
|
|
105
|
+
cyan: '#15aabf',
|
|
106
|
+
teal: '#12b886',
|
|
107
|
+
green: '#40c057',
|
|
108
|
+
lime: '#82c91e',
|
|
109
|
+
yellow: '#fab005',
|
|
110
|
+
orange: '#fd7e14',
|
|
111
|
+
dark: '#212529',
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Full Mantine color scales (0..9). The renderer can pick a shade
|
|
116
|
+
* (default 6 for `light`/`filled`).
|
|
117
|
+
*/
|
|
118
|
+
export const COLOR_SCALES: Record<TCanonicalColor, readonly string[]> = {
|
|
119
|
+
gray: ['#f8f9fa', '#f1f3f5', '#e9ecef', '#dee2e6', '#ced4da', '#adb5bd', '#868e96', '#495057', '#343a40', '#212529'],
|
|
120
|
+
red: ['#fff5f5', '#ffe3e3', '#ffc9c9', '#ffa8a8', '#ff8787', '#ff6b6b', '#fa5252', '#f03e3e', '#e03131', '#c92a2a'],
|
|
121
|
+
pink: ['#fff0f6', '#ffdeeb', '#fcc2d7', '#faa2c1', '#f783ac', '#f06595', '#e64980', '#d6336c', '#c2255c', '#a61e4d'],
|
|
122
|
+
grape: ['#f8f0fc', '#f3d9fa', '#eebefa', '#e599f7', '#da77f2', '#cc5de8', '#be4bdb', '#ae3ec9', '#9c36b5', '#862e9c'],
|
|
123
|
+
violet: ['#f3f0ff', '#e5dbff', '#d0bfff', '#b197fc', '#9775fa', '#845ef7', '#7950f2', '#7048e8', '#6741d9', '#5f3dc4'],
|
|
124
|
+
indigo: ['#edf2ff', '#dbe4ff', '#bac8ff', '#91a7ff', '#748ffc', '#5c7cfa', '#4c6ef5', '#4263eb', '#3b5bdb', '#364fc7'],
|
|
125
|
+
blue: ['#e7f5ff', '#d0ebff', '#a5d8ff', '#74c0fc', '#4dabf7', '#339af0', '#228be6', '#1c7ed6', '#1971c2', '#1864ab'],
|
|
126
|
+
cyan: ['#e3fafc', '#c5f6fa', '#99e9f2', '#66d9e8', '#3bc9db', '#22b8cf', '#15aabf', '#1098ad', '#0c8599', '#0b7285'],
|
|
127
|
+
teal: ['#e6fcf5', '#c3fae8', '#96f2d7', '#63e6be', '#38d9a9', '#20c997', '#12b886', '#0ca678', '#099268', '#087f5b'],
|
|
128
|
+
green: ['#ebfbee', '#d3f9d8', '#b2f2bb', '#8ce99a', '#69db7c', '#51cf66', '#40c057', '#37b24d', '#2f9e44', '#2b8a3e'],
|
|
129
|
+
lime: ['#f4fce3', '#e9fac8', '#d8f5a2', '#c0eb75', '#a9e34b', '#94d82d', '#82c91e', '#74b816', '#66a80f', '#5c940d'],
|
|
130
|
+
yellow: ['#fff9db', '#fff3bf', '#ffec99', '#ffe066', '#ffd43b', '#fcc419', '#fab005', '#f59f00', '#f08c00', '#e67700'],
|
|
131
|
+
orange: ['#fff4e6', '#ffe8cc', '#ffd8a8', '#ffc078', '#ffa94d', '#ff922b', '#fd7e14', '#f76707', '#e8590c', '#d9480f'],
|
|
132
|
+
dark: ['#c1c2c5', '#a6a7ab', '#909296', '#5c5f66', '#373a40', '#2c2e33', '#25262b', '#1a1b1e', '#141517', '#101113'],
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export interface ISpacingResolved {
|
|
136
|
+
mt?: number | string;
|
|
137
|
+
mb?: number | string;
|
|
138
|
+
ms?: number | string;
|
|
139
|
+
me?: number | string;
|
|
140
|
+
pt?: number | string;
|
|
141
|
+
pb?: number | string;
|
|
142
|
+
ps?: number | string;
|
|
143
|
+
pe?: number | string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Resolve a spacing token (xs..xl/none) to a px value, passing through any non-Mantine string verbatim. */
|
|
147
|
+
export function spacingToPx(token: string | undefined): number | string | undefined {
|
|
148
|
+
if (!token || token === 'none') return undefined;
|
|
149
|
+
if (token in SPACING_PX) return SPACING_PX[token as TCanonicalSpacing];
|
|
150
|
+
return token;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Resolve a Mantine size to a font-size px value, passing through any non-Mantine string verbatim. */
|
|
154
|
+
export function sizeToFontPx(token: string | undefined): number | string | undefined {
|
|
155
|
+
if (!token) return undefined;
|
|
156
|
+
if (token in FONT_SIZE_PX) return FONT_SIZE_PX[token as TMantineSize];
|
|
157
|
+
return token;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** Resolve a Mantine radius to a px value, passing through any non-Mantine string verbatim. */
|
|
161
|
+
export function radiusToPx(token: string | undefined): number | string | undefined {
|
|
162
|
+
if (!token) return undefined;
|
|
163
|
+
if (token in RADIUS_PX) return RADIUS_PX[token as TCanonicalRadius];
|
|
164
|
+
return token;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Resolve a Mantine palette color name + optional shade index to a hex
|
|
169
|
+
* string. Passes raw hex/css color values through unchanged.
|
|
170
|
+
*/
|
|
171
|
+
export function colorToHex(name: string | undefined, shade = 6): string | undefined {
|
|
172
|
+
if (!name) return undefined;
|
|
173
|
+
if (name.startsWith('#') || name.startsWith('rgb') || name.startsWith('hsl')) return name;
|
|
174
|
+
const scale = COLOR_SCALES[name as TCanonicalColor];
|
|
175
|
+
if (!scale) return name;
|
|
176
|
+
return scale[Math.max(0, Math.min(9, shade))];
|
|
177
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { IBaseApiResponse } from './envelope';
|
|
6
|
+
import type { IUserData } from '../auth';
|
|
7
|
+
|
|
8
|
+
export interface ILoginRequest {
|
|
9
|
+
email: string;
|
|
10
|
+
password: string;
|
|
11
|
+
remember?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ITwoFactorVerifyRequest {
|
|
15
|
+
id_users: number;
|
|
16
|
+
code: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface IRefreshRequest {
|
|
20
|
+
refresh_token: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ILoginSuccessData {
|
|
24
|
+
access_token: string;
|
|
25
|
+
refresh_token: string;
|
|
26
|
+
user: IUserData;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ITwoFactorRequiredData {
|
|
30
|
+
requires_2fa: true;
|
|
31
|
+
id_users: number;
|
|
32
|
+
expires_in_seconds?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type ILoginSuccessResponse = IBaseApiResponse<ILoginSuccessData>;
|
|
36
|
+
export type ITwoFactorRequiredResponse = IBaseApiResponse<ITwoFactorRequiredData>;
|
|
37
|
+
export type ITwoFactorVerifySuccessResponse = IBaseApiResponse<ILoginSuccessData>;
|
|
38
|
+
export type ILogoutSuccessResponse = IBaseApiResponse<{ message: string }>;
|
|
39
|
+
export type IRefreshSuccessResponse = IBaseApiResponse<{
|
|
40
|
+
access_token: string;
|
|
41
|
+
refresh_token?: string;
|
|
42
|
+
}>;
|
|
43
|
+
export type ILanguagePreferenceUpdateResponse = IBaseApiResponse<{
|
|
44
|
+
access_token?: string;
|
|
45
|
+
language_id: number;
|
|
46
|
+
}>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Common API envelope returned by the Symfony backend's ApiResponseFormatter.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface IApiMeta {
|
|
10
|
+
version: string;
|
|
11
|
+
timestamp: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type IMeta = IApiMeta;
|
|
15
|
+
|
|
16
|
+
export interface IBaseApiResponse<TData> {
|
|
17
|
+
status: number;
|
|
18
|
+
message: string;
|
|
19
|
+
error: null | string;
|
|
20
|
+
error_type?: string;
|
|
21
|
+
logged_in: boolean;
|
|
22
|
+
meta: IApiMeta;
|
|
23
|
+
data: TData;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface IApiError {
|
|
27
|
+
status: number;
|
|
28
|
+
message: string;
|
|
29
|
+
error: string;
|
|
30
|
+
error_type?: string;
|
|
31
|
+
logged_in?: boolean;
|
|
32
|
+
meta?: IApiMeta;
|
|
33
|
+
data?: unknown;
|
|
34
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { IBaseApiResponse } from './envelope';
|
|
6
|
+
|
|
7
|
+
export interface IFormSubmitRequest {
|
|
8
|
+
section_id: number;
|
|
9
|
+
page_id?: number;
|
|
10
|
+
record_id?: number;
|
|
11
|
+
form_data: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface IFormUpdateRequest {
|
|
15
|
+
section_id: number;
|
|
16
|
+
page_id?: number;
|
|
17
|
+
record_id?: number;
|
|
18
|
+
form_data: Record<string, unknown>;
|
|
19
|
+
update_based_on?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface IFormDeleteRequest {
|
|
23
|
+
record_id: number;
|
|
24
|
+
page_id?: number;
|
|
25
|
+
section_id: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface IFormSubmitData {
|
|
29
|
+
record_id?: number;
|
|
30
|
+
success: boolean;
|
|
31
|
+
redirect_url?: string;
|
|
32
|
+
message?: string;
|
|
33
|
+
field_errors?: Record<string, string>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type IFormSubmitResponse = IBaseApiResponse<IFormSubmitData>;
|
|
37
|
+
export type IFormUpdateResponse = IBaseApiResponse<IFormSubmitData>;
|
|
38
|
+
export type IFormDeleteResponse = IBaseApiResponse<{ success: boolean; message?: string }>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { IBaseApiResponse } from './envelope';
|
|
6
|
+
import type { ILanguagePreference } from '../auth';
|
|
7
|
+
|
|
8
|
+
export interface ILanguageItem extends ILanguagePreference {
|
|
9
|
+
is_default?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type ILanguagesResponse = IBaseApiResponse<ILanguageItem[]>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { IBaseApiResponse } from './envelope';
|
|
6
|
+
import type { IPageContent, IPageItem } from '../pages';
|
|
7
|
+
|
|
8
|
+
export type IGetPageResponse = IBaseApiResponse<{ page: IPageContent }>;
|
|
9
|
+
export type IGetPagesResponse = IBaseApiResponse<IPageItem[]>;
|