@useinsider/guido 2.1.0-beta.9ba2e9d → 2.1.0-beta.aa05b06

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 (143) hide show
  1. package/README.md +36 -0
  2. package/dist/@types/config/schemas.js +70 -65
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +69 -58
  5. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +14 -15
  6. package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
  7. package/dist/composables/useBlocksConfig.js +29 -20
  8. package/dist/composables/useHtmlValidator.js +84 -106
  9. package/dist/composables/useRecommendation.js +21 -54
  10. package/dist/config/compiler/recommendationCompilerRules.js +39 -45
  11. package/dist/config/migrator/recommendationMigrator.js +2 -2
  12. package/dist/enums/defaults.js +8 -4
  13. package/dist/enums/recommendation.js +15 -16
  14. package/dist/extensions/Blocks/Recommendation/block.js +9 -130
  15. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +187 -0
  16. package/dist/extensions/Blocks/Recommendation/constants.js +13 -0
  17. package/dist/extensions/Blocks/Recommendation/control.js +336 -0
  18. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +68 -0
  19. package/dist/extensions/Blocks/Recommendation/controls/index.js +245 -0
  20. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +74 -0
  21. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscount/textAfter.js → omnibusDiscountTextAfterControl.js} +14 -16
  22. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscount/textBefore.js → omnibusDiscountTextBeforeControl.js} +14 -16
  23. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPrice/textAfter.js → omnibusPriceTextAfterControl.js} +14 -16
  24. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPrice/textBefore.js → omnibusPriceTextBeforeControl.js} +12 -14
  25. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +188 -0
  26. package/dist/extensions/Blocks/Recommendation/extension.js +17 -40
  27. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +3 -19
  28. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -13
  29. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +10 -21
  30. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +193 -230
  31. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +181 -0
  32. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +189 -0
  33. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +209 -0
  34. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
  35. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +15 -26
  36. package/dist/extensions/Blocks/controlFactories.js +93 -125
  37. package/dist/extensions/ModulesTabIcons/extension.js +17 -0
  38. package/dist/guido.css +1 -1
  39. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +238 -224
  40. package/dist/services/recommendationApi.js +9 -10
  41. package/dist/services/templateLibraryApi.js +13 -16
  42. package/dist/src/@types/config/schemas.d.ts +8 -0
  43. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  44. package/dist/src/composables/useConfig.d.ts +4 -0
  45. package/dist/src/composables/useRecommendation.d.ts +0 -1
  46. package/dist/src/enums/defaults.d.ts +4 -0
  47. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -67
  48. package/dist/src/extensions/Blocks/Recommendation/{controls/cardComposition/index.d.ts → cardCompositionControl.d.ts} +3 -23
  49. package/dist/src/extensions/Blocks/Recommendation/{constants/controlIds.d.ts → constants.d.ts} +24 -0
  50. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +38 -0
  51. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +589 -21
  52. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +16 -0
  53. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +0 -9
  54. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +468 -131
  55. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +16 -0
  56. package/dist/src/extensions/Blocks/Recommendation/templates/{grid/migration.d.ts → migrationTemplate.d.ts} +4 -11
  57. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +52 -0
  58. package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
  59. package/dist/src/stores/config.d.ts +36 -0
  60. package/dist/static/styles/customEditorStyle.css.js +2 -25
  61. package/dist/utils/pairProductVariables.js +56 -57
  62. package/dist/utils/templatePreparation.js +14 -15
  63. package/package.json +1 -1
  64. package/dist/config/compiler/utils/recommendationCompilerUtils.js +0 -147
  65. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +0 -4
  66. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +0 -4
  67. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +0 -65
  68. package/dist/extensions/Blocks/Recommendation/constants/layout.js +0 -20
  69. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +0 -19
  70. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +0 -64
  71. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +0 -80
  72. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +0 -232
  73. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +0 -19
  74. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +0 -92
  75. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +0 -102
  76. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +0 -209
  77. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +0 -52
  78. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +0 -217
  79. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +0 -70
  80. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +0 -110
  81. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +0 -67
  82. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +0 -286
  83. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +0 -46
  84. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +0 -108
  85. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +0 -44
  86. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +0 -48
  87. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +0 -48
  88. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +0 -44
  89. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +0 -222
  90. package/dist/extensions/Blocks/Recommendation/services/configService.js +0 -240
  91. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +0 -233
  92. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
  93. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +0 -69
  94. package/dist/extensions/Blocks/Recommendation/templates/index.js +0 -12
  95. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +0 -174
  96. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +0 -73
  97. package/dist/extensions/Blocks/Recommendation/templates/utils.js +0 -122
  98. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +0 -6
  99. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +0 -29
  100. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +0 -46
  101. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +0 -17
  102. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +0 -13
  103. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +0 -49
  104. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +0 -13
  105. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +0 -35
  106. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -31
  107. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +0 -143
  108. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +0 -31
  109. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +0 -35
  110. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +0 -37
  111. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +0 -29
  112. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +0 -52
  113. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +0 -22
  114. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -68
  115. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +0 -24
  116. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -42
  117. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +0 -23
  118. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -214
  119. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +0 -97
  120. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +0 -34
  121. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +0 -95
  122. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +0 -100
  123. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +0 -15
  124. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +0 -15
  125. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +0 -100
  126. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +0 -15
  127. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +0 -15
  128. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +0 -95
  129. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +0 -83
  130. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +0 -151
  131. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +0 -6
  132. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -20
  133. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +0 -33
  134. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +0 -39
  135. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +0 -8
  136. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +0 -25
  137. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +0 -18
  138. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +0 -57
  139. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +0 -7
  140. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -160
  141. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +0 -33
  142. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
  143. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +0 -77
