@useinsider/guido 3.2.0-beta.565bfaf → 3.2.0-beta.570fb6d
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/dist/@types/config/schemas.js +1 -1
- package/dist/@types/config/validator.js +27 -34
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +76 -81
- package/dist/components/organisms/base/Toaster.vue2.js +10 -11
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue2.js +12 -12
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue2.js +6 -6
- package/dist/components/organisms/email-preview/mobile-preview/InboxView.vue2.js +9 -15
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +31 -40
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +19 -20
- package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +11 -14
- package/dist/components/organisms/header/EditorActions.vue.js +11 -12
- package/dist/components/organisms/header/EditorActions.vue2.js +18 -22
- package/dist/components/organisms/header/HeaderWrapper.vue2.js +12 -15
- package/dist/components/organisms/header/LeftSlot.vue2.js +16 -19
- package/dist/components/organisms/header/MiddleSlot.vue2.js +14 -11
- package/dist/components/organisms/header/RightSlot.vue2.js +14 -17
- package/dist/components/organisms/onboarding/AMPOnboarding.vue.js +11 -12
- package/dist/components/organisms/onboarding/AMPOnboarding.vue2.js +20 -22
- package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +11 -12
- package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +38 -41
- package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +11 -12
- package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +38 -43
- package/dist/components/organisms/onboarding/NewVersionPopup.vue2.js +18 -21
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +27 -31
- package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +11 -12
- package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +27 -29
- package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue.js +11 -12
- package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue2.js +19 -21
- package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +8 -9
- package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.js +9 -10
- package/dist/composables/useActionsApi.js +37 -38
- package/dist/composables/useBlocksConfig.js +26 -26
- package/dist/composables/useFullStoryBridge.js +13 -0
- package/dist/composables/useHtmlCompiler.js +34 -26
- package/dist/composables/useHtmlValidator.js +101 -109
- package/dist/composables/useHttp.js +30 -30
- package/dist/composables/usePartner.js +1 -1
- package/dist/composables/useRecommendation.js +14 -15
- package/dist/composables/useSave.js +21 -22
- package/dist/composables/useStripo.js +47 -42
- package/dist/composables/useSyncModuleExtractor.js +31 -29
- package/dist/composables/useTimerClone.js +24 -25
- package/dist/composables/useTranslations.js +23 -16
- package/dist/composables/useValidation.js +7 -8
- package/dist/composables/validators/useLiquidValidator.js +13 -13
- package/dist/config/compiler/recommendationCompilerRules.js +72 -67
- package/dist/config/compiler/unsubscribeCompilerRules.js +38 -37
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +36 -34
- package/dist/config/migrator/checkboxMigrator.js +20 -21
- package/dist/config/migrator/couponBlockMigrator.js +18 -19
- package/dist/config/migrator/itemsBlockMigrator.js +87 -89
- package/dist/config/migrator/radioButtonMigrator.js +12 -13
- package/dist/config/migrator/recommendationMigrator.js +107 -110
- package/dist/config/migrator/unsubscribeMigrator.js +10 -11
- package/dist/enums/displayConditions.js +78 -82
- package/dist/enums/extensions/recommendationBlock.js +41 -95
- package/dist/enums/unsubscribe.js +35 -30
- package/dist/extensions/Blocks/Checkbox/control.js +23 -23
- package/dist/extensions/Blocks/Items/block.js +9 -9
- package/dist/extensions/Blocks/Items/controls/button/link.js +14 -14
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +89 -97
- package/dist/extensions/Blocks/Items/controls/image/link.js +14 -14
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +23 -24
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +13 -14
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +44 -47
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +38 -38
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +11 -11
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +38 -40
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +35 -35
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +155 -162
- package/dist/extensions/Blocks/Items/enums/productEnums.js +21 -14
- package/dist/extensions/Blocks/Items/template.js +210 -210
- package/dist/extensions/Blocks/RadioButton/control.js +15 -15
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/button/index.js +36 -36
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +128 -133
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +23 -20
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +99 -0
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +19 -20
- package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +4 -6
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +84 -90
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +18 -18
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +4 -4
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +35 -36
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +134 -135
- package/dist/extensions/Blocks/Recommendation/controls/name/index.js +24 -24
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +27 -57
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +24 -24
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +24 -24
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +4 -4
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +4 -4
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +24 -24
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +4 -4
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +4 -4
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +24 -24
- package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +14 -0
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +32 -32
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +18 -20
- package/dist/extensions/Blocks/Recommendation/extension.js +31 -32
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +25 -32
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +72 -69
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +22 -23
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +10 -10
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +10 -10
- package/dist/extensions/Blocks/Recommendation/templates/index.js +6 -6
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +24 -25
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +11 -11
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +45 -47
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
- package/dist/extensions/Blocks/Recommendation/validation/filterSchema.js +13 -16
- package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
- package/dist/extensions/Blocks/Unsubscribe/control.js +11 -13
- package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +16 -18
- package/dist/extensions/Blocks/common-control.js +25 -26
- package/dist/extensions/DynamicContent/dynamic-content.js +53 -58
- package/dist/guido.css +1 -1
- package/dist/library.js +11 -12
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +272 -167
- package/dist/node_modules/valibot/dist/index.js +122 -126
- package/dist/package.json.js +1 -1
- package/dist/services/recommendationApi.js +14 -17
- package/dist/services/templateLibraryApi.js +37 -38
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useActionsApi.d.ts +1 -1
- package/dist/src/composables/useFullStoryBridge.d.ts +11 -0
- package/dist/src/composables/useHtmlCompiler.d.ts +1 -2
- package/dist/src/composables/useTranslations.d.ts +1 -1
- package/dist/src/enums/displayConditions.d.ts +1 -5
- package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -5
- package/dist/src/enums/unsubscribe.d.ts +8 -8
- package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +3 -20
- package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +29 -0
- package/dist/src/stores/dynamic-content.d.ts +3 -3
- package/dist/static/styles/components/button.css.js +16 -9
- package/dist/static/styles/components/loader.css.js +4 -0
- package/dist/static/styles/components/narrow-panel.css.js +52 -0
- package/dist/stores/config.js +25 -81
- package/dist/stores/dynamic-content.js +6 -11
- package/dist/stores/onboarding.js +5 -5
- package/dist/stores/preview.js +6 -9
- package/dist/stores/unsubscribe.js +1 -4
- package/dist/utils/dateUtil.js +7 -10
- package/dist/utils/genericUtil.js +10 -13
- package/dist/utils/pairProductVariables.js +13 -14
- package/package.json +8 -5
- package/dist/node_modules/lodash-es/_DataView.js +0 -6
- package/dist/node_modules/lodash-es/_Hash.js +0 -20
- package/dist/node_modules/lodash-es/_ListCache.js +0 -20
- package/dist/node_modules/lodash-es/_Map.js +0 -6
- package/dist/node_modules/lodash-es/_MapCache.js +0 -20
- package/dist/node_modules/lodash-es/_Promise.js +0 -6
- package/dist/node_modules/lodash-es/_Set.js +0 -6
- package/dist/node_modules/lodash-es/_SetCache.js +0 -13
- package/dist/node_modules/lodash-es/_Stack.js +0 -18
- package/dist/node_modules/lodash-es/_Symbol.js +0 -5
- package/dist/node_modules/lodash-es/_Uint8Array.js +0 -5
- package/dist/node_modules/lodash-es/_WeakMap.js +0 -6
- package/dist/node_modules/lodash-es/_arrayFilter.js +0 -10
- package/dist/node_modules/lodash-es/_arrayLikeKeys.js +0 -20
- package/dist/node_modules/lodash-es/_arrayMap.js +0 -8
- package/dist/node_modules/lodash-es/_arrayPush.js +0 -8
- package/dist/node_modules/lodash-es/_arraySome.js +0 -9
- package/dist/node_modules/lodash-es/_assocIndexOf.js +0 -10
- package/dist/node_modules/lodash-es/_baseEach.js +0 -6
- package/dist/node_modules/lodash-es/_baseFlatten.js +0 -13
- package/dist/node_modules/lodash-es/_baseFor.js +0 -5
- package/dist/node_modules/lodash-es/_baseForOwn.js +0 -8
- package/dist/node_modules/lodash-es/_baseGet.js +0 -11
- package/dist/node_modules/lodash-es/_baseGetAllKeys.js +0 -9
- package/dist/node_modules/lodash-es/_baseGetTag.js +0 -10
- package/dist/node_modules/lodash-es/_baseHasIn.js +0 -6
- package/dist/node_modules/lodash-es/_baseIsArguments.js +0 -9
- package/dist/node_modules/lodash-es/_baseIsEqual.js +0 -8
- package/dist/node_modules/lodash-es/_baseIsEqualDeep.js +0 -32
- package/dist/node_modules/lodash-es/_baseIsMatch.js +0 -29
- package/dist/node_modules/lodash-es/_baseIsNative.js +0 -16
- package/dist/node_modules/lodash-es/_baseIsTypedArray.js +0 -12
- package/dist/node_modules/lodash-es/_baseIteratee.js +0 -11
- package/dist/node_modules/lodash-es/_baseKeys.js +0 -14
- package/dist/node_modules/lodash-es/_baseMap.js +0 -11
- package/dist/node_modules/lodash-es/_baseMatches.js +0 -12
- package/dist/node_modules/lodash-es/_baseMatchesProperty.js +0 -17
- package/dist/node_modules/lodash-es/_baseProperty.js +0 -8
- package/dist/node_modules/lodash-es/_basePropertyDeep.js +0 -9
- package/dist/node_modules/lodash-es/_baseRange.js +0 -9
- package/dist/node_modules/lodash-es/_baseTimes.js +0 -8
- package/dist/node_modules/lodash-es/_baseToString.js +0 -18
- package/dist/node_modules/lodash-es/_baseTrim.js +0 -8
- package/dist/node_modules/lodash-es/_baseUnary.js +0 -8
- package/dist/node_modules/lodash-es/_cacheHas.js +0 -6
- package/dist/node_modules/lodash-es/_castPath.js +0 -10
- package/dist/node_modules/lodash-es/_coreJsData.js +0 -5
- package/dist/node_modules/lodash-es/_createBaseEach.js +0 -15
- package/dist/node_modules/lodash-es/_createBaseFor.js +0 -13
- package/dist/node_modules/lodash-es/_createRange.js +0 -11
- package/dist/node_modules/lodash-es/_equalArrays.js +0 -40
- package/dist/node_modules/lodash-es/_equalByTag.js +0 -45
- package/dist/node_modules/lodash-es/_equalObjects.js +0 -36
- package/dist/node_modules/lodash-es/_freeGlobal.js +0 -4
- package/dist/node_modules/lodash-es/_getAllKeys.js +0 -9
- package/dist/node_modules/lodash-es/_getMapData.js +0 -8
- package/dist/node_modules/lodash-es/_getMatchData.js +0 -12
- package/dist/node_modules/lodash-es/_getNative.js +0 -9
- package/dist/node_modules/lodash-es/_getRawTag.js +0 -15
- package/dist/node_modules/lodash-es/_getSymbols.js +0 -10
- package/dist/node_modules/lodash-es/_getTag.js +0 -28
- package/dist/node_modules/lodash-es/_getValue.js +0 -6
- package/dist/node_modules/lodash-es/_hasPath.js +0 -19
- package/dist/node_modules/lodash-es/_hashClear.js +0 -7
- package/dist/node_modules/lodash-es/_hashDelete.js +0 -7
- package/dist/node_modules/lodash-es/_hashGet.js +0 -13
- package/dist/node_modules/lodash-es/_hashHas.js +0 -9
- package/dist/node_modules/lodash-es/_hashSet.js +0 -9
- package/dist/node_modules/lodash-es/_isFlattenable.js +0 -10
- package/dist/node_modules/lodash-es/_isIndex.js +0 -8
- package/dist/node_modules/lodash-es/_isIterateeCall.js +0 -13
- package/dist/node_modules/lodash-es/_isKey.js +0 -12
- package/dist/node_modules/lodash-es/_isKeyable.js +0 -7
- package/dist/node_modules/lodash-es/_isMasked.js +0 -11
- package/dist/node_modules/lodash-es/_isPrototype.js +0 -8
- package/dist/node_modules/lodash-es/_isStrictComparable.js +0 -7
- package/dist/node_modules/lodash-es/_listCacheClear.js +0 -6
- package/dist/node_modules/lodash-es/_listCacheDelete.js +0 -12
- package/dist/node_modules/lodash-es/_listCacheGet.js +0 -8
- package/dist/node_modules/lodash-es/_listCacheHas.js +0 -7
- package/dist/node_modules/lodash-es/_listCacheSet.js +0 -8
- package/dist/node_modules/lodash-es/_mapCacheClear.js +0 -13
- package/dist/node_modules/lodash-es/_mapCacheDelete.js +0 -8
- package/dist/node_modules/lodash-es/_mapCacheGet.js +0 -7
- package/dist/node_modules/lodash-es/_mapCacheHas.js +0 -7
- package/dist/node_modules/lodash-es/_mapCacheSet.js +0 -8
- package/dist/node_modules/lodash-es/_mapToArray.js +0 -9
- package/dist/node_modules/lodash-es/_matchesStrictComparable.js +0 -8
- package/dist/node_modules/lodash-es/_memoizeCapped.js +0 -11
- package/dist/node_modules/lodash-es/_nativeCreate.js +0 -5
- package/dist/node_modules/lodash-es/_nativeKeys.js +0 -5
- package/dist/node_modules/lodash-es/_nodeUtil.js +0 -11
- package/dist/node_modules/lodash-es/_objectToString.js +0 -7
- package/dist/node_modules/lodash-es/_overArg.js +0 -8
- package/dist/node_modules/lodash-es/_root.js +0 -5
- package/dist/node_modules/lodash-es/_setCacheAdd.js +0 -7
- package/dist/node_modules/lodash-es/_setCacheHas.js +0 -6
- package/dist/node_modules/lodash-es/_setToArray.js +0 -9
- package/dist/node_modules/lodash-es/_stackClear.js +0 -7
- package/dist/node_modules/lodash-es/_stackDelete.js +0 -7
- package/dist/node_modules/lodash-es/_stackGet.js +0 -6
- package/dist/node_modules/lodash-es/_stackHas.js +0 -6
- package/dist/node_modules/lodash-es/_stackSet.js +0 -17
- package/dist/node_modules/lodash-es/_stringToPath.js +0 -10
- package/dist/node_modules/lodash-es/_toKey.js +0 -10
- package/dist/node_modules/lodash-es/_toSource.js +0 -17
- package/dist/node_modules/lodash-es/_trimmedEndIndex.js +0 -9
- package/dist/node_modules/lodash-es/eq.js +0 -6
- package/dist/node_modules/lodash-es/flatMap.js +0 -8
- package/dist/node_modules/lodash-es/get.js +0 -8
- package/dist/node_modules/lodash-es/hasIn.js +0 -8
- package/dist/node_modules/lodash-es/identity.js +0 -6
- package/dist/node_modules/lodash-es/isArguments.js +0 -10
- package/dist/node_modules/lodash-es/isArray.js +0 -4
- package/dist/node_modules/lodash-es/isArrayLike.js +0 -8
- package/dist/node_modules/lodash-es/isBuffer.js +0 -6
- package/dist/node_modules/lodash-es/isFunction.js +0 -12
- package/dist/node_modules/lodash-es/isLength.js +0 -7
- package/dist/node_modules/lodash-es/isObject.js +0 -7
- package/dist/node_modules/lodash-es/isObjectLike.js +0 -6
- package/dist/node_modules/lodash-es/isSymbol.js +0 -9
- package/dist/node_modules/lodash-es/isTypedArray.js +0 -7
- package/dist/node_modules/lodash-es/keys.js +0 -9
- package/dist/node_modules/lodash-es/map.js +0 -11
- package/dist/node_modules/lodash-es/memoize.js +0 -18
- package/dist/node_modules/lodash-es/property.js +0 -10
- package/dist/node_modules/lodash-es/range.js +0 -5
- package/dist/node_modules/lodash-es/stubArray.js +0 -6
- package/dist/node_modules/lodash-es/stubFalse.js +0 -6
- package/dist/node_modules/lodash-es/toFinite.js +0 -14
- package/dist/node_modules/lodash-es/toNumber.js +0 -22
- package/dist/node_modules/lodash-es/toString.js +0 -7
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ModificationDescription as T } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as m } from "../../../common-control.js";
|
|
3
|
+
import { CSS_CLASS_TEXT_TRIM as o, ensureTextTrimCssRulesExist as l } from "../shared/textTrimCssRules.js";
|
|
4
|
+
import { RecommendationControlId as u } from "../../constants/controlIds.js";
|
|
5
|
+
import { BLOCK_ROOT_SELECTOR as c, ATTR_PRODUCT_ATTR as n } from "../../constants/selectors.js";
|
|
6
|
+
import { RecommendationBlockId as a } from "../../constants/blockIds.js";
|
|
7
|
+
const i = {
|
|
8
|
+
TEXT_TRIM_ENABLED: "customAttrTextTrimEnabled"
|
|
9
|
+
};
|
|
10
|
+
class g extends m {
|
|
11
|
+
getId() {
|
|
12
|
+
return u.CUSTOM_ATTR_TEXT_TRIM;
|
|
13
|
+
}
|
|
14
|
+
getTemplate() {
|
|
15
|
+
return `
|
|
16
|
+
<hr style="margin: 0; border: none; border-top: 1px solid #e0e0e0;" />
|
|
17
|
+
<div class="custom-attr-text-trim-control-container">
|
|
18
|
+
${this._GuTwoColumns([
|
|
19
|
+
this._GuLabel({ text: this.api.translate("Trim Long Text") }),
|
|
20
|
+
this._GuToggle(i.TEXT_TRIM_ENABLED)
|
|
21
|
+
])}
|
|
22
|
+
</div>
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
onRender() {
|
|
26
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
27
|
+
}
|
|
28
|
+
onTemplateNodeUpdated(t) {
|
|
29
|
+
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
30
|
+
}
|
|
31
|
+
// ========================================================================
|
|
32
|
+
// State Reading
|
|
33
|
+
// ========================================================================
|
|
34
|
+
_setFormValues() {
|
|
35
|
+
this.api.updateValues({
|
|
36
|
+
[i.TEXT_TRIM_ENABLED]: this._getCurrentTrimState()
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
_getCurrentTrimState() {
|
|
40
|
+
if (!this.currentNode || !("hasClass" in this.currentNode))
|
|
41
|
+
return !1;
|
|
42
|
+
if (this.currentNode.hasClass(o))
|
|
43
|
+
return !0;
|
|
44
|
+
const t = this._getTargetElements();
|
|
45
|
+
return t.length > 0 && "hasClass" in t[0] ? t[0].hasClass(o) : !1;
|
|
46
|
+
}
|
|
47
|
+
// ========================================================================
|
|
48
|
+
// Target Element Discovery (per-attribute scoping)
|
|
49
|
+
// ========================================================================
|
|
50
|
+
/**
|
|
51
|
+
* Finds all custom attribute elements of the same type as the current node.
|
|
52
|
+
*
|
|
53
|
+
* Similar to getCustomAttrTargetNodes in customAttribute/index.ts, but adapted
|
|
54
|
+
* for CommonControl lifecycle where currentNode is a class property (not a
|
|
55
|
+
* parameter from Stripo's getTargetNodes override).
|
|
56
|
+
*/
|
|
57
|
+
_getTargetElements() {
|
|
58
|
+
if (!this.currentNode || !("closest" in this.currentNode))
|
|
59
|
+
return [];
|
|
60
|
+
const t = this.currentNode.closest(c);
|
|
61
|
+
if (!t)
|
|
62
|
+
return [];
|
|
63
|
+
const e = "asElement" in this.currentNode ? this.currentNode.asElement().getAttribute(n) : null;
|
|
64
|
+
if (e) {
|
|
65
|
+
const s = `[esd-extension-block-id="${a.CUSTOM_ATTRIBUTE}"][${n}="${e}"]`;
|
|
66
|
+
return Array.from(t.querySelectorAll(s));
|
|
67
|
+
}
|
|
68
|
+
return Array.from(
|
|
69
|
+
t.querySelectorAll(
|
|
70
|
+
`[esd-extension-block-id="${a.CUSTOM_ATTRIBUTE}"]`
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
// ========================================================================
|
|
75
|
+
// Toggle Handler
|
|
76
|
+
// ========================================================================
|
|
77
|
+
_onTextTrimChange(t) {
|
|
78
|
+
const e = this._getTargetElements();
|
|
79
|
+
if (!e.length)
|
|
80
|
+
return;
|
|
81
|
+
t && l(this.api);
|
|
82
|
+
const r = this.api.getDocumentModifier();
|
|
83
|
+
e.forEach((s) => {
|
|
84
|
+
t ? r.modifyHtml(s).setClass(o) : r.modifyHtml(s).removeClass(o);
|
|
85
|
+
}), r.apply(
|
|
86
|
+
new T(
|
|
87
|
+
t ? "Enable custom attribute text trimming" : "Disable custom attribute text trimming"
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
_listenToFormUpdates() {
|
|
92
|
+
this.api.onValueChanged(i.TEXT_TRIM_ENABLED, (t) => {
|
|
93
|
+
this._onTextTrimChange(t);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
g as CustomAttributeTextTrimControl
|
|
99
|
+
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { createImageMarginsControl as m, createImageSizeControl as n } from "../../../controlFactories.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { BLOCK_ROOT_SELECTOR as o } from "../../constants/selectors.js";
|
|
3
|
+
import { RecommendationBlockId as r } from "../../constants/blockIds.js";
|
|
4
|
+
import { RecommendationControlId as t } from "../../constants/controlIds.js";
|
|
5
5
|
const e = n(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
t.IMAGE_SIZE,
|
|
7
|
+
r.IMAGE,
|
|
8
|
+
o
|
|
9
9
|
), i = m(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
t.IMAGE_MARGINS,
|
|
11
|
+
r.IMAGE,
|
|
12
|
+
o
|
|
13
13
|
), C = {
|
|
14
14
|
size: e,
|
|
15
15
|
margins: i
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var h = (
|
|
3
|
-
var a = (
|
|
4
|
-
import { UEAttr as
|
|
1
|
+
var l = Object.defineProperty;
|
|
2
|
+
var h = (o, i, t) => i in o ? l(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
|
|
3
|
+
var a = (o, i, t) => h(o, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
+
import { UEAttr as c } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as d } from "../../../common-control.js";
|
|
6
|
-
import { RecommendationConfigService as
|
|
6
|
+
import { RecommendationConfigService as r } from "../../services/configService.js";
|
|
7
7
|
import { useRecommendationExtensionStore as m } from "../../store/recommendation.js";
|
|
8
8
|
const g = "recommendation-algorithm-control", e = {
|
|
9
9
|
ALGORITHM: "strategy",
|
|
@@ -42,35 +42,34 @@ class T extends d {
|
|
|
42
42
|
this._initializeSelectItems(), this._setFormValues(), this._listenToFormUpdates();
|
|
43
43
|
}
|
|
44
44
|
onTemplateNodeUpdated(t) {
|
|
45
|
-
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
45
|
+
super.onTemplateNodeUpdated(t), this._initializeSelectItems(), this._setFormValues();
|
|
46
46
|
}
|
|
47
47
|
_setFormValues() {
|
|
48
|
-
const t =
|
|
48
|
+
const t = r.getConfig(this.currentNode);
|
|
49
49
|
this._setProductIdsVisibility(t.strategy), this.api.updateValues({
|
|
50
50
|
[e.ALGORITHM]: t.strategy,
|
|
51
51
|
[e.PRODUCT_IDS]: t.productIds.join(",")
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
_initializeSelectItems() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (t != null && t.length)
|
|
55
|
+
const t = this.store?.getActivePredictiveAlgorithms;
|
|
56
|
+
if (t?.length)
|
|
58
57
|
try {
|
|
59
58
|
this.api.setUIEAttribute(
|
|
60
59
|
e.ALGORITHM,
|
|
61
|
-
|
|
60
|
+
c.SELECTPICKER.items,
|
|
62
61
|
t
|
|
63
62
|
);
|
|
64
|
-
} catch (
|
|
65
|
-
console.warn("[AlgorithmControl] Failed to set algorithm options:",
|
|
63
|
+
} catch (s) {
|
|
64
|
+
console.warn("[AlgorithmControl] Failed to set algorithm options:", s);
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
_setProductIdsVisibility(t) {
|
|
69
|
-
const
|
|
70
|
-
this.api.setVisibility(e.PRODUCT_IDS,
|
|
68
|
+
const n = (t ?? r.getConfig(this.currentNode).strategy) === "manualMerchandising";
|
|
69
|
+
this.api.setVisibility(e.PRODUCT_IDS, n), this.api.setVisibility(`${e.PRODUCT_IDS}_label`, n);
|
|
71
70
|
}
|
|
72
71
|
_onAlgorithmChange(t) {
|
|
73
|
-
!this.currentNode ||
|
|
72
|
+
!this.currentNode || r.getConfig(this.currentNode).strategy === t || (r.updateConfig(
|
|
74
73
|
this.api,
|
|
75
74
|
this.currentNode,
|
|
76
75
|
{ strategy: t },
|
|
@@ -80,13 +79,13 @@ class T extends d {
|
|
|
80
79
|
_onProductIdsChange(t) {
|
|
81
80
|
if (!this.currentNode)
|
|
82
81
|
return;
|
|
83
|
-
const
|
|
84
|
-
|
|
82
|
+
const s = t.split(",").map((n) => n.trim()).filter(Boolean);
|
|
83
|
+
r.updateConfig(
|
|
85
84
|
this.api,
|
|
86
85
|
this.currentNode,
|
|
87
|
-
{ productIds:
|
|
86
|
+
{ productIds: s },
|
|
88
87
|
"Updated product IDs"
|
|
89
|
-
), this.store.patchCurrentBlockConfig({ productIds:
|
|
88
|
+
), this.store.patchCurrentBlockConfig({ productIds: s });
|
|
90
89
|
}
|
|
91
90
|
_listenToFormUpdates() {
|
|
92
91
|
this.api.onValueChanged(e.ALGORITHM, (t) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var n = Object.defineProperty;
|
|
2
|
-
var o = (
|
|
3
|
-
var r = (
|
|
2
|
+
var o = (e, t, i) => t in e ? n(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
|
+
var r = (e, t, i) => o(e, typeof t != "symbol" ? t + "" : t, i);
|
|
4
4
|
import { CommonControl as s } from "../../../common-control.js";
|
|
5
5
|
import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
|
|
6
6
|
const d = "recommendation-filters-control", a = {
|
|
@@ -35,15 +35,13 @@ class h extends s {
|
|
|
35
35
|
this._setupButtonListener();
|
|
36
36
|
}
|
|
37
37
|
onDestroy() {
|
|
38
|
-
|
|
39
|
-
(t = this.addFilterButton) == null || t.removeEventListener("click", this.addFilterListener);
|
|
38
|
+
this.addFilterButton?.removeEventListener("click", this.addFilterListener);
|
|
40
39
|
}
|
|
41
40
|
_onFilterSelectClick() {
|
|
42
41
|
this.store.openFilterDrawer();
|
|
43
42
|
}
|
|
44
43
|
_setupButtonListener() {
|
|
45
|
-
|
|
46
|
-
this.addFilterListener = this._onFilterSelectClick.bind(this), this.addFilterButton = this.getContainer().querySelector("#guido__btn-add-filter"), (t = this.addFilterButton) == null || t.addEventListener("click", this.addFilterListener);
|
|
44
|
+
this.addFilterListener = this._onFilterSelectClick.bind(this), this.addFilterButton = this.getContainer().querySelector("#guido__btn-add-filter"), this.addFilterButton?.addEventListener("click", this.addFilterListener);
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
47
|
export {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var f = Object.defineProperty;
|
|
2
|
-
var p = (d,
|
|
3
|
-
var
|
|
2
|
+
var p = (d, c, t) => c in d ? f(d, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[c] = t;
|
|
3
|
+
var i = (d, c, t) => p(d, typeof c != "symbol" ? c + "" : c, t);
|
|
4
4
|
import { CommonControl as g } from "../../../common-control.js";
|
|
5
|
-
import { DEFAULT_NODE_CONFIG as
|
|
5
|
+
import { DEFAULT_NODE_CONFIG as s } from "../../constants/defaultConfig.js";
|
|
6
6
|
import { RecommendationConfigService as h } from "../../services/configService.js";
|
|
7
7
|
import { useRecommendationExtensionStore as y } from "../../store/recommendation.js";
|
|
8
8
|
import { AlgorithmControl as R } from "./algorithm.js";
|
|
@@ -12,13 +12,13 @@ import { CURRENCY_CONTROL_ID as X } from "./currency.js";
|
|
|
12
12
|
import { FiltersControl as _ } from "./filters.js";
|
|
13
13
|
import { FILTERS_CONTROL_ID as tt } from "./filters.js";
|
|
14
14
|
import { LayoutOrientationControl as b } from "./layoutOrientation.js";
|
|
15
|
-
import { LAYOUT_ORIENTATION_CONTROL_ID as
|
|
15
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as et } from "./layoutOrientation.js";
|
|
16
16
|
import { LocaleControl as O } from "./locale.js";
|
|
17
17
|
import { LOCALE_CONTROL_ID as nt } from "./locale.js";
|
|
18
18
|
import { ProductCountControl as I } from "./productCount.js";
|
|
19
19
|
import { PRODUCT_COUNT_CONTROL_ID as st } from "./productCount.js";
|
|
20
20
|
import { ProductLayoutControl as T } from "./productLayout.js";
|
|
21
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
21
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as ct } from "./productLayout.js";
|
|
22
22
|
import { ShuffleControl as S } from "./shuffle.js";
|
|
23
23
|
import { SHUFFLE_CONTROL_ID as ut } from "./shuffle.js";
|
|
24
24
|
import { getBlockElement as L, updateProductContentInPlace as P, regenerateProductRowsWithStyles as D } from "./utils.js";
|
|
@@ -28,22 +28,22 @@ const k = "recommendation-id", E = "ui-elements-recommendation-block";
|
|
|
28
28
|
class H extends g {
|
|
29
29
|
constructor() {
|
|
30
30
|
super(...arguments);
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
i(this, "store", y());
|
|
32
|
+
i(this, "storeUnsubscription", () => {
|
|
33
33
|
});
|
|
34
34
|
// Sub-control instances for lifecycle management
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
i(this, "algorithmControl", null);
|
|
36
|
+
i(this, "localeControl", null);
|
|
37
|
+
i(this, "currencyControl", null);
|
|
38
|
+
i(this, "productCountControl", null);
|
|
39
|
+
i(this, "productLayoutControl", null);
|
|
40
|
+
i(this, "filtersControl", null);
|
|
41
|
+
i(this, "shuffleControl", null);
|
|
42
|
+
i(this, "layoutOrientationControl", null);
|
|
43
43
|
/**
|
|
44
44
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
i(this, "_debouncedFetchProducts", m(() => {
|
|
47
47
|
this.store.fetchRecommendationProducts();
|
|
48
48
|
}, 500));
|
|
49
49
|
/**
|
|
@@ -57,18 +57,18 @@ class H extends g {
|
|
|
57
57
|
* count. The store pads products to the configured size, so in-place only
|
|
58
58
|
* fails when the size actually changed.
|
|
59
59
|
*/
|
|
60
|
-
|
|
60
|
+
i(this, "_debouncedRegenerateWithProducts", m(() => {
|
|
61
61
|
const t = this.store.recommendationProducts;
|
|
62
62
|
if (!this.currentNode || !this.api)
|
|
63
63
|
return;
|
|
64
|
-
const
|
|
64
|
+
const o = this.api.getDocumentModifier();
|
|
65
65
|
P({
|
|
66
66
|
currentNode: this.currentNode,
|
|
67
|
-
documentModifier:
|
|
67
|
+
documentModifier: o,
|
|
68
68
|
products: t
|
|
69
69
|
}) || D({
|
|
70
70
|
currentNode: this.currentNode,
|
|
71
|
-
documentModifier:
|
|
71
|
+
documentModifier: o,
|
|
72
72
|
products: t
|
|
73
73
|
});
|
|
74
74
|
}, 100));
|
|
@@ -86,8 +86,8 @@ class H extends g {
|
|
|
86
86
|
this.filtersControl,
|
|
87
87
|
this.shuffleControl,
|
|
88
88
|
this.layoutOrientationControl
|
|
89
|
-
].forEach((
|
|
90
|
-
|
|
89
|
+
].forEach((o) => {
|
|
90
|
+
o.api = this.api;
|
|
91
91
|
}), `
|
|
92
92
|
<div class="recommendation-controls-container">
|
|
93
93
|
${this.layoutOrientationControl.getTemplate()}
|
|
@@ -102,19 +102,19 @@ class H extends g {
|
|
|
102
102
|
`;
|
|
103
103
|
}
|
|
104
104
|
async onRender() {
|
|
105
|
-
var e;
|
|
106
105
|
const t = this._getRecommendationIdFromNode(this.currentNode) ?? this.store.currentRecommendationId;
|
|
107
|
-
if (t !== null && this.store.setCurrentBlock(t), this._listenStateUpdates(), t !== null &&
|
|
106
|
+
if (t !== null && this.store.setCurrentBlock(t), this._listenStateUpdates(), t !== null && this.store.blockStates[t]?.isInitialized) {
|
|
108
107
|
this._initializeSubControls();
|
|
109
108
|
return;
|
|
110
109
|
}
|
|
111
110
|
await this._fetchBlockData(t), this._initializeSubControls();
|
|
112
111
|
}
|
|
113
112
|
onTemplateNodeUpdated(t) {
|
|
114
|
-
var r;
|
|
115
113
|
super.onTemplateNodeUpdated(t);
|
|
116
|
-
const
|
|
117
|
-
|
|
114
|
+
const o = this._getRecommendationIdFromNode(t);
|
|
115
|
+
o !== null && o !== this.store.currentRecommendationId && this.store.setCurrentBlock(o), o !== null && this._syncNodeConfigToStore(), o !== null && !this.store.blockStates[o]?.isInitialized && this._fetchBlockData(o).then(() => {
|
|
116
|
+
this._initializeSubControls();
|
|
117
|
+
}), [
|
|
118
118
|
this.layoutOrientationControl,
|
|
119
119
|
this.productCountControl,
|
|
120
120
|
this.algorithmControl,
|
|
@@ -123,9 +123,8 @@ class H extends g {
|
|
|
123
123
|
this.productLayoutControl,
|
|
124
124
|
this.filtersControl,
|
|
125
125
|
this.shuffleControl
|
|
126
|
-
].forEach((
|
|
127
|
-
|
|
128
|
-
n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
|
|
126
|
+
].forEach((r) => {
|
|
127
|
+
r?.api && (r.currentNode = t, r.onTemplateNodeUpdated?.(t));
|
|
129
128
|
});
|
|
130
129
|
}
|
|
131
130
|
onDestroy() {
|
|
@@ -138,10 +137,7 @@ class H extends g {
|
|
|
138
137
|
this.productLayoutControl,
|
|
139
138
|
this.filtersControl,
|
|
140
139
|
this.shuffleControl
|
|
141
|
-
].forEach((
|
|
142
|
-
var o;
|
|
143
|
-
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
144
|
-
});
|
|
140
|
+
].forEach((o) => o?.onDestroy?.());
|
|
145
141
|
}
|
|
146
142
|
/**
|
|
147
143
|
* Initialize all sub-controls with the shared API context
|
|
@@ -157,9 +153,8 @@ class H extends g {
|
|
|
157
153
|
this.productLayoutControl,
|
|
158
154
|
this.filtersControl,
|
|
159
155
|
this.shuffleControl
|
|
160
|
-
].forEach((
|
|
161
|
-
|
|
162
|
-
e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
|
|
156
|
+
].forEach((o) => {
|
|
157
|
+
o && (o.api = this.api, o.currentNode = this.currentNode, o.onRender?.());
|
|
163
158
|
});
|
|
164
159
|
}
|
|
165
160
|
/**
|
|
@@ -174,8 +169,7 @@ class H extends g {
|
|
|
174
169
|
* values are being prepared for the upcoming initial fetch.
|
|
175
170
|
*/
|
|
176
171
|
_syncNodeConfigToStore() {
|
|
177
|
-
|
|
178
|
-
const t = h.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
|
|
172
|
+
const t = h.getConfig(this.currentNode), o = this.store.currentRecommendationId, e = o !== null && this.store.blockStates[o]?.isInitialized;
|
|
179
173
|
this.store.patchCurrentBlockConfig({
|
|
180
174
|
strategy: t.strategy,
|
|
181
175
|
language: t.language,
|
|
@@ -184,7 +178,7 @@ class H extends g {
|
|
|
184
178
|
// Only sync filters from node config during initial load.
|
|
185
179
|
// After initialization, the Pinia store is the source of truth
|
|
186
180
|
// for filters (edited via the filter drawer).
|
|
187
|
-
...
|
|
181
|
+
...e ? {} : { filters: t.filters },
|
|
188
182
|
shuffleProducts: t.shuffleProducts,
|
|
189
183
|
currencySettings: {
|
|
190
184
|
name: t.currency.code,
|
|
@@ -210,13 +204,13 @@ class H extends g {
|
|
|
210
204
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
211
205
|
this.store.fetchRecommendationCreateData(),
|
|
212
206
|
this.store.fetchRecommendationFilters()
|
|
213
|
-
])).forEach((
|
|
214
|
-
|
|
207
|
+
])).forEach((e, r) => {
|
|
208
|
+
e.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][r]} failed`, e.reason);
|
|
215
209
|
}), this._applySmartDefaults();
|
|
216
210
|
try {
|
|
217
211
|
await this.store.fetchRecommendationProducts();
|
|
218
|
-
} catch (
|
|
219
|
-
console.warn("Recommendation block: fetchRecommendationProducts failed",
|
|
212
|
+
} catch (e) {
|
|
213
|
+
console.warn("Recommendation block: fetchRecommendationProducts failed", e);
|
|
220
214
|
}
|
|
221
215
|
}
|
|
222
216
|
/**
|
|
@@ -232,62 +226,62 @@ class H extends g {
|
|
|
232
226
|
_applySmartDefaults() {
|
|
233
227
|
if (!this.currentNode || !this.api)
|
|
234
228
|
return;
|
|
235
|
-
const t = h.getConfig(this.currentNode),
|
|
236
|
-
let
|
|
237
|
-
if (t.currency.code ===
|
|
238
|
-
const { currencyList:
|
|
239
|
-
|
|
240
|
-
(u) => u.value === `price.${
|
|
241
|
-
) || (
|
|
242
|
-
...
|
|
243
|
-
code:
|
|
244
|
-
symbol:
|
|
229
|
+
const t = h.getConfig(this.currentNode), o = {};
|
|
230
|
+
let e = null, r = null, l = null;
|
|
231
|
+
if (t.currency.code === s.currency.code) {
|
|
232
|
+
const { currencyList: n } = this.store;
|
|
233
|
+
n.length > 0 && (n.some(
|
|
234
|
+
(u) => u.value === `price.${s.currency.code}`
|
|
235
|
+
) || (e = n[0].value.replace("price.", ""), o.currency = {
|
|
236
|
+
...s.currency,
|
|
237
|
+
code: e,
|
|
238
|
+
symbol: e
|
|
245
239
|
}));
|
|
246
240
|
}
|
|
247
|
-
if (t.strategy ===
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
(u) => u.value ===
|
|
251
|
-
) || (r =
|
|
241
|
+
if (t.strategy === s.strategy) {
|
|
242
|
+
const n = this.store.getActivePredictiveAlgorithms;
|
|
243
|
+
n.length > 0 && (n.some(
|
|
244
|
+
(u) => u.value === s.strategy
|
|
245
|
+
) || (r = n[0].value, o.strategy = r));
|
|
252
246
|
}
|
|
253
|
-
if (t.language ===
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
(u) => u.value ===
|
|
257
|
-
) || (
|
|
247
|
+
if (t.language === s.language) {
|
|
248
|
+
const n = this.store.getLanguages;
|
|
249
|
+
n.length > 0 && (n.some(
|
|
250
|
+
(u) => u.value === s.language
|
|
251
|
+
) || (l = n[0].value, o.language = l));
|
|
258
252
|
}
|
|
259
|
-
!
|
|
253
|
+
!e && !r && !l || (h.updateConfig(
|
|
260
254
|
this.api,
|
|
261
255
|
this.currentNode,
|
|
262
|
-
|
|
256
|
+
o,
|
|
263
257
|
"Applied smart defaults"
|
|
264
258
|
), this.store.patchCurrentBlockConfig({
|
|
265
|
-
...
|
|
259
|
+
...e ? {
|
|
266
260
|
currencySettings: {
|
|
267
|
-
name:
|
|
268
|
-
value:
|
|
269
|
-
symbol:
|
|
270
|
-
alignment:
|
|
271
|
-
decimalCount:
|
|
272
|
-
decimalSeparator:
|
|
273
|
-
thousandSeparator:
|
|
261
|
+
name: e,
|
|
262
|
+
value: e,
|
|
263
|
+
symbol: e,
|
|
264
|
+
alignment: s.currency.alignment === "before" ? "0" : "1",
|
|
265
|
+
decimalCount: s.currency.decimalCount.toString(),
|
|
266
|
+
decimalSeparator: s.currency.decimalSeparator,
|
|
267
|
+
thousandSeparator: s.currency.thousandSeparator
|
|
274
268
|
}
|
|
275
269
|
} : {},
|
|
276
270
|
...r ? { strategy: r } : {},
|
|
277
|
-
...
|
|
271
|
+
...l ? { language: l } : {}
|
|
278
272
|
}, { triggerRefetch: !1 }));
|
|
279
273
|
}
|
|
280
274
|
/**
|
|
281
275
|
* Reads the recommendation-id attribute from the block element within the node
|
|
282
276
|
*/
|
|
283
277
|
_getRecommendationIdFromNode(t) {
|
|
284
|
-
const
|
|
285
|
-
if (!
|
|
278
|
+
const o = L(t);
|
|
279
|
+
if (!o || !("getAttribute" in o))
|
|
286
280
|
return null;
|
|
287
|
-
const
|
|
288
|
-
if (!
|
|
281
|
+
const e = o.getAttribute(k);
|
|
282
|
+
if (!e)
|
|
289
283
|
return null;
|
|
290
|
-
const r = parseInt(
|
|
284
|
+
const r = parseInt(e);
|
|
291
285
|
return Number.isNaN(r) ? null : r;
|
|
292
286
|
}
|
|
293
287
|
/**
|
|
@@ -305,17 +299,17 @@ class H extends g {
|
|
|
305
299
|
*/
|
|
306
300
|
_listenStateUpdates() {
|
|
307
301
|
const { store: t } = this;
|
|
308
|
-
let
|
|
302
|
+
let o = t.recommendationProducts, e = t.$state.configVersion, r = t.currentRecommendationId;
|
|
309
303
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
310
|
-
const
|
|
311
|
-
if (
|
|
312
|
-
r =
|
|
304
|
+
const l = t.currentRecommendationId;
|
|
305
|
+
if (l !== r) {
|
|
306
|
+
r = l, o = t.recommendationProducts, e = t.$state.configVersion;
|
|
313
307
|
return;
|
|
314
308
|
}
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
const
|
|
318
|
-
u && C && (
|
|
309
|
+
const n = t.$state.configVersion;
|
|
310
|
+
n !== e && (e = n, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
|
|
311
|
+
const a = t.recommendationProducts, u = a !== o, C = Array.isArray(a) && a.length > 0;
|
|
312
|
+
u && C && (o = a, this._debouncedRegenerateWithProducts());
|
|
319
313
|
});
|
|
320
314
|
}
|
|
321
315
|
/**
|
|
@@ -342,12 +336,12 @@ export {
|
|
|
342
336
|
N as CurrencyControl,
|
|
343
337
|
tt as FILTERS_CONTROL_ID,
|
|
344
338
|
_ as FiltersControl,
|
|
345
|
-
|
|
339
|
+
et as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
346
340
|
nt as LOCALE_CONTROL_ID,
|
|
347
341
|
b as LayoutOrientationControl,
|
|
348
342
|
O as LocaleControl,
|
|
349
343
|
st as PRODUCT_COUNT_CONTROL_ID,
|
|
350
|
-
|
|
344
|
+
ct as PRODUCT_LAYOUT_CONTROL_ID,
|
|
351
345
|
I as ProductCountControl,
|
|
352
346
|
T as ProductLayoutControl,
|
|
353
347
|
H as RecommendationBlockControl,
|
|
@@ -3,12 +3,12 @@ var p = (o, e, t) => e in o ? O(o, e, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var r = (o, e, t) => p(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as N } from "../../../common-control.js";
|
|
6
|
-
import { ATTR_DATA_CUSTOM_ATTRIBUTES as L } from "../../constants/selectors.js";
|
|
7
|
-
import { LAYOUT_OPTIONS as T, DEFAULT_MOBILE_ROW_SPACING as m, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as l, DEFAULT_COLUMN_SPACING as g } from "../../constants/layout.js";
|
|
8
|
-
import { DEFAULT_COMPOSITION as _ } from "../../constants/defaultConfig.js";
|
|
9
6
|
import { RecommendationConfigService as s } from "../../services/configService.js";
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
import { getCurrentLayout as
|
|
7
|
+
import { useRecommendationExtensionStore as L } from "../../store/recommendation.js";
|
|
8
|
+
import { getCurrentLayout as m, getBlockElement as T, regenerateProductRowsWithStyles as f } from "./utils.js";
|
|
9
|
+
import { LAYOUT_OPTIONS as I, DEFAULT_MOBILE_ROW_SPACING as d, DEFAULT_MOBILE_COLUMN_SPACING as l, DEFAULT_ROW_SPACING as g, DEFAULT_COLUMN_SPACING as _ } from "../../constants/layout.js";
|
|
10
|
+
import { DEFAULT_COMPOSITION as C } from "../../constants/defaultConfig.js";
|
|
11
|
+
import { ATTR_DATA_CUSTOM_ATTRIBUTES as S } from "../../constants/selectors.js";
|
|
12
12
|
const U = "recommendation-layout-orientation-control", A = "recommendationInfoBannerTest", a = {
|
|
13
13
|
LAYOUT: "layout"
|
|
14
14
|
}, y = "data-card-composition", i = {
|
|
@@ -21,7 +21,7 @@ const U = "recommendation-layout-orientation-control", A = "recommendationInfoBa
|
|
|
21
21
|
class Y extends N {
|
|
22
22
|
constructor() {
|
|
23
23
|
super(...arguments);
|
|
24
|
-
r(this, "store",
|
|
24
|
+
r(this, "store", L());
|
|
25
25
|
r(this, "isChangingLayout", !1);
|
|
26
26
|
}
|
|
27
27
|
getId() {
|
|
@@ -36,7 +36,7 @@ class Y extends N {
|
|
|
36
36
|
this._GuLabel({ text: this.api.translate("Layout Orientation") }),
|
|
37
37
|
this._GuRadioButton({
|
|
38
38
|
name: a.LAYOUT,
|
|
39
|
-
buttons:
|
|
39
|
+
buttons: I
|
|
40
40
|
})
|
|
41
41
|
])}
|
|
42
42
|
</div>
|
|
@@ -55,7 +55,7 @@ class Y extends N {
|
|
|
55
55
|
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
56
56
|
}
|
|
57
57
|
_setFormValues() {
|
|
58
|
-
const u = s.getConfig(this.currentNode).layout ||
|
|
58
|
+
const u = s.getConfig(this.currentNode).layout || m(this.currentNode);
|
|
59
59
|
this.api.updateValues({
|
|
60
60
|
[a.LAYOUT]: u
|
|
61
61
|
});
|
|
@@ -65,9 +65,9 @@ class Y extends N {
|
|
|
65
65
|
* Updates node config, data attribute and regenerates product rows
|
|
66
66
|
*/
|
|
67
67
|
_onLayoutChange(t) {
|
|
68
|
-
if (this.isChangingLayout || !this.currentNode || (s.getConfig(this.currentNode).layout ||
|
|
68
|
+
if (this.isChangingLayout || !this.currentNode || (s.getConfig(this.currentNode).layout || m(this.currentNode)) === t)
|
|
69
69
|
return;
|
|
70
|
-
const c =
|
|
70
|
+
const c = T(this.currentNode);
|
|
71
71
|
if (c) {
|
|
72
72
|
this.isChangingLayout = !0;
|
|
73
73
|
try {
|
|
@@ -76,15 +76,15 @@ class Y extends N {
|
|
|
76
76
|
this.currentNode,
|
|
77
77
|
{
|
|
78
78
|
layout: t,
|
|
79
|
-
columnSpacing:
|
|
80
|
-
rowSpacing:
|
|
81
|
-
mobileColumnSpacing:
|
|
82
|
-
mobileRowSpacing:
|
|
79
|
+
columnSpacing: _,
|
|
80
|
+
rowSpacing: g,
|
|
81
|
+
mobileColumnSpacing: l,
|
|
82
|
+
mobileRowSpacing: d
|
|
83
83
|
},
|
|
84
84
|
`Changed layout to ${t}`
|
|
85
85
|
), this.store.patchCurrentBlockConfig({ orientation: t });
|
|
86
|
-
const n = this.api.getDocumentModifier().modifyHtml(c).setAttribute(i.LAYOUT, t).setAttribute(i.COLUMN_SPACING,
|
|
87
|
-
t === "list" ? (n.setClass("es-m-p0"), n.setClass("ins-recommendation-list-layout")) : (n.removeClass("es-m-p0"), n.removeClass("ins-recommendation-list-layout")), n.setAttribute(y,
|
|
86
|
+
const n = this.api.getDocumentModifier().modifyHtml(c).setAttribute(i.LAYOUT, t).setAttribute(i.COLUMN_SPACING, _.toString()).setAttribute(i.ROW_SPACING, g.toString()).setAttribute(i.MOBILE_COLUMN_SPACING, l.toString()).setAttribute(i.MOBILE_ROW_SPACING, d.toString());
|
|
87
|
+
t === "list" ? (n.setClass("es-m-p0"), n.setClass("ins-recommendation-list-layout")) : (n.removeClass("es-m-p0"), n.removeClass("ins-recommendation-list-layout")), n.setAttribute(y, C.join(",")).setAttribute(S, "[]"), n.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t);
|
|
88
88
|
} finally {
|
|
89
89
|
this.isChangingLayout = !1;
|
|
90
90
|
}
|
|
@@ -96,11 +96,11 @@ class Y extends N {
|
|
|
96
96
|
* @param layout - The layout to use for regeneration (passed explicitly to avoid stale DOM reads)
|
|
97
97
|
*/
|
|
98
98
|
_regenerateProductRows(t) {
|
|
99
|
-
this.currentNode &&
|
|
99
|
+
this.currentNode && f({
|
|
100
100
|
currentNode: this.currentNode,
|
|
101
101
|
documentModifier: this.api.getDocumentModifier(),
|
|
102
102
|
layout: t,
|
|
103
|
-
composition:
|
|
103
|
+
composition: C
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
_listenToFormUpdates() {
|