@searchspring/snap-store-mobx 0.20.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/LICENSE +21 -0
- package/README.md +54 -0
- package/dist/cjs/Abstract/AbstractStore.d.ts +18 -0
- package/dist/cjs/Abstract/AbstractStore.d.ts.map +1 -0
- package/dist/cjs/Abstract/AbstractStore.js +31 -0
- package/dist/cjs/Autocomplete/AutocompleteStore.d.ts +32 -0
- package/dist/cjs/Autocomplete/AutocompleteStore.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/AutocompleteStore.js +121 -0
- package/dist/cjs/Autocomplete/Stores/FacetStore.d.ts +9 -0
- package/dist/cjs/Autocomplete/Stores/FacetStore.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/Stores/FacetStore.js +69 -0
- package/dist/cjs/Autocomplete/Stores/QueryStore.d.ts +15 -0
- package/dist/cjs/Autocomplete/Stores/QueryStore.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/Stores/QueryStore.js +30 -0
- package/dist/cjs/Autocomplete/Stores/StateStore.d.ts +23 -0
- package/dist/cjs/Autocomplete/Stores/StateStore.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/Stores/StateStore.js +52 -0
- package/dist/cjs/Autocomplete/Stores/TermStore.d.ts +19 -0
- package/dist/cjs/Autocomplete/Stores/TermStore.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/Stores/TermStore.js +86 -0
- package/dist/cjs/Autocomplete/Stores/TrendingStore.d.ts +7 -0
- package/dist/cjs/Autocomplete/Stores/TrendingStore.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/Stores/TrendingStore.js +44 -0
- package/dist/cjs/Autocomplete/Stores/index.d.ts +6 -0
- package/dist/cjs/Autocomplete/Stores/index.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/Stores/index.js +13 -0
- package/dist/cjs/Finder/FinderStore.d.ts +21 -0
- package/dist/cjs/Finder/FinderStore.d.ts.map +1 -0
- package/dist/cjs/Finder/FinderStore.js +56 -0
- package/dist/cjs/Finder/Stores/SelectionStore.d.ts +8 -0
- package/dist/cjs/Finder/Stores/SelectionStore.d.ts.map +1 -0
- package/dist/cjs/Finder/Stores/SelectionStore.js +232 -0
- package/dist/cjs/Finder/Stores/index.d.ts +2 -0
- package/dist/cjs/Finder/Stores/index.d.ts.map +1 -0
- package/dist/cjs/Finder/Stores/index.js +5 -0
- package/dist/cjs/Recommendation/RecommendationStore.d.ts +14 -0
- package/dist/cjs/Recommendation/RecommendationStore.d.ts.map +1 -0
- package/dist/cjs/Recommendation/RecommendationStore.js +51 -0
- package/dist/cjs/Recommendation/Stores/ProfileStore.d.ts +8 -0
- package/dist/cjs/Recommendation/Stores/ProfileStore.d.ts.map +1 -0
- package/dist/cjs/Recommendation/Stores/ProfileStore.js +22 -0
- package/dist/cjs/Recommendation/Stores/index.d.ts +2 -0
- package/dist/cjs/Recommendation/Stores/index.d.ts.map +1 -0
- package/dist/cjs/Recommendation/Stores/index.js +5 -0
- package/dist/cjs/Search/SearchStore.d.ts +26 -0
- package/dist/cjs/Search/SearchStore.d.ts.map +1 -0
- package/dist/cjs/Search/SearchStore.js +61 -0
- package/dist/cjs/Search/Stores/FacetStore.d.ts +8 -0
- package/dist/cjs/Search/Stores/FacetStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/FacetStore.js +317 -0
- package/dist/cjs/Search/Stores/FilterStore.d.ts +7 -0
- package/dist/cjs/Search/Stores/FilterStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/FilterStore.js +100 -0
- package/dist/cjs/Search/Stores/MerchandisingStore.d.ts +20 -0
- package/dist/cjs/Search/Stores/MerchandisingStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/MerchandisingStore.js +59 -0
- package/dist/cjs/Search/Stores/PaginationStore.d.ts +40 -0
- package/dist/cjs/Search/Stores/PaginationStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/PaginationStore.js +190 -0
- package/dist/cjs/Search/Stores/QueryStore.d.ts +16 -0
- package/dist/cjs/Search/Stores/QueryStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/QueryStore.js +34 -0
- package/dist/cjs/Search/Stores/ResultStore.d.ts +7 -0
- package/dist/cjs/Search/Stores/ResultStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/ResultStore.js +156 -0
- package/dist/cjs/Search/Stores/SortingStore.d.ts +21 -0
- package/dist/cjs/Search/Stores/SortingStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/SortingStore.js +75 -0
- package/dist/cjs/Search/Stores/index.d.ts +8 -0
- package/dist/cjs/Search/Stores/index.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/index.js +17 -0
- package/dist/cjs/Storage/StorageStore.d.ts +25 -0
- package/dist/cjs/Storage/StorageStore.d.ts.map +1 -0
- package/dist/cjs/Storage/StorageStore.js +130 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +27 -0
- package/dist/cjs/types.d.ts +81 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +9 -0
- package/dist/esm/Abstract/AbstractStore.d.ts +18 -0
- package/dist/esm/Abstract/AbstractStore.d.ts.map +1 -0
- package/dist/esm/Abstract/AbstractStore.js +25 -0
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts +32 -0
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts.map +1 -0
- package/dist/esm/Autocomplete/AutocompleteStore.js +94 -0
- package/dist/esm/Autocomplete/Stores/FacetStore.d.ts +9 -0
- package/dist/esm/Autocomplete/Stores/FacetStore.d.ts.map +1 -0
- package/dist/esm/Autocomplete/Stores/FacetStore.js +29 -0
- package/dist/esm/Autocomplete/Stores/QueryStore.d.ts +15 -0
- package/dist/esm/Autocomplete/Stores/QueryStore.d.ts.map +1 -0
- package/dist/esm/Autocomplete/Stores/QueryStore.js +24 -0
- package/dist/esm/Autocomplete/Stores/StateStore.d.ts +23 -0
- package/dist/esm/Autocomplete/Stores/StateStore.d.ts.map +1 -0
- package/dist/esm/Autocomplete/Stores/StateStore.js +40 -0
- package/dist/esm/Autocomplete/Stores/TermStore.d.ts +19 -0
- package/dist/esm/Autocomplete/Stores/TermStore.d.ts.map +1 -0
- package/dist/esm/Autocomplete/Stores/TermStore.js +42 -0
- package/dist/esm/Autocomplete/Stores/TrendingStore.d.ts +7 -0
- package/dist/esm/Autocomplete/Stores/TrendingStore.d.ts.map +1 -0
- package/dist/esm/Autocomplete/Stores/TrendingStore.js +16 -0
- package/dist/esm/Autocomplete/Stores/index.d.ts +6 -0
- package/dist/esm/Autocomplete/Stores/index.d.ts.map +1 -0
- package/dist/esm/Autocomplete/Stores/index.js +5 -0
- package/dist/esm/Finder/FinderStore.d.ts +21 -0
- package/dist/esm/Finder/FinderStore.d.ts.map +1 -0
- package/dist/esm/Finder/FinderStore.js +33 -0
- package/dist/esm/Finder/Stores/SelectionStore.d.ts +8 -0
- package/dist/esm/Finder/Stores/SelectionStore.d.ts.map +1 -0
- package/dist/esm/Finder/Stores/SelectionStore.js +171 -0
- package/dist/esm/Finder/Stores/index.d.ts +2 -0
- package/dist/esm/Finder/Stores/index.d.ts.map +1 -0
- package/dist/esm/Finder/Stores/index.js +1 -0
- package/dist/esm/Recommendation/RecommendationStore.d.ts +14 -0
- package/dist/esm/Recommendation/RecommendationStore.d.ts.map +1 -0
- package/dist/esm/Recommendation/RecommendationStore.js +28 -0
- package/dist/esm/Recommendation/Stores/ProfileStore.d.ts +8 -0
- package/dist/esm/Recommendation/Stores/ProfileStore.d.ts.map +1 -0
- package/dist/esm/Recommendation/Stores/ProfileStore.js +17 -0
- package/dist/esm/Recommendation/Stores/index.d.ts +2 -0
- package/dist/esm/Recommendation/Stores/index.d.ts.map +1 -0
- package/dist/esm/Recommendation/Stores/index.js +1 -0
- package/dist/esm/Search/SearchStore.d.ts +26 -0
- package/dist/esm/Search/SearchStore.d.ts.map +1 -0
- package/dist/esm/Search/SearchStore.js +38 -0
- package/dist/esm/Search/Stores/FacetStore.d.ts +8 -0
- package/dist/esm/Search/Stores/FacetStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/FacetStore.js +264 -0
- package/dist/esm/Search/Stores/FilterStore.d.ts +7 -0
- package/dist/esm/Search/Stores/FilterStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/FilterStore.js +68 -0
- package/dist/esm/Search/Stores/MerchandisingStore.d.ts +20 -0
- package/dist/esm/Search/Stores/MerchandisingStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/MerchandisingStore.js +32 -0
- package/dist/esm/Search/Stores/PaginationStore.d.ts +40 -0
- package/dist/esm/Search/Stores/PaginationStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/PaginationStore.js +148 -0
- package/dist/esm/Search/Stores/QueryStore.d.ts +16 -0
- package/dist/esm/Search/Stores/QueryStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/QueryStore.js +28 -0
- package/dist/esm/Search/Stores/ResultStore.d.ts +7 -0
- package/dist/esm/Search/Stores/ResultStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/ResultStore.js +117 -0
- package/dist/esm/Search/Stores/SortingStore.d.ts +21 -0
- package/dist/esm/Search/Stores/SortingStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/SortingStore.js +65 -0
- package/dist/esm/Search/Stores/index.d.ts +8 -0
- package/dist/esm/Search/Stores/index.d.ts.map +1 -0
- package/dist/esm/Search/Stores/index.js +7 -0
- package/dist/esm/Storage/StorageStore.d.ts +25 -0
- package/dist/esm/Storage/StorageStore.d.ts.map +1 -0
- package/dist/esm/Storage/StorageStore.js +123 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/types.d.ts +81 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +6 -0
- package/package.json +34 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.TrendingStore = void 0;
|
|
19
|
+
var TermStore_1 = require("./TermStore");
|
|
20
|
+
var TrendingStore = /** @class */ (function (_super) {
|
|
21
|
+
__extends(TrendingStore, _super);
|
|
22
|
+
function TrendingStore(services, trendingData, resetTerms, rootState) {
|
|
23
|
+
var _a;
|
|
24
|
+
var _this = this;
|
|
25
|
+
var terms = [];
|
|
26
|
+
(_a = trendingData === null || trendingData === void 0 ? void 0 : trendingData.queries) === null || _a === void 0 ? void 0 : _a.map(function (term) {
|
|
27
|
+
terms.push(new TermStore_1.Term(services, {
|
|
28
|
+
active: false,
|
|
29
|
+
value: term.searchQuery,
|
|
30
|
+
}, terms, resetTerms, rootState));
|
|
31
|
+
});
|
|
32
|
+
_this = _super.apply(this, terms) || this;
|
|
33
|
+
return _this;
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(TrendingStore, Symbol.species, {
|
|
36
|
+
get: function () {
|
|
37
|
+
return Array;
|
|
38
|
+
},
|
|
39
|
+
enumerable: false,
|
|
40
|
+
configurable: true
|
|
41
|
+
});
|
|
42
|
+
return TrendingStore;
|
|
43
|
+
}(Array));
|
|
44
|
+
exports.TrendingStore = TrendingStore;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Autocomplete/Stores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TrendingStore = exports.TermStore = exports.StateStore = exports.QueryStore = exports.FacetStore = void 0;
|
|
4
|
+
var FacetStore_1 = require("./FacetStore");
|
|
5
|
+
Object.defineProperty(exports, "FacetStore", { enumerable: true, get: function () { return FacetStore_1.FacetStore; } });
|
|
6
|
+
var QueryStore_1 = require("./QueryStore");
|
|
7
|
+
Object.defineProperty(exports, "QueryStore", { enumerable: true, get: function () { return QueryStore_1.QueryStore; } });
|
|
8
|
+
var StateStore_1 = require("./StateStore");
|
|
9
|
+
Object.defineProperty(exports, "StateStore", { enumerable: true, get: function () { return StateStore_1.StateStore; } });
|
|
10
|
+
var TermStore_1 = require("./TermStore");
|
|
11
|
+
Object.defineProperty(exports, "TermStore", { enumerable: true, get: function () { return TermStore_1.TermStore; } });
|
|
12
|
+
var TrendingStore_1 = require("./TrendingStore");
|
|
13
|
+
Object.defineProperty(exports, "TrendingStore", { enumerable: true, get: function () { return TrendingStore_1.TrendingStore; } });
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SearchResponseModel, MetaResponseModel } from '@searchspring/snapi-types';
|
|
2
|
+
import { AbstractStore } from '../Abstract/AbstractStore';
|
|
3
|
+
import { PaginationStore } from '../Search/Stores';
|
|
4
|
+
import { StorageStore } from '../Storage/StorageStore';
|
|
5
|
+
import { SelectionStore } from './Stores';
|
|
6
|
+
import type { FinderStoreConfig, StoreServices } from '../types';
|
|
7
|
+
export declare class FinderStore extends AbstractStore {
|
|
8
|
+
services: StoreServices;
|
|
9
|
+
config: FinderStoreConfig;
|
|
10
|
+
meta: MetaResponseModel;
|
|
11
|
+
storage: StorageStore;
|
|
12
|
+
pagination: PaginationStore;
|
|
13
|
+
selections: SelectionStore;
|
|
14
|
+
constructor(config: FinderStoreConfig, services: StoreServices);
|
|
15
|
+
setService(name: any, service: any): void;
|
|
16
|
+
update(data: SearchResponseModel & {
|
|
17
|
+
meta: MetaResponseModel;
|
|
18
|
+
selections: SelectionStore[];
|
|
19
|
+
}): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=FinderStore.d.ts.map
|
|
@@ -0,0 +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,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEjE,qBAAa,WAAY,SAAQ,aAAa;IAC7C,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,IAAI,EAAE,iBAAiB,CAAM;IAC7B,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,eAAe,CAAC;IAC5B,UAAU,EAAE,cAAc,CAAC;gBAEf,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa;IAmB9D,UAAU,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA,GAAG,IAAI;IAM/B,MAAM,CAAC,IAAI,EAAE,mBAAmB,GAAG;QAAE,IAAI,EAAE,iBAAiB,CAAC;QAAC,UAAU,EAAE,cAAc,EAAE,CAAA;KAAE,GAAG,IAAI;CAOnG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.FinderStore = void 0;
|
|
19
|
+
var mobx_1 = require("mobx");
|
|
20
|
+
var AbstractStore_1 = require("../Abstract/AbstractStore");
|
|
21
|
+
var Stores_1 = require("../Search/Stores");
|
|
22
|
+
var StorageStore_1 = require("../Storage/StorageStore");
|
|
23
|
+
var Stores_2 = require("./Stores");
|
|
24
|
+
var FinderStore = /** @class */ (function (_super) {
|
|
25
|
+
__extends(FinderStore, _super);
|
|
26
|
+
function FinderStore(config, services) {
|
|
27
|
+
var _a;
|
|
28
|
+
var _this = _super.call(this, config) || this;
|
|
29
|
+
_this.meta = {};
|
|
30
|
+
if (typeof services != 'object' || typeof ((_a = services.urlManager) === null || _a === void 0 ? void 0 : _a.subscribe) != 'function') {
|
|
31
|
+
throw new Error("Invalid service 'urlManager' passed to AutocompleteStore. Missing \"subscribe\" function.");
|
|
32
|
+
}
|
|
33
|
+
_this.services = services;
|
|
34
|
+
_this.storage = new StorageStore_1.StorageStore();
|
|
35
|
+
_this.update({ meta: {}, selections: [] });
|
|
36
|
+
(0, mobx_1.makeObservable)(_this, {
|
|
37
|
+
selections: mobx_1.observable,
|
|
38
|
+
pagination: mobx_1.observable,
|
|
39
|
+
});
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
FinderStore.prototype.setService = function (name, service) {
|
|
43
|
+
if (this.services[name] && service) {
|
|
44
|
+
this.services[name] = service;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
FinderStore.prototype.update = function (data) {
|
|
48
|
+
this.error = undefined;
|
|
49
|
+
this.loaded = !!data.pagination;
|
|
50
|
+
this.meta = data.meta;
|
|
51
|
+
this.pagination = new Stores_1.PaginationStore(this.config, this.services, data.pagination);
|
|
52
|
+
this.selections = new Stores_2.SelectionStore(this.config, this.services, data.facets, this.meta, this.loading, this.storage);
|
|
53
|
+
};
|
|
54
|
+
return FinderStore;
|
|
55
|
+
}(AbstractStore_1.AbstractStore));
|
|
56
|
+
exports.FinderStore = FinderStore;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FinderStoreConfig, StoreServices } from '../../types';
|
|
2
|
+
import type { StorageStore } from '../../Storage/StorageStore';
|
|
3
|
+
import type { MetaResponseModel, SearchResponseModelFacet } from '@searchspring/snapi-types';
|
|
4
|
+
export declare class SelectionStore extends Array {
|
|
5
|
+
static get [Symbol.species](): ArrayConstructor;
|
|
6
|
+
constructor(config: FinderStoreConfig, services: StoreServices, facets: SearchResponseModelFacet[], meta: MetaResponseModel, loading: boolean, storage: StorageStore);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=SelectionStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionStore.d.ts","sourceRoot":"","sources":["../../../../src/Finder/Stores/SelectionStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAqB,aAAa,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAA4C,MAAM,2BAA2B,CAAC;AAEvI,qBAAa,cAAe,SAAQ,KAAK;IACxC,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAE9C;gBAGA,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,wBAAwB,EAAE,EAClC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,YAAY;CA+CtB"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
29
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
+
if (ar || !(i in from)) {
|
|
31
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
+
ar[i] = from[i];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.SelectionStore = void 0;
|
|
39
|
+
var SelectionStore = /** @class */ (function (_super) {
|
|
40
|
+
__extends(SelectionStore, _super);
|
|
41
|
+
function SelectionStore(config, services, facets, meta, loading, storage) {
|
|
42
|
+
var _a;
|
|
43
|
+
var _this = this;
|
|
44
|
+
if (!facets || !meta) {
|
|
45
|
+
_this = _super.call(this) || this;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// re-order facets to match our config
|
|
49
|
+
(config === null || config === void 0 ? void 0 : config.fields) &&
|
|
50
|
+
facets.sort(function (a, b) {
|
|
51
|
+
var fields = config.fields.map(function (fieldConfig) { return fieldConfig.field; });
|
|
52
|
+
return fields.indexOf(a.field) - fields.indexOf(b.field);
|
|
53
|
+
});
|
|
54
|
+
var selections = [];
|
|
55
|
+
(_a = config === null || config === void 0 ? void 0 : config.fields) === null || _a === void 0 ? void 0 : _a.forEach(function (fieldObj) {
|
|
56
|
+
var _a;
|
|
57
|
+
var facet = facets === null || facets === void 0 ? void 0 : facets.filter(function (facet) { return facet.field == fieldObj.field; }).pop();
|
|
58
|
+
facet = __assign(__assign({}, meta === null || meta === void 0 ? void 0 : meta.facets[fieldObj.field]), facet);
|
|
59
|
+
var isHierarchy = facet.display === 'hierarchy';
|
|
60
|
+
if (isHierarchy) {
|
|
61
|
+
// filter out history/current hierarchy values
|
|
62
|
+
var filtered = facet.filtered && facet.values.filter(function (value) { return value.filtered; }).pop();
|
|
63
|
+
if (filtered) {
|
|
64
|
+
var filteredLevel_1 = filtered.value.split(facet.hierarchyDelimiter).length;
|
|
65
|
+
facet.values = facet.values.filter(function (value, index) {
|
|
66
|
+
return (value.value && value.value.split(facet.hierarchyDelimiter).length > filteredLevel_1) || index == facet.values.length - 1;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
var levels = (fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.levels) || ((_a = facet === null || facet === void 0 ? void 0 : facet.values[(facet === null || facet === void 0 ? void 0 : facet.values.length) - 1]) === null || _a === void 0 ? void 0 : _a.value.split(facet.hierarchyDelimiter));
|
|
70
|
+
levels === null || levels === void 0 ? void 0 : levels.map(function (level, index) {
|
|
71
|
+
var levelConfig = { index: index, label: fieldObj.levels ? level : '', key: "ss-".concat(index) };
|
|
72
|
+
selections.push(new SelectionHierarchy(services, config.id, facet, levelConfig, loading, storage));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
selections.push(new Selection(services, config.id, facet, fieldObj, loading, storage));
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
_this = _super.apply(this, selections) || this;
|
|
80
|
+
return _this;
|
|
81
|
+
}
|
|
82
|
+
Object.defineProperty(SelectionStore, Symbol.species, {
|
|
83
|
+
get: function () {
|
|
84
|
+
return Array;
|
|
85
|
+
},
|
|
86
|
+
enumerable: false,
|
|
87
|
+
configurable: true
|
|
88
|
+
});
|
|
89
|
+
return SelectionStore;
|
|
90
|
+
}(Array));
|
|
91
|
+
exports.SelectionStore = SelectionStore;
|
|
92
|
+
var SelectionBase = /** @class */ (function () {
|
|
93
|
+
function SelectionBase(services, id, facet, selectionConfig, loading, storageStore) {
|
|
94
|
+
this.filtered = false;
|
|
95
|
+
this.collapsed = false;
|
|
96
|
+
this.display = '';
|
|
97
|
+
this.disabled = false;
|
|
98
|
+
this.selected = '';
|
|
99
|
+
this.custom = {};
|
|
100
|
+
this.services = services;
|
|
101
|
+
this.loading = loading;
|
|
102
|
+
this.id = id;
|
|
103
|
+
this.config = selectionConfig;
|
|
104
|
+
// inherit all standard facet properties
|
|
105
|
+
this.type = facet.type;
|
|
106
|
+
this.field = facet.field;
|
|
107
|
+
this.filtered = facet.filtered;
|
|
108
|
+
this.collapsed = facet.collapsed;
|
|
109
|
+
this.display = facet.display;
|
|
110
|
+
this.label = facet.label;
|
|
111
|
+
this.multiple = facet.multiple;
|
|
112
|
+
// abstracted StorageStore
|
|
113
|
+
this.storage = {
|
|
114
|
+
key: "ss-finder-".concat(this.id, ".").concat(this.field),
|
|
115
|
+
get: function (key) {
|
|
116
|
+
var path = this.key + (key ? ".".concat(key) : '');
|
|
117
|
+
return storageStore.get(path);
|
|
118
|
+
},
|
|
119
|
+
set: function (key, value) {
|
|
120
|
+
var path = this.key + (key ? ".".concat(key) : '');
|
|
121
|
+
return storageStore.set(path, value);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
Object.defineProperty(SelectionBase.prototype, "values", {
|
|
126
|
+
get: function () {
|
|
127
|
+
var values = __spreadArray([], (this.data || []), true);
|
|
128
|
+
values.unshift({
|
|
129
|
+
filtered: false,
|
|
130
|
+
value: '',
|
|
131
|
+
label: this.config.label || this.label,
|
|
132
|
+
});
|
|
133
|
+
return values;
|
|
134
|
+
},
|
|
135
|
+
enumerable: false,
|
|
136
|
+
configurable: true
|
|
137
|
+
});
|
|
138
|
+
return SelectionBase;
|
|
139
|
+
}());
|
|
140
|
+
var Selection = /** @class */ (function (_super) {
|
|
141
|
+
__extends(Selection, _super);
|
|
142
|
+
function Selection(services, id, facet, config, loading, storageStore) {
|
|
143
|
+
var _this = _super.call(this, services, id, facet, config, loading, storageStore) || this;
|
|
144
|
+
_this.loading = loading;
|
|
145
|
+
_this.storage.set('values', facet.values);
|
|
146
|
+
var storageData = _this.storage.get();
|
|
147
|
+
_this.data = storageData.values;
|
|
148
|
+
// check if any dropdowns have been selected
|
|
149
|
+
_this.disabled = !_this.values.length;
|
|
150
|
+
_this.selected = _this.disabled ? '' : storageData.selected || '';
|
|
151
|
+
return _this;
|
|
152
|
+
}
|
|
153
|
+
Selection.prototype.select = function (value) {
|
|
154
|
+
if (value === void 0) { value = ''; }
|
|
155
|
+
if (this.loading)
|
|
156
|
+
return;
|
|
157
|
+
this.selected = value;
|
|
158
|
+
this.storage.set('selected', value);
|
|
159
|
+
if (!value) {
|
|
160
|
+
this.services.urlManager.remove("filter.".concat(this.field)).go();
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
this.services.urlManager.set("filter.".concat(this.field), value).go();
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
return Selection;
|
|
167
|
+
}(SelectionBase));
|
|
168
|
+
var SelectionHierarchy = /** @class */ (function (_super) {
|
|
169
|
+
__extends(SelectionHierarchy, _super);
|
|
170
|
+
function SelectionHierarchy(services, id, facet, config, loading, storageStore) {
|
|
171
|
+
var _a, _b, _c;
|
|
172
|
+
var _this = _super.call(this, services, id, facet, config, loading, storageStore) || this;
|
|
173
|
+
// inherit additional facet properties
|
|
174
|
+
_this.hierarchyDelimiter = facet.hierarchyDelimiter;
|
|
175
|
+
var storageData = _this.storage.get();
|
|
176
|
+
if (!storageData) {
|
|
177
|
+
// nothing in storage - initial state for first dropdown
|
|
178
|
+
_this.storage.set("".concat(_this.config.key, ".values"), facet.values);
|
|
179
|
+
storageData = _this.storage.get();
|
|
180
|
+
}
|
|
181
|
+
else if ((_a = storageData[_this.config.key]) === null || _a === void 0 ? void 0 : _a.values) {
|
|
182
|
+
// set selected from storage
|
|
183
|
+
_this.selected = ((_b = storageData[_this.config.key]) === null || _b === void 0 ? void 0 : _b.selected) || '';
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
// value does not exist in storage
|
|
187
|
+
var storedLevels_1 = _this.storage.get();
|
|
188
|
+
var levels = Object.keys(storedLevels_1).map(function (a, index) { return "ss-".concat(index); });
|
|
189
|
+
!levels.includes(_this.config.key) && levels.push(_this.config.key);
|
|
190
|
+
var selectedLevels = Object.keys(storedLevels_1).filter(function (key) { return storedLevels_1[key].selected; });
|
|
191
|
+
var lastSelected = selectedLevels[selectedLevels.length - 1];
|
|
192
|
+
var labelIndex = levels.indexOf(_this.config.key);
|
|
193
|
+
var lastSelectedIndex = levels.indexOf(lastSelected);
|
|
194
|
+
if (lastSelectedIndex != -1 && labelIndex == lastSelectedIndex + 1) {
|
|
195
|
+
_this.storage.set("".concat(_this.config.key, ".values"), facet.values);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
_this.disabled = true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
_this.data = ((_c = storageData[_this.config.key]) === null || _c === void 0 ? void 0 : _c.values) || [];
|
|
202
|
+
return _this;
|
|
203
|
+
}
|
|
204
|
+
SelectionHierarchy.prototype.select = function (value) {
|
|
205
|
+
var _this = this;
|
|
206
|
+
if (value === void 0) { value = ''; }
|
|
207
|
+
if (this.loading)
|
|
208
|
+
return;
|
|
209
|
+
this.selected = value;
|
|
210
|
+
var selectedLevel = this.config.index;
|
|
211
|
+
var storedLevels = this.storage.get();
|
|
212
|
+
var keysToRemove = Object.keys(storedLevels).slice(selectedLevel);
|
|
213
|
+
Object.keys(storedLevels)
|
|
214
|
+
.reverse()
|
|
215
|
+
.forEach(function (key) {
|
|
216
|
+
if (key == _this.config.key) {
|
|
217
|
+
_this.storage.set("".concat(key, ".selected"), value);
|
|
218
|
+
}
|
|
219
|
+
else if (keysToRemove.includes(key)) {
|
|
220
|
+
_this.storage.set("".concat(key), {});
|
|
221
|
+
}
|
|
222
|
+
value = value || _this.storage.get("".concat(key, ".selected"));
|
|
223
|
+
});
|
|
224
|
+
if (!value) {
|
|
225
|
+
this.services.urlManager.remove("filter.".concat(this.field)).go();
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
this.services.urlManager.set("filter.".concat(this.field), value).go();
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
return SelectionHierarchy;
|
|
232
|
+
}(SelectionBase));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Finder/Stores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SelectionStore = void 0;
|
|
4
|
+
var SelectionStore_1 = require("./SelectionStore");
|
|
5
|
+
Object.defineProperty(exports, "SelectionStore", { enumerable: true, get: function () { return SelectionStore_1.SelectionStore; } });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AbstractStore } from '../Abstract/AbstractStore';
|
|
2
|
+
import { ResultStore } from '../Search/Stores';
|
|
3
|
+
import { ProfileStore } from './Stores';
|
|
4
|
+
import type { RecommendationStoreConfig, StoreServices } from '../types';
|
|
5
|
+
export declare class RecommendationStore extends AbstractStore {
|
|
6
|
+
services: StoreServices;
|
|
7
|
+
loaded: boolean;
|
|
8
|
+
profile: ProfileStore;
|
|
9
|
+
results: ResultStore;
|
|
10
|
+
constructor(config: RecommendationStoreConfig, services: StoreServices);
|
|
11
|
+
reset(): void;
|
|
12
|
+
update(data: any): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=RecommendationStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecommendationStore.d.ts","sourceRoot":"","sources":["../../../src/Recommendation/RecommendationStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzE,qBAAa,mBAAoB,SAAQ,aAAa;IACrD,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,UAAS;IACf,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,WAAW,CAAC;gBAET,MAAM,EAAE,yBAAyB,EAAE,QAAQ,EAAE,aAAa;IAiBtE,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,IAAI,KAAA,GAAG,IAAI;CAMlB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.RecommendationStore = void 0;
|
|
19
|
+
var mobx_1 = require("mobx");
|
|
20
|
+
var AbstractStore_1 = require("../Abstract/AbstractStore");
|
|
21
|
+
var Stores_1 = require("../Search/Stores");
|
|
22
|
+
var Stores_2 = require("./Stores");
|
|
23
|
+
var RecommendationStore = /** @class */ (function (_super) {
|
|
24
|
+
__extends(RecommendationStore, _super);
|
|
25
|
+
function RecommendationStore(config, services) {
|
|
26
|
+
var _a;
|
|
27
|
+
var _this = _super.call(this, config) || this;
|
|
28
|
+
_this.loaded = false;
|
|
29
|
+
if (typeof services != 'object' || typeof ((_a = services.urlManager) === null || _a === void 0 ? void 0 : _a.subscribe) != 'function') {
|
|
30
|
+
throw new Error("Invalid service 'urlManager' passed to AutocompleteStore. Missing \"subscribe\" function.");
|
|
31
|
+
}
|
|
32
|
+
_this.services = services;
|
|
33
|
+
_this.reset();
|
|
34
|
+
(0, mobx_1.makeObservable)(_this, {
|
|
35
|
+
profile: mobx_1.observable,
|
|
36
|
+
results: mobx_1.observable,
|
|
37
|
+
});
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
RecommendationStore.prototype.reset = function () {
|
|
41
|
+
this.update({});
|
|
42
|
+
};
|
|
43
|
+
RecommendationStore.prototype.update = function (data) {
|
|
44
|
+
this.error = undefined;
|
|
45
|
+
this.loaded = !!data.profile;
|
|
46
|
+
this.profile = new Stores_2.ProfileStore(this.services, data.profile);
|
|
47
|
+
this.results = new Stores_1.ResultStore(this.config, this.services, data.results);
|
|
48
|
+
};
|
|
49
|
+
return RecommendationStore;
|
|
50
|
+
}(AbstractStore_1.AbstractStore));
|
|
51
|
+
exports.RecommendationStore = RecommendationStore;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProfileStore.d.ts","sourceRoot":"","sources":["../../../../src/Recommendation/Stores/ProfileStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,qBAAa,YAAY;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;gBAEtB,QAAQ,EAAE,aAAa,EAAE,OAAO,KAAA;CAe5C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProfileStore = void 0;
|
|
4
|
+
var mobx_1 = require("mobx");
|
|
5
|
+
var ProfileStore = /** @class */ (function () {
|
|
6
|
+
function ProfileStore(services, profile) {
|
|
7
|
+
this.display = {};
|
|
8
|
+
if (!(profile === null || profile === void 0 ? void 0 : profile.tag)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
this.tag = profile.tag;
|
|
12
|
+
this.placement = profile.placement;
|
|
13
|
+
this.display = profile.display;
|
|
14
|
+
(0, mobx_1.makeObservable)(this, {
|
|
15
|
+
tag: mobx_1.observable,
|
|
16
|
+
placement: mobx_1.observable,
|
|
17
|
+
display: mobx_1.observable,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return ProfileStore;
|
|
21
|
+
}());
|
|
22
|
+
exports.ProfileStore = ProfileStore;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Recommendation/Stores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProfileStore = void 0;
|
|
4
|
+
var ProfileStore_1 = require("./ProfileStore");
|
|
5
|
+
Object.defineProperty(exports, "ProfileStore", { enumerable: true, get: function () { return ProfileStore_1.ProfileStore; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SearchResponseModel, MetaResponseModel } from '@searchspring/snapi-types';
|
|
2
|
+
import type { SearchStoreConfig, StoreServices } from '../types';
|
|
3
|
+
import { MerchandisingStore, FacetStore, FilterStore, ResultStore, PaginationStore, SortingStore, QueryStore } from './Stores';
|
|
4
|
+
import { AbstractStore } from '../Abstract/AbstractStore';
|
|
5
|
+
import { StorageStore } from '../Storage/StorageStore';
|
|
6
|
+
export declare class SearchStore extends AbstractStore {
|
|
7
|
+
config: SearchStoreConfig;
|
|
8
|
+
services: StoreServices;
|
|
9
|
+
data: SearchResponseModel & {
|
|
10
|
+
meta: MetaResponseModel;
|
|
11
|
+
};
|
|
12
|
+
meta: MetaResponseModel;
|
|
13
|
+
merchandising: MerchandisingStore;
|
|
14
|
+
search: QueryStore;
|
|
15
|
+
facets: FacetStore;
|
|
16
|
+
filters: FilterStore;
|
|
17
|
+
results: ResultStore;
|
|
18
|
+
pagination: PaginationStore;
|
|
19
|
+
sorting: SortingStore;
|
|
20
|
+
storage: StorageStore;
|
|
21
|
+
constructor(config: SearchStoreConfig, services: StoreServices);
|
|
22
|
+
update(data: SearchResponseModel & {
|
|
23
|
+
meta: MetaResponseModel;
|
|
24
|
+
}): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=SearchStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchStore.d.ts","sourceRoot":"","sources":["../../../src/Search/SearchStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC/H,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,WAAY,SAAQ,aAAa;IAC7C,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,aAAa,CAAC;IACjB,IAAI,EAAE,mBAAmB,GAAG;QAAE,IAAI,EAAE,iBAAiB,CAAA;KAAE,CAAC;IACxD,IAAI,EAAE,iBAAiB,CAAM;IAC7B,aAAa,EAAE,kBAAkB,CAAC;IAClC,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;IACrB,UAAU,EAAE,eAAe,CAAC;IAC5B,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,YAAY,CAAC;gBAEjB,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa;IAuB9D,MAAM,CAAC,IAAI,EAAE,mBAAmB,GAAG;QAAE,IAAI,EAAE,iBAAiB,CAAA;KAAE,GAAG,IAAI;CAarE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.SearchStore = void 0;
|
|
19
|
+
var mobx_1 = require("mobx");
|
|
20
|
+
var Stores_1 = require("./Stores");
|
|
21
|
+
var AbstractStore_1 = require("../Abstract/AbstractStore");
|
|
22
|
+
var StorageStore_1 = require("../Storage/StorageStore");
|
|
23
|
+
var SearchStore = /** @class */ (function (_super) {
|
|
24
|
+
__extends(SearchStore, _super);
|
|
25
|
+
function SearchStore(config, services) {
|
|
26
|
+
var _a;
|
|
27
|
+
var _this = _super.call(this, config) || this;
|
|
28
|
+
_this.meta = {};
|
|
29
|
+
if (typeof services != 'object' || typeof ((_a = services.urlManager) === null || _a === void 0 ? void 0 : _a.subscribe) != 'function') {
|
|
30
|
+
throw new Error("Invalid service 'urlManager' passed to SearchStore. Missing \"subscribe\" function.");
|
|
31
|
+
}
|
|
32
|
+
_this.services = services;
|
|
33
|
+
_this.storage = new StorageStore_1.StorageStore();
|
|
34
|
+
_this.update({ meta: _this.meta });
|
|
35
|
+
(0, mobx_1.makeObservable)(_this, {
|
|
36
|
+
search: mobx_1.observable,
|
|
37
|
+
merchandising: mobx_1.observable,
|
|
38
|
+
facets: mobx_1.observable,
|
|
39
|
+
filters: mobx_1.observable,
|
|
40
|
+
results: mobx_1.observable,
|
|
41
|
+
pagination: mobx_1.observable,
|
|
42
|
+
sorting: mobx_1.observable,
|
|
43
|
+
});
|
|
44
|
+
return _this;
|
|
45
|
+
}
|
|
46
|
+
SearchStore.prototype.update = function (data) {
|
|
47
|
+
this.error = undefined;
|
|
48
|
+
this.data = JSON.parse(JSON.stringify(data));
|
|
49
|
+
this.loaded = !!data.pagination;
|
|
50
|
+
this.meta = data.meta;
|
|
51
|
+
this.merchandising = new Stores_1.MerchandisingStore(this.services, data.merchandising);
|
|
52
|
+
this.search = new Stores_1.QueryStore(this.services, data.search);
|
|
53
|
+
this.facets = new Stores_1.FacetStore(this.config, this.services, this.storage, data.facets, data.pagination, this.meta);
|
|
54
|
+
this.filters = new Stores_1.FilterStore(this.services, data.filters, this.meta);
|
|
55
|
+
this.results = new Stores_1.ResultStore(this.config, this.services, data.results, data.pagination, data.merchandising);
|
|
56
|
+
this.pagination = new Stores_1.PaginationStore(this.config, this.services, data.pagination);
|
|
57
|
+
this.sorting = new Stores_1.SortingStore(this.services, data.sorting, data.search, this.meta);
|
|
58
|
+
};
|
|
59
|
+
return SearchStore;
|
|
60
|
+
}(AbstractStore_1.AbstractStore));
|
|
61
|
+
exports.SearchStore = SearchStore;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StorageStore } from '../../Storage/StorageStore';
|
|
2
|
+
import type { AutocompleteStoreConfig, SearchStoreConfig, StoreServices } from '../../types';
|
|
3
|
+
import type { MetaResponseModel, SearchResponseModelPagination, SearchResponseModelFacet } from '@searchspring/snapi-types';
|
|
4
|
+
export declare class FacetStore extends Array {
|
|
5
|
+
static get [Symbol.species](): ArrayConstructor;
|
|
6
|
+
constructor(config: SearchStoreConfig | AutocompleteStoreConfig, services: StoreServices, storage: StorageStore, facetsData: SearchResponseModelFacet[], pagination: SearchResponseModelPagination, meta: MetaResponseModel);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=FacetStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FacetStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/FacetStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,KAAK,EACX,iBAAiB,EAMjB,6BAA6B,EAC7B,wBAAwB,EAMxB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,UAAW,SAAQ,KAAK;IACpC,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAE9C;gBAEA,MAAM,EAAE,iBAAiB,GAAG,uBAAuB,EACnD,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,wBAAwB,EAAO,EAC3C,UAAU,EAAE,6BAA6B,EACzC,IAAI,EAAE,iBAAiB;CAsCxB"}
|