@useinsider/guido 2.2.0-beta.fa4cec8 → 3.0.0-beta.2235a35

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 (95) hide show
  1. package/README.md +41 -2
  2. package/dist/@types/config/schemas.js +1 -1
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +66 -66
  5. package/dist/components/organisms/base/Toaster.vue.js +4 -4
  6. package/dist/components/organisms/base/Toaster.vue2.js +12 -9
  7. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
  8. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  9. package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +11 -13
  10. package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +54 -23
  11. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +7 -5
  12. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +34 -21
  13. package/dist/components/organisms/extensions/recommendation/Filters.vue.js +11 -11
  14. package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +48 -36
  15. package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue2.js +11 -9
  16. package/dist/composables/useRecommendation.js +9 -9
  17. package/dist/composables/useSave.js +16 -12
  18. package/dist/composables/useStripo.js +66 -62
  19. package/dist/composables/useStripoEventHandler.js +27 -12
  20. package/dist/composables/useSyncModuleExtractor.js +45 -0
  21. package/dist/config/compiler/utils/recommendationCompilerUtils.js +1 -1
  22. package/dist/config/migrator/recommendationMigrator.js +1 -1
  23. package/dist/enums/unsubscribe.js +25 -21
  24. package/dist/extensions/Blocks/Recommendation/block.js +1 -1
  25. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +36 -33
  26. package/dist/extensions/Blocks/Recommendation/constants/layout.js +16 -14
  27. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -13
  28. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +9 -9
  29. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +1 -1
  30. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +41 -29
  31. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +16 -16
  32. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +30 -32
  33. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +194 -104
  34. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +9 -9
  35. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +46 -38
  36. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +16 -16
  37. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +291 -217
  38. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +14 -14
  39. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +10 -10
  40. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
  41. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +14 -14
  42. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +9 -9
  43. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +3 -3
  44. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +1 -1
  45. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +9 -9
  46. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +3 -3
  47. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +13 -13
  48. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +3 -3
  49. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +223 -99
  50. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +172 -85
  51. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +2 -2
  52. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +1 -1
  53. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +2 -2
  54. package/dist/extensions/Blocks/Recommendation/templates/utils.js +32 -32
  55. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +8 -8
  56. package/dist/extensions/Blocks/Recommendation/validation/filterSchema.js +29 -0
  57. package/dist/guido.css +1 -1
  58. package/dist/services/stripoApi.js +55 -19
  59. package/dist/src/@types/config/schemas.d.ts +1 -1
  60. package/dist/src/@types/events.d.ts +38 -2
  61. package/dist/src/App.vue.d.ts +0 -1
  62. package/dist/src/components/Guido.vue.d.ts +2 -2
  63. package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +1 -0
  64. package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +17 -1
  65. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
  66. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
  67. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
  68. package/dist/src/composables/useGuidoActions.d.ts +1 -1
  69. package/dist/src/composables/useSave.d.ts +2 -2
  70. package/dist/src/composables/useStripo.d.ts +2 -2
  71. package/dist/src/composables/useSyncModuleExtractor.d.ts +4 -0
  72. package/dist/src/enums/unsubscribe.d.ts +3 -0
  73. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +6 -0
  74. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +3 -3
  75. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -2
  76. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +8 -1
  77. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +38 -10
  78. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +27 -14
  79. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +50 -17
  80. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +19 -2
  81. package/dist/src/extensions/Blocks/Recommendation/templates/grid/migration.d.ts +1 -1
  82. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +4 -2
  83. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +1 -1
  84. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -1
  85. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +8 -0
  86. package/dist/src/extensions/Blocks/Recommendation/validation/filterSchema.d.ts +15 -0
  87. package/dist/src/main.d.ts +3 -1
  88. package/dist/src/mock/api/settings.d.ts +2 -0
  89. package/dist/src/services/stripoApi.d.ts +5 -0
  90. package/dist/src/stores/editor.d.ts +23 -0
  91. package/dist/src/utils/templatePreparation.d.ts +1 -1
  92. package/dist/static/styles/customEditorStyle.css.js +50 -23
  93. package/dist/stores/editor.js +2 -1
  94. package/dist/utils/templatePreparation.js +1 -1
  95. package/package.json +2 -2
