@designcrowd/library.brand-page 5.18.4 → 5.18.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 (162) hide show
  1. package/lib/src/{CreatedOnBrandCrowd-de-de-DQLtpdLe.js → CreatedOnBrandCrowd-de-de-ciKpCAd9.js} +1 -1
  2. package/lib/src/{CreatedOnBrandCrowd-en-us-CvEhlADd.js → CreatedOnBrandCrowd-en-us-CZbTS1AZ.js} +1 -1
  3. package/lib/src/{CreatedOnBrandCrowd-es-es-pYQeTTC0.js → CreatedOnBrandCrowd-es-es-C8MExng5.js} +1 -1
  4. package/lib/src/{CreatedOnBrandCrowd-fr-fr-CcE-iCEq.js → CreatedOnBrandCrowd-fr-ca-CO0L9NK2.js} +1 -1
  5. package/lib/src/{CreatedOnBrandCrowd-fr-ca-CcE-iCEq.js → CreatedOnBrandCrowd-fr-fr-CO0L9NK2.js} +1 -1
  6. package/lib/src/{CreatedOnBrandCrowd-pt-pt-OyhWWWyO.js → CreatedOnBrandCrowd-pt-br-zVDvBF2H.js} +1 -1
  7. package/lib/src/{CreatedOnBrandCrowd-pt-br-OyhWWWyO.js → CreatedOnBrandCrowd-pt-pt-zVDvBF2H.js} +1 -1
  8. package/lib/src/{CreatedOnDcom-de-de-DH98FFLS.js → CreatedOnDcom-de-de-WrUSQdjf.js} +1 -1
  9. package/lib/src/{CreatedOnDcom-en-us-DK67NN1r.js → CreatedOnDcom-en-us-BqC9YtkL.js} +1 -1
  10. package/lib/src/{CreatedOnDcom-es-es-9-QU4BU6.js → CreatedOnDcom-es-es-BzH32Oya.js} +1 -1
  11. package/lib/src/{CreatedOnDcom-fr-ca-U9J9H9VB.js → CreatedOnDcom-fr-ca-D7TYfCW0.js} +1 -1
  12. package/lib/src/{CreatedOnDcom-fr-fr-DqdzB1DJ.js → CreatedOnDcom-fr-fr-DVlyfBtb.js} +1 -1
  13. package/lib/src/{CreatedOnDcom-pt-br-c4UiWtkB.js → CreatedOnDcom-pt-br-CSRB91ey.js} +1 -1
  14. package/lib/src/{CreatedOnDcom-pt-pt-Do2qJsYp.js → CreatedOnDcom-pt-pt-9KMj5gpc.js} +1 -1
  15. package/lib/src/brand-page/models/navigation-styles.model.d.ts +7 -0
  16. package/lib/src/brand-page/models/navigation-styles.model.js +25 -2
  17. package/lib/src/brand-page/utils/migration/migration-16.d.ts +2 -0
  18. package/lib/src/brand-page/utils/migration/migration-16.js +47 -0
  19. package/lib/src/brand-page/utils/migration.util.js +7 -0
  20. package/lib/src/brand-page-maker/components/action-bar/ActionBar.mixin.d.ts +7 -2
  21. package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.d.ts +7 -2
  22. package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.js +8 -0
  23. package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMakerTemplateSettings.mixin.d.ts +7 -2
  24. package/lib/src/brand-page-maker/components/brand-page-maker/__fixtures__/brand-page-examples.js +1 -0
  25. package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.d.ts +87 -2
  26. package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.js +5 -0
  27. package/lib/src/brand-page-maker/components/brandpage-settings/ReplaceImageSettingsForBrandPageSettings.mixin.d.ts +7 -2
  28. package/lib/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.mixin.d.ts +3 -0
  29. package/lib/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.mixin.js +11 -0
  30. package/lib/src/brand-page-maker/components/seo-settings/SeoPageSettings.mixin.d.ts +7 -2
  31. package/lib/src/brand-page-maker/components/seo-settings/UrlSettings.mixin.d.ts +7 -2
  32. package/lib/src/brand-page-maker/components/social-share/SocialShare.mixin.d.ts +7 -2
  33. package/lib/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.d.ts +7 -2
  34. package/lib/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.js +9 -0
  35. package/lib/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.js +20 -1
  36. package/lib/src/brand-page-maker/composables/useEventTracker.d.ts +20 -0
  37. package/lib/src/brand-page-maker/composables/useEventTracker.js +17 -0
  38. package/lib/src/brand-page-maker/composables/useUndoRedoFlag.d.ts +17 -0
  39. package/lib/src/brand-page-maker/composables/useUndoRedoFlag.js +25 -0
  40. package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.d.ts +41 -2
  41. package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.js +308 -14
  42. package/lib/src/brand-page-maker/stores/history/history-store.d.ts +83 -0
  43. package/lib/src/brand-page-maker/stores/history/history-store.js +495 -0
  44. package/lib/src/brand-page-maker/stores/logo-store/logo-store.d.ts +1 -0
  45. package/lib/src/brand-page-maker/stores/user/user-store.js +1 -0
  46. package/lib/src/bundled-translations-D1q3rSEz.js +175 -0
  47. package/lib/src/bundled-translations.de-DE-BxqLLwbh.js +175 -0
  48. package/lib/src/bundled-translations.es-ES-uh249NlJ.js +175 -0
  49. package/lib/src/bundled-translations.fr-CA-BEQmv2fX.js +175 -0
  50. package/lib/src/bundled-translations.fr-FR-BnNuCojH.js +175 -0
  51. package/lib/src/bundled-translations.pt-BR-CJUOxVlq.js +175 -0
  52. package/lib/src/bundled-translations.pt-PT-Ds9cMEqK.js +175 -0
  53. package/lib/src/bundles/bundled-translations.de-DE.json +3 -1
  54. package/lib/src/bundles/bundled-translations.es-ES.json +3 -1
  55. package/lib/src/bundles/bundled-translations.fr-CA.json +3 -1
  56. package/lib/src/bundles/bundled-translations.fr-FR.json +3 -1
  57. package/lib/src/bundles/bundled-translations.json +3 -1
  58. package/lib/src/bundles/bundled-translations.pt-BR.json +3 -1
  59. package/lib/src/bundles/bundled-translations.pt-PT.json +3 -1
  60. package/lib/src/constants/ui.d.ts +1 -0
  61. package/lib/src/css/library.brand-page-brandCrowd.min.css +77 -82
  62. package/lib/src/css/library.brand-page-brandPage.min.css +77 -83
  63. package/lib/src/css/library.brand-page-designCom.min.css +77 -82
  64. package/lib/src/css/library.brand-page-preview.min.css +77 -82
  65. package/lib/src/index.mjs +62 -60
  66. package/lib/src/{lib-BI3J4Mbk.js → lib-BXbo_N88.js} +35072 -34447
  67. package/lib/src/metadata-builder/builders/reorder-pages-builder.d.ts +13 -0
  68. package/lib/src/metadata-builder/builders/reorder-pages-builder.js +49 -0
  69. package/lib/src/shared/content-settings/components/content-settings/ContentSettings.mixin.d.ts +87 -2
  70. package/lib/src/shared/content-settings/components/content-settings/ContentSettings.mixin.js +5 -0
  71. package/lib/src/shared/content-settings/components/content-settings/ContentSettings.stories.js +1 -0
  72. package/lib/src/shared/content-settings/components/content-settings/ReplaceImageSettingsForContent.mixin.d.ts +23 -2
  73. package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItem.mixin.d.ts +16 -0
  74. package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.d.ts +7 -2
  75. package/lib/src/shared/content-settings/components/draggable-item-list/DraggableItemList.mixin.d.ts +3 -0
  76. package/lib/src/shared/content-settings/components/draggable-item-list/DraggableItemList.mixin.js +19 -2
  77. package/lib/src/shared/content-settings/components/form-fields-field/FormFieldsField.mixin.js +18 -8
  78. package/lib/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.d.ts +64 -0
  79. package/lib/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.js +6 -0
  80. package/lib/src/shared/logo-settings/components/EditLogoSettings.mixin.d.ts +19 -0
  81. package/lib/src/shared/logo-settings/components/EditLogoSettings.mixin.js +11 -0
  82. package/lib/src/shared/logo-settings/components/LogoSettings.mixin.d.ts +10 -2
  83. package/lib/src/shared/logo-settings/store/editable-logo-store.d.ts +5 -1
  84. package/lib/src/shared/logo-settings/store/editable-logo-store.js +31 -0
  85. package/lib/src/shared/navigation-style-settings/components/navigation-style-settings/NavigationStyleSettings.mixin.js +10 -8
  86. package/lib/src/shared/navigation-style-settings/store/index.js +1 -12
  87. package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +24 -2
  88. package/lib/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.d.ts +10 -2
  89. package/lib/src/shared/publish-brand-page-with-state/PublishBrandPageModalWithState.mixin.d.ts +23 -2
  90. package/lib/src/shared/side-bar/components/SideBarTabButton.mixin.d.ts +16 -0
  91. package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +23 -2
  92. package/lib/src/shared/template-settings/components/TemplatesSettings.mixin.d.ts +16 -0
  93. package/package.json +1 -1
  94. package/src/brand-page/components/button/Button.vue +2 -10
  95. package/src/brand-page/components/contact-form/ContactForm.vue +2 -2
  96. package/src/brand-page/components/navigation/navigation-side-menu/NavigationSideMenu.vue +4 -1
  97. package/src/brand-page/models/navigation-styles.model.ts +39 -1
  98. package/src/brand-page/utils/__snapshots__/migration.util.test.ts.snap +3 -3
  99. package/src/brand-page/utils/migration/migration-16.test.ts +319 -0
  100. package/src/brand-page/utils/migration/migration-16.ts +75 -0
  101. package/src/brand-page/utils/migration.util.ts +8 -0
  102. package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.ts +9 -0
  103. package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.vue +2 -3
  104. package/src/brand-page-maker/components/brand-page-maker/__fixtures__/brand-page-examples.ts +1 -0
  105. package/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.ts +5 -0
  106. package/src/brand-page-maker/components/color-palette/BpColorPalette.vue +9 -7
  107. package/src/brand-page-maker/components/cookie-collection/CookieSettings.vue +18 -17
  108. package/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.mixin.ts +13 -0
  109. package/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.vue +26 -3
  110. package/src/brand-page-maker/components/quick-link-bar/RedoButton.vue +66 -0
  111. package/src/brand-page-maker/components/quick-link-bar/UndoButton.vue +66 -0
  112. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.de-DE.json +6 -4
  113. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.es-ES.json +6 -4
  114. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.fr-CA.json +6 -4
  115. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.fr-FR.json +6 -4
  116. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.json +3 -1
  117. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.pt-BR.json +6 -4
  118. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.pt-PT.json +6 -4
  119. package/src/brand-page-maker/components/quick-link-bar/undo-redo-buttons.test.ts +116 -0
  120. package/src/brand-page-maker/components/save-contact/SaveContact.vue +12 -19
  121. package/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.ts +10 -0
  122. package/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.ts +24 -1
  123. package/src/brand-page-maker/composables/useEventTracker.ts +29 -0
  124. package/src/brand-page-maker/composables/useUndoRedoFlag.ts +30 -0
  125. package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.test.ts +377 -0
  126. package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.ts +371 -18
  127. package/src/brand-page-maker/stores/history/history-store.test.ts +1120 -0
  128. package/src/brand-page-maker/stores/history/history-store.ts +660 -0
  129. package/src/brand-page-maker/stores/logo-store/logo-store.ts +5 -0
  130. package/src/brand-page-maker/stores/user/user-store.ts +1 -0
  131. package/src/bundles/bundled-translations.de-DE.json +3 -1
  132. package/src/bundles/bundled-translations.es-ES.json +3 -1
  133. package/src/bundles/bundled-translations.fr-CA.json +3 -1
  134. package/src/bundles/bundled-translations.fr-FR.json +3 -1
  135. package/src/bundles/bundled-translations.json +3 -1
  136. package/src/bundles/bundled-translations.pt-BR.json +3 -1
  137. package/src/bundles/bundled-translations.pt-PT.json +3 -1
  138. package/src/constants/ui.ts +1 -0
  139. package/src/metadata-builder/builders/reorder-pages-builder.ts +80 -0
  140. package/src/shared/content-settings/components/color-field/ColorField.vue +10 -5
  141. package/src/shared/content-settings/components/content-settings/ContentSettings.mixin.ts +5 -0
  142. package/src/shared/content-settings/components/content-settings/ContentSettings.stories.ts +1 -0
  143. package/src/shared/content-settings/components/draggable-item-list/DraggableItemList.mixin.ts +19 -2
  144. package/src/shared/content-settings/components/draggable-item-list/DraggableItemList.vue +1 -1
  145. package/src/shared/content-settings/components/form-fields-field/FormFieldsField.mixin.ts +26 -10
  146. package/src/shared/content-settings/components/logo-selection-field/LogoSelection.vue +63 -48
  147. package/src/shared/content-settings/components/page-dropdown-field/PageDropdownField.vue +4 -0
  148. package/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.ts +7 -0
  149. package/src/shared/content-settings/components/text-field/TextField.vue +1 -0
  150. package/src/shared/content-settings/components/text-image-field/TextImageField.vue +33 -4
  151. package/src/shared/logo-settings/components/EditLogoSettings.mixin.ts +11 -0
  152. package/src/shared/logo-settings/store/editable-logo-store.ts +42 -1
  153. package/src/shared/navigation-style-settings/components/navigation-style-settings/NavigationStyleSettings.mixin.ts +17 -11
  154. package/src/shared/navigation-style-settings/components/navigation-style-settings/NavigationStyleSettings.vue +4 -1
  155. package/src/shared/navigation-style-settings/store/index.ts +1 -21
  156. package/lib/src/bundled-translations-B5Fkt3qd.js +0 -175
  157. package/lib/src/bundled-translations.de-DE-DpdVePM9.js +0 -175
  158. package/lib/src/bundled-translations.es-ES-BsIcrzZF.js +0 -175
  159. package/lib/src/bundled-translations.fr-CA-G1XCp2Qh.js +0 -175
  160. package/lib/src/bundled-translations.fr-FR-BdwLXOnB.js +0 -175
  161. package/lib/src/bundled-translations.pt-BR-Bvn5ePe7.js +0 -175
  162. package/lib/src/bundled-translations.pt-PT-CDtkb2k1.js +0 -175
