@selfhelp/shared 1.21.0 → 1.21.1
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 +11 -0
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +56 -1
- package/dist/index.mjs +53 -1
- package/package.json +1 -1
- package/src/navigation/__tests__/navigation.test.ts +61 -0
- package/src/navigation/branchNav.ts +45 -0
- package/src/navigation/menuMembership.ts +27 -1
- package/src/navigation/menuSearch.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,17 @@ 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.21.1
|
|
13
|
+
|
|
14
|
+
**Menu-builder navigation helpers (patch)** — additive navigation utilities for
|
|
15
|
+
mobile bottom tabs and cross-menu page lookup. `findPageRefInNavigationPayload`
|
|
16
|
+
resolves `INavigationResolvedPageRef` metadata from any public menu tree;
|
|
17
|
+
`findNearestBottomTabMenuItemForPage` and `isBottomTabMenuItemActive` drive
|
|
18
|
+
nested bottom-tab active state (ancestor tab stays active for descendant paths).
|
|
19
|
+
`searchMenuPagesInPayload` now honours `payload.search.min_chars` before
|
|
20
|
+
returning hits. Regression tests assert legacy `TWebNavRender` /
|
|
21
|
+
`TMobileNavRender` option lists are not re-exported from the package root.
|
|
22
|
+
|
|
12
23
|
## v1.21.0
|
|
13
24
|
|
|
14
25
|
**Menu-builder navigation contract (breaking cleanup)** — replaces the page-level
|
package/dist/index.d.mts
CHANGED
|
@@ -2119,6 +2119,8 @@ declare function isPageInMenuTree(items: INavigationMenuItem[], pageId: number):
|
|
|
2119
2119
|
declare function isPageInResolvedMenus(menus: Partial<Record<TNavigationMenuKey, INavigationMenu>>, menuKeys: TNavigationMenuKey[], pageId: number): boolean;
|
|
2120
2120
|
declare function isOnAnyMobileMenu(menus: Partial<Record<TNavigationMenuKey, INavigationMenu>>, pageId: number): boolean;
|
|
2121
2121
|
declare function findMenuItemByPageId(items: INavigationMenuItem[], pageId: number): INavigationMenuItem | null;
|
|
2122
|
+
/** Resolved page metadata from any public menu tree (for holder redirects, etc.). */
|
|
2123
|
+
declare function findPageRefInNavigationPayload(payload: INavigationPayload, pageId: number): INavigationResolvedPageRef | null;
|
|
2122
2124
|
|
|
2123
2125
|
interface IBranchNavSegment {
|
|
2124
2126
|
pageId: number;
|
|
@@ -2146,6 +2148,14 @@ declare function isOnAnyMobileMenuFromPayload(payload: INavigationPayload, pageI
|
|
|
2146
2148
|
* return the first child route to auto-select.
|
|
2147
2149
|
*/
|
|
2148
2150
|
declare function resolveHolderRedirectPath(payload: INavigationPayload, currentPageId: number, platform: 'web' | 'mobile', hasContent: boolean): string | null;
|
|
2151
|
+
/**
|
|
2152
|
+
* Returns the top-level bottom-tab item that owns a nested page, if any.
|
|
2153
|
+
*/
|
|
2154
|
+
declare function findNearestBottomTabMenuItemForPage(tabs: INavigationMenuItem[], pageId: number): INavigationMenuItem | null;
|
|
2155
|
+
/**
|
|
2156
|
+
* Active state for a flat bottom-tab item, including descendants on the current path.
|
|
2157
|
+
*/
|
|
2158
|
+
declare function isBottomTabMenuItemActive(item: INavigationMenuItem, pathname: string): boolean;
|
|
2149
2159
|
|
|
2150
2160
|
declare function getNavigationItemLabel(item: INavigationMenuItem): string;
|
|
2151
2161
|
declare function getNavigationItemHref(item: INavigationMenuItem): string;
|
|
@@ -2279,4 +2289,4 @@ declare function transformPageData(apiPage: IRawPage): IPageItem;
|
|
|
2279
2289
|
*/
|
|
2280
2290
|
declare function transformPagesData(pages: IRawPage[] | null | undefined): IPageItem[];
|
|
2281
2291
|
|
|
2282
|
-
export { API_VERSION_PREFIX, type AdvisoryAffected, type AdvisoryFeed, type AdvisorySeverity, type BackupManifest, type BackupRetentionPolicy, type BackupSchedulePolicy, type BundledPluginRef, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, type CheckSeverity, type CompatibilityRules, type CoreRelease, DEFAULT_MOBILE_ICON, DEFAULT_WEB_HEADER_PRESET, type DatabaseMigrationMetadata, ENDPOINTS, type FrontendRelease, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IBranchNavSegment, 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 IMenuSearchHit, type IMeta, type IMobileAdapterBaseProps, type IMobileButtonProps, type IMobileCardProps, type IMobileCheckboxProps, type IMobileContainerProps, type IMobileIconEntry, type IMobileInputProps, type IMobileModalProps, type IMobilePreviewExchangeData, type IMobilePreviewExchangeRequest, type IMobilePreviewExchangeResponse, type IMobilePreviewSessionData, type IMobilePreviewSessionRequest, type IMobilePreviewSessionResponse, type IMobilePreviewUpdatePreflight, type IMobilePreviewUpdatePreflightResponse, type IMobilePreviewUpdateReleases, type IMobilePreviewUpdateReleasesResponse, type IMobilePreviewUpdateRequest, type IMobilePreviewUpdateRequestResponse, type IMobileSelectOption, type IMobileSelectProps, type IMobileSwitchProps, type IMobileTextProps, type IMobileTextareaProps, type IMobileUiAdapters, type INavigationMenu, type INavigationMenuItem, type INavigationPayload, type INavigationResolvedPageRef, type INavigationSearchConfig, type INavigationStartupConfig, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageRoute, type IPageSectionWithFields, type IPageSectionsData, type IPreviewNavigateCommand, type IPreviewNavigatedMessage, type IPreviewPreferences, type IPreviewPreferencesChangedMessage, type IPreviewReadyMessage, type IPreviewSetPreferencesCommand, type IRefreshRequest, type IRefreshSuccessResponse, type IResetPasswordRequest, type IResetPasswordResponse, type IResolvePageResponse, 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 IWebHeaderPresetOption, 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, MOBILE_ICON_NAMES, MOBILE_ICON_SET, MOBILE_PREVIEW_ENDPOINTS, type MobilePreviewRelease, PERMISSIONS, PREVIEW_BRIDGE_MESSAGE, PREVIEW_PARENT_ORIGIN_PARAM, PREVIEW_SHELL_PARAM, 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, TMobileButtonFeedback, TMobileFieldVariant, type TMobilePagePresentation, TMobileSelectPresentation, type TNavigationChildSource, type TNavigationMenuItemType, type TNavigationMenuKey, type TNavigationMobileStartSource, type TNavigationSearchMode, type TNavigationStartMode, type TPermission, type TPlatform, type TPreviewBridgeMessage, type TPreviewBridgeMessageType, type TPreviewColorScheme, type TPreviewFrameSource, TStyleName, type TSystemAdvisorySeverity, type TSystemComponentStatus, type TSystemDeployment, type TSystemHealthOverall, type TUpdateCheckSeverity, type TUpdateKind, type TUpdateOperationStatus, type TUpdatePreflightStatus, type TWebHeaderPreset, type TrustLevel, type TrustedKey, type TrustedKeysFile, type UpdatePreflightResult, WEB_HEADER_PRESET_OPTIONS, WEB_HEADER_PRESET_VALUES, type WorkerRelease, arePreviewPreferencesEqual, buildConditionContext, classifyClass, classifyClassString, collectPageIdsFromMenuItems, evaluateCondition, findMenuItemByPageId, findRemap, flattenMenuItems, flattenNavigationMenuItems, getNavigationItemHref, getNavigationItemKeyword, getNavigationItemLabel, hasInlineFormatting, isMobileIconName, isOnAnyMobileMenu, isOnAnyMobileMenuFromPayload, isPageInMenuTree, isPageInResolvedMenus, isPageOnAnyMenu, isPageOnMobileMenu, isPageOnWebMenu, isPreviewBridgeMessage, isWebHeaderPreset, pageUrlToMobileRoute, parseInlineRich, parseSpacing, previewKeywordFromPath, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, resolveBranchNavGroup, resolveHolderRedirectPath, resolveMobileIcon, resolveMobilePagePresentation, resolveMobileSegmentGroup, resolveMobileStartupKeyword, resolveMobileStartupRoute, resolveWebBranchNavGroup, resolveWebHeaderPreset, resolveWebStartupPath, searchMenuPagesInPayload, spacingToClasses, stripHtmlToText, transformPageData, transformPagesData };
|
|
2292
|
+
export { API_VERSION_PREFIX, type AdvisoryAffected, type AdvisoryFeed, type AdvisorySeverity, type BackupManifest, type BackupRetentionPolicy, type BackupSchedulePolicy, type BundledPluginRef, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, type CheckSeverity, type CompatibilityRules, type CoreRelease, DEFAULT_MOBILE_ICON, DEFAULT_WEB_HEADER_PRESET, type DatabaseMigrationMetadata, ENDPOINTS, type FrontendRelease, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IBranchNavSegment, 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 IMenuSearchHit, type IMeta, type IMobileAdapterBaseProps, type IMobileButtonProps, type IMobileCardProps, type IMobileCheckboxProps, type IMobileContainerProps, type IMobileIconEntry, type IMobileInputProps, type IMobileModalProps, type IMobilePreviewExchangeData, type IMobilePreviewExchangeRequest, type IMobilePreviewExchangeResponse, type IMobilePreviewSessionData, type IMobilePreviewSessionRequest, type IMobilePreviewSessionResponse, type IMobilePreviewUpdatePreflight, type IMobilePreviewUpdatePreflightResponse, type IMobilePreviewUpdateReleases, type IMobilePreviewUpdateReleasesResponse, type IMobilePreviewUpdateRequest, type IMobilePreviewUpdateRequestResponse, type IMobileSelectOption, type IMobileSelectProps, type IMobileSwitchProps, type IMobileTextProps, type IMobileTextareaProps, type IMobileUiAdapters, type INavigationMenu, type INavigationMenuItem, type INavigationPayload, type INavigationResolvedPageRef, type INavigationSearchConfig, type INavigationStartupConfig, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageRoute, type IPageSectionWithFields, type IPageSectionsData, type IPreviewNavigateCommand, type IPreviewNavigatedMessage, type IPreviewPreferences, type IPreviewPreferencesChangedMessage, type IPreviewReadyMessage, type IPreviewSetPreferencesCommand, type IRefreshRequest, type IRefreshSuccessResponse, type IResetPasswordRequest, type IResetPasswordResponse, type IResolvePageResponse, 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 IWebHeaderPresetOption, 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, MOBILE_ICON_NAMES, MOBILE_ICON_SET, MOBILE_PREVIEW_ENDPOINTS, type MobilePreviewRelease, PERMISSIONS, PREVIEW_BRIDGE_MESSAGE, PREVIEW_PARENT_ORIGIN_PARAM, PREVIEW_SHELL_PARAM, 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, TMobileButtonFeedback, TMobileFieldVariant, type TMobilePagePresentation, TMobileSelectPresentation, type TNavigationChildSource, type TNavigationMenuItemType, type TNavigationMenuKey, type TNavigationMobileStartSource, type TNavigationSearchMode, type TNavigationStartMode, type TPermission, type TPlatform, type TPreviewBridgeMessage, type TPreviewBridgeMessageType, type TPreviewColorScheme, type TPreviewFrameSource, TStyleName, type TSystemAdvisorySeverity, type TSystemComponentStatus, type TSystemDeployment, type TSystemHealthOverall, type TUpdateCheckSeverity, type TUpdateKind, type TUpdateOperationStatus, type TUpdatePreflightStatus, type TWebHeaderPreset, type TrustLevel, type TrustedKey, type TrustedKeysFile, type UpdatePreflightResult, WEB_HEADER_PRESET_OPTIONS, WEB_HEADER_PRESET_VALUES, type WorkerRelease, arePreviewPreferencesEqual, buildConditionContext, classifyClass, classifyClassString, collectPageIdsFromMenuItems, evaluateCondition, findMenuItemByPageId, findNearestBottomTabMenuItemForPage, findPageRefInNavigationPayload, findRemap, flattenMenuItems, flattenNavigationMenuItems, getNavigationItemHref, getNavigationItemKeyword, getNavigationItemLabel, hasInlineFormatting, isBottomTabMenuItemActive, isMobileIconName, isOnAnyMobileMenu, isOnAnyMobileMenuFromPayload, isPageInMenuTree, isPageInResolvedMenus, isPageOnAnyMenu, isPageOnMobileMenu, isPageOnWebMenu, isPreviewBridgeMessage, isWebHeaderPreset, pageUrlToMobileRoute, parseInlineRich, parseSpacing, previewKeywordFromPath, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, resolveBranchNavGroup, resolveHolderRedirectPath, resolveMobileIcon, resolveMobilePagePresentation, resolveMobileSegmentGroup, resolveMobileStartupKeyword, resolveMobileStartupRoute, resolveWebBranchNavGroup, resolveWebHeaderPreset, resolveWebStartupPath, searchMenuPagesInPayload, spacingToClasses, stripHtmlToText, transformPageData, transformPagesData };
|
package/dist/index.d.ts
CHANGED
|
@@ -2119,6 +2119,8 @@ declare function isPageInMenuTree(items: INavigationMenuItem[], pageId: number):
|
|
|
2119
2119
|
declare function isPageInResolvedMenus(menus: Partial<Record<TNavigationMenuKey, INavigationMenu>>, menuKeys: TNavigationMenuKey[], pageId: number): boolean;
|
|
2120
2120
|
declare function isOnAnyMobileMenu(menus: Partial<Record<TNavigationMenuKey, INavigationMenu>>, pageId: number): boolean;
|
|
2121
2121
|
declare function findMenuItemByPageId(items: INavigationMenuItem[], pageId: number): INavigationMenuItem | null;
|
|
2122
|
+
/** Resolved page metadata from any public menu tree (for holder redirects, etc.). */
|
|
2123
|
+
declare function findPageRefInNavigationPayload(payload: INavigationPayload, pageId: number): INavigationResolvedPageRef | null;
|
|
2122
2124
|
|
|
2123
2125
|
interface IBranchNavSegment {
|
|
2124
2126
|
pageId: number;
|
|
@@ -2146,6 +2148,14 @@ declare function isOnAnyMobileMenuFromPayload(payload: INavigationPayload, pageI
|
|
|
2146
2148
|
* return the first child route to auto-select.
|
|
2147
2149
|
*/
|
|
2148
2150
|
declare function resolveHolderRedirectPath(payload: INavigationPayload, currentPageId: number, platform: 'web' | 'mobile', hasContent: boolean): string | null;
|
|
2151
|
+
/**
|
|
2152
|
+
* Returns the top-level bottom-tab item that owns a nested page, if any.
|
|
2153
|
+
*/
|
|
2154
|
+
declare function findNearestBottomTabMenuItemForPage(tabs: INavigationMenuItem[], pageId: number): INavigationMenuItem | null;
|
|
2155
|
+
/**
|
|
2156
|
+
* Active state for a flat bottom-tab item, including descendants on the current path.
|
|
2157
|
+
*/
|
|
2158
|
+
declare function isBottomTabMenuItemActive(item: INavigationMenuItem, pathname: string): boolean;
|
|
2149
2159
|
|
|
2150
2160
|
declare function getNavigationItemLabel(item: INavigationMenuItem): string;
|
|
2151
2161
|
declare function getNavigationItemHref(item: INavigationMenuItem): string;
|
|
@@ -2279,4 +2289,4 @@ declare function transformPageData(apiPage: IRawPage): IPageItem;
|
|
|
2279
2289
|
*/
|
|
2280
2290
|
declare function transformPagesData(pages: IRawPage[] | null | undefined): IPageItem[];
|
|
2281
2291
|
|
|
2282
|
-
export { API_VERSION_PREFIX, type AdvisoryAffected, type AdvisoryFeed, type AdvisorySeverity, type BackupManifest, type BackupRetentionPolicy, type BackupSchedulePolicy, type BundledPluginRef, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, type CheckSeverity, type CompatibilityRules, type CoreRelease, DEFAULT_MOBILE_ICON, DEFAULT_WEB_HEADER_PRESET, type DatabaseMigrationMetadata, ENDPOINTS, type FrontendRelease, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IBranchNavSegment, 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 IMenuSearchHit, type IMeta, type IMobileAdapterBaseProps, type IMobileButtonProps, type IMobileCardProps, type IMobileCheckboxProps, type IMobileContainerProps, type IMobileIconEntry, type IMobileInputProps, type IMobileModalProps, type IMobilePreviewExchangeData, type IMobilePreviewExchangeRequest, type IMobilePreviewExchangeResponse, type IMobilePreviewSessionData, type IMobilePreviewSessionRequest, type IMobilePreviewSessionResponse, type IMobilePreviewUpdatePreflight, type IMobilePreviewUpdatePreflightResponse, type IMobilePreviewUpdateReleases, type IMobilePreviewUpdateReleasesResponse, type IMobilePreviewUpdateRequest, type IMobilePreviewUpdateRequestResponse, type IMobileSelectOption, type IMobileSelectProps, type IMobileSwitchProps, type IMobileTextProps, type IMobileTextareaProps, type IMobileUiAdapters, type INavigationMenu, type INavigationMenuItem, type INavigationPayload, type INavigationResolvedPageRef, type INavigationSearchConfig, type INavigationStartupConfig, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageRoute, type IPageSectionWithFields, type IPageSectionsData, type IPreviewNavigateCommand, type IPreviewNavigatedMessage, type IPreviewPreferences, type IPreviewPreferencesChangedMessage, type IPreviewReadyMessage, type IPreviewSetPreferencesCommand, type IRefreshRequest, type IRefreshSuccessResponse, type IResetPasswordRequest, type IResetPasswordResponse, type IResolvePageResponse, 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 IWebHeaderPresetOption, 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, MOBILE_ICON_NAMES, MOBILE_ICON_SET, MOBILE_PREVIEW_ENDPOINTS, type MobilePreviewRelease, PERMISSIONS, PREVIEW_BRIDGE_MESSAGE, PREVIEW_PARENT_ORIGIN_PARAM, PREVIEW_SHELL_PARAM, 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, TMobileButtonFeedback, TMobileFieldVariant, type TMobilePagePresentation, TMobileSelectPresentation, type TNavigationChildSource, type TNavigationMenuItemType, type TNavigationMenuKey, type TNavigationMobileStartSource, type TNavigationSearchMode, type TNavigationStartMode, type TPermission, type TPlatform, type TPreviewBridgeMessage, type TPreviewBridgeMessageType, type TPreviewColorScheme, type TPreviewFrameSource, TStyleName, type TSystemAdvisorySeverity, type TSystemComponentStatus, type TSystemDeployment, type TSystemHealthOverall, type TUpdateCheckSeverity, type TUpdateKind, type TUpdateOperationStatus, type TUpdatePreflightStatus, type TWebHeaderPreset, type TrustLevel, type TrustedKey, type TrustedKeysFile, type UpdatePreflightResult, WEB_HEADER_PRESET_OPTIONS, WEB_HEADER_PRESET_VALUES, type WorkerRelease, arePreviewPreferencesEqual, buildConditionContext, classifyClass, classifyClassString, collectPageIdsFromMenuItems, evaluateCondition, findMenuItemByPageId, findRemap, flattenMenuItems, flattenNavigationMenuItems, getNavigationItemHref, getNavigationItemKeyword, getNavigationItemLabel, hasInlineFormatting, isMobileIconName, isOnAnyMobileMenu, isOnAnyMobileMenuFromPayload, isPageInMenuTree, isPageInResolvedMenus, isPageOnAnyMenu, isPageOnMobileMenu, isPageOnWebMenu, isPreviewBridgeMessage, isWebHeaderPreset, pageUrlToMobileRoute, parseInlineRich, parseSpacing, previewKeywordFromPath, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, resolveBranchNavGroup, resolveHolderRedirectPath, resolveMobileIcon, resolveMobilePagePresentation, resolveMobileSegmentGroup, resolveMobileStartupKeyword, resolveMobileStartupRoute, resolveWebBranchNavGroup, resolveWebHeaderPreset, resolveWebStartupPath, searchMenuPagesInPayload, spacingToClasses, stripHtmlToText, transformPageData, transformPagesData };
|
|
2292
|
+
export { API_VERSION_PREFIX, type AdvisoryAffected, type AdvisoryFeed, type AdvisorySeverity, type BackupManifest, type BackupRetentionPolicy, type BackupSchedulePolicy, type BundledPluginRef, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, type CheckSeverity, type CompatibilityRules, type CoreRelease, DEFAULT_MOBILE_ICON, DEFAULT_WEB_HEADER_PRESET, type DatabaseMigrationMetadata, ENDPOINTS, type FrontendRelease, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IBranchNavSegment, 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 IMenuSearchHit, type IMeta, type IMobileAdapterBaseProps, type IMobileButtonProps, type IMobileCardProps, type IMobileCheckboxProps, type IMobileContainerProps, type IMobileIconEntry, type IMobileInputProps, type IMobileModalProps, type IMobilePreviewExchangeData, type IMobilePreviewExchangeRequest, type IMobilePreviewExchangeResponse, type IMobilePreviewSessionData, type IMobilePreviewSessionRequest, type IMobilePreviewSessionResponse, type IMobilePreviewUpdatePreflight, type IMobilePreviewUpdatePreflightResponse, type IMobilePreviewUpdateReleases, type IMobilePreviewUpdateReleasesResponse, type IMobilePreviewUpdateRequest, type IMobilePreviewUpdateRequestResponse, type IMobileSelectOption, type IMobileSelectProps, type IMobileSwitchProps, type IMobileTextProps, type IMobileTextareaProps, type IMobileUiAdapters, type INavigationMenu, type INavigationMenuItem, type INavigationPayload, type INavigationResolvedPageRef, type INavigationSearchConfig, type INavigationStartupConfig, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageRoute, type IPageSectionWithFields, type IPageSectionsData, type IPreviewNavigateCommand, type IPreviewNavigatedMessage, type IPreviewPreferences, type IPreviewPreferencesChangedMessage, type IPreviewReadyMessage, type IPreviewSetPreferencesCommand, type IRefreshRequest, type IRefreshSuccessResponse, type IResetPasswordRequest, type IResetPasswordResponse, type IResolvePageResponse, 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 IWebHeaderPresetOption, 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, MOBILE_ICON_NAMES, MOBILE_ICON_SET, MOBILE_PREVIEW_ENDPOINTS, type MobilePreviewRelease, PERMISSIONS, PREVIEW_BRIDGE_MESSAGE, PREVIEW_PARENT_ORIGIN_PARAM, PREVIEW_SHELL_PARAM, 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, TMobileButtonFeedback, TMobileFieldVariant, type TMobilePagePresentation, TMobileSelectPresentation, type TNavigationChildSource, type TNavigationMenuItemType, type TNavigationMenuKey, type TNavigationMobileStartSource, type TNavigationSearchMode, type TNavigationStartMode, type TPermission, type TPlatform, type TPreviewBridgeMessage, type TPreviewBridgeMessageType, type TPreviewColorScheme, type TPreviewFrameSource, TStyleName, type TSystemAdvisorySeverity, type TSystemComponentStatus, type TSystemDeployment, type TSystemHealthOverall, type TUpdateCheckSeverity, type TUpdateKind, type TUpdateOperationStatus, type TUpdatePreflightStatus, type TWebHeaderPreset, type TrustLevel, type TrustedKey, type TrustedKeysFile, type UpdatePreflightResult, WEB_HEADER_PRESET_OPTIONS, WEB_HEADER_PRESET_VALUES, type WorkerRelease, arePreviewPreferencesEqual, buildConditionContext, classifyClass, classifyClassString, collectPageIdsFromMenuItems, evaluateCondition, findMenuItemByPageId, findNearestBottomTabMenuItemForPage, findPageRefInNavigationPayload, findRemap, flattenMenuItems, flattenNavigationMenuItems, getNavigationItemHref, getNavigationItemKeyword, getNavigationItemLabel, hasInlineFormatting, isBottomTabMenuItemActive, isMobileIconName, isOnAnyMobileMenu, isOnAnyMobileMenuFromPayload, isPageInMenuTree, isPageInResolvedMenus, isPageOnAnyMenu, isPageOnMobileMenu, isPageOnWebMenu, isPreviewBridgeMessage, isWebHeaderPreset, pageUrlToMobileRoute, parseInlineRich, parseSpacing, previewKeywordFromPath, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, resolveBranchNavGroup, resolveHolderRedirectPath, resolveMobileIcon, resolveMobilePagePresentation, resolveMobileSegmentGroup, resolveMobileStartupKeyword, resolveMobileStartupRoute, resolveWebBranchNavGroup, resolveWebHeaderPreset, resolveWebStartupPath, searchMenuPagesInPayload, spacingToClasses, stripHtmlToText, transformPageData, transformPagesData };
|
package/dist/index.js
CHANGED
|
@@ -76,6 +76,8 @@ __export(index_exports, {
|
|
|
76
76
|
evaluateCondition: () => evaluateCondition,
|
|
77
77
|
extendStyleRegistry: () => extendStyleRegistry,
|
|
78
78
|
findMenuItemByPageId: () => findMenuItemByPageId,
|
|
79
|
+
findNearestBottomTabMenuItemForPage: () => findNearestBottomTabMenuItemForPage,
|
|
80
|
+
findPageRefInNavigationPayload: () => findPageRefInNavigationPayload,
|
|
79
81
|
findRemap: () => findRemap,
|
|
80
82
|
flattenMenuItems: () => flattenMenuItems,
|
|
81
83
|
flattenNavigationMenuItems: () => flattenNavigationMenuItems,
|
|
@@ -91,6 +93,7 @@ __export(index_exports, {
|
|
|
91
93
|
getStylePluginId: () => getStylePluginId,
|
|
92
94
|
gridSpanToReactNativeColumn: () => gridSpanToReactNativeColumn,
|
|
93
95
|
hasInlineFormatting: () => hasInlineFormatting,
|
|
96
|
+
isBottomTabMenuItemActive: () => isBottomTabMenuItemActive,
|
|
94
97
|
isKnownStyleName: () => isKnownStyleName,
|
|
95
98
|
isMobileIconName: () => isMobileIconName,
|
|
96
99
|
isOnAnyMobileMenu: () => isOnAnyMobileMenu,
|
|
@@ -1634,6 +1637,25 @@ function findMenuItemByPageId(items, pageId) {
|
|
|
1634
1637
|
}
|
|
1635
1638
|
return null;
|
|
1636
1639
|
}
|
|
1640
|
+
function findPageRefInNavigationPayload(payload, pageId) {
|
|
1641
|
+
const menuKeys = [
|
|
1642
|
+
"web_header",
|
|
1643
|
+
"web_footer",
|
|
1644
|
+
"mobile_drawer",
|
|
1645
|
+
"mobile_bottom_tabs"
|
|
1646
|
+
];
|
|
1647
|
+
for (const key of menuKeys) {
|
|
1648
|
+
const menu = payload.menus[key];
|
|
1649
|
+
if (!menu?.items?.length) {
|
|
1650
|
+
continue;
|
|
1651
|
+
}
|
|
1652
|
+
const item = findMenuItemByPageId(menu.items, pageId);
|
|
1653
|
+
if (item?.page) {
|
|
1654
|
+
return item.page;
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
return null;
|
|
1658
|
+
}
|
|
1637
1659
|
|
|
1638
1660
|
// src/navigation/mobileRoute.ts
|
|
1639
1661
|
function pageUrlToMobileRoute(url, keyword) {
|
|
@@ -1785,6 +1807,35 @@ function resolveHolderRedirectPath(payload, currentPageId, platform, hasContent)
|
|
|
1785
1807
|
}
|
|
1786
1808
|
return target.keyword === "home" ? "/" : `/${target.keyword}`;
|
|
1787
1809
|
}
|
|
1810
|
+
function findNearestBottomTabMenuItemForPage(tabs, pageId) {
|
|
1811
|
+
for (const tab of tabs) {
|
|
1812
|
+
if (tab.page?.id === pageId) {
|
|
1813
|
+
return tab;
|
|
1814
|
+
}
|
|
1815
|
+
if (findMenuItemByPageId2(tab.children ?? [], pageId)) {
|
|
1816
|
+
return tab;
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
return null;
|
|
1820
|
+
}
|
|
1821
|
+
function navigationPathMatches(item, pathname) {
|
|
1822
|
+
const href = pageUrlToMobileRoute(item.page?.url ?? null, item.page?.keyword ?? "");
|
|
1823
|
+
if (pathname === href) {
|
|
1824
|
+
return true;
|
|
1825
|
+
}
|
|
1826
|
+
if (href !== "/" && pathname.startsWith(`${href}/`)) {
|
|
1827
|
+
return true;
|
|
1828
|
+
}
|
|
1829
|
+
return false;
|
|
1830
|
+
}
|
|
1831
|
+
function isBottomTabMenuItemActive(item, pathname) {
|
|
1832
|
+
if (navigationPathMatches(item, pathname)) {
|
|
1833
|
+
return true;
|
|
1834
|
+
}
|
|
1835
|
+
return (item.children ?? []).some(
|
|
1836
|
+
(child) => navigationPathMatches(child, pathname) || isBottomTabMenuItemActive(child, pathname)
|
|
1837
|
+
);
|
|
1838
|
+
}
|
|
1788
1839
|
|
|
1789
1840
|
// src/navigation/navLinks.ts
|
|
1790
1841
|
function getNavigationItemLabel(item) {
|
|
@@ -1959,7 +2010,8 @@ function haystacksForItem(item) {
|
|
|
1959
2010
|
}
|
|
1960
2011
|
function searchMenuPagesInPayload(payload, query, limit = 8) {
|
|
1961
2012
|
const needle = query.trim().toLowerCase();
|
|
1962
|
-
|
|
2013
|
+
const minChars = payload.search?.min_chars ?? 2;
|
|
2014
|
+
if (needle === "" || needle.length < minChars) {
|
|
1963
2015
|
return [];
|
|
1964
2016
|
}
|
|
1965
2017
|
const hits = [];
|
|
@@ -2106,6 +2158,8 @@ function transformPagesData(pages) {
|
|
|
2106
2158
|
evaluateCondition,
|
|
2107
2159
|
extendStyleRegistry,
|
|
2108
2160
|
findMenuItemByPageId,
|
|
2161
|
+
findNearestBottomTabMenuItemForPage,
|
|
2162
|
+
findPageRefInNavigationPayload,
|
|
2109
2163
|
findRemap,
|
|
2110
2164
|
flattenMenuItems,
|
|
2111
2165
|
flattenNavigationMenuItems,
|
|
@@ -2121,6 +2175,7 @@ function transformPagesData(pages) {
|
|
|
2121
2175
|
getStylePluginId,
|
|
2122
2176
|
gridSpanToReactNativeColumn,
|
|
2123
2177
|
hasInlineFormatting,
|
|
2178
|
+
isBottomTabMenuItemActive,
|
|
2124
2179
|
isKnownStyleName,
|
|
2125
2180
|
isMobileIconName,
|
|
2126
2181
|
isOnAnyMobileMenu,
|
package/dist/index.mjs
CHANGED
|
@@ -1473,6 +1473,25 @@ function findMenuItemByPageId(items, pageId) {
|
|
|
1473
1473
|
}
|
|
1474
1474
|
return null;
|
|
1475
1475
|
}
|
|
1476
|
+
function findPageRefInNavigationPayload(payload, pageId) {
|
|
1477
|
+
const menuKeys = [
|
|
1478
|
+
"web_header",
|
|
1479
|
+
"web_footer",
|
|
1480
|
+
"mobile_drawer",
|
|
1481
|
+
"mobile_bottom_tabs"
|
|
1482
|
+
];
|
|
1483
|
+
for (const key of menuKeys) {
|
|
1484
|
+
const menu = payload.menus[key];
|
|
1485
|
+
if (!menu?.items?.length) {
|
|
1486
|
+
continue;
|
|
1487
|
+
}
|
|
1488
|
+
const item = findMenuItemByPageId(menu.items, pageId);
|
|
1489
|
+
if (item?.page) {
|
|
1490
|
+
return item.page;
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
return null;
|
|
1494
|
+
}
|
|
1476
1495
|
|
|
1477
1496
|
// src/navigation/mobileRoute.ts
|
|
1478
1497
|
function pageUrlToMobileRoute(url, keyword) {
|
|
@@ -1624,6 +1643,35 @@ function resolveHolderRedirectPath(payload, currentPageId, platform, hasContent)
|
|
|
1624
1643
|
}
|
|
1625
1644
|
return target.keyword === "home" ? "/" : `/${target.keyword}`;
|
|
1626
1645
|
}
|
|
1646
|
+
function findNearestBottomTabMenuItemForPage(tabs, pageId) {
|
|
1647
|
+
for (const tab of tabs) {
|
|
1648
|
+
if (tab.page?.id === pageId) {
|
|
1649
|
+
return tab;
|
|
1650
|
+
}
|
|
1651
|
+
if (findMenuItemByPageId2(tab.children ?? [], pageId)) {
|
|
1652
|
+
return tab;
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
return null;
|
|
1656
|
+
}
|
|
1657
|
+
function navigationPathMatches(item, pathname) {
|
|
1658
|
+
const href = pageUrlToMobileRoute(item.page?.url ?? null, item.page?.keyword ?? "");
|
|
1659
|
+
if (pathname === href) {
|
|
1660
|
+
return true;
|
|
1661
|
+
}
|
|
1662
|
+
if (href !== "/" && pathname.startsWith(`${href}/`)) {
|
|
1663
|
+
return true;
|
|
1664
|
+
}
|
|
1665
|
+
return false;
|
|
1666
|
+
}
|
|
1667
|
+
function isBottomTabMenuItemActive(item, pathname) {
|
|
1668
|
+
if (navigationPathMatches(item, pathname)) {
|
|
1669
|
+
return true;
|
|
1670
|
+
}
|
|
1671
|
+
return (item.children ?? []).some(
|
|
1672
|
+
(child) => navigationPathMatches(child, pathname) || isBottomTabMenuItemActive(child, pathname)
|
|
1673
|
+
);
|
|
1674
|
+
}
|
|
1627
1675
|
|
|
1628
1676
|
// src/navigation/navLinks.ts
|
|
1629
1677
|
function getNavigationItemLabel(item) {
|
|
@@ -1798,7 +1846,8 @@ function haystacksForItem(item) {
|
|
|
1798
1846
|
}
|
|
1799
1847
|
function searchMenuPagesInPayload(payload, query, limit = 8) {
|
|
1800
1848
|
const needle = query.trim().toLowerCase();
|
|
1801
|
-
|
|
1849
|
+
const minChars = payload.search?.min_chars ?? 2;
|
|
1850
|
+
if (needle === "" || needle.length < minChars) {
|
|
1802
1851
|
return [];
|
|
1803
1852
|
}
|
|
1804
1853
|
const hits = [];
|
|
@@ -1944,6 +1993,8 @@ export {
|
|
|
1944
1993
|
evaluateCondition,
|
|
1945
1994
|
extendStyleRegistry,
|
|
1946
1995
|
findMenuItemByPageId,
|
|
1996
|
+
findNearestBottomTabMenuItemForPage,
|
|
1997
|
+
findPageRefInNavigationPayload,
|
|
1947
1998
|
findRemap,
|
|
1948
1999
|
flattenMenuItems,
|
|
1949
2000
|
flattenNavigationMenuItems,
|
|
@@ -1959,6 +2010,7 @@ export {
|
|
|
1959
2010
|
getStylePluginId,
|
|
1960
2011
|
gridSpanToReactNativeColumn,
|
|
1961
2012
|
hasInlineFormatting,
|
|
2013
|
+
isBottomTabMenuItemActive,
|
|
1962
2014
|
isKnownStyleName,
|
|
1963
2015
|
isMobileIconName,
|
|
1964
2016
|
isOnAnyMobileMenu,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@selfhelp/shared",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.1",
|
|
4
4
|
"description": "Shared TypeScript package for SelfHelp web frontend and mobile app: style registry, types, API contracts, Mantine theme tokens, condition + interpolation engines, CMS class allow-list.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,7 +22,10 @@ import {
|
|
|
22
22
|
isPageOnMobileMenu,
|
|
23
23
|
isPageOnWebMenu,
|
|
24
24
|
} from '../menuVisibility';
|
|
25
|
+
import { findPageRefInNavigationPayload } from '../menuMembership';
|
|
25
26
|
import {
|
|
27
|
+
findNearestBottomTabMenuItemForPage,
|
|
28
|
+
isBottomTabMenuItemActive,
|
|
26
29
|
resolveHolderRedirectPath,
|
|
27
30
|
resolveMobileSegmentGroup,
|
|
28
31
|
resolveWebBranchNavGroup,
|
|
@@ -191,4 +194,62 @@ describe('menu search', () => {
|
|
|
191
194
|
expect(hits).toHaveLength(1);
|
|
192
195
|
expect(hits[0]?.keyword).toBe('about');
|
|
193
196
|
});
|
|
197
|
+
|
|
198
|
+
it('honours payload.search.min_chars before returning hits', () => {
|
|
199
|
+
const payload = navigationPayload([
|
|
200
|
+
menuItem({
|
|
201
|
+
id: 1,
|
|
202
|
+
page: { id: 10, keyword: 'about', url: '/about', title: 'About us' },
|
|
203
|
+
}),
|
|
204
|
+
]);
|
|
205
|
+
payload.search.min_chars = 4;
|
|
206
|
+
|
|
207
|
+
expect(searchMenuPagesInPayload(payload, 'abo')).toHaveLength(0);
|
|
208
|
+
expect(searchMenuPagesInPayload(payload, 'about')).toHaveLength(1);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
describe('page ref lookup', () => {
|
|
213
|
+
it('finds resolved page metadata across menu trees', () => {
|
|
214
|
+
const payload = navigationPayload([
|
|
215
|
+
menuItem({
|
|
216
|
+
id: 1,
|
|
217
|
+
page: { id: 42, keyword: 'team', url: '/team', title: 'Team', has_content: false },
|
|
218
|
+
}),
|
|
219
|
+
]);
|
|
220
|
+
const ref = findPageRefInNavigationPayload(payload, 42);
|
|
221
|
+
expect(ref?.keyword).toBe('team');
|
|
222
|
+
expect(ref?.has_content).toBe(false);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
describe('legacy nav-render exports', () => {
|
|
227
|
+
it('does not export removed web/mobile nav render option lists', async () => {
|
|
228
|
+
const mod = await import('../../index');
|
|
229
|
+
expect('WEB_NAV_RENDER_OPTIONS' in mod).toBe(false);
|
|
230
|
+
expect('MOBILE_NAV_RENDER_OPTIONS' in mod).toBe(false);
|
|
231
|
+
expect('TWebNavRender' in mod).toBe(false);
|
|
232
|
+
expect('TMobileNavRender' in mod).toBe(false);
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
describe('bottom tab active state', () => {
|
|
237
|
+
it('marks the nearest ancestor tab active for nested paths', () => {
|
|
238
|
+
const tabs = [
|
|
239
|
+
menuItem({
|
|
240
|
+
id: 1,
|
|
241
|
+
page: { id: 10, keyword: 'team', url: '/team', title: 'Team' },
|
|
242
|
+
children: [
|
|
243
|
+
menuItem({
|
|
244
|
+
id: 2,
|
|
245
|
+
page: { id: 11, keyword: 'alice', url: '/team/alice', title: 'Alice' },
|
|
246
|
+
}),
|
|
247
|
+
],
|
|
248
|
+
}),
|
|
249
|
+
];
|
|
250
|
+
expect(findNearestBottomTabMenuItemForPage(tabs, 11)?.page?.keyword).toBe('team');
|
|
251
|
+
expect(isBottomTabMenuItemActive(tabs[0], '/alice')).toBe(true);
|
|
252
|
+
expect(isBottomTabMenuItemActive(tabs[0], '/team')).toBe(true);
|
|
253
|
+
expect(isBottomTabMenuItemActive(tabs[0], '/other')).toBe(false);
|
|
254
|
+
});
|
|
194
255
|
});
|
|
@@ -214,3 +214,48 @@ export function resolveHolderRedirectPath(
|
|
|
214
214
|
|
|
215
215
|
return target.keyword === 'home' ? '/' : `/${target.keyword}`;
|
|
216
216
|
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Returns the top-level bottom-tab item that owns a nested page, if any.
|
|
220
|
+
*/
|
|
221
|
+
export function findNearestBottomTabMenuItemForPage(
|
|
222
|
+
tabs: INavigationMenuItem[],
|
|
223
|
+
pageId: number,
|
|
224
|
+
): INavigationMenuItem | null {
|
|
225
|
+
for (const tab of tabs) {
|
|
226
|
+
if (tab.page?.id === pageId) {
|
|
227
|
+
return tab;
|
|
228
|
+
}
|
|
229
|
+
if (findMenuItemByPageId(tab.children ?? [], pageId)) {
|
|
230
|
+
return tab;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function navigationPathMatches(item: INavigationMenuItem, pathname: string): boolean {
|
|
238
|
+
const href = pageUrlToMobileRoute(item.page?.url ?? null, item.page?.keyword ?? '');
|
|
239
|
+
if (pathname === href) {
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
if (href !== '/' && pathname.startsWith(`${href}/`)) {
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Active state for a flat bottom-tab item, including descendants on the current path.
|
|
251
|
+
*/
|
|
252
|
+
export function isBottomTabMenuItemActive(item: INavigationMenuItem, pathname: string): boolean {
|
|
253
|
+
if (navigationPathMatches(item, pathname)) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return (item.children ?? []).some(
|
|
258
|
+
(child) => navigationPathMatches(child, pathname)
|
|
259
|
+
|| isBottomTabMenuItemActive(child, pathname),
|
|
260
|
+
);
|
|
261
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
3
|
SPDX-License-Identifier: MPL-2.0
|
|
4
4
|
*/
|
|
5
|
-
import type { INavigationMenu, INavigationMenuItem, TNavigationMenuKey } from './navigationPayload';
|
|
5
|
+
import type { INavigationMenu, INavigationMenuItem, INavigationPayload, INavigationResolvedPageRef, TNavigationMenuKey } from './navigationPayload';
|
|
6
6
|
|
|
7
7
|
function flattenItems(items: INavigationMenuItem[]): INavigationMenuItem[] {
|
|
8
8
|
const out: INavigationMenuItem[] = [];
|
|
@@ -61,3 +61,29 @@ export function findMenuItemByPageId(
|
|
|
61
61
|
}
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
64
|
+
|
|
65
|
+
/** Resolved page metadata from any public menu tree (for holder redirects, etc.). */
|
|
66
|
+
export function findPageRefInNavigationPayload(
|
|
67
|
+
payload: INavigationPayload,
|
|
68
|
+
pageId: number,
|
|
69
|
+
): INavigationResolvedPageRef | null {
|
|
70
|
+
const menuKeys: TNavigationMenuKey[] = [
|
|
71
|
+
'web_header',
|
|
72
|
+
'web_footer',
|
|
73
|
+
'mobile_drawer',
|
|
74
|
+
'mobile_bottom_tabs',
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
for (const key of menuKeys) {
|
|
78
|
+
const menu = payload.menus[key];
|
|
79
|
+
if (!menu?.items?.length) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const item = findMenuItemByPageId(menu.items, pageId);
|
|
83
|
+
if (item?.page) {
|
|
84
|
+
return item.page;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
@@ -32,7 +32,8 @@ export function searchMenuPagesInPayload(
|
|
|
32
32
|
limit = 8,
|
|
33
33
|
): IMenuSearchHit[] {
|
|
34
34
|
const needle = query.trim().toLowerCase();
|
|
35
|
-
|
|
35
|
+
const minChars = payload.search?.min_chars ?? 2;
|
|
36
|
+
if (needle === '' || needle.length < minChars) {
|
|
36
37
|
return [];
|
|
37
38
|
}
|
|
38
39
|
|