@@ -1,47 +1,83 @@
1
- import { useHttp as l } from "../composables/useHttp.js";
2
- import { useToaster as u } from "../composables/useToaster.js";
3
- import { MAX_DEFAULT_TEMPLATE_ID as d } from "../enums/defaults.js";
4
- import f from "../static/templates/empty/index.html.js";
5
- import g from "../static/templates/empty/style.css.js";
6
- const D = () => {
7
- const { get: o } = l(), { handleError: a } = u();
1
+ import { useHttp as d } from "../composables/useHttp.js";
2
+ import { useToaster as m } from "../composables/useToaster.js";
3
+ import { MAX_DEFAULT_TEMPLATE_ID as y } from "../enums/defaults.js";
4
+ import g from "../static/templates/empty/index.html.js";
5
+ import f from "../static/templates/empty/style.css.js";
6
+ const E = () => {
7
+ const { get: s, post: c } = d(), { handleError: r } = m();
8
8
  return {
9
9
  getToken: async () => {
10
10
  try {
11
- const t = Number(localStorage.getItem("ins-guido-test-instance")), { data: e } = await o(`/stripo/get-user-token?test=${t}`);
11
+ const t = Number(localStorage.getItem("ins-guido-test-instance")), { data: e } = await s(`/stripo/get-user-token?test=${t}`);
12
12
  return e.body.token;
13
13
  } catch (t) {
14
- return a(t, "Failed to fetch token"), "";
14
+ return r(t, "Failed to fetch token"), "";
15
15
  }
16
16
  },
17
17
  getCustomFonts: async () => {
18
18
  try {
19
- const { data: t = [] } = await o("/stripo/get-partner-custom-fonts");
19
+ const { data: t = [] } = await s("/stripo/get-partner-custom-fonts");
20
20
  return t.map((e) => ({
21
21
  ...e,
22
22
  active: !0
23
23
  }));
24
24
  } catch (t) {
25
- return a(t, "Failed to fetch custom fonts"), [];
25
+ return r(t, "Failed to fetch custom fonts"), [];
26
26
  }
27
27
  },
28
28
  getDefaultTemplate: async () => {
29
29
  const t = {
30
- html: f,
31
- css: g
30
+ html: g,
31
+ css: f
32
32
  };
33
33
  try {
34
- const e = new URLSearchParams(window.location.search), c = e.get("default-template"), p = e.get("master"), s = c ? parseInt(c) : 0, m = s >= 1 && s <= d ? s : 0;
35
- if (!m && !p)
34
+ const e = new URLSearchParams(window.location.search), u = e.get("default-template"), l = e.get("master"), a = u ? parseInt(u) : 0, i = a >= 1 && a <= y ? a : 0;
35
+ if (!i && !l)
36
36
  return t;
37
- const i = `/stripo/default-template/${m}`, { data: n } = await o(i), r = typeof n == "string" ? JSON.parse(n) : n;
38
- return !r || typeof r != "object" || !("html" in r) || !("css" in r) ? t : r;
37
+ const p = `/stripo/default-template/${i}`, { data: n } = await s(p), o = typeof n == "string" ? JSON.parse(n) : n;
38
+ return !o || typeof o != "object" || !("html" in o) || !("css" in o) ? t : o;
39
39
  } catch (e) {
40
- return a(e, "Failed to fetch default template"), t;
40
+ return r(e, "Failed to fetch default template"), t;
41
+ }
42
+ },
43
+ getSyncModulesStatus: async () => {
44
+ try {
45
+ const { data: t } = await s("/newsletter/settings/synchronisation-in-modules-status");
46
+ return t.status;
47
+ } catch (t) {
48
+ return r(t, "Failed to fetch sync modules status"), !1;
49
+ }
50
+ },
51
+ updateSyncModule: async (t) => {
52
+ try {
53
+ return await c(`/stripo/stripo-modules/${t.moduleId}/update`), !0;
54
+ } catch (e) {
55
+ return r(e, "Failed to update sync module"), !1;
56
+ }
57
+ },
58
+ getSyncModule: async (t) => {
59
+ try {
60
+ const { data: e } = await s(`/stripo/stripo-modules/${t}/get`);
61
+ return e;
62
+ } catch (e) {
63
+ return r(e, "Failed to get sync module"), {
64
+ id: 0,
65
+ stripoId: 0,
66
+ unsubscriptionPreferencePages: []
67
+ };
68
+ }
69
+ },
70
+ setSyncModuleUnsubscriptionPages: async (t) => {
71
+ if (t.length === 0)
72
+ return !0;
73
+ try {
74
+ return await c("/stripo/stripo-modules/set-unsubscription-preference-pages", t), !0;
75
+ } catch (e) {
76
+ return r(e, "Failed to set unsubscription preference pages"), !1;
41
77
  }
42
78
  }
43
79
  };
44
80
  };
45
81
  export {
46
- D as useStripoApi
82
+ E as useStripoApi
47
83
  };
@@ -12,7 +12,7 @@ import * as v from 'valibot';
12
12
  * @param data - The template details to validate
13
13
  * @returns Promise<boolean> - true if valid, false to cancel save
14
14
  */
15
- export type ExternalValidationHandler = (data: SavedTemplateDetails) => Promise<boolean>;
15
+ export type ExternalValidationHandler = (data: Omit<SavedTemplateDetails, 'metadata'>) => Promise<boolean>;
16
16
  /**
17
17
  * Message type constants for email templates
18
18
  */
@@ -1,6 +1,42 @@
1
- export type StripoEventType = 'save' | 'export' | 'close' | 'autosave' | 'publish' | 'export:requested' | 'export:ready';
1
+ export type StripoEventType = 'save' | 'export' | 'close' | 'autosave' | 'publish' | 'export:requested' | 'export:ready' | 'module_updated' | 'module_dropped';
2
+ export interface ModuleUpdatedParams {
3
+ target: string;
4
+ blockType: string;
5
+ moduleId: number;
6
+ moduleCategory: string | null;
7
+ syncModule: boolean;
8
+ }
9
+ export interface ModuleDroppedParams {
10
+ target: string;
11
+ blockType: string;
12
+ moduleId: number;
13
+ syncModule: boolean;
14
+ }
15
+ export interface SyncModuleUnsubscribePayload {
16
+ stripoModuleId: string;
17
+ unsubscriptionPreferencePages: number[];
18
+ type: string;
19
+ }
20
+ export interface SyncModuleExtractResult {
21
+ unsubscribePayload: SyncModuleUnsubscribePayload[];
22
+ stripoModules: number[];
23
+ }
24
+ export interface SyncModuleResponse {
25
+ id: number;
26
+ stripoId: number;
27
+ unsubscriptionPreferencePages: UnsubscriptionPreferencePage[];
28
+ }
29
+ export interface UnsubscriptionPreferencePage {
30
+ id: number;
31
+ name: string;
32
+ type: number;
33
+ status: number;
34
+ isVisible: number;
35
+ thumbnail: string;
36
+ createdAt: string;
37
+ }
2
38
  export interface EventHandler {
3
- (params: Record<string, string>): void | Promise<void>;
39
+ (params: Record<string, unknown>): void | Promise<void>;
4
40
  }
5
41
  export interface EventHandlers {
6
42
  [eventType: string]: EventHandler;
@@ -1,3 +1,2 @@
1
- import '../node_modules/@useinsider/design-system-vue/dist/design-system-vue.css';
2
1
  declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
3
2
  export default _default;
@@ -11,7 +11,7 @@ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__
11
11
  close: () => void;
12
12
  };
13
13
  hasChanges: import("vue").ComputedRef<boolean>;
14
- saveSilent: () => Promise<SavedTemplateDetails | undefined> | undefined;
14
+ saveSilent: () => Promise<Omit<SavedTemplateDetails, "metadata"> | undefined> | undefined;
15
15
  }, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
