@selfhelp/shared 1.8.0 → 1.11.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/{common-B96dASgu.d.mts → common-CJSHQL1E.d.mts} +13 -1
  3. package/dist/{common-B96dASgu.d.ts → common-CJSHQL1E.d.ts} +13 -1
  4. package/dist/index.d.mts +136 -44
  5. package/dist/index.d.ts +136 -44
  6. package/dist/index.js +395 -8
  7. package/dist/index.mjs +371 -8
  8. package/dist/plugin-sdk/index.d.mts +2 -2
  9. package/dist/plugin-sdk/index.d.ts +2 -2
  10. package/dist/plugin-sdk/index.js +10 -1
  11. package/dist/plugin-sdk/index.mjs +10 -1
  12. package/dist/registry/index.d.mts +42 -4
  13. package/dist/registry/index.d.ts +42 -4
  14. package/dist/registry/index.js +56 -3
  15. package/dist/registry/index.mjs +48 -2
  16. package/dist/{styles.registry-ClluRYkN.d.ts → styles.registry-BV1iF7k-.d.ts} +678 -461
  17. package/dist/{styles.registry-nl8uzvMN.d.mts → styles.registry-DkoT-FmN.d.mts} +678 -461
  18. package/dist/theme/index.d.mts +225 -4
  19. package/dist/theme/index.d.ts +225 -4
  20. package/dist/theme/index.js +343 -9
  21. package/dist/theme/index.mjs +325 -8
  22. package/dist/theme/tailwind.d.mts +2 -2
  23. package/dist/theme/tailwind.d.ts +2 -2
  24. package/package.json +1 -1
  25. package/src/registry/__tests__/platform.test.ts +187 -0
  26. package/src/registry/index.ts +73 -0
  27. package/src/registry/styles.registry.ts +60 -0
  28. package/src/theme/__tests__/mantineVariant.test.ts +87 -0
  29. package/src/theme/__tests__/semantic.test.ts +231 -0
  30. package/src/theme/index.ts +2 -0
  31. package/src/theme/mantineVariant.ts +145 -0
  32. package/src/theme/semantic.ts +472 -0
  33. package/src/theme/tailwind.ts +2 -2
  34. package/src/theme/tokens.ts +2 -2
  35. package/src/types/__tests__/mobile-adapters.test.ts +80 -0
  36. package/src/types/index.ts +1 -0
  37. package/src/types/mantine/common.ts +13 -0
  38. package/src/types/mobile-adapters.ts +144 -0
  39. package/src/types/styles/auth.ts +11 -11
  40. package/src/types/styles/base.ts +4 -4
  41. package/src/types/styles/composite.ts +59 -45
  42. package/src/types/styles/error.ts +24 -13
  43. package/src/types/styles/forms.ts +184 -184
  44. package/src/types/styles/interactive.ts +81 -76
  45. package/src/types/styles/layout.ts +103 -85
  46. package/src/types/styles/media.ts +20 -20
  47. package/src/types/styles/typography.ts +39 -39
  48. package/src/types/styles/unknown.ts +20 -2
  49. package/src/utils/spacing.ts +1 -1
