@useinsider/guido 2.1.0-beta.42f5dfa → 2.1.0-beta.4bcb91b

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 (149) hide show
  1. package/README.md +3 -1
  2. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +14 -15
  3. package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
  4. package/dist/composables/useHtmlValidator.js +84 -106
  5. package/dist/composables/useRecommendation.js +21 -54
  6. package/dist/composables/useSave.js +16 -12
  7. package/dist/composables/useStripo.js +58 -54
  8. package/dist/composables/useStripoEventHandler.js +27 -12
  9. package/dist/composables/useSyncModuleExtractor.js +33 -0
  10. package/dist/config/compiler/recommendationCompilerRules.js +39 -45
  11. package/dist/config/migrator/recommendationMigrator.js +2 -2
  12. package/dist/enums/extensions/recommendationBlock.js +1 -1
  13. package/dist/enums/recommendation.js +15 -16
  14. package/dist/enums/unsubscribe.js +25 -21
  15. package/dist/extensions/Blocks/Recommendation/block.js +9 -130
  16. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +187 -0
  17. package/dist/extensions/Blocks/Recommendation/constants.js +13 -0
  18. package/dist/extensions/Blocks/Recommendation/control.js +336 -0
  19. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +68 -0
  20. package/dist/extensions/Blocks/Recommendation/controls/index.js +245 -0
  21. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +74 -0
  22. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscount/textAfter.js → omnibusDiscountTextAfterControl.js} +14 -16
  23. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscount/textBefore.js → omnibusDiscountTextBeforeControl.js} +14 -16
  24. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPrice/textAfter.js → omnibusPriceTextAfterControl.js} +14 -16
  25. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPrice/textBefore.js → omnibusPriceTextBeforeControl.js} +12 -14
  26. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +188 -0
  27. package/dist/extensions/Blocks/Recommendation/extension.js +17 -40
  28. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +3 -19
  29. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -13
  30. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +10 -21
  31. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +193 -230
  32. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +181 -0
  33. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +189 -0
  34. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +209 -0
  35. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
  36. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +15 -26
  37. package/dist/extensions/Blocks/controlFactories.js +93 -125
  38. package/dist/guido.css +1 -1
  39. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +169 -223
  40. package/dist/services/recommendationApi.js +9 -10
  41. package/dist/services/stripoApi.js +50 -14
  42. package/dist/services/templateLibraryApi.js +13 -16
  43. package/dist/src/@types/events.d.ts +34 -2
  44. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  45. package/dist/src/composables/useRecommendation.d.ts +0 -1
  46. package/dist/src/composables/useSyncModuleExtractor.d.ts +4 -0
  47. package/dist/src/enums/unsubscribe.d.ts +3 -0
  48. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -67
  49. package/dist/src/extensions/Blocks/Recommendation/{controls/cardComposition/index.d.ts → cardCompositionControl.d.ts} +3 -23
  50. package/dist/src/extensions/Blocks/Recommendation/{constants/controlIds.d.ts → constants.d.ts} +24 -0
  51. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +38 -0
  52. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +589 -21
  53. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +16 -0
  54. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +0 -9
  55. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +468 -131
  56. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +16 -0
  57. package/dist/src/extensions/Blocks/Recommendation/templates/{grid/migration.d.ts → migrationTemplate.d.ts} +4 -11
  58. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +52 -0
  59. package/dist/src/mock/api/settings.d.ts +2 -0
  60. package/dist/src/services/stripoApi.d.ts +5 -0
  61. package/dist/src/stores/editor.d.ts +23 -0
  62. package/dist/static/styles/components/notification.css.js +1 -0
  63. package/dist/static/styles/components/version-history.css.js +10 -2
  64. package/dist/static/styles/components/wide-panel.css.js +18 -2
  65. package/dist/static/styles/customEditorStyle.css.js +2 -25
  66. package/dist/stores/editor.js +2 -1
  67. package/dist/utils/pairProductVariables.js +56 -57
  68. package/dist/utils/templatePreparation.js +14 -15
  69. package/package.json +1 -1
  70. package/dist/config/compiler/utils/recommendationCompilerUtils.js +0 -116
  71. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +0 -4
  72. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +0 -4
  73. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +0 -65
  74. package/dist/extensions/Blocks/Recommendation/constants/layout.js +0 -20
  75. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +0 -19
  76. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +0 -64
  77. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +0 -80
  78. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +0 -232
  79. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +0 -19
  80. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +0 -92
  81. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +0 -102
  82. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +0 -209
  83. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +0 -52
  84. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +0 -217
  85. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +0 -70
  86. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +0 -110
  87. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +0 -67
  88. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +0 -286
  89. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +0 -46
  90. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +0 -108
  91. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +0 -44
  92. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +0 -48
  93. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +0 -48
  94. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +0 -44
  95. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +0 -222
  96. package/dist/extensions/Blocks/Recommendation/services/configService.js +0 -240
  97. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +0 -233
  98. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
  99. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +0 -69
  100. package/dist/extensions/Blocks/Recommendation/templates/index.js +0 -12
  101. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +0 -174
  102. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +0 -73
  103. package/dist/extensions/Blocks/Recommendation/templates/utils.js +0 -122
  104. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +0 -6
  105. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +0 -29
  106. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +0 -46
  107. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +0 -17
  108. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +0 -13
  109. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +0 -49
  110. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +0 -13
  111. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +0 -35
  112. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -31
  113. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +0 -143
  114. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +0 -31
  115. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +0 -35
  116. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +0 -37
  117. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +0 -29
  118. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +0 -52
  119. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +0 -22
  120. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -68
  121. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +0 -24
  122. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -42
  123. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +0 -23
  124. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -214
  125. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +0 -97
  126. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +0 -34
  127. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +0 -95
  128. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +0 -100
  129. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +0 -15
  130. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +0 -15
  131. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +0 -100
  132. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +0 -15
  133. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +0 -15
  134. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +0 -95
  135. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +0 -83
  136. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +0 -151
  137. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +0 -6
  138. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -20
  139. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +0 -33
  140. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +0 -39
  141. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +0 -8
  142. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +0 -25
  143. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +0 -18
  144. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +0 -57
  145. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +0 -7
  146. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -160
  147. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +0 -33
  148. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
  149. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +0 -77
