@selfhelp/shared 1.20.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 +23 -0
- package/dist/index.d.mts +168 -108
- package/dist/index.d.ts +168 -108
- package/dist/index.js +476 -107
- package/dist/index.mjs +444 -92
- package/package.json +1 -1
- package/src/api/endpoints.ts +8 -0
- package/src/navigation/__tests__/navigation.test.ts +217 -68
- package/src/navigation/__tests__/startup.test.ts +33 -0
- package/src/navigation/branchNav.ts +261 -0
- package/src/navigation/headerPreset.ts +52 -0
- package/src/navigation/index.ts +9 -7
- package/src/navigation/menuMembership.ts +89 -0
- package/src/navigation/menuSearch.ts +69 -0
- package/src/navigation/menuVisibility.ts +24 -25
- package/src/navigation/mobileRoute.ts +20 -0
- package/src/navigation/navLinks.ts +38 -0
- package/src/navigation/navigationPayload.ts +84 -0
- package/src/navigation/startup.ts +87 -0
- package/src/types/api/__tests__/page-routing.test.ts +0 -6
- package/src/types/pages.ts +0 -13
- package/src/utils/__tests__/transformPageData.test.ts +3 -19
- package/src/utils/transformPageData.ts +1 -37
- package/src/navigation/navRender.ts +0 -132
package/dist/index.js
CHANGED
|
@@ -41,11 +41,8 @@ __export(index_exports, {
|
|
|
41
41
|
COLOR_PALETTE: () => COLOR_PALETTE,
|
|
42
42
|
COLOR_SCALES: () => COLOR_SCALES,
|
|
43
43
|
CONTAINER_SIZE_PX: () => CONTAINER_SIZE_PX,
|
|
44
|
-
DEFAULT_MOBILE_GLOBAL_NAV_RENDER: () => DEFAULT_MOBILE_GLOBAL_NAV_RENDER,
|
|
45
44
|
DEFAULT_MOBILE_ICON: () => DEFAULT_MOBILE_ICON,
|
|
46
|
-
|
|
47
|
-
DEFAULT_WEB_GLOBAL_NAV_RENDER: () => DEFAULT_WEB_GLOBAL_NAV_RENDER,
|
|
48
|
-
DEFAULT_WEB_NAV_RENDER: () => DEFAULT_WEB_NAV_RENDER,
|
|
45
|
+
DEFAULT_WEB_HEADER_PRESET: () => DEFAULT_WEB_HEADER_PRESET,
|
|
49
46
|
ENDPOINTS: () => ENDPOINTS,
|
|
50
47
|
FONT_SIZE_PX: () => FONT_SIZE_PX,
|
|
51
48
|
FULL_RADIUS_PX: () => FULL_RADIUS_PX,
|
|
@@ -54,8 +51,6 @@ __export(index_exports, {
|
|
|
54
51
|
LITERAL_CLASSES: () => LITERAL_CLASSES,
|
|
55
52
|
MOBILE_ICON_NAMES: () => MOBILE_ICON_NAMES,
|
|
56
53
|
MOBILE_ICON_SET: () => MOBILE_ICON_SET,
|
|
57
|
-
MOBILE_NAV_RENDER_OPTIONS: () => MOBILE_NAV_RENDER_OPTIONS,
|
|
58
|
-
MOBILE_NAV_RENDER_VALUES: () => MOBILE_NAV_RENDER_VALUES,
|
|
59
54
|
MOBILE_PREVIEW_ENDPOINTS: () => MOBILE_PREVIEW_ENDPOINTS,
|
|
60
55
|
PERMISSIONS: () => PERMISSIONS,
|
|
61
56
|
PREVIEW_BRIDGE_MESSAGE: () => PREVIEW_BRIDGE_MESSAGE,
|
|
@@ -69,19 +64,27 @@ __export(index_exports, {
|
|
|
69
64
|
SPACING_VALUES: () => SPACING_VALUES,
|
|
70
65
|
STYLE_REGISTRY: () => STYLE_REGISTRY,
|
|
71
66
|
SYSTEM_ENDPOINTS: () => SYSTEM_ENDPOINTS,
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
WEB_HEADER_PRESET_OPTIONS: () => WEB_HEADER_PRESET_OPTIONS,
|
|
68
|
+
WEB_HEADER_PRESET_VALUES: () => WEB_HEADER_PRESET_VALUES,
|
|
74
69
|
_resetPluginStyleRegistry: () => _resetPluginStyleRegistry,
|
|
75
70
|
arePreviewPreferencesEqual: () => arePreviewPreferencesEqual,
|
|
76
71
|
buildConditionContext: () => buildConditionContext,
|
|
77
72
|
classifyClass: () => classifyClass,
|
|
78
73
|
classifyClassString: () => classifyClassString,
|
|
74
|
+
collectPageIdsFromMenuItems: () => collectPageIdsFromMenuItems,
|
|
79
75
|
colorToHex: () => colorToHex,
|
|
80
76
|
evaluateCondition: () => evaluateCondition,
|
|
81
77
|
extendStyleRegistry: () => extendStyleRegistry,
|
|
78
|
+
findMenuItemByPageId: () => findMenuItemByPageId,
|
|
79
|
+
findNearestBottomTabMenuItemForPage: () => findNearestBottomTabMenuItemForPage,
|
|
80
|
+
findPageRefInNavigationPayload: () => findPageRefInNavigationPayload,
|
|
82
81
|
findRemap: () => findRemap,
|
|
83
|
-
|
|
82
|
+
flattenMenuItems: () => flattenMenuItems,
|
|
83
|
+
flattenNavigationMenuItems: () => flattenNavigationMenuItems,
|
|
84
84
|
getMergedStyleRegistry: () => getMergedStyleRegistry,
|
|
85
|
+
getNavigationItemHref: () => getNavigationItemHref,
|
|
86
|
+
getNavigationItemKeyword: () => getNavigationItemKeyword,
|
|
87
|
+
getNavigationItemLabel: () => getNavigationItemLabel,
|
|
85
88
|
getPluginStyleRegistry: () => getPluginStyleRegistry,
|
|
86
89
|
getRegistryEntry: () => getRegistryEntry,
|
|
87
90
|
getRegistryEntryAny: () => getRegistryEntryAny,
|
|
@@ -90,17 +93,22 @@ __export(index_exports, {
|
|
|
90
93
|
getStylePluginId: () => getStylePluginId,
|
|
91
94
|
gridSpanToReactNativeColumn: () => gridSpanToReactNativeColumn,
|
|
92
95
|
hasInlineFormatting: () => hasInlineFormatting,
|
|
96
|
+
isBottomTabMenuItemActive: () => isBottomTabMenuItemActive,
|
|
93
97
|
isKnownStyleName: () => isKnownStyleName,
|
|
94
|
-
isMenuVisible: () => isMenuVisible,
|
|
95
98
|
isMobileIconName: () => isMobileIconName,
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
isOnAnyMobileMenu: () => isOnAnyMobileMenu,
|
|
100
|
+
isOnAnyMobileMenuFromPayload: () => isOnAnyMobileMenuFromPayload,
|
|
101
|
+
isPageInMenuTree: () => isPageInMenuTree,
|
|
102
|
+
isPageInResolvedMenus: () => isPageInResolvedMenus,
|
|
103
|
+
isPageOnAnyMenu: () => isPageOnAnyMenu,
|
|
104
|
+
isPageOnMobileMenu: () => isPageOnMobileMenu,
|
|
105
|
+
isPageOnWebMenu: () => isPageOnWebMenu,
|
|
98
106
|
isPreviewBridgeMessage: () => isPreviewBridgeMessage,
|
|
99
107
|
isRegisteredStyleName: () => isRegisteredStyleName,
|
|
100
108
|
isStyleAllowedOnPage: () => isStyleAllowedOnPage,
|
|
101
109
|
isStylePlacementAllowed: () => isStylePlacementAllowed,
|
|
102
110
|
isStyleSupportedOnPlatform: () => isStyleSupportedOnPlatform,
|
|
103
|
-
|
|
111
|
+
isWebHeaderPreset: () => isWebHeaderPreset,
|
|
104
112
|
mapAccordionVariantToHeroUiVariant: () => mapAccordionVariantToHeroUiVariant,
|
|
105
113
|
mapChipVariantToHeroUiVariant: () => mapChipVariantToHeroUiVariant,
|
|
106
114
|
mapDividerVariantToReactNative: () => mapDividerVariantToReactNative,
|
|
@@ -112,6 +120,7 @@ __export(index_exports, {
|
|
|
112
120
|
mapSizeToHeroUi: () => mapSizeToHeroUi,
|
|
113
121
|
mapSizeToMantine: () => mapSizeToMantine,
|
|
114
122
|
mapSpacingToPx: () => mapSpacingToPx,
|
|
123
|
+
pageUrlToMobileRoute: () => pageUrlToMobileRoute,
|
|
115
124
|
parseDimensionToReactNative: () => parseDimensionToReactNative,
|
|
116
125
|
parseDimensionToWeb: () => parseDimensionToWeb,
|
|
117
126
|
parseInlineRich: () => parseInlineRich,
|
|
@@ -121,14 +130,22 @@ __export(index_exports, {
|
|
|
121
130
|
replaceCalcedValues: () => replaceCalcedValues,
|
|
122
131
|
resolveAssetSources: () => resolveAssetSources,
|
|
123
132
|
resolveAssetUrl: () => resolveAssetUrl,
|
|
133
|
+
resolveBranchNavGroup: () => resolveBranchNavGroup,
|
|
134
|
+
resolveHolderRedirectPath: () => resolveHolderRedirectPath,
|
|
124
135
|
resolveMantineVariant: () => resolveMantineVariant,
|
|
125
136
|
resolveMobileIcon: () => resolveMobileIcon,
|
|
126
|
-
|
|
137
|
+
resolveMobilePagePresentation: () => resolveMobilePagePresentation,
|
|
138
|
+
resolveMobileSegmentGroup: () => resolveMobileSegmentGroup,
|
|
139
|
+
resolveMobileStartupKeyword: () => resolveMobileStartupKeyword,
|
|
140
|
+
resolveMobileStartupRoute: () => resolveMobileStartupRoute,
|
|
127
141
|
resolveSharedStyle: () => resolveSharedStyle,
|
|
128
142
|
resolveSharedStyleForMobile: () => resolveSharedStyleForMobile,
|
|
129
143
|
resolveSharedStyleForWeb: () => resolveSharedStyleForWeb,
|
|
130
144
|
resolveSharedStyleProps: () => resolveSharedStyleProps,
|
|
131
|
-
|
|
145
|
+
resolveWebBranchNavGroup: () => resolveWebBranchNavGroup,
|
|
146
|
+
resolveWebHeaderPreset: () => resolveWebHeaderPreset,
|
|
147
|
+
resolveWebStartupPath: () => resolveWebStartupPath,
|
|
148
|
+
searchMenuPagesInPayload: () => searchMenuPagesInPayload,
|
|
132
149
|
setToStylePlatform: () => setToStylePlatform,
|
|
133
150
|
sharedTailwindExtend: () => sharedTailwindExtend,
|
|
134
151
|
sharedTailwindPreset: () => sharedTailwindPreset,
|
|
@@ -546,6 +563,14 @@ var ENDPOINTS = {
|
|
|
546
563
|
*/
|
|
547
564
|
RESOLVE: (path) => `${API_VERSION_PREFIX}/pages/resolve?path=${encodeURIComponent(path)}`
|
|
548
565
|
},
|
|
566
|
+
NAVIGATION: {
|
|
567
|
+
GET: `${API_VERSION_PREFIX}/navigation`,
|
|
568
|
+
LAST_VISITED: `${API_VERSION_PREFIX}/navigation/last-visited`
|
|
569
|
+
},
|
|
570
|
+
SEARCH: {
|
|
571
|
+
CONTENT: `${API_VERSION_PREFIX}/search`,
|
|
572
|
+
PAGES: `${API_VERSION_PREFIX}/search/pages`
|
|
573
|
+
},
|
|
549
574
|
LANGUAGES: `${API_VERSION_PREFIX}/languages`,
|
|
550
575
|
FORMS: {
|
|
551
576
|
SUBMIT: `${API_VERSION_PREFIX}/forms/submit`,
|
|
@@ -1544,78 +1569,327 @@ function stripHtmlToText(value) {
|
|
|
1544
1569
|
return out.replace(/\s+/g, " ").trim();
|
|
1545
1570
|
}
|
|
1546
1571
|
|
|
1547
|
-
// src/navigation/
|
|
1548
|
-
var
|
|
1549
|
-
"
|
|
1572
|
+
// src/navigation/headerPreset.ts
|
|
1573
|
+
var WEB_HEADER_PRESET_VALUES = [
|
|
1574
|
+
"simple",
|
|
1575
|
+
"dropdown",
|
|
1576
|
+
"mega-menu",
|
|
1550
1577
|
"tabs",
|
|
1551
|
-
"
|
|
1552
|
-
"
|
|
1578
|
+
"double-dropdown",
|
|
1579
|
+
"double-mega-menu"
|
|
1553
1580
|
];
|
|
1554
|
-
var
|
|
1555
|
-
|
|
1556
|
-
"
|
|
1557
|
-
"
|
|
1558
|
-
"
|
|
1581
|
+
var DEFAULT_WEB_HEADER_PRESET = "dropdown";
|
|
1582
|
+
var WEB_HEADER_PRESET_OPTIONS = [
|
|
1583
|
+
{ value: "simple", label: "Simple", description: "Flat header links for small sites." },
|
|
1584
|
+
{ value: "dropdown", label: "Dropdown", description: "Default \u2014 nested dropdown menus." },
|
|
1585
|
+
{ value: "mega-menu", label: "Mega menu", description: "Rich sections with descriptions and icons." },
|
|
1586
|
+
{ value: "tabs", label: "Tabs", description: "Top-level sections as tabs." },
|
|
1587
|
+
{ value: "double-dropdown", label: "Double header (dropdown)", description: "Utility row plus main dropdown nav." },
|
|
1588
|
+
{ value: "double-mega-menu", label: "Double header (mega menu)", description: "Utility row plus mega menu." }
|
|
1559
1589
|
];
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
{
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
{
|
|
1576
|
-
value: "sidebar-drawer",
|
|
1577
|
-
label: "Sidebar drawer",
|
|
1578
|
-
description: "Side drawer / hamburger menu. Best for large or deep navigation."
|
|
1579
|
-
},
|
|
1580
|
-
{
|
|
1581
|
-
value: "hero-cards",
|
|
1582
|
-
label: "Hero cards",
|
|
1583
|
-
description: "Dashboard-style card grid. Best for landing pages and CMS app dashboards."
|
|
1590
|
+
function isWebHeaderPreset(value) {
|
|
1591
|
+
return typeof value === "string" && WEB_HEADER_PRESET_VALUES.includes(value);
|
|
1592
|
+
}
|
|
1593
|
+
function resolveWebHeaderPreset(value, fallback = DEFAULT_WEB_HEADER_PRESET) {
|
|
1594
|
+
return isWebHeaderPreset(value) ? value : fallback;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
// src/navigation/menuMembership.ts
|
|
1598
|
+
function flattenItems(items) {
|
|
1599
|
+
const out = [];
|
|
1600
|
+
for (const item of items) {
|
|
1601
|
+
out.push(item);
|
|
1602
|
+
if (item.children?.length) {
|
|
1603
|
+
out.push(...flattenItems(item.children));
|
|
1604
|
+
}
|
|
1584
1605
|
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
value: "bottom-tabs",
|
|
1594
|
-
label: "Bottom tabs",
|
|
1595
|
-
description: "Bottom tab bar for 3\u20135 main app-like destinations."
|
|
1596
|
-
},
|
|
1597
|
-
{
|
|
1598
|
-
value: "drawer",
|
|
1599
|
-
label: "Drawer",
|
|
1600
|
-
description: "Hamburger / side drawer for larger navigation."
|
|
1601
|
-
},
|
|
1602
|
-
{
|
|
1603
|
-
value: "hero-cards",
|
|
1604
|
-
label: "Hero cards",
|
|
1605
|
-
description: "Card grid for dashboards and CMS app pages."
|
|
1606
|
+
return out;
|
|
1607
|
+
}
|
|
1608
|
+
function collectPageIdsFromMenuItems(items) {
|
|
1609
|
+
const ids = /* @__PURE__ */ new Set();
|
|
1610
|
+
for (const item of flattenItems(items)) {
|
|
1611
|
+
if (item.page?.id != null) {
|
|
1612
|
+
ids.add(item.page.id);
|
|
1613
|
+
}
|
|
1606
1614
|
}
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1615
|
+
return ids;
|
|
1616
|
+
}
|
|
1617
|
+
function isPageInMenuTree(items, pageId) {
|
|
1618
|
+
return collectPageIdsFromMenuItems(items).has(pageId);
|
|
1619
|
+
}
|
|
1620
|
+
function isPageInResolvedMenus(menus, menuKeys, pageId) {
|
|
1621
|
+
for (const key of menuKeys) {
|
|
1622
|
+
const menu = menus[key];
|
|
1623
|
+
if (menu && isPageInMenuTree(menu.items, pageId)) {
|
|
1624
|
+
return true;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
return false;
|
|
1628
|
+
}
|
|
1629
|
+
function isOnAnyMobileMenu(menus, pageId) {
|
|
1630
|
+
return isPageInResolvedMenus(menus, ["mobile_drawer", "mobile_bottom_tabs"], pageId);
|
|
1631
|
+
}
|
|
1632
|
+
function findMenuItemByPageId(items, pageId) {
|
|
1633
|
+
for (const item of flattenItems(items)) {
|
|
1634
|
+
if (item.page?.id === pageId) {
|
|
1635
|
+
return item;
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
return null;
|
|
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
|
+
}
|
|
1659
|
+
|
|
1660
|
+
// src/navigation/mobileRoute.ts
|
|
1661
|
+
function pageUrlToMobileRoute(url, keyword) {
|
|
1662
|
+
const normalizedKeyword = keyword.trim().toLowerCase();
|
|
1663
|
+
if (normalizedKeyword === "profile") {
|
|
1664
|
+
return "/profile";
|
|
1665
|
+
}
|
|
1666
|
+
if (normalizedKeyword === "home" || url === "/" || url === "" || url == null) {
|
|
1667
|
+
return "/index";
|
|
1668
|
+
}
|
|
1669
|
+
return `/${normalizedKeyword}`;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
// src/navigation/branchNav.ts
|
|
1673
|
+
function itemLabel(item) {
|
|
1674
|
+
return item.label || item.page?.title || item.page?.keyword || "";
|
|
1675
|
+
}
|
|
1676
|
+
function toSegment(item) {
|
|
1677
|
+
if (!item.page) {
|
|
1678
|
+
return null;
|
|
1679
|
+
}
|
|
1680
|
+
return {
|
|
1681
|
+
pageId: item.page.id,
|
|
1682
|
+
keyword: item.page.keyword,
|
|
1683
|
+
url: item.page.url,
|
|
1684
|
+
label: itemLabel(item),
|
|
1685
|
+
icon: item.icon ?? item.page.icon,
|
|
1686
|
+
mobile_icon: item.page.mobile_icon
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
function findParentItem(items, pageId, parent = null) {
|
|
1690
|
+
for (const item of items) {
|
|
1691
|
+
if (item.page?.id === pageId) {
|
|
1692
|
+
return { parent, siblings: items };
|
|
1693
|
+
}
|
|
1694
|
+
if (item.children?.length) {
|
|
1695
|
+
const found = findParentItem(item.children, pageId, item);
|
|
1696
|
+
if (found) {
|
|
1697
|
+
return found;
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
return null;
|
|
1702
|
+
}
|
|
1703
|
+
function menuVisibleChildItems(item) {
|
|
1704
|
+
return (item.children ?? []).filter((child) => child.page != null && child.is_active !== false);
|
|
1705
|
+
}
|
|
1706
|
+
function findMenuItemByPageId2(items, pageId) {
|
|
1707
|
+
for (const item of items) {
|
|
1708
|
+
if (item.page?.id === pageId) {
|
|
1709
|
+
return item;
|
|
1710
|
+
}
|
|
1711
|
+
if (item.children?.length) {
|
|
1712
|
+
const nested = findMenuItemByPageId2(item.children, pageId);
|
|
1713
|
+
if (nested) {
|
|
1714
|
+
return nested;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
return null;
|
|
1719
|
+
}
|
|
1720
|
+
function selfSegment(item) {
|
|
1721
|
+
return toSegment(item);
|
|
1722
|
+
}
|
|
1723
|
+
function resolveBranchNavGroup(payload, currentPageId, menuKeys) {
|
|
1724
|
+
const allItems = [];
|
|
1725
|
+
for (const key of menuKeys) {
|
|
1726
|
+
const menu = payload.menus[key];
|
|
1727
|
+
if (menu?.items) {
|
|
1728
|
+
allItems.push(...menu.items);
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
for (const root of allItems) {
|
|
1732
|
+
const selfChildren = menuVisibleChildItems(root);
|
|
1733
|
+
if (root.page?.id === currentPageId && selfChildren.length > 0) {
|
|
1734
|
+
const segments = selfChildren.map(toSegment).filter((s) => s != null);
|
|
1735
|
+
return segments.length > 0 ? segments : null;
|
|
1736
|
+
}
|
|
1737
|
+
const located = findParentItem([root], currentPageId);
|
|
1738
|
+
if (located) {
|
|
1739
|
+
const directChildren = menuVisibleChildItems(
|
|
1740
|
+
located.parent ?? { id: 0, item_type: "group", label: "", position: 0, children: located.siblings }
|
|
1741
|
+
);
|
|
1742
|
+
if (located.parent && located.parent.page?.id === currentPageId && directChildren.length > 0) {
|
|
1743
|
+
const segments = directChildren.map(toSegment).filter((s) => s != null);
|
|
1744
|
+
return segments.length > 0 ? segments : null;
|
|
1745
|
+
}
|
|
1746
|
+
const siblings = located.siblings.filter((s) => s.page != null && s.is_active !== false);
|
|
1747
|
+
if (siblings.length > 1) {
|
|
1748
|
+
const segments = siblings.map(toSegment).filter((s) => s != null);
|
|
1749
|
+
return segments.length > 0 ? segments : null;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
return null;
|
|
1754
|
+
}
|
|
1755
|
+
function resolveMobileSegmentGroup(payload, currentPageId) {
|
|
1756
|
+
const allItems = [];
|
|
1757
|
+
for (const key of ["mobile_drawer", "mobile_bottom_tabs"]) {
|
|
1758
|
+
const menu = payload.menus[key];
|
|
1759
|
+
if (menu?.items) {
|
|
1760
|
+
allItems.push(...menu.items);
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
const currentItem = findMenuItemByPageId2(allItems, currentPageId);
|
|
1764
|
+
if (currentItem) {
|
|
1765
|
+
const selfChildren = menuVisibleChildItems(currentItem);
|
|
1766
|
+
if (selfChildren.length > 0) {
|
|
1767
|
+
const childSegments = selfChildren.map(toSegment).filter((segment) => segment != null);
|
|
1768
|
+
if (childSegments.length > 0) {
|
|
1769
|
+
if (currentItem.page?.has_content) {
|
|
1770
|
+
const self = selfSegment(currentItem);
|
|
1771
|
+
return self ? [self, ...childSegments] : childSegments;
|
|
1772
|
+
}
|
|
1773
|
+
return childSegments;
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
return resolveBranchNavGroup(payload, currentPageId, ["mobile_drawer", "mobile_bottom_tabs"]);
|
|
1778
|
+
}
|
|
1779
|
+
function resolveWebBranchNavGroup(payload, currentPageId) {
|
|
1780
|
+
return resolveBranchNavGroup(payload, currentPageId, ["web_header", "web_footer"]);
|
|
1610
1781
|
}
|
|
1611
|
-
function
|
|
1612
|
-
return
|
|
1782
|
+
function resolveMobilePagePresentation(payload, pageId) {
|
|
1783
|
+
return isOnAnyMobileMenuFromPayload(payload, pageId) ? "route" : "modal";
|
|
1613
1784
|
}
|
|
1614
|
-
function
|
|
1615
|
-
|
|
1785
|
+
function isOnAnyMobileMenuFromPayload(payload, pageId) {
|
|
1786
|
+
const drawerIds = collectPageIdsFromMenuItems(payload.menus.mobile_drawer?.items ?? []);
|
|
1787
|
+
const tabIds = collectPageIdsFromMenuItems(payload.menus.mobile_bottom_tabs?.items ?? []);
|
|
1788
|
+
return drawerIds.has(pageId) || tabIds.has(pageId);
|
|
1616
1789
|
}
|
|
1617
|
-
function
|
|
1618
|
-
|
|
1790
|
+
function resolveHolderRedirectPath(payload, currentPageId, platform, hasContent) {
|
|
1791
|
+
if (hasContent) {
|
|
1792
|
+
return null;
|
|
1793
|
+
}
|
|
1794
|
+
const segments = platform === "mobile" ? resolveMobileSegmentGroup(payload, currentPageId) : resolveWebBranchNavGroup(payload, currentPageId);
|
|
1795
|
+
if (!segments || segments.length === 0) {
|
|
1796
|
+
return null;
|
|
1797
|
+
}
|
|
1798
|
+
const target = segments.find((segment) => segment.pageId !== currentPageId) ?? segments[0];
|
|
1799
|
+
if (target.pageId === currentPageId) {
|
|
1800
|
+
return null;
|
|
1801
|
+
}
|
|
1802
|
+
if (platform === "mobile") {
|
|
1803
|
+
return pageUrlToMobileRoute(target.url, target.keyword);
|
|
1804
|
+
}
|
|
1805
|
+
if (target.url && target.url !== "") {
|
|
1806
|
+
return target.url.startsWith("/") ? target.url : `/${target.url}`;
|
|
1807
|
+
}
|
|
1808
|
+
return target.keyword === "home" ? "/" : `/${target.keyword}`;
|
|
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
|
+
}
|
|
1839
|
+
|
|
1840
|
+
// src/navigation/navLinks.ts
|
|
1841
|
+
function getNavigationItemLabel(item) {
|
|
1842
|
+
return item.label || item.page?.title || item.page?.keyword || "";
|
|
1843
|
+
}
|
|
1844
|
+
function getNavigationItemHref(item) {
|
|
1845
|
+
if (item.item_type === "external_url" && item.external_url) {
|
|
1846
|
+
return item.external_url;
|
|
1847
|
+
}
|
|
1848
|
+
const page = item.page;
|
|
1849
|
+
if (!page) {
|
|
1850
|
+
return "#";
|
|
1851
|
+
}
|
|
1852
|
+
if (page.url) {
|
|
1853
|
+
return page.url;
|
|
1854
|
+
}
|
|
1855
|
+
return page.keyword === "home" ? "/" : `/${page.keyword}`;
|
|
1856
|
+
}
|
|
1857
|
+
function flattenNavigationMenuItems(items) {
|
|
1858
|
+
const out = [];
|
|
1859
|
+
for (const item of items) {
|
|
1860
|
+
out.push(item);
|
|
1861
|
+
if (item.children?.length) {
|
|
1862
|
+
out.push(...flattenNavigationMenuItems(item.children));
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
return out;
|
|
1866
|
+
}
|
|
1867
|
+
function getNavigationItemKeyword(item) {
|
|
1868
|
+
return item.page?.keyword ?? null;
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
// src/navigation/menuVisibility.ts
|
|
1872
|
+
var WEB_MENU_KEYS = ["web_header", "web_footer"];
|
|
1873
|
+
var MOBILE_MENU_KEYS = ["mobile_drawer", "mobile_bottom_tabs"];
|
|
1874
|
+
var ALL_MENU_KEYS = [...WEB_MENU_KEYS, ...MOBILE_MENU_KEYS];
|
|
1875
|
+
function isPageOnAnyMenu(payload, pageId) {
|
|
1876
|
+
return isPageInResolvedMenus(payload.menus, ALL_MENU_KEYS, pageId);
|
|
1877
|
+
}
|
|
1878
|
+
function isPageOnWebMenu(payload, pageId) {
|
|
1879
|
+
return isPageInResolvedMenus(payload.menus, WEB_MENU_KEYS, pageId);
|
|
1880
|
+
}
|
|
1881
|
+
function isPageOnMobileMenu(payload, pageId) {
|
|
1882
|
+
return isPageInResolvedMenus(payload.menus, MOBILE_MENU_KEYS, pageId);
|
|
1883
|
+
}
|
|
1884
|
+
function flattenMenuItems(items) {
|
|
1885
|
+
const out = [];
|
|
1886
|
+
for (const item of items) {
|
|
1887
|
+
out.push(item);
|
|
1888
|
+
if (item.children?.length) {
|
|
1889
|
+
out.push(...flattenMenuItems(item.children));
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
return out;
|
|
1619
1893
|
}
|
|
1620
1894
|
|
|
1621
1895
|
// src/navigation/mobileIcons.ts
|
|
@@ -1674,17 +1948,99 @@ function resolveMobileIcon(value) {
|
|
|
1674
1948
|
return isMobileIconName(value) ? value : DEFAULT_MOBILE_ICON;
|
|
1675
1949
|
}
|
|
1676
1950
|
|
|
1677
|
-
// src/navigation/
|
|
1678
|
-
function
|
|
1679
|
-
|
|
1680
|
-
|
|
1951
|
+
// src/navigation/startup.ts
|
|
1952
|
+
function pickStartPage(startup, isLoggedIn, platform) {
|
|
1953
|
+
const useMobileCustom = startup.mobile_start_page_source === "custom_mobile_pages";
|
|
1954
|
+
if (isLoggedIn) {
|
|
1955
|
+
const lastVisited = platform === "mobile" ? startup.mobile_user_last_visited_page : startup.web_user_last_visited_page;
|
|
1956
|
+
const startMode = platform === "mobile" ? startup.mobile_user_start_mode : startup.web_user_start_mode;
|
|
1957
|
+
if (startMode === "last_visited_then_fixed_page" && lastVisited) {
|
|
1958
|
+
return lastVisited;
|
|
1959
|
+
}
|
|
1960
|
+
if (platform === "mobile" && useMobileCustom) {
|
|
1961
|
+
return startup.mobile_user_start_page;
|
|
1962
|
+
}
|
|
1963
|
+
if (platform === "mobile") {
|
|
1964
|
+
return startup.mobile_user_start_page ?? startup.web_user_start_page;
|
|
1965
|
+
}
|
|
1966
|
+
return startup.web_user_start_page;
|
|
1967
|
+
}
|
|
1968
|
+
if (platform === "mobile" && useMobileCustom) {
|
|
1969
|
+
return startup.mobile_guest_start_page;
|
|
1970
|
+
}
|
|
1971
|
+
if (platform === "mobile") {
|
|
1972
|
+
return startup.mobile_guest_start_page ?? startup.web_guest_start_page;
|
|
1973
|
+
}
|
|
1974
|
+
return startup.web_guest_start_page;
|
|
1681
1975
|
}
|
|
1682
|
-
function
|
|
1683
|
-
const
|
|
1684
|
-
|
|
1976
|
+
function resolveMobileStartupRoute(startup, isLoggedIn) {
|
|
1977
|
+
const page = pickStartPage(startup, isLoggedIn, "mobile");
|
|
1978
|
+
if (!page) {
|
|
1979
|
+
return "/index";
|
|
1980
|
+
}
|
|
1981
|
+
return pageUrlToMobileRoute(page.url, page.keyword);
|
|
1982
|
+
}
|
|
1983
|
+
function resolveMobileStartupKeyword(startup, isLoggedIn) {
|
|
1984
|
+
const page = pickStartPage(startup, isLoggedIn, "mobile");
|
|
1985
|
+
return page?.keyword ?? "home";
|
|
1986
|
+
}
|
|
1987
|
+
function resolveWebStartupPath(startup, isLoggedIn) {
|
|
1988
|
+
const page = pickStartPage(startup, isLoggedIn, "web");
|
|
1989
|
+
if (!page) {
|
|
1990
|
+
return null;
|
|
1991
|
+
}
|
|
1992
|
+
if (page.url && page.url !== "") {
|
|
1993
|
+
return page.url.startsWith("/") ? page.url : `/${page.url}`;
|
|
1994
|
+
}
|
|
1995
|
+
if (page.keyword === "home") {
|
|
1996
|
+
return "/";
|
|
1997
|
+
}
|
|
1998
|
+
return `/${page.keyword}`;
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
// src/navigation/menuSearch.ts
|
|
2002
|
+
function haystacksForItem(item) {
|
|
2003
|
+
const page = item.page;
|
|
2004
|
+
const label = getNavigationItemLabel(item);
|
|
2005
|
+
const values = [label];
|
|
2006
|
+
if (page) {
|
|
2007
|
+
values.push(page.title ?? "", page.keyword ?? "", page.url ?? "");
|
|
2008
|
+
}
|
|
2009
|
+
return values.map((value) => value.trim().toLowerCase()).filter((value) => value !== "");
|
|
1685
2010
|
}
|
|
1686
|
-
function
|
|
1687
|
-
|
|
2011
|
+
function searchMenuPagesInPayload(payload, query, limit = 8) {
|
|
2012
|
+
const needle = query.trim().toLowerCase();
|
|
2013
|
+
const minChars = payload.search?.min_chars ?? 2;
|
|
2014
|
+
if (needle === "" || needle.length < minChars) {
|
|
2015
|
+
return [];
|
|
2016
|
+
}
|
|
2017
|
+
const hits = [];
|
|
2018
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2019
|
+
for (const menu of Object.values(payload.menus)) {
|
|
2020
|
+
if (!menu?.items?.length) {
|
|
2021
|
+
continue;
|
|
2022
|
+
}
|
|
2023
|
+
for (const item of flattenMenuItems(menu.items)) {
|
|
2024
|
+
if (!item.page || seen.has(item.page.id)) {
|
|
2025
|
+
continue;
|
|
2026
|
+
}
|
|
2027
|
+
const matched = haystacksForItem(item).some((haystack) => haystack.includes(needle));
|
|
2028
|
+
if (!matched) {
|
|
2029
|
+
continue;
|
|
2030
|
+
}
|
|
2031
|
+
seen.add(item.page.id);
|
|
2032
|
+
hits.push({
|
|
2033
|
+
page_id: item.page.id,
|
|
2034
|
+
keyword: item.page.keyword,
|
|
2035
|
+
url: getNavigationItemHref(item),
|
|
2036
|
+
title: getNavigationItemLabel(item)
|
|
2037
|
+
});
|
|
2038
|
+
if (hits.length >= limit) {
|
|
2039
|
+
return hits;
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
return hits;
|
|
1688
2044
|
}
|
|
1689
2045
|
|
|
1690
2046
|
// src/utils/spacing.ts
|
|
@@ -1734,15 +2090,11 @@ function transformPageData(apiPage) {
|
|
|
1734
2090
|
url: apiPage.url ?? null,
|
|
1735
2091
|
parent_page_id: parentPageId,
|
|
1736
2092
|
is_headless: toBool(apiPage.is_headless),
|
|
1737
|
-
navPosition: apiPage.navPosition !== void 0 ? apiPage.navPosition : apiPage.nav_position ?? null,
|
|
1738
|
-
footerPosition: apiPage.footerPosition !== void 0 ? apiPage.footerPosition : apiPage.footer_position ?? null,
|
|
1739
2093
|
is_system: apiPage.is_system !== void 0 ? toBool(apiPage.is_system) : void 0,
|
|
1740
2094
|
title: apiPage.title ?? null,
|
|
1741
2095
|
description: apiPage.description ?? null,
|
|
1742
2096
|
icon: apiPage.icon ?? null,
|
|
1743
2097
|
mobile_icon: apiPage.mobile_icon ?? null,
|
|
1744
|
-
web_nav_render: apiPage.web_nav_render ?? null,
|
|
1745
|
-
mobile_nav_render: apiPage.mobile_nav_render ?? null,
|
|
1746
2098
|
children: apiPage.children?.map(transformPageData) ?? [],
|
|
1747
2099
|
id_users: apiPage.id_users,
|
|
1748
2100
|
id_pages: apiPage.id_pages ?? id,
|
|
@@ -1771,11 +2123,8 @@ function transformPagesData(pages) {
|
|
|
1771
2123
|
COLOR_PALETTE,
|
|
1772
2124
|
COLOR_SCALES,
|
|
1773
2125
|
CONTAINER_SIZE_PX,
|
|
1774
|
-
DEFAULT_MOBILE_GLOBAL_NAV_RENDER,
|
|
1775
2126
|
DEFAULT_MOBILE_ICON,
|
|
1776
|
-
|
|
1777
|
-
DEFAULT_WEB_GLOBAL_NAV_RENDER,
|
|
1778
|
-
DEFAULT_WEB_NAV_RENDER,
|
|
2127
|
+
DEFAULT_WEB_HEADER_PRESET,
|
|
1779
2128
|
ENDPOINTS,
|
|
1780
2129
|
FONT_SIZE_PX,
|
|
1781
2130
|
FULL_RADIUS_PX,
|
|
@@ -1784,8 +2133,6 @@ function transformPagesData(pages) {
|
|
|
1784
2133
|
LITERAL_CLASSES,
|
|
1785
2134
|
MOBILE_ICON_NAMES,
|
|
1786
2135
|
MOBILE_ICON_SET,
|
|
1787
|
-
MOBILE_NAV_RENDER_OPTIONS,
|
|
1788
|
-
MOBILE_NAV_RENDER_VALUES,
|
|
1789
2136
|
MOBILE_PREVIEW_ENDPOINTS,
|
|
1790
2137
|
PERMISSIONS,
|
|
1791
2138
|
PREVIEW_BRIDGE_MESSAGE,
|
|
@@ -1799,19 +2146,27 @@ function transformPagesData(pages) {
|
|
|
1799
2146
|
SPACING_VALUES,
|
|
1800
2147
|
STYLE_REGISTRY,
|
|
1801
2148
|
SYSTEM_ENDPOINTS,
|
|
1802
|
-
|
|
1803
|
-
|
|
2149
|
+
WEB_HEADER_PRESET_OPTIONS,
|
|
2150
|
+
WEB_HEADER_PRESET_VALUES,
|
|
1804
2151
|
_resetPluginStyleRegistry,
|
|
1805
2152
|
arePreviewPreferencesEqual,
|
|
1806
2153
|
buildConditionContext,
|
|
1807
2154
|
classifyClass,
|
|
1808
2155
|
classifyClassString,
|
|
2156
|
+
collectPageIdsFromMenuItems,
|
|
1809
2157
|
colorToHex,
|
|
1810
2158
|
evaluateCondition,
|
|
1811
2159
|
extendStyleRegistry,
|
|
2160
|
+
findMenuItemByPageId,
|
|
2161
|
+
findNearestBottomTabMenuItemForPage,
|
|
2162
|
+
findPageRefInNavigationPayload,
|
|
1812
2163
|
findRemap,
|
|
1813
|
-
|
|
2164
|
+
flattenMenuItems,
|
|
2165
|
+
flattenNavigationMenuItems,
|
|
1814
2166
|
getMergedStyleRegistry,
|
|
2167
|
+
getNavigationItemHref,
|
|
2168
|
+
getNavigationItemKeyword,
|
|
2169
|
+
getNavigationItemLabel,
|
|
1815
2170
|
getPluginStyleRegistry,
|
|
1816
2171
|
getRegistryEntry,
|
|
1817
2172
|
getRegistryEntryAny,
|
|
@@ -1820,17 +2175,22 @@ function transformPagesData(pages) {
|
|
|
1820
2175
|
getStylePluginId,
|
|
1821
2176
|
gridSpanToReactNativeColumn,
|
|
1822
2177
|
hasInlineFormatting,
|
|
2178
|
+
isBottomTabMenuItemActive,
|
|
1823
2179
|
isKnownStyleName,
|
|
1824
|
-
isMenuVisible,
|
|
1825
2180
|
isMobileIconName,
|
|
1826
|
-
|
|
1827
|
-
|
|
2181
|
+
isOnAnyMobileMenu,
|
|
2182
|
+
isOnAnyMobileMenuFromPayload,
|
|
2183
|
+
isPageInMenuTree,
|
|
2184
|
+
isPageInResolvedMenus,
|
|
2185
|
+
isPageOnAnyMenu,
|
|
2186
|
+
isPageOnMobileMenu,
|
|
2187
|
+
isPageOnWebMenu,
|
|
1828
2188
|
isPreviewBridgeMessage,
|
|
1829
2189
|
isRegisteredStyleName,
|
|
1830
2190
|
isStyleAllowedOnPage,
|
|
1831
2191
|
isStylePlacementAllowed,
|
|
1832
2192
|
isStyleSupportedOnPlatform,
|
|
1833
|
-
|
|
2193
|
+
isWebHeaderPreset,
|
|
1834
2194
|
mapAccordionVariantToHeroUiVariant,
|
|
1835
2195
|
mapChipVariantToHeroUiVariant,
|
|
1836
2196
|
mapDividerVariantToReactNative,
|
|
@@ -1842,6 +2202,7 @@ function transformPagesData(pages) {
|
|
|
1842
2202
|
mapSizeToHeroUi,
|
|
1843
2203
|
mapSizeToMantine,
|
|
1844
2204
|
mapSpacingToPx,
|
|
2205
|
+
pageUrlToMobileRoute,
|
|
1845
2206
|
parseDimensionToReactNative,
|
|
1846
2207
|
parseDimensionToWeb,
|
|
1847
2208
|
parseInlineRich,
|
|
@@ -1851,14 +2212,22 @@ function transformPagesData(pages) {
|
|
|
1851
2212
|
replaceCalcedValues,
|
|
1852
2213
|
resolveAssetSources,
|
|
1853
2214
|
resolveAssetUrl,
|
|
2215
|
+
resolveBranchNavGroup,
|
|
2216
|
+
resolveHolderRedirectPath,
|
|
1854
2217
|
resolveMantineVariant,
|
|
1855
2218
|
resolveMobileIcon,
|
|
1856
|
-
|
|
2219
|
+
resolveMobilePagePresentation,
|
|
2220
|
+
resolveMobileSegmentGroup,
|
|
2221
|
+
resolveMobileStartupKeyword,
|
|
2222
|
+
resolveMobileStartupRoute,
|
|
1857
2223
|
resolveSharedStyle,
|
|
1858
2224
|
resolveSharedStyleForMobile,
|
|
1859
2225
|
resolveSharedStyleForWeb,
|
|
1860
2226
|
resolveSharedStyleProps,
|
|
1861
|
-
|
|
2227
|
+
resolveWebBranchNavGroup,
|
|
2228
|
+
resolveWebHeaderPreset,
|
|
2229
|
+
resolveWebStartupPath,
|
|
2230
|
+
searchMenuPagesInPayload,
|
|
1862
2231
|
setToStylePlatform,
|
|
1863
2232
|
sharedTailwindExtend,
|
|
1864
2233
|
sharedTailwindPreset,
|