@@ -0,0 +1,144 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * Mobile UI adapter contract — the SINGLE public source of the capability
7
+ * shape both mobile tiers implement (mobile rendering plan, sections 8.3 / 9).
8
+ *
9
+ * The public mobile app renders CMS styles through these `Mobile*` capability
10
+ * interfaces only, never directly against a UI library, so the build can swap
11
+ * the implementation behind the `@selfhelp/mobile-pro-ui` specifier:
12
+ * - OSS tier -> the public app's in-repo adapters on open `heroui-native` +
13
+ * React Native primitives.
14
+ * - Pro tier -> the private `@selfhelp/mobile-pro-ui` package built on paid
15
+ * HeroUI Pro components.
16
+ *
17
+ * It lives here (not copied into each consumer) so the public app and the Pro
18
+ * package consume ONE contract and cannot silently drift. This module is
19
+ * type-only: it imports `react` types and the shared semantic scales, and
20
+ * pulls in NO React Native runtime dependency, which is why it belongs in
21
+ * `@selfhelp/shared` rather than a separate contract package (plan 8.3).
22
+ *
23
+ * Props are normalized + renderer-agnostic (driven by the shared semantic
24
+ * mapper in this package), NOT raw library props, so both tiers share one
25
+ * contract.
26
+ */
27
+ import type { ComponentType, ReactNode } from 'react';
28
+ import type { THeroUiButtonVariant, THeroUiSize } from '../theme/semantic';
29
+
30
+ /** Props shared by every adapter (styling + accessibility passthrough). */
31
+ export interface IMobileAdapterBaseProps {
32
+ /** Uniwind/Tailwind class string (from `css_mobile` + spacing). */
33
+ className?: string;
34
+ /** Accessibility label for assistive tech. */
35
+ accessibilityLabel?: string;
36
+ testID?: string;
37
+ }
38
+
39
+ export interface IMobileButtonProps extends IMobileAdapterBaseProps {
40
+ label?: string;
41
+ onPress?: () => void;
42
+ variant?: THeroUiButtonVariant;
43
+ size?: THeroUiSize;
44
+ isDisabled?: boolean;
45
+ isLoading?: boolean;
46
+ isIconOnly?: boolean;
47
+ fullWidth?: boolean;
48
+ children?: ReactNode;
49
+ }
50
+
51
+ export interface IMobileTextProps extends IMobileAdapterBaseProps {
52
+ children?: ReactNode;
53
+ /** Map to a heading level / emphasis; renderer decides exact styling. */
54
+ emphasis?: 'title' | 'body' | 'muted';
55
+ numberOfLines?: number;
56
+ }
57
+
58
+ export interface IMobileContainerProps extends IMobileAdapterBaseProps {
59
+ children?: ReactNode;
60
+ fullWidth?: boolean;
61
+ /** Resolved padding in px (from shared spacing). */
62
+ paddingPx?: number;
63
+ }
64
+
65
+ export interface IMobileCardProps extends IMobileAdapterBaseProps {
66
+ children?: ReactNode;
67
+ /** Resolved corner radius in px (from shared radius). */
68
+ radiusPx?: number;
69
+ }
70
+
71
+ export interface IMobileInputProps extends IMobileAdapterBaseProps {
72
+ value?: string;
73
+ onChangeText?: (next: string) => void;
74
+ placeholder?: string;
75
+ label?: string;
76
+ isDisabled?: boolean;
77
+ isInvalid?: boolean;
78
+ isRequired?: boolean;
79
+ secureTextEntry?: boolean;
80
+ keyboardType?: 'default' | 'email-address' | 'numeric' | 'phone-pad';
81
+ }
82
+
83
+ export interface IMobileTextareaProps extends IMobileAdapterBaseProps {
84
+ value?: string;
85
+ onChangeText?: (next: string) => void;
86
+ placeholder?: string;
87
+ label?: string;
88
+ isDisabled?: boolean;
89
+ isInvalid?: boolean;
90
+ isRequired?: boolean;
91
+ /** Minimum visible rows (maps to RN `numberOfLines`). */
92
+ numberOfLines?: number;
93
+ }
94
+
95
+ export interface IMobileSwitchProps extends IMobileAdapterBaseProps {
96
+ isSelected?: boolean;
97
+ onSelectedChange?: (next: boolean) => void;
98
+ isDisabled?: boolean;
99
+ label?: string;
100
+ }
101
+
102
+ export interface IMobileCheckboxProps extends IMobileAdapterBaseProps {
103
+ isSelected?: boolean;
104
+ onSelectedChange?: (next: boolean) => void;
105
+ isDisabled?: boolean;
106
+ label?: string;
107
+ }
108
+
109
+ export interface IMobileSelectOption {
110
+ value: string;
111
+ label: string;
112
+ }
113
+
114
+ export interface IMobileSelectProps extends IMobileAdapterBaseProps {
115
+ value?: string;
116
+ onValueChange?: (next: string) => void;
117
+ options: readonly IMobileSelectOption[];
118
+ placeholder?: string;
119
+ isDisabled?: boolean;
120
+ }
121
+
122
+ export interface IMobileModalProps extends IMobileAdapterBaseProps {
123
+ isOpen: boolean;
124
+ onClose: () => void;
125
+ title?: string;
126
+ children?: ReactNode;
127
+ }
128
+
129
+ /**
130
+ * The full adapter set every tier must provide. Both the public app's OSS
131
+ * index and the private Pro package satisfy this exact shape.
132
+ */
133
+ export interface IMobileUiAdapters {
134
+ MobileButton: ComponentType<IMobileButtonProps>;
135
+ MobileText: ComponentType<IMobileTextProps>;
136
+ MobileContainer: ComponentType<IMobileContainerProps>;
137
+ MobileCard: ComponentType<IMobileCardProps>;
138
+ MobileInput: ComponentType<IMobileInputProps>;
139
+ MobileTextarea: ComponentType<IMobileTextareaProps>;
140
+ MobileSwitch: ComponentType<IMobileSwitchProps>;
141
+ MobileCheckbox: ComponentType<IMobileCheckboxProps>;
142
+ MobileSelect: ComponentType<IMobileSelectProps>;
143
+ MobileModal: ComponentType<IMobileModalProps>;
144
+ }
@@ -62,17 +62,17 @@ export interface IValidateStyle extends IStyleWithSpacing {
62
62
  label_save?: IContentField<string>;
63
63
  label_update?: IContentField<string>;
64
64
  label_cancel?: IContentField<string>;
65
- mantine_buttons_size?: IContentField<string>;
66
- mantine_buttons_radius?: IContentField<string>;
67
- mantine_buttons_variant?: IContentField<string>;
68
- mantine_buttons_position?: IContentField<string>;
69
- mantine_buttons_order?: IContentField<string>;
70
- mantine_btn_save_color?: IContentField<string>;
71
- mantine_btn_cancel_color?: IContentField<string>;
72
- mantine_card_shadow?: IContentField<string>;
73
- mantine_card_padding?: IContentField<string>;
74
- mantine_radius?: IContentField<TMantineRadius>;
75
- mantine_border?: IContentField<string>;
65
+ web_buttons_size?: IContentField<string>;
66
+ web_buttons_radius?: IContentField<string>;
67
+ web_buttons_variant?: IContentField<string>;
68
+ web_buttons_position?: IContentField<string>;
69
+ web_buttons_order?: IContentField<string>;
70
+ web_btn_save_color?: IContentField<string>;
71
+ web_btn_cancel_color?: IContentField<string>;
72
+ web_card_shadow?: IContentField<string>;
73
+ web_card_padding?: IContentField<string>;
74
+ shared_radius?: IContentField<TMantineRadius>;
75
+ web_border?: IContentField<string>;
76
76
  /** Activation lifecycle status text (shown after the registration email). */
77
77
  loading_title?: IContentField<string>;
78
78
  loading_text?: IContentField<string>;
@@ -65,8 +65,8 @@ export interface IBaseStyle {
65
65
 
66
66
  /** Styles that support the unified spacing field. */
67
67
  export interface IStyleWithSpacing extends IBaseStyle {
68
- /** Legacy / margin-only field still used by many Mantine styles in the DB. */
69
- mantine_spacing_margin?: IContentField<string>;
70
- /** Newer box-model field that supports both margin and padding. */
71
- mantine_spacing_margin_padding?: IContentField<string>;
68
+ /** Legacy / margin-only field still used by many web styles in the DB (web-only; not consolidated into shared_spacing). */
69
+ web_spacing_margin?: IContentField<string>;
70
+ /** Portable box-model spacing (margin + padding). Backend field `shared_spacing` (was `mantine_spacing_margin_padding`). */
71
+ shared_spacing?: IContentField<string>;
72
72
  }
@@ -4,7 +4,6 @@ SPDX-License-Identifier: MPL-2.0
4
4
  */
5
5
  import type { IBaseStyle, IContentField, IStyleWithSpacing } from './base';
6
6
  import type {
7
- TMantineSize,
8
7
  TMantineColor,
9
8
  TMantineRadius,
10
9
  TMantineSpacing,
@@ -12,6 +11,8 @@ import type {
12
11
  TMantineAccordionVariant,
13
12
  TMantineTabsVariant,
14
13
  TMantineTimelineLineVariant,
14
+ TSharedSize,
15
+ TSharedRadius,
15
16
  } from '../mantine/common';
16
17
  import type { TMantineWidth, TMantineHeight } from './layout';
17
18
  import type { TMantineLineClamp } from './typography';
@@ -39,77 +40,90 @@ export type TMantineListCenter = '0' | '1';
39
40
 
40
41
  export interface IAccordionStyle extends IStyleWithSpacing {
41
42
  style_name: 'accordion';
42
- mantine_accordion_variant?: IContentField<TMantineAccordionVariant>;
43
- mantine_accordion_multiple?: IContentField<TMantineAccordionMultiple>;
44
- mantine_accordion_chevron_position?: IContentField<TMantineAccordionChevronPosition>;
45
- mantine_accordion_chevron_size?: IContentField<string>;
46
- mantine_accordion_disable_chevron_rotation?: IContentField<TMantineAccordionDisableChevronRotation>;
47
- mantine_accordion_loop?: IContentField<TMantineAccordionLoop>;
48
- mantine_accordion_transition_duration?: IContentField<string>;
49
- mantine_accordion_default_value?: IContentField<string>;
50
- mantine_radius?: IContentField<TMantineRadius>;
51
- use_mantine_style?: IContentField<string>;
43
+ web_accordion_variant?: IContentField<TMantineAccordionVariant>;
44
+ web_accordion_multiple?: IContentField<TMantineAccordionMultiple>;
45
+ web_accordion_chevron_position?: IContentField<TMantineAccordionChevronPosition>;
46
+ web_accordion_chevron_size?: IContentField<string>;
47
+ web_accordion_disable_chevron_rotation?: IContentField<TMantineAccordionDisableChevronRotation>;
48
+ web_accordion_loop?: IContentField<TMantineAccordionLoop>;
49
+ web_accordion_transition_duration?: IContentField<string>;
50
+ web_accordion_default_value?: IContentField<string>;
51
+ shared_radius?: IContentField<TSharedRadius>;
52
+ use_web_style?: IContentField<string>;
52
53
  }
53
54
 
54
55
  export interface IAccordionItemStyle extends IStyleWithSpacing {
55
56
  style_name: 'accordion-item';
56
- mantine_accordion_item_value?: IContentField<string>;
57
+ web_accordion_item_value?: IContentField<string>;
57
58
  label?: IContentField<string>;
58
- mantine_accordion_item_icon?: IContentField<string>;
59
+ web_accordion_item_icon?: IContentField<string>;
59
60
  disabled?: IContentField<string>;
60
- use_mantine_style?: IContentField<string>;
61
+ use_web_style?: IContentField<string>;
61
62
  }
62
63
 
63
64
  export interface ITabsStyle extends IStyleWithSpacing {
64
65
  style_name: 'tabs';
65
- mantine_tabs_variant?: IContentField<TMantineTabsVariant>;
66
- mantine_tabs_orientation?: IContentField<TMantineOrientation>;
67
- mantine_tabs_radius?: IContentField<TMantineRadius>;
68
- mantine_color?: IContentField<TMantineColor>;
69
- mantine_width?: IContentField<TMantineWidth>;
70
- mantine_height?: IContentField<TMantineHeight>;
71
- use_mantine_style?: IContentField<string>;
66
+ web_tabs_variant?: IContentField<TMantineTabsVariant>;
67
+ web_tabs_orientation?: IContentField<TMantineOrientation>;
68
+ web_tabs_radius?: IContentField<TMantineRadius>;
69
+ web_color?: IContentField<TMantineColor>;
70
+ web_width?: IContentField<TMantineWidth>;
71
+ web_height?: IContentField<TMantineHeight>;
72
+ use_web_style?: IContentField<string>;
72
73
  }
73
74
 
74
75
  export interface ITabStyle extends IBaseStyle {
75
76
  style_name: 'tab';
76
77
  label?: IContentField<string>;
77
- mantine_left_icon?: IContentField<string>;
78
- mantine_right_icon?: IContentField<string>;
79
- mantine_tab_disabled?: IContentField<string>;
80
- mantine_width?: IContentField<TMantineWidth>;
81
- mantine_height?: IContentField<TMantineHeight>;
82
- use_mantine_style?: IContentField<string>;
78
+ web_left_icon?: IContentField<string>;
79
+ web_right_icon?: IContentField<string>;
80
+ web_tab_disabled?: IContentField<string>;
81
+ web_width?: IContentField<TMantineWidth>;
82
+ web_height?: IContentField<TMantineHeight>;
83
+ use_web_style?: IContentField<string>;
83
84
  }
84
85
 
85
86
  export interface ITimelineStyle extends IStyleWithSpacing {
86
87
  style_name: 'timeline';
87
- mantine_timeline_bullet_size?: IContentField<string>;
88
- mantine_timeline_line_width?: IContentField<string>;
89
- mantine_timeline_active?: IContentField<string>;
90
- mantine_timeline_align?: IContentField<TMantineTimelineAlign>;
91
- mantine_timeline_line_variant?: IContentField<TMantineTimelineLineVariant>;
92
- mantine_color?: IContentField<TMantineColor>;
93
- use_mantine_style?: IContentField<string>;
88
+ web_timeline_bullet_size?: IContentField<string>;
89
+ web_timeline_line_width?: IContentField<string>;
90
+ web_timeline_active?: IContentField<string>;
91
+ web_timeline_align?: IContentField<TMantineTimelineAlign>;
92
+ web_timeline_line_variant?: IContentField<TMantineTimelineLineVariant>;
93
+ web_color?: IContentField<TMantineColor>;
94
+ use_web_style?: IContentField<string>;
95
+ }
96
+
97
+ /**
98
+ * A single entry inside a `timeline`. Child-only style; placement is enforced
99
+ * by the backend parent/child relationship rules.
100
+ */
101
+ export interface ITimelineItemStyle extends IBaseStyle {
102
+ style_name: 'timeline-item';
103
+ title?: IContentField<string>;
104
+ web_timeline_item_bullet?: IContentField<string>;
105
+ web_timeline_item_line_variant?: IContentField<TMantineTimelineLineVariant>;
106
+ web_color?: IContentField<TMantineColor>;
107
+ use_web_style?: IContentField<string>;
94
108
  }
95
109
 
96
110
  export interface IListStyle extends IStyleWithSpacing {
97
111
  style_name: 'list';
98
- mantine_list_type?: IContentField<TMantineListType>;
99
- mantine_spacing?: IContentField<TMantineSpacing>;
100
- mantine_size?: IContentField<TMantineSize>;
101
- use_mantine_style?: IContentField<string>;
102
- mantine_list_list_style_type?: IContentField<TMantineListStyleType>;
103
- mantine_list_with_padding?: IContentField<TMantineListWithPadding>;
104
- mantine_list_center?: IContentField<TMantineListCenter>;
105
- mantine_list_icon?: IContentField<string>;
112
+ web_list_type?: IContentField<TMantineListType>;
113
+ web_spacing?: IContentField<TMantineSpacing>;
114
+ shared_size?: IContentField<TSharedSize>;
115
+ use_web_style?: IContentField<string>;
116
+ web_list_list_style_type?: IContentField<TMantineListStyleType>;
117
+ web_list_with_padding?: IContentField<TMantineListWithPadding>;
118
+ web_list_center?: IContentField<TMantineListCenter>;
119
+ web_list_icon?: IContentField<string>;
106
120
  }
107
121
 
108
122
  export interface IListItemStyle extends IStyleWithSpacing {
109
123
  style_name: 'list-item';
110
- mantine_list_item_content?: IContentField<string>;
111
- mantine_list_item_icon?: IContentField<string>;
112
- use_mantine_style?: IContentField<string>;
124
+ web_list_item_content?: IContentField<string>;
125
+ web_list_item_icon?: IContentField<string>;
126
+ use_web_style?: IContentField<string>;
113
127
  }
114
128
 
115
129
  export interface IEntryListStyle extends IBaseStyle {
@@ -2,7 +2,8 @@
2
2
  SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
3
  SPDX-License-Identifier: MPL-2.0
4
4
  */
5
- import type { IContentField, IStyleWithSpacing } from './base';
5
+ import type { IBaseStyle, IContentField, IStyleWithSpacing } from './base';
6
+ import type { TSharedRadius } from '../mantine/common';
6
7
 
7
8
  export interface INoAccessStyle extends IStyleWithSpacing {
8
9
  style_name: 'no-access';
@@ -11,10 +12,10 @@ export interface INoAccessStyle extends IStyleWithSpacing {
11
12
  button_label?: IContentField<string>;
12
13
  login_label?: IContentField<string>;
13
14
  show_login?: IContentField<string>;
14
- mantine_color?: IContentField<string>;
15
- mantine_radius?: IContentField<string>;
16
- mantine_shadow?: IContentField<string>;
17
- mantine_button_variant?: IContentField<string>;
15
+ web_color?: IContentField<string>;
16
+ shared_radius?: IContentField<TSharedRadius>;
17
+ web_shadow?: IContentField<string>;
18
+ web_button_variant?: IContentField<string>;
18
19
  show_icon?: IContentField<string>;
19
20
  }
20
21
 
@@ -24,10 +25,10 @@ export interface INotFoundStyle extends IStyleWithSpacing {
24
25
  message?: IContentField<string>;
25
26
  button_label?: IContentField<string>;
26
27
  login_label?: IContentField<string>;
27
- mantine_color?: IContentField<string>;
28
- mantine_radius?: IContentField<string>;
29
- mantine_shadow?: IContentField<string>;
30
- mantine_button_variant?: IContentField<string>;
28
+ web_color?: IContentField<string>;
29
+ shared_radius?: IContentField<TSharedRadius>;
30
+ web_shadow?: IContentField<string>;
31
+ web_button_variant?: IContentField<string>;
31
32
  show_icon?: IContentField<string>;
32
33
  }
33
34
 
@@ -36,9 +37,19 @@ export interface IMissingStyle extends IStyleWithSpacing {
36
37
  title?: IContentField<string>;
37
38
  message?: IContentField<string>;
38
39
  button_label?: IContentField<string>;
39
- mantine_color?: IContentField<string>;
40
- mantine_radius?: IContentField<string>;
41
- mantine_shadow?: IContentField<string>;
42
- mantine_button_variant?: IContentField<string>;
40
+ web_color?: IContentField<string>;
41
+ shared_radius?: IContentField<TSharedRadius>;
42
+ web_shadow?: IContentField<string>;
43
+ web_button_variant?: IContentField<string>;
43
44
  show_icon?: IContentField<string>;
44
45
  }
46
+
47
+ /**
48
+ * Build/version diagnostic surface. Has no content fields in the catalog.
49
+ * Per the mobile rendering plan (section 5.3) it is a candidate to be marked
50
+ * web-only or removed after a zero-reference check; kept `both` for now to
51
+ * match the backend render-target backfill.
52
+ */
53
+ export interface IVersionStyle extends IBaseStyle {
54
+ style_name: 'version';
55
+ }