@@ -1,44 +0,0 @@
1
- import { createPaddingsControl as r, createTextBackgroundColorControl as C, createTextFontFamilyControl as e, createTextStyleControl as l, createTextSizeControl as c, createTextColorControl as _, createTextAlignControl as I } from "../../../controlFactories.js";
2
- import { RecommendationBlockId as o } from "../../constants/blockIds.js";
3
- import { RecommendationControlId as t } from "../../constants/controlIds.js";
4
- import { CONTAINER_SELECTOR as n } from "../../constants/selectors.js";
5
- const O = I(
6
- t.OLD_PRICE_ALIGN,
7
- o.OLD_PRICE,
8
- n
9
- ), R = _(
10
- t.OLD_PRICE_COLOR,
11
- o.OLD_PRICE,
12
- n
13
- ), a = c(
14
- t.OLD_PRICE_SIZE,
15
- o.OLD_PRICE,
16
- n
17
- ), i = l(
18
- t.OLD_PRICE_STYLE,
19
- o.OLD_PRICE,
20
- n
21
- ), E = e(
22
- t.OLD_PRICE_FONT_FAMILY,
23
- o.OLD_PRICE,
24
- n
25
- ), L = C(
26
- t.OLD_PRICE_BACKGROUND,
27
- o.OLD_PRICE,
28
- n
29
- ), P = r(
30
- t.OLD_PRICE_PADDINGS,
31
- o.OLD_PRICE,
32
- n
33
- ), T = {
34
- align: O,
35
- color: R,
36
- size: a,
37
- style: i,
38
- fontFamily: E,
39
- background: L,
40
- paddings: P
41
- };
42
- export {
43
- T as OldPriceControls
44
- };
@@ -1,48 +0,0 @@
1
- import { createPaddingsControl as n, createTextBackgroundColorControl as e, createTextFontFamilyControl as C, createTextStyleControl as O, createTextSizeControl as S, createTextColorControl as I, createTextAlignControl as N } from "../../../controlFactories.js";
2
- import { RecommendationBlockId as o } from "../../constants/blockIds.js";
3
- import { RecommendationControlId as t } from "../../constants/controlIds.js";
4
- import { CONTAINER_SELECTOR as r } from "../../constants/selectors.js";
5
- import { OmnibusDiscountTextAfterControl as l } from "./textAfter.js";
6
- import { OmnibusDiscountTextBeforeControl as U } from "./textBefore.js";
7
- const i = N(
8
- t.OMNIBUS_DISCOUNT_ALIGN,
9
- o.OMNIBUS_DISCOUNT,
10
- r
11
- ), T = I(
12
- t.OMNIBUS_DISCOUNT_COLOR,
13
- o.OMNIBUS_DISCOUNT,
14
- r
15
- ), c = S(
16
- t.OMNIBUS_DISCOUNT_SIZE,
17
- o.OMNIBUS_DISCOUNT,
18
- r
19
- ), _ = O(
20
- t.OMNIBUS_DISCOUNT_STYLE,
21
- o.OMNIBUS_DISCOUNT,
22
- r
23
- ), m = C(
24
- t.OMNIBUS_DISCOUNT_FONT_FAMILY,
25
- o.OMNIBUS_DISCOUNT,
26
- r
27
- ), s = e(
28
- t.OMNIBUS_DISCOUNT_BACKGROUND,
29
- o.OMNIBUS_DISCOUNT,
30
- r
31
- ), B = n(
32
- t.OMNIBUS_DISCOUNT_PADDINGS,
33
- o.OMNIBUS_DISCOUNT,
34
- r
35
- ), g = {
36
- align: i,
37
- color: T,
38
- size: c,
39
- style: _,
40
- fontFamily: m,
41
- background: s,
42
- paddings: B,
43
- textBefore: U,
44
- textAfter: l
45
- };
46
- export {
47
- g as OmnibusDiscountControls
48
- };
@@ -1,48 +0,0 @@
1
- import { createPaddingsControl as n, createTextBackgroundColorControl as e, createTextFontFamilyControl as C, createTextStyleControl as I, createTextSizeControl as l, createTextColorControl as i, createTextAlignControl as c } from "../../../controlFactories.js";
2
- import { RecommendationBlockId as o } from "../../constants/blockIds.js";
3
- import { RecommendationControlId as t } from "../../constants/controlIds.js";
4
- import { CONTAINER_SELECTOR as r } from "../../constants/selectors.js";
5
- import { OmnibusPriceTextAfterControl as O } from "./textAfter.js";
6
- import { OmnibusPriceTextBeforeControl as _ } from "./textBefore.js";
7
- const m = c(
8
- t.OMNIBUS_PRICE_ALIGN,
9
- o.OMNIBUS_PRICE,
10
- r
11
- ), S = i(
12
- t.OMNIBUS_PRICE_COLOR,
13
- o.OMNIBUS_PRICE,
14
- r
15
- ), B = l(
16
- t.OMNIBUS_PRICE_SIZE,
17
- o.OMNIBUS_PRICE,
18
- r
19
- ), N = I(
20
- t.OMNIBUS_PRICE_STYLE,
21
- o.OMNIBUS_PRICE,
22
- r
23
- ), P = C(
24
- t.OMNIBUS_PRICE_FONT_FAMILY,
25
- o.OMNIBUS_PRICE,
26
- r
27
- ), R = e(
28
- t.OMNIBUS_PRICE_BACKGROUND,
29
- o.OMNIBUS_PRICE,
30
- r
31
- ), a = n(
32
- t.OMNIBUS_PRICE_PADDINGS,
33
- o.OMNIBUS_PRICE,
34
- r
35
- ), f = {
36
- align: m,
37
- color: S,
38
- size: B,
39
- style: N,
40
- fontFamily: P,
41
- background: R,
42
- paddings: a,
43
- textBefore: _,
44
- textAfter: O
45
- };
46
- export {
47
- f as OmnibusPriceControls
48
- };
@@ -1,44 +0,0 @@
1
- import { createPaddingsControl as r, createTextBackgroundColorControl as C, createTextFontFamilyControl as e, createTextStyleControl as l, createTextSizeControl as c, createTextColorControl as I, createTextAlignControl as R } from "../../../controlFactories.js";
2
- import { RecommendationBlockId as o } from "../../constants/blockIds.js";
3
- import { RecommendationControlId as t } from "../../constants/controlIds.js";
4
- import { CONTAINER_SELECTOR as n } from "../../constants/selectors.js";
5
- const a = R(
6
- t.PRICE_ALIGN,
7
- o.PRICE,
8
- n
9
- ), i = I(
10
- t.PRICE_COLOR,
11
- o.PRICE,
12
- n
13
- ), E = c(
14
- t.PRICE_SIZE,
15
- o.PRICE,
16
- n
17
- ), P = l(
18
- t.PRICE_STYLE,
19
- o.PRICE,
20
- n
21
- ), m = e(
22
- t.PRICE_FONT_FAMILY,
23
- o.PRICE,
24
- n
25
- ), s = C(
26
- t.PRICE_BACKGROUND,
27
- o.PRICE,
28
- n
29
- ), d = r(
30
- t.PRICE_PADDINGS,
31
- o.PRICE,
32
- n
33
- ), x = {
34
- align: a,
35
- color: i,
36
- size: E,
37
- style: P,
38
- fontFamily: m,
39
- background: s,
40
- paddings: d
41
- };
42
- export {
43
- x as PriceControls
44
- };
@@ -1,222 +0,0 @@
1
- var G = Object.defineProperty;
2
- var I = (o, n, t) => n in o ? G(o, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[n] = t;
3
- var l = (o, n, t) => I(o, typeof n != "symbol" ? n + "" : n, t);
4
- import { ModificationDescription as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as L } from "../../../common-control.js";
6
- import { SPACING_STEP as b, MAX_SPACING as y, MIN_SPACING as A, DEFAULT_COLUMN_SPACING as a, DEFAULT_ROW_SPACING as m } from "../../constants/layout.js";
7
- import { RecommendationConfigService as d } from "../../services/configService.js";
8
- import { useRecommendationExtensionStore as w } from "../../store/recommendation.js";
9
- import { safeGetStyle as S, safeGetParent as V } from "../../utils/tagName.js";
10
- import { getCurrentLayout as C } from "../main/utils.js";
11
- import { useDebounceFn as O } from "../../../../../node_modules/@vueuse/shared/index.js";
12
- const R = "recommendation-spacing-control", s = {
13
- COLUMN_SPACING: "columnSpacing",
14
- COLUMN_SPACING_LABEL: "columnSpacingLabel",
15
- ROW_SPACING: "rowSpacing"
16
- }, P = {
17
- COLUMN_SPACING: "data-column-spacing",
18
- ROW_SPACING: "data-row-spacing"
19
- };
20
- function N(o, n) {
21
- if (!o)
22
- return n;
23
- const t = parseFloat(o);
24
- return Number.isNaN(t) ? n : t;
25
- }
26
- class $ extends L {
27
- constructor() {
28
- super(...arguments);
29
- l(this, "store", w());
30
- l(this, "unsubscribeOrientation", null);
31
- /**
32
- * Debounced version of _onColumnSpacingChange
33
- * Prevents excessive DOM updates when user rapidly adjusts the counter
34
- */
35
- l(this, "_debouncedOnColumnSpacingChange", O((t) => {
36
- this._onColumnSpacingChange(t);
37
- }, 300));
38
- /**
39
- * Debounced version of _onRowSpacingChange
40
- * Prevents excessive DOM updates when user rapidly adjusts the counter
41
- */
42
- l(this, "_debouncedOnRowSpacingChange", O((t) => {
43
- this._onRowSpacingChange(t);
44
- }, 300));
45
- }
46
- getId() {
47
- return R;
48
- }
49
- getTemplate() {
50
- return `
51
- <div class="spacing-control-container">
52
- ${this._GuTwoColumns([
53
- this._GuLabel({ text: "Column Spacing (px)", name: s.COLUMN_SPACING_LABEL }),
54
- this._GuCounter({
55
- name: s.COLUMN_SPACING,
56
- minValue: A,
57
- maxValue: y,
58
- step: b
59
- }),
60
- this._GuLabel({ text: "Row Spacing (px)" }),
61
- this._GuCounter({
62
- name: s.ROW_SPACING,
63
- minValue: A,
64
- maxValue: y,
65
- step: b
66
- })
67
- ])}
68
- </div>
69
- `;
70
- }
71
- onRender() {
72
- this._setFormValues(), this._updateColumnSpacingVisibility(), this._listenToFormUpdates(), this._subscribeToOrientationChanges();
73
- }
74
- onTemplateNodeUpdated(t) {
75
- super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateColumnSpacingVisibility();
76
- }
77
- onDestroy() {
78
- this.unsubscribeOrientation && (this.unsubscribeOrientation(), this.unsubscribeOrientation = null);
79
- }
80
- /**
81
- * Updates column spacing visibility based on layout orientation
82
- * Column spacing is hidden for list layout (products are stacked vertically)
83
- * Reads from node config first, falls back to store then DOM
84
- */
85
- _updateColumnSpacingVisibility() {
86
- if (!this.api)
87
- return;
88
- const t = d.getConfig(this.currentNode), e = this.store.recommendationConfigs.orientation, i = (t.layout || e || C(this.currentNode)) === "grid";
89
- this.api.setVisibility(s.COLUMN_SPACING, i), this.api.setVisibility(s.COLUMN_SPACING_LABEL, i);
90
- }
91
- /**
92
- * Reads spacing values from node config first, falls back to DOM styles
93
- */
94
- _setFormValues() {
95
- if (!this.api)
96
- return;
97
- const t = d.getConfig(this.currentNode), e = t.columnSpacing !== a ? t.columnSpacing : this._getStoredColumnSpacing(), r = t.rowSpacing !== m ? t.rowSpacing : this._getStoredRowSpacing();
98
- this.api.updateValues({
99
- [s.COLUMN_SPACING]: e,
100
- [s.ROW_SPACING]: r
101
- });
102
- }
103
- /**
104
- * Gets stored column spacing from the first attribute row cell's padding.
105
- * For grid layout: cells inside .recommendation-attribute-row have padding applied.
106
- * For list layout: the parent of .product-card-wrapper has the padding.
107
- * The padding is applied as "0 {halfSpacing}px", so we extract and multiply by 2.
108
- */
109
- _getStoredColumnSpacing() {
110
- if (!this.currentNode)
111
- return a;
112
- if (C(this.currentNode) === "grid") {
113
- const p = this.currentNode.querySelector(".recommendation-attribute-row"), c = p == null ? void 0 : p.querySelector("td"), f = S(c, "padding");
114
- if (!f)
115
- return a;
116
- const _ = f.trim().split(/\s+/);
117
- return _.length < 2 ? a : N(_[1], a / 2) * 2;
118
- }
119
- const e = this.currentNode.querySelector(".product-card-wrapper"), r = V(e), i = S(r, "padding");
120
- if (!i)
121
- return a;
122
- const u = i.trim().split(/\s+/);
123
- return u.length < 2 ? a : N(u[1], a / 2) * 2;
124
- }
125
- /**
126
- * Gets stored row spacing from the first spacer element's height style
127
- */
128
- _getStoredRowSpacing() {
129
- if (!this.currentNode)
130
- return m;
131
- const t = this.currentNode.querySelector(".spacer"), e = S(t, "height");
132
- return N(e, m);
133
- }
134
- /**
135
- * Handles column spacing changes.
136
- * For grid layout: applies horizontal padding to all cells inside attribute rows.
137
- * For list layout: applies padding to parent of product card wrappers.
138
- */
139
- _onColumnSpacingChange(t) {
140
- if (!this.currentNode)
141
- return;
142
- d.updateConfig(
143
- this.api,
144
- this.currentNode,
145
- { columnSpacing: t },
146
- `Changed column spacing to ${t}px`
147
- ), this._storeColumnSpacing(t);
148
- const r = d.getConfig(this.currentNode).layout || C(this.currentNode), i = this.api.getDocumentModifier(), h = `0 ${t / 2}px`;
149
- r === "grid" ? Array.from(
150
- this.currentNode.querySelectorAll(".attribute-cell")
151
- ).forEach((c) => {
152
- i.modifyHtml(c).setStyle("padding", h);
153
- }) : Array.from(
154
- this.currentNode.querySelectorAll(".product-card-wrapper")
155
- ).forEach((c) => {
156
- "parent" in c && c.parent() && i.modifyHtml(c.parent()).setStyle("padding", h);
157
- }), i.apply(new g(`Update column spacing to ${t}px`));
158
- }
159
- /**
160
- * Handles row spacing changes
161
- * Applies height to all spacer elements between product rows
162
- */
163
- _onRowSpacingChange(t) {
164
- if (!this.currentNode)
165
- return;
166
- d.updateConfig(
167
- this.api,
168
- this.currentNode,
169
- { rowSpacing: t },
170
- `Changed row spacing to ${t}px`
171
- ), this._storeRowSpacing(t);
172
- const e = Array.from(
173
- this.currentNode.querySelectorAll(".spacer")
174
- );
175
- if (!e.length)
176
- return;
177
- const r = this.api.getDocumentModifier(), i = `${t}px`;
178
- e.forEach((u) => {
179
- r.modifyHtml(u).setStyle("height", i);
180
- }), r.apply(new g(`Update row spacing to ${t}px`));
181
- }
182
- /**
183
- * Stores column spacing value in block data attribute
184
- */
185
- _storeColumnSpacing(t) {
186
- if (!this.currentNode)
187
- return;
188
- const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
189
- e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(P.COLUMN_SPACING, t.toString()).apply(new g("Store column spacing"));
190
- }
191
- /**
192
- * Stores row spacing value in block data attribute
193
- */
194
- _storeRowSpacing(t) {
195
- if (!this.currentNode)
196
- return;
197
- const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
198
- e && this.api.getDocumentModifier().modifyHtml(e).setAttribute(P.ROW_SPACING, t.toString()).apply(new g("Store row spacing"));
199
- }
200
- _listenToFormUpdates() {
201
- this.api.onValueChanged(s.COLUMN_SPACING, (t) => {
202
- const e = parseInt(t);
203
- Number.isNaN(e) || this._debouncedOnColumnSpacingChange(e);
204
- }), this.api.onValueChanged(s.ROW_SPACING, (t) => {
205
- const e = parseInt(t);
206
- Number.isNaN(e) || this._debouncedOnRowSpacingChange(e);
207
- });
208
- }
209
- /**
210
- * Subscribe to store orientation changes
211
- * Updates column spacing visibility when layout changes via the layout control
212
- */
213
- _subscribeToOrientationChanges() {
214
- this.unsubscribeOrientation && this.unsubscribeOrientation(), this.unsubscribeOrientation = this.store.$subscribe((t) => {
215
- t.type === "patch object" && this._updateColumnSpacingVisibility();
216
- });
217
- }
218
- }
219
- export {
220
- R as SPACING_CONTROL_ID,
221
- $ as SpacingControl
222
- };
@@ -1,240 +0,0 @@
1
- import { ModificationDescription as f } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CURRENT_CONFIG_VERSION as u, DEFAULT_NODE_CONFIG as e } from "../constants/defaultConfig.js";
3
- import { setCurrencyAttributes as g } from "../controls/main/utils.js";
4
- import { hasMinimalConfig as a } from "../types/nodeConfig.js";
5
- class C {
6
- // ========================================================================
7
- // Read Operations
8
- // ========================================================================
9
- /**
10
- * Get configuration from a node, with defaults for missing values
11
- *
12
- * This is the primary way to read configuration from a block.
13
- * Always returns a complete config object with defaults merged in.
14
- * @example
15
- * const config = RecommendationConfigService.getConfig(this.currentNode);
16
- * console.log(config.strategy); // 'mostPopular'
17
- * @param node - The immutable HTML node to read config from
18
- * @returns Complete configuration with defaults for missing values
19
- */
20
- static getConfig(i) {
21
- if (!i)
22
- return this.cloneDefaults();
23
- if (!("getNodeConfig" in i) || typeof i.getNodeConfig != "function")
24
- return this.cloneDefaults();
25
- try {
26
- const t = i.getNodeConfig();
27
- return t ? this.mergeWithDefaults(t) : this.cloneDefaults();
28
- } catch {
29
- return this.cloneDefaults();
30
- }
31
- }
32
- /**
33
- * Check if a node has valid configuration stored
34
- *
35
- * Used for migration detection - returns false for legacy templates
36
- * that need their configuration migrated.
37
- * @param node - The immutable HTML node to check
38
- * @returns True if node has valid config with version number
39
- */
40
- static hasConfig(i) {
41
- if (!i || !("getNodeConfig" in i) || typeof i.getNodeConfig != "function")
42
- return !1;
43
- try {
44
- const t = i.getNodeConfig();
45
- return a(t);
46
- } catch {
47
- return !1;
48
- }
49
- }
50
- /**
51
- * Get the configuration version from a node
52
- * @param node - The immutable HTML node to check
53
- * @returns Config version number, or 0 if no config exists
54
- */
55
- static getConfigVersion(i) {
56
- return this.hasConfig(i) && this.getConfig(i).configVersion || 0;
57
- }
58
- // ========================================================================
59
- // Write Operations
60
- // ========================================================================
61
- /**
62
- * Update specific configuration values
63
- *
64
- * Merges the updates with existing config and persists to node.
65
- * This is the primary way to update configuration from controls.
66
- * @example
67
- * RecommendationConfigService.updateConfig(
68
- * this.api,
69
- * this.currentNode,
70
- * { strategy: 'complementaryItems' },
71
- * 'Changed recommendation algorithm'
72
- * );
73
- * @param api - Stripo extension API with document modifier
74
- * @param node - The immutable HTML node to update
75
- * @param updates - Partial config with values to update
76
- * @param description - Human-readable description for undo/redo
77
- * @returns The new complete configuration
78
- */
79
- static updateConfig(i, t, o, n) {
80
- const s = this.getConfig(t), r = this.deepMerge(s, o);
81
- return this.saveConfig(i, t, r, n), r;
82
- }
83
- /**
84
- * Initialize configuration for a new block
85
- *
86
- * Called when a block is first created (dropped into template).
87
- * Can optionally merge in partial config from migration.
88
- * @example
89
- * // In Block.onCreated lifecycle
90
- * RecommendationConfigService.initializeConfig(this.api, node);
91
- * @param api - Stripo extension API with document modifier
92
- * @param node - The immutable HTML node to initialize
93
- * @param partialConfig - Optional partial config to merge with defaults
94
- * @returns The initialized configuration
95
- */
96
- static initializeConfig(i, t, o) {
97
- const n = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
98
- return this.saveConfig(i, t, n, "Initialize recommendation block"), g({
99
- currentNode: t,
100
- documentModifier: i.getDocumentModifier(),
101
- currency: n.currency
102
- }), n;
103
- }
104
- /**
105
- * Save complete configuration to a node
106
- *
107
- * Low-level method - prefer `updateConfig` or `initializeConfig` in most cases.
108
- * @param api - Stripo extension API with document modifier
109
- * @param node - The immutable HTML node to save to
110
- * @param config - Complete configuration to save
111
- * @param description - Human-readable description for undo/redo
112
- */
113
- static saveConfig(i, t, o, n) {
114
- try {
115
- i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new f(n));
116
- } catch (s) {
117
- console.warn("[RecommendationConfigService] Failed to save config:", s);
118
- }
119
- }
120
- // ========================================================================
121
- // Migration Helpers
122
- // ========================================================================
123
- /**
124
- * Migrate configuration from legacy data-attributes
125
- *
126
- * Reads existing data-attributes and creates a proper node config.
127
- * Used when loading templates created before node config was implemented.
128
- * @param api - Stripo extension API with document modifier
129
- * @param node - The block node to migrate
130
- * @returns The migrated configuration
131
- */
132
- static migrateFromDataAttributes(i, t) {
133
- const o = {
134
- configVersion: u
135
- };
136
- if ("getAttribute" in t && typeof t.getAttribute == "function") {
137
- const n = t.getAttribute("data-layout");
138
- n === "list" || n === "horizontal" ? o.layout = "list" : (n === "grid" || n === "vertical") && (o.layout = "grid");
139
- const s = t.getAttribute("data-card-composition");
140
- s && (o.composition = s.split(",").filter(Boolean));
141
- const r = t.getAttribute("data-column-spacing");
142
- r && (o.columnSpacing = parseInt(r) || e.columnSpacing);
143
- const c = t.getAttribute("data-row-spacing");
144
- c && (o.rowSpacing = parseInt(c) || e.rowSpacing);
145
- }
146
- return this.initializeConfig(i, t, o);
147
- }
148
- /**
149
- * Check if configuration needs migration
150
- * @param node - The block node to check
151
- * @returns True if migration is needed
152
- */
153
- static needsMigration(i) {
154
- return i ? this.hasConfig(i) ? this.getConfigVersion(i) < u : !0 : !1;
155
- }
156
- // ========================================================================
157
- // Internal Helpers
158
- // ========================================================================
159
- /**
160
- * Clone default config to avoid mutations
161
- */
162
- static cloneDefaults() {
163
- return {
164
- ...e,
165
- currency: { ...e.currency },
166
- omnibusPrice: { ...e.omnibusPrice },
167
- omnibusDiscount: { ...e.omnibusDiscount },
168
- composition: [...e.composition],
169
- visibility: { ...e.visibility },
170
- filters: [],
171
- productIds: [],
172
- recommendationId: 0
173
- };
174
- }
175
- /**
176
- * Merge partial config with defaults
177
- *
178
- * Deep merges nested objects like currency, omnibus settings.
179
- */
180
- static mergeWithDefaults(i) {
181
- const t = this.cloneDefaults();
182
- return {
183
- ...t,
184
- ...i,
185
- currency: {
186
- ...t.currency,
187
- ...i.currency || {}
188
- },
189
- omnibusPrice: {
190
- ...t.omnibusPrice,
191
- ...i.omnibusPrice || {}
192
- },
193
- omnibusDiscount: {
194
- ...t.omnibusDiscount,
195
- ...i.omnibusDiscount || {}
196
- },
197
- visibility: {
198
- ...t.visibility,
199
- ...i.visibility || {}
200
- },
201
- composition: i.composition || t.composition,
202
- filters: i.filters || [],
203
- productIds: i.productIds || []
204
- };
205
- }
206
- /**
207
- * Deep merge for nested objects
208
- *
209
- * Recursively merges source into target, preserving existing values
210
- * that aren't explicitly overwritten.
211
- */
212
- static deepMerge(i, t) {
213
- return {
214
- ...i,
215
- ...t,
216
- currency: {
217
- ...i.currency,
218
- ...t.currency || {}
219
- },
220
- omnibusPrice: {
221
- ...i.omnibusPrice,
222
- ...t.omnibusPrice || {}
223
- },
224
- omnibusDiscount: {
225
- ...i.omnibusDiscount,
226
- ...t.omnibusDiscount || {}
227
- },
228
- visibility: {
229
- ...i.visibility,
230
- ...t.visibility || {}
231
- },
232
- composition: t.composition ?? i.composition,
233
- filters: t.filters ?? i.filters,
234
- productIds: t.productIds ?? i.productIds
235
- };
236
- }
237
- }
238
- export {
239
- C as RecommendationConfigService
240
- };