16
16
  "dynamic-content:open": (detail: {
17
17
  text: string;
@@ -24,7 +24,7 @@ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__
24
24
  } | null, position?: PositionData | undefined) => void;
25
25
  back: () => void;
26
26
  "save:start": () => void;
27
- "save:complete": (data: Omit<SavedTemplateDetails, "forceRecreate">) => void;
27
+ "save:complete": (data: SavedTemplateDetails) => void;
28
28
  "on-change": (hasChanges: boolean) => void;
29
29
  ready: () => void;
30
30
  "onboarding:finished": () => void;
@@ -3,6 +3,7 @@ type __VLS_Props = {
3
3
  filter: Filter;
4
4
  index: number;
5
5
  hasLogicAdapter?: boolean;
6
+ submitted: boolean;
6
7
  };
7
8
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
8
9
  "delete-filter": (filter: Filter) => void;
@@ -1,2 +1,18 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
1
+ type __VLS_Props = {
2
+ submitted: boolean;
3
+ };
4
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {
5
+ switchToGroup: (groupId: number) => void;
6
+ }, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
7
+ "reset-validation": () => void;
8
+ }, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}>;
2
9
  export default _default;
10
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
11
+ type __VLS_TypePropsToOption<T> = {
12
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
13
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
14
+ } : {
15
+ type: import('vue').PropType<T[K]>;
16
+ required: true;
17
+ };
18
+ };
@@ -1,4 +1,4 @@
1
1
  declare const _default: import("vue").DefineComponent<{}, {
2
- handleSave: (isSilent: boolean) => Promise<import("../../../@types/stripo").SavedTemplateDetails | undefined>;
2
+ handleSave: (isSilent: boolean) => Promise<Omit<import("../../../@types/stripo").SavedTemplateDetails, "metadata"> | undefined>;
3
3
  }, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
4
4
  export default _default;
