@useinsider/guido 2.2.0-beta.dc12458 → 2.2.0-beta.fa4cec8

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 (172) 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 +15 -14
  6. package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
  7. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
  8. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
  9. package/dist/composables/useBlocksConfig.js +26 -16
  10. package/dist/composables/useHtmlValidator.js +114 -104
  11. package/dist/composables/useRecommendation.js +54 -21
  12. package/dist/composables/useStripo.js +25 -23
  13. package/dist/composables/useVersionHistoryApi.js +1 -1
  14. package/dist/config/compiler/recommendationCompilerRules.js +45 -39
  15. package/dist/config/compiler/utils/recommendationCompilerUtils.js +121 -0
  16. package/dist/config/i18n/en/index.js +11 -0
  17. package/dist/config/i18n/en/labels.json.js +7 -0
  18. package/dist/config/i18n/en/toasters.json.js +56 -0
  19. package/dist/config/i18n/en/tooltips.json.js +82 -0
  20. package/dist/config/i18n/index.js +7 -0
  21. package/dist/config/migrator/itemsBlockMigrator.js +127 -122
  22. package/dist/config/migrator/recommendationMigrator.js +2 -2
  23. package/dist/enums/defaults.js +8 -4
  24. package/dist/enums/extensions/recommendationBlock.js +1 -1
  25. package/dist/enums/recommendation.js +16 -15
  26. package/dist/extensions/Blocks/Recommendation/block.js +133 -9
  27. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
  28. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
  29. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +66 -0
  30. package/dist/extensions/Blocks/Recommendation/constants/layout.js +22 -0
  31. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +21 -0
  32. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
  33. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
  34. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
  35. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
  36. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +92 -0
  37. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +102 -0
  38. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +209 -0
  39. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +52 -0
  40. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +250 -0
  41. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +70 -0
  42. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +160 -0
  43. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +67 -0
  44. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +307 -0
  45. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
  46. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
  47. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +108 -0
  48. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
  49. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
  50. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
  51. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
  52. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
  53. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
  54. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +14 -12
  55. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
  56. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +222 -0
  57. package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
  58. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
  59. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
  60. package/dist/extensions/Blocks/Recommendation/services/configService.js +240 -0
  61. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
  62. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +254 -207
  63. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +228 -0
  64. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
  65. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +66 -0
  66. package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
  67. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +169 -0
  68. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
  69. package/dist/extensions/Blocks/Recommendation/templates/utils.js +134 -0
  70. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
  71. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
  72. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +26 -15
  73. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
  74. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
  75. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  76. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  77. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  78. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  79. package/dist/extensions/Blocks/controlFactories.js +125 -93
  80. package/dist/extensions/ModulesTabIcons/extension.js +17 -0
  81. package/dist/guido.css +1 -1
  82. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +317 -193
  83. package/dist/services/recommendationApi.js +11 -8
  84. package/dist/services/stripoApi.js +20 -17
  85. package/dist/services/templateLibraryApi.js +16 -13
  86. package/dist/src/@types/config/schemas.d.ts +8 -0
  87. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  88. package/dist/src/composables/useConfig.d.ts +4 -0
  89. package/dist/src/composables/useRecommendation.d.ts +1 -0
  90. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
  91. package/dist/src/config/i18n/en/index.d.ts +1 -0
  92. package/dist/src/config/i18n/index.d.ts +16 -0
  93. package/dist/src/enums/defaults.d.ts +4 -0
  94. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +67 -0
  95. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
  96. package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
  97. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +49 -0
  98. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
  99. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +41 -0
  100. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +35 -0
  101. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
  102. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
  103. package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
  104. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
  105. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
  106. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
  107. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
  108. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +52 -0
  109. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
  110. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +79 -0
  111. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
  112. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +60 -0
  113. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
  114. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +221 -0
  115. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
  116. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
  117. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +34 -0
  118. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
  119. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
  120. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
  121. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
  122. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
  123. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
  124. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
  125. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
  126. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +83 -0
  127. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
  128. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
  129. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
  130. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +138 -468
  131. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
  132. package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → grid/migration.d.ts} +11 -4
  133. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
  134. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +41 -0
  135. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
  136. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
  137. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
  138. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +66 -0
  139. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
  140. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +166 -0
  141. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
  142. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  143. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
  144. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  145. package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
  146. package/dist/src/stores/config.d.ts +36 -0
  147. package/dist/static/styles/components/notification.css.js +19 -0
  148. package/dist/static/styles/components/tools.css.js +6 -2
  149. package/dist/static/styles/components/version-history.css.js +10 -2
  150. package/dist/static/styles/components/wide-panel.css.js +18 -2
  151. package/dist/static/styles/customEditorStyle.css.js +35 -11
  152. package/dist/static/styles/variables.css.js +2 -0
  153. package/dist/static/templates/empty/index.html.js +74 -0
  154. package/dist/static/templates/empty/style.css.js +779 -0
  155. package/dist/stores/unsubscribe.js +37 -34
  156. package/dist/utils/pairProductVariables.js +57 -56
  157. package/dist/utils/templatePreparation.js +15 -14
  158. package/package.json +1 -1
  159. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
  160. package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
  161. package/dist/extensions/Blocks/Recommendation/control.js +0 -336
  162. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
  163. package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
  164. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
  165. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
  166. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
  167. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
  168. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
  169. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -38
  170. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +0 -16
  171. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
  172. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
