@searchspring/snap-store-mobx 0.27.5 → 0.27.8
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 +8 -7
- package/dist/cjs/Autocomplete/AutocompleteStore.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/AutocompleteStore.js +17 -16
- package/dist/cjs/Autocomplete/Stores/QueryStore.d.ts +3 -3
- package/dist/cjs/Autocomplete/Stores/QueryStore.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/Stores/QueryStore.js +1 -1
- package/dist/cjs/Autocomplete/Stores/StateStore.d.ts +2 -2
- package/dist/cjs/Autocomplete/Stores/StateStore.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/Stores/StateStore.js +2 -2
- package/dist/cjs/Autocomplete/Stores/TermStore.d.ts +1 -1
- package/dist/cjs/Autocomplete/Stores/TermStore.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/Stores/TrendingStore.d.ts +4 -2
- package/dist/cjs/Autocomplete/Stores/TrendingStore.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/Stores/TrendingStore.js +2 -2
- package/dist/cjs/Finder/FinderStore.d.ts +2 -1
- package/dist/cjs/Finder/FinderStore.d.ts.map +1 -1
- package/dist/cjs/Finder/FinderStore.js +7 -7
- package/dist/cjs/Finder/Stores/SelectionStore.d.ts +43 -4
- package/dist/cjs/Finder/Stores/SelectionStore.d.ts.map +1 -1
- package/dist/cjs/Finder/Stores/SelectionStore.js +10 -9
- package/dist/cjs/Recommendation/RecommendationStore.d.ts +2 -1
- package/dist/cjs/Recommendation/RecommendationStore.d.ts.map +1 -1
- package/dist/cjs/Recommendation/RecommendationStore.js +4 -4
- package/dist/cjs/Recommendation/Stores/ProfileStore.d.ts +2 -1
- package/dist/cjs/Recommendation/Stores/ProfileStore.d.ts.map +1 -1
- package/dist/cjs/Recommendation/Stores/ProfileStore.js +6 -5
- package/dist/cjs/Search/SearchStore.d.ts +3 -3
- package/dist/cjs/Search/SearchStore.d.ts.map +1 -1
- package/dist/cjs/Search/SearchStore.js +24 -8
- package/dist/cjs/Search/Stores/FacetStore.d.ts +70 -1
- package/dist/cjs/Search/Stores/FacetStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/FacetStore.js +36 -30
- package/dist/cjs/Search/Stores/FilterStore.d.ts +30 -2
- package/dist/cjs/Search/Stores/FilterStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/FilterStore.js +30 -33
- package/dist/cjs/Search/Stores/MerchandisingStore.d.ts +4 -4
- package/dist/cjs/Search/Stores/MerchandisingStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/MerchandisingStore.js +1 -1
- package/dist/cjs/Search/Stores/PaginationStore.d.ts +3 -4
- package/dist/cjs/Search/Stores/PaginationStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/PaginationStore.js +2 -1
- package/dist/cjs/Search/Stores/QueryStore.d.ts +4 -4
- package/dist/cjs/Search/Stores/QueryStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/ResultStore.d.ts +30 -3
- package/dist/cjs/Search/Stores/ResultStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/ResultStore.js +4 -2
- package/dist/cjs/Search/Stores/SortingStore.d.ts +7 -3
- package/dist/cjs/Search/Stores/SortingStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/SortingStore.js +4 -5
- package/dist/cjs/Search/Stores/index.d.ts +1 -1
- package/dist/cjs/Search/Stores/index.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/index.js +2 -1
- package/dist/cjs/Storage/StorageStore.d.ts +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 +5 -1
- package/dist/cjs/types.d.ts +6 -23
- 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 +8 -7
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts.map +1 -1
- package/dist/esm/Autocomplete/AutocompleteStore.js +16 -17
- package/dist/esm/Autocomplete/Stores/QueryStore.d.ts +3 -3
- package/dist/esm/Autocomplete/Stores/QueryStore.d.ts.map +1 -1
- package/dist/esm/Autocomplete/Stores/QueryStore.js +1 -1
- package/dist/esm/Autocomplete/Stores/StateStore.d.ts +2 -2
- package/dist/esm/Autocomplete/Stores/StateStore.d.ts.map +1 -1
- package/dist/esm/Autocomplete/Stores/StateStore.js +2 -2
- package/dist/esm/Autocomplete/Stores/TermStore.d.ts +1 -1
- package/dist/esm/Autocomplete/Stores/TermStore.d.ts.map +1 -1
- package/dist/esm/Autocomplete/Stores/TrendingStore.d.ts +4 -2
- package/dist/esm/Autocomplete/Stores/TrendingStore.d.ts.map +1 -1
- package/dist/esm/Autocomplete/Stores/TrendingStore.js +1 -1
- package/dist/esm/Finder/FinderStore.d.ts +2 -1
- package/dist/esm/Finder/FinderStore.d.ts.map +1 -1
- package/dist/esm/Finder/FinderStore.js +5 -5
- package/dist/esm/Finder/Stores/SelectionStore.d.ts +47 -4
- package/dist/esm/Finder/Stores/SelectionStore.d.ts.map +1 -1
- package/dist/esm/Finder/Stores/SelectionStore.js +8 -8
- package/dist/esm/Recommendation/RecommendationStore.d.ts +2 -1
- package/dist/esm/Recommendation/RecommendationStore.d.ts.map +1 -1
- package/dist/esm/Recommendation/RecommendationStore.js +4 -4
- package/dist/esm/Recommendation/Stores/ProfileStore.d.ts +2 -1
- package/dist/esm/Recommendation/Stores/ProfileStore.d.ts.map +1 -1
- package/dist/esm/Recommendation/Stores/ProfileStore.js +5 -5
- package/dist/esm/Search/SearchStore.d.ts +3 -3
- package/dist/esm/Search/SearchStore.d.ts.map +1 -1
- package/dist/esm/Search/SearchStore.js +24 -9
- package/dist/esm/Search/Stores/FacetStore.d.ts +71 -2
- package/dist/esm/Search/Stores/FacetStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/FacetStore.js +29 -28
- package/dist/esm/Search/Stores/FilterStore.d.ts +31 -3
- package/dist/esm/Search/Stores/FilterStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/FilterStore.js +28 -35
- package/dist/esm/Search/Stores/MerchandisingStore.d.ts +4 -4
- package/dist/esm/Search/Stores/MerchandisingStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/MerchandisingStore.js +1 -1
- package/dist/esm/Search/Stores/PaginationStore.d.ts +3 -4
- package/dist/esm/Search/Stores/PaginationStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/PaginationStore.js +2 -2
- package/dist/esm/Search/Stores/QueryStore.d.ts +4 -4
- package/dist/esm/Search/Stores/QueryStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/ResultStore.d.ts +30 -3
- package/dist/esm/Search/Stores/ResultStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/ResultStore.js +3 -5
- package/dist/esm/Search/Stores/SortingStore.d.ts +7 -3
- package/dist/esm/Search/Stores/SortingStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/SortingStore.js +4 -5
- package/dist/esm/Search/Stores/index.d.ts +1 -1
- package/dist/esm/Search/Stores/index.d.ts.map +1 -1
- package/dist/esm/Search/Stores/index.js +1 -1
- package/dist/esm/Storage/StorageStore.d.ts +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 +6 -23
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrendingStore.d.ts","sourceRoot":"","sources":["../../../../src/Autocomplete/Stores/TrendingStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"TrendingStore.d.ts","sourceRoot":"","sources":["../../../../src/Autocomplete/Stores/TrendingStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,qBAAa,aAAc,SAAQ,KAAK,CAAC,IAAI,CAAC;IAC7C,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAE9C;gBAEW,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,IAAI,EAAE,SAAS,EAAE,UAAU;CAoBvH"}
|
|
@@ -5,7 +5,7 @@ export class TrendingStore extends Array {
|
|
|
5
5
|
}
|
|
6
6
|
constructor(services, trendingData, resetTerms, rootState) {
|
|
7
7
|
const terms = [];
|
|
8
|
-
trendingData?.queries?.map((term) => {
|
|
8
|
+
trendingData?.trending?.queries?.map((term) => {
|
|
9
9
|
terms.push(new Term(services, {
|
|
10
10
|
active: false,
|
|
11
11
|
value: term.searchQuery,
|
|
@@ -4,6 +4,7 @@ import { PaginationStore } from '../Search/Stores';
|
|
|
4
4
|
import { StorageStore } from '../Storage/StorageStore';
|
|
5
5
|
import { SelectionStore } from './Stores';
|
|
6
6
|
import type { FinderStoreConfig, StoreServices, SelectedSelection, FinderStoreState } from '../types';
|
|
7
|
+
import { UrlManager } from '@searchspring/snap-url-manager';
|
|
7
8
|
export declare class FinderStore extends AbstractStore {
|
|
8
9
|
services: StoreServices;
|
|
9
10
|
config: FinderStoreConfig;
|
|
@@ -17,7 +18,7 @@ export declare class FinderStore extends AbstractStore {
|
|
|
17
18
|
selections: SelectionStore;
|
|
18
19
|
state: FinderStoreState;
|
|
19
20
|
constructor(config: FinderStoreConfig, services: StoreServices);
|
|
20
|
-
setService(name:
|
|
21
|
+
setService(name: keyof StoreServices, service: UrlManager): void;
|
|
21
22
|
save(): void;
|
|
22
23
|
reset: () => void;
|
|
23
24
|
loadPersisted(): void;
|
|
@@ -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,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAe,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;
|
|
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;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACtG,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,qBAAa,WAAY,SAAQ,aAAa;IACtC,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAG,iBAAiB,CAAC;IAC3B,IAAI,EAAG,mBAAmB,GAAG;QAAE,IAAI,EAAE,iBAAiB,CAAA;KAAE,CAAC;IACzD,IAAI,EAAE,iBAAiB,CAAM;IAC7B,OAAO,EAAE,YAAY,CAAC;IACtB,gBAAgB,EAAG,YAAY,CAAC;IAChC,UAAU,EAAG,eAAe,CAAC;IAC7B,UAAU,EAAG,cAAc,CAAC;IAC5B,KAAK,EAAE,gBAAgB,CAE5B;gBAEU,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa;IA0BvD,UAAU,CAAC,IAAI,EAAE,MAAM,aAAa,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IAMhE,IAAI,IAAI,IAAI;IAkBZ,KAAK,QAAO,IAAI,CAWrB;IAEK,aAAa,IAAI,IAAI;IAoBrB,MAAM,CAAC,IAAI,EAAE,mBAAmB,GAAG;QAAE,IAAI,EAAE,iBAAiB,CAAA;KAAE,EAAE,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,GAAG,IAAI;CAetH"}
|
|
@@ -12,7 +12,7 @@ export class FinderStore extends AbstractStore {
|
|
|
12
12
|
};
|
|
13
13
|
this.reset = () => {
|
|
14
14
|
if (this.config.persist?.enabled) {
|
|
15
|
-
this.persistedStorage
|
|
15
|
+
this.persistedStorage?.clear();
|
|
16
16
|
this.state.persisted = false;
|
|
17
17
|
}
|
|
18
18
|
if (this.services.urlManager.state.filter) {
|
|
@@ -44,7 +44,7 @@ export class FinderStore extends AbstractStore {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
save() {
|
|
47
|
-
if (this.config.persist?.enabled && this.selections
|
|
47
|
+
if (this.config.persist?.enabled && this.persistedStorage && this?.selections?.filter((selection) => selection.selected).length) {
|
|
48
48
|
this.persistedStorage.set('config', this.config);
|
|
49
49
|
this.persistedStorage.set('data', this.data);
|
|
50
50
|
this.persistedStorage.set('date', Date.now());
|
|
@@ -58,7 +58,7 @@ export class FinderStore extends AbstractStore {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
loadPersisted() {
|
|
61
|
-
if (this.config.persist?.enabled && !this.loaded) {
|
|
61
|
+
if (this.config.persist?.enabled && this.persistedStorage && !this.loaded) {
|
|
62
62
|
const date = this.persistedStorage.get('date');
|
|
63
63
|
const data = this.persistedStorage.get('data');
|
|
64
64
|
const config = this.persistedStorage.get('config');
|
|
@@ -84,11 +84,11 @@ export class FinderStore extends AbstractStore {
|
|
|
84
84
|
this.pagination = new PaginationStore(this.config, this.services, data.pagination);
|
|
85
85
|
this.selections = new SelectionStore(this.config, this.services, {
|
|
86
86
|
state: this.state,
|
|
87
|
-
facets: data.facets,
|
|
87
|
+
facets: data.facets || [],
|
|
88
88
|
meta: this.meta,
|
|
89
89
|
loading: this.loading,
|
|
90
90
|
storage: this.storage,
|
|
91
|
-
selections: selectedSelections,
|
|
91
|
+
selections: selectedSelections || [],
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { FinderStoreConfig, StoreServices, SelectedSelection, FinderStoreState } from '../../types';
|
|
1
|
+
import type { FinderStoreConfig, FinderFieldConfig, StoreServices, SelectedSelection, FinderStoreState } from '../../types';
|
|
2
2
|
import type { StorageStore } from '../../Storage/StorageStore';
|
|
3
|
-
import type { MetaResponseModel, SearchResponseModelFacet } from '@searchspring/snapi-types';
|
|
4
|
-
declare type SelectionStoreData = {
|
|
3
|
+
import type { MetaResponseModel, MetaResponseModelFacetGrid, MetaResponseModelFacetHierarchy, MetaResponseModelFacetList, MetaResponseModelFacetPalette, MetaResponseModelFacetSlider, SearchResponseModelFacet, SearchResponseModelFacetRange, SearchResponseModelFacetRangeBuckets, SearchResponseModelFacetValue, SearchResponseModelFacetValueAllOfValues } from '@searchspring/snapi-types';
|
|
4
|
+
export declare type SelectionStoreData = {
|
|
5
5
|
state: FinderStoreState;
|
|
6
6
|
facets: SearchResponseModelFacet[];
|
|
7
7
|
meta: MetaResponseModel;
|
|
@@ -9,9 +9,52 @@ declare type SelectionStoreData = {
|
|
|
9
9
|
storage: StorageStore;
|
|
10
10
|
selections: SelectedSelection[];
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
declare type FacetWithMeta = MetaResponseModelFacetGrid & MetaResponseModelFacetHierarchy & MetaResponseModelFacetList & MetaResponseModelFacetPalette & MetaResponseModelFacetSlider & SearchResponseModelFacetValue & SearchResponseModelFacetRange & SearchResponseModelFacetRangeBuckets;
|
|
13
|
+
export declare class SelectionStore extends Array<Selection | SelectionHierarchy> {
|
|
13
14
|
static get [Symbol.species](): ArrayConstructor;
|
|
14
15
|
constructor(config: FinderStoreConfig, services: StoreServices, { state, facets, meta, loading, storage, selections }: SelectionStoreData);
|
|
15
16
|
}
|
|
17
|
+
declare class SelectionBase {
|
|
18
|
+
state: FinderStoreState;
|
|
19
|
+
type: string;
|
|
20
|
+
field: string;
|
|
21
|
+
filtered: boolean;
|
|
22
|
+
collapsed: boolean;
|
|
23
|
+
display: string;
|
|
24
|
+
label: string;
|
|
25
|
+
multiple: string;
|
|
26
|
+
id: string;
|
|
27
|
+
disabled: boolean;
|
|
28
|
+
selected: string;
|
|
29
|
+
custom: {};
|
|
30
|
+
facet: FacetWithMeta;
|
|
31
|
+
services: StoreServices;
|
|
32
|
+
loading: boolean;
|
|
33
|
+
config: FinderFieldConfig | LevelConfig;
|
|
34
|
+
data?: SearchResponseModelFacetValueAllOfValues[];
|
|
35
|
+
storage: {
|
|
36
|
+
key: string;
|
|
37
|
+
get: (key?: string | undefined) => any;
|
|
38
|
+
set: (key: string, value: unknown) => void;
|
|
39
|
+
};
|
|
40
|
+
constructor(services: StoreServices, id: string, state: FinderStoreState, facet: FacetWithMeta, selectionConfig: FinderFieldConfig | LevelConfig, loading: boolean, storageStore: StorageStore);
|
|
41
|
+
get values(): SearchResponseModelFacetValueAllOfValues[];
|
|
42
|
+
}
|
|
43
|
+
declare class Selection extends SelectionBase {
|
|
44
|
+
config: FinderFieldConfig;
|
|
45
|
+
constructor(services: StoreServices, id: string, state: FinderStoreState, facet: FacetWithMeta, config: FinderFieldConfig, loading: boolean, storageStore: StorageStore);
|
|
46
|
+
select(value?: string): void;
|
|
47
|
+
}
|
|
48
|
+
declare class SelectionHierarchy extends SelectionBase {
|
|
49
|
+
hierarchyDelimiter: string;
|
|
50
|
+
config: LevelConfig;
|
|
51
|
+
constructor(services: StoreServices, id: string, state: FinderStoreState, facet: FacetWithMeta, config: LevelConfig, loading: boolean, storageStore: StorageStore);
|
|
52
|
+
select(value?: string): void;
|
|
53
|
+
}
|
|
54
|
+
declare type LevelConfig = {
|
|
55
|
+
index: number;
|
|
56
|
+
label?: string;
|
|
57
|
+
key: string;
|
|
58
|
+
};
|
|
16
59
|
export {};
|
|
17
60
|
//# sourceMappingURL=SelectionStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionStore.d.ts","sourceRoot":"","sources":["../../../../src/Finder/Stores/SelectionStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"SelectionStore.d.ts","sourceRoot":"","sources":["../../../../src/Finder/Stores/SelectionStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC5H,OAAO,KAAK,EAAE,YAAY,EAAE,MAA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);
|
|
53
53
|
});
|
|
54
54
|
config?.fields?.forEach((fieldObj) => {
|
|
55
|
-
let facet = facets
|
|
55
|
+
let facet = facets.filter((facet) => facet.field == fieldObj.field).pop();
|
|
56
56
|
facet = {
|
|
57
|
-
...meta?.facets[fieldObj.field],
|
|
57
|
+
...((meta?.facets && meta.facets[fieldObj.field]) || {}),
|
|
58
58
|
...facet,
|
|
59
59
|
};
|
|
60
|
-
const isHierarchy = facet
|
|
60
|
+
const isHierarchy = facet?.display === 'hierarchy';
|
|
61
61
|
if (isHierarchy) {
|
|
62
62
|
// filter out history/current hierarchy values
|
|
63
|
-
const filtered = facet.
|
|
63
|
+
const filtered = facet.values?.filter((value) => value.filtered).pop();
|
|
64
64
|
if (filtered) {
|
|
65
|
-
const filteredLevel = filtered.value
|
|
66
|
-
facet.values = facet.values
|
|
67
|
-
return (value.value && value.value.split(facet
|
|
65
|
+
const filteredLevel = filtered.value?.split(facet?.hierarchyDelimiter).length;
|
|
66
|
+
facet.values = facet.values?.filter((value, index) => {
|
|
67
|
+
return (value.value && value.value.split(facet?.hierarchyDelimiter).length > filteredLevel) || index == facet.values?.length - 1;
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
const levels = fieldObj?.levels || facet?.values[facet?.values
|
|
70
|
+
const levels = fieldObj?.levels || (facet?.values && facet?.values[facet?.values?.length - 1].value?.split(facet.hierarchyDelimiter));
|
|
71
71
|
levels?.map((level, index) => {
|
|
72
72
|
const levelConfig = { index, label: fieldObj.levels ? level : '', key: `ss-${index}` };
|
|
73
73
|
selectedSelections.push(new SelectionHierarchy(services, config.id, state, facet, levelConfig, loading, storage));
|
|
@@ -2,6 +2,7 @@ import { AbstractStore } from '../Abstract/AbstractStore';
|
|
|
2
2
|
import { ResultStore } from '../Search/Stores';
|
|
3
3
|
import { ProfileStore } from './Stores';
|
|
4
4
|
import type { RecommendationStoreConfig, StoreServices } from '../types';
|
|
5
|
+
import type { RecommendCombinedResponseModel } from '@searchspring/snap-client';
|
|
5
6
|
export declare class RecommendationStore extends AbstractStore {
|
|
6
7
|
services: StoreServices;
|
|
7
8
|
loaded: boolean;
|
|
@@ -9,6 +10,6 @@ export declare class RecommendationStore extends AbstractStore {
|
|
|
9
10
|
results: ResultStore;
|
|
10
11
|
constructor(config: RecommendationStoreConfig, services: StoreServices);
|
|
11
12
|
reset(): void;
|
|
12
|
-
update(data
|
|
13
|
+
update(data?: RecommendCombinedResponseModel): void;
|
|
13
14
|
}
|
|
14
15
|
//# sourceMappingURL=RecommendationStore.d.ts.map
|
|
@@ -1 +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;
|
|
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;AACzE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAEhF,qBAAa,mBAAoB,SAAQ,aAAa;IAC9C,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,UAAS;IACf,OAAO,EAAG,YAAY,CAAC;IACvB,OAAO,EAAG,WAAW,CAAC;gBAEjB,MAAM,EAAE,yBAAyB,EAAE,QAAQ,EAAE,aAAa;IAiB/D,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,IAAI,CAAC,EAAE,8BAA8B,GAAG,IAAI;CAM1D"}
|
|
@@ -17,12 +17,12 @@ export class RecommendationStore extends AbstractStore {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
reset() {
|
|
20
|
-
this.update(
|
|
20
|
+
this.update();
|
|
21
21
|
}
|
|
22
22
|
update(data) {
|
|
23
23
|
this.error = undefined;
|
|
24
|
-
this.loaded = !!data
|
|
25
|
-
this.profile = new ProfileStore(this.services, data
|
|
26
|
-
this.results = new ResultStore(this.config, this.services, data
|
|
24
|
+
this.loaded = !!data?.profile;
|
|
25
|
+
this.profile = new ProfileStore(this.services, data);
|
|
26
|
+
this.results = new ResultStore(this.config, this.services, data?.results);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { StoreServices } from '../../types';
|
|
2
|
+
import type { RecommendCombinedResponseModel } from '@searchspring/snap-client';
|
|
2
3
|
export declare class ProfileStore {
|
|
3
4
|
tag: string;
|
|
4
5
|
placement: string;
|
|
5
6
|
display: Record<string, any>;
|
|
6
|
-
constructor(services: StoreServices,
|
|
7
|
+
constructor(services: StoreServices, data?: RecommendCombinedResponseModel);
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=ProfileStore.d.ts.map
|
|
@@ -1 +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;
|
|
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;AACjD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAEhF,qBAAa,YAAY;IACjB,GAAG,EAAG,MAAM,CAAC;IACb,SAAS,EAAG,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;gBAE7B,QAAQ,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,8BAA8B;CAe1E"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { observable, makeObservable } from 'mobx';
|
|
2
2
|
export class ProfileStore {
|
|
3
|
-
constructor(services,
|
|
3
|
+
constructor(services, data) {
|
|
4
4
|
this.display = {};
|
|
5
|
-
if (!profile?.tag) {
|
|
5
|
+
if (!data?.profile?.tag) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
-
this.tag = profile.tag;
|
|
9
|
-
this.placement = profile.placement;
|
|
10
|
-
this.display = profile.display;
|
|
8
|
+
this.tag = data.profile.tag;
|
|
9
|
+
this.placement = data.profile.placement;
|
|
10
|
+
this.display = data.profile.display;
|
|
11
11
|
makeObservable(this, {
|
|
12
12
|
tag: observable,
|
|
13
13
|
placement: observable,
|
|
@@ -4,7 +4,6 @@ import { MerchandisingStore, FacetStore, FilterStore, ResultStore, PaginationSto
|
|
|
4
4
|
import { AbstractStore } from '../Abstract/AbstractStore';
|
|
5
5
|
import { StorageStore } from '../Storage/StorageStore';
|
|
6
6
|
export declare class SearchStore extends AbstractStore {
|
|
7
|
-
config: SearchStoreConfig;
|
|
8
7
|
services: StoreServices;
|
|
9
8
|
data: SearchResponseModel & {
|
|
10
9
|
meta: MetaResponseModel;
|
|
@@ -19,8 +18,9 @@ export declare class SearchStore extends AbstractStore {
|
|
|
19
18
|
sorting: SortingStore;
|
|
20
19
|
storage: StorageStore;
|
|
21
20
|
constructor(config: SearchStoreConfig, services: StoreServices);
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
reset(): void;
|
|
22
|
+
update(data?: SearchResponseModel & {
|
|
23
|
+
meta?: MetaResponseModel;
|
|
24
24
|
}): void;
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=SearchStore.d.ts.map
|
|
@@ -1 +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;
|
|
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;IACtC,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAG,mBAAmB,GAAG;QAAE,IAAI,EAAE,iBAAiB,CAAA;KAAE,CAAC;IACzD,IAAI,EAAG,iBAAiB,CAAC;IACzB,aAAa,EAAG,kBAAkB,CAAC;IACnC,MAAM,EAAG,UAAU,CAAC;IACpB,MAAM,EAAG,UAAU,CAAC;IACpB,OAAO,EAAG,WAAW,CAAC;IACtB,OAAO,EAAG,WAAW,CAAC;IACtB,UAAU,EAAG,eAAe,CAAC;IAC7B,OAAO,EAAG,YAAY,CAAC;IACvB,OAAO,EAAE,YAAY,CAAC;gBAEjB,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa;IAqCvD,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,IAAI,GAAE,mBAAmB,GAAG;QAAE,IAAI,CAAC,EAAE,iBAAiB,CAAA;KAAO,GAAG,IAAI;CAalF"}
|
|
@@ -5,13 +5,12 @@ 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 MerchandisingStore(this.services, data
|
|
31
|
-
this.search = new QueryStore(this.services, data
|
|
32
|
-
this.facets = new FacetStore(this.config, this.services, this.storage, data.facets, data
|
|
44
|
+
this.meta = data.meta || {};
|
|
45
|
+
this.merchandising = new MerchandisingStore(this.services, data?.merchandising || {});
|
|
46
|
+
this.search = new QueryStore(this.services, data?.search || {});
|
|
47
|
+
this.facets = new FacetStore(this.config, this.services, this.storage, data.facets, data?.pagination || {}, this.meta);
|
|
33
48
|
this.filters = new FilterStore(this.services, data.filters, this.meta);
|
|
34
|
-
this.results = new ResultStore(this.config, this.services, data
|
|
49
|
+
this.results = new ResultStore(this.config, this.services, data?.results || [], data.pagination, data.merchandising);
|
|
35
50
|
this.pagination = new PaginationStore(this.config, this.services, data.pagination);
|
|
36
|
-
this.sorting = new SortingStore(this.services, data
|
|
51
|
+
this.sorting = new SortingStore(this.services, data?.sorting || [], data?.search || {}, this.meta);
|
|
37
52
|
}
|
|
38
53
|
}
|
|
@@ -1,8 +1,77 @@
|
|
|
1
|
+
import type { UrlManager } from '@searchspring/snap-url-manager';
|
|
1
2
|
import type { StorageStore } from '../../Storage/StorageStore';
|
|
2
3
|
import type { AutocompleteStoreConfig, SearchStoreConfig, StoreServices } from '../../types';
|
|
3
|
-
import type { MetaResponseModel, SearchResponseModelPagination, SearchResponseModelFacet } from '@searchspring/snapi-types';
|
|
4
|
+
import type { MetaResponseModel, MetaResponseModelFacet, MetaResponseModelFacetSlider, MetaResponseModelFacetValueMultipleEnum, MetaResponseModelFacetHierarchyAllOf, SearchResponseModelPagination, SearchResponseModelFacet, SearchResponseModelFacetRange, SearchResponseModelFacetValue, SearchResponseModelFacetValueAllOfValues, SearchRequestModelFilterRangeAllOfValue } from '@searchspring/snapi-types';
|
|
4
5
|
export declare class FacetStore extends Array {
|
|
5
6
|
static get [Symbol.species](): ArrayConstructor;
|
|
6
|
-
constructor(config: SearchStoreConfig | AutocompleteStoreConfig, services: StoreServices, storage: StorageStore, facetsData: SearchResponseModelFacet[], pagination: SearchResponseModelPagination, meta: MetaResponseModel);
|
|
7
|
+
constructor(config: SearchStoreConfig | AutocompleteStoreConfig, services: StoreServices, storage: StorageStore, facetsData: SearchResponseModelFacet[] | undefined, pagination: SearchResponseModelPagination | undefined, meta: MetaResponseModel);
|
|
7
8
|
}
|
|
9
|
+
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<HierarchyValue | Value | RangeValue | 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(): (HierarchyValue | Value | RangeValue | undefined)[];
|
|
50
|
+
}
|
|
51
|
+
export declare class Value {
|
|
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 HierarchyValue extends Value {
|
|
62
|
+
level: number;
|
|
63
|
+
history: boolean;
|
|
64
|
+
constructor(services: StoreServices, facet: ValueFacet & MetaResponseModelFacetHierarchyAllOf, value: SearchResponseModelFacetValueAllOfValues, filteredValues: SearchResponseModelFacetValueAllOfValues[]);
|
|
65
|
+
}
|
|
66
|
+
export declare class RangeValue {
|
|
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
|
+
export {};
|
|
8
77
|
//# sourceMappingURL=FacetStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FacetStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/FacetStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FacetStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/FacetStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAC;AAC/G,OAAO,KAAK,EACX,iBAAiB,EACjB,sBAAsB,EAEtB,4BAA4B,EAC5B,uCAAuC,EACvC,oCAAoC,EACpC,6BAA6B,EAC7B,wBAAwB,EACxB,6BAA6B,EAC7B,6BAA6B,EAE7B,wCAAwC,EACxC,uCAAuC,EACvC,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,wCAAiC,EAC3C,UAAU,2CAAoC,EAC9C,IAAI,EAAE,iBAAiB;CAgDxB;AAED,cAAM,KAAK;IACH,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAG,MAAM,CAAC;IACd,KAAK,EAAG,MAAM,CAAC;IACf,QAAQ,UAAS;IACjB,MAAM,KAAM;IACZ,SAAS,UAAS;IAClB,OAAO,SAAM;IACb,KAAK,SAAM;IACX,OAAO,EAAE,YAAY,CAAC;gBAG5B,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,6BAA6B,GAAG,6BAA6B,EACpE,SAAS,EAAE,sBAAsB;IA0BlC,IAAW,KAAK;;MAIf;IA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AE,UAAU,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;gBAEhB,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,wCAAwC;CAavG;AAED,qBAAa,cAAe,SAAQ,KAAK;IACjC,KAAK,SAAK;IACV,OAAO,UAAS;gBAGtB,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,UAAU,GAAG,oCAAoC,EACxD,KAAK,EAAE,wCAAwC,EAC/C,cAAc,EAAE,wCAAwC,EAAE;CAqB3D;AAED,qBAAa,UAAU;IACf,KAAK,EAAG,MAAM,CAAC;IACf,KAAK,EAAG,MAAM,CAAC;IACf,QAAQ,EAAG,OAAO,CAAC;IACnB,GAAG,EAAG,MAAM,CAAC;IACb,IAAI,EAAG,MAAM,CAAC;IACd,MAAM,EAAG,EAAE,CAAC;IACZ,GAAG,EAAE,UAAU,CAAC;gBAEX,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,wCAAwC;CAevG"}
|
|
@@ -3,10 +3,10 @@ export class FacetStore 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
|
|
@@ -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,12 +175,12 @@ class ValueFacet extends Facet {
|
|
|
174
175
|
switch (facet.type) {
|
|
175
176
|
case 'value':
|
|
176
177
|
if (facetMeta.display === 'hierarchy') {
|
|
177
|
-
const filteredValues = facet
|
|
178
|
+
const filteredValues = facet?.values?.filter((value) => value.filtered) || [];
|
|
178
179
|
return new HierarchyValue(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
|
+
value.value = value?.value?.toString();
|
|
183
184
|
return new Value(services, this, value);
|
|
184
185
|
}
|
|
185
186
|
case 'range-buckets':
|
|
@@ -187,7 +188,7 @@ class ValueFacet extends Facet {
|
|
|
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 Value {
|
|
223
|
+
export class Value {
|
|
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 HierarchyValue extends Value {
|
|
238
|
+
export class HierarchyValue extends Value {
|
|
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 RangeValue {
|
|
260
|
+
export class RangeValue {
|
|
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
|
}
|