@useinsider/guido 3.4.2-beta.6886b92 → 3.5.0-beta.6fa034d
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 +2 -0
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +50 -48
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +2 -2
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +49 -49
- package/dist/composables/useActionsApi.js +9 -5
- package/dist/composables/useSave.js +13 -14
- package/dist/extensions/Blocks/Recommendation/block.js +142 -43
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +33 -14
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +24 -16
- package/dist/extensions/Blocks/Unsubscribe/block.js +133 -49
- package/dist/extensions/Blocks/Unsubscribe/template.js +8 -8
- package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +2 -1
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +145 -144
- package/dist/src/composables/useActionsApi.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +37 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/filterUtil.d.ts +2 -0
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +20 -1
- package/dist/src/extensions/Blocks/Unsubscribe/utils/constants.d.ts +1 -0
- package/dist/src/stores/config.test.d.ts +1 -0
- package/dist/src/vitest.setup.d.ts +0 -0
- package/dist/stores/config.js +24 -23
- package/dist/utils/templatePreparation.js +51 -43
- package/package.json +3 -2
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { BlockId as
|
|
5
|
-
import { getMigrationBannerHtml as
|
|
6
|
-
import { Block as R, BlockCompositionType as
|
|
7
|
-
import { regenerateMobileProductRows as
|
|
8
|
-
import { ensureMobileCssRulesExist as
|
|
9
|
-
import { RecommendationConfigService as
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
2
|
+
var y = (a, r, t) => r in a ? k(a, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[r] = t;
|
|
3
|
+
var d = (a, r, t) => y(a, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { BlockId as B } from "../../../enums/block.js";
|
|
5
|
+
import { getMigrationBannerHtml as D } from "../../../utils/migrationBannerHtml.js";
|
|
6
|
+
import { Block as R, BlockCompositionType as C, ModificationDescription as h } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
|
+
import { regenerateMobileProductRows as b } from "./controls/main/utils.js";
|
|
8
|
+
import { ensureMobileCssRulesExist as p, setMobileLayoutOptOut as f, hasMobileLayoutOptOut as A } from "./controls/mobileLayout/cssRules.js";
|
|
9
|
+
import { RecommendationConfigService as c } from "./services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as g } from "./store/recommendation.js";
|
|
11
11
|
import { getDefaultTemplate as E } from "./templates/grid/template.js";
|
|
12
|
-
const
|
|
12
|
+
const _ = B.Recommendation, m = "recommendation-block-v2", u = "recommendation-id";
|
|
13
13
|
let I = !1;
|
|
14
14
|
class q extends R {
|
|
15
15
|
constructor() {
|
|
@@ -18,16 +18,16 @@ class q extends R {
|
|
|
18
18
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
19
19
|
* This avoids generating a new (different) ID in onCreated().
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
d(this, "_pendingBlockId", null);
|
|
22
22
|
}
|
|
23
23
|
getId() {
|
|
24
|
-
return
|
|
24
|
+
return _;
|
|
25
25
|
}
|
|
26
26
|
getIcon() {
|
|
27
27
|
return "recommendation-icon";
|
|
28
28
|
}
|
|
29
29
|
getBlockCompositionType() {
|
|
30
|
-
return
|
|
30
|
+
return C.CONTAINER;
|
|
31
31
|
}
|
|
32
32
|
getName() {
|
|
33
33
|
return this.api.translate("Recommendation Block");
|
|
@@ -38,8 +38,8 @@ class q extends R {
|
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
getSettingsPanelTitleHtml() {
|
|
41
|
-
return
|
|
42
|
-
|
|
41
|
+
return D(
|
|
42
|
+
_,
|
|
43
43
|
this.api.translate("Recommendation Block"),
|
|
44
44
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
45
45
|
);
|
|
@@ -70,24 +70,32 @@ class q extends R {
|
|
|
70
70
|
*/
|
|
71
71
|
onCreated(t) {
|
|
72
72
|
const e = this._getRecommendationId(t);
|
|
73
|
-
if (e !== null && e > 0)
|
|
73
|
+
if (e !== null && e > 0) {
|
|
74
|
+
if (this._detectDuplicate(e)) {
|
|
75
|
+
this._handleDuplicate(t, e);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this._pendingBlockId === null && setTimeout(() => {
|
|
79
|
+
this._getBlockElement(t) && this._detectDuplicate(e) && this._handleDuplicate(t, e);
|
|
80
|
+
}, 0);
|
|
74
81
|
return;
|
|
82
|
+
}
|
|
75
83
|
const i = this._pendingBlockId ?? this._generateNextId();
|
|
76
84
|
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
77
|
-
const { config:
|
|
85
|
+
const { config: n, wasFreshDrop: o } = c.initializeConfig(
|
|
78
86
|
this.api,
|
|
79
87
|
t,
|
|
80
88
|
{ recommendationId: i }
|
|
81
|
-
),
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
89
|
+
), s = g();
|
|
90
|
+
if (s.setCurrentBlock(i), o) {
|
|
91
|
+
p(this.api);
|
|
92
|
+
const l = this._getBlockElement(t);
|
|
93
|
+
l && (f(this.api, l, !0), b({
|
|
86
94
|
currentNode: t,
|
|
87
95
|
documentModifier: this.api.getDocumentModifier()
|
|
88
96
|
}));
|
|
89
97
|
}
|
|
90
|
-
|
|
98
|
+
s.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
|
|
91
99
|
}
|
|
92
100
|
/**
|
|
93
101
|
* Called when the document changes or template is loaded
|
|
@@ -100,20 +108,20 @@ class q extends R {
|
|
|
100
108
|
if (!(!t || !("getNodeConfig" in t))) {
|
|
101
109
|
if (!this._getRecommendationId(t)) {
|
|
102
110
|
const e = this._generateNextId();
|
|
103
|
-
this._assignRecommendationId(t, e),
|
|
111
|
+
this._assignRecommendationId(t, e), c.hasConfig(t) && c.updateConfig(
|
|
104
112
|
this.api,
|
|
105
113
|
t,
|
|
106
114
|
{ recommendationId: e },
|
|
107
115
|
"Assign recommendation ID to legacy block"
|
|
108
116
|
);
|
|
109
117
|
}
|
|
110
|
-
|
|
118
|
+
this._healLingeringDuplicate(t), c.needsMigration(t) && this._migrateFromLegacy(t);
|
|
111
119
|
try {
|
|
112
|
-
I || (
|
|
113
|
-
const e =
|
|
120
|
+
I || (p(this.api), I = !0);
|
|
121
|
+
const e = c.getConfig(t), i = this._getBlockElement(t);
|
|
114
122
|
if (i) {
|
|
115
|
-
const
|
|
116
|
-
|
|
123
|
+
const n = !e.mobileLayoutEnabled;
|
|
124
|
+
A(i) !== n && f(this.api, i, n);
|
|
117
125
|
}
|
|
118
126
|
} catch {
|
|
119
127
|
}
|
|
@@ -127,7 +135,7 @@ class q extends R {
|
|
|
127
135
|
*/
|
|
128
136
|
onDelete(t) {
|
|
129
137
|
const e = this._getRecommendationId(t);
|
|
130
|
-
e &&
|
|
138
|
+
e && g().removeBlockState(e);
|
|
131
139
|
}
|
|
132
140
|
/**
|
|
133
141
|
* Generates the next unique recommendation ID by scanning all existing blocks
|
|
@@ -137,16 +145,107 @@ class q extends R {
|
|
|
137
145
|
let t = 0;
|
|
138
146
|
try {
|
|
139
147
|
const e = this.api.getDocumentRoot();
|
|
140
|
-
e && "querySelectorAll" in e && e.querySelectorAll(`.${
|
|
141
|
-
if ("getAttribute" in
|
|
142
|
-
const
|
|
143
|
-
|
|
148
|
+
e && "querySelectorAll" in e && e.querySelectorAll(`.${m}`).forEach((n) => {
|
|
149
|
+
if ("getAttribute" in n) {
|
|
150
|
+
const o = n.getAttribute(u), s = o ? parseInt(o) : 0;
|
|
151
|
+
s > t && (t = s);
|
|
144
152
|
}
|
|
145
153
|
});
|
|
146
154
|
} catch {
|
|
147
155
|
}
|
|
148
156
|
return t + 1;
|
|
149
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Heals a duplicate that slipped past the create-time `_detectDuplicate`
|
|
160
|
+
* scan (or that was persisted by an older template before SD-142352).
|
|
161
|
+
* When two blocks share a `recommendation-id`, the first occurrence in DOM
|
|
162
|
+
* order is treated as the source and any later sibling is reassigned a
|
|
163
|
+
* fresh id. The store entry and active-block focus are intentionally not
|
|
164
|
+
* touched here: each block's persisted `esd-ext-config` carries its own
|
|
165
|
+
* truth and the regular save-time hydration (`hydrateRecommendationStore`)
|
|
166
|
+
* will seed the new id from that. Skipping `setCurrentBlock` avoids
|
|
167
|
+
* yanking the user's current selection mid-edit when the heal fires from
|
|
168
|
+
* `onDocumentChanged`.
|
|
169
|
+
*/
|
|
170
|
+
_healLingeringDuplicate(t) {
|
|
171
|
+
const e = this._getRecommendationId(t);
|
|
172
|
+
if (!(e === null || e <= 0))
|
|
173
|
+
try {
|
|
174
|
+
const i = this.api.getDocumentRoot();
|
|
175
|
+
if (!i || !("querySelectorAll" in i))
|
|
176
|
+
return;
|
|
177
|
+
const n = i.querySelectorAll(
|
|
178
|
+
`.${m}[${u}="${e}"]`
|
|
179
|
+
);
|
|
180
|
+
if (n.length <= 1)
|
|
181
|
+
return;
|
|
182
|
+
const o = this._getBlockElement(t);
|
|
183
|
+
if (!o)
|
|
184
|
+
return;
|
|
185
|
+
let s = -1;
|
|
186
|
+
for (let l = 0; l < n.length; l++)
|
|
187
|
+
if (n[l] === o) {
|
|
188
|
+
s = l;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
if (s <= 0)
|
|
192
|
+
return;
|
|
193
|
+
this._reassignDuplicateId(t, e);
|
|
194
|
+
} catch {
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/** True when another block already holds the same id — Stripo's duplication signal. */
|
|
198
|
+
_detectDuplicate(t) {
|
|
199
|
+
try {
|
|
200
|
+
const e = this.api.getDocumentRoot();
|
|
201
|
+
if (e && "querySelectorAll" in e)
|
|
202
|
+
return e.querySelectorAll(
|
|
203
|
+
`.${m}[${u}="${t}"]`
|
|
204
|
+
).length > 1;
|
|
205
|
+
} catch {
|
|
206
|
+
}
|
|
207
|
+
return !1;
|
|
208
|
+
}
|
|
209
|
+
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
210
|
+
_handleDuplicate(t, e) {
|
|
211
|
+
const i = this._reassignDuplicateId(t, e), n = g();
|
|
212
|
+
n.cloneBlockState(e, i), n.setCurrentBlock(i);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
216
|
+
* `recommendation-id`, the instance class and the persisted node config to
|
|
217
|
+
* a fresh id. Returns the new id.
|
|
218
|
+
*
|
|
219
|
+
* Used by `_handleDuplicate` at create-time (which additionally clones the
|
|
220
|
+
* store entry and focuses the new block) and by `_healLingeringDuplicate`
|
|
221
|
+
* at document-change time (which intentionally skips store/focus side
|
|
222
|
+
* effects so older bug-affected templates can self-repair without
|
|
223
|
+
* disturbing the user's current selection).
|
|
224
|
+
*/
|
|
225
|
+
_reassignDuplicateId(t, e) {
|
|
226
|
+
const i = this._generateNextId(), n = this._getBlockElement(t);
|
|
227
|
+
return this._assignRecommendationId(t, i), n && this._reassignInstanceClass(n, e, i), c.hasConfig(t) && c.updateConfig(
|
|
228
|
+
this.api,
|
|
229
|
+
t,
|
|
230
|
+
{ recommendationId: i },
|
|
231
|
+
`Reassign recommendation ID on duplicate (was ${e})`
|
|
232
|
+
), i;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Rewrites `ins-recommendation-v3-block-{id}` on the clone — the instance
|
|
236
|
+
* class scopes per-block CSS rules in the editor and is also the key the
|
|
237
|
+
* mail render service reads to look up per-id campaign config, so leaving
|
|
238
|
+
* the source's class would both leak stylistic edits across blocks and
|
|
239
|
+
* cause the mail render to apply the source block's config to the clone.
|
|
240
|
+
*/
|
|
241
|
+
_reassignInstanceClass(t, e, i) {
|
|
242
|
+
if (!("getAttribute" in t))
|
|
243
|
+
return;
|
|
244
|
+
const n = `ins-recommendation-v3-block-${e}`, o = `ins-recommendation-v3-block-${i}`, s = this.api.getDocumentModifier();
|
|
245
|
+
s.modifyHtml(t).removeClass(n).setClass(o), s.apply(new h(
|
|
246
|
+
`Reassign recommendation instance class ${n} -> ${o}`
|
|
247
|
+
));
|
|
248
|
+
}
|
|
150
249
|
/**
|
|
151
250
|
* Assigns a recommendation-id attribute to the block element.
|
|
152
251
|
* The instance class (ins-recommendation-v3-block-{id}) is embedded in the template
|
|
@@ -157,8 +256,8 @@ class q extends R {
|
|
|
157
256
|
const i = this._getBlockElement(t);
|
|
158
257
|
if (!i)
|
|
159
258
|
return;
|
|
160
|
-
const
|
|
161
|
-
|
|
259
|
+
const n = this.api.getDocumentModifier();
|
|
260
|
+
n.modifyHtml(i).setAttribute(u, e.toString()), n.apply(new h(`Assign recommendation ID ${e}`));
|
|
162
261
|
}
|
|
163
262
|
/**
|
|
164
263
|
* Gets the recommendation-id from a block node
|
|
@@ -167,11 +266,11 @@ class q extends R {
|
|
|
167
266
|
const e = this._getBlockElement(t);
|
|
168
267
|
if (!e || !("getAttribute" in e))
|
|
169
268
|
return null;
|
|
170
|
-
const i = e.getAttribute(
|
|
269
|
+
const i = e.getAttribute(u);
|
|
171
270
|
if (!i)
|
|
172
271
|
return null;
|
|
173
|
-
const
|
|
174
|
-
return Number.isNaN(
|
|
272
|
+
const n = parseInt(i);
|
|
273
|
+
return Number.isNaN(n) ? null : n;
|
|
175
274
|
}
|
|
176
275
|
/**
|
|
177
276
|
* Gets the block element (the element with BLOCK_CLASS)
|
|
@@ -179,19 +278,19 @@ class q extends R {
|
|
|
179
278
|
_getBlockElement(t) {
|
|
180
279
|
if ("getAttribute" in t) {
|
|
181
280
|
const e = t.getAttribute("class");
|
|
182
|
-
if (e && e.includes(
|
|
281
|
+
if (e && e.includes(m))
|
|
183
282
|
return t;
|
|
184
283
|
}
|
|
185
|
-
return "querySelector" in t ? t.querySelector(`.${
|
|
284
|
+
return "querySelector" in t ? t.querySelector(`.${m}`) ?? null : null;
|
|
186
285
|
}
|
|
187
286
|
/**
|
|
188
287
|
* Migrate configuration from legacy format
|
|
189
288
|
*/
|
|
190
289
|
_migrateFromLegacy(t) {
|
|
191
|
-
|
|
290
|
+
c.migrateFromDataAttributes(this.api, t);
|
|
192
291
|
}
|
|
193
292
|
}
|
|
194
293
|
export {
|
|
195
|
-
|
|
294
|
+
_ as BLOCK_ID,
|
|
196
295
|
q as RecommendationBlock
|
|
197
296
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { getRecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as
|
|
2
|
-
import { useRecommendationApi as
|
|
1
|
+
import { getRecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as C } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { useRecommendationApi as y } from "../../../../services/recommendationApi.js";
|
|
3
3
|
import { useConfigStore as G } from "../../../../stores/config.js";
|
|
4
4
|
import { defineStore as P } from "pinia";
|
|
5
5
|
import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
|
|
6
6
|
import { EXCLUDED_ALGORITHM_IDS as D } from "../constants/defaultConfig.js";
|
|
7
7
|
import { getDefaultProducts as S } from "../templates/utils.js";
|
|
8
8
|
import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
|
|
9
|
-
import { isFilterValid as
|
|
10
|
-
import { isConfigValid as
|
|
11
|
-
const h =
|
|
9
|
+
import { isFilterValid as v } from "../validation/filterSchema.js";
|
|
10
|
+
import { isConfigValid as w } from "../validation/requiredFields.js";
|
|
11
|
+
const h = y();
|
|
12
12
|
let m = null, u = null, d = null;
|
|
13
|
-
function
|
|
13
|
+
function I() {
|
|
14
14
|
return {
|
|
15
15
|
cardsInRow: F,
|
|
16
16
|
currencySettings: {
|
|
@@ -38,9 +38,9 @@ function k() {
|
|
|
38
38
|
customAttributes: []
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function k() {
|
|
42
42
|
return {
|
|
43
|
-
recommendationConfigs:
|
|
43
|
+
recommendationConfigs: I(),
|
|
44
44
|
recommendationProducts: [],
|
|
45
45
|
filterStatus: !1,
|
|
46
46
|
filterSelectionDrawerStatus: !1,
|
|
@@ -69,7 +69,7 @@ const N = () => ({
|
|
|
69
69
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
70
70
|
*/
|
|
71
71
|
recommendationConfigs(t) {
|
|
72
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs :
|
|
72
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : I();
|
|
73
73
|
},
|
|
74
74
|
/**
|
|
75
75
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
@@ -133,7 +133,7 @@ const N = () => ({
|
|
|
133
133
|
getFilterList() {
|
|
134
134
|
return Object.values(this.filterList).map((t) => {
|
|
135
135
|
let e;
|
|
136
|
-
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` :
|
|
136
|
+
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : C.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
|
|
137
137
|
text: t.displayName,
|
|
138
138
|
value: e,
|
|
139
139
|
type: t.attributeType
|
|
@@ -155,7 +155,7 @@ const N = () => ({
|
|
|
155
155
|
setCurrentBlock(t) {
|
|
156
156
|
this.blockStates[t] || (this.blockStates = {
|
|
157
157
|
...this.blockStates,
|
|
158
|
-
[t]:
|
|
158
|
+
[t]: k()
|
|
159
159
|
}), this.currentRecommendationId = t;
|
|
160
160
|
},
|
|
161
161
|
/**
|
|
@@ -174,6 +174,25 @@ const N = () => ({
|
|
|
174
174
|
this.currentRecommendationId = n.length > 0 ? n[0] : null;
|
|
175
175
|
}
|
|
176
176
|
},
|
|
177
|
+
/**
|
|
178
|
+
* Deep-clones a block's state and mirrors its campaign URL under a new id.
|
|
179
|
+
* Invoked from `onCreated` when a duplicate is detected (SD-142352).
|
|
180
|
+
*/
|
|
181
|
+
cloneBlockState(t, e) {
|
|
182
|
+
const r = this.blockStates[t];
|
|
183
|
+
if (r) {
|
|
184
|
+
const o = structuredClone(r);
|
|
185
|
+
o.recommendationConfigs.id = e, this.blockStates = {
|
|
186
|
+
...this.blockStates,
|
|
187
|
+
[e]: o
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
const n = t.toString(), c = e.toString(), i = this.recommendationCampaignUrls[n];
|
|
191
|
+
i && (this.recommendationCampaignUrls = {
|
|
192
|
+
...this.recommendationCampaignUrls,
|
|
193
|
+
[c]: i
|
|
194
|
+
});
|
|
195
|
+
},
|
|
177
196
|
/**
|
|
178
197
|
* Marks a block as initialized (initial API data has been fetched).
|
|
179
198
|
* Automatically cleaned up when removeBlockState deletes the block entry.
|
|
@@ -204,7 +223,7 @@ const N = () => ({
|
|
|
204
223
|
decimalCount: String(e.currencyDecimalCount),
|
|
205
224
|
decimalSeparator: r(e.currencyDecimalSeparator, ","),
|
|
206
225
|
thousandSeparator: r(e.currencyThousandSeparator, ".")
|
|
207
|
-
}, c = !this.blockStates[t], i = c ?
|
|
226
|
+
}, c = !this.blockStates[t], i = c ? k() : this.blockStates[t];
|
|
208
227
|
i.recommendationConfigs = {
|
|
209
228
|
...i.recommendationConfigs,
|
|
210
229
|
strategy: e.strategy,
|
|
@@ -359,7 +378,7 @@ const N = () => ({
|
|
|
359
378
|
const n = [...e.recommendationConfigs.filters];
|
|
360
379
|
n[r] = {
|
|
361
380
|
...t,
|
|
362
|
-
isValid:
|
|
381
|
+
isValid: v(t)
|
|
363
382
|
}, e.recommendationConfigs.filters = n;
|
|
364
383
|
}
|
|
365
384
|
},
|
|
@@ -405,7 +424,7 @@ const N = () => ({
|
|
|
405
424
|
* every block's recommendationConfigs across user edits.
|
|
406
425
|
*/
|
|
407
426
|
hasInvalidBlock() {
|
|
408
|
-
return Object.values(this.blockStates).some((t) => !
|
|
427
|
+
return Object.values(this.blockStates).some((t) => !w(t.recommendationConfigs, this));
|
|
409
428
|
},
|
|
410
429
|
// ====================================================================
|
|
411
430
|
// Per-Block Product Fetching
|
|
@@ -9,36 +9,44 @@ function m(t) {
|
|
|
9
9
|
function f(t) {
|
|
10
10
|
return t.split(",").filter(Boolean).map(m);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function G(t) {
|
|
13
|
+
return t.map(encodeURIComponent).join(",");
|
|
14
|
+
}
|
|
15
|
+
function Q(t) {
|
|
16
|
+
return t.trim().length > 0;
|
|
17
|
+
}
|
|
18
|
+
function d(t) {
|
|
13
19
|
if (t.length === 0)
|
|
14
20
|
return "";
|
|
15
21
|
const o = t.sort((r, e) => r.filterNumber - e.filterNumber), u = o.map((r) => {
|
|
16
|
-
const e = r.operator === l, a = e ? "=" : r.operator,
|
|
17
|
-
return `[${r.attribute}][${encodeURIComponent(a)}][${
|
|
18
|
-
}), [
|
|
19
|
-
let n =
|
|
20
|
-
for (let r = 0; r <
|
|
22
|
+
const e = r.operator === l, a = e ? "=" : r.operator, s = e ? f(r.value).join(l) : r.value;
|
|
23
|
+
return `[${r.attribute}][${encodeURIComponent(a)}][${s}]`;
|
|
24
|
+
}), [p, ...i] = u;
|
|
25
|
+
let n = p;
|
|
26
|
+
for (let r = 0; r < i.length; r++) {
|
|
21
27
|
const e = o[r].innerGroupOperator;
|
|
22
|
-
n += `${e}${
|
|
28
|
+
n += `${e}${i[r]}`;
|
|
23
29
|
}
|
|
24
30
|
return `(${n})`;
|
|
25
31
|
}
|
|
26
|
-
function
|
|
32
|
+
function F(t) {
|
|
27
33
|
if (!t || t.length === 0)
|
|
28
34
|
return "";
|
|
29
|
-
const o = t.reduce((r, e) => (r[e.filterGroup] || (r[e.filterGroup] = []), r[e.filterGroup].push(e), r), {}), u = Object.keys(o).map(Number).sort((r, e) => r - e),
|
|
35
|
+
const o = t.reduce((r, e) => (r[e.filterGroup] || (r[e.filterGroup] = []), r[e.filterGroup].push(e), r), {}), u = Object.keys(o).map(Number).sort((r, e) => r - e), p = u.map((r) => {
|
|
30
36
|
const e = o[r];
|
|
31
|
-
return
|
|
32
|
-
}), [
|
|
33
|
-
let
|
|
37
|
+
return d(e);
|
|
38
|
+
}), [i, ...n] = p;
|
|
39
|
+
let c = i;
|
|
34
40
|
for (let r = 0; r < n.length; r++) {
|
|
35
|
-
const e = u[r + 1],
|
|
36
|
-
|
|
41
|
+
const e = u[r + 1], s = o[e][0].outerGroupOperator;
|
|
42
|
+
c += `${s}${n[r]}`;
|
|
37
43
|
}
|
|
38
|
-
return
|
|
44
|
+
return c.trim();
|
|
39
45
|
}
|
|
40
46
|
export {
|
|
41
|
-
|
|
47
|
+
G as encodeTagList,
|
|
48
|
+
F as generateCompleteFilterQuery,
|
|
49
|
+
Q as isValidFilterTag,
|
|
42
50
|
f as parseTagList,
|
|
43
51
|
m as safeDecodeURIComponent
|
|
44
52
|
};
|