@selfhelp/shared 1.14.12 → 1.14.14

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 CHANGED
@@ -9,6 +9,61 @@ All notable changes to `@selfhelp/shared` will be documented in this file.
9
9
 
10
10
  This project follows semantic versioning.
11
11
 
12
+ ## v1.14.14
13
+
14
+ Cross-platform **inline rich-text** keystone. CMS authors can apply lightweight
15
+ inline formatting (Ctrl+B bold, Ctrl+I italic, Ctrl+U underline, links) to
16
+ `markdown-inline` content fields. Web could already render that HTML subset, but
17
+ React Native `<Text>` cannot render HTML, so mobile (and several web leaf slots)
18
+ used to strip it and the formatting was lost. This adds the canonical parser that
19
+ turns the safe subset into a flat list of formatted runs each platform can render
20
+ natively (web → `<strong>/<em>/<u>/<a>`, mobile → nested `<Text>`).
21
+
22
+ ### Added (`content`)
23
+
24
+ - **`parseInlineRich(value)`** → `IInlineNode[]`: parses the safe inline subset
25
+ (`<strong>`/`<b>`, `<em>`/`<i>`, `<u>`, `<a href>`) into `{ text, bold?,
26
+ italic?, underline?, href? }` runs. Block tags (`<p>`, `<div>`, headings,
27
+ lists, `<blockquote>`) and `<br>` collapse to a single space (an inline text
28
+ slot cannot lay out blocks); unknown tags are dropped but their text kept;
29
+ HTML entities are decoded; adjacent same-format runs are merged.
30
+ - **`hasInlineFormatting(value)`** → `boolean`: cheap check for whether a string
31
+ carries any supported inline tag (lets renderers fast-path plain strings).
32
+ - **`stripHtmlToText(value)`**: the canonical plain-text strip (web `stripHtmlTags`
33
+ / mobile `sanitizeContent` mirror this) — drop tags, decode entities, collapse
34
+ whitespace, block tags → spaces.
35
+ - **JSON-aware (hard):** any value that parses as JSON is returned untouched, so
36
+ structured content payloads are never mangled.
37
+ - New `IInlineNode` type and `./content` re-export from the package root.
38
+
39
+ Consumers (frontend web + mobile) currently use behaviour-identical local copies
40
+ of the parser/strip (mirroring the existing `stripHtmlToText` pattern); folding
41
+ them onto this shared export is a follow-up.
42
+
43
+ ## v1.14.13
44
+
45
+ `css_mobile` Tailwind-class lockstep fix. The web CMS class dropdown
46
+ (`generate-css-classes.js`) offers the **standard Tailwind numeric color scale**
47
+ (`bg-blue-500`, `text-gray-800`, `border-red-500`, …), but Tailwind v4's default
48
+ palette is authored in `oklch()`, which React Native cannot parse — so the mobile
49
+ allow-list only ever accepted the hex-backed Mantine scale (`bg-blue-6`) and
50
+ silently dropped every dropdown color class on mobile. Authors saw colored
51
+ backgrounds on web and nothing on mobile.
52
+
53
+ ### Fixed (`cms-classes`)
54
+
55
+ - **Standard Tailwind color scale → Mantine hex scale remap** in
56
+ `src/cms-classes/remap.ts`: `bg-/text-/border-{name}-{50..950}` is now rewritten
57
+ onto the RN-safe Mantine scale (`…-{0..9}`) instead of being dropped. Tailwind-only
58
+ names (`slate`, `purple`, `sky`, `emerald`, `amber`, …) alias to their nearest
59
+ Mantine palette. This is a deliberate, documented web→mobile remap (shade is the
60
+ closest visual match).
61
+ - **`text-white` / `text-black`** are now allow-listed (plain colors, RN-safe).
62
+ - The web dropdown's interactive-state classes (`hover:*`, `focus:ring-*`,
63
+ `focus:outline-none`) are remapped to drop cleanly on mobile instead of warning.
64
+
65
+ Patch bump (additive remap/allow-list; no contract change).
66
+
12
67
  ## v1.14.12
13
68
 
