@searchspring/snap-store-mobx 0.53.4 → 0.55.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 +7 -6
- 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 +3 -1
- 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 +7 -6
- package/dist/cjs/Search/Stores/SearchHistoryStore.js +1 -1
- package/dist/cjs/Search/Stores/SearchResultStore.d.ts +28 -10
- package/dist/cjs/Search/Stores/SearchResultStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/SearchResultStore.js +152 -45
- 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 +8 -3
- 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 +7 -6
- 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 +3 -1
- 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 +7 -6
- package/dist/esm/Search/Stores/SearchHistoryStore.js +2 -2
- package/dist/esm/Search/Stores/SearchResultStore.d.ts +28 -10
- package/dist/esm/Search/Stores/SearchResultStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/SearchResultStore.js +139 -39
- 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 +8 -3
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -38,16 +38,16 @@ 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
45
|
var SearchResultStore = /** @class */ (function (_super) {
|
|
46
46
|
__extends(SearchResultStore, _super);
|
|
47
|
-
function SearchResultStore(config, services, resultData, paginationData, merchData) {
|
|
47
|
+
function SearchResultStore(config, services, metaData, resultData, paginationData, merchData) {
|
|
48
48
|
var _a;
|
|
49
49
|
var results = (resultData || []).map(function (result) {
|
|
50
|
-
return new Product(services, result, config);
|
|
50
|
+
return new Product(services, result, metaData, config);
|
|
51
51
|
});
|
|
52
52
|
if ((_a = merchData === null || merchData === void 0 ? void 0 : merchData.content) === null || _a === void 0 ? void 0 : _a.inline) {
|
|
53
53
|
var banners = merchData.content.inline
|
|
@@ -94,8 +94,8 @@ var Banner = /** @class */ (function () {
|
|
|
94
94
|
}());
|
|
95
95
|
exports.Banner = Banner;
|
|
96
96
|
var Product = /** @class */ (function () {
|
|
97
|
-
function Product(services, result, config) {
|
|
98
|
-
var _a, _b, _c;
|
|
97
|
+
function Product(services, result, metaData, config) {
|
|
98
|
+
var _a, _b, _c, _d;
|
|
99
99
|
this.type = 'product';
|
|
100
100
|
this.attributes = {};
|
|
101
101
|
this.mappings = {
|
|
@@ -108,19 +108,20 @@ var Product = /** @class */ (function () {
|
|
|
108
108
|
this.id = result.id;
|
|
109
109
|
this.attributes = result.attributes;
|
|
110
110
|
this.mappings = result.mappings;
|
|
111
|
+
this.badges = new Badges(result, metaData);
|
|
111
112
|
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
113
|
if (config && variantsField && this.attributes && this.attributes[variantsField]) {
|
|
113
114
|
try {
|
|
114
115
|
// parse the field (JSON)
|
|
115
116
|
var parsedVariants = JSON.parse(this.attributes[variantsField]);
|
|
116
|
-
this.variants = new Variants(parsedVariants, this.mask);
|
|
117
|
+
this.variants = new Variants(parsedVariants, this.mask, (_c = config.settings) === null || _c === void 0 ? void 0 : _c.variants);
|
|
117
118
|
}
|
|
118
119
|
catch (err) {
|
|
119
120
|
// failed to parse the variant JSON
|
|
120
121
|
console.error(err, "Invalid variant JSON for product id: ".concat(result.id));
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
|
-
if ((
|
|
124
|
+
if ((_d = result === null || result === void 0 ? void 0 : result.children) === null || _d === void 0 ? void 0 : _d.length) {
|
|
124
125
|
this.children = result.children.map(function (variant, index) {
|
|
125
126
|
return new Child(services, __assign({ id: "".concat(result.id, "-").concat(index) }, variant));
|
|
126
127
|
});
|
|
@@ -149,6 +150,64 @@ var Product = /** @class */ (function () {
|
|
|
149
150
|
return Product;
|
|
150
151
|
}());
|
|
151
152
|
exports.Product = Product;
|
|
153
|
+
var Badges = /** @class */ (function () {
|
|
154
|
+
function Badges(result, metaData) {
|
|
155
|
+
this.all = [];
|
|
156
|
+
this.all = (result.badges || [])
|
|
157
|
+
.filter(function (badge) {
|
|
158
|
+
var _a, _b, _c;
|
|
159
|
+
// remove badges that are not in the meta or are disabled
|
|
160
|
+
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));
|
|
161
|
+
})
|
|
162
|
+
.map(function (badge) {
|
|
163
|
+
var _a, _b;
|
|
164
|
+
// merge badge with badge meta data
|
|
165
|
+
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];
|
|
166
|
+
return __assign(__assign({}, badge), metaBadgeData);
|
|
167
|
+
})
|
|
168
|
+
.sort(function (a, b) {
|
|
169
|
+
return a.priority - b.priority;
|
|
170
|
+
});
|
|
171
|
+
(0, mobx_1.makeObservable)(this, {
|
|
172
|
+
all: mobx_1.observable,
|
|
173
|
+
tags: mobx_1.computed,
|
|
174
|
+
locations: mobx_1.computed,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
// get all the result badges that are in a specific location
|
|
178
|
+
Badges.prototype.atLocation = function (location) {
|
|
179
|
+
var locations = Array.isArray(location) ? location : [location];
|
|
180
|
+
return this.all.filter(function (badge) {
|
|
181
|
+
// filter location
|
|
182
|
+
return locations.some(function (location) { return badge.location.startsWith("".concat(location, "/")) || badge.location == location; });
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
Object.defineProperty(Badges.prototype, "tags", {
|
|
186
|
+
get: function () {
|
|
187
|
+
return this.all.reduce(function (badgeMap, badge) {
|
|
188
|
+
badgeMap[badge.tag] = badge;
|
|
189
|
+
return badgeMap;
|
|
190
|
+
}, {});
|
|
191
|
+
},
|
|
192
|
+
enumerable: false,
|
|
193
|
+
configurable: true
|
|
194
|
+
});
|
|
195
|
+
Object.defineProperty(Badges.prototype, "locations", {
|
|
196
|
+
get: function () {
|
|
197
|
+
return this.all.reduce(function (locationMap, badge) {
|
|
198
|
+
// put badge in location by path
|
|
199
|
+
var _a = badge.location.split('/'), section = _a[0], tag = _a[1];
|
|
200
|
+
locationMap[section] = locationMap[section] || {};
|
|
201
|
+
locationMap[section][tag] = (locationMap[section][tag] || []).concat(badge);
|
|
202
|
+
return locationMap;
|
|
203
|
+
}, {});
|
|
204
|
+
},
|
|
205
|
+
enumerable: false,
|
|
206
|
+
configurable: true
|
|
207
|
+
});
|
|
208
|
+
return Badges;
|
|
209
|
+
}());
|
|
210
|
+
exports.Badges = Badges;
|
|
152
211
|
// Mask is used to power the product display for quick attribute swapping
|
|
153
212
|
var ProductMask = /** @class */ (function () {
|
|
154
213
|
function ProductMask() {
|
|
@@ -178,38 +237,59 @@ var ProductMask = /** @class */ (function () {
|
|
|
178
237
|
}());
|
|
179
238
|
exports.ProductMask = ProductMask;
|
|
180
239
|
var Variants = /** @class */ (function () {
|
|
181
|
-
function Variants(variantData, mask) {
|
|
240
|
+
function Variants(variantData, mask, config) {
|
|
182
241
|
var _this = this;
|
|
183
242
|
this.data = [];
|
|
184
243
|
this.selections = [];
|
|
185
|
-
var options = [];
|
|
186
|
-
// create variants objects
|
|
187
|
-
this.data = variantData.map(function (variant) {
|
|
188
|
-
Object.keys(variant.options).forEach(function (variantOption) {
|
|
189
|
-
if (!options.includes(variantOption)) {
|
|
190
|
-
options.push(variantOption);
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
return new Variant(variant);
|
|
194
|
-
});
|
|
195
|
-
options.map(function (option) {
|
|
196
|
-
// TODO - merge with variant config before constructing selection (for label overrides and swatch mappings)
|
|
197
|
-
var optionConfig = {
|
|
198
|
-
field: option,
|
|
199
|
-
label: option,
|
|
200
|
-
};
|
|
201
|
-
_this.selections.push(new VariantSelection(_this, optionConfig));
|
|
202
|
-
});
|
|
203
244
|
// setting function in constructor to prevent exposing mask as class property
|
|
204
245
|
this.setActive = function (variant) {
|
|
205
246
|
_this.active = variant;
|
|
206
247
|
mask.set({ mappings: _this.active.mappings, attributes: _this.active.attributes });
|
|
207
248
|
};
|
|
208
|
-
|
|
209
|
-
this.
|
|
249
|
+
this.config = config;
|
|
250
|
+
this.update(variantData, config);
|
|
210
251
|
}
|
|
252
|
+
Variants.prototype.update = function (variantData, config) {
|
|
253
|
+
var _this = this;
|
|
254
|
+
if (config === void 0) { config = this.config; }
|
|
255
|
+
try {
|
|
256
|
+
var options_1 = [];
|
|
257
|
+
// create variants objects
|
|
258
|
+
this.data = variantData.map(function (variant) {
|
|
259
|
+
Object.keys(variant.options).forEach(function (variantOption) {
|
|
260
|
+
if (!options_1.includes(variantOption)) {
|
|
261
|
+
options_1.push(variantOption);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
return new Variant(variant);
|
|
265
|
+
});
|
|
266
|
+
//need to reset this.selections first
|
|
267
|
+
this.selections = [];
|
|
268
|
+
options_1.map(function (option) {
|
|
269
|
+
// TODO - merge with variant config before constructing selection (for label overrides and swatch mappings)
|
|
270
|
+
var optionConfig = {
|
|
271
|
+
field: option,
|
|
272
|
+
label: option,
|
|
273
|
+
};
|
|
274
|
+
_this.selections.push(new VariantSelection(_this, optionConfig));
|
|
275
|
+
});
|
|
276
|
+
var preselectedOptions_1 = {};
|
|
277
|
+
if (config === null || config === void 0 ? void 0 : config.options) {
|
|
278
|
+
Object.keys(config === null || config === void 0 ? void 0 : config.options).forEach(function (option) {
|
|
279
|
+
if (config.options[option].preSelected) {
|
|
280
|
+
preselectedOptions_1[option] = config.options[option].preSelected;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
// select first available
|
|
285
|
+
this.makeSelections(preselectedOptions_1);
|
|
286
|
+
}
|
|
287
|
+
catch (err) {
|
|
288
|
+
// failed to parse the variant JSON
|
|
289
|
+
console.error(err, "Invalid variant JSON for: ".concat(variantData));
|
|
290
|
+
}
|
|
291
|
+
};
|
|
211
292
|
Variants.prototype.makeSelections = function (options) {
|
|
212
|
-
// TODO - support for affinity to attempt to pre-selected options
|
|
213
293
|
// options = {color: 'Blue', size: 'L'};
|
|
214
294
|
if (!options) {
|
|
215
295
|
// select first available for each selection
|
|
@@ -220,8 +300,40 @@ var Variants = /** @class */ (function () {
|
|
|
220
300
|
}
|
|
221
301
|
});
|
|
222
302
|
}
|
|
303
|
+
else {
|
|
304
|
+
this.selections.forEach(function (selection, idx) {
|
|
305
|
+
// filter by first available, then by preselected option preference
|
|
306
|
+
//make all options available for first selection.
|
|
307
|
+
var availableOptions = selection.values.filter(function (value) { return (idx == 0 ? true : value.available); });
|
|
308
|
+
var preferedOptions = options[selection.field];
|
|
309
|
+
var preferencedOption = availableOptions[0];
|
|
310
|
+
// if theres a preference for that field
|
|
311
|
+
if (preferedOptions) {
|
|
312
|
+
var checkIfAvailable_1 = function (preference) {
|
|
313
|
+
//see if that option is in the available options
|
|
314
|
+
var availablePreferedOptions = availableOptions.find(function (value) { return value.value.toLowerCase() == preference.toLowerCase(); });
|
|
315
|
+
//use it
|
|
316
|
+
if (availablePreferedOptions) {
|
|
317
|
+
preferencedOption = availablePreferedOptions;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
if (Array.isArray(preferedOptions)) {
|
|
321
|
+
//loop through each preference option
|
|
322
|
+
preferedOptions.forEach(function (preference) {
|
|
323
|
+
checkIfAvailable_1(preference);
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
checkIfAvailable_1(preferedOptions);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (preferencedOption) {
|
|
331
|
+
selection.select(preferencedOption.value);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
}
|
|
223
335
|
};
|
|
224
|
-
Variants.prototype.
|
|
336
|
+
Variants.prototype.refineSelections = function (fromSelection) {
|
|
225
337
|
var _this = this;
|
|
226
338
|
// need to ensure the update originator is at the BOTTOM of the list for refinement
|
|
227
339
|
var orderedSelections = __spreadArray([], this.selections, true);
|
|
@@ -232,13 +344,13 @@ var Variants = /** @class */ (function () {
|
|
|
232
344
|
return -1;
|
|
233
345
|
});
|
|
234
346
|
// refine selections ensuring that the selection that triggered the update refines LAST
|
|
235
|
-
orderedSelections.forEach(function (selection) { return selection.
|
|
347
|
+
orderedSelections.forEach(function (selection) { return selection.refineValues(_this); });
|
|
236
348
|
// check to see if we have enough selections made to update the display
|
|
237
|
-
var selectedSelections = this.selections.filter(function (selection) {
|
|
349
|
+
var selectedSelections = this.selections.filter(function (selection) { return selection.selected; });
|
|
238
350
|
if (selectedSelections.length) {
|
|
239
351
|
var availableVariants = this.data;
|
|
240
352
|
var _loop_1 = function (selectedSelection) {
|
|
241
|
-
availableVariants = availableVariants.filter(function (variant) { return selectedSelection.selected == variant.options[selectedSelection.field] && variant.available; });
|
|
353
|
+
availableVariants = availableVariants.filter(function (variant) { return selectedSelection.selected == variant.options[selectedSelection.field].value && variant.available; });
|
|
242
354
|
};
|
|
243
355
|
// loop through selectedSelections and only include available products that match current selections
|
|
244
356
|
for (var _i = 0, selectedSelections_1 = selectedSelections; _i < selectedSelections_1.length; _i++) {
|
|
@@ -263,21 +375,21 @@ var VariantSelection = /** @class */ (function () {
|
|
|
263
375
|
this.field = selectorConfig.field;
|
|
264
376
|
this.label = selectorConfig.label;
|
|
265
377
|
// needed to prevent attaching variants as class property
|
|
266
|
-
this.variantsUpdate = function () { return variants.
|
|
378
|
+
this.variantsUpdate = function () { return variants.refineSelections(_this); };
|
|
267
379
|
// create possible values from the data and refine them
|
|
268
|
-
this.
|
|
380
|
+
this.refineValues(variants);
|
|
269
381
|
(0, mobx_1.makeObservable)(this, {
|
|
270
382
|
selected: mobx_1.observable,
|
|
271
383
|
values: mobx_1.observable,
|
|
272
384
|
});
|
|
273
385
|
}
|
|
274
|
-
VariantSelection.prototype.
|
|
386
|
+
VariantSelection.prototype.refineValues = function (variants) {
|
|
275
387
|
var _this = this;
|
|
276
388
|
// current selection should only consider OTHER selections for availability
|
|
277
389
|
var selectedSelections = variants.selections.filter(function (selection) { return selection.field != _this.field && selection.selected; });
|
|
278
390
|
var availableVariants = variants.data;
|
|
279
391
|
var _loop_2 = function (selectedSelection) {
|
|
280
|
-
availableVariants = availableVariants.filter(function (variant) { return selectedSelection.selected == variant.options[selectedSelection.field] && variant.available; });
|
|
392
|
+
availableVariants = availableVariants.filter(function (variant) { return selectedSelection.selected == variant.options[selectedSelection.field].value && variant.available; });
|
|
281
393
|
};
|
|
282
394
|
// loop through selectedSelections and remove products that do not match
|
|
283
395
|
for (var _i = 0, selectedSelections_2 = selectedSelections; _i < selectedSelections_2.length; _i++) {
|
|
@@ -288,15 +400,11 @@ var VariantSelection = /** @class */ (function () {
|
|
|
288
400
|
.filter(function (variant) { return variant.options[_this.field]; })
|
|
289
401
|
.reduce(function (values, variant) {
|
|
290
402
|
var _a;
|
|
291
|
-
if (!values.some(function (val) { return variant.options[_this.field] == val.value; })) {
|
|
292
|
-
values.push({
|
|
293
|
-
value: variant.options[_this.field],
|
|
294
|
-
label: variant.options[_this.field],
|
|
403
|
+
if (!values.some(function (val) { return variant.options[_this.field].value == val.value; })) {
|
|
404
|
+
values.push(__assign({ label: variant.options[_this.field].value,
|
|
295
405
|
// TODO: use configurable mappings from config
|
|
296
406
|
// TODO: set background for swatches (via configurable mappings) from config
|
|
297
|
-
thumbnailImageUrl: (_a = variant.mappings.core) === null || _a === void 0 ? void 0 : _a.thumbnailImageUrl,
|
|
298
|
-
available: Boolean(availableVariants.some(function (availableVariant) { return availableVariant.options[_this.field] == variant.options[_this.field]; })),
|
|
299
|
-
});
|
|
407
|
+
thumbnailImageUrl: (_a = variant.mappings.core) === null || _a === void 0 ? void 0 : _a.thumbnailImageUrl, available: Boolean(availableVariants.some(function (availableVariant) { return availableVariant.options[_this.field].value == variant.options[_this.field].value; })) }, variant.options[_this.field]));
|
|
300
408
|
}
|
|
301
409
|
// TODO: use sorting function from config
|
|
302
410
|
return values;
|
|
@@ -347,7 +455,6 @@ var Variant = /** @class */ (function () {
|
|
|
347
455
|
function Variant(variantData) {
|
|
348
456
|
this.type = 'variant';
|
|
349
457
|
this.attributes = {};
|
|
350
|
-
this.options = {};
|
|
351
458
|
this.mappings = {
|
|
352
459
|
core: {},
|
|
353
460
|
};
|
|
@@ -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,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,UAAU,CAAe;IACjC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,GAAG,CAAgB;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;gBAE3B,MAAM,CAAC,EAAE,aAAa;IA8C3B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAyBnC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;IAiClC,KAAK,IAAI,IAAI;CAcpB;AAED,MAAM,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"StorageStore.d.ts","sourceRoot":"","sources":["../../../src/Storage/StorageStore.ts"],"names":[],"mappings":"AAMA,qBAAa,YAAY;IACxB,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,UAAU,CAAe;IACjC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,GAAG,CAAgB;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;gBAE3B,MAAM,CAAC,EAAE,aAAa;IA8C3B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAyBnC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;IAiClC,KAAK,IAAI,IAAI;CAcpB;AAED,MAAM,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,WAAW,GAAG,MAAM,OAAO,WAAW,CAAC;IAC7C,MAAM,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,GAAG,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,oBAAY,WAAW;IACtB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,MAAM,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,11 +1,16 @@
|
|
|
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
|
-
type VariantConfig = {
|
|
7
|
+
export type VariantConfig = {
|
|
8
8
|
field: string;
|
|
9
|
+
options?: {
|
|
10
|
+
[field: string]: {
|
|
11
|
+
preSelected?: string[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
9
14
|
};
|
|
10
15
|
export type VariantSelectionOptions = {
|
|
11
16
|
field: string;
|
|
@@ -120,5 +125,5 @@ export type SelectedSelection = {
|
|
|
120
125
|
export type FinderStoreState = {
|
|
121
126
|
persisted: boolean;
|
|
122
127
|
};
|
|
123
|
-
export
|
|
128
|
+
export type ResultBadge = MetaResponseModelBadgeTag & SearchResponseModelResultBadges;
|
|
124
129
|
//# 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,aAAa,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE;QACT,CAAC,KAAK,EAAE,MAAM,GAAG;YAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;SACvB,CAAC;KACF,CAAC;CACF,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CAGd,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE;QACV,SAAS,CAAC,EAAE;YACX,aAAa,CAAC,EAAE,OAAO,CAAC;YACxB,YAAY,CAAC,EAAE,OAAO,CAAC;SACvB,CAAC;QACF,MAAM,CAAC,EAAE,gBAAgB,GAAG;YAC3B,MAAM,CAAC,EAAE;gBACR,CAAC,KAAK,EAAE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M,MAAM,aAAa,GAAG;IAC3B,UAAU,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,oBAAY,SAAS;IACpB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,KAAK,UAAU;CACf;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,wCAAwC,EAAE,CAAC;IACjD,KAAK,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC9B,SAAS,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,yBAAyB,GAAG,+BAA+B,CAAC"}
|
|
@@ -6,9 +6,10 @@ import { AutocompleteStateStore, AutocompleteTermStore, AutocompleteQueryStore,
|
|
|
6
6
|
import type { AutocompleteResponseModel, MetaResponseModel } from '@searchspring/snapi-types';
|
|
7
7
|
import type { TrendingResponseModel } from '@searchspring/snap-client';
|
|
8
8
|
import type { AutocompleteStoreConfig, StoreServices } from '../types';
|
|
9
|
+
import { MetaStore } from '../Meta/MetaStore';
|
|
9
10
|
export declare class AutocompleteStore extends AbstractStore {
|
|
10
11
|
services: StoreServices;
|
|
11
|
-
meta:
|
|
12
|
+
meta: MetaStore;
|
|
12
13
|
merchandising: SearchMerchandisingStore;
|
|
13
14
|
search: AutocompleteQueryStore;
|
|
14
15
|
terms: AutocompleteTermStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteStore.d.ts","sourceRoot":"","sources":["../../../src/Autocomplete/AutocompleteStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAElB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YA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AAM,EAAG,sBAAsB,CAAC;IAChC,KAAK,EAAG,qBAAqB,CAAC;IAC9B,MAAM,EAAG,sBAAsB,CAAC;IAChC,OAAO,EAAG,iBAAiB,CAAC;IAC5B,OAAO,EAAG,iBAAiB,CAAC;IAC5B,UAAU,EAAG,qBAAqB,CAAC;IACnC,OAAO,EAAG,kBAAkB,CAAC;IAC7B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,yBAAyB,CAAC;IACpC,OAAO,EAAE,wBAAwB,CAAC;gBAE7B,MAAM,EAAE,uBAAuB,EAAE,QAAQ,EAAE,aAAa;IAiC7D,KAAK,IAAI,IAAI;IAMb,WAAW,IAAI,IAAI;IAgBnB,UAAU,IAAI,IAAI;IAMlB,gBAAgB,IAAI,IAAI;IAIxB,aAAa,IAAI,IAAI;IAIrB,YAAY,IAAI,IAAI;IAIpB,UAAU,CAAC,IAAI,EAAE,MAAM,aAAa,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IAUhE,mBAAmB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI;IAWtD,MAAM,CAAC,IAAI,GAAE,yBAAyB,GAAG;QAAE,IAAI,CAAC,EAAE,iBAAiB,CAAA;KAAO,GAAG,IAAI;CA2DxF"}
|
|
@@ -3,6 +3,7 @@ import { AbstractStore } from '../Abstract/AbstractStore';
|
|
|
3
3
|
import { SearchFilterStore, SearchResultStore, SearchMerchandisingStore, SearchPaginationStore, SearchSortingStore, SearchHistoryStore, } from '../Search/Stores';
|
|
4
4
|
import { StorageStore } from '../Storage/StorageStore';
|
|
5
5
|
import { AutocompleteStateStore, AutocompleteTermStore, AutocompleteQueryStore, AutocompleteFacetStore, AutocompleteTrendingStore, AutocompleteHistoryStore, } from './Stores';
|
|
6
|
+
import { MetaStore } from '../Meta/MetaStore';
|
|
6
7
|
export class AutocompleteStore extends AbstractStore {
|
|
7
8
|
constructor(config, services) {
|
|
8
9
|
super(config);
|
|
@@ -76,7 +77,7 @@ export class AutocompleteStore extends AbstractStore {
|
|
|
76
77
|
return;
|
|
77
78
|
this.error = undefined;
|
|
78
79
|
this.loaded = !!data.pagination;
|
|
79
|
-
this.meta = data.meta
|
|
80
|
+
this.meta = new MetaStore(data.meta);
|
|
80
81
|
// set the query to match the actual queried term and not the input query
|
|
81
82
|
if (data.search) {
|
|
82
83
|
this.state.url = this.services.urlManager = this.services.urlManager.set('query', data.search.query);
|
|
@@ -93,16 +94,16 @@ export class AutocompleteStore extends AbstractStore {
|
|
|
93
94
|
this.search = new AutocompleteQueryStore(this.services, data.autocomplete || {}, data.search || {}, this.config);
|
|
94
95
|
// only run if we want to update the facets (not locked)
|
|
95
96
|
if (!this.state.locks.facets.locked) {
|
|
96
|
-
this.facets = new AutocompleteFacetStore(this.config, this.services, this.storage, data.facets || [], data.pagination || {}, this.meta, this.state, data.merchandising || {});
|
|
97
|
+
this.facets = new AutocompleteFacetStore(this.config, this.services, this.storage, data.facets || [], data.pagination || {}, this.meta.data, this.state, data.merchandising || {});
|
|
97
98
|
}
|
|
98
|
-
this.filters = new SearchFilterStore(this.services, data.filters, this.meta);
|
|
99
|
-
this.results = new SearchResultStore(this.config, this.services, data.results || [], data.pagination, data.merchandising);
|
|
99
|
+
this.filters = new SearchFilterStore(this.services, data.filters, this.meta.data);
|
|
100
|
+
this.results = new SearchResultStore(this.config, this.services, this.meta.data, data.results || [], data.pagination, data.merchandising);
|
|
100
101
|
if ((this.results.length === 0 && !this.trending.filter((term) => term.active).length) || this.terms?.filter((term) => term.active).length) {
|
|
101
102
|
// if a trending term was selected and then a subsequent search yields no results, reset trending terms to remove active state
|
|
102
103
|
// OR if any terms are active, also reset to ensure only a single term or trending term is active
|
|
103
104
|
this.resetTrending();
|
|
104
105
|
}
|
|
105
|
-
this.pagination = new SearchPaginationStore(this.config, this.services, data.pagination, this.meta);
|
|
106
|
-
this.sorting = new SearchSortingStore(this.services, data.sorting || [], data.search || {}, this.meta);
|
|
106
|
+
this.pagination = new SearchPaginationStore(this.config, this.services, data.pagination, this.meta.data);
|
|
107
|
+
this.sorting = new SearchSortingStore(this.services, data.sorting || [], data.search || {}, this.meta.data);
|
|
107
108
|
}
|
|
108
109
|
}
|
|
@@ -5,10 +5,11 @@ import { StorageStore } from '../Storage/StorageStore';
|
|
|
5
5
|
import { FinderSelectionStore } from './Stores';
|
|
6
6
|
import type { FinderStoreConfig, StoreServices, SelectedSelection, FinderStoreState } from '../types';
|
|
7
7
|
import { UrlManager } from '@searchspring/snap-url-manager';
|
|
8
|
+
import { MetaStore } from '../Meta/MetaStore';
|
|
8
9
|
export declare class FinderStore extends AbstractStore {
|
|
9
10
|
services: StoreServices;
|
|
10
11
|
config: FinderStoreConfig;
|
|
11
|
-
meta:
|
|
12
|
+
meta: MetaStore;
|
|
12
13
|
storage: StorageStore;
|
|
13
14
|
persistedStorage: StorageStore;
|
|
14
15
|
pagination: SearchPaginationStore;
|
|
@@ -20,7 +21,7 @@ export declare class FinderStore extends AbstractStore {
|
|
|
20
21
|
reset: () => void;
|
|
21
22
|
loadPersisted(): void;
|
|
22
23
|
update(data: SearchResponseModel & {
|
|
23
|
-
meta
|
|
24
|
+
meta?: MetaResponseModel;
|
|
24
25
|
}, selectedSelections?: SelectedSelection[]): void;
|
|
25
26
|
}
|
|
26
27
|
//# sourceMappingURL=FinderStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FinderStore.d.ts","sourceRoot":"","sources":["../../../src/Finder/FinderStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"FinderStore.d.ts","sourceRoot":"","sources":["../../../src/Finder/Finder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