@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
@@ -53,6 +53,13 @@ describe('isPreviewBridgeMessage', () => {
53
53
  expect(
54
54
  isPreviewBridgeMessage({ type: PREVIEW_BRIDGE_MESSAGE.NAVIGATE, keyword: null }),
55
55
  ).toBe(true);
56
+ expect(
57
+ isPreviewBridgeMessage({
58
+ type: PREVIEW_BRIDGE_MESSAGE.NAVIGATE,
59
+ keyword: 'team-members-record',
60
+ path: '/team-members/5',
61
+ }),
62
+ ).toBe(true);
56
63
  });
57
64
 
58
65
  it('accepts a shell->frame set-preferences command (theme + locale)', () => {
package/src/types/auth.ts CHANGED
@@ -69,6 +69,10 @@ export const PERMISSIONS = {
69
69
  ADMIN_PAGE_VERSION_PUBLISH: 'admin.page.version.publish',
70
70
  ADMIN_PAGE_VERSION_READ: 'admin.page.version.read',
71
71
  ADMIN_PAGE_VERSION_COMPARE: 'admin.page.version.compare',
72
+ ADMIN_CMS_APP_READ: 'admin.cms_app.read',
73
+ ADMIN_CMS_APP_CREATE: 'admin.cms_app.create',
74
+ ADMIN_CMS_APP_UPDATE: 'admin.cms_app.update',
75
+ ADMIN_CMS_APP_DELETE: 'admin.cms_app.delete',
72
76
  ADMIN_USER_READ: 'admin.user.read',
73
77
  ADMIN_USER_CREATE: 'admin.user.create',
74
78
  ADMIN_USER_UPDATE: 'admin.user.update',
@@ -0,0 +1,74 @@
1
+ /*
2
+ * SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ /**
7
+ * First-class CMS app contract (Host Admin product unit).
8
+ * Mirrors backend CmsAppRole + CmsAppService response shapes.
9
+ */
10
+
11
+ export type TCmsAppRole =
12
+ | 'form'
13
+ | 'cms_list'
14
+ | 'cms_detail'
15
+ | 'public_list'
16
+ | 'public_detail'
17
+ | 'other';
18
+
19
+ export const CMS_APP_ROLES: readonly TCmsAppRole[] = [
20
+ 'form',
21
+ 'cms_list',
22
+ 'cms_detail',
23
+ 'public_list',
24
+ 'public_detail',
25
+ 'other',
26
+ ] as const;
27
+
28
+ export const CMS_APP_PRIMARY_ROLES: readonly TCmsAppRole[] = [
29
+ 'form',
30
+ 'cms_list',
31
+ 'cms_detail',
32
+ 'public_list',
33
+ 'public_detail',
34
+ ] as const;
35
+
36
+ /** Assigned page row inside a CMS app detail payload. */
37
+ export interface ICmsAppPage {
38
+ page_id: number;
39
+ keyword: string;
40
+ url: string | null;
41
+ page_surface: string;
42
+ cms_app_role: TCmsAppRole | null;
43
+ }
44
+
45
+ /** @deprecated Prefer {@link ICmsAppPage} — kept for existing imports. */
46
+ export type ICmsAppAssignedPage = ICmsAppPage;
47
+
48
+ /** List/summary row for GET /admin/cms-apps. */
49
+ export interface ICmsAppSummary {
50
+ id: number;
51
+ name: string;
52
+ slug: string;
53
+ description: string | null;
54
+ page_count: number;
55
+ id_form_section: number | null;
56
+ id_cms_list_page: number | null;
57
+ cms_list_keyword: string | null;
58
+ cms_list_url: string | null;
59
+ id_cms_detail_page: number | null;
60
+ id_public_list_page: number | null;
61
+ public_list_keyword: string | null;
62
+ public_list_url: string | null;
63
+ id_public_detail_page: number | null;
64
+ created_at: string;
65
+ updated_at: string | null;
66
+ }
67
+
68
+ /** Detail payload (summary + assigned pages). Canonical alias: {@link ICmsApp}. */
69
+ export interface ICmsAppDetail extends ICmsAppSummary {
70
+ pages: ICmsAppPage[];
71
+ }
72
+
73
+ /** Canonical CMS app detail contract. */
74
+ export type ICmsApp = ICmsAppDetail;
@@ -14,6 +14,7 @@ export * from './styles/composite';
14
14
  export * from './styles/unknown';
15
15
  export * from './pages';
16
16
  export * from './auth';
17
+ export * from './cms-app';
17
18
  export * from './api';
18
19
  export * from './preview-bridge';
19
20
  export * from './distribution';
@@ -146,6 +146,7 @@ export interface IMobileCheckboxProps extends IMobileAdapterBaseProps {
146
146
  export interface IMobileSelectOption {
147
147
  value: string;
148
148
  label: string;
149
+ disabled?: boolean;
149
150
  }
150
151
 
151
152
  export interface IMobileSelectProps extends IMobileAdapterBaseProps {
@@ -73,6 +73,12 @@ export interface IPageContent {
73
73
  url: string | null;
74
74
  parent_page_id: number | null;
75
75
  is_headless: boolean;
76
+ /**
77
+ * CMS-in-CMS surface: `public` website pages vs `cms` admin-only snippets
78
+ * (entry-table / form). `cms` pages must not render on the public slug route;
79
+ * Host Admin hosts them under `/admin/cms-apps/.../content`.
80
+ */
81
+ page_surface?: 'public' | 'cms';
76
82
  /**
77
83
  * When true, the web frontend renders this page's content inside a modal
78
84
  * overlay (the page title becomes the modal header, with a close button)
@@ -105,6 +105,12 @@ export interface IPreviewNavigatedMessage {
105
105
  keyword: string | null;
106
106
  /** Full in-frame href, for diagnostics / the toolbar URL display. */
107
107
  href: string;
108
+ /**
109
+ * Public CMS path when the frame resolved a parameterized route
110
+ * (`/team-members/5`). The shell re-resolves via `/pages/resolve` so
111
+ * `route_params` stay in sync. Optional for static keyword pages.
112
+ */
113
+ path?: string | null;
108
114
  locale?: string | null;
109
115
  }
110
116
 
@@ -116,6 +122,12 @@ export interface IPreviewNavigatedMessage {
116
122
  export interface IPreviewNavigateCommand {
117
123
  type: typeof PREVIEW_BRIDGE_MESSAGE.NAVIGATE;
118
124
  keyword: string | null;
125
+ /**
126
+ * Full public path when keyword alone is insufficient (parameterized routes
127
+ * such as `/team-members/5`). The mobile frame resolves this via
128
+ * `GET /pages/resolve` instead of routing by keyword only.
129
+ */
130
+ path?: string | null;
119
131
  }
120
132
 
121
133
  /**
@@ -174,10 +186,18 @@ export function isPreviewBridgeMessage(value: unknown): value is TPreviewBridgeM
174
186
  return (
175
187
  (record.source === 'web' || record.source === 'mobile') &&
176
188
  (typeof record.keyword === 'string' || record.keyword === null) &&
177
- typeof record.href === 'string'
189
+ typeof record.href === 'string' &&
190
+ (record.path === undefined ||
191
+ record.path === null ||
192
+ typeof record.path === 'string')
178
193
  );
179
194
  case PREVIEW_BRIDGE_MESSAGE.NAVIGATE:
180
- return typeof record.keyword === 'string' || record.keyword === null;
195
+ return (
196
+ (typeof record.keyword === 'string' || record.keyword === null) &&
197
+ (record.path === undefined ||
198
+ record.path === null ||
199
+ typeof record.path === 'string')
200
+ );
181
201
  case PREVIEW_BRIDGE_MESSAGE.SET_PREFERENCES:
182
202
  return isPreviewPreferences(record.preferences);
183
203
  case PREVIEW_BRIDGE_MESSAGE.PREFERENCES_CHANGED:
@@ -122,14 +122,35 @@ export interface IListItemStyle extends IStyleWithSpacing {
122
122
  export interface IEntryListStyle extends IBaseStyle {
123
123
  style_name: 'entry-list';
124
124
  line_clamp?: IContentField<TMantineLineClamp>;
125
+ data_table?: IContentField<string>;
126
+ own_entries_only?: IContentField<string>;
127
+ filter?: IContentField<string>;
128
+ scope?: IContentField<string>;
129
+ load_as_table?: IContentField<string>;
130
+ selected_columns?: IContentField<string>;
125
131
  }
126
132
 
127
133
  export interface IEntryRecordStyle extends IBaseStyle {
128
134
  style_name: 'entry-record';
135
+ data_table?: IContentField<string>;
136
+ own_entries_only?: IContentField<string>;
137
+ /**
138
+ * Route parameter carrying the record id (same contract as
139
+ * `entry-record-form.load_record_from`, e.g. `record_id` on
140
+ * `/team-members/{record_id}`). The holder loads that single row.
141
+ */
142
+ load_record_from?: IContentField<string>;
143
+ scope?: IContentField<string>;
129
144
  }
130
145
 
131
146
  export interface IEntryRecordDeleteStyle extends IBaseStyle {
132
147
  style_name: 'entry-record-delete';
148
+ /** Delete button text (catalog field; the generic `label` field is not linked to this style). */
149
+ label_delete?: IContentField<string>;
150
+ confirmation_title?: IContentField<string>;
151
+ confirmation_message?: IContentField<string>;
152
+ confirmation_continue?: IContentField<string>;
153
+ confirmation_cancel?: IContentField<string>;
133
154
  }
134
155
 
135
156
  export interface ILoopStyle extends IBaseStyle {
@@ -23,7 +23,7 @@ export type TMobileSelectPresentation = 'bottom-sheet' | 'dialog' | 'popover';
23
23
  export type TMobileFieldVariant = 'primary' | 'secondary';
24
24
 
25
25
  export interface IFormStyle extends IStyleWithSpacing {
26
- style_name: 'form-log' | 'form-record';
26
+ style_name: 'form-log' | 'form-record' | 'entry-record-form';
27
27
  /** Optional auto-styled heading rendered above the form when set. */
28
28
  title?: IContentField<string>;
29
29
  /** Optional sub-heading rendered below the title when set. */
@@ -69,8 +69,30 @@ export interface IFormLogStyle extends IFormStyle {
69
69
 
70
70
  export interface IFormRecordStyle extends IFormStyle {
71
71
  style_name: 'form-record';
72
+ /** Human-readable table name slug (runtime table is owned by section id). */
73
+ name?: IContentField<string>;
74
+ btn_update_label?: IContentField<string>;
75
+ btn_update_color?: IContentField<string>;
76
+ /**
77
+ * '1' (default): the form only ever loads/updates the user's own records.
78
+ * '0': shared editing — foreign records can be loaded/updated by users
79
+ * holding UPDATE data access on the form's table (admins always pass).
80
+ */
81
+ own_entries_only?: IContentField<string>;
82
+ }
83
+
84
+ export interface IEntryRecordFormStyle extends IFormStyle {
85
+ style_name: 'entry-record-form';
72
86
  btn_update_label?: IContentField<string>;
73
87
  btn_update_color?: IContentField<string>;
88
+ /** Numeric data_tables.id or empty to use this section's owned table. */
89
+ data_table?: IContentField<string>;
90
+ /**
91
+ * Route parameter carrying the record id (e.g. record_id on /cms/team/{record_id}).
92
+ * When present the form loads that record; when absent the form stays empty (create).
93
+ */
94
+ load_record_from?: IContentField<string>;
95
+ own_entries_only?: IContentField<string>;
74
96
  }
75
97
 
76
98
  export interface IInputStyle extends IBaseStyle {
@@ -164,6 +186,8 @@ export interface ISelectStyle extends IBaseStyle {
164
186
  value?: IContentField<string>;
165
187
  placeholder?: IContentField<string>;
166
188
  options?: IContentField<string>;
189
+ /** Translatable map: `code -> label` for active language. */
190
+ option_labels?: IContentField<string>;
167
191
  is_multiple?: IContentField<string>;
168
192
  max?: IContentField<string>;
169
193
  // RF-17: searchable/clearable are portable behaviour (was the stale
@@ -191,6 +215,8 @@ export interface IRadioStyle extends IStyleWithSpacing {
191
215
  size?: IContentField<TSharedSize>;
192
216
  color?: IContentField<TMantineColor>;
193
217
  radio_options?: IContentField<string>;
218
+ /** Translatable map: `code -> label` for active language. */
219
+ option_labels?: IContentField<string>;
194
220
  web_radio_label_position?: IContentField<string>;
195
221
  web_radio_variant?: IContentField<string>;
196
222
  web_radio_card?: IContentField<string>;
@@ -317,6 +343,8 @@ export interface IComboboxStyle extends IStyleWithSpacing {
317
343
  style_name: 'combobox';
318
344
  placeholder?: IContentField<string>;
319
345
  combobox_options?: IContentField<string>;
346
+ /** Translatable map: `code -> label` for active language. */
347
+ option_labels?: IContentField<string>;
320
348
  disabled?: IContentField<string>; label?: IContentField<string>;
321
349
  description?: IContentField<string>;
322
350
  name?: IContentField<string>;
@@ -415,6 +443,8 @@ export interface INumberInputStyle extends IStyleWithSpacing {
415
443
  export interface ISegmentedControlStyle extends IStyleWithSpacing {
416
444
  style_name: 'segmented-control';
417
445
  segmented_control_data?: IContentField<string>;
446
+ /** Translatable map: `code -> label` for active language. */
447
+ option_labels?: IContentField<string>;
418
448
  orientation?: IContentField<string>;
419
449
  size?: IContentField<TSharedSize>;
420
450
  radius?: IContentField<TSharedRadius>;
@@ -472,15 +502,24 @@ export interface IProgressSectionStyle extends IBaseStyle {
472
502
  tooltip_label?: IContentField<string>;
473
503
  web_tooltip_position?: IContentField<string>;}
474
504
 
475
- export interface IShowUserInputEntry {
505
+ export interface IEntryTableEntry {
476
506
  record_id: number;
477
507
  id_users: number;
508
+ /** Per-row delete permission (backend rule `canDeleteOwnedRecord`). */
478
509
  _can_delete?: boolean;
510
+ /** Per-row edit permission (backend rule `canUpdateOwnedRecord`). */
511
+ _can_edit?: boolean;
479
512
  [key: string]: unknown;
480
513
  }
481
514
 
482
- export interface IShowUserInputStyle extends IBaseStyle {
483
- style_name: 'show-user-input';
515
+ /**
516
+ * The built-in admin CRUD grid (renamed from `show-user-input` in the
517
+ * CMS-in-CMS polish wave): a data table over a form's records with search /
518
+ * sort / pagination / CSV, an "Add new" button, a per-row edit action and a
519
+ * permission-gated per-row delete.
520
+ */
521
+ export interface IEntryTableStyle extends IBaseStyle {
522
+ style_name: 'entry-table';
484
523
  /** Optional auto-styled heading rendered above the entries when set. */
485
524
  title?: IContentField<string>;
486
525
  /** Message shown when there are no entries to display (default "No entries found."). */
@@ -498,20 +537,28 @@ export interface IShowUserInputStyle extends IBaseStyle {
498
537
  csv_export?: IContentField<string>;
499
538
  delete_entry?: IContentField<string>;
500
539
  fields_map?: IContentField<string>;
540
+ /** Per-language header labels keyed by field_key. */
541
+ fields_map_labels?: IContentField<string>;
501
542
  /**
502
543
  * Optional URL of a create form. When set, the web table shows an "Add new"
503
544
  * button above it (e.g. opens the create form modal). Web-only.
504
545
  */
505
546
  add_url?: IContentField<string>;
506
547
  /**
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.
548
+ * Optional URL template for opening a row's edit form (e.g.
549
+ * `/cms/team/{record_id}`). When set, each row with `_can_edit` gets an
550
+ * edit action with the single-brace `{record_id}` placeholder substituted
551
+ * by the renderer at click time. Web-only.
511
552
  */
512
553
  edit_url?: IContentField<string>;
513
554
  delete_modal_title?: IContentField<string>;
514
555
  delete_modal_body?: IContentField<string>;
556
+ /**
557
+ * When `1`, the web table shows a language selector above the grid and
558
+ * reloads translatable cell values for the chosen locale (CMS app lists).
559
+ * Default off.
560
+ */
561
+ show_language_preview?: IContentField<string>;
515
562
  spacing?: IContentField<string>;
516
563
  web_table_striped?: IContentField<string>;
517
564
  web_table_highlight_on_hover?: IContentField<string>;
@@ -521,10 +568,10 @@ export interface IShowUserInputStyle extends IBaseStyle {
521
568
  web_table_sticky_header?: IContentField<string>;
522
569
  web_table_caption_side?: IContentField<string>;
523
570
  /**
524
- * show-user-input rows, each keyed by the immutable data-column `field_key`
571
+ * entry-table rows, each keyed by the immutable data-column `field_key`
525
572
  * (issue #56 v2). Header labels come from {@link field_labels}, not the keys.
526
573
  */
527
- entries?: IShowUserInputEntry[];
574
+ entries?: IEntryTableEntry[];
528
575
  /**
529
576
  * Header map `field_key => display_name` for {@link entries} (issue #56 v2).
530
577
  * Lets the table show the human column label while rows stay keyed by the
@@ -177,6 +177,6 @@ export interface INotificationStyle extends IStyleWithSpacing {
177
177
  radius?: IContentField<TSharedRadius>;}
178
178
 
179
179
  // NOTE: `fab-button` and `biometric-login-button` are deferred (mobile rendering
180
- // plan, milestone-one scope). They are NOT part of the established 90-style
180
+ // plan, milestone-one scope). They are NOT part of the established 91-style
181
181
  // catalog and were removed from the registry, union and interfaces. Reintroduce
182
182
  // only with a concrete CMS authoring use case, fields, render target, and tests.
@@ -87,7 +87,7 @@ import type {
87
87
  IProgressStyle,
88
88
  IProgressRootStyle,
89
89
  IProgressSectionStyle,
90
- IShowUserInputStyle,
90
+ IEntryTableStyle,
91
91
  } from './forms';
92
92
  import type {
93
93
  IAccordionStyle,
@@ -208,7 +208,7 @@ export type TStyle =
208
208
  | IVersionStyle
209
209
  | IRefContainerStyle
210
210
  | IDataContainerStyle
211
- | IShowUserInputStyle;
211
+ | IEntryTableStyle;
212
212
 
213
213
  /**
214
214
  * Discriminator — name of every supported style. Derived from the