@useinsider/guido 2.1.0-beta.a720424 → 2.1.0-beta.e13d291

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 (117) hide show
  1. package/dist/config/migrator/recommendationMigrator.js +2 -2
  2. package/dist/extensions/Blocks/Recommendation/block.js +40 -6
  3. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
  4. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
  5. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +64 -0
  6. package/dist/extensions/Blocks/Recommendation/constants/layout.js +20 -0
  7. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +19 -0
  8. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
  9. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
  10. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
  11. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
  12. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +96 -0
  13. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +110 -0
  14. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +204 -0
  15. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +54 -0
  16. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +205 -0
  17. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +74 -0
  18. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +118 -0
  19. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +71 -0
  20. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +286 -0
  21. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
  22. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +76 -0
  23. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
  24. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
  25. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
  26. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
  27. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
  28. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
  29. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +14 -12
  30. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
  31. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +222 -0
  32. package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
  33. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
  34. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
  35. package/dist/extensions/Blocks/Recommendation/services/configService.js +239 -0
  36. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
  37. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +41 -36
  38. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +233 -0
  39. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
  40. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +69 -0
  41. package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
  42. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +174 -0
  43. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
  44. package/dist/extensions/Blocks/Recommendation/templates/utils.js +121 -0
  45. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
  46. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
  47. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +27 -16
  48. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
  49. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
  50. package/dist/extensions/Blocks/controlFactories.js +125 -93
  51. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +223 -169
  52. package/dist/services/recommendationApi.js +10 -9
  53. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  54. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +34 -0
  55. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
  56. package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
  57. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +49 -0
  58. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
  59. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +35 -0
  60. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +31 -0
  61. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
  62. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
  63. package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
  64. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
  65. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
  66. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
  67. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
  68. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +45 -0
  69. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
  70. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +57 -0
  71. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
  72. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +42 -0
  73. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
  74. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +214 -0
  75. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
  76. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +16 -0
  77. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
  78. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
  79. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
  80. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
  81. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
  82. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
  83. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
  84. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
  85. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +83 -0
  86. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
  87. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
  88. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
  89. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +17 -16
  90. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
  91. package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → grid/migration.d.ts} +11 -4
  92. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
  93. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +39 -0
  94. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
  95. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
  96. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
  97. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +54 -0
  98. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
  99. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +154 -0
  100. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
  101. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  102. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
  103. package/dist/static/styles/customEditorStyle.css.js +25 -2
  104. package/package.json +1 -1
  105. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
  106. package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
  107. package/dist/extensions/Blocks/Recommendation/control.js +0 -336
  108. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
  109. package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
  110. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
  111. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
  112. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
  113. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
  114. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
  115. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -38
  116. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
  117. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