@@ -0,0 +1,66 @@
1
+ import { DEFAULT_ROW_SPACING as U, DEFAULT_COLUMN_SPACING as I, DEFAULT_MOBILE_CARDS_IN_ROW as n, DEFAULT_CARDS_IN_ROW as s } from "./layout.js";
2
+ import { ATTR_PRODUCT_IMAGE as t, ATTR_PRODUCT_NAME as e, ATTR_PRODUCT_OLD_PRICE as o, ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OMNIBUS_PRICE as T, ATTR_PRODUCT_OMNIBUS_DISCOUNT as r, ATTR_PRODUCT_BUTTON as R } from "./selectors.js";
3
+ const O = {
4
+ code: "USD",
5
+ symbol: "USD",
6
+ alignment: "after",
7
+ decimalCount: 2,
8
+ decimalSeparator: ".",
9
+ thousandSeparator: ","
10
+ }, i = {
11
+ textBefore: "",
12
+ textAfter: ""
13
+ }, C = {
14
+ textBefore: "",
15
+ textAfter: ""
16
+ }, D = [
17
+ t,
18
+ e,
19
+ o,
20
+ _,
21
+ T,
22
+ r,
23
+ R
24
+ ], A = {
25
+ [t]: !0,
26
+ [e]: !0,
27
+ [_]: !0,
28
+ [o]: !0,
29
+ [T]: !1,
30
+ [r]: !1,
31
+ [R]: !0
32
+ }, E = {
33
+ // Settings
34
+ strategy: "mostPopular",
35
+ productIds: [],
36
+ size: "6",
37
+ shuffleProducts: !1,
38
+ language: "en_US",
39
+ currency: O,
40
+ filters: [],
41
+ // Layout
42
+ layout: "grid",
43
+ cardsInRow: s,
44
+ mobileCardsInRow: n,
45
+ columnSpacing: I,
46
+ rowSpacing: U,
47
+ // Composition
48
+ composition: D,
49
+ visibility: A,
50
+ // Element settings
51
+ omnibusPrice: i,
52
+ omnibusDiscount: C,
53
+ textTrimming: !1,
54
+ // Meta
55
+ configVersion: 1,
56
+ recommendationId: 0
57
+ }, N = 1;
58
+ export {
59
+ N as CURRENT_CONFIG_VERSION,
60
+ D as DEFAULT_COMPOSITION,
61
+ O as DEFAULT_CURRENCY,
62
+ E as DEFAULT_NODE_CONFIG,
63
+ C as DEFAULT_OMNIBUS_DISCOUNT,
64
+ i as DEFAULT_OMNIBUS_PRICE,
65
+ A as DEFAULT_VISIBILITY
66
+ };
@@ -0,0 +1,22 @@
1
+ const _ = {
2
+ GRID: "grid",
3
+ LIST: "list"
4
+ }, o = [
5
+ { icon: "grid-orientation", value: _.GRID },
6
+ { icon: "list-orientation", value: _.LIST }
7
+ ], t = 3, n = 3, A = 9, O = 4, R = 1, T = 2, c = 10, s = 20, I = 0, S = 50, P = 5;
8
+ export {
9
+ n as DEFAULT_CARDS_IN_ROW,
10
+ c as DEFAULT_COLUMN_SPACING,
11
+ R as DEFAULT_MOBILE_CARDS_IN_ROW,
12
+ t as DEFAULT_PRODUCTS_PER_ROW,
13
+ s as DEFAULT_ROW_SPACING,
14
+ o as LAYOUT_OPTIONS,
15
+ _ as LAYOUT_VALUES,
16
+ T as MAX_MOBILE_PRODUCTS_PER_ROW,
17
+ O as MAX_PRODUCTS_PER_ROW,
18
+ A as MAX_PRODUCT_COUNT,
19
+ S as MAX_SPACING,
20
+ I as MIN_SPACING,
21
+ P as SPACING_STEP
22
+ };
@@ -0,0 +1,21 @@
1
+ const c = ".ins-recommendation-product-container", n = ".ins-recommendation-desktop-container", o = ".ins-recommendation-mobile-container", T = {
2
+ CURRENCY: "currency",
3
+ SYMBOL: "currency-symbol",
4
+ ALIGNMENT: "currency-alignment",
5
+ THOUSAND_SEPARATOR: "currency-thousand-separator",
6
+ DECIMAL_SEPARATOR: "currency-decimal-separator",
7
+ DECIMAL_COUNT: "currency-decimal-count"
8
+ }, t = "productImage", r = "productName", R = "productPrice", e = "productOldPrice", O = "productOmnibusPrice", _ = "productOmnibusDiscount", C = "productButton";
9
+ export {
10
+ C as ATTR_PRODUCT_BUTTON,
11
+ t as ATTR_PRODUCT_IMAGE,
12
+ r as ATTR_PRODUCT_NAME,
13
+ e as ATTR_PRODUCT_OLD_PRICE,
14
+ _ as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
15
+ O as ATTR_PRODUCT_OMNIBUS_PRICE,
16
+ R as ATTR_PRODUCT_PRICE,
17
+ c as CONTAINER_SELECTOR,
18
+ T as CURRENCY_ATTR,
19
+ n as DESKTOP_CONTAINER_SELECTOR,
20
+ o as MOBILE_CONTAINER_SELECTOR
21
+ };
@@ -0,0 +1,64 @@
1
+ import { createButtonFitToContainerControl as T, createButtonTextStyleAndFontColorControl as r, createButtonTextSizeControl as e, createButtonTextControl as B, createButtonPaddingsControl as l, createButtonMarginsControl as C, createButtonFontFamilyControl as O, createButtonColorControl as N, createButtonBorderRadiusControl as i, createButtonBorderControl as a, createButtonAlignControl 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 n } from "../../constants/selectors.js";
5
+ const U = c(
6
+ t.BUTTON_ALIGN,
7
+ o.BUTTON,
8
+ n
9
+ ), d = a(
10
+ t.BUTTON_BORDER,
11
+ o.BUTTON,
12
+ n
13
+ ), s = i(
14
+ t.BUTTON_BORDER_RADIUS,
15
+ o.BUTTON,
16
+ n
17
+ ), _ = N(
18
+ t.BUTTON_COLOR,
19
+ o.BUTTON,
20
+ n
21
+ ), m = O(
22
+ t.BUTTON_FONT_FAMILY,
23
+ o.BUTTON,
24
+ n
25
+ ), u = C(
26
+ t.BUTTON_MARGINS,
27
+ o.BUTTON,
28
+ n
29
+ ), R = l(
30
+ t.BUTTON_PADDINGS,
31
+ o.BUTTON,
32
+ n
33
+ ), F = B(
34
+ t.BUTTON_TEXT,
35
+ o.BUTTON,
36
+ n
37
+ ), A = e(
38
+ t.BUTTON_TEXT_SIZE,
39
+ o.BUTTON,
40
+ n
41
+ ), S = r(
42
+ t.BUTTON_TEXT_STYLE_AND_FONT_COLOR,
43
+ o.BUTTON,
44
+ n
45
+ ), E = T(
46
+ t.BUTTON_FIT_TO_CONTENT,
47
+ o.BUTTON,
48
+ n
49
+ ), p = {
50
+ align: U,
51
+ border: d,
52
+ borderRadius: s,
53
+ color: _,
54
+ fontFamily: m,
55
+ margins: u,
56
+ paddings: R,
57
+ text: F,
58
+ textSize: A,
59
+ textStyleAndFontColor: S,
60
+ fitToContent: E
61
+ };
62
+ export {
63
+ p as ButtonControls
64
+ };
@@ -0,0 +1,80 @@
1
+ import { ModificationDescription as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as s } from "../../../common-control.js";
3
+ import { getCurrentLayout as l } from "../main/utils.js";
4
+ const u = "recommendation-card-background-color-control", e = {
5
+ CARD_BACKGROUND_COLOR: "cardBackgroundColor"
6
+ }, a = {
7
+ GRID: ".product-card-segment",
8
+ LIST: ".product-card-wrapper"
9
+ };
10
+ class _ extends s {
11
+ getId() {
12
+ return u;
13
+ }
14
+ getTemplate() {
15
+ return `
16
+ <div class="card-bg-control-container">
17
+ ${this._GuTwoColumns([
18
+ this._GuLabel({ text: "Card Background Color" }),
19
+ this._GuColorPicker(e.CARD_BACKGROUND_COLOR)
20
+ ])}
21
+ </div>
22
+ `;
23
+ }
24
+ onRender() {
25
+ this._setFormValues(), this._listenToFormUpdates();
26
+ }
27
+ onTemplateNodeUpdated(r) {
28
+ super.onTemplateNodeUpdated(r), this._setFormValues();
29
+ }
30
+ _setFormValues() {
31
+ const r = this._getCurrentCardBackgroundColor();
32
+ this.api.updateValues({
33
+ [e.CARD_BACKGROUND_COLOR]: r
34
+ });
35
+ }
36
+ /**
37
+ * Gets the appropriate selector based on layout
38
+ * Grid: .product-card-segment (inner table per product cell)
39
+ * List: .product-card-wrapper (table per product row)
40
+ */
41
+ _getCardSelector() {
42
+ return l(this.currentNode) === "grid" ? a.GRID : a.LIST;
43
+ }
44
+ /**
45
+ * Reads the current background color from the first product card element
46
+ * @returns The background color value or 'transparent' if not found
47
+ */
48
+ _getCurrentCardBackgroundColor() {
49
+ if (!this.currentNode || !("querySelectorAll" in this.currentNode))
50
+ return "transparent";
51
+ const r = this._getCardSelector(), t = this.currentNode.querySelector(r);
52
+ return !t || !("getStyle" in t) ? "transparent" : t.getStyle("background-color") || "transparent";
53
+ }
54
+ /**
55
+ * Handles card background color changes
56
+ * Applies the color to all product card elements based on layout
57
+ */
58
+ _onCardBackgroundColorChange(r) {
59
+ if (!this.currentNode || !("querySelectorAll" in this.currentNode))
60
+ return;
61
+ const t = this._getCardSelector(), o = Array.from(
62
+ this.currentNode.querySelectorAll(t)
63
+ );
64
+ if (o.length === 0)
65
+ return;
66
+ const n = this.api.getDocumentModifier();
67
+ o.forEach((c) => {
68
+ n.modifyHtml(c).setStyle("background-color", r);
69
+ }), n.apply(new d("Update card background color"));
70
+ }
71
+ _listenToFormUpdates() {
72
+ this.api.onValueChanged(e.CARD_BACKGROUND_COLOR, (r) => {
73
+ this._onCardBackgroundColorChange(r);
74
+ });
75
+ }
76
+ }
77
+ export {
78
+ u as CARD_BACKGROUND_COLOR_CONTROL_ID,
79
+ _ as CardBackgroundColorControl
80
+ };
@@ -0,0 +1,232 @@
1
+ var T = Object.defineProperty;
2
+ var C = (a, s, t) => s in a ? T(a, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[s] = t;
3
+ var l = (a, s, t) => C(a, typeof s != "symbol" ? s + "" : s, t);
4
+ import { ModificationDescription as u } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as f } from "../../../common-control.js";
6
+ import { ATTR_PRODUCT_IMAGE as O, ATTR_PRODUCT_NAME as g, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_OLD_PRICE as A, ATTR_PRODUCT_OMNIBUS_PRICE as D, ATTR_PRODUCT_OMNIBUS_DISCOUNT as N, ATTR_PRODUCT_BUTTON as V } from "../../constants/selectors.js";
7
+ import { useRecommendationExtensionStore as E } from "../../store/recommendation.js";
8
+ import { getTableDisplayValue as I } from "../../utils/tagName.js";
9
+ import { getCurrentLayout as P } from "../main/utils.js";
10
+ const S = "ui-elements-recommendation-card-composition", k = {
11
+ ORDERABLE: "cardComposition"
12
+ }, c = ".recommendation-attribute-row", v = ".product-card-wrapper > tbody", _ = "data-card-composition", d = "data-attribute-type", m = "data-visibility", n = [
13
+ { key: O, label: "Product Image", visible: !0 },
14
+ { key: g, label: "Product Name", visible: !0 },
15
+ { key: R, label: "Product Price", visible: !0 },
16
+ { key: A, label: "Product Original Price", visible: !0 },
17
+ { key: D, label: "Omnibus Price", visible: !1 },
18
+ { key: N, label: "Omnibus Discount", visible: !1 },
19
+ { key: V, label: "Product Button", visible: !0 }
20
+ ];
21
+ class H extends f {
22
+ constructor() {
23
+ super(...arguments);
24
+ l(this, "store", E());
25
+ l(this, "unsubscribeOrientation", null);
26
+ }
27
+ getId() {
28
+ return S;
29
+ }
30
+ getTemplate() {
31
+ const t = n.map((e) => ({
32
+ key: e.key,
33
+ label: e.label,
34
+ content: this._createItemContent(e.label, e.key)
35
+ }));
36
+ return `
37
+ <div class="container" data-card-composition-control>
38
+ ${this._GuLabel({ text: "Card Element Order & Visibility" })}
39
+ ${this._GuOrderable(k.ORDERABLE, t)}
40
+ </div>
41
+ `;
42
+ }
43
+ onRender() {
44
+ this._initializeComposition(), this._registerValueChangeListeners(), this._updateOrderableState(), this._subscribeToOrientationChanges();
45
+ }
46
+ onTemplateNodeUpdated(t) {
47
+ super.onTemplateNodeUpdated(t), this._initializeComposition(), this._updateOrderableState();
48
+ }
49
+ /**
50
+ * Creates the HTML content for an orderable item with label and toggle
51
+ */
52
+ _createItemContent(t, e) {
53
+ return `
54
+ <div style="display: flex; align-items: center; justify-content: space-between;
55
+ padding: 8px; gap: 8px;">
56
+ <span style="flex: 1;">${t}</span>
57
+ ${this._GuToggle(`visibility_${e}`)}
58
+ </div>
59
+ `;
60
+ }
61
+ /**
62
+ * Registers event listeners for composition and visibility changes
63
+ */
64
+ _registerValueChangeListeners() {
65
+ this.api.onValueChanged("cardComposition", (t) => {
66
+ this._applyCompositionToBlock(t);
67
+ }), n.forEach((t) => {
68
+ this.api.onValueChanged(`visibility_${t.key}`, (e) => {
69
+ this._applyVisibilityToBlock(t.key, e);
70
+ });
71
+ });
72
+ }
73
+ /**
74
+ * Initializes composition order and visibility state from the current node
75
+ */
76
+ _initializeComposition() {
77
+ const t = this._readCompositionFromNode(), e = this._readVisibilityFromRows(), i = {
78
+ cardComposition: t,
79
+ ...this._buildVisibilityValues(e)
80
+ };
81
+ this.api.updateValues(i);
82
+ }
83
+ /**
84
+ * Reads composition order from node's data-card-composition attribute
85
+ * Falls back to default order if attribute is not present
86
+ */
87
+ _readCompositionFromNode() {
88
+ if (!this.currentNode || !("getAttribute" in this.currentNode))
89
+ return n.map((e) => e.key);
90
+ const t = this.currentNode.getAttribute(_);
91
+ return t ? t.split(",").filter(Boolean) : n.map((e) => e.key);
92
+ }
93
+ /**
94
+ * Builds visibility values object from the visibility map
95
+ */
96
+ _buildVisibilityValues(t) {
97
+ return n.reduce((e, i) => (e[`visibility_${i.key}`] = t[i.key] ?? !0, e), {});
98
+ }
99
+ /**
100
+ * Read visibility state from individual row elements' data-visibility attributes
101
+ * This ensures toggles reflect the actual DOM state
102
+ */
103
+ _readVisibilityFromRows() {
104
+ if (!this.currentNode)
105
+ return this._getDefaultVisibilities();
106
+ const t = Array.from(this.currentNode.querySelectorAll(c)), e = this._extractVisibilityFromRows(t);
107
+ return this._mergeWithDefaults(e);
108
+ }
109
+ /**
110
+ * Returns default visibility values for all items
111
+ */
112
+ _getDefaultVisibilities() {
113
+ return n.reduce((t, e) => (t[e.key] = e.visible, t), {});
114
+ }
115
+ /**
116
+ * Extracts visibility values from DOM nodes
117
+ */
118
+ _extractVisibilityFromRows(t) {
119
+ const e = {};
120
+ return t.forEach((i) => {
121
+ if (!("getAttribute" in i))
122
+ return;
123
+ const o = i.getAttribute(d), r = i.getAttribute(m);
124
+ o && r !== null && (e[o] = this._parseVisibilityValue(r));
125
+ }), e;
126
+ }
127
+ /**
128
+ * Parses visibility value from string to boolean
129
+ * Accepts "1", "true" as true, everything else as false
130
+ */
131
+ _parseVisibilityValue(t) {
132
+ return t === "1" || t === "true";
133
+ }
134
+ /**
135
+ * Merges extracted visibilities with default values for missing keys
136
+ */
137
+ _mergeWithDefaults(t) {
138
+ return n.forEach((e) => {
139
+ e.key in t || (t[e.key] = e.visible);
140
+ }), t;
141
+ }
142
+ /**
143
+ * Apply the reordered composition to the block's HTML structure
144
+ * Updates the data-card-composition attribute and reorders product attributes
145
+ * Note: Reordering is only applied for grid layout
146
+ */
147
+ _applyCompositionToBlock(t) {
148
+ if (!this.currentNode)
149
+ return;
150
+ const e = this._getCurrentLayout();
151
+ this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(_, t.join(",")).apply(new u("Update card composition")), e === "grid" && this._reorderProductAttributes(t);
152
+ }
153
+ /**
154
+ * Reorders attribute rows within each product card based on composition order
155
+ * Targets the tbody inside each product-attribute-cell to preserve card structure
156
+ */
157
+ _reorderProductAttributes(t) {
158
+ if (!this.currentNode)
159
+ return;
160
+ const e = this.currentNode.querySelectorAll(v);
161
+ if (!(e != null && e.length))
162
+ return;
163
+ const i = this.api.getDocumentModifier();
164
+ e.forEach((o) => {
165
+ const r = this._buildCompositionHtml(o, t);
166
+ i.modifyHtml(o).setInnerHtml(r);
167
+ }), i.apply(new u("Reorder product attributes"));
168
+ }
169
+ /**
170
+ * Builds HTML string with attributes ordered according to composition
171
+ */
172
+ _buildCompositionHtml(t, e) {
173
+ return e.reduce((i, o) => {
174
+ const r = t.querySelector(`${c}[${d}="${o}"]`);
175
+ return r && "getOuterHTML" in r ? i + r.getOuterHTML() : i;
176
+ }, "");
177
+ }
178
+ /**
179
+ * Apply visibility changes to the block's HTML structure
180
+ * Updates display style and data-visibility attribute for all matching elements
181
+ * - <tr> elements: use display: none / table-row
182
+ * - <td> elements: use display: none / table-cell
183
+ */
184
+ _applyVisibilityToBlock(t, e) {
185
+ if (!this.currentNode)
186
+ return;
187
+ const i = this.currentNode.querySelectorAll(`${c}[${d}="${t}"]`);
188
+ if (!(i != null && i.length))
189
+ return;
190
+ const o = e ? "1" : "0", r = `Set ${t} visibility to ${e ? "visible" : "hidden"}`, b = this.api.getDocumentModifier();
191
+ i.forEach((p) => {
192
+ const y = I(p), h = e ? y : "none";
193
+ b.modifyHtml(p).setStyle("display", h).setAttribute(m, o);
194
+ }), b.apply(new u(r));
195
+ }
196
+ /**
197
+ * Gets the current layout orientation from store or DOM
198
+ */
199
+ _getCurrentLayout() {
200
+ return this.store.recommendationConfigs.orientation || P(this.currentNode);
201
+ }
202
+ /**
203
+ * Updates orderable state based on layout orientation
204
+ * Adds/removes disabled class to hide drag icons for list layout
205
+ */
206
+ _updateOrderableState() {
207
+ const e = this._getCurrentLayout() === "list", i = this.getContainer();
208
+ if (!i)
209
+ return;
210
+ const o = i.querySelector("[data-card-composition-control]");
211
+ if (!o)
212
+ return;
213
+ const r = o.querySelector("ue-orderable");
214
+ r && r.classList.toggle("orderable-disabled", e);
215
+ }
216
+ /**
217
+ * Subscribe to store orientation changes
218
+ * Updates orderable state when layout changes via the layout control
219
+ */
220
+ _subscribeToOrientationChanges() {
221
+ this.unsubscribeOrientation && this.unsubscribeOrientation();
222
+ let t = this.store.recommendationConfigs.orientation;
223
+ this.unsubscribeOrientation = this.store.$subscribe(() => {
224
+ const e = this.store.recommendationConfigs.orientation;
225
+ e !== t && (t = e, this._updateOrderableState());
226
+ });
227
+ }
228
+ }
229
+ export {
230
+ S as COMPOSITION_CONTROL_BLOCK_ID,
231
+ H as RecommendationCardCompositionControl
232
+ };
@@ -0,0 +1,19 @@
1
+ import { createImageMarginsControl as m, createImageSizeControl as n } from "../../../controlFactories.js";
2
+ import { RecommendationBlockId as o } from "../../constants/blockIds.js";
3
+ import { RecommendationControlId as r } from "../../constants/controlIds.js";
4
+ import { CONTAINER_SELECTOR as t } from "../../constants/selectors.js";
5
+ const e = n(
6
+ r.IMAGE_SIZE,
7
+ o.IMAGE,
8
+ t
9
+ ), i = m(
10
+ r.IMAGE_MARGINS,
11
+ o.IMAGE,
12
+ t
13
+ ), C = {
14
+ size: e,
15
+ margins: i
16
+ };
17
+ export {
18
+ C as ImageControls
19
+ };
@@ -0,0 +1,92 @@
1
+ var c = Object.defineProperty;
2
+ var d = (o, e, t) => e in o ? c(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var n = (o, e, t) => d(o, typeof e != "symbol" ? e + "" : e, t);
4
+ import { ModificationDescription as m } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as h } from "../../../common-control.js";
6
+ import { LAYOUT_OPTIONS as g } from "../../constants/layout.js";
7
+ import { RecommendationConfigService as r } from "../../services/configService.js";
8
+ import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
9
+ import { getCurrentLayout as u, getBlockElement as f, regenerateProductRowsWithStyles as p } from "../main/utils.js";
10
+ const L = "recommendation-layout-control", i = {
11
+ LAYOUT: "layout"
12
+ }, C = {
13
+ LAYOUT: "data-layout"
14
+ };
15
+ class Y extends h {
16
+ constructor() {
17
+ super(...arguments);
18
+ n(this, "store", l());
19
+ n(this, "isChangingLayout", !1);
20
+ }
21
+ getId() {
22
+ return L;
23
+ }
24
+ getTemplate() {
25
+ return `
26
+ <div class="layout-control-container">
27
+ ${this._GuTwoColumns([
28
+ this._GuLabel({ text: "Layout Orientation" }),
29
+ this._GuRadioButton({
30
+ name: i.LAYOUT,
31
+ buttons: g
32
+ })
33
+ ])}
34
+ </div>
35
+ `;
36
+ }
37
+ onRender() {
38
+ this._setFormValues(), this._listenToFormUpdates();
39
+ }
40
+ onTemplateNodeUpdated(t) {
41
+ super.onTemplateNodeUpdated(t), this._setFormValues();
42
+ }
43
+ _setFormValues() {
44
+ const s = r.getConfig(this.currentNode).layout || u(this.currentNode);
45
+ this.api.updateValues({
46
+ [i.LAYOUT]: s
47
+ });
48
+ }
49
+ /**
50
+ * Handles layout change
51
+ * Updates node config, data attribute and regenerates product rows
52
+ */
53
+ _onLayoutChange(t) {
54
+ if (this.isChangingLayout || !this.currentNode || (r.getConfig(this.currentNode).layout || u(this.currentNode)) === t)
55
+ return;
56
+ const a = f(this.currentNode);
57
+ if (a) {
58
+ this.isChangingLayout = !0;
59
+ try {
60
+ r.updateConfig(
61
+ this.api,
62
+ this.currentNode,
63
+ { layout: t },
64
+ `Changed layout to ${t}`
65
+ ), this.store.patchCurrentBlockConfig({ orientation: t }), this.api.getDocumentModifier().modifyHtml(a).setAttribute(C.LAYOUT, t).apply(new m(`Update layout to ${t}`)), this._regenerateProductRows(t);
66
+ } finally {
67
+ this.isChangingLayout = !1;
68
+ }
69
+ }
70
+ }
71
+ /**
72
+ * Regenerates product rows based on the selected layout
73
+ * Uses unified style-preserving regeneration to maintain user customizations
74
+ * @param layout - The layout to use for regeneration (passed explicitly to avoid stale DOM reads)
75
+ */
76
+ _regenerateProductRows(t) {
77
+ this.currentNode && p({
78
+ currentNode: this.currentNode,
79
+ documentModifier: this.api.getDocumentModifier(),
80
+ layout: t
81
+ });
82
+ }
83
+ _listenToFormUpdates() {
84
+ this.api.onValueChanged(i.LAYOUT, (t) => {
85
+ this._onLayoutChange(t);
86
+ });
87
+ }
88
+ }
89
+ export {
90
+ L as LAYOUT_CONTROL_ID,
91
+ Y as LayoutControl
92
+ };