@searchspring/snap-store-mobx 0.54.0 → 0.56.0
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/cjs/Autocomplete/AutocompleteStore.d.ts +2 -1
- package/dist/cjs/Autocomplete/AutocompleteStore.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/AutocompleteStore.js +8 -7
- package/dist/cjs/Cart/CartStore.js +2 -2
- package/dist/cjs/Finder/FinderStore.d.ts +3 -2
- package/dist/cjs/Finder/FinderStore.d.ts.map +1 -1
- package/dist/cjs/Finder/FinderStore.js +5 -5
- package/dist/cjs/Meta/MetaStore.d.ts +15 -0
- package/dist/cjs/Meta/MetaStore.d.ts.map +1 -0
- package/dist/cjs/Meta/MetaStore.js +54 -0
- package/dist/cjs/Recommendation/RecommendationStore.d.ts +6 -1
- package/dist/cjs/Recommendation/RecommendationStore.d.ts.map +1 -1
- package/dist/cjs/Recommendation/RecommendationStore.js +4 -2
- package/dist/cjs/Search/SearchStore.d.ts +2 -1
- package/dist/cjs/Search/SearchStore.d.ts.map +1 -1
- package/dist/cjs/Search/SearchStore.js +8 -7
- package/dist/cjs/Search/Stores/SearchHistoryStore.js +1 -1
- package/dist/cjs/Search/Stores/SearchResultStore.d.ts +19 -9
- package/dist/cjs/Search/Stores/SearchResultStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/SearchResultStore.js +180 -40
- package/dist/cjs/Search/Stores/index.d.ts +1 -1
- package/dist/cjs/Search/Stores/index.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/index.js +2 -1
- package/dist/cjs/Storage/StorageStore.d.ts +5 -5
- package/dist/cjs/Storage/StorageStore.d.ts.map +1 -1
- package/dist/cjs/Storage/StorageStore.js +17 -17
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/types.d.ts +23 -8
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts +2 -1
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts.map +1 -1
- package/dist/esm/Autocomplete/AutocompleteStore.js +8 -7
- package/dist/esm/Cart/CartStore.js +2 -2
- package/dist/esm/Finder/FinderStore.d.ts +3 -2
- package/dist/esm/Finder/FinderStore.d.ts.map +1 -1
- package/dist/esm/Finder/FinderStore.js +6 -6
- package/dist/esm/Meta/MetaStore.d.ts +15 -0
- package/dist/esm/Meta/MetaStore.d.ts.map +1 -0
- package/dist/esm/Meta/MetaStore.js +44 -0
- package/dist/esm/Recommendation/RecommendationStore.d.ts +6 -1
- package/dist/esm/Recommendation/RecommendationStore.d.ts.map +1 -1
- package/dist/esm/Recommendation/RecommendationStore.js +4 -2
- package/dist/esm/Search/SearchStore.d.ts +2 -1
- package/dist/esm/Search/SearchStore.d.ts.map +1 -1
- package/dist/esm/Search/SearchStore.js +8 -7
- package/dist/esm/Search/Stores/SearchHistoryStore.js +2 -2
- package/dist/esm/Search/Stores/SearchResultStore.d.ts +19 -9
- package/dist/esm/Search/Stores/SearchResultStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/SearchResultStore.js +159 -36
- package/dist/esm/Search/Stores/index.d.ts +1 -1
- package/dist/esm/Search/Stores/index.d.ts.map +1 -1
- package/dist/esm/Search/Stores/index.js +1 -1
- package/dist/esm/Storage/StorageStore.d.ts +5 -5
- package/dist/esm/Storage/StorageStore.d.ts.map +1 -1
- package/dist/esm/Storage/StorageStore.js +17 -17
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/types.d.ts +23 -8
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -38,18 +38,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
39
|
};
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.Variant = exports.VariantSelection = exports.Variants = exports.ProductMask = exports.Product = exports.Banner = exports.SearchResultStore = void 0;
|
|
41
|
+
exports.Variant = exports.VariantSelection = exports.Variants = exports.ProductMask = exports.Badges = exports.Product = exports.Banner = exports.SearchResultStore = void 0;
|
|
42
42
|
var mobx_1 = require("mobx");
|
|
43
43
|
var deepmerge_1 = __importDefault(require("deepmerge"));
|
|
44
44
|
var is_plain_object_1 = require("is-plain-object");
|
|
45
|
+
var VARIANT_ATTRIBUTE = 'ss-variant-option';
|
|
46
|
+
var VARIANT_ATTRIBUTE_SELECTED = 'ss-variant-option-selected';
|
|
45
47
|
var SearchResultStore = /** @class */ (function (_super) {
|
|
46
48
|
__extends(SearchResultStore, _super);
|
|
47
|
-
function SearchResultStore(config, services, resultData, paginationData, merchData) {
|
|
48
|
-
var _a;
|
|
49
|
+
function SearchResultStore(config, services, metaData, resultData, paginationData, merchData, loaded) {
|
|
50
|
+
var _a, _b, _c, _d;
|
|
49
51
|
var results = (resultData || []).map(function (result) {
|
|
50
|
-
return new Product(services, result, config);
|
|
52
|
+
return new Product(services, result, metaData, config);
|
|
51
53
|
});
|
|
52
|
-
|
|
54
|
+
var variantConfig = (_a = config === null || config === void 0 ? void 0 : config.settings) === null || _a === void 0 ? void 0 : _a.variants;
|
|
55
|
+
// preselected variant options
|
|
56
|
+
if ((_b = variantConfig === null || variantConfig === void 0 ? void 0 : variantConfig.realtime) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
57
|
+
// attach click events - ONLY happens once (known limitation)
|
|
58
|
+
if (!loaded && results.length) {
|
|
59
|
+
document.querySelectorAll("[".concat(VARIANT_ATTRIBUTE, "]")).forEach(function (elem) {
|
|
60
|
+
var _a;
|
|
61
|
+
if ((variantConfig === null || variantConfig === void 0 ? void 0 : variantConfig.field) && !((_a = variantConfig === null || variantConfig === void 0 ? void 0 : variantConfig.realtime) === null || _a === void 0 ? void 0 : _a.enabled) === false) {
|
|
62
|
+
elem.addEventListener('click', function () { return variantOptionClick(elem, variantConfig, results); });
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// check for attributes for preselection
|
|
67
|
+
if (results.length) {
|
|
68
|
+
if ((variantConfig === null || variantConfig === void 0 ? void 0 : variantConfig.field) && !((_c = variantConfig === null || variantConfig === void 0 ? void 0 : variantConfig.realtime) === null || _c === void 0 ? void 0 : _c.enabled) === false) {
|
|
69
|
+
var options_1 = {};
|
|
70
|
+
// grab values from elements on the page to form preselected elements
|
|
71
|
+
document.querySelectorAll("[".concat(VARIANT_ATTRIBUTE_SELECTED, "]")).forEach(function (elem) {
|
|
72
|
+
var attr = elem.getAttribute(VARIANT_ATTRIBUTE);
|
|
73
|
+
if (attr) {
|
|
74
|
+
var _a = attr.split(':'), option = _a[0], value = _a[1];
|
|
75
|
+
if (option && value) {
|
|
76
|
+
options_1[option.toLowerCase()] = [value.toLowerCase()];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
makeVariantSelections(variantConfig, options_1, results);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if ((_d = merchData === null || merchData === void 0 ? void 0 : merchData.content) === null || _d === void 0 ? void 0 : _d.inline) {
|
|
53
85
|
var banners = merchData.content.inline
|
|
54
86
|
.sort(function (a, b) {
|
|
55
87
|
return a.config.position.index - b.config.position.index;
|
|
@@ -94,7 +126,7 @@ var Banner = /** @class */ (function () {
|
|
|
94
126
|
}());
|
|
95
127
|
exports.Banner = Banner;
|
|
96
128
|
var Product = /** @class */ (function () {
|
|
97
|
-
function Product(services, result, config) {
|
|
129
|
+
function Product(services, result, metaData, config) {
|
|
98
130
|
var _a, _b, _c, _d;
|
|
99
131
|
this.type = 'product';
|
|
100
132
|
this.attributes = {};
|
|
@@ -108,12 +140,13 @@ var Product = /** @class */ (function () {
|
|
|
108
140
|
this.id = result.id;
|
|
109
141
|
this.attributes = result.attributes;
|
|
110
142
|
this.mappings = result.mappings;
|
|
143
|
+
this.badges = new Badges(result, metaData);
|
|
111
144
|
var variantsField = (_b = (_a = config === null || config === void 0 ? void 0 : config.settings) === null || _a === void 0 ? void 0 : _a.variants) === null || _b === void 0 ? void 0 : _b.field;
|
|
112
145
|
if (config && variantsField && this.attributes && this.attributes[variantsField]) {
|
|
113
146
|
try {
|
|
114
147
|
// parse the field (JSON)
|
|
115
148
|
var parsedVariants = JSON.parse(this.attributes[variantsField]);
|
|
116
|
-
this.variants = new Variants(parsedVariants, this.mask, (_c = config.settings) === null || _c === void 0 ? void 0 : _c.variants);
|
|
149
|
+
this.variants = new Variants(parsedVariants, this.mask, (_c = config === null || config === void 0 ? void 0 : config.settings) === null || _c === void 0 ? void 0 : _c.variants);
|
|
117
150
|
}
|
|
118
151
|
catch (err) {
|
|
119
152
|
// failed to parse the variant JSON
|
|
@@ -149,6 +182,64 @@ var Product = /** @class */ (function () {
|
|
|
149
182
|
return Product;
|
|
150
183
|
}());
|
|
151
184
|
exports.Product = Product;
|
|
185
|
+
var Badges = /** @class */ (function () {
|
|
186
|
+
function Badges(result, metaData) {
|
|
187
|
+
this.all = [];
|
|
188
|
+
this.all = (result.badges || [])
|
|
189
|
+
.filter(function (badge) {
|
|
190
|
+
var _a, _b, _c;
|
|
191
|
+
// remove badges that are not in the meta or are disabled
|
|
192
|
+
return !!((badge === null || badge === void 0 ? void 0 : badge.tag) && ((_a = metaData === null || metaData === void 0 ? void 0 : metaData.badges) === null || _a === void 0 ? void 0 : _a.tags) && ((_b = metaData === null || metaData === void 0 ? void 0 : metaData.badges) === null || _b === void 0 ? void 0 : _b.tags[badge.tag]) && ((_c = metaData === null || metaData === void 0 ? void 0 : metaData.badges) === null || _c === void 0 ? void 0 : _c.tags[badge.tag].enabled));
|
|
193
|
+
})
|
|
194
|
+
.map(function (badge) {
|
|
195
|
+
var _a, _b;
|
|
196
|
+
// merge badge with badge meta data
|
|
197
|
+
var metaBadgeData = (_b = (_a = metaData === null || metaData === void 0 ? void 0 : metaData.badges) === null || _a === void 0 ? void 0 : _a.tags) === null || _b === void 0 ? void 0 : _b[badge.tag];
|
|
198
|
+
return __assign(__assign({}, badge), metaBadgeData);
|
|
199
|
+
})
|
|
200
|
+
.sort(function (a, b) {
|
|
201
|
+
return a.priority - b.priority;
|
|
202
|
+
});
|
|
203
|
+
(0, mobx_1.makeObservable)(this, {
|
|
204
|
+
all: mobx_1.observable,
|
|
205
|
+
tags: mobx_1.computed,
|
|
206
|
+
locations: mobx_1.computed,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
// get all the result badges that are in a specific location
|
|
210
|
+
Badges.prototype.atLocation = function (location) {
|
|
211
|
+
var locations = Array.isArray(location) ? location : [location];
|
|
212
|
+
return this.all.filter(function (badge) {
|
|
213
|
+
// filter location
|
|
214
|
+
return locations.some(function (location) { return badge.location.startsWith("".concat(location, "/")) || badge.location == location; });
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
Object.defineProperty(Badges.prototype, "tags", {
|
|
218
|
+
get: function () {
|
|
219
|
+
return this.all.reduce(function (badgeMap, badge) {
|
|
220
|
+
badgeMap[badge.tag] = badge;
|
|
221
|
+
return badgeMap;
|
|
222
|
+
}, {});
|
|
223
|
+
},
|
|
224
|
+
enumerable: false,
|
|
225
|
+
configurable: true
|
|
226
|
+
});
|
|
227
|
+
Object.defineProperty(Badges.prototype, "locations", {
|
|
228
|
+
get: function () {
|
|
229
|
+
return this.all.reduce(function (locationMap, badge) {
|
|
230
|
+
// put badge in location by path
|
|
231
|
+
var _a = badge.location.split('/'), section = _a[0], tag = _a[1];
|
|
232
|
+
locationMap[section] = locationMap[section] || {};
|
|
233
|
+
locationMap[section][tag] = (locationMap[section][tag] || []).concat(badge);
|
|
234
|
+
return locationMap;
|
|
235
|
+
}, {});
|
|
236
|
+
},
|
|
237
|
+
enumerable: false,
|
|
238
|
+
configurable: true
|
|
239
|
+
});
|
|
240
|
+
return Badges;
|
|
241
|
+
}());
|
|
242
|
+
exports.Badges = Badges;
|
|
152
243
|
// Mask is used to power the product display for quick attribute swapping
|
|
153
244
|
var ProductMask = /** @class */ (function () {
|
|
154
245
|
function ProductMask() {
|
|
@@ -187,32 +278,31 @@ var Variants = /** @class */ (function () {
|
|
|
187
278
|
_this.active = variant;
|
|
188
279
|
mask.set({ mappings: _this.active.mappings, attributes: _this.active.attributes });
|
|
189
280
|
};
|
|
190
|
-
|
|
281
|
+
if (config) {
|
|
282
|
+
this.config = config;
|
|
283
|
+
}
|
|
191
284
|
this.update(variantData, config);
|
|
192
285
|
}
|
|
193
286
|
Variants.prototype.update = function (variantData, config) {
|
|
194
287
|
var _this = this;
|
|
195
288
|
if (config === void 0) { config = this.config; }
|
|
196
289
|
try {
|
|
197
|
-
var
|
|
290
|
+
var options_2 = [];
|
|
198
291
|
// create variants objects
|
|
199
292
|
this.data = variantData.map(function (variant) {
|
|
200
293
|
Object.keys(variant.options).forEach(function (variantOption) {
|
|
201
|
-
if (!
|
|
202
|
-
|
|
294
|
+
if (!options_2.includes(variantOption)) {
|
|
295
|
+
options_2.push(variantOption);
|
|
203
296
|
}
|
|
204
297
|
});
|
|
205
298
|
return new Variant(variant);
|
|
206
299
|
});
|
|
207
300
|
//need to reset this.selections first
|
|
208
301
|
this.selections = [];
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
var
|
|
212
|
-
|
|
213
|
-
label: option,
|
|
214
|
-
};
|
|
215
|
-
_this.selections.push(new VariantSelection(_this, optionConfig));
|
|
302
|
+
options_2.map(function (option) {
|
|
303
|
+
var _a;
|
|
304
|
+
var variantOptionConfig = ((_a = _this.config) === null || _a === void 0 ? void 0 : _a.options) && _this.config.options[option];
|
|
305
|
+
_this.selections.push(new VariantSelection(_this, option, variantOptionConfig));
|
|
216
306
|
});
|
|
217
307
|
var preselectedOptions_1 = {};
|
|
218
308
|
if (config === null || config === void 0 ? void 0 : config.options) {
|
|
@@ -232,7 +322,7 @@ var Variants = /** @class */ (function () {
|
|
|
232
322
|
};
|
|
233
323
|
Variants.prototype.makeSelections = function (options) {
|
|
234
324
|
// options = {color: 'Blue', size: 'L'};
|
|
235
|
-
if (!options) {
|
|
325
|
+
if (!options || !Object.keys(options).length) {
|
|
236
326
|
// select first available for each selection
|
|
237
327
|
this.selections.forEach(function (selection) {
|
|
238
328
|
var firstAvailableOption = selection.values.find(function (value) { return value.available; });
|
|
@@ -247,12 +337,12 @@ var Variants = /** @class */ (function () {
|
|
|
247
337
|
//make all options available for first selection.
|
|
248
338
|
var availableOptions = selection.values.filter(function (value) { return (idx == 0 ? true : value.available); });
|
|
249
339
|
var preferedOptions = options[selection.field];
|
|
250
|
-
var preferencedOption = availableOptions[0];
|
|
340
|
+
var preferencedOption = selection.selected || availableOptions[0];
|
|
251
341
|
// if theres a preference for that field
|
|
252
342
|
if (preferedOptions) {
|
|
253
343
|
var checkIfAvailable_1 = function (preference) {
|
|
254
344
|
//see if that option is in the available options
|
|
255
|
-
var availablePreferedOptions = availableOptions.find(function (value) { return value.value.toLowerCase() == preference.toLowerCase(); });
|
|
345
|
+
var availablePreferedOptions = availableOptions.find(function (value) { return value.value.toString().toLowerCase() == (preference === null || preference === void 0 ? void 0 : preference.toString().toLowerCase()); });
|
|
256
346
|
//use it
|
|
257
347
|
if (availablePreferedOptions) {
|
|
258
348
|
preferencedOption = availablePreferedOptions;
|
|
@@ -269,7 +359,7 @@ var Variants = /** @class */ (function () {
|
|
|
269
359
|
}
|
|
270
360
|
}
|
|
271
361
|
if (preferencedOption) {
|
|
272
|
-
selection.select(preferencedOption.value);
|
|
362
|
+
selection.select(preferencedOption.value, true);
|
|
273
363
|
}
|
|
274
364
|
});
|
|
275
365
|
}
|
|
@@ -287,11 +377,11 @@ var Variants = /** @class */ (function () {
|
|
|
287
377
|
// refine selections ensuring that the selection that triggered the update refines LAST
|
|
288
378
|
orderedSelections.forEach(function (selection) { return selection.refineValues(_this); });
|
|
289
379
|
// check to see if we have enough selections made to update the display
|
|
290
|
-
var selectedSelections = this.selections.filter(function (selection) { return selection.selected; });
|
|
380
|
+
var selectedSelections = this.selections.filter(function (selection) { var _a, _b; return (_b = (_a = selection.selected) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length; });
|
|
291
381
|
if (selectedSelections.length) {
|
|
292
382
|
var availableVariants = this.data;
|
|
293
383
|
var _loop_1 = function (selectedSelection) {
|
|
294
|
-
availableVariants = availableVariants.filter(function (variant) { return selectedSelection.selected == variant.options[selectedSelection.field].value && variant.available; });
|
|
384
|
+
availableVariants = availableVariants.filter(function (variant) { var _a; return ((_a = selectedSelection.selected) === null || _a === void 0 ? void 0 : _a.value) == variant.options[selectedSelection.field].value && variant.available; });
|
|
295
385
|
};
|
|
296
386
|
// loop through selectedSelections and only include available products that match current selections
|
|
297
387
|
for (var _i = 0, selectedSelections_1 = selectedSelections; _i < selectedSelections_1.length; _i++) {
|
|
@@ -308,13 +398,14 @@ var Variants = /** @class */ (function () {
|
|
|
308
398
|
}());
|
|
309
399
|
exports.Variants = Variants;
|
|
310
400
|
var VariantSelection = /** @class */ (function () {
|
|
311
|
-
function VariantSelection(variants,
|
|
401
|
+
function VariantSelection(variants, selectorField, variantConfig) {
|
|
312
402
|
var _this = this;
|
|
313
|
-
this.selected =
|
|
314
|
-
this.previouslySelected =
|
|
403
|
+
this.selected = undefined;
|
|
404
|
+
this.previouslySelected = undefined;
|
|
315
405
|
this.values = [];
|
|
316
|
-
this.field =
|
|
317
|
-
this.label =
|
|
406
|
+
this.field = selectorField;
|
|
407
|
+
this.label = (variantConfig === null || variantConfig === void 0 ? void 0 : variantConfig.label) || selectorField;
|
|
408
|
+
this.config = variantConfig || {};
|
|
318
409
|
// needed to prevent attaching variants as class property
|
|
319
410
|
this.variantsUpdate = function () { return variants.refineSelections(_this); };
|
|
320
411
|
// create possible values from the data and refine them
|
|
@@ -330,7 +421,7 @@ var VariantSelection = /** @class */ (function () {
|
|
|
330
421
|
var selectedSelections = variants.selections.filter(function (selection) { return selection.field != _this.field && selection.selected; });
|
|
331
422
|
var availableVariants = variants.data;
|
|
332
423
|
var _loop_2 = function (selectedSelection) {
|
|
333
|
-
availableVariants = availableVariants.filter(function (variant) { return selectedSelection.selected == variant.options[selectedSelection.field].value && variant.available; });
|
|
424
|
+
availableVariants = availableVariants.filter(function (variant) { var _a; return ((_a = selectedSelection.selected) === null || _a === void 0 ? void 0 : _a.value) == variant.options[selectedSelection.field].value && variant.available; });
|
|
334
425
|
};
|
|
335
426
|
// loop through selectedSelections and remove products that do not match
|
|
336
427
|
for (var _i = 0, selectedSelections_2 = selectedSelections; _i < selectedSelections_2.length; _i++) {
|
|
@@ -342,10 +433,30 @@ var VariantSelection = /** @class */ (function () {
|
|
|
342
433
|
.reduce(function (values, variant) {
|
|
343
434
|
var _a;
|
|
344
435
|
if (!values.some(function (val) { return variant.options[_this.field].value == val.value; })) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
436
|
+
var value = variant.options[_this.field].value;
|
|
437
|
+
var thumbnailImageUrl = (_a = variant.mappings.core) === null || _a === void 0 ? void 0 : _a.thumbnailImageUrl;
|
|
438
|
+
var mappedValue = {
|
|
439
|
+
value: value,
|
|
440
|
+
label: value,
|
|
441
|
+
thumbnailImageUrl: thumbnailImageUrl,
|
|
442
|
+
available: Boolean(availableVariants.some(function (availableVariant) { return availableVariant.options[_this.field].value == variant.options[_this.field].value; })),
|
|
443
|
+
};
|
|
444
|
+
if (_this.config.thumbnailBackgroundImages) {
|
|
445
|
+
mappedValue.backgroundImageUrl = thumbnailImageUrl;
|
|
446
|
+
}
|
|
447
|
+
if (_this.config.mappings && _this.config.mappings && _this.config.mappings[value.toString().toLowerCase()]) {
|
|
448
|
+
var mapping = _this.config.mappings[value.toString().toLowerCase()];
|
|
449
|
+
if (mapping.label) {
|
|
450
|
+
mappedValue.label = mapping.label;
|
|
451
|
+
}
|
|
452
|
+
if (mapping.background) {
|
|
453
|
+
mappedValue.background = mapping.background;
|
|
454
|
+
}
|
|
455
|
+
if (mapping.backgroundImageUrl) {
|
|
456
|
+
mappedValue.backgroundImageUrl = mapping.backgroundImageUrl;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
values.push(mappedValue);
|
|
349
460
|
}
|
|
350
461
|
// TODO: use sorting function from config
|
|
351
462
|
return values;
|
|
@@ -353,19 +464,19 @@ var VariantSelection = /** @class */ (function () {
|
|
|
353
464
|
// if selection has been made
|
|
354
465
|
if (this.selected) {
|
|
355
466
|
// check if the selection is stil available
|
|
356
|
-
if (!newValues.some(function (val) { return val.value == _this.selected && val.available; })) {
|
|
467
|
+
if (!newValues.some(function (val) { var _a; return val.value == ((_a = _this.selected) === null || _a === void 0 ? void 0 : _a.value) && val.available; })) {
|
|
357
468
|
// the selection is no longer available, attempt to select previous selection
|
|
358
469
|
if (this.selected !== this.previouslySelected &&
|
|
359
470
|
this.previouslySelected &&
|
|
360
|
-
newValues.some(function (val) { return val.value == _this.previouslySelected && val.available; })) {
|
|
361
|
-
this.select(this.previouslySelected, true);
|
|
471
|
+
newValues.some(function (val) { var _a; return val.value == ((_a = _this.previouslySelected) === null || _a === void 0 ? void 0 : _a.value) && val.available; })) {
|
|
472
|
+
this.select(this.previouslySelected.value, true);
|
|
362
473
|
}
|
|
363
474
|
else {
|
|
364
475
|
// choose the first available option if previous seletions are unavailable
|
|
365
476
|
var availableValues = newValues.filter(function (val) { return val.available; });
|
|
366
477
|
if (newValues.length && availableValues.length) {
|
|
367
478
|
var nextAvailableValue = availableValues[0].value;
|
|
368
|
-
if (this.selected !== nextAvailableValue) {
|
|
479
|
+
if (this.selected.value !== nextAvailableValue) {
|
|
369
480
|
this.select(nextAvailableValue, true);
|
|
370
481
|
}
|
|
371
482
|
}
|
|
@@ -375,7 +486,7 @@ var VariantSelection = /** @class */ (function () {
|
|
|
375
486
|
this.values = newValues;
|
|
376
487
|
};
|
|
377
488
|
VariantSelection.prototype.reset = function () {
|
|
378
|
-
this.selected =
|
|
489
|
+
this.selected = undefined;
|
|
379
490
|
this.values.forEach(function (val) { return (val.available = false); });
|
|
380
491
|
};
|
|
381
492
|
VariantSelection.prototype.select = function (value, internalSelection) {
|
|
@@ -385,7 +496,7 @@ var VariantSelection = /** @class */ (function () {
|
|
|
385
496
|
if (!internalSelection) {
|
|
386
497
|
this.previouslySelected = this.selected;
|
|
387
498
|
}
|
|
388
|
-
this.selected =
|
|
499
|
+
this.selected = valueExist;
|
|
389
500
|
this.variantsUpdate();
|
|
390
501
|
}
|
|
391
502
|
};
|
|
@@ -451,3 +562,32 @@ function addBannersToResults(config, results, banners, paginationData) {
|
|
|
451
562
|
});
|
|
452
563
|
return results;
|
|
453
564
|
}
|
|
565
|
+
function variantOptionClick(elem, variantConfig, results) {
|
|
566
|
+
var options = {};
|
|
567
|
+
var attr = elem.getAttribute(VARIANT_ATTRIBUTE);
|
|
568
|
+
if (attr) {
|
|
569
|
+
var _a = attr.split(':'), option = _a[0], value = _a[1];
|
|
570
|
+
options[option.toLowerCase()] = [value.toLowerCase()];
|
|
571
|
+
makeVariantSelections(variantConfig, options, results);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
function makeVariantSelections(variantConfig, options, results) {
|
|
575
|
+
var _a, _b;
|
|
576
|
+
var filteredResults = results;
|
|
577
|
+
// filter based on config
|
|
578
|
+
(_b = (_a = variantConfig.realtime) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.forEach(function (filter) {
|
|
579
|
+
if (filter == 'first') {
|
|
580
|
+
filteredResults = [filteredResults[0]];
|
|
581
|
+
}
|
|
582
|
+
if (filter == 'unaltered') {
|
|
583
|
+
filteredResults = filteredResults.filter(function (result) { var _a; return !((_a = result.variants) === null || _a === void 0 ? void 0 : _a.selections.some(function (selection) { return selection.previouslySelected; })); });
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
filteredResults.forEach(function (result) {
|
|
587
|
+
var _a;
|
|
588
|
+
// no banner types
|
|
589
|
+
if (result.type == 'product') {
|
|
590
|
+
(_a = result.variants) === null || _a === void 0 ? void 0 : _a.makeSelections(options);
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
}
|
|
@@ -2,7 +2,7 @@ export { SearchMerchandisingStore, BannerContent, ContentType } from './SearchMe
|
|
|
2
2
|
export { SearchFacetStore, ValueFacet, RangeFacet, FacetValue, FacetHierarchyValue, FacetRangeValue } from './SearchFacetStore';
|
|
3
3
|
export { SearchFilterStore, Filter } from './SearchFilterStore';
|
|
4
4
|
export { SearchPaginationStore } from './SearchPaginationStore';
|
|
5
|
-
export { SearchResultStore, Product, Banner } from './SearchResultStore';
|
|
5
|
+
export { SearchResultStore, Product, Banner, VariantSelection, VariantSelectionValue } from './SearchResultStore';
|
|
6
6
|
export { SearchSortingStore } from './SearchSortingStore';
|
|
7
7
|
export { SearchQueryStore } from './SearchQueryStore';
|
|
8
8
|
export { SearchHistoryStore } from './SearchHistoryStore';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChI,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChI,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAClH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SearchHistoryStore = exports.SearchQueryStore = exports.SearchSortingStore = exports.Banner = exports.Product = exports.SearchResultStore = exports.SearchPaginationStore = exports.Filter = exports.SearchFilterStore = exports.FacetRangeValue = exports.FacetHierarchyValue = exports.FacetValue = exports.RangeFacet = exports.ValueFacet = exports.SearchFacetStore = exports.ContentType = exports.SearchMerchandisingStore = void 0;
|
|
3
|
+
exports.SearchHistoryStore = exports.SearchQueryStore = exports.SearchSortingStore = exports.VariantSelection = exports.Banner = exports.Product = exports.SearchResultStore = exports.SearchPaginationStore = exports.Filter = exports.SearchFilterStore = exports.FacetRangeValue = exports.FacetHierarchyValue = exports.FacetValue = exports.RangeFacet = exports.ValueFacet = exports.SearchFacetStore = exports.ContentType = exports.SearchMerchandisingStore = void 0;
|
|
4
4
|
var SearchMerchandisingStore_1 = require("./SearchMerchandisingStore");
|
|
5
5
|
Object.defineProperty(exports, "SearchMerchandisingStore", { enumerable: true, get: function () { return SearchMerchandisingStore_1.SearchMerchandisingStore; } });
|
|
6
6
|
Object.defineProperty(exports, "ContentType", { enumerable: true, get: function () { return SearchMerchandisingStore_1.ContentType; } });
|
|
@@ -20,6 +20,7 @@ var SearchResultStore_1 = require("./SearchResultStore");
|
|
|
20
20
|
Object.defineProperty(exports, "SearchResultStore", { enumerable: true, get: function () { return SearchResultStore_1.SearchResultStore; } });
|
|
21
21
|
Object.defineProperty(exports, "Product", { enumerable: true, get: function () { return SearchResultStore_1.Product; } });
|
|
22
22
|
Object.defineProperty(exports, "Banner", { enumerable: true, get: function () { return SearchResultStore_1.Banner; } });
|
|
23
|
+
Object.defineProperty(exports, "VariantSelection", { enumerable: true, get: function () { return SearchResultStore_1.VariantSelection; } });
|
|
23
24
|
var SearchSortingStore_1 = require("./SearchSortingStore");
|
|
24
25
|
Object.defineProperty(exports, "SearchSortingStore", { enumerable: true, get: function () { return SearchSortingStore_1.SearchSortingStore; } });
|
|
25
26
|
var SearchQueryStore_1 = require("./SearchQueryStore");
|
|
@@ -10,7 +10,7 @@ export declare class StorageStore {
|
|
|
10
10
|
clear(): void;
|
|
11
11
|
}
|
|
12
12
|
export type StorageConfig = {
|
|
13
|
-
type: StorageType;
|
|
13
|
+
type: StorageType | keyof typeof StorageType;
|
|
14
14
|
cookie?: {
|
|
15
15
|
expiration?: number;
|
|
16
16
|
sameSite?: string;
|
|
@@ -18,9 +18,9 @@ export type StorageConfig = {
|
|
|
18
18
|
key: string;
|
|
19
19
|
};
|
|
20
20
|
export declare enum StorageType {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
session = "session",
|
|
22
|
+
local = "local",
|
|
23
|
+
cookie = "cookie",
|
|
24
|
+
memory = "memory"
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=StorageStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageStore.d.ts","sourceRoot":"","sources":["../../../src/Storage/StorageStore.ts"],"names":[],"mappings":"AAMA,qBAAa,YAAY;IACxB,O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AM,WAAW;IACjB,MAAM,WAAW;CACjB"}
|
|
@@ -24,7 +24,7 @@ var StorageStore = /** @class */ (function () {
|
|
|
24
24
|
this.sameSite = config.cookie.sameSite;
|
|
25
25
|
}
|
|
26
26
|
switch (config.type) {
|
|
27
|
-
case StorageType.
|
|
27
|
+
case StorageType.session: {
|
|
28
28
|
this.type = snap_toolbox_1.featureFlags.storage ? config.type : null;
|
|
29
29
|
if (this.type) {
|
|
30
30
|
this.state = JSON.parse(window.sessionStorage.getItem(this.key) || '{}');
|
|
@@ -32,7 +32,7 @@ var StorageStore = /** @class */ (function () {
|
|
|
32
32
|
}
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
35
|
-
case StorageType.
|
|
35
|
+
case StorageType.local: {
|
|
36
36
|
this.type = snap_toolbox_1.featureFlags.storage ? config.type : null;
|
|
37
37
|
if (this.type) {
|
|
38
38
|
this.state = JSON.parse(window.localStorage.getItem(this.key) || '{}');
|
|
@@ -40,7 +40,7 @@ var StorageStore = /** @class */ (function () {
|
|
|
40
40
|
}
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
|
-
case StorageType.
|
|
43
|
+
case StorageType.cookie: {
|
|
44
44
|
if (snap_toolbox_1.featureFlags.cookies) {
|
|
45
45
|
this.type = config.type;
|
|
46
46
|
var data = utils.cookies.get(this.key);
|
|
@@ -51,7 +51,7 @@ var StorageStore = /** @class */ (function () {
|
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
53
|
default: {
|
|
54
|
-
this.type = StorageType.
|
|
54
|
+
this.type = StorageType.memory;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -69,28 +69,28 @@ var StorageStore = /** @class */ (function () {
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
switch (this.type) {
|
|
72
|
-
case StorageType.
|
|
72
|
+
case StorageType.session:
|
|
73
73
|
window.sessionStorage.setItem(this.key, JSON.stringify(this.state));
|
|
74
74
|
break;
|
|
75
|
-
case StorageType.
|
|
75
|
+
case StorageType.local:
|
|
76
76
|
window.localStorage.setItem(this.key, JSON.stringify(this.state));
|
|
77
77
|
break;
|
|
78
|
-
case StorageType.
|
|
78
|
+
case StorageType.cookie:
|
|
79
79
|
utils.cookies.set(this.key, JSON.stringify(this.state), this.sameSite, this.expiration);
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
StorageStore.prototype.get = function (path) {
|
|
84
84
|
switch (this.type) {
|
|
85
|
-
case StorageType.
|
|
85
|
+
case StorageType.session:
|
|
86
86
|
var sessionData = window.sessionStorage.getItem(this.key);
|
|
87
87
|
this.state = sessionData ? JSON.parse(sessionData) : {};
|
|
88
88
|
break;
|
|
89
|
-
case StorageType.
|
|
89
|
+
case StorageType.local:
|
|
90
90
|
var localData = window.localStorage.getItem(this.key);
|
|
91
91
|
this.state = localData ? JSON.parse(localData) : {};
|
|
92
92
|
break;
|
|
93
|
-
case StorageType.
|
|
93
|
+
case StorageType.cookie:
|
|
94
94
|
var data = utils.cookies.get(this.key);
|
|
95
95
|
if (data) {
|
|
96
96
|
this.state = JSON.parse(data) || {};
|
|
@@ -115,13 +115,13 @@ var StorageStore = /** @class */ (function () {
|
|
|
115
115
|
};
|
|
116
116
|
StorageStore.prototype.clear = function () {
|
|
117
117
|
switch (this.type) {
|
|
118
|
-
case StorageType.
|
|
118
|
+
case StorageType.session:
|
|
119
119
|
window.sessionStorage.removeItem(this.key);
|
|
120
120
|
break;
|
|
121
|
-
case StorageType.
|
|
121
|
+
case StorageType.local:
|
|
122
122
|
window.localStorage.removeItem(this.key);
|
|
123
123
|
break;
|
|
124
|
-
case StorageType.
|
|
124
|
+
case StorageType.cookie:
|
|
125
125
|
utils.cookies.unset(this.key);
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
@@ -132,8 +132,8 @@ var StorageStore = /** @class */ (function () {
|
|
|
132
132
|
exports.StorageStore = StorageStore;
|
|
133
133
|
var StorageType;
|
|
134
134
|
(function (StorageType) {
|
|
135
|
-
StorageType["
|
|
136
|
-
StorageType["
|
|
137
|
-
StorageType["
|
|
138
|
-
StorageType["
|
|
135
|
+
StorageType["session"] = "session";
|
|
136
|
+
StorageType["local"] = "local";
|
|
137
|
+
StorageType["cookie"] = "cookie";
|
|
138
|
+
StorageType["memory"] = "memory";
|
|
139
139
|
})(StorageType || (exports.StorageType = StorageType = {}));
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export * from './Search/Stores/';
|
|
|
6
6
|
export { RecommendationStore } from './Recommendation/RecommendationStore';
|
|
7
7
|
export { CartStore } from './Cart/CartStore';
|
|
8
8
|
export { StorageStore, StorageConfig, StorageType } from './Storage/StorageStore';
|
|
9
|
+
export { MetaStore } from './Meta/MetaStore';
|
|
9
10
|
export * from './types';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,cAAc,SAAS,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.StorageType = exports.StorageStore = exports.CartStore = exports.RecommendationStore = exports.SearchStore = exports.FinderStore = exports.AutocompleteStore = exports.AbstractStore = void 0;
|
|
17
|
+
exports.MetaStore = exports.StorageType = exports.StorageStore = exports.CartStore = exports.RecommendationStore = exports.SearchStore = exports.FinderStore = exports.AutocompleteStore = exports.AbstractStore = void 0;
|
|
18
18
|
var AbstractStore_1 = require("./Abstract/AbstractStore");
|
|
19
19
|
Object.defineProperty(exports, "AbstractStore", { enumerable: true, get: function () { return AbstractStore_1.AbstractStore; } });
|
|
20
20
|
var AutocompleteStore_1 = require("./Autocomplete/AutocompleteStore");
|
|
@@ -31,4 +31,6 @@ Object.defineProperty(exports, "CartStore", { enumerable: true, get: function ()
|
|
|
31
31
|
var StorageStore_1 = require("./Storage/StorageStore");
|
|
32
32
|
Object.defineProperty(exports, "StorageStore", { enumerable: true, get: function () { return StorageStore_1.StorageStore; } });
|
|
33
33
|
Object.defineProperty(exports, "StorageType", { enumerable: true, get: function () { return StorageStore_1.StorageType; } });
|
|
34
|
+
var MetaStore_1 = require("./Meta/MetaStore");
|
|
35
|
+
Object.defineProperty(exports, "MetaStore", { enumerable: true, get: function () { return MetaStore_1.MetaStore; } });
|
|
34
36
|
__exportStar(require("./types"), exports);
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
import type { UrlManager } from '@searchspring/snap-url-manager';
|
|
2
|
-
import type { SearchResponseModelFacetValueAllOfValues, AutocompleteRequestModel, SearchRequestModel } from '@searchspring/snapi-types';
|
|
2
|
+
import type { SearchResponseModelFacetValueAllOfValues, AutocompleteRequestModel, SearchRequestModel, MetaResponseModelBadgeTag, SearchResponseModelResultBadges } from '@searchspring/snapi-types';
|
|
3
3
|
export type StoreConfig = {
|
|
4
4
|
id: string;
|
|
5
5
|
[any: string]: unknown;
|
|
6
6
|
};
|
|
7
|
+
export type VariantConfigFilterTypes = 'first' | 'unaltered';
|
|
7
8
|
export type VariantConfig = {
|
|
8
9
|
field: string;
|
|
10
|
+
realtime?: {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
filters?: VariantConfigFilterTypes[];
|
|
13
|
+
};
|
|
9
14
|
options?: {
|
|
10
|
-
[
|
|
11
|
-
preSelected?: string[];
|
|
12
|
-
};
|
|
15
|
+
[optionField: string]: VariantOptionConfig;
|
|
13
16
|
};
|
|
14
17
|
};
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
export type VariantOptionConfig = {
|
|
19
|
+
label?: string;
|
|
20
|
+
preSelected?: string[];
|
|
21
|
+
thumbnailBackgroundImages?: boolean;
|
|
22
|
+
mappings?: VariantOptionConfigMappings;
|
|
23
|
+
};
|
|
24
|
+
export type VariantOptionConfigMappings = {
|
|
25
|
+
[optionValue: string]: {
|
|
26
|
+
label?: string;
|
|
27
|
+
background?: string;
|
|
28
|
+
backgroundImageUrl?: string;
|
|
29
|
+
};
|
|
18
30
|
};
|
|
19
31
|
export type SearchStoreConfig = StoreConfig & {
|
|
20
32
|
globals?: Partial<SearchRequestModel>;
|
|
@@ -106,7 +118,9 @@ export type RecommendationStoreConfig = StoreConfig & {
|
|
|
106
118
|
realtime?: boolean;
|
|
107
119
|
batched?: boolean;
|
|
108
120
|
order?: number;
|
|
109
|
-
|
|
121
|
+
settings?: {
|
|
122
|
+
variants?: VariantConfig;
|
|
123
|
+
};
|
|
110
124
|
};
|
|
111
125
|
export type StoreConfigs = SearchStoreConfig | AutocompleteStoreConfig | FinderStoreConfig | RecommendationStoreConfig;
|
|
112
126
|
export type StoreServices = {
|
|
@@ -125,4 +139,5 @@ export type SelectedSelection = {
|
|
|
125
139
|
export type FinderStoreState = {
|
|
126
140
|
persisted: boolean;
|
|
127
141
|
};
|
|
142
|
+
export type ResultBadge = MetaResponseModelBadgeTag & SearchResponseModelResultBadges;
|
|
128
143
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/cjs/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EACX,wCAAwC,EACxC,wBAAwB,EACxB,kBAAkB,EAClB,yBAAyB,EACzB,+BAA+B,EAC/B,MAAM,2BAA2B,CAAC;AAEnC,MAAM,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,WAAW,CAAC;AAE7D,MAAM,MAAM,aAAa,GAAG;I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