@searchspring/snap-store-mobx 0.27.7 → 0.29.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/Abstract/AbstractStore.d.ts +3 -4
- package/dist/cjs/Abstract/AbstractStore.d.ts.map +1 -1
- package/dist/cjs/Abstract/AbstractStore.js +0 -1
- package/dist/cjs/Autocomplete/AutocompleteStore.d.ts +19 -18
- package/dist/cjs/Autocomplete/AutocompleteStore.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/AutocompleteStore.js +20 -19
- package/dist/cjs/Autocomplete/Stores/{FacetStore.d.ts → AutocompleteFacetStore.d.ts} +4 -4
- package/dist/cjs/Autocomplete/Stores/AutocompleteFacetStore.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/Stores/{FacetStore.js → AutocompleteFacetStore.js} +8 -8
- package/dist/{esm/Autocomplete/Stores/QueryStore.d.ts → cjs/Autocomplete/Stores/AutocompleteQueryStore.d.ts} +5 -5
- package/dist/cjs/Autocomplete/Stores/AutocompleteQueryStore.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/Stores/{QueryStore.js → AutocompleteQueryStore.js} +6 -6
- package/dist/{esm/Autocomplete/Stores/StateStore.d.ts → cjs/Autocomplete/Stores/AutocompleteStateStore.d.ts} +3 -3
- package/dist/cjs/Autocomplete/Stores/AutocompleteStateStore.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/Stores/{StateStore.js → AutocompleteStateStore.js} +6 -6
- package/dist/{esm/Autocomplete/Stores/TermStore.d.ts → cjs/Autocomplete/Stores/AutocompleteTermStore.d.ts} +5 -5
- package/dist/cjs/Autocomplete/Stores/AutocompleteTermStore.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/Stores/{TermStore.js → AutocompleteTermStore.js} +7 -7
- package/dist/cjs/Autocomplete/Stores/AutocompleteTrendingStore.d.ts +9 -0
- package/dist/cjs/Autocomplete/Stores/AutocompleteTrendingStore.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/Stores/{TrendingStore.js → AutocompleteTrendingStore.js} +11 -11
- package/dist/cjs/Autocomplete/Stores/index.d.ts +5 -5
- package/dist/cjs/Autocomplete/Stores/index.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/Stores/index.js +11 -11
- package/dist/cjs/Finder/FinderStore.d.ts +6 -5
- package/dist/cjs/Finder/FinderStore.d.ts.map +1 -1
- package/dist/cjs/Finder/FinderStore.js +9 -9
- package/dist/cjs/Finder/Stores/FinderSelectionStore.d.ts +56 -0
- package/dist/cjs/Finder/Stores/FinderSelectionStore.d.ts.map +1 -0
- package/dist/cjs/Finder/Stores/{SelectionStore.js → FinderSelectionStore.js} +17 -16
- package/dist/cjs/Finder/Stores/index.d.ts +1 -1
- package/dist/cjs/Finder/Stores/index.d.ts.map +1 -1
- package/dist/cjs/Finder/Stores/index.js +3 -3
- package/dist/cjs/Recommendation/RecommendationStore.d.ts +6 -5
- package/dist/cjs/Recommendation/RecommendationStore.d.ts.map +1 -1
- package/dist/cjs/Recommendation/RecommendationStore.js +4 -4
- package/dist/cjs/Recommendation/Stores/RecommendationProfileStore.d.ts +9 -0
- package/dist/cjs/Recommendation/Stores/RecommendationProfileStore.d.ts.map +1 -0
- package/dist/cjs/Recommendation/Stores/RecommendationProfileStore.js +23 -0
- package/dist/cjs/Recommendation/Stores/index.d.ts +1 -1
- package/dist/cjs/Recommendation/Stores/index.d.ts.map +1 -1
- package/dist/cjs/Recommendation/Stores/index.js +3 -3
- package/dist/cjs/Search/SearchStore.d.ts +11 -11
- package/dist/cjs/Search/SearchStore.d.ts.map +1 -1
- package/dist/cjs/Search/SearchStore.js +26 -10
- package/dist/cjs/Search/Stores/SearchFacetStore.d.ts +76 -0
- package/dist/cjs/Search/Stores/SearchFacetStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/{FacetStore.js → SearchFacetStore.js} +57 -50
- package/dist/cjs/Search/Stores/SearchFilterStore.d.ts +35 -0
- package/dist/cjs/Search/Stores/SearchFilterStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/SearchFilterStore.js +93 -0
- package/dist/cjs/Search/Stores/SearchMerchandisingStore.d.ts +21 -0
- package/dist/cjs/Search/Stores/SearchMerchandisingStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/{MerchandisingStore.js → SearchMerchandisingStore.js} +7 -7
- package/dist/cjs/Search/Stores/{PaginationStore.d.ts → SearchPaginationStore.d.ts} +5 -6
- package/dist/cjs/Search/Stores/SearchPaginationStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/{PaginationStore.js → SearchPaginationStore.js} +17 -16
- package/dist/cjs/Search/Stores/{QueryStore.d.ts → SearchQueryStore.d.ts} +6 -6
- package/dist/cjs/Search/Stores/SearchQueryStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/{QueryStore.js → SearchQueryStore.js} +5 -5
- package/dist/cjs/Search/Stores/SearchResultStore.d.ts +34 -0
- package/dist/cjs/Search/Stores/SearchResultStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/{ResultStore.js → SearchResultStore.js} +10 -8
- package/dist/cjs/Search/Stores/SearchSortingStore.d.ts +25 -0
- package/dist/cjs/Search/Stores/SearchSortingStore.d.ts.map +1 -0
- package/dist/cjs/Search/Stores/{SortingStore.js → SearchSortingStore.js} +10 -11
- package/dist/cjs/Search/Stores/index.d.ts +7 -7
- package/dist/cjs/Search/Stores/index.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/index.js +24 -15
- package/dist/cjs/Storage/StorageStore.d.ts +6 -6
- package/dist/cjs/Storage/StorageStore.d.ts.map +1 -1
- package/dist/cjs/Storage/StorageStore.js +7 -5
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/types.d.ts +3 -3
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/Abstract/AbstractStore.d.ts +3 -4
- package/dist/esm/Abstract/AbstractStore.d.ts.map +1 -1
- package/dist/esm/Abstract/AbstractStore.js +0 -1
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts +19 -18
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts.map +1 -1
- package/dist/esm/Autocomplete/AutocompleteStore.js +21 -22
- package/dist/esm/Autocomplete/Stores/{FacetStore.d.ts → AutocompleteFacetStore.d.ts} +4 -4
- package/dist/esm/Autocomplete/Stores/AutocompleteFacetStore.d.ts.map +1 -0
- package/dist/esm/Autocomplete/Stores/{FacetStore.js → AutocompleteFacetStore.js} +2 -2
- package/dist/{cjs/Autocomplete/Stores/QueryStore.d.ts → esm/Autocomplete/Stores/AutocompleteQueryStore.d.ts} +5 -5
- package/dist/esm/Autocomplete/Stores/AutocompleteQueryStore.d.ts.map +1 -0
- package/dist/esm/Autocomplete/Stores/{QueryStore.js → AutocompleteQueryStore.js} +2 -2
- package/dist/{cjs/Autocomplete/Stores/StateStore.d.ts → esm/Autocomplete/Stores/AutocompleteStateStore.d.ts} +3 -3
- package/dist/esm/Autocomplete/Stores/AutocompleteStateStore.d.ts.map +1 -0
- package/dist/esm/Autocomplete/Stores/{StateStore.js → AutocompleteStateStore.js} +1 -1
- package/dist/{cjs/Autocomplete/Stores/TermStore.d.ts → esm/Autocomplete/Stores/AutocompleteTermStore.d.ts} +5 -5
- package/dist/esm/Autocomplete/Stores/AutocompleteTermStore.d.ts.map +1 -0
- package/dist/esm/Autocomplete/Stores/{TermStore.js → AutocompleteTermStore.js} +1 -1
- package/dist/esm/Autocomplete/Stores/AutocompleteTrendingStore.d.ts +9 -0
- package/dist/esm/Autocomplete/Stores/AutocompleteTrendingStore.d.ts.map +1 -0
- package/dist/esm/Autocomplete/Stores/{TrendingStore.js → AutocompleteTrendingStore.js} +3 -3
- package/dist/esm/Autocomplete/Stores/index.d.ts +5 -5
- package/dist/esm/Autocomplete/Stores/index.d.ts.map +1 -1
- package/dist/esm/Autocomplete/Stores/index.js +5 -5
- package/dist/esm/Finder/FinderStore.d.ts +6 -5
- package/dist/esm/Finder/FinderStore.d.ts.map +1 -1
- package/dist/esm/Finder/FinderStore.js +9 -9
- package/dist/esm/Finder/Stores/FinderSelectionStore.d.ts +60 -0
- package/dist/esm/Finder/Stores/FinderSelectionStore.d.ts.map +1 -0
- package/dist/esm/Finder/Stores/{SelectionStore.js → FinderSelectionStore.js} +9 -9
- package/dist/esm/Finder/Stores/index.d.ts +1 -1
- package/dist/esm/Finder/Stores/index.d.ts.map +1 -1
- package/dist/esm/Finder/Stores/index.js +1 -1
- package/dist/esm/Recommendation/RecommendationStore.d.ts +6 -5
- package/dist/esm/Recommendation/RecommendationStore.d.ts.map +1 -1
- package/dist/esm/Recommendation/RecommendationStore.js +6 -6
- package/dist/esm/Recommendation/Stores/RecommendationProfileStore.d.ts +9 -0
- package/dist/esm/Recommendation/Stores/RecommendationProfileStore.d.ts.map +1 -0
- package/dist/esm/Recommendation/Stores/{ProfileStore.js → RecommendationProfileStore.js} +6 -6
- package/dist/esm/Recommendation/Stores/index.d.ts +1 -1
- package/dist/esm/Recommendation/Stores/index.d.ts.map +1 -1
- package/dist/esm/Recommendation/Stores/index.js +1 -1
- package/dist/esm/Search/SearchStore.d.ts +11 -11
- package/dist/esm/Search/SearchStore.d.ts.map +1 -1
- package/dist/esm/Search/SearchStore.js +27 -12
- package/dist/esm/Search/Stores/SearchFacetStore.d.ts +76 -0
- package/dist/esm/Search/Stores/SearchFacetStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/{FacetStore.js → SearchFacetStore.js} +34 -33
- package/dist/esm/Search/Stores/SearchFilterStore.d.ts +35 -0
- package/dist/esm/Search/Stores/SearchFilterStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/SearchFilterStore.js +61 -0
- package/dist/esm/Search/Stores/SearchMerchandisingStore.d.ts +21 -0
- package/dist/esm/Search/Stores/SearchMerchandisingStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/{MerchandisingStore.js → SearchMerchandisingStore.js} +3 -3
- package/dist/esm/Search/Stores/{PaginationStore.d.ts → SearchPaginationStore.d.ts} +5 -6
- package/dist/esm/Search/Stores/SearchPaginationStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/{PaginationStore.js → SearchPaginationStore.js} +3 -3
- package/dist/esm/Search/Stores/{QueryStore.d.ts → SearchQueryStore.d.ts} +6 -6
- package/dist/esm/Search/Stores/SearchQueryStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/{QueryStore.js → SearchQueryStore.js} +1 -1
- package/dist/esm/Search/Stores/SearchResultStore.d.ts +34 -0
- package/dist/esm/Search/Stores/SearchResultStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/{ResultStore.js → SearchResultStore.js} +4 -6
- package/dist/esm/Search/Stores/SearchSortingStore.d.ts +25 -0
- package/dist/esm/Search/Stores/SearchSortingStore.d.ts.map +1 -0
- package/dist/esm/Search/Stores/{SortingStore.js → SearchSortingStore.js} +5 -6
- package/dist/esm/Search/Stores/index.d.ts +7 -7
- package/dist/esm/Search/Stores/index.d.ts.map +1 -1
- package/dist/esm/Search/Stores/index.js +7 -7
- package/dist/esm/Storage/StorageStore.d.ts +6 -6
- package/dist/esm/Storage/StorageStore.d.ts.map +1 -1
- package/dist/esm/Storage/StorageStore.js +7 -5
- 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 +3 -3
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +6 -5
- package/dist/cjs/Autocomplete/Stores/FacetStore.d.ts.map +0 -1
- package/dist/cjs/Autocomplete/Stores/QueryStore.d.ts.map +0 -1
- package/dist/cjs/Autocomplete/Stores/StateStore.d.ts.map +0 -1
- package/dist/cjs/Autocomplete/Stores/TermStore.d.ts.map +0 -1
- package/dist/cjs/Autocomplete/Stores/TrendingStore.d.ts +0 -7
- package/dist/cjs/Autocomplete/Stores/TrendingStore.d.ts.map +0 -1
- package/dist/cjs/Finder/Stores/SelectionStore.d.ts +0 -17
- package/dist/cjs/Finder/Stores/SelectionStore.d.ts.map +0 -1
- package/dist/cjs/Recommendation/Stores/ProfileStore.d.ts +0 -8
- package/dist/cjs/Recommendation/Stores/ProfileStore.d.ts.map +0 -1
- package/dist/cjs/Recommendation/Stores/ProfileStore.js +0 -22
- package/dist/cjs/Search/Stores/FacetStore.d.ts +0 -8
- package/dist/cjs/Search/Stores/FacetStore.d.ts.map +0 -1
- package/dist/cjs/Search/Stores/FilterStore.d.ts +0 -7
- package/dist/cjs/Search/Stores/FilterStore.d.ts.map +0 -1
- package/dist/cjs/Search/Stores/FilterStore.js +0 -96
- package/dist/cjs/Search/Stores/MerchandisingStore.d.ts +0 -20
- package/dist/cjs/Search/Stores/MerchandisingStore.d.ts.map +0 -1
- package/dist/cjs/Search/Stores/PaginationStore.d.ts.map +0 -1
- package/dist/cjs/Search/Stores/QueryStore.d.ts.map +0 -1
- package/dist/cjs/Search/Stores/ResultStore.d.ts +0 -7
- package/dist/cjs/Search/Stores/ResultStore.d.ts.map +0 -1
- package/dist/cjs/Search/Stores/SortingStore.d.ts +0 -21
- package/dist/cjs/Search/Stores/SortingStore.d.ts.map +0 -1
- package/dist/esm/Autocomplete/Stores/FacetStore.d.ts.map +0 -1
- package/dist/esm/Autocomplete/Stores/QueryStore.d.ts.map +0 -1
- package/dist/esm/Autocomplete/Stores/StateStore.d.ts.map +0 -1
- package/dist/esm/Autocomplete/Stores/TermStore.d.ts.map +0 -1
- package/dist/esm/Autocomplete/Stores/TrendingStore.d.ts +0 -7
- package/dist/esm/Autocomplete/Stores/TrendingStore.d.ts.map +0 -1
- package/dist/esm/Finder/Stores/SelectionStore.d.ts +0 -17
- package/dist/esm/Finder/Stores/SelectionStore.d.ts.map +0 -1
- package/dist/esm/Recommendation/Stores/ProfileStore.d.ts +0 -8
- package/dist/esm/Recommendation/Stores/ProfileStore.d.ts.map +0 -1
- package/dist/esm/Search/Stores/FacetStore.d.ts +0 -8
- package/dist/esm/Search/Stores/FacetStore.d.ts.map +0 -1
- package/dist/esm/Search/Stores/FilterStore.d.ts +0 -7
- package/dist/esm/Search/Stores/FilterStore.d.ts.map +0 -1
- package/dist/esm/Search/Stores/FilterStore.js +0 -68
- package/dist/esm/Search/Stores/MerchandisingStore.d.ts +0 -20
- package/dist/esm/Search/Stores/MerchandisingStore.d.ts.map +0 -1
- package/dist/esm/Search/Stores/PaginationStore.d.ts.map +0 -1
- package/dist/esm/Search/Stores/QueryStore.d.ts.map +0 -1
- package/dist/esm/Search/Stores/ResultStore.d.ts +0 -7
- package/dist/esm/Search/Stores/ResultStore.d.ts.map +0 -1
- package/dist/esm/Search/Stores/SortingStore.d.ts +0 -21
- package/dist/esm/Search/Stores/SortingStore.d.ts.map +0 -1
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { makeObservable, observable } from 'mobx';
|
|
2
|
-
import {
|
|
2
|
+
import { SearchMerchandisingStore, SearchFacetStore, SearchFilterStore, SearchResultStore, SearchPaginationStore, SearchSortingStore, SearchQueryStore, } from './Stores';
|
|
3
3
|
import { AbstractStore } from '../Abstract/AbstractStore';
|
|
4
4
|
import { StorageStore } from '../Storage/StorageStore';
|
|
5
5
|
export class SearchStore extends AbstractStore {
|
|
6
6
|
constructor(config, services) {
|
|
7
7
|
super(config);
|
|
8
|
-
this.meta = {};
|
|
9
8
|
if (typeof services != 'object' || typeof services.urlManager?.subscribe != 'function') {
|
|
10
9
|
throw new Error(`Invalid service 'urlManager' passed to SearchStore. Missing "subscribe" function.`);
|
|
11
10
|
}
|
|
12
11
|
this.services = services;
|
|
13
12
|
this.storage = new StorageStore();
|
|
14
|
-
this.update(
|
|
13
|
+
this.update();
|
|
15
14
|
makeObservable(this, {
|
|
16
15
|
search: observable,
|
|
17
16
|
merchandising: observable,
|
|
@@ -22,17 +21,33 @@ export class SearchStore extends AbstractStore {
|
|
|
22
21
|
sorting: observable,
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
|
-
|
|
24
|
+
/*
|
|
25
|
+
TODO: refactor sub-store interfaces
|
|
26
|
+
|
|
27
|
+
interface StoreParameters {
|
|
28
|
+
config?: StoreConfigs;
|
|
29
|
+
services?: StoreServices;
|
|
30
|
+
stores?: {
|
|
31
|
+
storage?: StorageStore;
|
|
32
|
+
state?: StateStore;
|
|
33
|
+
};
|
|
34
|
+
data?: SearchResponseModel & { meta: MetaResponseModel };
|
|
35
|
+
}
|
|
36
|
+
*/
|
|
37
|
+
reset() {
|
|
38
|
+
this.update();
|
|
39
|
+
}
|
|
40
|
+
update(data = {}) {
|
|
26
41
|
this.error = undefined;
|
|
27
42
|
this.data = JSON.parse(JSON.stringify(data));
|
|
28
43
|
this.loaded = !!data.pagination;
|
|
29
|
-
this.meta = data.meta;
|
|
30
|
-
this.merchandising = new
|
|
31
|
-
this.search = new
|
|
32
|
-
this.facets = new
|
|
33
|
-
this.filters = new
|
|
34
|
-
this.results = new
|
|
35
|
-
this.pagination = new
|
|
36
|
-
this.sorting = new
|
|
44
|
+
this.meta = data.meta || {};
|
|
45
|
+
this.merchandising = new SearchMerchandisingStore(this.services, data?.merchandising || {});
|
|
46
|
+
this.search = new SearchQueryStore(this.services, data?.search || {});
|
|
47
|
+
this.facets = new SearchFacetStore(this.config, this.services, this.storage, data.facets, data?.pagination || {}, this.meta);
|
|
48
|
+
this.filters = new SearchFilterStore(this.services, data.filters, this.meta);
|
|
49
|
+
this.results = new SearchResultStore(this.config, this.services, data?.results || [], data.pagination, data.merchandising);
|
|
50
|
+
this.pagination = new SearchPaginationStore(this.config, this.services, data.pagination);
|
|
51
|
+
this.sorting = new SearchSortingStore(this.services, data?.sorting || [], data?.search || {}, this.meta);
|
|
37
52
|
}
|
|
38
53
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { UrlManager } from '@searchspring/snap-url-manager';
|
|
2
|
+
import type { StorageStore } from '../../Storage/StorageStore';
|
|
3
|
+
import type { AutocompleteStoreConfig, SearchStoreConfig, StoreServices } from '../../types';
|
|
4
|
+
import type { MetaResponseModel, MetaResponseModelFacet, MetaResponseModelFacetSlider, MetaResponseModelFacetValueMultipleEnum, MetaResponseModelFacetHierarchyAllOf, SearchResponseModelPagination, SearchResponseModelFacet, SearchResponseModelFacetRange, SearchResponseModelFacetValue, SearchResponseModelFacetValueAllOfValues, SearchRequestModelFilterRangeAllOfValue } from '@searchspring/snapi-types';
|
|
5
|
+
export declare class SearchFacetStore extends Array {
|
|
6
|
+
static get [Symbol.species](): ArrayConstructor;
|
|
7
|
+
constructor(config: SearchStoreConfig | AutocompleteStoreConfig, services: StoreServices, storage: StorageStore, facetsData: SearchResponseModelFacet[] | undefined, pagination: SearchResponseModelPagination | undefined, meta: MetaResponseModel);
|
|
8
|
+
}
|
|
9
|
+
export declare class Facet {
|
|
10
|
+
services: StoreServices;
|
|
11
|
+
type: string;
|
|
12
|
+
field: string;
|
|
13
|
+
filtered: boolean;
|
|
14
|
+
custom: {};
|
|
15
|
+
collapsed: boolean;
|
|
16
|
+
display: string;
|
|
17
|
+
label: string;
|
|
18
|
+
storage: StorageStore;
|
|
19
|
+
constructor(services: StoreServices, storage: StorageStore, facet: SearchResponseModelFacetValue | SearchResponseModelFacetRange, facetMeta: MetaResponseModelFacet);
|
|
20
|
+
get clear(): {
|
|
21
|
+
url: UrlManager;
|
|
22
|
+
};
|
|
23
|
+
toggleCollapse(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare class RangeFacet extends Facet {
|
|
26
|
+
step?: number;
|
|
27
|
+
range?: SearchRequestModelFilterRangeAllOfValue;
|
|
28
|
+
active?: SearchRequestModelFilterRangeAllOfValue;
|
|
29
|
+
formatSeparator: string;
|
|
30
|
+
formatValue: string;
|
|
31
|
+
constructor(config: SearchStoreConfig | AutocompleteStoreConfig, services: StoreServices, storage: StorageStore, facet: SearchResponseModelFacetRange, facetMeta: MetaResponseModelFacetSlider);
|
|
32
|
+
}
|
|
33
|
+
export declare class ValueFacet extends Facet {
|
|
34
|
+
values: Array<FacetHierarchyValue | FacetValue | FacetRangeValue | undefined>;
|
|
35
|
+
search: {
|
|
36
|
+
input: string;
|
|
37
|
+
};
|
|
38
|
+
multiple: MetaResponseModelFacetValueMultipleEnum;
|
|
39
|
+
overflow: {
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
limited: boolean;
|
|
42
|
+
limit: number;
|
|
43
|
+
remaining: number | undefined;
|
|
44
|
+
setLimit: (limit: number) => void;
|
|
45
|
+
toggle: (val?: boolean) => void;
|
|
46
|
+
calculate: () => void;
|
|
47
|
+
};
|
|
48
|
+
constructor(config: SearchStoreConfig | AutocompleteStoreConfig, services: StoreServices, storage: StorageStore, facet: SearchResponseModelFacetValue, facetMeta: MetaResponseModelFacet);
|
|
49
|
+
get refinedValues(): (FacetHierarchyValue | FacetValue | FacetRangeValue | undefined)[];
|
|
50
|
+
}
|
|
51
|
+
export declare class FacetValue {
|
|
52
|
+
label: string;
|
|
53
|
+
count: number;
|
|
54
|
+
filtered: boolean;
|
|
55
|
+
value: string;
|
|
56
|
+
custom: {};
|
|
57
|
+
url: UrlManager;
|
|
58
|
+
preview?: () => void;
|
|
59
|
+
constructor(services: StoreServices, facet: ValueFacet, value: SearchResponseModelFacetValueAllOfValues);
|
|
60
|
+
}
|
|
61
|
+
export declare class FacetHierarchyValue extends FacetValue {
|
|
62
|
+
level: number;
|
|
63
|
+
history: boolean;
|
|
64
|
+
constructor(services: StoreServices, facet: ValueFacet & MetaResponseModelFacetHierarchyAllOf, value: SearchResponseModelFacetValueAllOfValues, filteredValues: SearchResponseModelFacetValueAllOfValues[]);
|
|
65
|
+
}
|
|
66
|
+
export declare class FacetRangeValue {
|
|
67
|
+
label: string;
|
|
68
|
+
count: number;
|
|
69
|
+
filtered: boolean;
|
|
70
|
+
low: number;
|
|
71
|
+
high: number;
|
|
72
|
+
custom: {};
|
|
73
|
+
url: UrlManager;
|
|
74
|
+
constructor(services: StoreServices, facet: ValueFacet, value: SearchResponseModelFacetValueAllOfValues);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=SearchFacetStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchFacetStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/SearchFacetStore.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { makeObservable, observable, action, computed, reaction } from 'mobx';
|
|
2
|
-
export class
|
|
2
|
+
export class SearchFacetStore extends Array {
|
|
3
3
|
static get [Symbol.species]() {
|
|
4
4
|
return Array;
|
|
5
5
|
}
|
|
6
|
-
constructor(config, services, storage, facetsData = [], pagination, meta) {
|
|
6
|
+
constructor(config, services, storage, facetsData = [], pagination = {}, meta) {
|
|
7
7
|
const facets = facetsData
|
|
8
8
|
.filter((facet) => {
|
|
9
|
-
const facetMeta = meta.facets[facet.field];
|
|
9
|
+
const facetMeta = facet.field && meta.facets && meta.facets[facet.field];
|
|
10
10
|
// exclude facets that have no meta data
|
|
11
11
|
if (!facetMeta)
|
|
12
12
|
return false;
|
|
@@ -15,10 +15,11 @@ export class FacetStore extends Array {
|
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
17
|
// trim facets - remove facets that have no use
|
|
18
|
-
const facetConfig = config.settings?.facets?.fields && config.settings?.facets?.fields[facet.field];
|
|
18
|
+
const facetConfig = config.settings?.facets?.fields && facet.field && config.settings?.facets?.fields[facet.field];
|
|
19
19
|
const shouldTrim = typeof facetConfig?.trim == 'boolean' ? facetConfig.trim : config.settings?.facets?.trim;
|
|
20
20
|
if (shouldTrim) {
|
|
21
|
-
if (facet.type === 'range' &&
|
|
21
|
+
if (facet.type === 'range' &&
|
|
22
|
+
facet?.range?.low == facet?.range?.high) {
|
|
22
23
|
return false;
|
|
23
24
|
}
|
|
24
25
|
else if (facet.values?.length == 0) {
|
|
@@ -31,14 +32,14 @@ export class FacetStore extends Array {
|
|
|
31
32
|
return true;
|
|
32
33
|
})
|
|
33
34
|
.map((facet) => {
|
|
34
|
-
const facetMeta = meta.facets[facet.field];
|
|
35
|
+
const facetMeta = facet.field && meta.facets && meta.facets[facet.field];
|
|
35
36
|
switch (facet.type) {
|
|
36
37
|
case 'range':
|
|
37
|
-
return new RangeFacet(config, services, storage, facet, facetMeta);
|
|
38
|
+
return new RangeFacet(config, services, storage, facet, facetMeta || {});
|
|
38
39
|
case 'value':
|
|
39
40
|
case 'range-buckets':
|
|
40
41
|
default:
|
|
41
|
-
return new ValueFacet(config, services, storage, facet, facetMeta);
|
|
42
|
+
return new ValueFacet(config, services, storage, facet, facetMeta || {});
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
45
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -46,7 +47,7 @@ export class FacetStore extends Array {
|
|
|
46
47
|
super(...facets);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
class Facet {
|
|
50
|
+
export class Facet {
|
|
50
51
|
constructor(services, storage, facet, facetMeta) {
|
|
51
52
|
this.filtered = false;
|
|
52
53
|
this.custom = {};
|
|
@@ -75,7 +76,7 @@ class Facet {
|
|
|
75
76
|
}
|
|
76
77
|
get clear() {
|
|
77
78
|
return {
|
|
78
|
-
url: this.services
|
|
79
|
+
url: this.services.urlManager.remove('page').remove(`filter.${this.field}`),
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
82
|
toggleCollapse() {
|
|
@@ -83,7 +84,7 @@ class Facet {
|
|
|
83
84
|
this.storage.set(`facets.${this.field}.collapsed`, this.collapsed);
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
|
-
class RangeFacet extends Facet {
|
|
87
|
+
export class RangeFacet extends Facet {
|
|
87
88
|
constructor(config, services, storage, facet, facetMeta) {
|
|
88
89
|
super(services, storage, facet, facetMeta);
|
|
89
90
|
this.range = {
|
|
@@ -94,11 +95,11 @@ class RangeFacet extends Facet {
|
|
|
94
95
|
low: 0,
|
|
95
96
|
high: 0,
|
|
96
97
|
};
|
|
97
|
-
this.step = facet
|
|
98
|
-
const facetConfig = config.settings?.facets?.fields && config.settings?.facets?.fields[facet.field];
|
|
98
|
+
this.step = facet?.step;
|
|
99
|
+
const facetConfig = (config.settings?.facets?.fields && facet.field && config.settings?.facets?.fields[facet.field]) || {};
|
|
99
100
|
const shouldStore = typeof facetConfig?.storeRange == 'boolean' ? facetConfig.storeRange : config.settings?.facets?.storeRange;
|
|
100
101
|
const storedRange = shouldStore && this.storage.get(`facets.${this.field}.range`);
|
|
101
|
-
if (storedRange && facet.filtered && (facet.range
|
|
102
|
+
if (storedRange && facet.filtered && (facet.range?.low > storedRange.low || facet.range?.high < storedRange.high)) {
|
|
102
103
|
// range from API has shrunk
|
|
103
104
|
this.range = this.storage.get(`facets.${this.field}.range`);
|
|
104
105
|
}
|
|
@@ -120,7 +121,7 @@ class RangeFacet extends Facet {
|
|
|
120
121
|
});
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
|
-
class ValueFacet extends Facet {
|
|
124
|
+
export class ValueFacet extends Facet {
|
|
124
125
|
constructor(config, services, storage, facet, facetMeta) {
|
|
125
126
|
super(services, storage, facet, facetMeta);
|
|
126
127
|
this.values = [];
|
|
@@ -174,20 +175,20 @@ class ValueFacet extends Facet {
|
|
|
174
175
|
switch (facet.type) {
|
|
175
176
|
case 'value':
|
|
176
177
|
if (facetMeta.display === 'hierarchy') {
|
|
177
|
-
const filteredValues = facet
|
|
178
|
-
return new
|
|
178
|
+
const filteredValues = facet?.values?.filter((value) => value.filtered) || [];
|
|
179
|
+
return new FacetHierarchyValue(services, this, value, filteredValues);
|
|
179
180
|
}
|
|
180
181
|
else {
|
|
181
182
|
// converting values to strings to ensure UrlManager state matches state created from URL
|
|
182
|
-
value.value = value
|
|
183
|
-
return new
|
|
183
|
+
value.value = value?.value?.toString();
|
|
184
|
+
return new FacetValue(services, this, value);
|
|
184
185
|
}
|
|
185
186
|
case 'range-buckets':
|
|
186
|
-
return new
|
|
187
|
+
return new FacetRangeValue(services, this, value);
|
|
187
188
|
}
|
|
188
189
|
})) ||
|
|
189
190
|
[];
|
|
190
|
-
const facetConfig = config.settings?.facets?.fields && config.settings?.facets?.fields[facet.field];
|
|
191
|
+
const facetConfig = (config.settings?.facets?.fields && facet.field && config.settings?.facets?.fields[facet.field]) || {};
|
|
191
192
|
const shouldPin = typeof facetConfig?.pinFiltered == 'boolean' ? facetConfig.pinFiltered : config.settings?.facets?.pinFiltered;
|
|
192
193
|
if (shouldPin && facetMeta.display !== 'hierarchy') {
|
|
193
194
|
this.values.sort((a, b) => Number(b.filtered) - Number(a.filtered));
|
|
@@ -211,7 +212,7 @@ class ValueFacet extends Facet {
|
|
|
211
212
|
let values = this.values || [];
|
|
212
213
|
if (this.search.input) {
|
|
213
214
|
const search = new RegExp(escapeRegExp(this.search.input), 'i');
|
|
214
|
-
values = this.values.filter((value) => String(value
|
|
215
|
+
values = this.values.filter((value) => String(value?.label || '').match(search));
|
|
215
216
|
}
|
|
216
217
|
if (this.overflow.enabled && this.overflow.limited) {
|
|
217
218
|
values = values.slice(0, this.overflow.limit);
|
|
@@ -219,14 +220,14 @@ class ValueFacet extends Facet {
|
|
|
219
220
|
return values;
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
|
-
class
|
|
223
|
+
export class FacetValue {
|
|
223
224
|
constructor(services, facet, value) {
|
|
224
225
|
Object.assign(this, value);
|
|
225
226
|
if (this.filtered) {
|
|
226
|
-
this.url = services.urlManager
|
|
227
|
+
this.url = services.urlManager.remove('page').remove(`filter.${facet.field}`, value.value);
|
|
227
228
|
}
|
|
228
229
|
else {
|
|
229
|
-
let valueUrl = services.urlManager
|
|
230
|
+
let valueUrl = services.urlManager.remove('page');
|
|
230
231
|
if (facet.multiple == 'single') {
|
|
231
232
|
valueUrl = valueUrl?.remove(`filter.${facet.field}`);
|
|
232
233
|
}
|
|
@@ -234,7 +235,7 @@ class Value {
|
|
|
234
235
|
}
|
|
235
236
|
}
|
|
236
237
|
}
|
|
237
|
-
class
|
|
238
|
+
export class FacetHierarchyValue extends FacetValue {
|
|
238
239
|
constructor(services, facet, value, filteredValues) {
|
|
239
240
|
super(services, facet, value);
|
|
240
241
|
this.level = 0;
|
|
@@ -243,27 +244,27 @@ class HierarchyValue extends Value {
|
|
|
243
244
|
this.level = value.value.split(facet.hierarchyDelimiter).length;
|
|
244
245
|
}
|
|
245
246
|
if (facet.filtered && filteredValues?.length) {
|
|
246
|
-
const filteredLevel = filteredValues[0].value
|
|
247
|
-
if (this.level <= filteredLevel) {
|
|
247
|
+
const filteredLevel = facet?.hierarchyDelimiter && filteredValues[0].value?.split(facet.hierarchyDelimiter).length;
|
|
248
|
+
if (filteredLevel && this.level <= filteredLevel) {
|
|
248
249
|
this.history = true;
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
252
|
if (value.value) {
|
|
252
|
-
this.url = services
|
|
253
|
+
this.url = services.urlManager.remove('page').set(`filter.${facet.field}`, value.value);
|
|
253
254
|
}
|
|
254
255
|
else {
|
|
255
|
-
this.url = services
|
|
256
|
+
this.url = services.urlManager.remove('page').remove(`filter.${facet.field}`);
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
259
|
}
|
|
259
|
-
class
|
|
260
|
+
export class FacetRangeValue {
|
|
260
261
|
constructor(services, facet, value) {
|
|
261
262
|
Object.assign(this, value);
|
|
262
263
|
if (this.filtered) {
|
|
263
|
-
this.url = services
|
|
264
|
+
this.url = services.urlManager.remove('page').remove(`filter.${facet.field}`, [{ low: this.low, high: this.high }]);
|
|
264
265
|
}
|
|
265
266
|
else {
|
|
266
|
-
let valueUrl = services
|
|
267
|
+
let valueUrl = services.urlManager.remove('page');
|
|
267
268
|
if (facet.multiple == 'single') {
|
|
268
269
|
valueUrl = valueUrl?.remove(`filter.${facet.field}`);
|
|
269
270
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { UrlManager } from '@searchspring/snap-url-manager';
|
|
2
|
+
import type { StoreServices } from '../../types';
|
|
3
|
+
import type { SearchResponseModelFilter, MetaResponseModel, SearchResponseModelFilterRange, SearchResponseModelFilterValue, MetaResponseModelFacetDefaults, MetaResponseModelFacet } from '@searchspring/snapi-types';
|
|
4
|
+
export declare class SearchFilterStore extends Array<RangeFilter | Filter> {
|
|
5
|
+
static get [Symbol.species](): ArrayConstructor;
|
|
6
|
+
constructor(services: StoreServices, filtersData: SearchResponseModelFilter[] | undefined, meta: MetaResponseModel);
|
|
7
|
+
}
|
|
8
|
+
export declare class Filter {
|
|
9
|
+
label: string;
|
|
10
|
+
facet: {
|
|
11
|
+
field?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
};
|
|
14
|
+
value: {
|
|
15
|
+
value?: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
};
|
|
18
|
+
url: UrlManager;
|
|
19
|
+
constructor(services: StoreServices, filter: SearchResponseModelFilterValue, meta: MetaResponseModelFacet & MetaResponseModelFacetDefaults);
|
|
20
|
+
}
|
|
21
|
+
export declare class RangeFilter {
|
|
22
|
+
label: string;
|
|
23
|
+
facet: {
|
|
24
|
+
field?: string;
|
|
25
|
+
label?: string;
|
|
26
|
+
};
|
|
27
|
+
value: {
|
|
28
|
+
low?: number;
|
|
29
|
+
high?: number;
|
|
30
|
+
label: string;
|
|
31
|
+
};
|
|
32
|
+
url: UrlManager;
|
|
33
|
+
constructor(services: StoreServices, filter: SearchResponseModelFilterRange, meta: MetaResponseModelFacet & MetaResponseModelFacetDefaults);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=SearchFilterStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchFilterStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/SearchFilterStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EACX,yBAAyB,EACzB,iBAAiB,EACjB,8BAA8B,EAC9B,8BAA8B,EAC9B,8BAA8B,EAC9B,sBAAsB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,iBAAkB,SAAQ,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC;IACjE,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAE9C;gBAEW,QAAQ,EAAE,aAAa,EAAE,WAAW,yCAAkC,EAAE,IAAI,EAAE,iBAAiB;CAmB3G;AAED,qBAAa,MAAM;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACK,KAAK,EAAE;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IAEK,GAAG,EAAE,UAAU,CAAC;gBAEX,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,8BAA8B,EAAE,IAAI,EAAE,sBAAsB,GAAG,8BAA8B;CAmB1I;AAED,qBAAa,WAAW;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACK,KAAK,EAAE;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;IAEK,GAAG,EAAE,UAAU,CAAC;gBAEX,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,8BAA8B,EAAE,IAAI,EAAE,sBAAsB,GAAG,8BAA8B;CAoB1I"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { makeObservable, observable } from 'mobx';
|
|
2
|
+
export class SearchFilterStore extends Array {
|
|
3
|
+
static get [Symbol.species]() {
|
|
4
|
+
return Array;
|
|
5
|
+
}
|
|
6
|
+
constructor(services, filtersData = [], meta) {
|
|
7
|
+
const filters = filtersData.map((filter) => {
|
|
8
|
+
const field = filter.field;
|
|
9
|
+
const facetMeta = meta.facets && meta.facets[field];
|
|
10
|
+
switch (filter.type) {
|
|
11
|
+
case 'range':
|
|
12
|
+
const rangeFilter = filter;
|
|
13
|
+
return new RangeFilter(services, rangeFilter, facetMeta);
|
|
14
|
+
case 'value':
|
|
15
|
+
default:
|
|
16
|
+
const valueFilter = filter;
|
|
17
|
+
return new Filter(services, valueFilter, facetMeta);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
super(...filters);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class Filter {
|
|
24
|
+
constructor(services, filter, meta) {
|
|
25
|
+
this.facet = {
|
|
26
|
+
field: filter.field,
|
|
27
|
+
label: meta?.label || filter.field,
|
|
28
|
+
};
|
|
29
|
+
this.value = {
|
|
30
|
+
value: filter.value,
|
|
31
|
+
label: filter.label,
|
|
32
|
+
};
|
|
33
|
+
this.label = `${this.facet.label}: ${this.value.label}`;
|
|
34
|
+
this.url = services?.urlManager?.remove('page').remove(`filter.${this.facet.field}`, this.value.value);
|
|
35
|
+
makeObservable(this, {
|
|
36
|
+
facet: observable,
|
|
37
|
+
value: observable,
|
|
38
|
+
label: observable,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class RangeFilter {
|
|
43
|
+
constructor(services, filter, meta) {
|
|
44
|
+
this.facet = {
|
|
45
|
+
field: filter.field,
|
|
46
|
+
label: meta?.label || filter.field,
|
|
47
|
+
};
|
|
48
|
+
this.value = {
|
|
49
|
+
low: filter?.value?.low,
|
|
50
|
+
high: filter?.value?.high,
|
|
51
|
+
label: filter.label || `${filter?.value?.low} - ${filter?.value?.high}`,
|
|
52
|
+
};
|
|
53
|
+
this.label = `${this.facet.label}: ${this.value.label}`;
|
|
54
|
+
this.url = services?.urlManager?.remove('page').remove(`filter.${this.facet.field}`, { low: this.value.low, high: this.value.high });
|
|
55
|
+
makeObservable(this, {
|
|
56
|
+
facet: observable,
|
|
57
|
+
value: observable,
|
|
58
|
+
label: observable,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { StoreServices } from '../../types';
|
|
2
|
+
import type { SearchResponseModelMerchandising, SearchResponseModelMerchandisingContentInline } from '@searchspring/snapi-types';
|
|
3
|
+
export declare enum ContentType {
|
|
4
|
+
HEADER = "header",
|
|
5
|
+
BANNER = "banner",
|
|
6
|
+
FOOTER = "footer",
|
|
7
|
+
LEFT = "left",
|
|
8
|
+
INLINE = "inline"
|
|
9
|
+
}
|
|
10
|
+
export declare type BannerContent = Partial<Record<ContentType, Content>>;
|
|
11
|
+
export declare class SearchMerchandisingStore {
|
|
12
|
+
redirect: string;
|
|
13
|
+
content: BannerContent;
|
|
14
|
+
constructor(services: StoreServices, merchData: SearchResponseModelMerchandising);
|
|
15
|
+
}
|
|
16
|
+
declare class Content extends Array<string | SearchResponseModelMerchandisingContentInline> {
|
|
17
|
+
static get [Symbol.species](): ArrayConstructor;
|
|
18
|
+
constructor(content: string[] | SearchResponseModelMerchandisingContentInline[]);
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=SearchMerchandisingStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchMerchandisingStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/SearchMerchandisingStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gCAAgC,EAAE,6CAA6C,EAAE,MAAM,2BAA2B,CAAC;AAEjI,oBAAY,WAAW;IACtB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,MAAM,WAAW;CACjB;AAED,oBAAY,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAElE,qBAAa,wBAAwB;IAC7B,QAAQ,SAAM;IACd,OAAO,EAAE,aAAa,CAAM;gBAEvB,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,gCAAgC;CAahF;AAED,cAAM,OAAQ,SAAQ,KAAK,CAAC,MAAM,GAAG,6CAA6C,CAAC;IAClF,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAE9C;gBAEW,OAAO,EAAE,MAAM,EAAE,GAAG,6CAA6C,EAAE;CAG/E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ContentType;
|
|
1
|
+
export var ContentType;
|
|
2
2
|
(function (ContentType) {
|
|
3
3
|
ContentType["HEADER"] = "header";
|
|
4
4
|
ContentType["BANNER"] = "banner";
|
|
@@ -6,7 +6,7 @@ var ContentType;
|
|
|
6
6
|
ContentType["LEFT"] = "left";
|
|
7
7
|
ContentType["INLINE"] = "inline";
|
|
8
8
|
})(ContentType || (ContentType = {}));
|
|
9
|
-
export class
|
|
9
|
+
export class SearchMerchandisingStore {
|
|
10
10
|
constructor(services, merchData) {
|
|
11
11
|
this.redirect = '';
|
|
12
12
|
this.content = {};
|
|
@@ -14,7 +14,7 @@ export class MerchandisingStore {
|
|
|
14
14
|
this.redirect = merchData.redirect || '';
|
|
15
15
|
if (merchData.content) {
|
|
16
16
|
Object.values(ContentType).forEach((type) => {
|
|
17
|
-
if (merchData.content[type]) {
|
|
17
|
+
if (merchData.content && merchData.content[type]) {
|
|
18
18
|
this.content[type] = new Content(merchData.content[type]);
|
|
19
19
|
}
|
|
20
20
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { SearchStoreConfig, StoreServices } from '../../types';
|
|
2
2
|
import type { SearchResponseModelPagination } from '@searchspring/snapi-types';
|
|
3
3
|
import type { UrlManager } from '@searchspring/snap-url-manager';
|
|
4
|
-
export declare class
|
|
5
|
-
|
|
4
|
+
export declare class SearchPaginationStore {
|
|
5
|
+
services: StoreServices;
|
|
6
6
|
page: number;
|
|
7
7
|
pageSize: number;
|
|
8
8
|
pageSizeOptions: {
|
|
@@ -12,7 +12,6 @@ export declare class PaginationStore {
|
|
|
12
12
|
defaultPageSize: number;
|
|
13
13
|
totalResults: number;
|
|
14
14
|
totalPages: number;
|
|
15
|
-
infinite: boolean;
|
|
16
15
|
controllerConfig: SearchStoreConfig;
|
|
17
16
|
constructor(config: SearchStoreConfig, services: StoreServices, paginationData?: SearchResponseModelPagination);
|
|
18
17
|
get begin(): number;
|
|
@@ -21,8 +20,8 @@ export declare class PaginationStore {
|
|
|
21
20
|
get current(): Page;
|
|
22
21
|
get first(): Page;
|
|
23
22
|
get last(): Page;
|
|
24
|
-
get next(): Page;
|
|
25
|
-
get previous(): Page;
|
|
23
|
+
get next(): Page | undefined;
|
|
24
|
+
get previous(): Page | undefined;
|
|
26
25
|
getPages(min?: number, max?: number): Page[];
|
|
27
26
|
setPageSize(num: number): void;
|
|
28
27
|
}
|
|
@@ -37,4 +36,4 @@ export declare class Page {
|
|
|
37
36
|
active?: boolean;
|
|
38
37
|
});
|
|
39
38
|
}
|
|
40
|
-
//# sourceMappingURL=
|
|
39
|
+
//# sourceMappingURL=SearchPaginationStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchPaginationStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/SearchPaginationStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAEjE,qBAAa,qBAAqB;IAC1B,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE;QACvB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACd,EAAE,CAAC;IACG,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,iBAAiB,CAAC;gBAG1C,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,aAAa,EACvB,cAAc,GAAE,6BAMf;IA4CF,IAAW,KAAK,IAAI,MAAM,CAKzB;IAED,IAAW,GAAG,IAAI,MAAM,CAMvB;IAED,IAAW,aAAa,IAAI,OAAO,CAElC;IAED,IAAW,OAAO,IAAI,IAAI,CAKzB;IAED,IAAW,KAAK,IAAI,IAAI,CAKvB;IAED,IAAW,IAAI,IAAI,IAAI,CAKtB;IAED,IAAW,IAAI,IAAI,IAAI,GAAG,SAAS,CAMlC;IAED,IAAW,QAAQ,IAAI,IAAI,GAAG,SAAS,CAMtC;IAEM,QAAQ,CAAC,GAAG,GAAE,MAAU,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE;IAmD/C,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAKrC;AAED,qBAAa,IAAI;IACT,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE,UAAU,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;gBAGlB,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,OAAO,CAAC;KACjB;CAQF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { observable, action, computed, makeObservable } from 'mobx';
|
|
2
|
-
export class
|
|
2
|
+
export class SearchPaginationStore {
|
|
3
3
|
constructor(config, services, paginationData = {
|
|
4
4
|
page: undefined,
|
|
5
5
|
pageSize: undefined,
|
|
@@ -92,11 +92,11 @@ export class PaginationStore {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
getPages(min, max) {
|
|
95
|
+
getPages(min = 5, max) {
|
|
96
96
|
if (!Number.isInteger(min)) {
|
|
97
97
|
return [];
|
|
98
98
|
}
|
|
99
|
-
if (!Number.isInteger(max)) {
|
|
99
|
+
if (typeof max == 'undefined' || !Number.isInteger(max)) {
|
|
100
100
|
const surrounding = min - 1;
|
|
101
101
|
let from = this.page;
|
|
102
102
|
let to = this.page;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { UrlManager } from '@searchspring/snap-url-manager';
|
|
2
2
|
import type { StoreServices } from '../../types';
|
|
3
3
|
import type { SearchResponseModelSearch, SearchResponseModelSearchMatchTypeEnum } from '@searchspring/snapi-types';
|
|
4
|
-
export declare class
|
|
5
|
-
query
|
|
6
|
-
didYouMean
|
|
7
|
-
originalQuery
|
|
8
|
-
matchType
|
|
4
|
+
export declare class SearchQueryStore {
|
|
5
|
+
query?: Query;
|
|
6
|
+
didYouMean?: Query;
|
|
7
|
+
originalQuery?: Query;
|
|
8
|
+
matchType?: SearchResponseModelSearchMatchTypeEnum;
|
|
9
9
|
constructor(services: StoreServices, search: SearchResponseModelSearch);
|
|
10
10
|
}
|
|
11
11
|
declare class Query {
|
|
@@ -14,4 +14,4 @@ declare class Query {
|
|
|
14
14
|
constructor(services: StoreServices, query: string);
|
|
15
15
|
}
|
|
16
16
|
export {};
|
|
17
|
-
//# sourceMappingURL=
|
|
17
|
+
//# sourceMappingURL=SearchQueryStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchQueryStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/SearchQueryStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,yBAAyB,EAAE,sCAAsC,EAAE,MAAM,2BAA2B,CAAC;AAEnH,qBAAa,gBAAgB;IACrB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,aAAa,CAAC,EAAE,KAAK,CAAC;IACtB,SAAS,CAAC,EAAE,sCAAsC,CAAC;gBAE9C,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,yBAAyB;CAyBtE;AASD,cAAM,KAAK;IACH,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,UAAU,CAAC;gBAEX,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM;CASlD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { SearchStoreConfig, AutocompleteStoreConfig, StoreServices } from '../../types';
|
|
2
|
+
import type { SearchResponseModelResult, SearchResponseModelPagination, SearchResponseModelMerchandising, SearchResponseModelResultMappings, SearchResponseModelMerchandisingContentInline, SearchResponseModelMerchandisingContentConfig } from '@searchspring/snapi-types';
|
|
3
|
+
export declare class SearchResultStore extends Array<Product | Banner> {
|
|
4
|
+
static get [Symbol.species](): ArrayConstructor;
|
|
5
|
+
constructor(config: SearchStoreConfig | AutocompleteStoreConfig, services: StoreServices, resultData?: SearchResponseModelResult[], paginationData?: SearchResponseModelPagination, merchData?: SearchResponseModelMerchandising);
|
|
6
|
+
}
|
|
7
|
+
export declare class Banner {
|
|
8
|
+
type: string;
|
|
9
|
+
id: string;
|
|
10
|
+
attributes: Record<string, unknown>;
|
|
11
|
+
mappings: SearchResponseModelResultMappings;
|
|
12
|
+
custom: {};
|
|
13
|
+
config: SearchResponseModelMerchandisingContentConfig;
|
|
14
|
+
value: string;
|
|
15
|
+
constructor(services: StoreServices, banner: SearchResponseModelMerchandisingContentInline);
|
|
16
|
+
}
|
|
17
|
+
export declare class Product {
|
|
18
|
+
type: string;
|
|
19
|
+
id: string;
|
|
20
|
+
attributes: Record<string, unknown>;
|
|
21
|
+
mappings: SearchResponseModelResultMappings;
|
|
22
|
+
custom: {};
|
|
23
|
+
children?: Array<Child>;
|
|
24
|
+
constructor(services: StoreServices, result: SearchResponseModelResult);
|
|
25
|
+
}
|
|
26
|
+
declare class Child {
|
|
27
|
+
type: string;
|
|
28
|
+
id: string;
|
|
29
|
+
attributes: Record<string, unknown>;
|
|
30
|
+
custom: {};
|
|
31
|
+
constructor(services: StoreServices, result: SearchResponseModelResult);
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=SearchResultStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchResultStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/SearchResultStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,KAAK,EACX,yBAAyB,EACzB,6BAA6B,EAC7B,gCAAgC,EAChC,iCAAiC,EACjC,6CAA6C,EAC7C,6CAA6C,EAC7C,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,iBAAkB,SAAQ,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IAC7D,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAE9C;gBAGA,MAAM,EAAE,iBAAiB,GAAG,uBAAuB,EACnD,QAAQ,EAAE,aAAa,EACvB,UAAU,CAAC,EAAE,yBAAyB,EAAE,EACxC,cAAc,CAAC,EAAE,6BAA6B,EAC9C,SAAS,CAAC,EAAE,gCAAgC;CAqB7C;AAED,qBAAa,MAAM;IACX,IAAI,SAAY;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IACzC,QAAQ,EAAE,iCAAiC,CAEhD;IACK,MAAM,KAAM;IACZ,MAAM,EAAE,6CAA6C,CAAC;IACtD,KAAK,EAAE,MAAM,CAAC;gBAET,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,6CAA6C;CAW1F;AAED,qBAAa,OAAO;IACZ,IAAI,SAAa;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IACzC,QAAQ,EAAE,iCAAiC,CAEhD;IACK,MAAM,KAAM;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAM;gBAExB,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,yBAAyB;CA8BtE;AAED,cAAM,KAAK;IACH,IAAI,SAAW;IACf,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IACzC,MAAM,KAAM;gBAEP,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,yBAAyB;CAUtE"}
|