@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.
Files changed (64) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENSE +381 -0
  3. package/README.md +266 -0
  4. package/dist/common-B96dASgu.d.mts +80 -0
  5. package/dist/common-B96dASgu.d.ts +80 -0
  6. package/dist/index-Bg60YTsF.d.mts +1743 -0
  7. package/dist/index-DEOVT86P.d.ts +1743 -0
  8. package/dist/index.d.mts +597 -0
  9. package/dist/index.d.ts +597 -0
  10. package/dist/index.js +796 -0
  11. package/dist/index.mjs +718 -0
  12. package/dist/registry/index.d.mts +2 -0
  13. package/dist/registry/index.d.ts +2 -0
  14. package/dist/registry/index.js +134 -0
  15. package/dist/registry/index.mjs +105 -0
  16. package/dist/theme/index.d.mts +63 -0
  17. package/dist/theme/index.d.ts +63 -0
  18. package/dist/theme/index.js +202 -0
  19. package/dist/theme/index.mjs +162 -0
  20. package/dist/theme/tailwind.d.mts +36 -0
  21. package/dist/theme/tailwind.d.ts +36 -0
  22. package/dist/theme/tailwind.js +125 -0
  23. package/dist/theme/tailwind.mjs +97 -0
  24. package/package.json +69 -0
  25. package/src/api/endpoints.ts +58 -0
  26. package/src/api/index.ts +5 -0
  27. package/src/assets/index.ts +5 -0
  28. package/src/assets/resolveAssetUrl.ts +44 -0
  29. package/src/cms-classes/allow-list.ts +158 -0
  30. package/src/cms-classes/classify.ts +90 -0
  31. package/src/cms-classes/index.ts +7 -0
  32. package/src/cms-classes/remap.ts +44 -0
  33. package/src/condition/evaluate.ts +121 -0
  34. package/src/condition/index.ts +5 -0
  35. package/src/index.ts +25 -0
  36. package/src/interpolation/index.ts +5 -0
  37. package/src/interpolation/replaceCalcedValues.ts +27 -0
  38. package/src/registry/index.ts +37 -0
  39. package/src/registry/styles.registry.ts +158 -0
  40. package/src/theme/index.ts +6 -0
  41. package/src/theme/tailwind.ts +73 -0
  42. package/src/theme/tokens.ts +177 -0
  43. package/src/types/api/auth.ts +46 -0
  44. package/src/types/api/envelope.ts +34 -0
  45. package/src/types/api/forms.ts +38 -0
  46. package/src/types/api/index.ts +9 -0
  47. package/src/types/api/language.ts +12 -0
  48. package/src/types/api/page.ts +9 -0
  49. package/src/types/auth.ts +110 -0
  50. package/src/types/index.ts +17 -0
  51. package/src/types/mantine/common.ts +142 -0
  52. package/src/types/pages.ts +107 -0
  53. package/src/types/styles/auth.ts +165 -0
  54. package/src/types/styles/base.ts +72 -0
  55. package/src/types/styles/composite.ts +131 -0
  56. package/src/types/styles/forms.ts +439 -0
  57. package/src/types/styles/interactive.ts +165 -0
  58. package/src/types/styles/layout.ts +184 -0
  59. package/src/types/styles/media.ts +68 -0
  60. package/src/types/styles/typography.ts +118 -0
  61. package/src/types/styles/unknown.ts +220 -0
  62. package/src/utils/index.ts +6 -0
  63. package/src/utils/spacing.ts +64 -0
  64. package/src/utils/transformPageData.ts +93 -0