@@ -9,10 +9,14 @@ import {
9
9
  BrandPageModel,
10
10
  type ContactFormContent,
11
11
  emptyGlobalTextStyleDeclaration,
12
+ HEADER_DISPLAY,
12
13
  type LogoTheme,
14
+ NAVIGATION_DISPLAY,
13
15
  type PageStyles,
16
+ STYLE_THEME_KEYS,
14
17
  VIEWPORTS,
15
18
  } from '@brand-page';
19
+ import { useUiNavigationStyleSettingsStore } from '@shared/navigation-style-settings/store';
16
20
  import {
17
21
  DEFAULT_LOGO_HEIGHT,
18
22
  DEFAULT_LOGO_WIDTH,
@@ -40,6 +44,13 @@ import { useUiBackgroundSettingsStore } from '@shared/background-settings/store'
40
44
  import { useBrandPageMakerUserStore } from '../user';
41
45
  import { useBrandPageContainerStore } from '../brandpage-container';
42
46
  import { useUiTemplateSettingsStore } from '@shared/template-settings/store';
47
+ import {
48
+ CONTENT_SETTINGS_MODES,
49
+ useUiContentSettingsStore,
50
+ } from '@shared/content-settings/store';
51
+ import { useUiSideBarStore } from '@shared/side-bar/store';
52
+ import { useUiEditableLogoStore } from '@shared/logo-settings/store/editable-logo-store';
53
+ import { SIDE_BAR_TAB_NAMES } from '@brand-page-maker/constants';
43
54
  import { PAGE_SECTIONS } from '@shared/page-settings/models';
44
55
  import { FabricRenderClient } from '../../../clients/fabric-render-client';
45
56
  import { setLocaleAsync } from '@src/composables/useTranslate';
@@ -302,6 +313,45 @@ describe('brand page maker store module', () => {
302
313
  );
303
314
  });