@@ -0,0 +1,74 @@
1
+ var s = Object.defineProperty;
2
+ var r = (o, t, e) => t in o ? s(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var a = (o, t, e) => r(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { UEAttr as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as m } from "../../../common-control.js";
6
+ import { RecommendationConfigService as i } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as c } from "../../store/recommendation.js";
8
+ const g = "recommendation-locale-control", n = {
9
+ LOCALE: "language"
10
+ };
11
+ class C extends m {
12
+ constructor() {
13
+ super(...arguments);
14
+ // Store is used ONLY for API-fetched data (language options), not for config
15
+ a(this, "store", c());
16
+ }
17
+ getId() {
18
+ return g;
19
+ }
20
+ getTemplate() {
21
+ return `
22
+ <div class="locale-control-container">
23
+ ${this._GuTwoColumns([
24
+ this._GuLabel({ text: "Recommendation Locale" }),
25
+ this._GuSelect({
26
+ name: n.LOCALE,
27
+ placeholder: "Select Recommendation Locale",
28
+ options: this.store.getLanguages
29
+ })
30
+ ])}
31
+ </div>
32
+ `;
33
+ }
34
+ onRender() {
35
+ this._initializeSelectItems(), this._setFormValues(), this._listenToFormUpdates();
36
+ }
37
+ onTemplateNodeUpdated(e) {
38
+ super.onTemplateNodeUpdated(e), this._setFormValues();
39
+ }
40
+ _setFormValues() {
41
+ const e = i.getConfig(this.currentNode);
42
+ this.api.updateValues({
43
+ [n.LOCALE]: e.language
44
+ });
45
+ }
46
+ _initializeSelectItems() {
47
+ this.api.setUIEAttribute(
48
+ n.LOCALE,
49
+ l.SELECTPICKER.items,
50
+ this.store.getLanguages
51
+ );
52
+ }
53
+ _onLocaleChange(e) {
54
+ this.currentNode && (i.updateConfig(
55
+ this.api,
56
+ this.currentNode,
57
+ { language: e },
58
+ `Changed language to ${e}`
59
+ ), this.store.$patch({
60
+ recommendationConfigs: {
61
+ language: e
62
+ }
63
+ }));
64
+ }
65
+ _listenToFormUpdates() {
66
+ this.api.onValueChanged(n.LOCALE, (e) => {
67
+ this._onLocaleChange(e);
68
+ });
69
+ }
70
+ }
71
+ export {
72
+ g as LOCALE_CONTROL_ID,
73
+ C as LocaleControl
74
+ };
@@ -0,0 +1,118 @@
1
+ var u = Object.defineProperty;
2
+ var a = (i, e, t) => e in i ? u(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var n = (i, e, t) => a(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { CommonControl as c } from "../../../common-control.js";
5
+ import { MAX_PRODUCT_COUNT as _, MAX_PRODUCTS_PER_ROW as h } from "../../constants/layout.js";
6
+ import { RecommendationConfigService as s } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
8
+ import { getCurrentLayout as C, regenerateProductRowsWithStyles as m } from "./utils.js";
9
+ import { useDebounceFn as p } from "../../../../../node_modules/@vueuse/shared/index.js";
10
+ const O = "recommendation-product-layout-control", o = {
11
+ PRODUCT_COUNT: "size",
12
+ PRODUCT_IN_ROW: "cardsInRow",
13
+ PRODUCT_IN_ROW_LABEL: "cardsInRowLabel"
14
+ };
15
+ class I extends c {
16
+ constructor() {
17
+ super(...arguments);
18
+ // Store is used for backward compatibility with product fetching and regeneration
19
+ n(this, "store", R());
20
+ n(this, "storeUnsubscription", () => {
21
+ });
22
+ n(this, "_debouncedRegenerateProductRows", p(() => {
23
+ this._regenerateProductRows();
24
+ }, 500));
25
+ }
26
+ getId() {
27
+ return O;
28
+ }
29
+ getTemplate() {
30
+ return `
31
+ <div class="product-layout-control-container">
32
+ ${this._GuTwoColumns([
33
+ this._GuLabel({ text: "Number of Products" }),
34
+ this._GuCounter({ name: o.PRODUCT_COUNT, maxValue: _ }),
35
+ this._GuLabel({ text: "Products in One Row", name: o.PRODUCT_IN_ROW_LABEL }),
36
+ this._GuCounter({ name: o.PRODUCT_IN_ROW, maxValue: h })
37
+ ])}
38
+ </div>
39
+ `;
40
+ }
41
+ onRender() {
42
+ this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates();
43
+ }
44
+ onTemplateNodeUpdated(t) {
45
+ super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility();
46
+ }
47
+ onDestroy() {
48
+ this.storeUnsubscription();
49
+ }
50
+ _setFormValues() {
51
+ const t = s.getConfig(this.currentNode);
52
+ this.api.updateValues({
53
+ [o.PRODUCT_COUNT]: t.size,
54
+ [o.PRODUCT_IN_ROW]: t.cardsInRow
55
+ });
56
+ }
57
+ /**
58
+ * Updates "Products in One Row" visibility based on layout orientation
59
+ * This control is hidden for list layout (products always take full width)
60
+ * Reads from node config first, falls back to DOM
61
+ */
62
+ _updateProductsInRowVisibility() {
63
+ const d = (s.getConfig(this.currentNode).layout || C(this.currentNode)) === "grid";
64
+ this.api.setVisibility(o.PRODUCT_IN_ROW, d), this.api.setVisibility(o.PRODUCT_IN_ROW_LABEL, d);
65
+ }
66
+ _onProductCountChange(t) {
67
+ this.currentNode && (s.updateConfig(
68
+ this.api,
69
+ this.currentNode,
70
+ { size: t },
71
+ `Changed product count to ${t}`
72
+ ), this.store.$patch({
73
+ recommendationConfigs: {
74
+ size: t
75
+ }
76
+ }), this._debouncedRegenerateProductRows());
77
+ }
78
+ _onProductsInRowChange(t) {
79
+ this.currentNode && (s.updateConfig(
80
+ this.api,
81
+ this.currentNode,
82
+ { cardsInRow: t },
83
+ `Changed products per row to ${t}`
84
+ ), this.store.$patch({
85
+ recommendationConfigs: {
86
+ cardsInRow: t
87
+ }
88
+ }), this._debouncedRegenerateProductRows());
89
+ }
90
+ _regenerateProductRows() {
91
+ m({
92
+ currentNode: this.currentNode,
93
+ documentModifier: this.api.getDocumentModifier()
94
+ });
95
+ }
96
+ _listenToFormUpdates() {
97
+ this.api.onValueChanged(o.PRODUCT_COUNT, (t) => {
98
+ this._onProductCountChange(t.toString());
99
+ }), this.api.onValueChanged(o.PRODUCT_IN_ROW, (t) => {
100
+ this._onProductsInRowChange(Number(t));
101
+ });
102
+ }
103
+ /**
104
+ * Subscribe to store changes to update visibility when layout changes
105
+ * This is still needed because layout changes come from LayoutControl
106
+ */
107
+ _listenStateUpdates() {
108
+ let t = this.store.recommendationConfigs.orientation;
109
+ this.storeUnsubscription = this.store.$subscribe(() => {
110
+ const r = this.store.recommendationConfigs.orientation;
111
+ r !== t && (t = r, this._updateProductsInRowVisibility());
112
+ });
113
+ }
114
+ }
115
+ export {
116
+ O as PRODUCT_LAYOUT_CONTROL_ID,
117
+ I as ProductLayoutControl
118
+ };
@@ -0,0 +1,71 @@
1
+ var r = Object.defineProperty;
2
+ var u = (o, t, e) => t in o ? r(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var n = (o, t, e) => u(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { UEAttr as f } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as l } from "../../../common-control.js";
6
+ import { RecommendationConfigService as i } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as d } from "../../store/recommendation.js";
8
+ const a = "recommendation-shuffle-control", s = {
9
+ SHUFFLE_PRODUCTS: "shuffleProducts"
10
+ };
11
+ class C extends l {
12
+ constructor() {
13
+ super(...arguments);
14
+ // Store is used for backward compatibility with product fetching
15
+ n(this, "store", d());
16
+ }
17
+ getId() {
18
+ return a;
19
+ }
20
+ getTemplate() {
21
+ return `
22
+ <div class="shuffle-control-container">
23
+ ${this._GuTwoColumns([
24
+ this._GuLabel({ text: "Shuffle Recommended Products" }),
25
+ this._GuToggle(s.SHUFFLE_PRODUCTS)
26
+ ])}
27
+ </div>
28
+ `;
29
+ }
30
+ onRender() {
31
+ this._initializeToggle(), this._setFormValues(), this._listenToFormUpdates();
32
+ }
33
+ onTemplateNodeUpdated(e) {
34
+ super.onTemplateNodeUpdated(e), this._setFormValues();
35
+ }
36
+ _setFormValues() {
37
+ const e = i.getConfig(this.currentNode);
38
+ this.api.updateValues({
39
+ [s.SHUFFLE_PRODUCTS]: e.shuffleProducts
40
+ });
41
+ }
42
+ _initializeToggle() {
43
+ const e = i.getConfig(this.currentNode);
44
+ this.api.setUIEAttribute(
45
+ s.SHUFFLE_PRODUCTS,
46
+ f.SELECTPICKER.items,
47
+ e.shuffleProducts
48
+ );
49
+ }
50
+ _onShuffleChange(e) {
51
+ this.currentNode && (i.updateConfig(
52
+ this.api,
53
+ this.currentNode,
54
+ { shuffleProducts: e },
55
+ `${e ? "Enabled" : "Disabled"} product shuffle`
56
+ ), this.store.$patch({
57
+ recommendationConfigs: {
58
+ shuffleProducts: e
59
+ }
60
+ }));
61
+ }
62
+ _listenToFormUpdates() {
63
+ this.api.onValueChanged(s.SHUFFLE_PRODUCTS, (e) => {
64
+ this._onShuffleChange(!!e);
65
+ });
66
+ }
67
+ }
68
+ export {
69
+ a as SHUFFLE_CONTROL_ID,
70
+ C as ShuffleControl
71
+ };
@@ -0,0 +1,286 @@
1
+ import { ModificationDescription as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { RecommendationBlockId as f } from "../../constants/blockIds.js";
3
+ import { CURRENCY_ATTR as y, CONTAINER_SELECTOR as I } from "../../constants/selectors.js";
4
+ import { useRecommendationExtensionStore as A } from "../../store/recommendation.js";
5
+ import { prepareProductRows as R } from "../../templates/index.js";
6
+ import { formatPrice as O } from "../../utils/priceFormatter.js";
7
+ import { isTdNode as T } from "../../utils/tagName.js";
8
+ import { sanitizeImageUrl as k, getDefaultProducts as _, DEFAULT_CARD_COMPOSITION as P } from "../../templates/utils.js";
9
+ const C = "ins-recommendation-v3-block-v2";
10
+ function b(o) {
11
+ if (!o)
12
+ return null;
13
+ if ("getAttribute" in o) {
14
+ const e = o.getAttribute("class");
15
+ if (e && e.includes(C))
16
+ return o;
17
+ }
18
+ return "querySelector" in o ? o.querySelector(`.${C}`) : null;
19
+ }
20
+ function q(o) {
21
+ const e = b(o);
22
+ if (!e || !("getAttribute" in e))
23
+ return "grid";
24
+ const t = e.getAttribute("data-layout");
25
+ return t === "list" || t === "horizontal" ? "list" : "grid";
26
+ }
27
+ function D(o) {
28
+ const e = b(o);
29
+ if (!e || !("getAttribute" in e))
30
+ return P;
31
+ const t = e.getAttribute("data-card-composition");
32
+ return t ? t.split(",").filter(Boolean) : P;
33
+ }
34
+ function S(o, e, t) {
35
+ if (!e || !("childNodes" in e))
36
+ return !1;
37
+ const n = e.childNodes().find(
38
+ (i) => "getType" in i && i.getType() === "text"
39
+ );
40
+ return n ? (o.modifyHtml(n).setText(t), !0) : !1;
41
+ }
42
+ function w(o, e) {
43
+ return o && o.length > 0 ? o : e.length > 0 ? e : _();
44
+ }
45
+ function U(o) {
46
+ const { currentNode: e, documentModifier: t, afterRegenerate: r, products: n, layout: i } = o;
47
+ if (!e || !("querySelector" in e))
48
+ return;
49
+ const c = e.querySelector(I);
50
+ if (!c)
51
+ return;
52
+ const s = A(), l = w(n, s.recommendationProducts), { cardsInRow: u } = s.recommendationConfigs, d = D(e), a = i ?? q(e), p = R(l, a, {
53
+ productsPerRow: u,
54
+ composition: d
55
+ });
56
+ t.modifyHtml(c).setInnerHtml(p).apply(new g("Updated product")), r == null || r();
57
+ }
58
+ function $(o, e, t, r) {
59
+ const i = `0 ${Math.floor(t / 2)}px`;
60
+ let c = !1;
61
+ return r === "grid" ? Array.from(
62
+ o.querySelectorAll(".attribute-cell")
63
+ ).forEach((l) => {
64
+ e.modifyHtml(l).setStyle("padding", i), c = !0;
65
+ }) : Array.from(
66
+ o.querySelectorAll(".product-card-wrapper")
67
+ ).forEach((l) => {
68
+ const u = "parentNode" in l ? l.parentNode : null;
69
+ u && T(u) && (e.modifyHtml(u).setStyle("padding", i), c = !0);
70
+ }), c;
71
+ }
72
+ function L(o, e, t) {
73
+ const r = `${t}px`, n = Array.from(o.querySelectorAll(".spacer"));
74
+ let i = !1;
75
+ return n.forEach((c) => {
76
+ e.modifyHtml(c).setStyle("height", r), i = !0;
77
+ }), i;
78
+ }
79
+ function H(o) {
80
+ const { currentNode: e, documentModifier: t } = o;
81
+ if (!e)
82
+ return;
83
+ const r = b(e);
84
+ if (!r || !("getAttribute" in r))
85
+ return;
86
+ const n = r.getAttribute("data-column-spacing"), i = r.getAttribute("data-row-spacing"), c = q(e);
87
+ let s = !1;
88
+ if (n) {
89
+ const l = parseInt(n);
90
+ Number.isNaN(l) || (s = $(
91
+ e,
92
+ t,
93
+ l,
94
+ c
95
+ ));
96
+ }
97
+ if (i) {
98
+ const l = parseInt(i);
99
+ if (!Number.isNaN(l)) {
100
+ const u = L(e, t, l);
101
+ s = s || u;
102
+ }
103
+ }
104
+ s && t.apply(new g("Reapply spacing after regeneration"));
105
+ }
106
+ function K(o) {
107
+ const { currentNode: e, documentModifier: t, afterRegenerate: r, products: n, layout: i } = o;
108
+ e && U({
109
+ currentNode: e,
110
+ documentModifier: t,
111
+ products: n,
112
+ layout: i,
113
+ afterRegenerate: () => {
114
+ setTimeout(() => {
115
+ H({ currentNode: e, documentModifier: t });
116
+ }, 0), r == null || r();
117
+ }
118
+ });
119
+ }
120
+ function h() {
121
+ const o = A(), { currencySettings: e } = o.recommendationConfigs;
122
+ return {
123
+ code: e.value,
124
+ symbol: e.symbol,
125
+ alignment: e.alignment === "0" ? "before" : "after",
126
+ decimalCount: parseInt(e.decimalCount) || 2,
127
+ decimalSeparator: e.decimalSeparator,
128
+ thousandSeparator: e.thousandSeparator
129
+ };
130
+ }
131
+ function E(o, e = "price") {
132
+ const t = h(), r = o[e], n = (r == null ? void 0 : r[t.code]) ?? Object.values(r ?? {})[0] ?? 0;
133
+ return O({
134
+ price: n,
135
+ currency: t
136
+ });
137
+ }
138
+ function x(o) {
139
+ var i, c;
140
+ const e = h(), t = ((i = o.original_price) == null ? void 0 : i[e.code]) ?? Object.values(o.original_price ?? {})[0] ?? 0, r = ((c = o.price) == null ? void 0 : c[e.code]) ?? Object.values(o.price ?? {})[0] ?? 0, n = t > 0 ? Math.round((t - r) / t * 100) : 0;
141
+ return n > 0 ? `-${n}%` : "0%";
142
+ }
143
+ function N(o) {
144
+ const { documentModifier: e, product: t, priceEl: r, oldPriceEl: n, omnibusPriceEl: i, omnibusDiscountEl: c } = o;
145
+ let s = !1;
146
+ if (r && "querySelector" in r) {
147
+ const l = r.querySelector("strong"), u = E(t, "price");
148
+ S(e, l, u) && (s = !0);
149
+ }
150
+ if (n && "querySelector" in n) {
151
+ const l = n.querySelector("strong"), u = E(t, "original_price");
152
+ S(e, l, u) && (s = !0);
153
+ }
154
+ if (i && "querySelector" in i) {
155
+ const l = i.querySelector(".omnibus-price-value"), u = E(t, "original_price");
156
+ S(e, l, u) && (s = !0);
157
+ }
158
+ if (c && "querySelector" in c) {
159
+ const l = c.querySelector(".omnibus-discount-value"), u = x(t);
160
+ S(e, l, u) && (s = !0);
161
+ }
162
+ return s;
163
+ }
164
+ function B(o) {
165
+ const {
166
+ documentModifier: e,
167
+ product: t,
168
+ imageEl: r,
169
+ nameEl: n,
170
+ priceEl: i,
171
+ oldPriceEl: c,
172
+ omnibusPriceEl: s,
173
+ omnibusDiscountEl: l,
174
+ buttonEl: u
175
+ } = o;
176
+ let d = !1;
177
+ if (r && "querySelector" in r) {
178
+ const a = r.querySelector("img");
179
+ a && (e.modifyHtml(a).setAttribute("src", k(t.image_url)).setAttribute("alt", t.name), d = !0);
180
+ const p = r.querySelector("a");
181
+ p && (e.modifyHtml(p).setAttribute("href", t.url), d = !0);
182
+ }
183
+ if (n && "querySelector" in n) {
184
+ const a = n.querySelector("strong");
185
+ S(e, a, t.name) && (d = !0);
186
+ }
187
+ if (N({
188
+ documentModifier: e,
189
+ product: t,
190
+ priceEl: i,
191
+ oldPriceEl: c,
192
+ omnibusPriceEl: s,
193
+ omnibusDiscountEl: l
194
+ }) && (d = !0), u && "querySelector" in u) {
195
+ const a = u.querySelector("a.es-button") || u.querySelector("a");
196
+ a && (e.modifyHtml(a).setAttribute("href", t.url), d = !0);
197
+ }
198
+ return d;
199
+ }
200
+ function J(o) {
201
+ const { currentNode: e, documentModifier: t, products: r } = o;
202
+ if (!e || !("querySelectorAll" in e))
203
+ return !1;
204
+ const n = e.querySelectorAll(
205
+ `[esd-extension-block-id="${f.IMAGE}"]`
206
+ ), i = e.querySelectorAll(
207
+ `[esd-extension-block-id="${f.NAME}"]`
208
+ ), c = e.querySelectorAll(
209
+ `[esd-extension-block-id="${f.PRICE}"]`
210
+ ), s = e.querySelectorAll(
211
+ `[esd-extension-block-id="${f.OLD_PRICE}"]`
212
+ ), l = e.querySelectorAll(
213
+ `[esd-extension-block-id="${f.OMNIBUS_PRICE}"]`
214
+ ), u = e.querySelectorAll(
215
+ `[esd-extension-block-id="${f.OMNIBUS_DISCOUNT}"]`
216
+ ), d = e.querySelectorAll(
217
+ `[esd-extension-block-id="${f.BUTTON}"]`
218
+ );
219
+ if (n.length !== r.length)
220
+ return !1;
221
+ let a = !1;
222
+ return r.forEach((p, m) => {
223
+ const M = B({
224
+ documentModifier: t,
225
+ product: p,
226
+ imageEl: n[m] ?? null,
227
+ nameEl: i[m] ?? null,
228
+ priceEl: c[m] ?? null,
229
+ oldPriceEl: s[m] ?? null,
230
+ omnibusPriceEl: l[m] ?? null,
231
+ omnibusDiscountEl: u[m] ?? null,
232
+ buttonEl: d[m] ?? null
233
+ });
234
+ a = a || M;
235
+ }), a && t.apply(new g("Updated product content in-place")), !0;
236
+ }
237
+ function Q(o) {
238
+ const { currentNode: e, documentModifier: t } = o;
239
+ if (!e || !("querySelectorAll" in e))
240
+ return !1;
241
+ const n = A().recommendationProducts;
242
+ if (n.length === 0)
243
+ return !1;
244
+ const i = e.querySelectorAll(
245
+ `[esd-extension-block-id="${f.PRICE}"]`
246
+ ), c = e.querySelectorAll(
247
+ `[esd-extension-block-id="${f.OLD_PRICE}"]`
248
+ ), s = e.querySelectorAll(
249
+ `[esd-extension-block-id="${f.OMNIBUS_PRICE}"]`
250
+ ), l = e.querySelectorAll(
251
+ `[esd-extension-block-id="${f.OMNIBUS_DISCOUNT}"]`
252
+ );
253
+ let u = !1;
254
+ return n.forEach((d, a) => {
255
+ N({
256
+ documentModifier: t,
257
+ product: d,
258
+ priceEl: i[a] ?? null,
259
+ oldPriceEl: c[a] ?? null,
260
+ omnibusPriceEl: s[a] ?? null,
261
+ omnibusDiscountEl: l[a] ?? null
262
+ }) && (u = !0);
263
+ }), u && t.apply(new g("Updated price formatting in-place")), u;
264
+ }
265
+ function X(o) {
266
+ const { currentNode: e, documentModifier: t, currency: r } = o, n = b(e);
267
+ if (!n)
268
+ return;
269
+ const i = r.alignment === "before" ? "0" : "1", c = (s, l) => {
270
+ t.modifyHtml(n).setAttribute(s, l);
271
+ };
272
+ c(y.CURRENCY, r.code), c(y.SYMBOL, r.symbol), c(y.ALIGNMENT, i), c(y.THOUSAND_SEPARATOR, r.thousandSeparator), c(y.DECIMAL_SEPARATOR, r.decimalSeparator), c(y.DECIMAL_COUNT, r.decimalCount.toString()), t.apply(new g("Update currency attributes"));
273
+ }
274
+ export {
275
+ E as formatProductPrice,
276
+ b as getBlockElement,
277
+ D as getCardComposition,
278
+ q as getCurrentLayout,
279
+ H as reapplySpacing,
280
+ U as regenerateProductRows,
281
+ K as regenerateProductRowsWithStyles,
282
+ X as setCurrencyAttributes,
283
+ Q as updatePricesInPlace,
284
+ J as updateProductContentInPlace,
285
+ B as updateSingleProductContent
286
+ };
@@ -0,0 +1,46 @@
1
+ import { createPaddingsControl as n, createTextBackgroundColorControl as e, createTextFontFamilyControl as l, createTextStyleControl as C, createTextSizeControl as c, createTextColorControl as N, createTextAlignControl as a } 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 { NameTextTrimControl as i } from "./textTrim.js";
6
+ const m = a(
7
+ t.NAME_ALIGN,
8
+ o.NAME,
9
+ r
10
+ ), A = N(
11
+ t.NAME_COLOR,
12
+ o.NAME,
13
+ r
14
+ ), E = c(
15
+ t.NAME_SIZE,
16
+ o.NAME,
17
+ r
18
+ ), M = C(
19
+ t.NAME_STYLE,
20
+ o.NAME,
21
+ r
22
+ ), s = l(
23
+ t.NAME_FONT_FAMILY,
24
+ o.NAME,
25
+ r
26
+ ), d = e(
27
+ t.NAME_BACKGROUND,
28
+ o.NAME,
29
+ r
30
+ ), T = n(
31
+ t.NAME_PADDINGS,
32
+ o.NAME,
33
+ r
34
+ ), F = {
35
+ align: m,
36
+ color: A,
37
+ size: E,
38
+ style: M,
39
+ fontFamily: s,
40
+ background: d,
41
+ paddings: T,
42
+ textTrim: i
43
+ };
44
+ export {
45
+ F as NameControls
46
+ };
@@ -0,0 +1,76 @@
1
+ import { ModificationDescription as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as c } from "../../../common-control.js";
3
+ import { RecommendationBlockId as a } from "../../constants/blockIds.js";
4
+ import { RecommendationControlId as d } from "../../constants/controlIds.js";
5
+ import { CONTAINER_SELECTOR as m } from "../../constants/selectors.js";
6
+ const s = {
7
+ TEXT_TRIM_ENABLED: "textTrimEnabled"
8
+ }, r = "text-trim-enabled";
9
+ class p extends c {
10
+ getId() {
11
+ return d.NAME_TEXT_TRIM;
12
+ }
13
+ getTemplate() {
14
+ return `
15
+ <div class="name-text-trim-control-container">
16
+ ${this._GuTwoColumns([
17
+ this._GuLabel({ text: "Trim Long Text" }),
18
+ this._GuToggle(s.TEXT_TRIM_ENABLED)
19
+ ])}
20
+ </div>
21
+ `;
22
+ }
23
+ onRender() {
24
+ this._setFormValues(), this._listenToFormUpdates();
25
+ }
26
+ onTemplateNodeUpdated(t) {
27
+ super.onTemplateNodeUpdated(t), this._setFormValues();
28
+ }
29
+ _setFormValues() {
30
+ const t = this._getCurrentTrimState();
31
+ this.api.updateValues({
32
+ [s.TEXT_TRIM_ENABLED]: t
33
+ });
34
+ }
35
+ _getCurrentTrimState() {
36
+ if (!this.currentNode || !("hasClass" in this.currentNode))
37
+ return !1;
38
+ if (this.currentNode.hasClass(r))
39
+ return !0;
40
+ const t = this.currentNode.closest(m);
41
+ if (!t)
42
+ return !1;
43
+ const e = t.querySelector(
44
+ `[esd-extension-block-id="${a.NAME}"]`
45
+ );
46
+ return e && "hasClass" in e ? e.hasClass(r) : !1;
47
+ }
48
+ _onTextTrimChange(t) {
49
+ if (!this.currentNode || !("closest" in this.currentNode))
50
+ return;
51
+ const e = this.currentNode.closest(m);
52
+ if (!e || !("querySelectorAll" in e))
53
+ return;
54
+ const i = Array.from(
55
+ e.querySelectorAll(`[esd-extension-block-id="${a.NAME}"]`)
56
+ );
57
+ if (!i.length)
58
+ return;
59
+ const o = this.api.getDocumentModifier();
60
+ i.forEach((n) => {
61
+ t ? o.modifyHtml(n).setClass(r) : o.modifyHtml(n).removeClass(r);
62
+ }), o.apply(
63
+ new l(
64
+ t ? "Enable product name text trimming" : "Disable product name text trimming"
65
+ )
66
+ );
67
+ }
68
+ _listenToFormUpdates() {
69
+ this.api.onValueChanged(s.TEXT_TRIM_ENABLED, (t) => {
70
+ this._onTextTrimChange(t);
71
+ });
72
+ }
73
+ }
74
+ export {
75
+ p as NameTextTrimControl
76
+ };