@@ -0,0 +1,597 @@
1
+ import { T as TStyleName, I as IContentField } from './index-Bg60YTsF.mjs';
2
+ export { a as IAccordionItemStyle, b as IAccordionStyle, c as IActionIconStyle, d as IAlertStyle, e as IAspectRatioStyle, f as IAudioStyle, g as IAvatarStyle, h as IBackgroundImageStyle, i as IBadgeStyle, j as IBaseStyle, k as IBlockquoteStyle, l as IBoxStyle, m as IButtonStyle, n as ICardSegmentStyle, o as ICardStyle, p as ICarouselStyle, q as ICenterStyle, r as ICheckboxStyle, s as IChipStyle, t as ICodeStyle, u as IColorInputStyle, v as IColorPickerStyle, w as IComboboxStyle, x as IContainerStyle, y as IDatePickerStyle, z as IDividerStyle, A as IEntryListStyle, B as IEntryRecordDeleteStyle, C as IEntryRecordStyle, D as IFieldsetStyle, E as IFigureStyle, F as IFileInputStyle, G as IFlexStyle, H as IFormLogStyle, J as IFormRecordStyle, K as IFormStyle, L as IGridColumnStyle, M as IGridStyle, N as IGroupStyle, O as IHighlightStyle, P as IHtmlTagStyle, Q as IImageStyle, R as IIndicatorStyle, S as IInputStyle, U as IKbdStyle, V as ILinkStyle, W as IListItemStyle, X as IListStyle, Y as ILoginStyle, Z as ILoopStyle, _ as INotificationStyle, $ as INumberInputStyle, a0 as IPaperStyle, a1 as IProfileStyle, a2 as IProgressRootStyle, a3 as IProgressSectionStyle, a4 as IProgressStyle, a5 as IRadioStyle, a6 as IRangeSliderStyle, a7 as IRatingStyle, a8 as IRegisterStyle, a9 as IResetPasswordStyle, aa as IRichTextEditorStyle, ab as IScrollAreaStyle, ac as ISegmentedControlStyle, ad as ISelectStyle, ae as ISimpleGridStyle, af as ISliderStyle, ag as ISpaceStyle, ah as ISpoilerStyle, ai as IStackStyle, aj as IStyleRegistryEntry, ak as IStyleWithSpacing, al as ISwitchStyle, am as ITabStyle, an as ITabsStyle, ao as ITextInputStyle, ap as ITextStyle, aq as ITextareaStyle, ar as IThemeIconStyle, as as ITimelineStyle, at as ITitleStyle, au as ITwoFactorAuthStyle, av as ITypographyStyle, aw as IUnknownStyle, ax as IValidateStyle, ay as IVideoStyle, az as STYLE_REGISTRY, aA as TMantineAccordionChevronPosition, aB as TMantineAccordionDisableChevronRotation, aC as TMantineAccordionLoop, aD as TMantineAccordionMultiple, aE as TMantineBorder, aF as TMantineCardShadow, aG as TMantineCheckboxLabelPosition, aH as TMantineCols, aI as TMantineDividerVariant, aJ as TMantineGap, aK as TMantineGridOffset, aL as TMantineGridOrder, aM as TMantineHeight, aN as TMantineIconSize, aO as TMantineImageFit, aP as TMantineLineClamp, aQ as TMantineListCenter, aR as TMantineListStyleType, aS as TMantineListType, aT as TMantineListWithPadding, aU as TMantinePaperShadow, aV as TMantineProgressTransition, aW as TMantineScrollAreaSize, aX as TMantineScrollAreaType, aY as TMantineTextAlign, aZ as TMantineTextDecoration, a_ as TMantineTextFontStyle, a$ as TMantineTextFontWeight, b0 as TMantineTextInherit, b1 as TMantineTextInputVariant, b2 as TMantineTextSpan, b3 as TMantineTextTransform, b4 as TMantineTextTruncate, b5 as TMantineTextVariant, b6 as TMantineTextareaAutosize, b7 as TMantineTextareaResize, b8 as TMantineTextareaVariant, b9 as TMantineTimelineAlign, ba as TMantineTitleLineClamp, bb as TMantineTitleTextWrap, bc as TMantineTranslatable, bd as TMantineUseInputWrapper, be as TMantineWidth, bf as TStyle, bg as TStyleImplMap, bh as TStyleRegistryKey, bi as _AssertRegistryMatchesStyleName, bj as getRegistryEntry, bk as isKnownStyleName } from './index-Bg60YTsF.mjs';
3
+ export { s as TMantineAccordionVariant, v as TMantineActionIconLoading, d as TMantineAlign, w as TMantineAllowNextClicks, x as TMantineAllowStepClick, y as TMantineAspectRatio, z as TMantineAutoContrast, o as TMantineAvatarVariant, n as TMantineBadgeVariant, A as TMantineBlock, B as TMantineCenterInline, C as TMantineChecked, D as TMantineChipChecked, E as TMantineChipMultiple, p as TMantineChipVariant, F as TMantineClampBehavior, G as TMantineCodeBlock, i as TMantineColor, H as TMantineColorFormat, I as TMantineColorInputSwatches, J as TMantineColorPickerSwatches, K as TMantineColorPickerSwatchesPerRow, L as TMantineCompact, M as TMantineContainerFluid, e as TMantineDirection, N as TMantineDisabled, k as TMantineFieldsetVariant, O as TMantineFileAccept, P as TMantineFileInputMultiple, Q as TMantineFluid, R as TMantineFullWidth, S as TMantineGridGrow, U as TMantineGridOverflow, g as TMantineGridSpan, V as TMantineGroupGrow, W as TMantineGroupWrap, X as TMantineGrow, Y as TMantineHighlight, q as TMantineIndicatorPosition, Z as TMantineInline, _ as TMantineIsLink, c as TMantineJustify, $ as TMantineKbdSize, a0 as TMantineLoading, a1 as TMantineMultiple, a2 as TMantineNotificationWithCloseButton, a3 as TMantineNumberInputDecimalScale, a4 as TMantineOpenInNewTab, h as TMantineOrientation, a5 as TMantineProcessing, T as TMantineRadius, a6 as TMantineRangeSliderMarks, a7 as TMantineRatingCount, a8 as TMantineRatingFractions, a9 as TMantineRatingReadonly, aa as TMantineReadonly, a as TMantineSize, ab as TMantineSpaceHorizontal, b as TMantineSpacing, l as TMantineSpoilerMaxHeight, ac as TMantineSwatches, ad as TMantineTabDisabled, t as TMantineTabsVariant, r as TMantineThemeIconVariant, u as TMantineTimelineLineVariant, j as TMantineTitleOrder, ae as TMantineUseMantineStyle, m as TMantineVariant, af as TMantineWithCloseButton, ag as TMantineWithIcon, f as TMantineWrap } from './common-B96dASgu.mjs';
4
+ export { COLOR_PALETTE, COLOR_SCALES, CONTAINER_SIZE_PX, FONT_SIZE_PX, ISpacingResolved, LINE_HEIGHT, RADIUS_PX, SPACING_PX, SPACING_TO_TAILWIND, TCanonicalColor, TCanonicalRadius, TCanonicalSpacing, colorToHex, radiusToPx, sizeToFontPx, spacingToPx } from './theme/index.mjs';
5
+ export { sharedTailwindExtend, sharedTailwindPreset } from './theme/tailwind.mjs';
6
+
7
+ /**
8
+ * Comprehensive page type system, single source of truth for both apps.
9
+ */
10
+ interface IBasePageSection {
11
+ id: number;
12
+ section_name: string;
13
+ id_styles: number;
14
+ style_name: TStyleName;
15
+ position: number;
16
+ level: number | {
17
+ content: string;
18
+ meta: string | null;
19
+ };
20
+ path: string;
21
+ children: IBasePageSection[];
22
+ }
23
+ interface IPageSectionWithFields extends IBasePageSection {
24
+ can_have_children: number | null;
25
+ condition: string | null;
26
+ css: string | null;
27
+ css_mobile: string | null;
28
+ debug: number | null;
29
+ data_config: string | number | null;
30
+ section_data: unknown[];
31
+ fields: Record<string, IContentField<unknown>>;
32
+ children: IPageSectionWithFields[];
33
+ }
34
+ interface IBasePageInfo {
35
+ id: number;
36
+ keyword: string;
37
+ url: string | null;
38
+ parent_page_id: number | null;
39
+ is_headless: boolean;
40
+ navPosition: number | null;
41
+ footerPosition: number | null;
42
+ is_system?: boolean;
43
+ }
44
+ interface IPageAccessTypeInfo {
45
+ id: number;
46
+ typeCode: string;
47
+ lookupCode: string;
48
+ lookupValue: string;
49
+ lookupDescription: string | null;
50
+ }
51
+ interface IPageItem extends IBasePageInfo {
52
+ id_users?: number;
53
+ id_pages?: number;
54
+ acl_select?: 0 | 1;
55
+ acl_insert?: 0 | 1;
56
+ acl_update?: 0 | 1;
57
+ acl_delete?: 0 | 1;
58
+ id_type?: number;
59
+ id_pageAccessTypes?: number;
60
+ title?: string | null;
61
+ description?: string | null;
62
+ children?: IPageItem[];
63
+ }
64
+ interface IPageContent {
65
+ id: number;
66
+ keyword: string;
67
+ url: string | null;
68
+ parent_page_id: number | null;
69
+ is_headless: boolean;
70
+ nav_position: number | null;
71
+ footer_position: number | null;
72
+ title?: string | null;
73
+ description?: string | null;
74
+ sections: IPageSectionWithFields[];
75
+ }
76
+ interface IPageFieldTranslation {
77
+ language_id: number;
78
+ language_code: string;
79
+ content: string;
80
+ }
81
+ interface IPageField {
82
+ id: number;
83
+ name: string;
84
+ title: string | null;
85
+ type: string;
86
+ default_value: string | null;
87
+ help: string;
88
+ display: boolean;
89
+ translations: IPageFieldTranslation[];
90
+ config?: unknown;
91
+ }
92
+ interface IPageFieldsData {
93
+ page: unknown;
94
+ fields: IPageField[];
95
+ }
96
+ interface IPageSectionsData {
97
+ page_keyword: string;
98
+ sections: IPageSectionWithFields[];
99
+ }
100
+
101
+ /**
102
+ * Auth + permission types shared by both apps.
103
+ */
104
+ interface ILanguagePreference {
105
+ id: number;
106
+ locale: string;
107
+ language: string;
108
+ csvSeparator?: string;
109
+ }
110
+ type ILanguage = ILanguagePreference;
111
+ interface IUserData {
112
+ id: number;
113
+ email: string | null;
114
+ user_name: string | null;
115
+ name: string | null;
116
+ last_login: string | null;
117
+ created: string | null;
118
+ timezone_id: number | null;
119
+ timezone: string | null;
120
+ blocked: boolean;
121
+ user_type: string | null;
122
+ language: ILanguagePreference | null;
123
+ languages?: ILanguagePreference[];
124
+ permissions?: string[];
125
+ roles?: string[];
126
+ groups?: string[];
127
+ acl_version?: string | number | null;
128
+ }
129
+ interface IJwtPayload {
130
+ sub: number;
131
+ email?: string;
132
+ iat: number;
133
+ exp: number;
134
+ permissions?: string[];
135
+ roles?: string[];
136
+ }
137
+ interface IUserDataResponse {
138
+ status: number;
139
+ message: string;
140
+ error: null | string;
141
+ logged_in: boolean;
142
+ meta: {
143
+ version: string;
144
+ timestamp: string;
145
+ };
146
+ data: IUserData | null;
147
+ }
148
+ /**
149
+ * Permission constants. The full list lives in the backend; these are
150
+ * the most commonly checked client-side. Add to this list as new
151
+ * permissions are introduced.
152
+ */
153
+ declare const PERMISSIONS: {
154
+ readonly ADMIN_ACCESS: "admin.access";
155
+ readonly ADMIN_PAGE_READ: "admin.page.read";
156
+ readonly ADMIN_PAGE_CREATE: "admin.page.create";
157
+ readonly ADMIN_PAGE_UPDATE: "admin.page.update";
158
+ readonly ADMIN_PAGE_DELETE: "admin.page.delete";
159
+ readonly ADMIN_PAGE_EXPORT: "admin.page.export";
160
+ readonly ADMIN_PAGE_VERSION_PUBLISH: "admin.page.version.publish";
161
+ readonly ADMIN_PAGE_VERSION_READ: "admin.page.version.read";
162
+ readonly ADMIN_PAGE_VERSION_COMPARE: "admin.page.version.compare";
163
+ readonly ADMIN_USER_READ: "admin.user.read";
164
+ readonly ADMIN_USER_CREATE: "admin.user.create";
165
+ readonly ADMIN_USER_UPDATE: "admin.user.update";
166
+ readonly ADMIN_USER_DELETE: "admin.user.delete";
167
+ readonly ADMIN_USER_BLOCK: "admin.user.block";
168
+ readonly ADMIN_USER_IMPERSONATE: "admin.user.impersonate";
169
+ readonly ADMIN_GROUP_READ: "admin.group.read";
170
+ readonly ADMIN_GROUP_CREATE: "admin.group.create";
171
+ readonly ADMIN_GROUP_UPDATE: "admin.group.update";
172
+ readonly ADMIN_GROUP_DELETE: "admin.group.delete";
173
+ readonly ADMIN_GROUP_ACL: "admin.group.acl";
174
+ readonly ADMIN_ROLE_READ: "admin.role.read";
175
+ readonly ADMIN_ROLE_CREATE: "admin.role.create";
176
+ readonly ADMIN_ROLE_UPDATE: "admin.role.update";
177
+ readonly ADMIN_ROLE_DELETE: "admin.role.delete";
178
+ readonly ADMIN_ROLE_PERMISSIONS: "admin.role.permissions";
179
+ readonly ADMIN_PERMISSION_READ: "admin.permission.read";
180
+ readonly ADMIN_ASSET_READ: "admin.asset.read";
181
+ readonly ADMIN_ASSET_CREATE: "admin.asset.create";
182
+ readonly ADMIN_ASSET_DELETE: "admin.asset.delete";
183
+ readonly ADMIN_ACTION_READ: "admin.action.read";
184
+ readonly ADMIN_ACTION_UPDATE: "admin.action.update";
185
+ readonly ADMIN_ACTION_DELETE: "admin.action.delete";
186
+ readonly ADMIN_ACTION_TRANSLATION_READ: "admin.action.translation.read";
187
+ readonly ADMIN_DATA_READ: "admin.data.read";
188
+ readonly ADMIN_DATA_DELETE: "admin.data.delete";
189
+ readonly ADMIN_DATA_DELETE_COLUMNS: "admin.data.delete_columns";
190
+ readonly ADMIN_SCHEDULED_JOB_READ: "admin.scheduled_job.read";
191
+ readonly ADMIN_SCHEDULED_JOB_EXECUTE: "admin.scheduled_job.execute";
192
+ readonly ADMIN_SCHEDULED_JOB_DELETE: "admin.scheduled_job.delete";
193
+ readonly ADMIN_SECTION_DELETE: "admin.section.delete";
194
+ readonly ADMIN_SETTINGS: "admin.settings";
195
+ readonly ADMIN_CMS_PREFERENCES_READ: "admin.cms_preferences.read";
196
+ readonly ADMIN_CMS_PREFERENCES_UPDATE: "admin.cms_preferences.update";
197
+ readonly ADMIN_CACHE_READ: "admin.cache.read";
198
+ readonly ADMIN_CACHE_CLEAR: "admin.cache.clear";
199
+ readonly ADMIN_CACHE_MANAGE: "admin.cache.manage";
200
+ readonly ADMIN_AUDIT_VIEW: "admin.audit.view";
201
+ };
202
+ type TPermission = (typeof PERMISSIONS)[keyof typeof PERMISSIONS];
203
+
204
+ /**
205
+ * Common API envelope returned by the Symfony backend's ApiResponseFormatter.
206
+ */
207
+ interface IApiMeta {
208
+ version: string;
209
+ timestamp: string;
210
+ }
211
+ type IMeta = IApiMeta;
212
+ interface IBaseApiResponse<TData> {
213
+ status: number;
214
+ message: string;
215
+ error: null | string;
216
+ error_type?: string;
217
+ logged_in: boolean;
218
+ meta: IApiMeta;
219
+ data: TData;
220
+ }
221
+ interface IApiError {
222
+ status: number;
223
+ message: string;
224
+ error: string;
225
+ error_type?: string;
226
+ logged_in?: boolean;
227
+ meta?: IApiMeta;
228
+ data?: unknown;
229
+ }
230
+
231
+ interface ILoginRequest {
232
+ email: string;
233
+ password: string;
234
+ remember?: boolean;
235
+ }
236
+ interface ITwoFactorVerifyRequest {
237
+ id_users: number;
238
+ code: string;
239
+ }
240
+ interface IRefreshRequest {
241
+ refresh_token: string;
242
+ }
243
+ interface ILoginSuccessData {
244
+ access_token: string;
245
+ refresh_token: string;
246
+ user: IUserData;
247
+ }
248
+ interface ITwoFactorRequiredData {
249
+ requires_2fa: true;
250
+ id_users: number;
251
+ expires_in_seconds?: number;
252
+ }
253
+ type ILoginSuccessResponse = IBaseApiResponse<ILoginSuccessData>;
254
+ type ITwoFactorRequiredResponse = IBaseApiResponse<ITwoFactorRequiredData>;
255
+ type ITwoFactorVerifySuccessResponse = IBaseApiResponse<ILoginSuccessData>;
256
+ type ILogoutSuccessResponse = IBaseApiResponse<{
257
+ message: string;
258
+ }>;
259
+ type IRefreshSuccessResponse = IBaseApiResponse<{
260
+ access_token: string;
261
+ refresh_token?: string;
262
+ }>;
263
+ type ILanguagePreferenceUpdateResponse = IBaseApiResponse<{
264
+ access_token?: string;
265
+ language_id: number;
266
+ }>;
267
+
268
+ interface IFormSubmitRequest {
269
+ section_id: number;
270
+ page_id?: number;
271
+ record_id?: number;
272
+ form_data: Record<string, unknown>;
273
+ }
274
+ interface IFormUpdateRequest {
275
+ section_id: number;
276
+ page_id?: number;
277
+ record_id?: number;
278
+ form_data: Record<string, unknown>;
279
+ update_based_on?: Record<string, unknown>;
280
+ }
281
+ interface IFormDeleteRequest {
282
+ record_id: number;
283
+ page_id?: number;
284
+ section_id: number;
285
+ }
286
+ interface IFormSubmitData {
287
+ record_id?: number;
288
+ success: boolean;
289
+ redirect_url?: string;
290
+ message?: string;
291
+ field_errors?: Record<string, string>;
292
+ }
293
+ type IFormSubmitResponse = IBaseApiResponse<IFormSubmitData>;
294
+ type IFormUpdateResponse = IBaseApiResponse<IFormSubmitData>;
295
+ type IFormDeleteResponse = IBaseApiResponse<{
296
+ success: boolean;
297
+ message?: string;
298
+ }>;
299
+
300
+ interface ILanguageItem extends ILanguagePreference {
301
+ is_default?: boolean;
302
+ }
303
+ type ILanguagesResponse = IBaseApiResponse<ILanguageItem[]>;
304
+
305
+ type IGetPageResponse = IBaseApiResponse<{
306
+ page: IPageContent;
307
+ }>;
308
+ type IGetPagesResponse = IBaseApiResponse<IPageItem[]>;
309
+
310
+ /**
311
+ * Frontend-only subset of /cms-api/v1/* endpoints. The web frontend keeps
312
+ * its admin endpoints local. The mobile app consumes only what's here.
313
+ */
314
+ declare const API_VERSION_PREFIX = "/cms-api/v1";
315
+ declare const ENDPOINTS: {
316
+ readonly AUTH: {
317
+ readonly LOGIN: "/cms-api/v1/auth/login";
318
+ readonly TWO_FACTOR_VERIFY: "/cms-api/v1/auth/two-factor-verify";
319
+ readonly LOGOUT: "/cms-api/v1/auth/logout";
320
+ readonly REFRESH: "/cms-api/v1/auth/refresh-token";
321
+ readonly SET_LANGUAGE: "/cms-api/v1/auth/set-language";
322
+ readonly USER_DATA: "/cms-api/v1/auth/user-data";
323
+ readonly EVENTS: "/cms-api/v1/auth/events";
324
+ };
325
+ readonly USER: {
326
+ readonly UPDATE_USERNAME: "/cms-api/v1/auth/user/username";
327
+ readonly UPDATE_NAME: "/cms-api/v1/auth/user/name";
328
+ readonly UPDATE_PASSWORD: "/cms-api/v1/auth/user/password";
329
+ readonly UPDATE_TIMEZONE: "/cms-api/v1/auth/user/timezone";
330
+ readonly DELETE_ACCOUNT: "/cms-api/v1/auth/user/account";
331
+ readonly VALIDATE_TOKEN: (userId: number, token: string) => string;
332
+ readonly COMPLETE_VALIDATION: (userId: number, token: string) => string;
333
+ };
334
+ readonly PAGES: {
335
+ readonly LIST: "/cms-api/v1/pages";
336
+ readonly LIST_WITH_LANGUAGE: (languageId: number) => string;
337
+ readonly BY_KEYWORD: (keyword: string) => string;
338
+ readonly BY_ID: (pageId: number) => string;
339
+ };
340
+ readonly LANGUAGES: "/cms-api/v1/languages";
341
+ readonly FORMS: {
342
+ readonly SUBMIT: "/cms-api/v1/forms/submit";
343
+ readonly UPDATE: "/cms-api/v1/forms/update";
344
+ readonly DELETE: "/cms-api/v1/forms/delete";
345
+ };
346
+ };
347
+ /** Header set the backend reads to switch page-access mode + condition platform var. */
348
+ declare const HEADER_CLIENT_TYPE = "X-Client-Type";
349
+ declare const CLIENT_TYPE_WEB = "web";
350
+ declare const CLIENT_TYPE_MOBILE = "mobile";
351
+ declare const CLIENT_TYPE_MOBILE_AND_WEB = "mobile_and_web";
352
+ type TClientType = typeof CLIENT_TYPE_WEB | typeof CLIENT_TYPE_MOBILE | typeof CLIENT_TYPE_MOBILE_AND_WEB;
353
+
354
+ /**
355
+ * Mirrors the backend `PageDb::replace_calced_values()` regex:
356
+ *
357
+ * ~{{({{)?(.*?)(}})?}}~s
358
+ *
359
+ * Replaces every `{{name}}` or `{{{{name}}}}` occurrence in the input
360
+ * string with `values[name]`. Unknown placeholders are left intact so
361
+ * editors notice them and so we never accidentally render `undefined`.
362
+ */
363
+ type TCalcedValues = Record<string, string | number | boolean | null | undefined>;
364
+ declare function replaceCalcedValues(input: string | null | undefined, values: TCalcedValues): string;
365
+
366
+ /**
367
+ * Client-side mirror of the backend `ConditionService::evaluateCondition`.
368
+ * Uses `json-logic-js` so the same JSON-Logic expressions evaluated on
369
+ * the server are evaluated identically here.
370
+ *
371
+ * Backend system variables (see ConditionService docblock):
372
+ * - language: ISO locale code, e.g. 'de-CH'
373
+ * - current_date / current_datetime / current_time
374
+ * - page_keyword
375
+ * - platform: 'web' | 'mobile'
376
+ *
377
+ * Anything else passed in `extraVars` is merged on top.
378
+ */
379
+ type TPlatform = 'web' | 'mobile';
380
+ interface IConditionContext {
381
+ platform: TPlatform;
382
+ language?: string;
383
+ page_keyword?: string;
384
+ current_date?: string;
385
+ current_datetime?: string;
386
+ current_time?: string;
387
+ [extraKey: string]: unknown;
388
+ }
389
+ interface IEvaluatedCondition {
390
+ /** Whether the condition allowed the section to render. */
391
+ visible: boolean;
392
+ /** Optional debug payload (only set when `withDebug` is true). */
393
+ debug?: {
394
+ condition: string | null;
395
+ result: boolean;
396
+ variables: Record<string, unknown>;
397
+ error?: string;
398
+ };
399
+ }
400
+ /**
401
+ * Build a default context with current date/time + the platform
402
+ * variable. Pass any extra vars (data-bound section variables, etc).
403
+ */
404
+ declare function buildConditionContext(platform: TPlatform, extraVars?: Record<string, unknown>, now?: Date): IConditionContext;
405
+ /**
406
+ * Evaluate a JSON-Logic condition string. A null/empty/whitespace
407
+ * condition is treated as `visible: true` (no condition).
408
+ */
409
+ declare function evaluateCondition(condition: string | null | undefined, context: IConditionContext, options?: {
410
+ withDebug?: boolean;
411
+ }): IEvaluatedCondition;
412
+
413
+ /**
414
+ * Tailwind classes the CMS may emit in `css_mobile`. Anything outside
415
+ * this list (or the remap table) is dropped on mobile with a dev-only
416
+ * warning. Web doesn't apply this filter (it has full Tailwind +
417
+ * Mantine CSS) — only the mobile renderer does.
418
+ *
419
+ * Patterns we accept: a literal class string, OR a value-pattern using
420
+ * the `IClassPattern` shape (e.g. `mt-{xs,sm,md,lg,xl,1..12}`).
421
+ *
422
+ * Keep this list curated. Adding a class also means making sure Uniwind
423
+ * supports it on Native; if it doesn't, add an entry to `remap.ts` instead.
424
+ */
425
+ interface IClassPattern {
426
+ /** Prefix including the dash, e.g. 'mt-', 'p-', 'text-'. */
427
+ prefix: string;
428
+ /** Allowed value tokens after the prefix. */
429
+ values: readonly string[];
430
+ }
431
+ /** Mantine spacing tokens we anchor on (matches `theme/tokens.ts`). */
432
+ declare const SPACING_VALUES: readonly ["none", "xs", "sm", "md", "lg", "xl"];
433
+ /** Mantine size tokens. */
434
+ declare const SIZE_VALUES: readonly ["xs", "sm", "md", "lg", "xl"];
435
+ /** Mantine palette names. */
436
+ declare const COLOR_NAMES: readonly ["gray", "red", "pink", "grape", "violet", "indigo", "blue", "cyan", "teal", "green", "lime", "yellow", "orange", "dark"];
437
+ /**
438
+ * Allow-listed class patterns. Each entry: `<prefix><value>` is allowed.
439
+ * Atomic literal classes that need no value go in `LITERAL_CLASSES`.
440
+ */
441
+ declare const CLASS_PATTERNS: readonly IClassPattern[];
442
+ /** Atomic literal classes (no value tail) safe to pass through. */
443
+ declare const LITERAL_CLASSES: ReadonlySet<string>;
444
+
445
+ /**
446
+ * Web -> mobile class remap. Some Tailwind classes are valid on web but
447
+ * have no mobile equivalent (or have a different name in Uniwind). This
448
+ * table runs BEFORE the allow-list check.
449
+ *
450
+ * Rules of thumb:
451
+ * - drop classes that don't make sense on mobile (`select-text` is a no-op on RN, `cursor-*`, `hover:*`).
452
+ * - rewrite logical pairs (e.g. mobile prefers `text-center` over `text-left` defaults — leave alone).
453
+ * - alias common Mantine-flavored utility names users may type.
454
+ */
455
+ interface IClassRemap {
456
+ /** Class to rewrite. */
457
+ from: string;
458
+ /** Replacement class, or null to drop the class entirely. */
459
+ to: string | null;
460
+ /** Optional reason surfaced via dev warning. */
461
+ reason?: string;
462
+ }
463
+ declare const CLASS_REMAP: readonly IClassRemap[];
464
+ declare function findRemap(className: string): IClassRemap | undefined;
465
+
466
+ /**
467
+ * `classifyClass()` — one-shot decision for a single CMS class on mobile.
468
+ *
469
+ * Returns a tuple describing what the renderer should do:
470
+ * - 'allow' — pass the class through unchanged
471
+ * - 'remap' — pass the rewritten class through (`to` is the new value)
472
+ * - 'drop' — do not pass the class through; renderer should warn
473
+ * in development.
474
+ */
475
+ type TClassDecision = {
476
+ kind: 'allow';
477
+ className: string;
478
+ } | {
479
+ kind: 'remap';
480
+ from: string;
481
+ to: string;
482
+ reason?: string;
483
+ } | {
484
+ kind: 'drop';
485
+ className: string;
486
+ reason?: string;
487
+ };
488
+ declare function classifyClass(rawClass: string): TClassDecision;
489
+ /**
490
+ * Run classifyClass over a whitespace-separated class string and return
491
+ * the resulting list of allowed classes. The optional `onWarn` callback
492
+ * fires for every drop/remap (use this in dev to spot CMS-side issues).
493
+ */
494
+ declare function classifyClassString(raw: string | null | undefined, onWarn?: (decision: Exclude<TClassDecision, {
495
+ kind: 'allow';
496
+ }>) => void): string[];
497
+
498
+ /**
499
+ * Resolve a CMS-supplied asset URL.
500
+ *
501
+ * resolveAssetUrl('/assets/img/foo.png', 'https://api.example.com')
502
+ * -> 'https://api.example.com/assets/img/foo.png'
503
+ *
504
+ * resolveAssetUrl('https://cdn.example.com/foo.png', 'https://api.example.com')
505
+ * -> 'https://cdn.example.com/foo.png' (already absolute, passes through)
506
+ *
507
+ * resolveAssetUrl('data:image/png;base64,...', 'https://api.example.com')
508
+ * -> 'data:image/png;base64,...' (data URIs pass through)
509
+ *
510
+ * resolveAssetUrl(null, ...) / resolveAssetUrl(undefined, ...) -> ''
511
+ */
512
+ declare function resolveAssetUrl(url: string | null | undefined, baseUrl: string): string;
513
+ /**
514
+ * Resolve potentially nested `sources` arrays (used by video/audio/carousel).
515
+ */
516
+ interface IAssetSource {
517
+ src: string;
518
+ type?: string;
519
+ [extra: string]: unknown;
520
+ }
521
+ declare function resolveAssetSources<T extends IAssetSource>(sources: T[] | undefined, baseUrl: string): T[];
522
+
523
+ /**
524
+ * Parse the unified `mantine_spacing_margin_padding` field. The CMS
525
+ * stores this as a JSON string with optional keys for each side:
526
+ *
527
+ * { "mt": "md", "mb": "lg", "ms": "0", "me": "auto",
528
+ * "pt": "sm", "pb": "sm", "ps": "md", "pe": "md" }
529
+ *
530
+ * Empty/null/missing values are filtered out so downstream renderers
531
+ * can call e.g. `Object.entries(parsed)` without seeing falsy entries.
532
+ */
533
+ interface ISpacingValue {
534
+ mt?: string;
535
+ mb?: string;
536
+ ms?: string;
537
+ me?: string;
538
+ pt?: string;
539
+ pb?: string;
540
+ ps?: string;
541
+ pe?: string;
542
+ }
543
+ declare function parseSpacing(raw: string | null | undefined): ISpacingValue;
544
+ /**
545
+ * Convert spacing values to Tailwind classes via `SPACING_TO_TAILWIND`
546
+ * mapping. Numeric values pass through as `mt-{n}` etc.
547
+ */
548
+ declare function spacingToClasses(spacing: ISpacingValue, spacingToTailwind: Record<string, string>): string[];
549
+
550
+ /**
551
+ * Backend → frontend page-shape transformer.
552
+ *
553
+ * The Symfony repositories project pages with snake_case keys
554
+ * (`nav_position`, `footer_position`, `id_pages`, `parent`) for legacy
555
+ * reasons. Both the web and the mobile app prefer camelCase
556
+ * (`navPosition`, `footerPosition`) at the type-system level. This
557
+ * helper bridges the two so consumers don't have to know about the
558
+ * snake-case wire format.
559
+ *
560
+ * It is the single source of truth for the conversion. Web frontend
561
+ * and mobile both import it from `@selfhelp/shared`.
562
+ */
563
+
564
+ interface IRawPage {
565
+ id?: number;
566
+ id_pages?: number;
567
+ keyword?: string;
568
+ url?: string | null;
569
+ parent?: number | null;
570
+ parent_page_id?: number | null;
571
+ is_headless?: number | boolean | null;
572
+ nav_position?: number | null;
573
+ navPosition?: number | null;
574
+ footer_position?: number | null;
575
+ footerPosition?: number | null;
576
+ is_system?: number | boolean | null;
577
+ is_open_access?: number | boolean | null;
578
+ title?: string | null;
579
+ description?: string | null;
580
+ id_users?: number;
581
+ acl_select?: 0 | 1;
582
+ acl_insert?: 0 | 1;
583
+ acl_update?: 0 | 1;
584
+ acl_delete?: 0 | 1;
585
+ id_type?: number;
586
+ id_pageAccessTypes?: number;
587
+ children?: IRawPage[];
588
+ [key: string]: unknown;
589
+ }
590
+ declare function transformPageData(apiPage: IRawPage): IPageItem;
591
+ /**
592
+ * Same as `transformPageData` but for an array. Convenience helper
593
+ * because almost every consumer fetches a list of pages.
594
+ */
595
+ declare function transformPagesData(pages: IRawPage[] | null | undefined): IPageItem[];
596
+
597
+ export { API_VERSION_PREFIX, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, ENDPOINTS, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IClassPattern, type IClassRemap, type IConditionContext, IContentField, type IEvaluatedCondition, type IFormDeleteRequest, type IFormDeleteResponse, type IFormSubmitData, type IFormSubmitRequest, type IFormSubmitResponse, type IFormUpdateRequest, type IFormUpdateResponse, type IGetPageResponse, type IGetPagesResponse, type IJwtPayload, type ILanguage, type ILanguageItem, type ILanguagePreference, type ILanguagePreferenceUpdateResponse, type ILanguagesResponse, type ILoginRequest, type ILoginSuccessData, type ILoginSuccessResponse, type ILogoutSuccessResponse, type IMeta, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageSectionWithFields, type IPageSectionsData, type IRefreshRequest, type IRefreshSuccessResponse, type ISpacingValue, type ITwoFactorRequiredData, type ITwoFactorRequiredResponse, type ITwoFactorVerifyRequest, type ITwoFactorVerifySuccessResponse, type IUserData, type IUserDataResponse, LITERAL_CLASSES, PERMISSIONS, SIZE_VALUES, SPACING_VALUES, type TCalcedValues, type TClassDecision, type TClientType, type TPermission, type TPlatform, TStyleName, buildConditionContext, classifyClass, classifyClassString, evaluateCondition, findRemap, parseSpacing, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, spacingToClasses, transformPageData, transformPagesData };