@useinsider/guido 2.1.0-beta.6df87d7 → 2.1.0-beta.76217f3

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 (145) 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/composables/useBlocksConfig.js +26 -16
  7. package/dist/composables/useHtmlValidator.js +84 -106
  8. package/dist/composables/useRecommendation.js +21 -54
  9. package/dist/config/compiler/recommendationCompilerRules.js +39 -45
  10. package/dist/config/migrator/recommendationMigrator.js +2 -2
  11. package/dist/enums/defaults.js +8 -4
  12. package/dist/enums/extensions/recommendationBlock.js +1 -1
  13. package/dist/enums/recommendation.js +15 -16
  14. package/dist/extensions/Blocks/Recommendation/block.js +9 -133
  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 +207 -256
  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 +237 -225
  40. package/dist/services/recommendationApi.js +8 -11
  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 -138
  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 +11 -35
  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 -116
  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 -66
  68. package/dist/extensions/Blocks/Recommendation/constants/layout.js +0 -22
  69. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +0 -21
  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 -218
  79. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +0 -70
  80. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +0 -160
  81. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +0 -67
  82. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +0 -307
  83. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +0 -21
  84. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +0 -46
  85. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +0 -108
  86. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +0 -44
  87. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +0 -48
  88. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +0 -48
  89. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +0 -44
  90. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +0 -222
  91. package/dist/extensions/Blocks/Recommendation/services/configService.js +0 -240
  92. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +0 -233
  93. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
  94. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +0 -66
  95. package/dist/extensions/Blocks/Recommendation/templates/index.js +0 -12
  96. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +0 -174
  97. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +0 -73
  98. package/dist/extensions/Blocks/Recommendation/templates/utils.js +0 -134
  99. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +0 -6
  100. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +0 -29
  101. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +0 -46
  102. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +0 -17
  103. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +0 -13
  104. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +0 -49
  105. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +0 -13
  106. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +0 -41
  107. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -35
  108. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +0 -143
  109. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +0 -31
  110. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +0 -35
  111. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +0 -37
  112. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +0 -29
  113. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +0 -52
  114. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +0 -22
  115. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -67
  116. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +0 -24
  117. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -60
  118. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +0 -23
  119. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -221
  120. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +0 -29
  121. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +0 -97
  122. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +0 -34
  123. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +0 -95
  124. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +0 -100
  125. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +0 -15
  126. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +0 -15
  127. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +0 -100
  128. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +0 -15
  129. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +0 -15
  130. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +0 -95
  131. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +0 -83
  132. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +0 -151
  133. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +0 -6
  134. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -20
  135. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +0 -33
  136. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +0 -41
  137. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +0 -8
  138. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +0 -25
  139. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +0 -18
  140. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +0 -66
  141. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +0 -7
  142. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -166
  143. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +0 -33
  144. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
  145. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +0 -77
