@selfhelp/shared 1.21.2 → 1.21.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/README.md +2 -1
  3. package/dist/index.d.mts +427 -20
  4. package/dist/index.d.ts +427 -20
  5. package/dist/index.js +560 -13
  6. package/dist/index.mjs +518 -13
  7. package/dist/plugin-sdk/index.d.mts +1 -1
  8. package/dist/plugin-sdk/index.d.ts +1 -1
  9. package/dist/plugin-sdk/index.js +2 -1
  10. package/dist/plugin-sdk/index.mjs +2 -1
  11. package/dist/registry/index.d.mts +2 -2
  12. package/dist/registry/index.d.ts +2 -2
  13. package/dist/registry/index.js +2 -1
  14. package/dist/registry/index.mjs +2 -1
  15. package/dist/{styles.registry-DEDEZ8l3.d.ts → styles.registry-DX79oirw.d.ts} +93 -16
  16. package/dist/{styles.registry-DHM4M77N.d.mts → styles.registry-ffw0MH3r.d.mts} +93 -16
  17. package/package.json +1 -1
  18. package/src/content/__tests__/fieldsMapLabels.test.ts +55 -0
  19. package/src/content/__tests__/optionLabels.test.ts +100 -0
  20. package/src/content/fieldsMapLabels.ts +103 -0
  21. package/src/content/index.ts +2 -0
  22. package/src/content/optionLabels.ts +200 -0
  23. package/src/navigation/__tests__/navigation.test.ts +296 -6
  24. package/src/navigation/activeTrail.ts +99 -0
  25. package/src/navigation/branchNav.ts +155 -6
  26. package/src/navigation/footerPreset.ts +109 -0
  27. package/src/navigation/headerLayers.ts +56 -0
  28. package/src/navigation/headerPreset.ts +9 -2
  29. package/src/navigation/index.ts +4 -0
  30. package/src/navigation/menuDepth.ts +73 -37
  31. package/src/navigation/mobileRoute.ts +25 -0
  32. package/src/navigation/navLinks.ts +0 -4
  33. package/src/navigation/navigationBundle.ts +81 -0
  34. package/src/navigation/navigationPayload.ts +96 -17
  35. package/src/registry/__tests__/platform.test.ts +11 -10
  36. package/src/registry/styles.registry.ts +2 -1
  37. package/src/types/__tests__/preview-bridge.test.ts +7 -0
  38. package/src/types/auth.ts +4 -0
  39. package/src/types/cms-app.ts +74 -0
  40. package/src/types/index.ts +1 -0
  41. package/src/types/mobile-adapters.ts +1 -0
  42. package/src/types/pages.ts +6 -0
  43. package/src/types/preview-bridge.ts +12 -1
  44. package/src/types/styles/composite.ts +21 -0
  45. package/src/types/styles/forms.ts +57 -10
  46. package/src/types/styles/interactive.ts +1 -1
  47. package/src/types/styles/unknown.ts +2 -2