@@ -1,70 +0,0 @@
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.patchCurrentBlockConfig({ language: e }));
60
- }
61
- _listenToFormUpdates() {
62
- this.api.onValueChanged(n.LOCALE, (e) => {
63
- this._onLocaleChange(e);
64
- });
65
- }
66
- }
67
- export {
68
- g as LOCALE_CONTROL_ID,
69
- C as LocaleControl
70
- };
@@ -1,110 +0,0 @@
1
- var d = Object.defineProperty;
2
- var a = (i, e, t) => e in i ? d(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 r } from "../../services/configService.js";
7
- import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
8
- import { getCurrentLayout as C, regenerateProductRowsWithStyles as p } from "./utils.js";
9
- import { useDebounceFn as m } from "../../../../../node_modules/@vueuse/shared/index.js";
10
- const l = "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", m(() => {
23
- this._regenerateProductRows();
24
- }, 500));
25
- }
26
- getId() {
27
- return l;
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 = r.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 u = (r.getConfig(this.currentNode).layout || C(this.currentNode)) === "grid";
64
- this.api.setVisibility(o.PRODUCT_IN_ROW, u), this.api.setVisibility(o.PRODUCT_IN_ROW_LABEL, u);
65
- }
66
- _onProductCountChange(t) {
67
- this.currentNode && (r.updateConfig(
68
- this.api,
69
- this.currentNode,
70
- { size: t },
71
- `Changed product count to ${t}`
72
- ), this.store.patchCurrentBlockConfig({ size: t }), this._debouncedRegenerateProductRows());
73
- }
74
- _onProductsInRowChange(t) {
75
- this.currentNode && (r.updateConfig(
76
- this.api,
77
- this.currentNode,
78
- { cardsInRow: t },
79
- `Changed products per row to ${t}`
80
- ), this.store.patchCurrentBlockConfig({ cardsInRow: t }), this._debouncedRegenerateProductRows());
81
- }
82
- _regenerateProductRows() {
83
- p({
84
- currentNode: this.currentNode,
85
- documentModifier: this.api.getDocumentModifier()
86
- });
87
- }
88
- _listenToFormUpdates() {
89
- this.api.onValueChanged(o.PRODUCT_COUNT, (t) => {
90
- this._onProductCountChange(t.toString());
91
- }), this.api.onValueChanged(o.PRODUCT_IN_ROW, (t) => {
92
- this._onProductsInRowChange(Number(t));
93
- });
94
- }
95
- /**
96
- * Subscribe to store changes to update visibility when layout changes
97
- * This is still needed because layout changes come from LayoutControl
98
- */
99
- _listenStateUpdates() {
100
- let t = this.store.recommendationConfigs.orientation;
101
- this.storeUnsubscription = this.store.$subscribe(() => {
102
- const s = this.store.recommendationConfigs.orientation;
103
- s !== t && (t = s, this._updateProductsInRowVisibility());
104
- });
105
- }
106
- }
107
- export {
108
- l as PRODUCT_LAYOUT_CONTROL_ID,
109
- I as ProductLayoutControl
110
- };
@@ -1,67 +0,0 @@
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 l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as f } from "../../../common-control.js";
6
- import { RecommendationConfigService as i } from "../../services/configService.js";
7
- import { useRecommendationExtensionStore as d } from "../../store/recommendation.js";
8
- const h = "recommendation-shuffle-control", s = {
9
- SHUFFLE_PRODUCTS: "shuffleProducts"
10
- };
11
- class g extends f {
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 h;
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
- l.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.patchCurrentBlockConfig({ shuffleProducts: e }));
57
- }
58
- _listenToFormUpdates() {
59
- this.api.onValueChanged(s.SHUFFLE_PRODUCTS, (e) => {
60
- this._onShuffleChange(!!e);
61
- });
62
- }
63
- }
64
- export {
65
- h as SHUFFLE_CONTROL_ID,
66
- g as ShuffleControl
67
- };
@@ -1,286 +0,0 @@
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
- };
@@ -1,46 +0,0 @@
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
- };
@@ -1,108 +0,0 @@
1
- import { ModificationDescription as a } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CommonControl as c } from "../../../common-control.js";
3
- import { RecommendationBlockId as l } from "../../constants/blockIds.js";
4
- import { RecommendationControlId as m } from "../../constants/controlIds.js";
5
- import { CONTAINER_SELECTOR as u } from "../../constants/selectors.js";
6
- const i = {
7
- TEXT_TRIM_ENABLED: "textTrimEnabled"
8
- }, o = "text-trim-enabled", d = `.${o}`, T = `.${o} p`, f = `.${o} { max-width: 0; }`, p = `.${o} p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; display: block; }`;
9
- class g extends c {
10
- getId() {
11
- return m.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(i.TEXT_TRIM_ENABLED)
19
- ])}
20
- </div>
21
- `;
22
- }
23
- onRender() {
24
- this._setFormValues(), this._listenToFormUpdates();
25
- }
26
- onTemplateNodeUpdated(e) {
27
- super.onTemplateNodeUpdated(e), this._setFormValues();
28
- }
29
- _setFormValues() {
30
- const e = this._getCurrentTrimState();
31
- this.api.updateValues({
32
- [i.TEXT_TRIM_ENABLED]: e
33
- });
34
- }
35
- _getCurrentTrimState() {
36
- if (!this.currentNode || !("hasClass" in this.currentNode))
37
- return !1;
38
- if (this.currentNode.hasClass(o))
39
- return !0;
40
- const e = this.currentNode.closest(u);
41
- if (!e)
42
- return !1;
43
- const t = e.querySelector(
44
- `[esd-extension-block-id="${l.NAME}"]`
45
- );
46
- return t && "hasClass" in t ? t.hasClass(o) : !1;
47
- }
48
- /**
49
- * Finds an existing CSS rule in the document stylesheet by exact query
50
- * @param query - The CSS query to search for (uses Stripo's CSS query syntax)
51
- * @returns The CSS rule node if found, undefined otherwise
52
- */
53
- _findCssRule(e) {
54
- const t = this.api.getDocumentRootCssNode();
55
- if (t)
56
- return t.querySelector(e);
57
- }
58
- /**
59
- * Finds the .text-trim-enabled p rule by searching all text-trim rules and comparing selectors
60
- * This is needed because Stripo's CSS query syntax interprets spaces as path separators
61
- * @returns true if the rule exists
62
- */
63
- _hasParagraphRule() {
64
- const e = this.api.getDocumentRootCssNode();
65
- return e ? e.querySelectorAll(`*${o}`).some((s) => "getSelector" in s && typeof s.getSelector == "function" ? s.getSelector() === T : !1) : !1;
66
- }
67
- /**
68
- * Ensures the text-trim CSS rules exist in the document stylesheet
69
- * Only adds rules if they don't already exist (prevents duplicates across multiple blocks)
70
- */
71
- _ensureCssRulesExist() {
72
- const e = this.api.getDocumentRootCssNode();
73
- if (!e)
74
- return;
75
- const t = this.api.getDocumentModifier();
76
- let s = !1;
77
- this._findCssRule(d) || (t.modifyCss(e).appendRule(f), s = !0), this._hasParagraphRule() || (t.modifyCss(e).appendRule(p), s = !0), s && t.apply(new a("Add text trim CSS rules"));
78
- }
79
- _onTextTrimChange(e) {
80
- if (!this.currentNode || !("closest" in this.currentNode))
81
- return;
82
- const t = this.currentNode.closest(u);
83
- if (!t || !("querySelectorAll" in t))
84
- return;
85
- const s = Array.from(
86
- t.querySelectorAll(`[esd-extension-block-id="${l.NAME}"]`)
87
- );
88
- if (!s.length)
89
- return;
90
- e && this._ensureCssRulesExist();
91
- const r = this.api.getDocumentModifier();
92
- s.forEach((n) => {
93
- e ? r.modifyHtml(n).setClass(o) : r.modifyHtml(n).removeClass(o);
94
- }), r.apply(
95
- new a(
96
- e ? "Enable product name text trimming" : "Disable product name text trimming"
97
- )
98
- );
99
- }
100
- _listenToFormUpdates() {
101
- this.api.onValueChanged(i.TEXT_TRIM_ENABLED, (e) => {
102
- this._onTextTrimChange(e);
103
- });
104
- }
105
- }
106
- export {
107
- g as NameTextTrimControl
108
- };