14
69
  Layout cross-platform pass — the 13 layout styles (`container`, `box`, `flex`,
package/dist/index.d.mts CHANGED
@@ -1511,6 +1511,78 @@ interface IAssetSource {
1511
1511
  }
1512
1512
  declare function resolveAssetSources<T extends IAssetSource>(sources: T[] | undefined, baseUrl: string): T[];
1513
1513
 
1514
+ /**
1515
+ * Cross-platform inline-formatting helpers for CMS content fields.
1516
+ *
1517
+ * ## Why
1518
+ *
1519
+ * CMS authors can apply lightweight inline formatting (Ctrl+B bold, Ctrl+I
1520
+ * italic, Ctrl+U underline, links) to content fields whose field type allows it
1521
+ * (`markdown-inline`). The editor stores that as a tiny HTML subset
1522
+ * (`<strong>`/`<b>`, `<em>`/`<i>`, `<u>`, `<a>`), often wrapped in block tags
1523
+ * (`<p>`, `<div>`) that markdown processing leaves behind.
1524
+ *
1525
+ * Web can render that subset as real inline HTML, but React Native `<Text>`
1526
+ * cannot render HTML at all — so historically mobile (and several web leaf slots)
1527
+ * stripped everything to plain text and the bold was lost. To carry the same
1528
+ * formatting to BOTH platforms we parse the subset once, here, into a flat list
1529
+ * of {@link IInlineNode} runs. Each platform then renders the runs natively:
1530
+ *
1531
+ * - web → a fragment of `<strong>/<em>/<u>/<a>` (see frontend `InlineRich`)
1532
+ * - mobile → nested `<Text>` with `fontWeight`/`fontStyle`/`textDecorationLine`
1533
+ * (see mobile `InlineText`)
1534
+ *
1535
+ * ## Scope (deliberately tiny + safe)
1536
+ *
1537
+ * Only the inline subset above survives. **Block** tags (`<p>`, `<div>`,
1538
+ * `<h1>`…`<h6>`, `<ul>`/`<ol>`/`<li>`, `<blockquote>`, `<br>`) collapse to a
1539
+ * single space — an inline text slot (a label, a paragraph run) cannot lay out
1540
+ * block structure, and flattening matches the old strip behaviour. Any other tag
1541
+ * is dropped while keeping its inner text. HTML entities are decoded.
1542
+ *
1543
+ * ## JSON-aware (HARD)
1544
+ *
1545
+ * Some content fields legitimately hold JSON (config blobs, table/segmented
1546
+ * data). Those are read via `readField`, not these helpers, but as a safety net
1547
+ * a value that parses as JSON is returned untouched so structured payloads are
1548
+ * never mangled.
1549
+ *
1550
+ * This module is the canonical home the style docs refer to; the web
1551
+ * `stripHtmlTags` and mobile `stripHtmlToText` local copies mirror
1552
+ * {@link stripHtmlToText} and are folded into this once consumers adopt it.
1553
+ */
1554
+ /** A single run of text with the inline formatting that applies to it. */
1555
+ interface IInlineNode {
1556
+ text: string;
1557
+ bold?: boolean;
1558
+ italic?: boolean;
1559
+ underline?: boolean;
1560
+ /** Present when the run sits inside an `<a href>`; the resolved target. */
1561
+ href?: string;
1562
+ }
1563
+ /**
1564
+ * Parse a CMS content string into a flat list of inline-formatted runs,
1565
+ * preserving only the safe inline subset. Block tags + `<br>` collapse to
1566
+ * spaces; entities are decoded; a JSON payload is returned as one untouched run.
1567
+ * Adjacent runs that share formatting are merged and outer whitespace trimmed.
1568
+ */
1569
+ declare function parseInlineRich(value: string | null | undefined): IInlineNode[];
1570
+ /**
1571
+ * Does this value carry any of the supported inline tags? Used by renderers to
1572
+ * fast-path plain strings (and to skip JSON). Cheap: no full parse.
1573
+ */
1574
+ declare function hasInlineFormatting(value: string | null | undefined): boolean;
1575
+ /**
1576
+ * Strip a content string to readable plain text: drop every tag, decode common
1577
+ * entities, collapse whitespace. Block tags + `<br>` become spaces so words do
1578
+ * not run together. JSON payloads and tag-free strings are returned untouched
1579
+ * (apart from entity decoding), so it is safe to call on any field.
1580
+ *
1581
+ * This is the canonical cross-platform helper (web `stripHtmlTags` / mobile
1582
+ * `stripHtmlToText` mirror it).
1583
+ */
1584
+ declare function stripHtmlToText(value: string | null | undefined): string;
1585
+
1514
1586
  /**
1515
1587
  * Parse the unified `shared_spacing` field. The CMS
1516
1588
  * stores this as a JSON string with optional keys for each side:
@@ -1590,4 +1662,4 @@ declare function transformPageData(apiPage: IRawPage): IPageItem;
1590
1662
  */
1591
1663
  declare function transformPagesData(pages: IRawPage[] | null | undefined): IPageItem[];
1592
1664
 
1593
- export { API_VERSION_PREFIX, type AdvisoryAffected, type AdvisoryFeed, type AdvisorySeverity, type BackupManifest, type BackupRetentionPolicy, type BackupSchedulePolicy, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, type CheckSeverity, type CompatibilityRules, type CoreRelease, type DatabaseMigrationMetadata, ENDPOINTS, type FrontendRelease, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IClassPattern, type IClassRemap, type ICompatibilityError, type IConditionContext, IContentField, type IEvaluatedCondition, type IForgotPasswordRequest, type IForgotPasswordResponse, type IFormDeleteRequest, type IFormDeleteResponse, type IFormResultLegacyFields, type IFormSubmitData, type IFormSubmitRequest, type IFormSubmitResponse, type IFormUpdateData, type IFormUpdateRequest, type IFormUpdateResponse, type IFrontendUpdatePreflight, type IFrontendUpdatePreflightResponse, type IFrontendUpdateReleases, type IFrontendUpdateReleasesResponse, type IFrontendUpdateRequest, type IFrontendUpdateRequestResponse, 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 IMaintenanceSetRequest, type IMeta, type IMobileAdapterBaseProps, type IMobileButtonProps, type IMobileCardProps, type IMobileCheckboxProps, type IMobileContainerProps, type IMobileInputProps, type IMobileModalProps, type IMobileSelectOption, type IMobileSelectProps, type IMobileSwitchProps, type IMobileTextProps, type IMobileTextareaProps, type IMobileUiAdapters, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageSectionWithFields, type IPageSectionsData, type IRefreshRequest, type IRefreshSuccessResponse, type IResetPasswordRequest, type IResetPasswordResponse, type ISpacingValue, type ISystemAdvisories, type ISystemAdvisoriesResponse, type ISystemAdvisory, type ISystemAdvisoryAffected, type ISystemHealth, type ISystemHealthComponent, type ISystemHealthResponse, type ISystemInstalledPlugin, type ISystemMaintenance, type ISystemMaintenanceResponse, type ISystemVersion, type ISystemVersionResponse, type ITwoFactorRequiredData, type ITwoFactorRequiredResponse, type ITwoFactorVerifyRequest, type ITwoFactorVerifySuccessResponse, type IUpdatePreflight, type IUpdatePreflightCheck, type IUpdatePreflightOption, type IUpdatePreflightResponse, type IUpdateRelease, type IUpdateReleases, type IUpdateReleasesResponse, type IUpdateRequest, type IUpdateRequestResponse, type IUpdateStatus, type IUpdateStatusManager, type IUpdateStatusResponse, type IUpdateStep, type IUserData, type IUserDataResponse, type ImageRef, type InstalledPlugin, type InstanceImages, type InstanceLock, type InstanceManifest, type InstanceMode, type InstanceResourceConfig, type InstanceRouting, type InstanceStatus, type InstanceVersions, type InventoryInstanceEntry, LITERAL_CLASSES, type LockPluginEntry, type LockServiceEntry, PERMISSIONS, type PluginRelease, type PreflightCheck, type PreflightOption, type PreflightStatus, RELEASE_CHANNELS, type RegistryIndex, type RegistryReleaseRef, type ReleaseChannel, type RuntimeServicePolicy, type RuntimeServiceRange, SIZE_VALUES, SPACING_VALUES, SYSTEM_ENDPOINTS, type SchedulerRelease, type SecurityAdvisory, type ServerInventory, type ServiceBackendCompatibility, type SignatureBlock, type SupportBundleMeta, type TCalcedValues, type TClassDecision, type TClientType, THeroUiButtonVariant, THeroUiSize, type TPermission, type TPlatform, TStyleName, type TSystemAdvisorySeverity, type TSystemComponentStatus, type TSystemDeployment, type TSystemHealthOverall, type TUpdateCheckSeverity, type TUpdateKind, type TUpdateOperationStatus, type TUpdatePreflightStatus, type TrustLevel, type TrustedKey, type TrustedKeysFile, type UpdatePreflightResult, type WorkerRelease, buildConditionContext, classifyClass, classifyClassString, evaluateCondition, findRemap, parseSpacing, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, spacingToClasses, transformPageData, transformPagesData };
1665
+ export { API_VERSION_PREFIX, type AdvisoryAffected, type AdvisoryFeed, type AdvisorySeverity, type BackupManifest, type BackupRetentionPolicy, type BackupSchedulePolicy, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, type CheckSeverity, type CompatibilityRules, type CoreRelease, type DatabaseMigrationMetadata, ENDPOINTS, type FrontendRelease, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IClassPattern, type IClassRemap, type ICompatibilityError, type IConditionContext, IContentField, type IEvaluatedCondition, type IForgotPasswordRequest, type IForgotPasswordResponse, type IFormDeleteRequest, type IFormDeleteResponse, type IFormResultLegacyFields, type IFormSubmitData, type IFormSubmitRequest, type IFormSubmitResponse, type IFormUpdateData, type IFormUpdateRequest, type IFormUpdateResponse, type IFrontendUpdatePreflight, type IFrontendUpdatePreflightResponse, type IFrontendUpdateReleases, type IFrontendUpdateReleasesResponse, type IFrontendUpdateRequest, type IFrontendUpdateRequestResponse, type IGetPageResponse, type IGetPagesResponse, type IInlineNode, type IJwtPayload, type ILanguage, type ILanguageItem, type ILanguagePreference, type ILanguagePreferenceUpdateResponse, type ILanguagesResponse, type ILoginRequest, type ILoginSuccessData, type ILoginSuccessResponse, type ILogoutSuccessResponse, type IMaintenanceSetRequest, type IMeta, type IMobileAdapterBaseProps, type IMobileButtonProps, type IMobileCardProps, type IMobileCheckboxProps, type IMobileContainerProps, type IMobileInputProps, type IMobileModalProps, type IMobileSelectOption, type IMobileSelectProps, type IMobileSwitchProps, type IMobileTextProps, type IMobileTextareaProps, type IMobileUiAdapters, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageSectionWithFields, type IPageSectionsData, type IRefreshRequest, type IRefreshSuccessResponse, type IResetPasswordRequest, type IResetPasswordResponse, type ISpacingValue, type ISystemAdvisories, type ISystemAdvisoriesResponse, type ISystemAdvisory, type ISystemAdvisoryAffected, type ISystemHealth, type ISystemHealthComponent, type ISystemHealthResponse, type ISystemInstalledPlugin, type ISystemMaintenance, type ISystemMaintenanceResponse, type ISystemVersion, type ISystemVersionResponse, type ITwoFactorRequiredData, type ITwoFactorRequiredResponse, type ITwoFactorVerifyRequest, type ITwoFactorVerifySuccessResponse, type IUpdatePreflight, type IUpdatePreflightCheck, type IUpdatePreflightOption, type IUpdatePreflightResponse, type IUpdateRelease, type IUpdateReleases, type IUpdateReleasesResponse, type IUpdateRequest, type IUpdateRequestResponse, type IUpdateStatus, type IUpdateStatusManager, type IUpdateStatusResponse, type IUpdateStep, type IUserData, type IUserDataResponse, type ImageRef, type InstalledPlugin, type InstanceImages, type InstanceLock, type InstanceManifest, type InstanceMode, type InstanceResourceConfig, type InstanceRouting, type InstanceStatus, type InstanceVersions, type InventoryInstanceEntry, LITERAL_CLASSES, type LockPluginEntry, type LockServiceEntry, PERMISSIONS, type PluginRelease, type PreflightCheck, type PreflightOption, type PreflightStatus, RELEASE_CHANNELS, type RegistryIndex, type RegistryReleaseRef, type ReleaseChannel, type RuntimeServicePolicy, type RuntimeServiceRange, SIZE_VALUES, SPACING_VALUES, SYSTEM_ENDPOINTS, type SchedulerRelease, type SecurityAdvisory, type ServerInventory, type ServiceBackendCompatibility, type SignatureBlock, type SupportBundleMeta, type TCalcedValues, type TClassDecision, type TClientType, THeroUiButtonVariant, THeroUiSize, type TPermission, type TPlatform, TStyleName, type TSystemAdvisorySeverity, type TSystemComponentStatus, type TSystemDeployment, type TSystemHealthOverall, type TUpdateCheckSeverity, type TUpdateKind, type TUpdateOperationStatus, type TUpdatePreflightStatus, type TrustLevel, type TrustedKey, type TrustedKeysFile, type UpdatePreflightResult, type WorkerRelease, buildConditionContext, classifyClass, classifyClassString, evaluateCondition, findRemap, hasInlineFormatting, parseInlineRich, parseSpacing, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, spacingToClasses, stripHtmlToText, transformPageData, transformPagesData };
package/dist/index.d.ts CHANGED
@@ -1511,6 +1511,78 @@ interface IAssetSource {
1511
1511
  }
1512
1512
  declare function resolveAssetSources<T extends IAssetSource>(sources: T[] | undefined, baseUrl: string): T[];
1513
1513
 
1514
+ /**
1515
+ * Cross-platform inline-formatting helpers for CMS content fields.
1516
+ *
1517
+ * ## Why
1518
+ *
1519
+ * CMS authors can apply lightweight inline formatting (Ctrl+B bold, Ctrl+I
1520
+ * italic, Ctrl+U underline, links) to content fields whose field type allows it
1521
+ * (`markdown-inline`). The editor stores that as a tiny HTML subset
1522
+ * (`<strong>`/`<b>`, `<em>`/`<i>`, `<u>`, `<a>`), often wrapped in block tags
1523
+ * (`<p>`, `<div>`) that markdown processing leaves behind.
1524
+ *
1525
+ * Web can render that subset as real inline HTML, but React Native `<Text>`
1526
+ * cannot render HTML at all — so historically mobile (and several web leaf slots)
1527
+ * stripped everything to plain text and the bold was lost. To carry the same
1528
+ * formatting to BOTH platforms we parse the subset once, here, into a flat list
1529
+ * of {@link IInlineNode} runs. Each platform then renders the runs natively:
1530
+ *
1531
+ * - web → a fragment of `<strong>/<em>/<u>/<a>` (see frontend `InlineRich`)
1532
+ * - mobile → nested `<Text>` with `fontWeight`/`fontStyle`/`textDecorationLine`
1533
+ * (see mobile `InlineText`)
1534
+ *
1535
+ * ## Scope (deliberately tiny + safe)
1536
+ *
1537
+ * Only the inline subset above survives. **Block** tags (`<p>`, `<div>`,
1538
+ * `<h1>`…`<h6>`, `<ul>`/`<ol>`/`<li>`, `<blockquote>`, `<br>`) collapse to a
1539
+ * single space — an inline text slot (a label, a paragraph run) cannot lay out
1540
+ * block structure, and flattening matches the old strip behaviour. Any other tag
1541
+ * is dropped while keeping its inner text. HTML entities are decoded.
1542
+ *
1543
+ * ## JSON-aware (HARD)
1544
+ *
1545
+ * Some content fields legitimately hold JSON (config blobs, table/segmented
1546
+ * data). Those are read via `readField`, not these helpers, but as a safety net
1547
+ * a value that parses as JSON is returned untouched so structured payloads are
1548
+ * never mangled.
1549
+ *
1550
+ * This module is the canonical home the style docs refer to; the web
1551
+ * `stripHtmlTags` and mobile `stripHtmlToText` local copies mirror
1552
+ * {@link stripHtmlToText} and are folded into this once consumers adopt it.
1553
+ */
1554
+ /** A single run of text with the inline formatting that applies to it. */
1555
+ interface IInlineNode {
1556
+ text: string;
1557
+ bold?: boolean;
1558
+ italic?: boolean;
1559
+ underline?: boolean;
1560
+ /** Present when the run sits inside an `<a href>`; the resolved target. */
1561
+ href?: string;
1562
+ }
1563
+ /**
1564
+ * Parse a CMS content string into a flat list of inline-formatted runs,
1565
+ * preserving only the safe inline subset. Block tags + `<br>` collapse to
1566
+ * spaces; entities are decoded; a JSON payload is returned as one untouched run.
1567
+ * Adjacent runs that share formatting are merged and outer whitespace trimmed.
1568
+ */
1569
+ declare function parseInlineRich(value: string | null | undefined): IInlineNode[];
1570
+ /**
1571
+ * Does this value carry any of the supported inline tags? Used by renderers to
1572
+ * fast-path plain strings (and to skip JSON). Cheap: no full parse.
1573
+ */
1574
+ declare function hasInlineFormatting(value: string | null | undefined): boolean;
1575
+ /**
1576
+ * Strip a content string to readable plain text: drop every tag, decode common
1577
+ * entities, collapse whitespace. Block tags + `<br>` become spaces so words do
1578
+ * not run together. JSON payloads and tag-free strings are returned untouched
1579
+ * (apart from entity decoding), so it is safe to call on any field.
1580
+ *
1581
+ * This is the canonical cross-platform helper (web `stripHtmlTags` / mobile
1582
+ * `stripHtmlToText` mirror it).
1583
+ */
1584
+ declare function stripHtmlToText(value: string | null | undefined): string;
1585
+
1514
1586
  /**
1515
1587
  * Parse the unified `shared_spacing` field. The CMS
1516
1588
  * stores this as a JSON string with optional keys for each side:
@@ -1590,4 +1662,4 @@ declare function transformPageData(apiPage: IRawPage): IPageItem;
1590
1662
  */
1591
1663
  declare function transformPagesData(pages: IRawPage[] | null | undefined): IPageItem[];
1592
1664
 
1593
- export { API_VERSION_PREFIX, type AdvisoryAffected, type AdvisoryFeed, type AdvisorySeverity, type BackupManifest, type BackupRetentionPolicy, type BackupSchedulePolicy, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, type CheckSeverity, type CompatibilityRules, type CoreRelease, type DatabaseMigrationMetadata, ENDPOINTS, type FrontendRelease, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IClassPattern, type IClassRemap, type ICompatibilityError, type IConditionContext, IContentField, type IEvaluatedCondition, type IForgotPasswordRequest, type IForgotPasswordResponse, type IFormDeleteRequest, type IFormDeleteResponse, type IFormResultLegacyFields, type IFormSubmitData, type IFormSubmitRequest, type IFormSubmitResponse, type IFormUpdateData, type IFormUpdateRequest, type IFormUpdateResponse, type IFrontendUpdatePreflight, type IFrontendUpdatePreflightResponse, type IFrontendUpdateReleases, type IFrontendUpdateReleasesResponse, type IFrontendUpdateRequest, type IFrontendUpdateRequestResponse, 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 IMaintenanceSetRequest, type IMeta, type IMobileAdapterBaseProps, type IMobileButtonProps, type IMobileCardProps, type IMobileCheckboxProps, type IMobileContainerProps, type IMobileInputProps, type IMobileModalProps, type IMobileSelectOption, type IMobileSelectProps, type IMobileSwitchProps, type IMobileTextProps, type IMobileTextareaProps, type IMobileUiAdapters, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageSectionWithFields, type IPageSectionsData, type IRefreshRequest, type IRefreshSuccessResponse, type IResetPasswordRequest, type IResetPasswordResponse, type ISpacingValue, type ISystemAdvisories, type ISystemAdvisoriesResponse, type ISystemAdvisory, type ISystemAdvisoryAffected, type ISystemHealth, type ISystemHealthComponent, type ISystemHealthResponse, type ISystemInstalledPlugin, type ISystemMaintenance, type ISystemMaintenanceResponse, type ISystemVersion, type ISystemVersionResponse, type ITwoFactorRequiredData, type ITwoFactorRequiredResponse, type ITwoFactorVerifyRequest, type ITwoFactorVerifySuccessResponse, type IUpdatePreflight, type IUpdatePreflightCheck, type IUpdatePreflightOption, type IUpdatePreflightResponse, type IUpdateRelease, type IUpdateReleases, type IUpdateReleasesResponse, type IUpdateRequest, type IUpdateRequestResponse, type IUpdateStatus, type IUpdateStatusManager, type IUpdateStatusResponse, type IUpdateStep, type IUserData, type IUserDataResponse, type ImageRef, type InstalledPlugin, type InstanceImages, type InstanceLock, type InstanceManifest, type InstanceMode, type InstanceResourceConfig, type InstanceRouting, type InstanceStatus, type InstanceVersions, type InventoryInstanceEntry, LITERAL_CLASSES, type LockPluginEntry, type LockServiceEntry, PERMISSIONS, type PluginRelease, type PreflightCheck, type PreflightOption, type PreflightStatus, RELEASE_CHANNELS, type RegistryIndex, type RegistryReleaseRef, type ReleaseChannel, type RuntimeServicePolicy, type RuntimeServiceRange, SIZE_VALUES, SPACING_VALUES, SYSTEM_ENDPOINTS, type SchedulerRelease, type SecurityAdvisory, type ServerInventory, type ServiceBackendCompatibility, type SignatureBlock, type SupportBundleMeta, type TCalcedValues, type TClassDecision, type TClientType, THeroUiButtonVariant, THeroUiSize, type TPermission, type TPlatform, TStyleName, type TSystemAdvisorySeverity, type TSystemComponentStatus, type TSystemDeployment, type TSystemHealthOverall, type TUpdateCheckSeverity, type TUpdateKind, type TUpdateOperationStatus, type TUpdatePreflightStatus, type TrustLevel, type TrustedKey, type TrustedKeysFile, type UpdatePreflightResult, type WorkerRelease, buildConditionContext, classifyClass, classifyClassString, evaluateCondition, findRemap, parseSpacing, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, spacingToClasses, transformPageData, transformPagesData };
1665
+ export { API_VERSION_PREFIX, type AdvisoryAffected, type AdvisoryFeed, type AdvisorySeverity, type BackupManifest, type BackupRetentionPolicy, type BackupSchedulePolicy, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, type CheckSeverity, type CompatibilityRules, type CoreRelease, type DatabaseMigrationMetadata, ENDPOINTS, type FrontendRelease, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IClassPattern, type IClassRemap, type ICompatibilityError, type IConditionContext, IContentField, type IEvaluatedCondition, type IForgotPasswordRequest, type IForgotPasswordResponse, type IFormDeleteRequest, type IFormDeleteResponse, type IFormResultLegacyFields, type IFormSubmitData, type IFormSubmitRequest, type IFormSubmitResponse, type IFormUpdateData, type IFormUpdateRequest, type IFormUpdateResponse, type IFrontendUpdatePreflight, type IFrontendUpdatePreflightResponse, type IFrontendUpdateReleases, type IFrontendUpdateReleasesResponse, type IFrontendUpdateRequest, type IFrontendUpdateRequestResponse, type IGetPageResponse, type IGetPagesResponse, type IInlineNode, type IJwtPayload, type ILanguage, type ILanguageItem, type ILanguagePreference, type ILanguagePreferenceUpdateResponse, type ILanguagesResponse, type ILoginRequest, type ILoginSuccessData, type ILoginSuccessResponse, type ILogoutSuccessResponse, type IMaintenanceSetRequest, type IMeta, type IMobileAdapterBaseProps, type IMobileButtonProps, type IMobileCardProps, type IMobileCheckboxProps, type IMobileContainerProps, type IMobileInputProps, type IMobileModalProps, type IMobileSelectOption, type IMobileSelectProps, type IMobileSwitchProps, type IMobileTextProps, type IMobileTextareaProps, type IMobileUiAdapters, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageSectionWithFields, type IPageSectionsData, type IRefreshRequest, type IRefreshSuccessResponse, type IResetPasswordRequest, type IResetPasswordResponse, type ISpacingValue, type ISystemAdvisories, type ISystemAdvisoriesResponse, type ISystemAdvisory, type ISystemAdvisoryAffected, type ISystemHealth, type ISystemHealthComponent, type ISystemHealthResponse, type ISystemInstalledPlugin, type ISystemMaintenance, type ISystemMaintenanceResponse, type ISystemVersion, type ISystemVersionResponse, type ITwoFactorRequiredData, type ITwoFactorRequiredResponse, type ITwoFactorVerifyRequest, type ITwoFactorVerifySuccessResponse, type IUpdatePreflight, type IUpdatePreflightCheck, type IUpdatePreflightOption, type IUpdatePreflightResponse, type IUpdateRelease, type IUpdateReleases, type IUpdateReleasesResponse, type IUpdateRequest, type IUpdateRequestResponse, type IUpdateStatus, type IUpdateStatusManager, type IUpdateStatusResponse, type IUpdateStep, type IUserData, type IUserDataResponse, type ImageRef, type InstalledPlugin, type InstanceImages, type InstanceLock, type InstanceManifest, type InstanceMode, type InstanceResourceConfig, type InstanceRouting, type InstanceStatus, type InstanceVersions, type InventoryInstanceEntry, LITERAL_CLASSES, type LockPluginEntry, type LockServiceEntry, PERMISSIONS, type PluginRelease, type PreflightCheck, type PreflightOption, type PreflightStatus, RELEASE_CHANNELS, type RegistryIndex, type RegistryReleaseRef, type ReleaseChannel, type RuntimeServicePolicy, type RuntimeServiceRange, SIZE_VALUES, SPACING_VALUES, SYSTEM_ENDPOINTS, type SchedulerRelease, type SecurityAdvisory, type ServerInventory, type ServiceBackendCompatibility, type SignatureBlock, type SupportBundleMeta, type TCalcedValues, type TClassDecision, type TClientType, THeroUiButtonVariant, THeroUiSize, type TPermission, type TPlatform, TStyleName, type TSystemAdvisorySeverity, type TSystemComponentStatus, type TSystemDeployment, type TSystemHealthOverall, type TUpdateCheckSeverity, type TUpdateKind, type TUpdateOperationStatus, type TUpdatePreflightStatus, type TrustLevel, type TrustedKey, type TrustedKeysFile, type UpdatePreflightResult, type WorkerRelease, buildConditionContext, classifyClass, classifyClassString, evaluateCondition, findRemap, hasInlineFormatting, parseInlineRich, parseSpacing, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, spacingToClasses, stripHtmlToText, transformPageData, transformPagesData };
package/dist/index.js CHANGED
@@ -72,6 +72,7 @@ __export(index_exports, {
72
72
  getStylePlatforms: () => getStylePlatforms,
73
73
  getStylePluginId: () => getStylePluginId,
74
74
  gridSpanToReactNativeColumn: () => gridSpanToReactNativeColumn,
75
+ hasInlineFormatting: () => hasInlineFormatting,
75
76
  isKnownStyleName: () => isKnownStyleName,
76
77
  isRegisteredStyleName: () => isRegisteredStyleName,
77
78
  isStyleAllowedOnPage: () => isStyleAllowedOnPage,
@@ -93,6 +94,7 @@ __export(index_exports, {
93
94
  mapSpacingToPx: () => mapSpacingToPx,
94
95
  parseDimensionToReactNative: () => parseDimensionToReactNative,
95
96
  parseDimensionToWeb: () => parseDimensionToWeb,
97
+ parseInlineRich: () => parseInlineRich,
96
98
  parseSpacing: () => parseSpacing,
97
99
  radiusToPx: () => radiusToPx,
98
100
  replaceCalcedValues: () => replaceCalcedValues,
@@ -109,6 +111,7 @@ __export(index_exports, {
109
111
  sizeToFontPx: () => sizeToFontPx,
110
112
  spacingToClasses: () => spacingToClasses,
111
113
  spacingToPx: () => spacingToPx,
114
+ stripHtmlToText: () => stripHtmlToText,
112
115
  stylePlatformToSet: () => stylePlatformToSet,
113
116
  toHeroUiSemanticProps: () => toHeroUiSemanticProps,
114
117
  toMantineSemanticProps: () => toMantineSemanticProps,
@@ -1135,7 +1138,7 @@ var CLASS_PATTERNS = [
1135
1138
  { prefix: "max-w-", values: [...SIZE_VALUES, "full", "fit", "screen", "none"] },
1136
1139
  { prefix: "max-h-", values: [...SIZE_VALUES, "full", "screen", "none"] },
1137
1140
  // typography
1138
- { prefix: "text-", values: [...SIZE_VALUES, "left", "center", "right", "justify", ...COLOR_SCALE_VALUES] },
1141
+ { prefix: "text-", values: [...SIZE_VALUES, "left", "center", "right", "justify", "white", "black", ...COLOR_SCALE_VALUES] },
1139
1142
  { prefix: "font-", values: ["thin", "light", "normal", "medium", "semibold", "bold", "extrabold", "black"] },
1140
1143
  { prefix: "leading-", values: ["none", "tight", "snug", "normal", "relaxed", "loose"] },
1141
1144
  { prefix: "tracking-", values: ["tighter", "tight", "normal", "wide", "wider", "widest"] },
@@ -1206,10 +1209,78 @@ var LITERAL_CLASSES = /* @__PURE__ */ new Set([
1206
1209
  ]);
1207
1210
 
1208
1211
  // src/cms-classes/remap.ts
1212
+ var TW_SCALE_TO_MANTINE = {
1213
+ "50": "0",
1214
+ "100": "1",
1215
+ "200": "2",
1216
+ "300": "3",
1217
+ "400": "4",
1218
+ "500": "6",
1219
+ "600": "7",
1220
+ "700": "8",
1221
+ "800": "9",
1222
+ "900": "9",
1223
+ "950": "9"
1224
+ };
1225
+ var TW_NAME_TO_MANTINE = {
1226
+ slate: "gray",
1227
+ gray: "gray",
1228
+ zinc: "gray",
1229
+ neutral: "gray",
1230
+ stone: "gray",
1231
+ red: "red",
1232
+ rose: "pink",
1233
+ pink: "pink",
1234
+ fuchsia: "grape",
1235
+ purple: "grape",
1236
+ grape: "grape",
1237
+ violet: "violet",
1238
+ indigo: "indigo",
1239
+ blue: "blue",
1240
+ sky: "cyan",
1241
+ cyan: "cyan",
1242
+ teal: "teal",
1243
+ emerald: "green",
1244
+ green: "green",
1245
+ lime: "lime",
1246
+ yellow: "yellow",
1247
+ amber: "orange",
1248
+ orange: "orange"
1249
+ };
1250
+ var COLOR_PREFIXES = ["bg-", "text-", "border-"];
1251
+ function buildColorScaleRemaps() {
1252
+ const out = [];
1253
+ for (const prefix of COLOR_PREFIXES) {
1254
+ for (const [twName, mantineName] of Object.entries(TW_NAME_TO_MANTINE)) {
1255
+ for (const [twScale, idx] of Object.entries(TW_SCALE_TO_MANTINE)) {
1256
+ out.push({
1257
+ from: `${prefix}${twName}-${twScale}`,
1258
+ to: `${prefix}${mantineName}-${idx}`,
1259
+ reason: "tailwind oklch scale \u2192 mantine hex scale (RN-safe)"
1260
+ });
1261
+ }
1262
+ }
1263
+ }
1264
+ return out;
1265
+ }
1266
+ var INTERACTIVE_DROP = [
1267
+ "hover:bg-gray-100",
1268
+ "hover:bg-blue-600",
1269
+ "hover:bg-green-600",
1270
+ "hover:bg-red-600",
1271
+ "hover:text-blue-600",
1272
+ "hover:text-green-600",
1273
+ "hover:text-red-600",
1274
+ "hover:shadow-md",
1275
+ "hover:shadow-lg",
1276
+ "hover:underline",
1277
+ "focus:outline-none",
1278
+ "focus:ring-2",
1279
+ "focus:ring-blue-500",
1280
+ "focus:ring-offset-2"
1281
+ ].map((from) => ({ from, to: null, reason: "interactive state not applicable on mobile" }));
1209
1282
  var CLASS_REMAP = [
1210
- // hover/focus on mobile only fires for keyboard nav; safe to drop.
1211
- { from: "hover:bg-gray-100", to: null, reason: "hover not applicable on mobile" },
1212
- { from: "hover:underline", to: null, reason: "hover not applicable on mobile" },
1283
+ ...INTERACTIVE_DROP,
1213
1284
  // cursor classes are no-ops on RN.
1214
1285
  { from: "cursor-pointer", to: null, reason: "no cursor on RN" },
1215
1286
  { from: "cursor-default", to: null, reason: "no cursor on RN" },
@@ -1218,7 +1289,9 @@ var CLASS_REMAP = [
1218
1289
  { from: "select-text", to: null, reason: "unsupported on RN" },
1219
1290
  // legacy aliases
1220
1291
  { from: "mantine-fw", to: "w-full" },
1221
- { from: "mantine-h-full", to: "h-full" }
1292
+ { from: "mantine-h-full", to: "h-full" },
1293
+ // standard Tailwind color scale → Mantine hex scale (RN-safe)
1294
+ ...buildColorScaleRemaps()
1222
1295
  ];
1223
1296
  var REMAP_MAP = new Map(CLASS_REMAP.map((r) => [r.from, r]));
1224
1297
  function findRemap(className) {
@@ -1292,6 +1365,149 @@ function resolveAssetSources(sources, baseUrl) {
1292
1365
  return sources.map((s) => ({ ...s, src: resolveAssetUrl(s.src, baseUrl) }));
1293
1366
  }
1294
1367
 
1368
+ // src/content/inlineFormat.ts
1369
+ var HTML_ENTITIES = {
1370
+ "&amp;": "&",
1371
+ "&lt;": "<",
1372
+ "&gt;": ">",
1373
+ "&quot;": '"',
1374
+ "&#39;": "'",
1375
+ "&apos;": "'",
1376
+ "&nbsp;": " ",
1377
+ "&#x2f;": "/",
1378
+ "&#47;": "/"
1379
+ };
1380
+ function decodeEntities(value) {
1381
+ if (!value.includes("&")) return value;
1382
+ return value.replace(/&[a-zA-Z#0-9]+;/g, (entity) => HTML_ENTITIES[entity.toLowerCase()] ?? entity);
1383
+ }
1384
+ function looksLikeJson(trimmed) {
1385
+ const first = trimmed[0];
1386
+ if (first !== "{" && first !== "[") return false;
1387
+ try {
1388
+ JSON.parse(trimmed);
1389
+ return true;
1390
+ } catch {
1391
+ return false;
1392
+ }
1393
+ }
1394
+ var SEPARATOR_TAGS = /* @__PURE__ */ new Set([
1395
+ "br",
1396
+ "p",
1397
+ "div",
1398
+ "li",
1399
+ "ul",
1400
+ "ol",
1401
+ "h1",
1402
+ "h2",
1403
+ "h3",
1404
+ "h4",
1405
+ "h5",
1406
+ "h6",
1407
+ "blockquote",
1408
+ "tr",
1409
+ "section",
1410
+ "article",
1411
+ "header",
1412
+ "footer",
1413
+ "pre"
1414
+ ]);
1415
+ var INLINE_TAG_RE = /<(?:b|strong|i|em|u|a)\b/i;
1416
+ var TAG_RE = /<\/?([a-z][a-z0-9]*)\b([^>]*)>/gi;
1417
+ var HREF_RE = /href\s*=\s*(?:"([^"]*)"|'([^']*)')/i;
1418
+ function extractHref(attrs) {
1419
+ const match = HREF_RE.exec(attrs);
1420
+ return (match?.[1] ?? match?.[2] ?? "").trim();
1421
+ }
1422
+ function formatKey(node) {
1423
+ return `${node.bold ? 1 : 0}|${node.italic ? 1 : 0}|${node.underline ? 1 : 0}|${node.href ?? ""}`;
1424
+ }
1425
+ function parseInlineRich(value) {
1426
+ if (value == null) return [];
1427
+ const str = String(value);
1428
+ if (str === "") return [];
1429
+ const trimmed = str.trim();
1430
+ if (looksLikeJson(trimmed)) return [{ text: str }];
1431
+ if (!str.includes("<")) {
1432
+ const text = decodeEntities(str);
1433
+ return text === "" ? [] : [{ text }];
1434
+ }
1435
+ const raw = [];
1436
+ let bold = 0;
1437
+ let italic = 0;
1438
+ let underline = 0;
1439
+ const hrefStack = [];
1440
+ const pushText = (segment) => {
1441
+ if (segment === "") return;
1442
+ raw.push({
1443
+ text: segment,
1444
+ ...bold > 0 ? { bold: true } : {},
1445
+ ...italic > 0 ? { italic: true } : {},
1446
+ ...underline > 0 ? { underline: true } : {},
1447
+ ...hrefStack.length > 0 ? { href: hrefStack[hrefStack.length - 1] } : {}
1448
+ });
1449
+ };
1450
+ let lastIndex = 0;
1451
+ let match;
1452
+ TAG_RE.lastIndex = 0;
1453
+ while ((match = TAG_RE.exec(str)) !== null) {
1454
+ pushText(str.slice(lastIndex, match.index));
1455
+ lastIndex = TAG_RE.lastIndex;
1456
+ const isClose = match[0].charAt(1) === "/";
1457
+ const tag = match[1].toLowerCase();
1458
+ const attrs = match[2] ?? "";
1459
+ if (tag === "b" || tag === "strong") {
1460
+ bold = isClose ? Math.max(0, bold - 1) : bold + 1;
1461
+ } else if (tag === "i" || tag === "em") {
1462
+ italic = isClose ? Math.max(0, italic - 1) : italic + 1;
1463
+ } else if (tag === "u") {
1464
+ underline = isClose ? Math.max(0, underline - 1) : underline + 1;
1465
+ } else if (tag === "a") {
1466
+ if (isClose) {
1467
+ hrefStack.pop();
1468
+ } else {
1469
+ hrefStack.push(extractHref(attrs));
1470
+ }
1471
+ } else if (SEPARATOR_TAGS.has(tag)) {
1472
+ pushText(" ");
1473
+ }
1474
+ }
1475
+ pushText(str.slice(lastIndex));
1476
+ const merged = [];
1477
+ for (const node of raw) {
1478
+ const prev = merged[merged.length - 1];
1479
+ if (prev && formatKey(prev) === formatKey(node)) {
1480
+ prev.text += node.text;
1481
+ } else {
1482
+ merged.push({ ...node });
1483
+ }
1484
+ }
1485
+ for (const node of merged) {
1486
+ node.text = decodeEntities(node.text).replace(/\s+/g, " ");
1487
+ }
1488
+ if (merged.length > 0) {
1489
+ merged[0].text = merged[0].text.replace(/^\s+/, "");
1490
+ merged[merged.length - 1].text = merged[merged.length - 1].text.replace(/\s+$/, "");
1491
+ }
1492
+ return merged.filter((node) => node.text !== "");
1493
+ }
1494
+ function hasInlineFormatting(value) {
1495
+ if (value == null) return false;
1496
+ const str = String(value);
1497
+ if (!str.includes("<")) return false;
1498
+ if (looksLikeJson(str.trim())) return false;
1499
+ return INLINE_TAG_RE.test(str);
1500
+ }
1501
+ function stripHtmlToText(value) {
1502
+ if (!value || typeof value !== "string") return value ?? "";
1503
+ const trimmed = value.trim();
1504
+ if (looksLikeJson(trimmed)) return value;
1505
+ if (!/[<&]/.test(value)) return value;
1506
+ let out = value.replace(/<br\s*\/?>/gi, " ").replace(/<\/(p|div|li|h[1-6]|tr|blockquote)>/gi, " ").replace(/<[^>]+>/g, "");
1507
+ out = out.replace(/&[a-zA-Z#0-9]+;/g, (entity) => HTML_ENTITIES[entity.toLowerCase()] ?? entity);
1508
+ return out.replace(/\s+/g, " ").trim();
1509
+ }
1510
+
1295
1511
  // src/utils/spacing.ts
1296
1512
  var ALLOWED_KEYS = ["mt", "mb", "ms", "me", "pt", "pb", "ps", "pe"];
1297
1513
  function parseSpacing(raw) {
@@ -1403,6 +1619,7 @@ function transformPagesData(pages) {
1403
1619
  getStylePlatforms,
1404
1620
  getStylePluginId,
1405
1621
  gridSpanToReactNativeColumn,
1622
+ hasInlineFormatting,
1406
1623
  isKnownStyleName,
1407
1624
  isRegisteredStyleName,
1408
1625
  isStyleAllowedOnPage,
@@ -1424,6 +1641,7 @@ function transformPagesData(pages) {
1424
1641
  mapSpacingToPx,
1425
1642
  parseDimensionToReactNative,
1426
1643
  parseDimensionToWeb,
1644
+ parseInlineRich,
1427
1645
  parseSpacing,
1428
1646
  radiusToPx,
1429
1647
  replaceCalcedValues,
@@ -1440,6 +1658,7 @@ function transformPagesData(pages) {
1440
1658
  sizeToFontPx,
1441
1659
  spacingToClasses,
1442
1660
  spacingToPx,
1661
+ stripHtmlToText,
1443
1662
  stylePlatformToSet,
1444
1663
  toHeroUiSemanticProps,
1445
1664
  toMantineSemanticProps,