@@ -1,4 +1,4 @@
1
1
  declare const _default: import("vue").DefineComponent<{}, {
2
- handleSave: (isSilent: boolean) => Promise<import("../../../@types/stripo.js").SavedTemplateDetails | undefined> | undefined;
2
+ handleSave: (isSilent: boolean) => Promise<Omit<import("../../../@types/stripo.js").SavedTemplateDetails, "metadata"> | undefined> | undefined;
3
3
  }, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
4
4
  export default _default;
@@ -1,4 +1,4 @@
1
1
  declare const _default: import("vue").DefineComponent<{}, {
2
- handleSave: (isSilent: boolean) => Promise<import("../../../@types/stripo.js").SavedTemplateDetails | undefined> | undefined;
2
+ handleSave: (isSilent: boolean) => Promise<Omit<import("../../../@types/stripo.js").SavedTemplateDetails, "metadata"> | undefined> | undefined;
3
3
  }, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
4
4
  export default _default;
@@ -2,7 +2,7 @@ import type { SavedTemplateDetails } from '@@/Types/stripo';
2
2
  import type { InjectionKey } from 'vue';
3
3
  export type BackHandler = () => void;
4
4
  export type SaveStartHandler = () => void;
5
- export type SaveCompleteHandler = (template: Omit<SavedTemplateDetails, 'forceRecreate'>) => void;
5
+ export type SaveCompleteHandler = (template: Omit<SavedTemplateDetails, 'metadata'>) => void;
6
6
  export type TestEmailClickHandler = () => void;
7
7
  export declare const BACK_KEY: InjectionKey<BackHandler>;
8
8
  export declare const SAVE_START_KEY: InjectionKey<SaveStartHandler>;
@@ -1,4 +1,4 @@
1
- import { SavedTemplateDetails } from '@@/Types/stripo';
1
+ import type { SavedTemplateDetails } from '@@/Types/stripo';
2
2
  export declare const useSave: () => {
3
- save: (isSilent?: boolean) => Promise<SavedTemplateDetails | undefined>;
3
+ save: (isSilent?: boolean) => Promise<Omit<SavedTemplateDetails, "metadata"> | undefined>;
4
4
  };