304
315
 
316
+ // bp-5634: the sub nav default is applied when content is first materialised. The
317
+ // admin maker loads a template (no designDraftToken => isUserDraft === false), so a
318
+ // colour-matched menu font colour-matches the sub nav on load. (Existing user drafts
319
+ // are skipped — covered by migration-16.test.ts.)
320
+ test('hamburger template in admin colour-matches the sub nav when the font is matched', async () => {
321
+ useBrandPageMakerUserStore().setUserState({ isAdmin: true });
322
+
323
+ const store = useBrandPageMakerStore();
324
+
325
+ const hamburgerHeader = (displayStyle: string) => ({
326
+ displayStyle,
327
+ navigation: {
328
+ displayType: NAVIGATION_DISPLAY.HAMBURGER_1,
329
+ hamburgerMenuStyle: {
330
+ defaultButtonStyle: { color: STYLE_THEME_KEYS.LogoTextColor },
331
+ },
332
+ },
333
+ });
334
+
335
+ await store.initialise({
336
+ ...INITIALISE_PAYLOAD,
337
+ brandPage: {
338
+ ...BRAND_PAGE,
339
+ pageHeaderDesktop: hamburgerHeader(HEADER_DISPLAY.DESKTOP_HAMBURGER_1),
340
+ pageHeaderMobile: hamburgerHeader(HEADER_DISPLAY.MOBILE_HAMBURGER_1),
341
+ },
342
+ });
343
+ await store.initialiseAdminMaker({ models: [] });
344
+
345
+ const hamburger =
346
+ useUiNavigationStyleSettingsStore().navigation[PAGE_SECTIONS.header][
347
+ VIEWPORTS.desktop
348
+ ].hamburgerMenuStyle;
349
+
350
+ expect(hamburger.subNavBackgroundColor).toBe(
351
+ STYLE_THEME_KEYS.LogoBackgroundColor,
352
+ );
353
+ });
354
+
305
355
  test('brand page maker module should returns distinct brand page content type', async () => {
306
356
  // Arrange
307
357
  const store = useBrandPageMakerStore();
@@ -560,4 +610,331 @@ describe('brand page maker store module', () => {
560
610
  // Assert
561
611
  expect(setDesignTemplateTokenSpy).not.toHaveBeenCalled();
562
612
  });
613
+
614
+ // BP-5506 regression: applyHistorySnapshot must replace nested navigation
615
+ // style refs as a whole, not deep-merge them. The previous bug was that
616
+ // object-form $patch would leave keys present in the live state but absent
617
+ // from the snapshot in place — e.g. switching nav button styles then
618
+ // undoing would leave the new style's borderColor / borderRadius applied.
619
+ test('applyHistorySnapshot replaces navigation styles wholesale (no key bleed across undo)', async () => {
620
+ // Arrange — initialise the maker so `applyHistorySnapshot` has a
621
+ // populated set of dependent stores to write into.
622
+ const makerStore = useBrandPageMakerStore();
623
+ const navigationStyleSettingsStore = useUiNavigationStyleSettingsStore();
624
+
625
+ await makerStore.initialise(INITIALISE_PAYLOAD);
626
+
627
+ // Build snapshot A — the "older" state we'll undo back to. Keep the
628
+ // navigation simple: only borderRadius is set on selectedButtonStyle.
629
+ const snapshotA = {
630
+ ...makerStore.brandPageData,
631
+ pageHeaderDesktop: {
632
+ ...makerStore.brandPageData.pageHeaderDesktop,
633
+ navigation: {
634
+ ...makerStore.brandPageData.pageHeaderDesktop?.navigation,
635
+ selectedButtonStyle: {
636
+ borderRadius: '0px',
637
+ },
638
+ },
639
+ },
640
+ } as BrandPageModel;
641
+
642
+ // Build snapshot B — the "newer" state with extra keys that the
643
+ // older snapshot does NOT have. If $patch deep-merged, these would
644
+ // survive an undo back to A.
645
+ const snapshotB = {
646
+ ...snapshotA,
647
+ pageHeaderDesktop: {
648
+ ...snapshotA.pageHeaderDesktop,
649
+ navigation: {
650
+ ...snapshotA.pageHeaderDesktop?.navigation,
651
+ selectedButtonStyle: {
652
+ borderRadius: '12px',
653
+ borderColor: 'rgb(255, 0, 0)',
654
+ borderStyle: 'dashed',
655
+ borderWidth: '4px',
656
+ },
657
+ },
658
+ },
659
+ } as BrandPageModel;
660
+
661
+ // Act — apply newer first (simulates the user making the edit), then
662
+ // older (simulates the undo). NavigationDesktop's constructor folds
663
+ // its input over a defaults object, so we read the resulting state
664
+ // and assert against the keys that came from snapshotB but NOT from
665
+ // snapshotA.
666
+ await makerStore.applyHistorySnapshot(snapshotB);
667
+ await makerStore.applyHistorySnapshot(snapshotA);
668
+
669
+ // Assert — after the undo, no keys from B should bleed through onto
670
+ // A's selectedButtonStyle. Specifically the values that are unique to
671
+ // B (red dashed border) must not be present.
672
+ const restored =
673
+ navigationStyleSettingsStore.navigation[PAGE_SECTIONS.header][
674
+ VIEWPORTS.desktop
675
+ ];
676
+ const restoredSelected = restored.selectedButtonStyle;
677
+
678
+ expect(restoredSelected.borderRadius).toBe('0px');
679
+ // The B-only values must not survive the undo. NavigationStyles'
680
+ // constructor seeds defaults for selectedButtonStyle, so we assert
681
+ // the *exact* B-only values are gone rather than a strict superset.
682
+ expect(restoredSelected.borderColor).not.toBe('rgb(255, 0, 0)');
683
+ expect(restoredSelected.borderStyle).not.toBe('dashed');
684
+ expect(restoredSelected.borderWidth).not.toBe('4px');
685
+ });
686
+
687
+ // BP-5506 regression: undoing a page-add must clear the URL/active-page
688
+ // back to a page that exists in the restored snapshot. The page-tabs
689
+ // carousel keys "selected" off the route URL; after `setNav` removes the
690
+ // added route, no nav item matches the URL slug and the highlight
691
+ // disappears. `applyHistorySnapshot` accepts an `activePageId` and writes
692
+ // it through `pageNavigationStore.setCurrentActivePage` so the routeStore
693
+ // and `currentPage` getter realign.
694
+ test('applyHistorySnapshot updates pageNavigation.activePageId when given a valid id', async () => {
695
+ const makerStore = useBrandPageMakerStore();
696
+ const pageNavigationStore = usePageNavigationStore();
697
+
698
+ await makerStore.initialise(INITIALISE_PAYLOAD);
699
+
700
+ const restoredPageId = pageNavigationStore.routes[0]?.pageId;
701
+
702
+ expect(restoredPageId).toBeDefined();
703
+
704
+ pageNavigationStore.activePageId = '';
705
+
706
+ await makerStore.applyHistorySnapshot(
707
+ makerStore.brandPageData,
708
+ restoredPageId,
709
+ );
710
+
711
+ expect(pageNavigationStore.activePageId).toBe(restoredPageId);
712
+ });
713
+
714
+ test('applyHistorySnapshot falls back to first/default route when no activePageId is provided', async () => {
715
+ const makerStore = useBrandPageMakerStore();
716
+ const pageNavigationStore = usePageNavigationStore();
717
+
718
+ await makerStore.initialise(INITIALISE_PAYLOAD);
719
+
720
+ const expectedFirstId =
721
+ pageNavigationStore.getFirstOrDefaultRoute()?.pageId;
722
+
723
+ expect(expectedFirstId).toBeDefined();
724
+
725
+ pageNavigationStore.activePageId = 'stale-page-id-not-in-nav';
726
+
727
+ await makerStore.applyHistorySnapshot(makerStore.brandPageData);
728
+
729
+ expect(pageNavigationStore.activePageId).toBe(expectedFirstId);
730
+ });
731
+
732
+ // BP-5506 follow-up: undoing a non-page-structural edit (e.g. a title
733
+ // change) must NOT push a new route. The router push fires
734
+ // `router.afterEach`, and BrandPageMaker.mixin's afterEach hook resets
735
+ // the content-settings modeStack — which would snap the sidebar back
736
+ // to the default Content tab on every undo, even when the user was
737
+ // deep-editing a content item. Same-page navigation MUST be skipped.
738
+ test('applyHistorySnapshot does NOT touch modeStack when active page is unchanged', async () => {
739
+ const makerStore = useBrandPageMakerStore();
740
+ const pageNavigationStore = usePageNavigationStore();
741
+ const contentSettingsStore = useUiContentSettingsStore();
742
+
743
+ await makerStore.initialise(INITIALISE_PAYLOAD);
744
+
745
+ const activePageId = pageNavigationStore.routes[0]?.pageId;
746
+
747
+ expect(activePageId).toBeDefined();
748
+
749
+ pageNavigationStore.activePageId = activePageId!;
750
+
751
+ // User is deep-editing a content item — focused mode pushed onto the stack.
752
+ const realItemId = contentSettingsStore.items[0]?.id;
753
+
754
+ expect(realItemId).toBeDefined();
755
+
756
+ contentSettingsStore.pushMode({
757
+ mode: CONTENT_SETTINGS_MODES.focusedContentItem,
758
+ selectedItemId: realItemId,
759
+ });
760
+ contentSettingsStore.selectedItemId = realItemId;
761
+
762
+ expect(contentSettingsStore.mode).toBe(
763
+ CONTENT_SETTINGS_MODES.focusedContentItem,
764
+ );
765
+
766
+ // Apply a snapshot whose activePageId equals the current page (i.e.
767
+ // a non-structural edit that didn't change pages — title edit, color
768
+ // change, etc.).
769
+ await makerStore.applyHistorySnapshot(
770
+ makerStore.brandPageData,
771
+ activePageId,
772
+ );
773
+
774
+ // Mode stack is preserved — no router.afterEach was triggered.
775
+ expect(contentSettingsStore.mode).toBe(
776
+ CONTENT_SETTINGS_MODES.focusedContentItem,
777
+ );
778
+ expect(contentSettingsStore.selectedItemId).toBe(realItemId);
779
+ });
780
+
781
+ // BP-5506 regression: when undoing a content add, the selected item
782
+ // disappears. The fallback must restore the Content tab's natural
783
+ // landing state (mode = edit, selectedItemId = null), not just switch
784
+ // tabs — otherwise `<FocusedContentItemSettings>` keeps rendering for
785
+ // a missing item and paints a blank panel.
786
+ test('applyHistorySnapshot resets sidebar to default Content tab when selected item is gone', async () => {
787
+ const makerStore = useBrandPageMakerStore();
788
+ const contentSettingsStore = useUiContentSettingsStore();
789
+ const sideBarStore = useUiSideBarStore();
790
+
791
+ await makerStore.initialise(INITIALISE_PAYLOAD);
792
+
793
+ // Simulate the user opening a content item's focused settings.
794
+ const orphanItemId = 'orphan-content-id-not-in-snapshot';
795
+
796
+ contentSettingsStore.pushMode({
797
+ mode: CONTENT_SETTINGS_MODES.focusedContentItem,
798
+ selectedItemId: orphanItemId,
799
+ });
800
+ contentSettingsStore.selectedItemId = orphanItemId;
801
+ sideBarStore.setSelectedTabName({
802
+ tabName: SIDE_BAR_TAB_NAMES.CONTENT_SETTINGS,
803
+ });
804
+
805
+ // Pre-condition: panel is showing the focused content item.
806
+ expect(contentSettingsStore.mode).toBe(
807
+ CONTENT_SETTINGS_MODES.focusedContentItem,
808
+ );
809
+ expect(contentSettingsStore.selectedItemId).toBe(orphanItemId);
810
+
811
+ // Snapshot does NOT contain orphanItemId — simulates undo of an add.
812
+ await makerStore.applyHistorySnapshot(makerStore.brandPageData);
813
+
814
+ // Post-condition: same shape as a fresh Content tab click.
815
+ expect(contentSettingsStore.mode).toBe(CONTENT_SETTINGS_MODES.edit);
816
+ expect(contentSettingsStore.selectedItemId).toBeNull();
817
+ expect(sideBarStore.selectedTabName).toBe(
818
+ SIDE_BAR_TAB_NAMES.CONTENT_SETTINGS,
819
+ );
820
+ });
821
+
822
+ // BP-5506 follow-up: applyHistorySnapshot accepts a `logoEdits` JSON
823
+ // string (sidecar to brandPageData; pre-purchase logo-tab form-field
824
+ // state). On undo it must wholesale-replace `editableLogoStore.logoEdits`
825
+ // so the form fields reflect the pre-edit state. Wholesale replacement
826
+ // matters because a previous entry's textObjects/colors must NOT leak
827
+ // through (e.g. switching template A→B then undoing must NOT keep B's
828
+ // textObject ids in A's restored state).
829
+ test('applyHistorySnapshot restores editableLogoStore.logoEdits from sidecar', async () => {
830
+ const makerStore = useBrandPageMakerStore();
831
+ const editableLogoStore = useUiEditableLogoStore();
832
+
833
+ await makerStore.initialise(INITIALISE_PAYLOAD);
834
+
835
+ // User has typed "AcmeCo" — current logoEdits state.
836
+ editableLogoStore.logoEdits.textObjects = [
837
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
838
+ {
839
+ id: 't1',
840
+ role: 'primary-text',
841
+ text: 'AcmeCo',
842
+ textEnabled: true,
843
+ } as any,
844
+ ];
845
+
846
+ // The history entry the user is undoing TO captured "Acme".
847
+ const sidecar = JSON.stringify({
848
+ backgroundObject: { id: 'bg', type: 'rect', role: 'background' },
849
+ logoObject: {
850
+ id: 'lg',
851
+ type: 'group',
852
+ role: 'logo',
853
+ logoColors: [],
854
+ logoStrokeColors: [],
855
+ },
856
+ textObjects: [
857
+ { id: 't1', role: 'primary-text', text: 'Acme', textEnabled: true },
858
+ ],
859
+ });
860
+
861
+ await makerStore.applyHistorySnapshot(
862
+ makerStore.brandPageData,
863
+ undefined,
864
+ sidecar,
865
+ );
866
+
867
+ expect(editableLogoStore.logoEdits.textObjects).toEqual([
868
+ { id: 't1', role: 'primary-text', text: 'Acme', textEnabled: true },
869
+ ]);
870
+ });
871
+
872
+ test('applyHistorySnapshot wholesale-replaces logoEdits (no leak from prior state)', async () => {
873
+ const makerStore = useBrandPageMakerStore();
874
+ const editableLogoStore = useUiEditableLogoStore();
875
+
876
+ await makerStore.initialise(INITIALISE_PAYLOAD);
877
+
878
+ // Current state has TWO textObjects (e.g. user is on template B with a
879
+ // logo + tagline).
880
+ editableLogoStore.logoEdits.textObjects = [
881
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
882
+ {
883
+ id: 'b-1',
884
+ role: 'primary-text',
885
+ text: 'Brand B',
886
+ textEnabled: true,
887
+ } as any,
888
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
889
+ { id: 'b-2', role: 'tagline', text: 'tagline', textEnabled: true } as any,
890
+ ];
891
+
892
+ // Undo target captured template A — only ONE textObject with a
893
+ // different id. After restore, b-1 / b-2 must be gone.
894
+ const sidecar = JSON.stringify({
895
+ backgroundObject: { id: 'bg', type: 'rect', role: 'background' },
896
+ logoObject: {
897
+ id: 'lg',
898
+ type: 'group',
899
+ role: 'logo',
900
+ logoColors: [],
901
+ logoStrokeColors: [],
902
+ },
903
+ textObjects: [
904
+ { id: 'a-1', role: 'primary-text', text: 'Brand A', textEnabled: true },
905
+ ],
906
+ });
907
+
908
+ await makerStore.applyHistorySnapshot(
909
+ makerStore.brandPageData,
910
+ undefined,
911
+ sidecar,
912
+ );
913
+
914
+ expect(editableLogoStore.logoEdits.textObjects).toHaveLength(1);
915
+ expect(editableLogoStore.logoEdits.textObjects[0].id).toBe('a-1');
916
+ });
917
+
918
+ test('applyHistorySnapshot leaves logoEdits untouched when sidecar is undefined', async () => {
919
+ const makerStore = useBrandPageMakerStore();
920
+ const editableLogoStore = useUiEditableLogoStore();
921
+
922
+ await makerStore.initialise(INITIALISE_PAYLOAD);
923
+
924
+ editableLogoStore.logoEdits.textObjects = [
925
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
926
+ {
927
+ id: 't1',
928
+ role: 'primary-text',
929
+ text: 'Acme',
930
+ textEnabled: true,
931
+ } as any,
932
+ ];
933
+
934
+ // No third arg — pre-existing entries from before this feature shipped.
935
+ await makerStore.applyHistorySnapshot(makerStore.brandPageData);
936
+
937
+ // Still 'Acme' — no restore attempted.
938
+ expect(editableLogoStore.logoEdits.textObjects[0].text).toBe('Acme');
939
+ });
563
940
  });