@@ -1,29 +1,18 @@
1
- var p = Object.defineProperty;
2
- var f = (r, o, t) => o in r ? p(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t;
3
- var g = (r, o, t) => f(r, typeof o != "symbol" ? o + "" : o, t);
4
- import { Block as h, BlockCompositionType as I, ModificationDescription as _ } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { ensureMobileCssRulesExist as d } from "./controls/mobileLayout/cssRules.js";
6
- import { RecommendationConfigService as s } from "./services/configService.js";
7
- import { useRecommendationExtensionStore as u } from "./store/recommendation.js";
8
- import { getDefaultTemplate as k } from "./templates/grid/template.js";
9
- const B = "recommendation-block", c = "ins-recommendation-v3-block-v2", a = "recommendation-id";
10
- class y extends h {
1
+ import { Block as e, BlockCompositionType as t } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { getDefaultTemplate as o } from "./templates/blockTemplate.js";
3
+ const n = "recommendation-block";
4
+ class m extends e {
11
5
  constructor() {
12
6
  super();
13
- /**
14
- * Stores the ID generated in getTemplate() so onCreated() can reuse it.
15
- * This avoids generating a new (different) ID in onCreated().
16
- */
17
- g(this, "_pendingBlockId", null);
18
7
  }
19
8
  getId() {
20
- return B;
9
+ return n;
21
10
  }
22
11
  getIcon() {
23
12
  return "recommendation-icon";
24
13
  }
25
14
  getBlockCompositionType() {
26
- return I.CONTAINER;
15
+ return t.CONTAINER;
27
16
  }
28
17
  getName() {
29
18
  return this.api.translate("Recommendation Block");
@@ -31,124 +20,11 @@ class y extends h {
31
20
  getDescription() {
32
21
  return this.api.translate("Recommendation Block Title Description");
33
22
  }
34
- /**
35
- * Returns the template HTML for a new recommendation block.
36
- * Generates a unique recommendation ID and embeds the instance class
37
- * (ins-recommendation-v3-block-{id}) directly in the template HTML.
38
- * This is necessary because Stripo's Angular rendering manages the class
39
- * attribute and overwrites dynamically added classes via setAttribute.
40
- */
41
23
  getTemplate() {
42
- const t = this._generateNextId();
43
- return this._pendingBlockId = t, k(t);
44
- }
45
- /**
46
- * Called when a new block is dropped into the template
47
- *
48
- * Uses the ID from getTemplate() (which already embedded the instance class)
49
- * and assigns the recommendation-id attribute + initializes configuration.
50
- * @param node - The newly created block node
51
- */
52
- onCreated(t) {
53
- const e = this._pendingBlockId ?? this._generateNextId();
54
- this._pendingBlockId = null, this._assignRecommendationId(t, e);
55
- const n = s.initializeConfig(this.api, t, { recommendationId: e }), i = u();
56
- i.setCurrentBlock(e), d(this.api), i.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
57
- }
58
- /**
59
- * Called when the document changes or template is loaded
60
- *
61
- * Handles migration from legacy templates that don't have node config
62
- * and assigns recommendation-id to legacy blocks that lack one.
63
- * @param node - The block node that may need migration
64
- */
65
- onDocumentChanged(t) {
66
- if (!(!t || !("getNodeConfig" in t))) {
67
- if (!this._getRecommendationId(t)) {
68
- const e = this._generateNextId();
69
- this._assignRecommendationId(t, e), s.hasConfig(t) && s.updateConfig(
70
- this.api,
71
- t,
72
- { recommendationId: e },
73
- "Assign recommendation ID to legacy block"
74
- );
75
- }
76
- s.needsMigration(t) && this._migrateFromLegacy(t), d(this.api);
77
- }
78
- }
79
- /**
80
- * Called when a block is deleted from the template
81
- *
82
- * Cleans up the per-block state from the Pinia store.
83
- * @param node - The block node being deleted
84
- */
85
- onDelete(t) {
86
- const e = this._getRecommendationId(t);
87
- e && u().removeBlockState(e);
88
- }
89
- /**
90
- * Generates the next unique recommendation ID by scanning all existing blocks
91
- * in the document and finding the maximum existing ID + 1.
92
- */
93
- _generateNextId() {
94
- let t = 0;
95
- try {
96
- const e = this.api.getDocumentRoot();
97
- e && "querySelectorAll" in e && e.querySelectorAll(`.${c}`).forEach((i) => {
98
- if ("getAttribute" in i) {
99
- const m = i.getAttribute(a), l = m ? parseInt(m) : 0;
100
- l > t && (t = l);
101
- }
102
- });
103
- } catch {
104
- }
105
- return t + 1;
106
- }
107
- /**
108
- * Assigns a recommendation-id attribute to the block element.
109
- * The instance class (ins-recommendation-v3-block-{id}) is embedded in the template
110
- * HTML by getTemplate(), since Stripo's Angular rendering overwrites dynamically
111
- * added classes via setAttribute.
112
- */
113
- _assignRecommendationId(t, e) {
114
- const n = this._getBlockElement(t);
115
- if (!n)
116
- return;
117
- const i = this.api.getDocumentModifier();
118
- i.modifyHtml(n).setAttribute(a, e.toString()), i.apply(new _(`Assign recommendation ID ${e}`));
119
- }
120
- /**
121
- * Gets the recommendation-id from a block node
122
- */
123
- _getRecommendationId(t) {
124
- const e = this._getBlockElement(t);
125
- if (!e || !("getAttribute" in e))
126
- return null;
127
- const n = e.getAttribute(a);
128
- if (!n)
129
- return null;
130
- const i = parseInt(n);
131
- return Number.isNaN(i) ? null : i;
132
- }
133
- /**
134
- * Gets the block element (the element with BLOCK_CLASS)
135
- */
136
- _getBlockElement(t) {
137
- if ("getAttribute" in t) {
138
- const e = t.getAttribute("class");
139
- if (e && e.includes(c))
140
- return t;
141
- }
142
- return "querySelector" in t ? t.querySelector(`.${c}`) : null;
143
- }
144
- /**
145
- * Migrate configuration from legacy format
146
- */
147
- _migrateFromLegacy(t) {
148
- s.migrateFromDataAttributes(this.api, t);
24
+ return o();
149
25
  }
150
26
  }
151
27
  export {
152
- B as BLOCK_ID,
153
- y as RecommendationBlock
28
+ n as BLOCK_ID,
29
+ m as RecommendationBlock
154
30
  };
@@ -0,0 +1,187 @@
1
+ import { ModificationDescription as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as _ } from "../common-control.js";
3
+ import { ATTR_PRODUCT_IMAGE as m, ATTR_PRODUCT_NAME as y, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_OLD_PRICE as h, ATTR_PRODUCT_OMNIBUS_PRICE as C, ATTR_PRODUCT_OMNIBUS_DISCOUNT as f, ATTR_PRODUCT_BUTTON as g } from "./constants.js";
4
+ const R = "ui-elements-recommendation-card-composition", l = ".recommendation-attribute-row", A = "tr.recommendation-product-row", c = "data-card-composition", a = "data-attribute-type", d = "data-visibility", s = [
5
+ { key: m, label: "Product Image", visible: !0 },
6
+ { key: y, label: "Product Name", visible: !0 },
7
+ { key: T, label: "Product Price", visible: !0 },
8
+ { key: h, label: "Product Original Price", visible: !0 },
9
+ { key: C, label: "Omnibus Price", visible: !1 },
10
+ { key: f, label: "Omnibus Discount", visible: !1 },
11
+ { key: g, label: "Product Button", visible: !0 }
12
+ ];
13
+ class N extends _ {
14
+ getId() {
15
+ return R;
16
+ }
17
+ getTemplate() {
18
+ const t = s.map((i) => ({
19
+ key: i.key,
20
+ label: i.label,
21
+ content: this._createItemContent(i.label, i.key)
22
+ }));
23
+ return `
24
+ <div class="container">
25
+ ${this._GuLabel({ text: "Card Element Order & Visibility" })}
26
+ ${this._GuOrderable("cardComposition", t)}
27
+ </div>
28
+ `;
29
+ }
30
+ onRender() {
31
+ this._initializeComposition(), this._registerValueChangeListeners();
32
+ }
33
+ onTemplateNodeUpdated(t) {
34
+ super.onTemplateNodeUpdated(t), this._initializeComposition();
35
+ }
36
+ /**
37
+ * Creates the HTML content for an orderable item with label and toggle
38
+ */
39
+ _createItemContent(t, i) {
40
+ return `
41
+ <div style="display: flex; align-items: center; justify-content: space-between;
42
+ padding: 8px; gap: 8px;">
43
+ <span style="flex: 1;">${t}</span>
44
+ ${this._GuToggle(`visibility_${i}`)}
45
+ </div>
46
+ `;
47
+ }
48
+ /**
49
+ * Registers event listeners for composition and visibility changes
50
+ */
51
+ _registerValueChangeListeners() {
52
+ this.api.onValueChanged("cardComposition", (t) => {
53
+ this._applyCompositionToBlock(t);
54
+ }), s.forEach((t) => {
55
+ this.api.onValueChanged(`visibility_${t.key}`, (i) => {
56
+ this._applyVisibilityToBlock(t.key, i);
57
+ });
58
+ });
59
+ }
60
+ /**
61
+ * Initializes composition order and visibility state from the current node
62
+ */
63
+ _initializeComposition() {
64
+ const t = this._readCompositionFromNode(), i = this._readVisibilityFromRows(), e = {
65
+ cardComposition: t,
66
+ ...this._buildVisibilityValues(i)
67
+ };
68
+ this.api.updateValues(e);
69
+ }
70
+ /**
71
+ * Reads composition order from node's data-card-composition attribute
72
+ * Falls back to default order if attribute is not present
73
+ */
74
+ _readCompositionFromNode() {
75
+ if (!this.currentNode || !("getAttribute" in this.currentNode))
76
+ return s.map((i) => i.key);
77
+ const t = this.currentNode.getAttribute(c);
78
+ return t ? t.split(",").filter(Boolean) : s.map((i) => i.key);
79
+ }
80
+ /**
81
+ * Builds visibility values object from the visibility map
82
+ */
83
+ _buildVisibilityValues(t) {
84
+ return s.reduce((i, e) => (i[`visibility_${e.key}`] = t[e.key] ?? !0, i), {});
85
+ }
86
+ /**
87
+ * Read visibility state from individual row elements' data-visibility attributes
88
+ * This ensures toggles reflect the actual DOM state
89
+ */
90
+ _readVisibilityFromRows() {
91
+ if (!this.currentNode)
92
+ return this._getDefaultVisibilities();
93
+ const t = Array.from(this.currentNode.querySelectorAll(l));
94
+ console.debug("_readVisibilityFromRows - found attribute rows:", t.length);
95
+ const i = this._extractVisibilityFromRows(t);
96
+ return this._mergeWithDefaults(i);
97
+ }
98
+ /**
99
+ * Returns default visibility values for all items
100
+ */
101
+ _getDefaultVisibilities() {
102
+ return s.reduce((t, i) => (t[i.key] = i.visible, t), {});
103
+ }
104
+ /**
105
+ * Extracts visibility values from DOM nodes
106
+ */
107
+ _extractVisibilityFromRows(t) {
108
+ const i = {};
109
+ return t.forEach((e) => {
110
+ if (!("getAttribute" in e))
111
+ return;
112
+ const o = e.getAttribute(a), r = e.getAttribute(d);
113
+ o && r !== null && (i[o] = this._parseVisibilityValue(r), console.debug(
114
+ `_readVisibilityFromRows - ${o}: ${i[o]} (raw: ${r})`
115
+ ));
116
+ }), i;
117
+ }
118
+ /**
119
+ * Parses visibility value from string to boolean
120
+ * Accepts "1", "true" as true, everything else as false
121
+ */
122
+ _parseVisibilityValue(t) {
123
+ return t === "1" || t === "true";
124
+ }
125
+ /**
126
+ * Merges extracted visibilities with default values for missing keys
127
+ */
128
+ _mergeWithDefaults(t) {
129
+ return s.forEach((i) => {
130
+ i.key in t || (t[i.key] = i.visible, console.debug(`_readVisibilityFromRows - ${i.key}: using default ${i.visible}`));
131
+ }), t;
132
+ }
133
+ /**
134
+ * Apply the reordered composition to the block's HTML structure
135
+ * Updates the data-card-composition attribute and reorders product attributes
136
+ */
137
+ _applyCompositionToBlock(t) {
138
+ if (console.debug("_applyCompositionToBlock - composition:", t), !this.currentNode) {
139
+ console.debug("_applyCompositionToBlock - no current node");
140
+ return;
141
+ }
142
+ this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(c, t.join(",")).apply(new n("Update card composition")), this._reorderProductAttributes(t);
143
+ }
144
+ /**
145
+ * Reorders attribute rows within each product row based on composition order
146
+ */
147
+ _reorderProductAttributes(t) {
148
+ if (!this.currentNode)
149
+ return;
150
+ const i = this.currentNode.querySelectorAll(A);
151
+ if (!(i != null && i.length))
152
+ return;
153
+ const e = this.api.getDocumentModifier();
154
+ i.forEach((o) => {
155
+ const r = this._buildCompositionHtml(o, t);
156
+ e.modifyHtml(o).setInnerHtml(r);
157
+ }), e.apply(new n("Reorder product attributes"));
158
+ }
159
+ /**
160
+ * Builds HTML string with attributes ordered according to composition
161
+ */
162
+ _buildCompositionHtml(t, i) {
163
+ return i.reduce((e, o) => {
164
+ const r = t.querySelector(`${l}[${a}="${o}"]`);
165
+ return r && "getOuterHTML" in r ? e + r.getOuterHTML() : e;
166
+ }, "");
167
+ }
168
+ /**
169
+ * Apply visibility changes to the block's HTML structure
170
+ * Updates display style and data-visibility attribute for all matching rows
171
+ */
172
+ _applyVisibilityToBlock(t, i) {
173
+ if (console.debug("_applyVisibilityToBlock", t, i), !this.currentNode)
174
+ return;
175
+ const e = this.currentNode.querySelectorAll(`${l}[${a}="${t}"]`);
176
+ if (!(e != null && e.length))
177
+ return;
178
+ const o = i ? "table-row" : "none", r = i ? "1" : "0", p = `Set ${t} visibility to ${i ? "visible" : "hidden"}`, u = this.api.getDocumentModifier();
179
+ e.forEach((b) => {
180
+ u.modifyHtml(b).setStyle("display", o).setAttribute(d, r);
181
+ }), u.apply(new n(p));
182
+ }
183
+ }
184
+ export {
185
+ R as COMPOSITION_CONTROL_BLOCK_ID,
186
+ N as RecommendationCardCompositionControl
187
+ };
@@ -0,0 +1,13 @@
1
+ const _ = "productImage", b = "productName", n = "productPrice", i = "productOldPrice", O = "productOmnibusPrice", T = "productOmnibusDiscount", t = "productButton";
2
+ var o = /* @__PURE__ */ ((c) => (c.BUTTON = "recommendation-block-button", c.NAME = "recommendation-block-name", c.PRICE = "recommendation-block-price", c.OLD_PRICE = "recommendation-block-old-price", c.OMNIBUS_PRICE = "recommendation-block-omnibus-price", c.OMNIBUS_DISCOUNT = "recommendation-block-omnibus-discount", c.IMAGE = "recommendation-block-image", c))(o || {}), r = /* @__PURE__ */ ((c) => (c.BUTTON_ALIGN = "recommendation-block-button-align-control", c.BUTTON_BORDER = "recommendation-block-button-border-control", c.BUTTON_BORDER_RADIUS = "recommendation-block-button-border-radius-control", c.BUTTON_COLOR = "recommendation-block-button-color-control", c.BUTTON_FIT_TO_CONTENT = "recommendation-block-button-fit-to-content-control", c.BUTTON_FONT_FAMILY = "recommendation-block-button-font-family-control", c.BUTTON_MARGINS = "recommendation-block-button-margins-control", c.BUTTON_PADDINGS = "recommendation-block-button-paddings-control", c.BUTTON_TEXT = "recommendation-block-button-text-control", c.BUTTON_TEXT_SIZE = "recommendation-block-button-text-size-control", c.BUTTON_TEXT_STYLE_AND_FONT_COLOR = "recommendation-block-button-text-style-and-font-color-control", c.NAME_ALIGN = "recommendation-block-name-align-control", c.NAME_BACKGROUND = "recommendation-block-name-background-control", c.NAME_COLOR = "recommendation-block-name-color-control", c.NAME_FONT_FAMILY = "recommendation-block-name-font-family-control", c.NAME_PADDINGS = "recommendation-block-name-paddings-control", c.NAME_SIZE = "recommendation-block-name-size-control", c.NAME_STYLE = "recommendation-block-name-style-control", c.NAME_TEXT_TRIM = "recommendation-block-name-text-trim-control", c.PRICE_ALIGN = "recommendation-block-price-align-control", c.PRICE_BACKGROUND = "recommendation-block-price-background-control", c.PRICE_COLOR = "recommendation-block-price-color-control", c.PRICE_FONT_FAMILY = "recommendation-block-price-font-family-control", c.PRICE_PADDINGS = "recommendation-block-price-paddings-control", c.PRICE_SIZE = "recommendation-block-price-size-control", c.PRICE_STYLE = "recommendation-block-price-style-control", c.OLD_PRICE_ALIGN = "recommendation-block-old-price-align-control", c.OLD_PRICE_BACKGROUND = "recommendation-block-old-price-background-control", c.OLD_PRICE_COLOR = "recommendation-block-old-price-color-control", c.OLD_PRICE_FONT_FAMILY = "recommendation-block-old-price-font-family-control", c.OLD_PRICE_PADDINGS = "recommendation-block-old-price-paddings-control", c.OLD_PRICE_SIZE = "recommendation-block-old-price-size-control", c.OLD_PRICE_STYLE = "recommendation-block-old-price-style-control", c.OMNIBUS_PRICE_ALIGN = "recommendation-block-omnibus-price-align-control", c.OMNIBUS_PRICE_BACKGROUND = "recommendation-block-omnibus-price-background-control", c.OMNIBUS_PRICE_COLOR = "recommendation-block-omnibus-price-color-control", c.OMNIBUS_PRICE_FONT_FAMILY = "recommendation-block-omnibus-price-font-family-control", c.OMNIBUS_PRICE_PADDINGS = "recommendation-block-omnibus-price-paddings-control", c.OMNIBUS_PRICE_SIZE = "recommendation-block-omnibus-price-size-control", c.OMNIBUS_PRICE_STYLE = "recommendation-block-omnibus-price-style-control", c.OMNIBUS_PRICE_TEXT_BEFORE = "recommendation-block-omnibus-price-text-before-control", c.OMNIBUS_PRICE_TEXT_AFTER = "recommendation-block-omnibus-price-text-after-control", c.OMNIBUS_DISCOUNT_ALIGN = "recommendation-block-omnibus-discount-align-control", c.OMNIBUS_DISCOUNT_BACKGROUND = "recommendation-block-omnibus-discount-background-control", c.OMNIBUS_DISCOUNT_COLOR = "recommendation-block-omnibus-discount-color-control", c.OMNIBUS_DISCOUNT_FONT_FAMILY = "recommendation-block-omnibus-discount-font-family-control", c.OMNIBUS_DISCOUNT_PADDINGS = "recommendation-block-omnibus-discount-paddings-control", c.OMNIBUS_DISCOUNT_SIZE = "recommendation-block-omnibus-discount-size-control", c.OMNIBUS_DISCOUNT_STYLE = "recommendation-block-omnibus-discount-style-control", c.OMNIBUS_DISCOUNT_TEXT_BEFORE = "recommendation-block-omnibus-discount-text-before-control", c.OMNIBUS_DISCOUNT_TEXT_AFTER = "recommendation-block-omnibus-discount-text-after-control", c.IMAGE_SIZE = "recommendation-block-image-size-control", c.IMAGE_MARGINS = "recommendation-block-image-margins-control", c))(r || {});
3
+ export {
4
+ t as ATTR_PRODUCT_BUTTON,
5
+ _ as ATTR_PRODUCT_IMAGE,
6
+ b as ATTR_PRODUCT_NAME,
7
+ i as ATTR_PRODUCT_OLD_PRICE,
8
+ T as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
9
+ O as ATTR_PRODUCT_OMNIBUS_PRICE,
10
+ n as ATTR_PRODUCT_PRICE,
11
+ o as RecommendationBlockId,
12
+ r as RecommendationControlId
13
+ };