@@ -1,4 +1,4 @@
1
- import type { Metadata, Template } from '@@/Types/stripo';
2
- export declare const useStripo: (metadata: Metadata) => {
1
+ import type { Metadata, Options, Template } from '@@/Types/stripo';
2
+ export declare const useStripo: (metadata: Metadata, options: Options) => {
3
3
  initPlugin: (template: Template) => Promise<void>;
4
4
  };
@@ -0,0 +1,4 @@
1
+ import type { SyncModuleExtractResult } from '@@/Types/events';
2
+ export declare const useSyncModuleExtractor: () => {
3
+ extractSyncModuleData: (html: string) => SyncModuleExtractResult;
4
+ };
@@ -25,6 +25,9 @@ export declare const PAGE_TYPES: {
25
25
  SUBSCRIPTION_PREFERENCE_CONFIRMATION: number;
26
26
  RESUBSCRIBE: number;
27
27
  };
28
+ export declare const UNSUBSCRIBE_SYNC_MODULE_TYPES: {
29
+ [x: number]: string;
30
+ };
28
31
  export declare const TYPE_COLLECTIONS: {
29
32
  [x: number]: number[];
30
33
  };
@@ -41,6 +41,12 @@ export declare const DEFAULT_VISIBILITY: Record<string, boolean>;
41
41
  * All other code should import and use this constant.
42
42
  */
43
43
  export declare const DEFAULT_NODE_CONFIG: RecommendationNodeConfig;
44
+ /**
45
+ * Algorithm IDs to exclude from the recommendation algorithm dropdown.
46
+ * These algorithms will not be shown as options regardless of API response.
47
+ * View Together and Purchase Together algorithms are disabled because these require product id.
48
+ */
49
+ export declare const EXCLUDED_ALGORITHM_IDS: number[];
44
50
  /**
45
51
  * Current configuration version
46
52
  * Increment this when making breaking changes to the schema
@@ -8,6 +8,6 @@
8
8
  */
9
9
  export { RecommendationBlockId } from './blockIds';
10
10
  export { RecommendationControlId } from './controlIds';
11
- export { CONTAINER_SELECTOR, DESKTOP_CONTAINER_SELECTOR, MOBILE_CONTAINER_SELECTOR, CURRENCY_ATTR, ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON, } from './selectors';
12
- export { LAYOUT_VALUES, LAYOUT_OPTIONS, DEFAULT_PRODUCTS_PER_ROW, DEFAULT_CARDS_IN_ROW, DEFAULT_MOBILE_CARDS_IN_ROW, MAX_PRODUCT_COUNT, MIN_PRODUCT_COUNT, MAX_PRODUCTS_PER_ROW, MIN_PRODUCTS_PER_ROW, MAX_MOBILE_PRODUCTS_PER_ROW, MIN_MOBILE_PRODUCTS_PER_ROW, DEFAULT_COLUMN_SPACING, DEFAULT_ROW_SPACING, MIN_SPACING, MAX_SPACING, SPACING_STEP, } from './layout';
13
- export { DEFAULT_NODE_CONFIG, DEFAULT_CURRENCY, DEFAULT_COMPOSITION, DEFAULT_VISIBILITY, CURRENT_CONFIG_VERSION, } from './defaultConfig';
11
+ export { BLOCK_ROOT_SELECTOR, CONTAINER_SELECTOR, DESKTOP_CONTAINER_SELECTOR, MOBILE_CONTAINER_SELECTOR, MOBILE_ROW_SELECTOR, CURRENCY_ATTR, ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON, } from './selectors';
12
+ export { LAYOUT_VALUES, LAYOUT_OPTIONS, DEFAULT_PRODUCTS_PER_ROW, DEFAULT_CARDS_IN_ROW, DEFAULT_MOBILE_CARDS_IN_ROW, MAX_PRODUCT_COUNT, MIN_PRODUCT_COUNT, MAX_PRODUCTS_PER_ROW, MIN_PRODUCTS_PER_ROW, MAX_MOBILE_PRODUCTS_PER_ROW, MIN_MOBILE_PRODUCTS_PER_ROW, DEFAULT_COLUMN_SPACING, DEFAULT_ROW_SPACING, DEFAULT_MOBILE_COLUMN_SPACING, DEFAULT_MOBILE_ROW_SPACING, MIN_SPACING, MAX_SPACING, SPACING_STEP, } from './layout';
13
+ export { DEFAULT_NODE_CONFIG, DEFAULT_CURRENCY, DEFAULT_COMPOSITION, DEFAULT_VISIBILITY, CURRENT_CONFIG_VERSION, EXCLUDED_ALGORITHM_IDS, } from './defaultConfig';
@@ -31,8 +31,12 @@ export declare const MAX_MOBILE_PRODUCTS_PER_ROW = 2;
31
31
  export declare const MIN_MOBILE_PRODUCTS_PER_ROW = 1;
32
32
  /** Default column spacing between product cards (5px on each side = 10px total) */
33
33
  export declare const DEFAULT_COLUMN_SPACING = 10;
34
- /** Default row spacing between product rows */
35
- export declare const DEFAULT_ROW_SPACING = 20;
34
+ /** Default row spacing between product rows (matches spacer height in template) */
35
+ export declare const DEFAULT_ROW_SPACING = 10;
36
+ /** Default mobile column spacing between product cards */
37
+ export declare const DEFAULT_MOBILE_COLUMN_SPACING = 10;
38
+ /** Default mobile row spacing between product rows (matches spacer height in template) */
39
+ export declare const DEFAULT_MOBILE_ROW_SPACING = 10;
36
40
  /** Minimum spacing value */
37
41
  export declare const MIN_SPACING = 0;
38
42
  /** Maximum spacing value */
@@ -1,15 +1,22 @@
1
1
  /**
2
2
  * CSS selectors and data attributes used across the Recommendation extension
3
3
  */
4
+ /**
5
+ * Block root selector — common ancestor of both desktop and mobile containers.
6
+ * Used across attribute controls so edits apply to BOTH containers simultaneously.
7
+ */
8
+ export declare const BLOCK_ROOT_SELECTOR = ".recommendation-block-v2";
4
9
  /**
5
10
  * Container selector for the product container element
6
- * Used across controls to target elements within the recommendation block
11
+ * Used in product regeneration logic where container-specific scoping is needed
7
12
  */
8
13
  export declare const CONTAINER_SELECTOR = ".ins-recommendation-product-container";
9
14
  /** Desktop product container selector */
10
15
  export declare const DESKTOP_CONTAINER_SELECTOR = ".ins-recommendation-desktop-container";
11
16
  /** Mobile product container selector */
12
17
  export declare const MOBILE_CONTAINER_SELECTOR = ".ins-recommendation-mobile-container";
18
+ /** Mobile row wrapper — the <tr> that wraps the mobile container <td>/<table> */
19
+ export declare const MOBILE_ROW_SELECTOR = ".ins-recommendation-mobile-row";
13
20
  /**
14
21
  * Currency HTML attributes set on the block element
15
22
  * These are read by the HTML compiler at runtime to format prices
@@ -25,18 +25,13 @@ export declare class RecommendationBlockControl extends CommonControl {
25
25
  getId(): string;
26
26
  getTemplate(): string;
27
27
  onRender(): Promise<void>;
28
- /**
29
- * Immediately regenerate products with styles (no debounce)
30
- * Used for initial load after fetch completes
31
- */
32
- private _regenerateWithProducts;
33
28
  onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
34
29
  onDestroy(): void;
35
30
  /**
36
31
  * Initialize all sub-controls with the shared API context
37
32
  * Each sub-control manages its own form values and event listeners
38
33
  */
39
- _initializeSubControls(): void;
34
+ private _initializeSubControls;
40
35
  /**
41
36
  * Syncs persisted node config into the Pinia store's block state.
42
37
  *
@@ -50,11 +45,26 @@ export declare class RecommendationBlockControl extends CommonControl {
50
45
  */
51
46
  private _syncNodeConfigToStore;
52
47
  /**
53
- * Fetches initial data for a block (filters, algorithms, products).
48
+ * Fetches initial data for a block in three phases:
49
+ * 1. Shared reference data (algorithms, currencies, filters) — parallel
50
+ * 2. Smart defaults for new blocks (currency, algorithm) — sequential
51
+ * 3. Product data with correct defaults — sequential
52
+ *
54
53
  * Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
55
54
  * Marks the block as initialized to prevent redundant fetches on re-selection.
56
55
  */
57
56
  private _fetchBlockData;
57
+ /**
58
+ * Applies smart defaults for newly dropped blocks.
59
+ *
60
+ * For new blocks (config still matches hardcoded defaults), validates that
61
+ * the default currency and algorithm are available from the API response.
62
+ * If not, falls back to the first available option.
63
+ *
64
+ * Saved templates with user-customized config are left unchanged because
65
+ * their values won't match the hardcoded defaults.
66
+ */
67
+ private _applySmartDefaults;
58
68
  /**
59
69
  * Reads the recommendation-id attribute from the block element within the node
60
70
  */
@@ -64,8 +74,15 @@ export declare class RecommendationBlockControl extends CommonControl {
64
74
  */
65
75
  private _debouncedFetchProducts;
66
76
  /**
67
- * Debounced regeneration when products arrive from API
68
- * Tries in-place update first to preserve styles, falls back to full regeneration
77
+ * Debounced content update when products arrive from API.
78
+ *
79
+ * Tries in-place update first (preserves user-applied styles) — this succeeds
80
+ * when the product count matches the DOM (algorithm/locale/currency changes).
81
+ *
82
+ * Falls back to full regeneration when product count differs from DOM — this
83
+ * happens after "Number of Products" changes where the DOM still has the old
84
+ * count. The store pads products to the configured size, so in-place only
85
+ * fails when the size actually changed.
69
86
  */
70
87
  private _debouncedRegenerateWithProducts;
71
88
  /**
@@ -74,6 +91,17 @@ export declare class RecommendationBlockControl extends CommonControl {
74
91
  * Uses configVersion counter (incremented only by patchCurrentBlockConfig)
75
92
  * to distinguish user-initiated config changes from internal mutations
76
93
  * (e.g., fetchRecommendationCreateData setting preferred currency).
94
+ *
95
+ * Tracks currentRecommendationId to detect block switches. When the user
96
+ * selects a different recommendation block, the proxy getters (e.g.,
97
+ * recommendationProducts) return the new block's data — a different array
98
+ * reference that would be falsely detected as "new products arrived".
99
+ * We skip that tick and update tracking references instead.
100
+ */
101
+ private _listenStateUpdates;
102
+ /**
103
+ * Persists the current filter state from Pinia store to the Stripo node config.
104
+ * This ensures filters survive template save/reload cycles.
77
105
  */
78
- _listenStateUpdates(): void;
106
+ private _persistFiltersToNodeConfig;
79
107
  }
@@ -61,6 +61,9 @@ export interface RegenerateProductRowsOptions {
61
61
  * Regenerates only the mobile product container rows.
62
62
  * Used when mobile-specific settings change (mobileCardsInRow)
63
63
  * or when the desktop container is regenerated (to keep both in sync).
64
+ *
65
+ * For list layout: hides the mobile row entirely (list is inherently responsive).
66
+ * For grid layout: shows the mobile row and populates it.
64
67
  */
65
68
  export declare function regenerateMobileProductRows(options: Omit<RegenerateProductRowsOptions, 'afterRegenerate'>): void;
66
69
  /**
@@ -75,8 +78,12 @@ export interface ReapplySpacingOptions {
75
78
  documentModifier: DocumentModifier;
76
79
  }
77
80
  /**
78
- * Reapplies spacing values from data attributes after product regeneration
79
- * This ensures spacing persists when products are regenerated
81
+ * Reapplies spacing values after product regeneration.
82
+ * Desktop spacing applies only to the desktop container;
83
+ * mobile spacing applies only to the mobile container.
84
+ *
85
+ * Reads values from node config (primary) with data-attribute fallback
86
+ * for backward compatibility with pre-nodeConfig templates.
80
87
  * @param options - Configuration options
81
88
  */
82
89
  export declare function reapplySpacing(options: ReapplySpacingOptions): void;
@@ -112,6 +119,17 @@ export interface RegenerateWithStylesOptions extends Omit<RegenerateProductRowsO
112
119
  * @param options - Configuration options for regeneration
113
120
  */
114
121
  export declare function regenerateProductRowsWithStyles(options: RegenerateWithStylesOptions): void;
122
+ /**
123
+ * Adjusts a products array to a target size.
124
+ * Used by ProductLayoutControl to synchronously match products to the new size
125
+ * before regeneration, avoiding the race condition where the store still holds
126
+ * products from the previous (stale) fetch.
127
+ *
128
+ * - More products than target → truncate
129
+ * - Fewer products than target → pad with dummy products
130
+ * - Exact match → return as-is
131
+ */
132
+ export declare function adjustProductsToSize(products: RecommendationProduct[], targetSize: number): RecommendationProduct[];
115
133
  type PriceKey = 'price' | 'original_price' | 'discount';
116
134
  /**
117
135
  * Formats a product price using current currency settings
@@ -149,16 +167,11 @@ export interface UpdateProductContentInPlaceOptions {
149
167
  * Updates product content in-place without regenerating HTML structure.
150
168
  * Preserves all user-applied styles by only touching dynamic content.
151
169
  *
152
- * This is the preferred method when:
153
- * - Product data changed but count remains the same
154
- * - Currency/locale changed (prices need reformatting)
155
- *
156
- * Uses setText() on text nodes instead of setInnerHtml() to preserve
157
- * Stripo's internal node references and avoid cursor/selection tracking issues.
170
+ * Scopes element queries to the desktop container to avoid double-counting
171
+ * mobile container elements (both containers share identical block IDs).
172
+ * After updating desktop, also updates mobile container to keep them in sync.
158
173
  *
159
- * Falls back to false when:
160
- * - Product count changed (need to add/remove elements)
161
- * - Cannot find required elements
174
+ * Falls back to false when product count changed (need to add/remove elements).
162
175
  * @param options - Configuration options
163
176
  * @returns true if in-place update was successful, false to fall back to full regeneration
164
177
  */
@@ -171,13 +184,13 @@ export interface UpdatePricesInPlaceOptions {
171
184
  * Updates only price displays in-place (for currency changes).
172
185
  * This is a lightweight update when only formatting changes, not product data.
173
186
  *
187
+ * Scopes element queries to the desktop container to avoid double-counting
188
+ * mobile container elements. After updating desktop, also updates mobile.
189
+ *
174
190
  * Perfect for:
175
191
  * - Currency symbol change
176
192
  * - Currency alignment change
177
193
  * - Decimal/thousand separator changes
178
- *
179
- * Uses setText() on text nodes instead of setInnerHtml() to preserve
180
- * Stripo's internal node references and avoid cursor/selection tracking issues.
181
194
  * @param options - Configuration options
182
195
  * @returns true if update was successful, false otherwise
183
196
  */
@@ -5,16 +5,20 @@
5
5
  * - Column spacing: horizontal gap between cards in the same row
6
6
  * - Row spacing: vertical gap between different rows
7
7
  *
8
+ * Desktop and mobile have independent spacing controls that toggle
9
+ * visibility based on Stripo's editor preview mode (desktop/mobile).
10
+ *
8
11
  * Configuration is stored via node config (persists with template).
9
12
  * Actual spacing is applied to DOM elements via inline styles.
10
13
  */
11
- import { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
14
+ import { type ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
12
15
  import { CommonControl } from '../../../common-control';
13
16
  export declare const SPACING_CONTROL_ID = "recommendation-spacing-control";
14
17
  /**
15
18
  * Control for managing spacing between product cards
16
19
  * - Column spacing: horizontal gap between cards in the same row
17
20
  * - Row spacing: vertical gap between different rows
21
+ * - Separate controls for desktop and mobile with device-mode toggling
18
22
  */
19
23
  export declare class SpacingControl extends CommonControl {
20
24
  private store;
@@ -25,17 +29,28 @@ export declare class SpacingControl extends CommonControl {
25
29
  onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
26
30
  onDestroy(): void;
27
31
  /**
28
- * Updates column spacing visibility based on layout orientation
29
- * Column spacing is hidden for list layout (products are stacked vertically)
30
- * Reads from node config first, falls back to store then DOM
32
+ * Checks if the editor is currently in mobile preview mode
33
+ * using Stripo's EditorStatePropertyType API.
34
+ */
35
+ _isMobileMode(): boolean;
36
+ /**
37
+ * Updates spacing control visibility based on layout orientation, editor mode,
38
+ * and products-per-row count.
39
+ * - List layout: hide column spacing (products are full-width), hide ALL mobile
40
+ * spacing controls (list is responsive — single row spacing applies to both views)
41
+ * - Desktop mode: show desktop spacing, hide mobile spacing
42
+ * - Mobile mode: show mobile spacing, hide desktop spacing
43
+ * - 1 product per row: hide column spacing (no gap between single column)
31
44
  */
32
- _updateColumnSpacingVisibility(): void;
45
+ _updateSpacingVisibility(): void;
33
46
  /**
34
- * Reads spacing values from node config first, falls back to DOM styles
47
+ * Reads spacing values from node config first, falls back to DOM styles.
48
+ * DOM fallback is only used for legacy templates that lack node config.
35
49
  */
36
50
  _setFormValues(): void;
37
51
  /**
38
52
  * Gets stored column spacing from the first attribute row cell's padding.
53
+ * Scoped to the desktop container for accurate readings.
39
54
  * For grid layout: cells inside .recommendation-attribute-row have padding applied.
40
55
  * For list layout: the parent of .product-card-wrapper has the padding.
41
56
  * The padding is applied as "0 {halfSpacing}px", so we extract and multiply by 2.
@@ -43,27 +58,33 @@ export declare class SpacingControl extends CommonControl {
43
58
  _getStoredColumnSpacing(): number;
44
59
  /**
45
60
  * Gets stored row spacing from the first spacer element's height style
61
+ * Scoped to the desktop container for accurate readings.
46
62
  */
47
63
  _getStoredRowSpacing(): number;
48
64
  /**
49
- * Handles column spacing changes.
50
- * For grid layout: applies horizontal padding to all cells inside attribute rows.
51
- * For list layout: applies padding to parent of product card wrappers.
65
+ * Handles column spacing changes for desktop.
66
+ * Applies horizontal padding only to the desktop container elements.
52
67
  */
53
68
  _onColumnSpacingChange(spacing: number): void;
54
69
  /**
55
- * Handles row spacing changes
56
- * Applies height to all spacer elements between product rows
70
+ * Handles row spacing changes for desktop.
71
+ * Applies height only to spacer elements in the desktop container.
57
72
  */
58
73
  _onRowSpacingChange(spacing: number): void;
59
74
  /**
60
- * Stores column spacing value in block data attribute
75
+ * Handles column spacing changes for mobile.
76
+ * Applies horizontal padding only to the mobile container elements.
61
77
  */
62
- _storeColumnSpacing(spacing: number): void;
78
+ _onMobileColumnSpacingChange(spacing: number): void;
63
79
  /**
64
- * Stores row spacing value in block data attribute
80
+ * Handles row spacing changes for mobile.
81
+ * Applies height only to spacer elements in the mobile container.
65
82
  */
66
- _storeRowSpacing(spacing: number): void;
83
+ _onMobileRowSpacingChange(spacing: number): void;
84
+ /**
85
+ * Stores a spacing value as a data attribute on the block root element
86
+ */
87
+ _storeDataAttribute(attr: string, spacing: number): void;
67
88
  _listenToFormUpdates(): void;
68
89
  /**
69
90
  * Debounced version of _onColumnSpacingChange
@@ -72,12 +93,24 @@ export declare class SpacingControl extends CommonControl {
72
93
  _debouncedOnColumnSpacingChange: import("@vueuse/shared").PromisifyFn<(spacing: number) => void>;
73
94
  /**
74
95
  * Debounced version of _onRowSpacingChange
75
- * Prevents excessive DOM updates when user rapidly adjusts the counter
76
96
  */
77
97
  _debouncedOnRowSpacingChange: import("@vueuse/shared").PromisifyFn<(spacing: number) => void>;
98
+ /**
99
+ * Debounced version of _onMobileColumnSpacingChange
100
+ */
101
+ _debouncedOnMobileColumnSpacingChange: import("@vueuse/shared").PromisifyFn<(spacing: number) => void>;
102
+ /**
103
+ * Debounced version of _onMobileRowSpacingChange
104
+ */
105
+ _debouncedOnMobileRowSpacingChange: import("@vueuse/shared").PromisifyFn<(spacing: number) => void>;
78
106
  /**
79
107
  * Subscribe to store orientation changes
80
- * Updates column spacing visibility when layout changes via the layout control
108
+ * Updates spacing visibility when layout changes via the layout control
81
109
  */
82
110
  _subscribeToOrientationChanges(): void;
111
+ /**
112
+ * Subscribes to editor preview mode changes via Stripo API.
113
+ * Toggles which spacing controls (desktop/mobile) are visible.
114
+ */
115
+ _subscribeToEditorModeChanges(): void;
83
116
  }