package/dist/index.mjs CHANGED
@@ -9,6 +9,10 @@ var PERMISSIONS = {
9
9
  ADMIN_PAGE_VERSION_PUBLISH: "admin.page.version.publish",
10
10
  ADMIN_PAGE_VERSION_READ: "admin.page.version.read",
11
11
  ADMIN_PAGE_VERSION_COMPARE: "admin.page.version.compare",
12
+ ADMIN_CMS_APP_READ: "admin.cms_app.read",
13
+ ADMIN_CMS_APP_CREATE: "admin.cms_app.create",
14
+ ADMIN_CMS_APP_UPDATE: "admin.cms_app.update",
15
+ ADMIN_CMS_APP_DELETE: "admin.cms_app.delete",
12
16
  ADMIN_USER_READ: "admin.user.read",
13
17
  ADMIN_USER_CREATE: "admin.user.create",
14
18
  ADMIN_USER_UPDATE: "admin.user.update",
@@ -50,6 +54,23 @@ var PERMISSIONS = {
50
54
  ADMIN_AUDIT_VIEW: "admin.audit.view"
51
55
  };
52
56
 
57
+ // src/types/cms-app.ts
58
+ var CMS_APP_ROLES = [
59
+ "form",
60
+ "cms_list",
61
+ "cms_detail",
62
+ "public_list",
63
+ "public_detail",
64
+ "other"
65
+ ];
66
+ var CMS_APP_PRIMARY_ROLES = [
67
+ "form",
68
+ "cms_list",
69
+ "cms_detail",
70
+ "public_list",
71
+ "public_detail"
72
+ ];
73
+
53
74
  // src/types/api/system.ts
54
75
  var SYSTEM_PREFIX = "/cms-api/v1/admin/system";
55
76
  var SYSTEM_ENDPOINTS = {
@@ -122,7 +143,7 @@ function isPreviewBridgeMessage(value) {
122
143
  case PREVIEW_BRIDGE_MESSAGE.NAVIGATED:
123
144
  return (record.source === "web" || record.source === "mobile") && (typeof record.keyword === "string" || record.keyword === null) && typeof record.href === "string";
124
145
  case PREVIEW_BRIDGE_MESSAGE.NAVIGATE:
125
- return typeof record.keyword === "string" || record.keyword === null;
146
+ return (typeof record.keyword === "string" || record.keyword === null) && (record.path === void 0 || record.path === null || typeof record.path === "string");
126
147
  case PREVIEW_BRIDGE_MESSAGE.SET_PREFERENCES:
127
148
  return isPreviewPreferences(record.preferences);
128
149
  case PREVIEW_BRIDGE_MESSAGE.PREFERENCES_CHANGED:
@@ -208,6 +229,7 @@ var BASE_STYLE_REGISTRY = {
208
229
  // ===== forms =====
209
230
  "form-log": { description: "Append-only form (one row per submit)", category: "forms", canHaveChildren: true },
210
231
  "form-record": { description: "Per-user record form", category: "forms", canHaveChildren: true },
232
+ "entry-record-form": { description: "Route-aware create/edit form", category: "forms", canHaveChildren: true },
211
233
  input: { description: "Plain HTML input", category: "forms", canHaveChildren: false },
212
234
  "text-input": { description: "Mantine TextInput", category: "forms", canHaveChildren: false },
213
235
  textarea: { description: "Mantine Textarea", category: "forms", canHaveChildren: false },
@@ -249,7 +271,7 @@ var BASE_STYLE_REGISTRY = {
249
271
  version: { description: "Build/version diagnostic surface", category: "auth", canHaveChildren: false },
250
272
  "ref-container": { description: "Renders content referenced from another section", category: "layout", canHaveChildren: true },
251
273
  "data-container": { description: "Data-scoped container (renders subtree against a data scope)", category: "layout", canHaveChildren: true },
252
- "show-user-input": { description: "Displays previously submitted user input as a list/card view", category: "forms", canHaveChildren: false }
274
+ "entry-table": { description: "Built-in admin CRUD grid over a form's records (search/sort/paginate/CSV, add / edit / delete actions)", category: "forms", canHaveChildren: false }
253
275
  };
254
276
  var STYLE_REGISTRY = BASE_STYLE_REGISTRY;
255
277
  var PLUGIN_STYLE_REGISTRY = {};
@@ -1405,6 +1427,183 @@ function stripHtmlToText(value) {
1405
1427
  return out.replace(/\s+/g, " ").trim();
1406
1428
  }
1407
1429
 
1430
+ // src/content/optionLabels.ts
1431
+ var OPTION_STYLE_CONFIGS = {
1432
+ select: {
1433
+ catalogField: "options",
1434
+ multipleField: "is_multiple"
1435
+ },
1436
+ radio: {
1437
+ catalogField: "radio_options"
1438
+ },
1439
+ combobox: {
1440
+ catalogField: "combobox_options",
1441
+ multipleField: "web_combobox_multi_select"
1442
+ },
1443
+ "segmented-control": {
1444
+ catalogField: "segmented_control_data"
1445
+ }
1446
+ };
1447
+ function parseJson(raw) {
1448
+ if (typeof raw !== "string" || raw.trim() === "") {
1449
+ return raw;
1450
+ }
1451
+ try {
1452
+ return JSON.parse(raw);
1453
+ } catch {
1454
+ return raw;
1455
+ }
1456
+ }
1457
+ function toString(value) {
1458
+ if (typeof value !== "string") return null;
1459
+ const trimmed = value.trim();
1460
+ return trimmed === "" ? null : trimmed;
1461
+ }
1462
+ function parseOptionCatalog(raw) {
1463
+ const parsed = parseJson(raw);
1464
+ if (!Array.isArray(parsed)) return [];
1465
+ const entries = [];
1466
+ for (const item of parsed) {
1467
+ if (item == null || typeof item !== "object") continue;
1468
+ const record = item;
1469
+ const value = toString(record.value);
1470
+ if (!value) continue;
1471
+ const explicitMeta = record.meta && typeof record.meta === "object" && !Array.isArray(record.meta) ? record.meta : {};
1472
+ const legacyDescription = toString(record.description);
1473
+ const meta = legacyDescription && explicitMeta.description === void 0 ? { ...explicitMeta, description: legacyDescription } : explicitMeta;
1474
+ entries.push({
1475
+ value,
1476
+ ...typeof record.sort === "number" ? { sort: record.sort } : {},
1477
+ ...typeof record.disabled === "boolean" ? { disabled: record.disabled } : {},
1478
+ ...Object.keys(meta).length > 0 ? { meta } : {},
1479
+ ...toString(record.label) ?? toString(record.text) ? { legacyLabel: toString(record.label) ?? toString(record.text) ?? void 0 } : {}
1480
+ });
1481
+ }
1482
+ return entries;
1483
+ }
1484
+ function parseOptionLabels(raw) {
1485
+ const parsed = parseJson(raw);
1486
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1487
+ return {};
1488
+ }
1489
+ const labels = {};
1490
+ for (const [key, value] of Object.entries(parsed)) {
1491
+ if (!key || typeof value !== "string") continue;
1492
+ const trimmed = value.trim();
1493
+ if (trimmed !== "") {
1494
+ labels[key] = trimmed;
1495
+ }
1496
+ }
1497
+ return labels;
1498
+ }
1499
+ function resolveOptionLabel(code, labels, fallbackLabels = {}, legacyLabel) {
1500
+ if (!code) return "";
1501
+ return labels[code] ?? fallbackLabels[code] ?? legacyLabel ?? code;
1502
+ }
1503
+ function resolveOptions(catalogRaw, labelsRaw, fallbackLabelsRaw) {
1504
+ const catalog = parseOptionCatalog(catalogRaw);
1505
+ const labels = parseOptionLabels(labelsRaw);
1506
+ const fallbackLabels = parseOptionLabels(fallbackLabelsRaw);
1507
+ return catalog.map((entry) => ({
1508
+ value: entry.value,
1509
+ label: resolveOptionLabel(entry.value, labels, fallbackLabels, entry.legacyLabel),
1510
+ ...entry.sort !== void 0 ? { sort: entry.sort } : {},
1511
+ ...entry.disabled !== void 0 ? { disabled: entry.disabled } : {},
1512
+ ...entry.meta ? { meta: entry.meta } : {}
1513
+ }));
1514
+ }
1515
+ function resolveOptionCodesLabels(codes, labels, fallbackLabels = {}) {
1516
+ return codes.map((code) => resolveOptionLabel(code, labels, fallbackLabels)).filter((label) => label !== "");
1517
+ }
1518
+ function parseOptionCodes(value) {
1519
+ const rawCodes = Array.isArray(value) ? value : typeof value === "string" ? value.split(",") : [];
1520
+ return rawCodes.filter((code) => typeof code === "string").map((code) => code.trim()).filter((code) => code !== "");
1521
+ }
1522
+ function resolveOptionValueLabels(value, labelsRaw, fallbackLabelsRaw) {
1523
+ return resolveOptionCodesLabels(
1524
+ parseOptionCodes(value),
1525
+ parseOptionLabels(labelsRaw),
1526
+ parseOptionLabels(fallbackLabelsRaw)
1527
+ );
1528
+ }
1529
+
1530
+ // src/content/fieldsMapLabels.ts
1531
+ var FIELDS_MAP_STYLE_CONFIG = {
1532
+ catalogField: "fields_map",
1533
+ labelsField: "fields_map_labels"
1534
+ };
1535
+ function parseJson2(raw) {
1536
+ if (typeof raw !== "string" || raw.trim() === "") {
1537
+ return raw;
1538
+ }
1539
+ try {
1540
+ return JSON.parse(raw);
1541
+ } catch {
1542
+ return raw;
1543
+ }
1544
+ }
1545
+ function parseFieldsMapCatalog(raw) {
1546
+ const parsed = parseJson2(raw);
1547
+ if (!Array.isArray(parsed)) {
1548
+ return [];
1549
+ }
1550
+ const keys = [];
1551
+ for (const item of parsed) {
1552
+ if (typeof item === "string" && item.trim() !== "") {
1553
+ keys.push(item.trim());
1554
+ continue;
1555
+ }
1556
+ if (item && typeof item === "object" && !Array.isArray(item)) {
1557
+ const record = item;
1558
+ const legacy = typeof record.field_name === "string" ? record.field_name.trim() : "";
1559
+ if (legacy !== "") {
1560
+ keys.push(legacy);
1561
+ }
1562
+ }
1563
+ }
1564
+ return keys;
1565
+ }
1566
+ function parseFieldsMapLabels(raw) {
1567
+ const parsed = parseJson2(raw);
1568
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1569
+ return {};
1570
+ }
1571
+ const labels = {};
1572
+ for (const [key, value] of Object.entries(parsed)) {
1573
+ if (!key || typeof value !== "string") {
1574
+ continue;
1575
+ }
1576
+ const trimmed = value.trim();
1577
+ if (trimmed !== "") {
1578
+ labels[key] = trimmed;
1579
+ }
1580
+ }
1581
+ return labels;
1582
+ }
1583
+ function resolveFieldsMapLabel(fieldKey, labels, fallbackLabels = {}) {
1584
+ return labels[fieldKey] ?? fallbackLabels[fieldKey] ?? fieldKey;
1585
+ }
1586
+ function serializeFieldsMapCatalog(fieldKeys) {
1587
+ const keys = fieldKeys.map((key) => key.trim()).filter((key) => key !== "");
1588
+ if (keys.length === 0) {
1589
+ return "";
1590
+ }
1591
+ return JSON.stringify(keys);
1592
+ }
1593
+ function serializeFieldsMapLabels(labels) {
1594
+ const clean = {};
1595
+ for (const [key, value] of Object.entries(labels)) {
1596
+ const trimmed = value.trim();
1597
+ if (key && trimmed !== "") {
1598
+ clean[key] = trimmed;
1599
+ }
1600
+ }
1601
+ if (Object.keys(clean).length === 0) {
1602
+ return "";
1603
+ }
1604
+ return JSON.stringify(clean);
1605
+ }
1606
+
1408
1607
  // src/navigation/headerPreset.ts
1409
1608
  var WEB_HEADER_PRESET_VALUES = [
1410
1609
  "simple",
@@ -1420,16 +1619,134 @@ var WEB_HEADER_PRESET_OPTIONS = [
1420
1619
  { value: "dropdown", label: "Dropdown", description: "Default \u2014 nested dropdown menus." },
1421
1620
  { value: "mega-menu", label: "Mega menu", description: "Rich sections with descriptions and icons." },
1422
1621
  { value: "tabs", label: "Tabs", description: "Top-level sections as tabs." },
1423
- { value: "double-dropdown", label: "Double header (dropdown)", description: "Utility row plus main dropdown nav." },
1424
- { value: "double-mega-menu", label: "Double header (mega menu)", description: "Utility row plus mega menu." }
1622
+ { value: "double-dropdown", label: "Double header (dropdown)", description: "Top row with flat links and utilities above the main dropdown nav." },
1623
+ { value: "double-mega-menu", label: "Double header (mega menu)", description: "Top row with flat links and utilities above the mega menu." }
1425
1624
  ];
1625
+ var DOUBLE_WEB_HEADER_PRESETS = ["double-dropdown", "double-mega-menu"];
1426
1626
  function isWebHeaderPreset(value) {
1427
1627
  return typeof value === "string" && WEB_HEADER_PRESET_VALUES.includes(value);
1428
1628
  }
1629
+ function isDoubleWebHeaderPreset(value) {
1630
+ return isWebHeaderPreset(value) && DOUBLE_WEB_HEADER_PRESETS.includes(value);
1631
+ }
1429
1632
  function resolveWebHeaderPreset(value, fallback = DEFAULT_WEB_HEADER_PRESET) {
1430
1633
  return isWebHeaderPreset(value) ? value : fallback;
1431
1634
  }
1432
1635
 
1636
+ // src/navigation/footerPreset.ts
1637
+ var WEB_FOOTER_PRESET_VALUES = [
1638
+ "columns",
1639
+ "inline"
1640
+ ];
1641
+ var DEFAULT_WEB_FOOTER_PRESET = "columns";
1642
+ var WEB_FOOTER_PRESET_OPTIONS = [
1643
+ {
1644
+ value: "columns",
1645
+ label: "Columns (grouped)",
1646
+ description: "Group headings become footer columns with their links below."
1647
+ },
1648
+ {
1649
+ value: "inline",
1650
+ label: "Inline links",
1651
+ description: "One flat centered link row; group links are shown inline, headings hidden. Groups are kept and restored when switching back."
1652
+ }
1653
+ ];
1654
+ function isWebFooterPreset(value) {
1655
+ return typeof value === "string" && WEB_FOOTER_PRESET_VALUES.includes(value);
1656
+ }
1657
+ function resolveWebFooterPreset(value, fallback = DEFAULT_WEB_FOOTER_PRESET) {
1658
+ return isWebFooterPreset(value) ? value : fallback;
1659
+ }
1660
+ function isRenderableFooterLeaf(item) {
1661
+ if (!item.is_active) {
1662
+ return false;
1663
+ }
1664
+ if (item.item_type === "external_url") {
1665
+ return item.external_url != null && item.external_url !== "";
1666
+ }
1667
+ return item.item_type === "page" && item.page != null;
1668
+ }
1669
+ function flattenFooterItems(items) {
1670
+ const out = [];
1671
+ for (const item of items) {
1672
+ if (!item.is_active) {
1673
+ continue;
1674
+ }
1675
+ if (item.item_type === "group") {
1676
+ out.push(...flattenFooterItems(item.children));
1677
+ continue;
1678
+ }
1679
+ if (isRenderableFooterLeaf(item)) {
1680
+ out.push(item);
1681
+ out.push(...flattenFooterItems(item.children));
1682
+ }
1683
+ }
1684
+ return out;
1685
+ }
1686
+ function footerColumnItems(items) {
1687
+ return items.filter(
1688
+ (item) => item.is_active && item.item_type === "group" && item.children.some(isRenderableFooterLeaf)
1689
+ );
1690
+ }
1691
+ function footerStandaloneItems(items) {
1692
+ return items.filter((item) => item.item_type !== "group" && isRenderableFooterLeaf(item));
1693
+ }
1694
+ function footerGroupLinks(group) {
1695
+ return group.children.filter(isRenderableFooterLeaf);
1696
+ }
1697
+
1698
+ // src/navigation/headerLayers.ts
1699
+ var NAVIGATION_HEADER_LAYER_TOP = "top";
1700
+ function byPosition(a, b) {
1701
+ return a.position - b.position || a.id - b.id;
1702
+ }
1703
+ function splitHeaderLayers(items) {
1704
+ const top = [];
1705
+ const main = [];
1706
+ for (const item of items) {
1707
+ if (item.layer === NAVIGATION_HEADER_LAYER_TOP) {
1708
+ top.push(item);
1709
+ } else {
1710
+ main.push(item);
1711
+ }
1712
+ }
1713
+ top.sort(byPosition);
1714
+ main.sort(byPosition);
1715
+ return { top, main };
1716
+ }
1717
+ function mergeHeaderLayers(items) {
1718
+ const { top, main } = splitHeaderLayers(items);
1719
+ return [...main, ...top];
1720
+ }
1721
+
1722
+ // src/navigation/navigationPayload.ts
1723
+ var NAVIGATION_BRANDING_LOGO_HEIGHTS = {
1724
+ sm: 24,
1725
+ md: 32,
1726
+ lg: 44,
1727
+ xl: 56
1728
+ };
1729
+ function resolveBrandingPresentation(branding) {
1730
+ const size = branding?.logo_size ?? "md";
1731
+ const requestedVariant = branding?.logo_variant ?? "logo-and-name";
1732
+ const hasLogo = Boolean(branding?.logo_url);
1733
+ const variant = hasLogo ? requestedVariant : "name-only";
1734
+ return {
1735
+ size,
1736
+ variant,
1737
+ logoHeight: NAVIGATION_BRANDING_LOGO_HEIGHTS[size],
1738
+ showLogo: variant !== "name-only",
1739
+ showName: variant !== "logo-only"
1740
+ };
1741
+ }
1742
+
1743
+ // src/navigation/navigationBundle.ts
1744
+ var NAVIGATION_BUNDLE_FORMAT = "selfhelp/navigation-bundle";
1745
+ var NAVIGATION_BUNDLE_VERSION = "2.0";
1746
+ function isNavigationBundleVersionSupported(version) {
1747
+ return version === NAVIGATION_BUNDLE_VERSION;
1748
+ }
1749
+
1433
1750
  // src/navigation/menuMembership.ts
1434
1751
  function flattenItems(items) {
1435
1752
  const out = [];
@@ -1494,6 +1811,22 @@ function findPageRefInNavigationPayload(payload, pageId) {
1494
1811
  }
1495
1812
 
1496
1813
  // src/navigation/mobileRoute.ts
1814
+ function buildPublicPathFromRoute(urlTemplate, routeParams) {
1815
+ if (!urlTemplate || !urlTemplate.includes("{")) {
1816
+ return null;
1817
+ }
1818
+ let path = urlTemplate;
1819
+ for (const [key, value] of Object.entries(routeParams)) {
1820
+ if (value === void 0 || value === "") {
1821
+ continue;
1822
+ }
1823
+ path = path.replaceAll(`{${key}}`, value);
1824
+ }
1825
+ if (path.includes("{")) {
1826
+ return null;
1827
+ }
1828
+ return path.replace(/\/+$/, "") || "/";
1829
+ }
1497
1830
  function pageUrlToMobileRoute(url, keyword) {
1498
1831
  const normalizedKeyword = keyword.trim().toLowerCase();
1499
1832
  if (normalizedKeyword === "profile") {
@@ -1518,8 +1851,8 @@ function toSegment(item) {
1518
1851
  keyword: item.page.keyword,
1519
1852
  url: item.page.url,
1520
1853
  label: itemLabel(item),
1521
- icon: item.icon ?? item.page.icon,
1522
- mobile_icon: item.page.mobile_icon
1854
+ icon: item.icon ?? null,
1855
+ mobile_icon: item.mobile_icon ?? null
1523
1856
  };
1524
1857
  }
1525
1858
  function findParentItem(items, pageId, parent = null) {
@@ -1572,9 +1905,7 @@ function resolveBranchNavGroup(payload, currentPageId, menuKeys) {
1572
1905
  }
1573
1906
  const located = findParentItem([root], currentPageId);
1574
1907
  if (located) {
1575
- const directChildren = menuVisibleChildItems(
1576
- located.parent ?? { id: 0, item_type: "group", label: "", position: 0, children: located.siblings }
1577
- );
1908
+ const directChildren = located.parent ? menuVisibleChildItems(located.parent) : located.siblings.filter((sibling) => sibling.page != null && sibling.is_active !== false);
1578
1909
  if (located.parent && located.parent.page?.id === currentPageId && directChildren.length > 0) {
1579
1910
  const segments = directChildren.map(toSegment).filter((s) => s != null);
1580
1911
  return segments.length > 0 ? segments : null;
@@ -1615,6 +1946,80 @@ function resolveMobileSegmentGroup(payload, currentPageId) {
1615
1946
  function resolveWebBranchNavGroup(payload, currentPageId) {
1616
1947
  return resolveBranchNavGroup(payload, currentPageId, ["web_header", "web_footer"]);
1617
1948
  }
1949
+ function findMenuItemPath(items, pageId, trail = []) {
1950
+ for (const item of items) {
1951
+ const nextTrail = [...trail, item];
1952
+ if (item.page?.id === pageId) {
1953
+ return nextTrail;
1954
+ }
1955
+ if (item.children?.length) {
1956
+ const found = findMenuItemPath(item.children, pageId, nextTrail);
1957
+ if (found) {
1958
+ return found;
1959
+ }
1960
+ }
1961
+ }
1962
+ return null;
1963
+ }
1964
+ function toBreadcrumb(item) {
1965
+ return {
1966
+ label: itemLabel(item),
1967
+ pageId: item.page?.id ?? null,
1968
+ keyword: item.page?.keyword ?? null,
1969
+ url: item.page?.url ?? null
1970
+ };
1971
+ }
1972
+ function resolveModeForBranch(branchParent, menu) {
1973
+ return branchParent?.children_nav ?? menu.children_nav ?? "sidebar";
1974
+ }
1975
+ function resolvePagerForBranch(branchParent, menu) {
1976
+ return branchParent?.show_pager ?? menu.show_pager ?? true;
1977
+ }
1978
+ function resolveWebBranchNavContext(payload, currentPageId) {
1979
+ for (const key of ["web_header", "web_footer"]) {
1980
+ const menu = payload.menus[key];
1981
+ if (!menu?.items?.length) {
1982
+ continue;
1983
+ }
1984
+ const path = findMenuItemPath(menu.items, currentPageId);
1985
+ if (!path) {
1986
+ continue;
1987
+ }
1988
+ const currentItem = path[path.length - 1];
1989
+ const ownChildren = menuVisibleChildItems(currentItem);
1990
+ let branchParent = null;
1991
+ let group;
1992
+ if (ownChildren.length > 0) {
1993
+ branchParent = currentItem;
1994
+ group = ownChildren;
1995
+ } else if (path.length >= 2) {
1996
+ branchParent = path[path.length - 2];
1997
+ group = menuVisibleChildItems(branchParent);
1998
+ } else {
1999
+ return null;
2000
+ }
2001
+ const segments = group.map(toSegment).filter((segment) => segment != null);
2002
+ if (segments.length === 0) {
2003
+ return null;
2004
+ }
2005
+ const currentIndex = segments.findIndex((segment) => segment.pageId === currentPageId);
2006
+ const pager = {
2007
+ prev: currentIndex > 0 ? segments[currentIndex - 1] : null,
2008
+ next: currentIndex >= 0 && currentIndex < segments.length - 1 ? segments[currentIndex + 1] : null
2009
+ };
2010
+ return {
2011
+ mode: resolveModeForBranch(branchParent, menu),
2012
+ showBreadcrumbs: menu.show_breadcrumbs ?? false,
2013
+ showPager: resolvePagerForBranch(branchParent, menu),
2014
+ heading: branchParent ? itemLabel(branchParent) : null,
2015
+ parent: branchParent ? toSegment(branchParent) : null,
2016
+ segments,
2017
+ breadcrumbs: path.map(toBreadcrumb),
2018
+ pager
2019
+ };
2020
+ }
2021
+ return null;
2022
+ }
1618
2023
  function resolveMobilePagePresentation(payload, pageId) {
1619
2024
  return isOnAnyMobileMenuFromPayload(payload, pageId) ? "route" : "modal";
1620
2025
  }
@@ -1678,10 +2083,6 @@ function getNavigationItemLabel(item) {
1678
2083
  return item.label || item.page?.title || item.page?.keyword || "";
1679
2084
  }
1680
2085
  function getNavigationItemAriaLabel(item) {
1681
- const aria = item.aria_label?.trim();
1682
- if (aria) {
1683
- return aria;
1684
- }
1685
2086
  const label = getNavigationItemLabel(item);
1686
2087
  return label || void 0;
1687
2088
  }
@@ -1905,6 +2306,68 @@ function clampMenuItemsAtDepth(items, maxDepth, depth = 0) {
1905
2306
  });
1906
2307
  }
1907
2308
 
2309
+ // src/navigation/activeTrail.ts
2310
+ function getNavigationItemMobileHref(item) {
2311
+ if (item.item_type === "external_url" && item.external_url) {
2312
+ return item.external_url;
2313
+ }
2314
+ if (!item.page) {
2315
+ return "/index";
2316
+ }
2317
+ return pageUrlToMobileRoute(item.page.url, item.page.keyword);
2318
+ }
2319
+ function matchesWebPath(href, pathname) {
2320
+ if (href === "" || href === "#") {
2321
+ return false;
2322
+ }
2323
+ if (pathname === href) {
2324
+ return true;
2325
+ }
2326
+ return href !== "/" && pathname.startsWith(`${href}/`);
2327
+ }
2328
+ function matchesMobilePath(href, pathname) {
2329
+ if (pathname === href) {
2330
+ return true;
2331
+ }
2332
+ if (href === "/index" && (pathname === "" || pathname === "/" || pathname === "/index")) {
2333
+ return true;
2334
+ }
2335
+ return href !== "/" && pathname.startsWith(`${href}/`);
2336
+ }
2337
+ function isActive(item, pathname, getHref, matches) {
2338
+ if (matches(getHref(item), pathname)) {
2339
+ return true;
2340
+ }
2341
+ return item.children.some((child) => isActive(child, pathname, getHref, matches));
2342
+ }
2343
+ function isMenuItemActiveOnWeb(item, pathname) {
2344
+ return isActive(item, pathname, getNavigationItemHref, matchesWebPath);
2345
+ }
2346
+ function isMenuItemActiveOnMobile(item, pathname) {
2347
+ return isActive(item, pathname, getNavigationItemMobileHref, matchesMobilePath);
2348
+ }
2349
+ function expandedIdsForActiveTrail(items, pathname, platform) {
2350
+ const getHref = platform === "mobile" ? getNavigationItemMobileHref : getNavigationItemHref;
2351
+ const matches = platform === "mobile" ? matchesMobilePath : matchesWebPath;
2352
+ const expanded = /* @__PURE__ */ new Set();
2353
+ const visit = (item) => {
2354
+ let childActive = false;
2355
+ for (const child of item.children) {
2356
+ if (visit(child)) {
2357
+ childActive = true;
2358
+ }
2359
+ }
2360
+ if (childActive) {
2361
+ expanded.add(item.id);
2362
+ }
2363
+ return childActive || matches(getHref(item), pathname);
2364
+ };
2365
+ for (const item of items) {
2366
+ visit(item);
2367
+ }
2368
+ return expanded;
2369
+ }
2370
+
1908
2371
  // src/utils/spacing.ts
1909
2372
  var ALLOWED_KEYS = ["mt", "mb", "ms", "me", "pt", "pb", "ps", "pe"];
1910
2373
  function parseSpacing(raw) {
@@ -1980,13 +2443,17 @@ export {
1980
2443
  CLIENT_TYPE_MOBILE,
1981
2444
  CLIENT_TYPE_MOBILE_AND_WEB,
1982
2445
  CLIENT_TYPE_WEB,
2446
+ CMS_APP_PRIMARY_ROLES,
2447
+ CMS_APP_ROLES,
1983
2448
  COLOR_NAMES,
1984
2449
  COLOR_PALETTE,
1985
2450
  COLOR_SCALES,
1986
2451
  CONTAINER_SIZE_PX,
1987
2452
  DEFAULT_MOBILE_ICON,
2453
+ DEFAULT_WEB_FOOTER_PRESET,
1988
2454
  DEFAULT_WEB_HEADER_PRESET,
1989
2455
  ENDPOINTS,
2456
+ FIELDS_MAP_STYLE_CONFIG,
1990
2457
  FONT_SIZE_PX,
1991
2458
  FULL_RADIUS_PX,
1992
2459
  HEADER_CLIENT_TYPE,
@@ -1995,6 +2462,11 @@ export {
1995
2462
  MOBILE_ICON_NAMES,
1996
2463
  MOBILE_ICON_SET,
1997
2464
  MOBILE_PREVIEW_ENDPOINTS,
2465
+ NAVIGATION_BRANDING_LOGO_HEIGHTS,
2466
+ NAVIGATION_BUNDLE_FORMAT,
2467
+ NAVIGATION_BUNDLE_VERSION,
2468
+ NAVIGATION_HEADER_LAYER_TOP,
2469
+ OPTION_STYLE_CONFIGS,
1998
2470
  PERMISSIONS,
1999
2471
  PREVIEW_BRIDGE_MESSAGE,
2000
2472
  PREVIEW_PARENT_ORIGIN_PARAM,
@@ -2007,29 +2479,38 @@ export {
2007
2479
  SPACING_VALUES,
2008
2480
  STYLE_REGISTRY,
2009
2481
  SYSTEM_ENDPOINTS,
2482
+ WEB_FOOTER_PRESET_OPTIONS,
2483
+ WEB_FOOTER_PRESET_VALUES,
2010
2484
  WEB_HEADER_PRESET_OPTIONS,
2011
2485
  WEB_HEADER_PRESET_VALUES,
2012
2486
  _resetPluginStyleRegistry,
2013
2487
  arePreviewPreferencesEqual,
2014
2488
  buildConditionContext,
2489
+ buildPublicPathFromRoute,
2015
2490
  clampMenuItemsAtDepth,
2016
2491
  classifyClass,
2017
2492
  classifyClassString,
2018
2493
  collectPageIdsFromMenuItems,
2019
2494
  colorToHex,
2020
2495
  evaluateCondition,
2496
+ expandedIdsForActiveTrail,
2021
2497
  extendStyleRegistry,
2022
2498
  findMenuItemByPageId,
2023
2499
  findNearestBottomTabMenuItemForPage,
2024
2500
  findPageRefInNavigationPayload,
2025
2501
  findRemap,
2502
+ flattenFooterItems,
2026
2503
  flattenMenuItems,
2027
2504
  flattenNavigationMenuItems,
2505
+ footerColumnItems,
2506
+ footerGroupLinks,
2507
+ footerStandaloneItems,
2028
2508
  getMergedStyleRegistry,
2029
2509
  getNavigationItemAriaLabel,
2030
2510
  getNavigationItemHref,
2031
2511
  getNavigationItemKeyword,
2032
2512
  getNavigationItemLabel,
2513
+ getNavigationItemMobileHref,
2033
2514
  getPluginStyleRegistry,
2034
2515
  getRegistryEntry,
2035
2516
  getRegistryEntryAny,
@@ -2039,8 +2520,12 @@ export {
2039
2520
  gridSpanToReactNativeColumn,
2040
2521
  hasInlineFormatting,
2041
2522
  isBottomTabMenuItemActive,
2523
+ isDoubleWebHeaderPreset,
2042
2524
  isKnownStyleName,
2525
+ isMenuItemActiveOnMobile,
2526
+ isMenuItemActiveOnWeb,
2043
2527
  isMobileIconName,
2528
+ isNavigationBundleVersionSupported,
2044
2529
  isOnAnyMobileMenu,
2045
2530
  isOnAnyMobileMenuFromPayload,
2046
2531
  isPageInMenuTree,
@@ -2053,6 +2538,7 @@ export {
2053
2538
  isStyleAllowedOnPage,
2054
2539
  isStylePlacementAllowed,
2055
2540
  isStyleSupportedOnPlatform,
2541
+ isWebFooterPreset,
2056
2542
  isWebHeaderPreset,
2057
2543
  mapAccordionVariantToHeroUiVariant,
2058
2544
  mapChipVariantToHeroUiVariant,
@@ -2065,10 +2551,18 @@ export {
2065
2551
  mapSizeToHeroUi,
2066
2552
  mapSizeToMantine,
2067
2553
  mapSpacingToPx,
2554
+ matchesMobilePath,
2555
+ matchesWebPath,
2556
+ mergeHeaderLayers,
2068
2557
  pageUrlToMobileRoute,
2069
2558
  parseDimensionToReactNative,
2070
2559
  parseDimensionToWeb,
2560
+ parseFieldsMapCatalog,
2561
+ parseFieldsMapLabels,
2071
2562
  parseInlineRich,
2563
+ parseOptionCatalog,
2564
+ parseOptionCodes,
2565
+ parseOptionLabels,
2072
2566
  parseSpacing,
2073
2567
  previewKeywordFromPath,
2074
2568
  radiusToPx,
@@ -2076,6 +2570,8 @@ export {
2076
2570
  resolveAssetSources,
2077
2571
  resolveAssetUrl,
2078
2572
  resolveBranchNavGroup,
2573
+ resolveBrandingPresentation,
2574
+ resolveFieldsMapLabel,
2079
2575
  resolveHolderRedirectPath,
2080
2576
  resolveMantineVariant,
2081
2577
  resolveMenuMaxDepth,
@@ -2084,20 +2580,29 @@ export {
2084
2580
  resolveMobileSegmentGroup,
2085
2581
  resolveMobileStartupKeyword,
2086
2582
  resolveMobileStartupRoute,
2583
+ resolveOptionCodesLabels,
2584
+ resolveOptionLabel,
2585
+ resolveOptionValueLabels,
2586
+ resolveOptions,
2087
2587
  resolveSharedStyle,
2088
2588
  resolveSharedStyleForMobile,
2089
2589
  resolveSharedStyleForWeb,
2090
2590
  resolveSharedStyleProps,
2591
+ resolveWebBranchNavContext,
2091
2592
  resolveWebBranchNavGroup,
2593
+ resolveWebFooterPreset,
2092
2594
  resolveWebHeaderPreset,
2093
2595
  resolveWebStartupPath,
2094
2596
  searchMenuPagesInPayload,
2597
+ serializeFieldsMapCatalog,
2598
+ serializeFieldsMapLabels,
2095
2599
  setToStylePlatform,
2096
2600
  sharedTailwindExtend,
2097
2601
  sharedTailwindPreset,
2098
2602
  sizeToFontPx,
2099
2603
  spacingToClasses,
2100
2604
  spacingToPx,
2605
+ splitHeaderLayers,
2101
2606
  stripHtmlToText,
2102
2607
  stylePlatformToSet,
2103
2608
  toHeroUiSemanticProps,