@useinsider/guido 2.1.0-beta.e2d48fe → 2.1.0-beta.e4c3fa1
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.
- package/README.md +36 -0
- package/dist/@types/config/schemas.js +70 -65
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +69 -58
- package/dist/components/organisms/base/Toaster.vue.js +4 -4
- package/dist/components/organisms/base/Toaster.vue2.js +12 -9
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +15 -14
- package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
- package/dist/composables/useActionsApi.js +15 -13
- package/dist/composables/useBlocksConfig.js +26 -16
- package/dist/composables/useHtmlValidator.js +114 -104
- package/dist/composables/useRecommendation.js +54 -21
- package/dist/composables/useStripo.js +25 -23
- package/dist/composables/useVersionHistoryApi.js +1 -1
- package/dist/config/compiler/recommendationCompilerRules.js +45 -39
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +121 -0
- package/dist/config/i18n/en/index.js +11 -0
- package/dist/config/i18n/en/labels.json.js +7 -0
- package/dist/config/i18n/en/toasters.json.js +56 -0
- package/dist/config/i18n/en/tooltips.json.js +82 -0
- package/dist/config/i18n/index.js +7 -0
- package/dist/config/migrator/itemsBlockMigrator.js +127 -122
- package/dist/config/migrator/recommendationMigrator.js +2 -2
- package/dist/enums/defaults.js +8 -4
- package/dist/enums/extensions/recommendationBlock.js +1 -1
- package/dist/enums/recommendation.js +16 -15
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +29 -29
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +29 -29
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +31 -29
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +0 -1
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +29 -27
- package/dist/extensions/Blocks/Items/settingsPanel.js +10 -15
- package/dist/extensions/Blocks/Recommendation/block.js +133 -9
- package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +69 -0
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +24 -0
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +22 -0
- package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
- package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +102 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +102 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +207 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +52 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +321 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +70 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +168 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +67 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +361 -0
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +108 -0
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +14 -12
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +345 -0
- package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
- package/dist/extensions/Blocks/Recommendation/services/configService.js +240 -0
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +297 -209
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +228 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +66 -0
- package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +169 -0
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +134 -0
- package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +26 -15
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
- package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
- package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
- package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
- package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
- package/dist/extensions/Blocks/controlFactories.js +125 -93
- package/dist/extensions/ModulesTabIcons/extension.js +17 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +317 -193
- package/dist/services/recommendationApi.js +11 -8
- package/dist/services/stripoApi.js +20 -17
- package/dist/services/templateLibraryApi.js +16 -13
- package/dist/src/@types/config/schemas.d.ts +8 -0
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useRecommendation.d.ts +1 -0
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
- package/dist/src/config/i18n/en/index.d.ts +1 -0
- package/dist/src/config/i18n/index.d.ts +16 -0
- package/dist/src/enums/defaults.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +67 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +55 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +45 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +40 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
- package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
- package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +52 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +102 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +60 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +231 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +34 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +115 -0
- package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
- package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +139 -468
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → grid/migration.d.ts} +11 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +41 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +66 -0
- package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +174 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
- package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
- package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
- package/dist/src/stores/config.d.ts +36 -0
- package/dist/static/styles/components/notification.css.js +19 -0
- package/dist/static/styles/components/tools.css.js +6 -2
- package/dist/static/styles/components/version-history.css.js +10 -2
- package/dist/static/styles/components/wide-panel.css.js +18 -2
- package/dist/static/styles/customEditorStyle.css.js +35 -11
- package/dist/static/styles/variables.css.js +2 -0
- package/dist/static/templates/empty/index.html.js +74 -0
- package/dist/static/templates/empty/style.css.js +779 -0
- package/dist/stores/unsubscribe.js +37 -34
- package/dist/utils/pairProductVariables.js +57 -56
- package/dist/utils/templatePreparation.js +15 -14
- package/package.json +1 -1
- package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
- package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
- package/dist/extensions/Blocks/Recommendation/control.js +0 -336
- package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
- package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
- package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
- package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
- package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
- package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
- package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
- package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -38
- package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +0 -16
- package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
- package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
var G = Object.defineProperty;
|
|
2
|
+
var R = (u, c, t) => c in u ? G(u, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[c] = t;
|
|
3
|
+
var h = (u, c, t) => R(u, typeof c != "symbol" ? c + "" : c, t);
|
|
4
|
+
import { EditorStatePropertyType as y, PreviewDeviceMode as w, ModificationDescription as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as V } from "../../../common-control.js";
|
|
6
|
+
import { DESKTOP_CONTAINER_SELECTOR as m, MOBILE_CONTAINER_SELECTOR as E } from "../../constants/selectors.js";
|
|
7
|
+
import { SPACING_STEP as S, MAX_SPACING as _, MIN_SPACING as N, DEFAULT_COLUMN_SPACING as C, DEFAULT_ROW_SPACING as P } from "../../constants/layout.js";
|
|
8
|
+
import { RecommendationConfigService as p } from "../../services/configService.js";
|
|
9
|
+
import { useRecommendationExtensionStore as B } from "../../store/recommendation.js";
|
|
10
|
+
import { safeGetStyle as A, safeGetParent as U } from "../../utils/tagName.js";
|
|
11
|
+
import { getCurrentLayout as b, getBlockElement as x } from "../main/utils.js";
|
|
12
|
+
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
13
|
+
const W = "recommendation-spacing-control", i = {
|
|
14
|
+
COLUMN_SPACING: "columnSpacing",
|
|
15
|
+
COLUMN_SPACING_LABEL: "columnSpacingLabel",
|
|
16
|
+
ROW_SPACING: "rowSpacing",
|
|
17
|
+
ROW_SPACING_LABEL: "rowSpacingLabel",
|
|
18
|
+
MOBILE_COLUMN_SPACING: "mobileColumnSpacing",
|
|
19
|
+
MOBILE_COLUMN_SPACING_LABEL: "mobileColumnSpacingLabel",
|
|
20
|
+
MOBILE_ROW_SPACING: "mobileRowSpacing",
|
|
21
|
+
MOBILE_ROW_SPACING_LABEL: "mobileRowSpacingLabel"
|
|
22
|
+
}, O = {
|
|
23
|
+
COLUMN_SPACING: "data-column-spacing",
|
|
24
|
+
ROW_SPACING: "data-row-spacing",
|
|
25
|
+
MOBILE_COLUMN_SPACING: "data-mobile-column-spacing",
|
|
26
|
+
MOBILE_ROW_SPACING: "data-mobile-row-spacing"
|
|
27
|
+
};
|
|
28
|
+
function L(u, c) {
|
|
29
|
+
if (!u)
|
|
30
|
+
return c;
|
|
31
|
+
const t = parseFloat(u);
|
|
32
|
+
return Number.isNaN(t) ? c : t;
|
|
33
|
+
}
|
|
34
|
+
class X extends V {
|
|
35
|
+
constructor() {
|
|
36
|
+
super(...arguments);
|
|
37
|
+
h(this, "store", B());
|
|
38
|
+
h(this, "unsubscribeOrientation", null);
|
|
39
|
+
/**
|
|
40
|
+
* Debounced version of _onColumnSpacingChange
|
|
41
|
+
* Prevents excessive DOM updates when user rapidly adjusts the counter
|
|
42
|
+
*/
|
|
43
|
+
h(this, "_debouncedOnColumnSpacingChange", f((t) => {
|
|
44
|
+
this._onColumnSpacingChange(t);
|
|
45
|
+
}, 300));
|
|
46
|
+
/**
|
|
47
|
+
* Debounced version of _onRowSpacingChange
|
|
48
|
+
*/
|
|
49
|
+
h(this, "_debouncedOnRowSpacingChange", f((t) => {
|
|
50
|
+
this._onRowSpacingChange(t);
|
|
51
|
+
}, 300));
|
|
52
|
+
/**
|
|
53
|
+
* Debounced version of _onMobileColumnSpacingChange
|
|
54
|
+
*/
|
|
55
|
+
h(this, "_debouncedOnMobileColumnSpacingChange", f((t) => {
|
|
56
|
+
this._onMobileColumnSpacingChange(t);
|
|
57
|
+
}, 300));
|
|
58
|
+
/**
|
|
59
|
+
* Debounced version of _onMobileRowSpacingChange
|
|
60
|
+
*/
|
|
61
|
+
h(this, "_debouncedOnMobileRowSpacingChange", f((t) => {
|
|
62
|
+
this._onMobileRowSpacingChange(t);
|
|
63
|
+
}, 300));
|
|
64
|
+
}
|
|
65
|
+
getId() {
|
|
66
|
+
return W;
|
|
67
|
+
}
|
|
68
|
+
getTemplate() {
|
|
69
|
+
return `
|
|
70
|
+
<div class="spacing-control-container">
|
|
71
|
+
${this._GuTwoColumns([
|
|
72
|
+
this._GuLabel({ text: "Column Spacing on Desktop (px)", name: i.COLUMN_SPACING_LABEL }),
|
|
73
|
+
this._GuCounter({
|
|
74
|
+
name: i.COLUMN_SPACING,
|
|
75
|
+
minValue: N,
|
|
76
|
+
maxValue: _,
|
|
77
|
+
step: S
|
|
78
|
+
}),
|
|
79
|
+
this._GuLabel({ text: "Row Spacing on Desktop (px)", name: i.ROW_SPACING_LABEL }),
|
|
80
|
+
this._GuCounter({
|
|
81
|
+
name: i.ROW_SPACING,
|
|
82
|
+
minValue: N,
|
|
83
|
+
maxValue: _,
|
|
84
|
+
step: S
|
|
85
|
+
}),
|
|
86
|
+
this._GuLabel({
|
|
87
|
+
text: "Column Spacing on Mobile (px)",
|
|
88
|
+
name: i.MOBILE_COLUMN_SPACING_LABEL
|
|
89
|
+
}),
|
|
90
|
+
this._GuCounter({
|
|
91
|
+
name: i.MOBILE_COLUMN_SPACING,
|
|
92
|
+
minValue: N,
|
|
93
|
+
maxValue: _,
|
|
94
|
+
step: S
|
|
95
|
+
}),
|
|
96
|
+
this._GuLabel({ text: "Row Spacing on Mobile (px)", name: i.MOBILE_ROW_SPACING_LABEL }),
|
|
97
|
+
this._GuCounter({
|
|
98
|
+
name: i.MOBILE_ROW_SPACING,
|
|
99
|
+
minValue: N,
|
|
100
|
+
maxValue: _,
|
|
101
|
+
step: S
|
|
102
|
+
})
|
|
103
|
+
])}
|
|
104
|
+
</div>
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
onRender() {
|
|
108
|
+
this._setFormValues(), this._updateSpacingVisibility(), this._listenToFormUpdates(), this._subscribeToOrientationChanges(), this._subscribeToEditorModeChanges();
|
|
109
|
+
}
|
|
110
|
+
onTemplateNodeUpdated(t) {
|
|
111
|
+
super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateSpacingVisibility();
|
|
112
|
+
}
|
|
113
|
+
onDestroy() {
|
|
114
|
+
this.unsubscribeOrientation && (this.unsubscribeOrientation(), this.unsubscribeOrientation = null);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Checks if the editor is currently in mobile preview mode
|
|
118
|
+
* using Stripo's EditorStatePropertyType API.
|
|
119
|
+
*/
|
|
120
|
+
_isMobileMode() {
|
|
121
|
+
return this.api.getEditorState()[y.previewDeviceMode] === w.MOBILE;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Updates spacing control visibility based on layout orientation, editor mode,
|
|
125
|
+
* and products-per-row count.
|
|
126
|
+
* - List layout: hide column spacing (products are full-width)
|
|
127
|
+
* - Desktop mode: show desktop spacing, hide mobile spacing
|
|
128
|
+
* - Mobile mode: show mobile spacing, hide desktop spacing
|
|
129
|
+
* - 1 product per row: hide column spacing (no gap between single column)
|
|
130
|
+
*/
|
|
131
|
+
_updateSpacingVisibility() {
|
|
132
|
+
if (!this.api)
|
|
133
|
+
return;
|
|
134
|
+
const t = p.getConfig(this.currentNode), e = this.store.recommendationConfigs.orientation, o = (t.layout || e || b(this.currentNode)) === "grid", r = this._isMobileMode(), a = t.cardsInRow > 1, l = t.mobileCardsInRow > 1;
|
|
135
|
+
this.api.setVisibility(i.COLUMN_SPACING, o && !r && a), this.api.setVisibility(i.COLUMN_SPACING_LABEL, o && !r && a), this.api.setVisibility(i.ROW_SPACING, !r), this.api.setVisibility(i.ROW_SPACING_LABEL, !r), this.api.setVisibility(i.MOBILE_COLUMN_SPACING, o && r && l), this.api.setVisibility(i.MOBILE_COLUMN_SPACING_LABEL, o && r && l), this.api.setVisibility(i.MOBILE_ROW_SPACING, r), this.api.setVisibility(i.MOBILE_ROW_SPACING_LABEL, r);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Reads spacing values from node config first, falls back to DOM styles.
|
|
139
|
+
* DOM fallback is only used for legacy templates that lack node config.
|
|
140
|
+
*/
|
|
141
|
+
_setFormValues() {
|
|
142
|
+
if (!this.api)
|
|
143
|
+
return;
|
|
144
|
+
const t = p.hasConfig(this.currentNode), e = p.getConfig(this.currentNode), n = t ? e.columnSpacing : this._getStoredColumnSpacing(), o = t ? e.rowSpacing : this._getStoredRowSpacing();
|
|
145
|
+
this.api.updateValues({
|
|
146
|
+
[i.COLUMN_SPACING]: n,
|
|
147
|
+
[i.ROW_SPACING]: o,
|
|
148
|
+
[i.MOBILE_COLUMN_SPACING]: e.mobileColumnSpacing,
|
|
149
|
+
[i.MOBILE_ROW_SPACING]: e.mobileRowSpacing
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Gets stored column spacing from the first attribute row cell's padding.
|
|
154
|
+
* Scoped to the desktop container for accurate readings.
|
|
155
|
+
* For grid layout: cells inside .recommendation-attribute-row have padding applied.
|
|
156
|
+
* For list layout: the parent of .product-card-wrapper has the padding.
|
|
157
|
+
* The padding is applied as "0 {halfSpacing}px", so we extract and multiply by 2.
|
|
158
|
+
*/
|
|
159
|
+
_getStoredColumnSpacing() {
|
|
160
|
+
if (!this.currentNode)
|
|
161
|
+
return C;
|
|
162
|
+
const t = this.currentNode.querySelector(m) ?? this.currentNode;
|
|
163
|
+
if (b(this.currentNode) === "grid") {
|
|
164
|
+
const d = t.querySelector(".recommendation-attribute-row"), s = d == null ? void 0 : d.querySelector("td"), I = A(s, "padding");
|
|
165
|
+
if (!I)
|
|
166
|
+
return C;
|
|
167
|
+
const M = I.trim().split(/\s+/);
|
|
168
|
+
return M.length < 2 ? C : L(M[1], C / 2) * 2;
|
|
169
|
+
}
|
|
170
|
+
const n = t.querySelector(".product-card-wrapper"), o = U(n), r = A(o, "padding");
|
|
171
|
+
if (!r)
|
|
172
|
+
return C;
|
|
173
|
+
const a = r.trim().split(/\s+/);
|
|
174
|
+
return a.length < 2 ? C : L(a[1], C / 2) * 2;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Gets stored row spacing from the first spacer element's height style
|
|
178
|
+
* Scoped to the desktop container for accurate readings.
|
|
179
|
+
*/
|
|
180
|
+
_getStoredRowSpacing() {
|
|
181
|
+
if (!this.currentNode)
|
|
182
|
+
return P;
|
|
183
|
+
const e = (this.currentNode.querySelector(m) ?? this.currentNode).querySelector(".spacer"), n = A(e, "height");
|
|
184
|
+
return L(n, P);
|
|
185
|
+
}
|
|
186
|
+
// ========================================================================
|
|
187
|
+
// Desktop Spacing Handlers
|
|
188
|
+
// ========================================================================
|
|
189
|
+
/**
|
|
190
|
+
* Handles column spacing changes for desktop.
|
|
191
|
+
* Applies horizontal padding only to the desktop container elements.
|
|
192
|
+
*/
|
|
193
|
+
_onColumnSpacingChange(t) {
|
|
194
|
+
if (!this.currentNode)
|
|
195
|
+
return;
|
|
196
|
+
p.updateConfig(
|
|
197
|
+
this.api,
|
|
198
|
+
this.currentNode,
|
|
199
|
+
{ columnSpacing: t },
|
|
200
|
+
`Changed column spacing to ${t}px`
|
|
201
|
+
), this._storeDataAttribute(O.COLUMN_SPACING, t);
|
|
202
|
+
const n = p.getConfig(this.currentNode).layout || b(this.currentNode), o = this.api.getDocumentModifier(), a = `0 ${t / 2}px`, l = this.currentNode.querySelector(m);
|
|
203
|
+
l && (n === "grid" ? Array.from(
|
|
204
|
+
l.querySelectorAll(".attribute-cell")
|
|
205
|
+
).forEach((s) => {
|
|
206
|
+
o.modifyHtml(s).setStyle("padding", a);
|
|
207
|
+
}) : Array.from(
|
|
208
|
+
l.querySelectorAll(".product-card-wrapper")
|
|
209
|
+
).forEach((s) => {
|
|
210
|
+
"parent" in s && s.parent() && o.modifyHtml(s.parent()).setStyle("padding", a);
|
|
211
|
+
}), o.apply(new g(`Update column spacing to ${t}px`)));
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Handles row spacing changes for desktop.
|
|
215
|
+
* Applies height only to spacer elements in the desktop container.
|
|
216
|
+
*/
|
|
217
|
+
_onRowSpacingChange(t) {
|
|
218
|
+
if (!this.currentNode)
|
|
219
|
+
return;
|
|
220
|
+
p.updateConfig(
|
|
221
|
+
this.api,
|
|
222
|
+
this.currentNode,
|
|
223
|
+
{ rowSpacing: t },
|
|
224
|
+
`Changed row spacing to ${t}px`
|
|
225
|
+
), this._storeDataAttribute(O.ROW_SPACING, t);
|
|
226
|
+
const e = this.currentNode.querySelector(m);
|
|
227
|
+
if (!e)
|
|
228
|
+
return;
|
|
229
|
+
const n = Array.from(
|
|
230
|
+
e.querySelectorAll(".spacer")
|
|
231
|
+
);
|
|
232
|
+
if (!n.length)
|
|
233
|
+
return;
|
|
234
|
+
const o = this.api.getDocumentModifier(), r = `${t}px`;
|
|
235
|
+
n.forEach((a) => {
|
|
236
|
+
o.modifyHtml(a).setStyle("height", r);
|
|
237
|
+
}), o.apply(new g(`Update row spacing to ${t}px`));
|
|
238
|
+
}
|
|
239
|
+
// ========================================================================
|
|
240
|
+
// Mobile Spacing Handlers
|
|
241
|
+
// ========================================================================
|
|
242
|
+
/**
|
|
243
|
+
* Handles column spacing changes for mobile.
|
|
244
|
+
* Applies horizontal padding only to the mobile container elements.
|
|
245
|
+
*/
|
|
246
|
+
_onMobileColumnSpacingChange(t) {
|
|
247
|
+
if (!this.currentNode)
|
|
248
|
+
return;
|
|
249
|
+
p.updateConfig(
|
|
250
|
+
this.api,
|
|
251
|
+
this.currentNode,
|
|
252
|
+
{ mobileColumnSpacing: t },
|
|
253
|
+
`Changed mobile column spacing to ${t}px`
|
|
254
|
+
), this._storeDataAttribute(O.MOBILE_COLUMN_SPACING, t);
|
|
255
|
+
const n = p.getConfig(this.currentNode).layout || b(this.currentNode), o = this.api.getDocumentModifier(), a = `0 ${t / 2}px`, l = this.currentNode.querySelector(E);
|
|
256
|
+
l && (n === "grid" ? Array.from(
|
|
257
|
+
l.querySelectorAll(".attribute-cell")
|
|
258
|
+
).forEach((s) => {
|
|
259
|
+
o.modifyHtml(s).setStyle("padding", a);
|
|
260
|
+
}) : Array.from(
|
|
261
|
+
l.querySelectorAll(".product-card-wrapper")
|
|
262
|
+
).forEach((s) => {
|
|
263
|
+
"parent" in s && s.parent() && o.modifyHtml(s.parent()).setStyle("padding", a);
|
|
264
|
+
}), o.apply(new g(`Update mobile column spacing to ${t}px`)));
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Handles row spacing changes for mobile.
|
|
268
|
+
* Applies height only to spacer elements in the mobile container.
|
|
269
|
+
*/
|
|
270
|
+
_onMobileRowSpacingChange(t) {
|
|
271
|
+
if (!this.currentNode)
|
|
272
|
+
return;
|
|
273
|
+
p.updateConfig(
|
|
274
|
+
this.api,
|
|
275
|
+
this.currentNode,
|
|
276
|
+
{ mobileRowSpacing: t },
|
|
277
|
+
`Changed mobile row spacing to ${t}px`
|
|
278
|
+
), this._storeDataAttribute(O.MOBILE_ROW_SPACING, t);
|
|
279
|
+
const e = this.currentNode.querySelector(E);
|
|
280
|
+
if (!e)
|
|
281
|
+
return;
|
|
282
|
+
const n = Array.from(
|
|
283
|
+
e.querySelectorAll(".spacer")
|
|
284
|
+
);
|
|
285
|
+
if (!n.length)
|
|
286
|
+
return;
|
|
287
|
+
const o = this.api.getDocumentModifier(), r = `${t}px`;
|
|
288
|
+
n.forEach((a) => {
|
|
289
|
+
o.modifyHtml(a).setStyle("height", r);
|
|
290
|
+
}), o.apply(new g(`Update mobile row spacing to ${t}px`));
|
|
291
|
+
}
|
|
292
|
+
// ========================================================================
|
|
293
|
+
// Data Attribute Storage
|
|
294
|
+
// ========================================================================
|
|
295
|
+
/**
|
|
296
|
+
* Stores a spacing value as a data attribute on the block root element
|
|
297
|
+
*/
|
|
298
|
+
_storeDataAttribute(t, e) {
|
|
299
|
+
const n = x(this.currentNode);
|
|
300
|
+
n && this.api.getDocumentModifier().modifyHtml(n).setAttribute(t, e.toString()).apply(new g(`Store ${t}`));
|
|
301
|
+
}
|
|
302
|
+
// ========================================================================
|
|
303
|
+
// Event Listeners
|
|
304
|
+
// ========================================================================
|
|
305
|
+
_listenToFormUpdates() {
|
|
306
|
+
this.api.onValueChanged(i.COLUMN_SPACING, (t) => {
|
|
307
|
+
const e = parseInt(t);
|
|
308
|
+
Number.isNaN(e) || this._debouncedOnColumnSpacingChange(e);
|
|
309
|
+
}), this.api.onValueChanged(i.ROW_SPACING, (t) => {
|
|
310
|
+
const e = parseInt(t);
|
|
311
|
+
Number.isNaN(e) || this._debouncedOnRowSpacingChange(e);
|
|
312
|
+
}), this.api.onValueChanged(i.MOBILE_COLUMN_SPACING, (t) => {
|
|
313
|
+
const e = parseInt(t);
|
|
314
|
+
Number.isNaN(e) || this._debouncedOnMobileColumnSpacingChange(e);
|
|
315
|
+
}), this.api.onValueChanged(i.MOBILE_ROW_SPACING, (t) => {
|
|
316
|
+
const e = parseInt(t);
|
|
317
|
+
Number.isNaN(e) || this._debouncedOnMobileRowSpacingChange(e);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Subscribe to store orientation changes
|
|
322
|
+
* Updates spacing visibility when layout changes via the layout control
|
|
323
|
+
*/
|
|
324
|
+
_subscribeToOrientationChanges() {
|
|
325
|
+
this.unsubscribeOrientation && this.unsubscribeOrientation(), this.unsubscribeOrientation = this.store.$subscribe((t) => {
|
|
326
|
+
t.type === "patch object" && (this._updateSpacingVisibility(), this._setFormValues());
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Subscribes to editor preview mode changes via Stripo API.
|
|
331
|
+
* Toggles which spacing controls (desktop/mobile) are visible.
|
|
332
|
+
*/
|
|
333
|
+
_subscribeToEditorModeChanges() {
|
|
334
|
+
this.api.onEditorStatePropUpdated(
|
|
335
|
+
y.previewDeviceMode,
|
|
336
|
+
() => {
|
|
337
|
+
this._updateSpacingVisibility();
|
|
338
|
+
}
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
export {
|
|
343
|
+
W as SPACING_CONTROL_ID,
|
|
344
|
+
X as SpacingControl
|
|
345
|
+
};
|
|
@@ -1,19 +1,42 @@
|
|
|
1
|
-
import { ExtensionBuilder as
|
|
2
|
-
import { RecommendationBlock as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
1
|
+
import { ExtensionBuilder as r } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { RecommendationBlock as m } from "./block.js";
|
|
3
|
+
import { RecommendationBlockControl as n } from "./controls/main/index.js";
|
|
4
|
+
import "./store/recommendation.js";
|
|
5
|
+
import { NameControls as i } from "./controls/name/index.js";
|
|
6
|
+
import { PriceControls as e } from "./controls/price/index.js";
|
|
7
|
+
import { OldPriceControls as l } from "./controls/oldPrice/index.js";
|
|
8
|
+
import { OmnibusPriceControls as s } from "./controls/omnibusPrice/index.js";
|
|
9
|
+
import { OmnibusDiscountControls as a } from "./controls/omnibusDiscount/index.js";
|
|
10
|
+
import { ButtonControls as p } from "./controls/button/index.js";
|
|
11
|
+
import { ImageControls as c } from "./controls/image/index.js";
|
|
12
|
+
import { SpacingControl as C } from "./controls/spacing/index.js";
|
|
13
|
+
import { CardBackgroundColorControl as d } from "./controls/cardBackground/index.js";
|
|
14
|
+
import { LayoutControl as f } from "./controls/layout/index.js";
|
|
15
|
+
import { RecommendationCardCompositionControl as u } from "./controls/cardComposition/index.js";
|
|
16
|
+
import { RecommendationIconsRegistry as g } from "./iconsRegistry.js";
|
|
17
|
+
import R from "./recommendation.css.js";
|
|
18
|
+
import { SettingsPanel as y } from "./settingsPanel.js";
|
|
19
|
+
const B = [
|
|
20
|
+
i,
|
|
21
|
+
e,
|
|
22
|
+
l,
|
|
23
|
+
s,
|
|
24
|
+
a,
|
|
25
|
+
p,
|
|
26
|
+
c
|
|
27
|
+
], P = [
|
|
28
|
+
n,
|
|
29
|
+
d,
|
|
30
|
+
f,
|
|
31
|
+
C,
|
|
32
|
+
u
|
|
33
|
+
], b = [
|
|
34
|
+
...P,
|
|
35
|
+
...B.flatMap((o) => Object.values(o))
|
|
36
|
+
], F = b.reduce(
|
|
37
|
+
(o, t) => o.addControl(t),
|
|
38
|
+
new r().addBlock(m).withSettingsPanelRegistry(y)
|
|
39
|
+
).addStyles(R).withIconsRegistry(g).build();
|
|
17
40
|
export {
|
|
18
|
-
|
|
41
|
+
F as default
|
|
19
42
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IconsRegistry as
|
|
2
|
-
class
|
|
1
|
+
import { IconsRegistry as r } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
class o extends r {
|
|
3
3
|
registerIconsSvg(C) {
|
|
4
4
|
C["recommendation-icon"] = `
|
|
5
5
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
@@ -43,9 +43,25 @@ class n extends o {
|
|
|
43
43
|
3.40029 12.0082 3.25285 11.7656 3.15234C11.365 2.98638 11.0001 2.64849 11 2.21484V2Z"
|
|
44
44
|
fill="currentColor"/>
|
|
45
45
|
</svg>
|
|
46
|
+
`, C["grid-orientation"] = `
|
|
47
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
|
|
48
|
+
<rect x="1" y="1" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" fill="none"/>
|
|
49
|
+
<rect x="12" y="1" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" fill="none"/>
|
|
50
|
+
<rect x="1" y="12" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" fill="none"/>
|
|
51
|
+
<rect x="12" y="12" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" fill="none"/>
|
|
52
|
+
</svg>
|
|
53
|
+
`, C["list-orientation"] = `
|
|
54
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
|
|
55
|
+
<circle cx="3" cy="4" r="1" stroke="currentColor" stroke-width="1"/>
|
|
56
|
+
<rect x="7" y="3" width="11" height="2" rx="1"/>
|
|
57
|
+
<circle cx="3" cy="10" r="1" stroke="currentColor" stroke-width="1"/>
|
|
58
|
+
<rect x="7" y="9" width="11" height="2" rx="1"/>
|
|
59
|
+
<circle cx="3" cy="16" r="1" stroke="currentColor" stroke-width="1"/>
|
|
60
|
+
<rect x="7" y="15" width="11" height="2" rx="1"/>
|
|
61
|
+
</svg>
|
|
46
62
|
`;
|
|
47
63
|
}
|
|
48
64
|
}
|
|
49
65
|
export {
|
|
50
|
-
|
|
66
|
+
o as RecommendationIconsRegistry
|
|
51
67
|
};
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
const n = `/* Utils */
|
|
2
2
|
.es-180w { width: 180px; }
|
|
3
3
|
|
|
4
|
-
/* Recommendation Controls */
|
|
5
|
-
.recommendation-controls-container >
|
|
6
|
-
|
|
4
|
+
/* Recommendation Controls - Main settings panel separators */
|
|
5
|
+
.recommendation-controls-container > div {
|
|
6
|
+
border-bottom: 1px solid #e0e0e0;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.recommendation-controls-container >
|
|
9
|
+
.recommendation-controls-container > div:first-child {
|
|
10
10
|
padding-top: 0;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
.recommendation-controls-container > div:last-child {
|
|
14
|
+
border-bottom: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
.container:has(.recommendation-controls-container) {
|
|
14
18
|
padding: 0
|
|
15
19
|
}
|
|
20
|
+
|
|
21
|
+
/* Hide drag icon for list layout (ordering disabled) */
|
|
22
|
+
ue-orderable.orderable-disabled .droppable-icon {
|
|
23
|
+
display: none;
|
|
24
|
+
}
|
|
16
25
|
`;
|
|
17
26
|
export {
|
|
18
27
|
n as default
|