@selfhelp/shared 1.21.1 → 1.21.2
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 +10 -0
- package/dist/index.d.mts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +32 -0
- package/dist/index.mjs +29 -0
- package/package.json +1 -1
- package/src/navigation/__tests__/navigation.test.ts +24 -0
- package/src/navigation/index.ts +1 -0
- package/src/navigation/menuDepth.ts +37 -0
- package/src/navigation/navLinks.ts +9 -0
- package/src/navigation/navigationPayload.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,16 @@ 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.2
|
|
13
|
+
|
|
14
|
+
**Menu-builder navigation depth and accessibility (patch)** — additive helpers for
|
|
15
|
+
menu depth limits and item labelling. `resolveMenuMaxDepth` and
|
|
16
|
+
`clampMenuItemsAtDepth` normalise `INavigationMenu.max_depth` (null/0 = unlimited)
|
|
17
|
+
and strip nested children beyond the configured depth for dropdown/mega renderers.
|
|
18
|
+
`getNavigationItemAriaLabel` resolves `aria_label` with a fallback to the visible
|
|
19
|
+
label. `INavigationMenu` gains optional `config` for menu-level presentation
|
|
20
|
+
settings from the backend payload.
|
|
21
|
+
|
|
12
22
|
## v1.21.1
|
|
13
23
|
|
|
14
24
|
**Menu-builder navigation helpers (patch)** — additive navigation utilities for
|
package/dist/index.d.mts
CHANGED
|
@@ -2088,6 +2088,7 @@ interface INavigationMenu {
|
|
|
2088
2088
|
preset?: TWebHeaderPreset | string | null;
|
|
2089
2089
|
max_depth?: number | null;
|
|
2090
2090
|
item_limit?: number | null;
|
|
2091
|
+
config?: Record<string, unknown> | null;
|
|
2091
2092
|
items: INavigationMenuItem[];
|
|
2092
2093
|
}
|
|
2093
2094
|
interface INavigationStartupConfig {
|
|
@@ -2158,6 +2159,7 @@ declare function findNearestBottomTabMenuItemForPage(tabs: INavigationMenuItem[]
|
|
|
2158
2159
|
declare function isBottomTabMenuItemActive(item: INavigationMenuItem, pathname: string): boolean;
|
|
2159
2160
|
|
|
2160
2161
|
declare function getNavigationItemLabel(item: INavigationMenuItem): string;
|
|
2162
|
+
declare function getNavigationItemAriaLabel(item: INavigationMenuItem): string | undefined;
|
|
2161
2163
|
declare function getNavigationItemHref(item: INavigationMenuItem): string;
|
|
2162
2164
|
declare function flattenNavigationMenuItems(items: INavigationMenuItem[]): INavigationMenuItem[];
|
|
2163
2165
|
declare function getNavigationItemKeyword(item: INavigationMenuItem): string | null;
|
|
@@ -2225,6 +2227,21 @@ interface IMenuSearchHit {
|
|
|
2225
2227
|
*/
|
|
2226
2228
|
declare function searchMenuPagesInPayload(payload: INavigationPayload, query: string, limit?: number): IMenuSearchHit[];
|
|
2227
2229
|
|
|
2230
|
+
/**
|
|
2231
|
+
|
|
2232
|
+
* Normalises menu max_depth: null/undefined/0 means unlimited.
|
|
2233
|
+
|
|
2234
|
+
*/
|
|
2235
|
+
declare function resolveMenuMaxDepth(maxDepth: number | null | undefined): number | null;
|
|
2236
|
+
/**
|
|
2237
|
+
|
|
2238
|
+
* Strips nested children beyond the configured depth so renderers do not
|
|
2239
|
+
|
|
2240
|
+
* expand deeper levels in dropdown/mega panels.
|
|
2241
|
+
|
|
2242
|
+
*/
|
|
2243
|
+
declare function clampMenuItemsAtDepth(items: INavigationMenuItem[], maxDepth: number | null, depth?: number): INavigationMenuItem[];
|
|
2244
|
+
|
|
2228
2245
|
/**
|
|
2229
2246
|
* Parse the unified `spacing` field. The CMS
|
|
2230
2247
|
* stores this as a JSON string with optional keys for each side:
|
|
@@ -2289,4 +2306,4 @@ declare function transformPageData(apiPage: IRawPage): IPageItem;
|
|
|
2289
2306
|
*/
|
|
2290
2307
|
declare function transformPagesData(pages: IRawPage[] | null | undefined): IPageItem[];
|
|
2291
2308
|
|
|
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 };
|
|
2309
|
+
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, clampMenuItemsAtDepth, classifyClass, classifyClassString, collectPageIdsFromMenuItems, evaluateCondition, findMenuItemByPageId, findNearestBottomTabMenuItemForPage, findPageRefInNavigationPayload, findRemap, flattenMenuItems, flattenNavigationMenuItems, getNavigationItemAriaLabel, getNavigationItemHref, getNavigationItemKeyword, getNavigationItemLabel, hasInlineFormatting, isBottomTabMenuItemActive, isMobileIconName, isOnAnyMobileMenu, isOnAnyMobileMenuFromPayload, isPageInMenuTree, isPageInResolvedMenus, isPageOnAnyMenu, isPageOnMobileMenu, isPageOnWebMenu, isPreviewBridgeMessage, isWebHeaderPreset, pageUrlToMobileRoute, parseInlineRich, parseSpacing, previewKeywordFromPath, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, resolveBranchNavGroup, resolveHolderRedirectPath, resolveMenuMaxDepth, resolveMobileIcon, resolveMobilePagePresentation, resolveMobileSegmentGroup, resolveMobileStartupKeyword, resolveMobileStartupRoute, resolveWebBranchNavGroup, resolveWebHeaderPreset, resolveWebStartupPath, searchMenuPagesInPayload, spacingToClasses, stripHtmlToText, transformPageData, transformPagesData };
|
package/dist/index.d.ts
CHANGED
|
@@ -2088,6 +2088,7 @@ interface INavigationMenu {
|
|
|
2088
2088
|
preset?: TWebHeaderPreset | string | null;
|
|
2089
2089
|
max_depth?: number | null;
|
|
2090
2090
|
item_limit?: number | null;
|
|
2091
|
+
config?: Record<string, unknown> | null;
|
|
2091
2092
|
items: INavigationMenuItem[];
|
|
2092
2093
|
}
|
|
2093
2094
|
interface INavigationStartupConfig {
|
|
@@ -2158,6 +2159,7 @@ declare function findNearestBottomTabMenuItemForPage(tabs: INavigationMenuItem[]
|
|
|
2158
2159
|
declare function isBottomTabMenuItemActive(item: INavigationMenuItem, pathname: string): boolean;
|
|
2159
2160
|
|
|
2160
2161
|
declare function getNavigationItemLabel(item: INavigationMenuItem): string;
|
|
2162
|
+
declare function getNavigationItemAriaLabel(item: INavigationMenuItem): string | undefined;
|
|
2161
2163
|
declare function getNavigationItemHref(item: INavigationMenuItem): string;
|
|
2162
2164
|
declare function flattenNavigationMenuItems(items: INavigationMenuItem[]): INavigationMenuItem[];
|
|
2163
2165
|
declare function getNavigationItemKeyword(item: INavigationMenuItem): string | null;
|
|
@@ -2225,6 +2227,21 @@ interface IMenuSearchHit {
|
|
|
2225
2227
|
*/
|
|
2226
2228
|
declare function searchMenuPagesInPayload(payload: INavigationPayload, query: string, limit?: number): IMenuSearchHit[];
|
|
2227
2229
|
|
|
2230
|
+
/**
|
|
2231
|
+
|
|
2232
|
+
* Normalises menu max_depth: null/undefined/0 means unlimited.
|
|
2233
|
+
|
|
2234
|
+
*/
|
|
2235
|
+
declare function resolveMenuMaxDepth(maxDepth: number | null | undefined): number | null;
|
|
2236
|
+
/**
|
|
2237
|
+
|
|
2238
|
+
* Strips nested children beyond the configured depth so renderers do not
|
|
2239
|
+
|
|
2240
|
+
* expand deeper levels in dropdown/mega panels.
|
|
2241
|
+
|
|
2242
|
+
*/
|
|
2243
|
+
declare function clampMenuItemsAtDepth(items: INavigationMenuItem[], maxDepth: number | null, depth?: number): INavigationMenuItem[];
|
|
2244
|
+
|
|
2228
2245
|
/**
|
|
2229
2246
|
* Parse the unified `spacing` field. The CMS
|
|
2230
2247
|
* stores this as a JSON string with optional keys for each side:
|
|
@@ -2289,4 +2306,4 @@ declare function transformPageData(apiPage: IRawPage): IPageItem;
|
|
|
2289
2306
|
*/
|
|
2290
2307
|
declare function transformPagesData(pages: IRawPage[] | null | undefined): IPageItem[];
|
|
2291
2308
|
|
|
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 };
|
|
2309
|
+
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, clampMenuItemsAtDepth, classifyClass, classifyClassString, collectPageIdsFromMenuItems, evaluateCondition, findMenuItemByPageId, findNearestBottomTabMenuItemForPage, findPageRefInNavigationPayload, findRemap, flattenMenuItems, flattenNavigationMenuItems, getNavigationItemAriaLabel, getNavigationItemHref, getNavigationItemKeyword, getNavigationItemLabel, hasInlineFormatting, isBottomTabMenuItemActive, isMobileIconName, isOnAnyMobileMenu, isOnAnyMobileMenuFromPayload, isPageInMenuTree, isPageInResolvedMenus, isPageOnAnyMenu, isPageOnMobileMenu, isPageOnWebMenu, isPreviewBridgeMessage, isWebHeaderPreset, pageUrlToMobileRoute, parseInlineRich, parseSpacing, previewKeywordFromPath, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, resolveBranchNavGroup, resolveHolderRedirectPath, resolveMenuMaxDepth, resolveMobileIcon, resolveMobilePagePresentation, resolveMobileSegmentGroup, resolveMobileStartupKeyword, resolveMobileStartupRoute, resolveWebBranchNavGroup, resolveWebHeaderPreset, resolveWebStartupPath, searchMenuPagesInPayload, spacingToClasses, stripHtmlToText, transformPageData, transformPagesData };
|
package/dist/index.js
CHANGED
|
@@ -69,6 +69,7 @@ __export(index_exports, {
|
|
|
69
69
|
_resetPluginStyleRegistry: () => _resetPluginStyleRegistry,
|
|
70
70
|
arePreviewPreferencesEqual: () => arePreviewPreferencesEqual,
|
|
71
71
|
buildConditionContext: () => buildConditionContext,
|
|
72
|
+
clampMenuItemsAtDepth: () => clampMenuItemsAtDepth,
|
|
72
73
|
classifyClass: () => classifyClass,
|
|
73
74
|
classifyClassString: () => classifyClassString,
|
|
74
75
|
collectPageIdsFromMenuItems: () => collectPageIdsFromMenuItems,
|
|
@@ -82,6 +83,7 @@ __export(index_exports, {
|
|
|
82
83
|
flattenMenuItems: () => flattenMenuItems,
|
|
83
84
|
flattenNavigationMenuItems: () => flattenNavigationMenuItems,
|
|
84
85
|
getMergedStyleRegistry: () => getMergedStyleRegistry,
|
|
86
|
+
getNavigationItemAriaLabel: () => getNavigationItemAriaLabel,
|
|
85
87
|
getNavigationItemHref: () => getNavigationItemHref,
|
|
86
88
|
getNavigationItemKeyword: () => getNavigationItemKeyword,
|
|
87
89
|
getNavigationItemLabel: () => getNavigationItemLabel,
|
|
@@ -133,6 +135,7 @@ __export(index_exports, {
|
|
|
133
135
|
resolveBranchNavGroup: () => resolveBranchNavGroup,
|
|
134
136
|
resolveHolderRedirectPath: () => resolveHolderRedirectPath,
|
|
135
137
|
resolveMantineVariant: () => resolveMantineVariant,
|
|
138
|
+
resolveMenuMaxDepth: () => resolveMenuMaxDepth,
|
|
136
139
|
resolveMobileIcon: () => resolveMobileIcon,
|
|
137
140
|
resolveMobilePagePresentation: () => resolveMobilePagePresentation,
|
|
138
141
|
resolveMobileSegmentGroup: () => resolveMobileSegmentGroup,
|
|
@@ -1841,6 +1844,14 @@ function isBottomTabMenuItemActive(item, pathname) {
|
|
|
1841
1844
|
function getNavigationItemLabel(item) {
|
|
1842
1845
|
return item.label || item.page?.title || item.page?.keyword || "";
|
|
1843
1846
|
}
|
|
1847
|
+
function getNavigationItemAriaLabel(item) {
|
|
1848
|
+
const aria = item.aria_label?.trim();
|
|
1849
|
+
if (aria) {
|
|
1850
|
+
return aria;
|
|
1851
|
+
}
|
|
1852
|
+
const label = getNavigationItemLabel(item);
|
|
1853
|
+
return label || void 0;
|
|
1854
|
+
}
|
|
1844
1855
|
function getNavigationItemHref(item) {
|
|
1845
1856
|
if (item.item_type === "external_url" && item.external_url) {
|
|
1846
1857
|
return item.external_url;
|
|
@@ -2043,6 +2054,24 @@ function searchMenuPagesInPayload(payload, query, limit = 8) {
|
|
|
2043
2054
|
return hits;
|
|
2044
2055
|
}
|
|
2045
2056
|
|
|
2057
|
+
// src/navigation/menuDepth.ts
|
|
2058
|
+
function resolveMenuMaxDepth(maxDepth) {
|
|
2059
|
+
if (maxDepth === null || maxDepth === void 0 || maxDepth <= 0) {
|
|
2060
|
+
return null;
|
|
2061
|
+
}
|
|
2062
|
+
return maxDepth;
|
|
2063
|
+
}
|
|
2064
|
+
function clampMenuItemsAtDepth(items, maxDepth, depth = 0) {
|
|
2065
|
+
return items.map((item) => {
|
|
2066
|
+
const atLimit = maxDepth !== null && depth >= maxDepth;
|
|
2067
|
+
const children = item.children ?? [];
|
|
2068
|
+
return {
|
|
2069
|
+
...item,
|
|
2070
|
+
children: atLimit ? [] : clampMenuItemsAtDepth(children, maxDepth, depth + 1)
|
|
2071
|
+
};
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2046
2075
|
// src/utils/spacing.ts
|
|
2047
2076
|
var ALLOWED_KEYS = ["mt", "mb", "ms", "me", "pt", "pb", "ps", "pe"];
|
|
2048
2077
|
function parseSpacing(raw) {
|
|
@@ -2151,6 +2180,7 @@ function transformPagesData(pages) {
|
|
|
2151
2180
|
_resetPluginStyleRegistry,
|
|
2152
2181
|
arePreviewPreferencesEqual,
|
|
2153
2182
|
buildConditionContext,
|
|
2183
|
+
clampMenuItemsAtDepth,
|
|
2154
2184
|
classifyClass,
|
|
2155
2185
|
classifyClassString,
|
|
2156
2186
|
collectPageIdsFromMenuItems,
|
|
@@ -2164,6 +2194,7 @@ function transformPagesData(pages) {
|
|
|
2164
2194
|
flattenMenuItems,
|
|
2165
2195
|
flattenNavigationMenuItems,
|
|
2166
2196
|
getMergedStyleRegistry,
|
|
2197
|
+
getNavigationItemAriaLabel,
|
|
2167
2198
|
getNavigationItemHref,
|
|
2168
2199
|
getNavigationItemKeyword,
|
|
2169
2200
|
getNavigationItemLabel,
|
|
@@ -2215,6 +2246,7 @@ function transformPagesData(pages) {
|
|
|
2215
2246
|
resolveBranchNavGroup,
|
|
2216
2247
|
resolveHolderRedirectPath,
|
|
2217
2248
|
resolveMantineVariant,
|
|
2249
|
+
resolveMenuMaxDepth,
|
|
2218
2250
|
resolveMobileIcon,
|
|
2219
2251
|
resolveMobilePagePresentation,
|
|
2220
2252
|
resolveMobileSegmentGroup,
|
package/dist/index.mjs
CHANGED
|
@@ -1677,6 +1677,14 @@ function isBottomTabMenuItemActive(item, pathname) {
|
|
|
1677
1677
|
function getNavigationItemLabel(item) {
|
|
1678
1678
|
return item.label || item.page?.title || item.page?.keyword || "";
|
|
1679
1679
|
}
|
|
1680
|
+
function getNavigationItemAriaLabel(item) {
|
|
1681
|
+
const aria = item.aria_label?.trim();
|
|
1682
|
+
if (aria) {
|
|
1683
|
+
return aria;
|
|
1684
|
+
}
|
|
1685
|
+
const label = getNavigationItemLabel(item);
|
|
1686
|
+
return label || void 0;
|
|
1687
|
+
}
|
|
1680
1688
|
function getNavigationItemHref(item) {
|
|
1681
1689
|
if (item.item_type === "external_url" && item.external_url) {
|
|
1682
1690
|
return item.external_url;
|
|
@@ -1879,6 +1887,24 @@ function searchMenuPagesInPayload(payload, query, limit = 8) {
|
|
|
1879
1887
|
return hits;
|
|
1880
1888
|
}
|
|
1881
1889
|
|
|
1890
|
+
// src/navigation/menuDepth.ts
|
|
1891
|
+
function resolveMenuMaxDepth(maxDepth) {
|
|
1892
|
+
if (maxDepth === null || maxDepth === void 0 || maxDepth <= 0) {
|
|
1893
|
+
return null;
|
|
1894
|
+
}
|
|
1895
|
+
return maxDepth;
|
|
1896
|
+
}
|
|
1897
|
+
function clampMenuItemsAtDepth(items, maxDepth, depth = 0) {
|
|
1898
|
+
return items.map((item) => {
|
|
1899
|
+
const atLimit = maxDepth !== null && depth >= maxDepth;
|
|
1900
|
+
const children = item.children ?? [];
|
|
1901
|
+
return {
|
|
1902
|
+
...item,
|
|
1903
|
+
children: atLimit ? [] : clampMenuItemsAtDepth(children, maxDepth, depth + 1)
|
|
1904
|
+
};
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1882
1908
|
// src/utils/spacing.ts
|
|
1883
1909
|
var ALLOWED_KEYS = ["mt", "mb", "ms", "me", "pt", "pb", "ps", "pe"];
|
|
1884
1910
|
function parseSpacing(raw) {
|
|
@@ -1986,6 +2012,7 @@ export {
|
|
|
1986
2012
|
_resetPluginStyleRegistry,
|
|
1987
2013
|
arePreviewPreferencesEqual,
|
|
1988
2014
|
buildConditionContext,
|
|
2015
|
+
clampMenuItemsAtDepth,
|
|
1989
2016
|
classifyClass,
|
|
1990
2017
|
classifyClassString,
|
|
1991
2018
|
collectPageIdsFromMenuItems,
|
|
@@ -1999,6 +2026,7 @@ export {
|
|
|
1999
2026
|
flattenMenuItems,
|
|
2000
2027
|
flattenNavigationMenuItems,
|
|
2001
2028
|
getMergedStyleRegistry,
|
|
2029
|
+
getNavigationItemAriaLabel,
|
|
2002
2030
|
getNavigationItemHref,
|
|
2003
2031
|
getNavigationItemKeyword,
|
|
2004
2032
|
getNavigationItemLabel,
|
|
@@ -2050,6 +2078,7 @@ export {
|
|
|
2050
2078
|
resolveBranchNavGroup,
|
|
2051
2079
|
resolveHolderRedirectPath,
|
|
2052
2080
|
resolveMantineVariant,
|
|
2081
|
+
resolveMenuMaxDepth,
|
|
2053
2082
|
resolveMobileIcon,
|
|
2054
2083
|
resolveMobilePagePresentation,
|
|
2055
2084
|
resolveMobileSegmentGroup,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@selfhelp/shared",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.2",
|
|
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",
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
resolveWebBranchNavGroup,
|
|
32
32
|
} from '../branchNav';
|
|
33
33
|
import { searchMenuPagesInPayload } from '../menuSearch';
|
|
34
|
+
import { clampMenuItemsAtDepth, resolveMenuMaxDepth } from '../menuDepth';
|
|
34
35
|
|
|
35
36
|
function menuItem(partial: Partial<INavigationMenuItem>): INavigationMenuItem {
|
|
36
37
|
return {
|
|
@@ -223,6 +224,29 @@ describe('page ref lookup', () => {
|
|
|
223
224
|
});
|
|
224
225
|
});
|
|
225
226
|
|
|
227
|
+
describe('menu depth helpers', () => {
|
|
228
|
+
it('treats null/zero max depth as unlimited', () => {
|
|
229
|
+
expect(resolveMenuMaxDepth(null)).toBeNull();
|
|
230
|
+
expect(resolveMenuMaxDepth(0)).toBeNull();
|
|
231
|
+
expect(resolveMenuMaxDepth(2)).toBe(2);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('strips nested children beyond max depth', () => {
|
|
235
|
+
const nested = menuItem({
|
|
236
|
+
id: 1,
|
|
237
|
+
children: [
|
|
238
|
+
menuItem({
|
|
239
|
+
id: 2,
|
|
240
|
+
children: [menuItem({ id: 3 })],
|
|
241
|
+
}),
|
|
242
|
+
],
|
|
243
|
+
});
|
|
244
|
+
const clamped = clampMenuItemsAtDepth([nested], 1);
|
|
245
|
+
expect(clamped[0]?.children?.length).toBe(1);
|
|
246
|
+
expect(clamped[0]?.children?.[0]?.children?.length).toBe(0);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
226
250
|
describe('legacy nav-render exports', () => {
|
|
227
251
|
it('does not export removed web/mobile nav render option lists', async () => {
|
|
228
252
|
const mod = await import('../../index');
|
package/src/navigation/index.ts
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { INavigationMenuItem } from './navigationPayload';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Normalises menu max_depth: null/undefined/0 means unlimited.
|
|
9
|
+
*/
|
|
10
|
+
export function resolveMenuMaxDepth(maxDepth: number | null | undefined): number | null {
|
|
11
|
+
if (maxDepth === null || maxDepth === undefined || maxDepth <= 0) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return maxDepth;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Strips nested children beyond the configured depth so renderers do not
|
|
20
|
+
* expand deeper levels in dropdown/mega panels.
|
|
21
|
+
*/
|
|
22
|
+
export function clampMenuItemsAtDepth(
|
|
23
|
+
items: INavigationMenuItem[],
|
|
24
|
+
maxDepth: number | null,
|
|
25
|
+
depth = 0,
|
|
26
|
+
): INavigationMenuItem[] {
|
|
27
|
+
return items.map((item) => {
|
|
28
|
+
const atLimit = maxDepth !== null && depth >= maxDepth;
|
|
29
|
+
const children = item.children ?? [];
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
...item,
|
|
33
|
+
children: atLimit ? [] : clampMenuItemsAtDepth(children, maxDepth, depth + 1),
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
@@ -8,6 +8,15 @@ export function getNavigationItemLabel(item: INavigationMenuItem): string {
|
|
|
8
8
|
return item.label || item.page?.title || item.page?.keyword || '';
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export function getNavigationItemAriaLabel(item: INavigationMenuItem): string | undefined {
|
|
12
|
+
const aria = item.aria_label?.trim();
|
|
13
|
+
if (aria) {
|
|
14
|
+
return aria;
|
|
15
|
+
}
|
|
16
|
+
const label = getNavigationItemLabel(item);
|
|
17
|
+
return label || undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
export function getNavigationItemHref(item: INavigationMenuItem): string {
|
|
12
21
|
if (item.item_type === 'external_url' && item.external_url) {
|
|
13
22
|
return item.external_url;
|