@coveo/headless 3.26.1 → 3.26.2-pre.497e1d73bf
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/case-assist/headless.cjs +1 -1
- package/dist/cjs/case-assist/node.cjs.stats.json +1 -1
- package/dist/cjs/commerce/headless.cjs +767 -778
- package/dist/cjs/commerce/node.cjs.stats.json +1 -1
- package/dist/cjs/headless.cjs +1 -1
- package/dist/cjs/insight/headless.cjs +1 -1
- package/dist/cjs/insight/node.cjs.stats.json +1 -1
- package/dist/cjs/node.cjs.stats.json +1 -1
- package/dist/cjs/recommendation/headless.cjs +1 -1
- package/dist/cjs/recommendation/node.cjs.stats.json +1 -1
- package/dist/cjs/ssr/headless.cjs +1 -1
- package/dist/cjs/ssr/node.cjs.stats.json +1 -1
- package/dist/cjs/ssr-commerce/headless.cjs +715 -722
- package/dist/cjs/ssr-commerce/node.cjs.stats.json +1 -1
- package/dist/definitions/controllers/commerce/core/facets/category/headless-commerce-category-facet.d.ts +6 -6
- package/dist/definitions/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.d.ts +12 -12
- package/dist/definitions/controllers/commerce/core/facets/headless-core-commerce-facet.d.ts +10 -10
- package/dist/definitions/features/commerce/facets/category-facet/category-facet-actions.d.ts +10 -3
- package/dist/definitions/features/commerce/facets/facet-set/facet-set-reducers.d.ts +6 -6
- package/dist/definitions/features/commerce/facets/facet-set/facet-set-slice.d.ts +4 -5
- package/dist/definitions/features/commerce/facets/facet-set/interfaces/request.d.ts +4 -3
- package/dist/esm/controllers/commerce/core/facets/category/headless-commerce-category-facet.js +28 -18
- package/dist/esm/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.js +7 -7
- package/dist/esm/controllers/commerce/core/facets/headless-core-commerce-facet.js +0 -3
- package/dist/esm/features/commerce/facets/facet-set/facet-set-reducers.js +13 -10
- package/dist/esm/features/commerce/facets/facet-set/facet-set-slice.js +41 -39
- package/dist/esm/utils/version.js +1 -1
- package/dist/quantic/browser.cjs.stats.json +1 -1
- package/dist/quantic/case-assist/browser.cjs.stats.json +1 -1
- package/dist/quantic/case-assist/headless.js +1 -1
- package/dist/quantic/case-assist/headless.js.map +1 -1
- package/dist/quantic/commerce/browser.cjs.stats.json +1 -1
- package/dist/quantic/commerce/headless.js +8 -8
- package/dist/quantic/commerce/headless.js.map +4 -4
- package/dist/quantic/headless.js +1 -1
- package/dist/quantic/headless.js.map +1 -1
- package/dist/quantic/insight/browser.cjs.stats.json +1 -1
- package/dist/quantic/insight/headless.js +1 -1
- package/dist/quantic/insight/headless.js.map +1 -1
- package/dist/quantic/recommendation/browser.cjs.stats.json +1 -1
- package/dist/quantic/recommendation/headless.js +1 -1
- package/dist/quantic/recommendation/headless.js.map +1 -1
- package/package.json +1 -1
- package/dist/definitions/features/commerce/facets/facet-set/facet-set-reducer-helpers.d.ts +0 -5
- package/dist/esm/features/commerce/facets/facet-set/facet-set-reducer-helpers.js +0 -12
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CommerceEngine } from '../../../../../app/commerce-engine/commerce-engine.js';
|
|
2
|
-
import { CategoryFacetValueRequest } from '../../../../../features/commerce/facets/facet-set/interfaces/request.js';
|
|
1
|
+
import type { CommerceEngine } from '../../../../../app/commerce-engine/commerce-engine.js';
|
|
2
|
+
import type { CategoryFacetRequest, CategoryFacetValueRequest } from '../../../../../features/commerce/facets/facet-set/interfaces/request.js';
|
|
3
3
|
import { categoryFacetSearchStateSelector } from '../../../../../features/facets/facet-search-set/category/category-facet-search-state-selector.js';
|
|
4
|
-
import { CategoryFacetValue, CoreCommerceFacet, CoreCommerceFacetOptions, CoreCommerceFacetState, FacetControllerType } from '../headless-core-commerce-facet.js';
|
|
5
|
-
import { SearchableFacetOptions } from '../searchable/headless-commerce-searchable-facet.js';
|
|
6
|
-
import { CategoryFacetSearch, CategoryFacetSearchState } from './headless-commerce-category-facet-search.js';
|
|
4
|
+
import { type CategoryFacetValue, type CoreCommerceFacet, type CoreCommerceFacetOptions, type CoreCommerceFacetState, type FacetControllerType } from '../headless-core-commerce-facet.js';
|
|
5
|
+
import type { SearchableFacetOptions } from '../searchable/headless-commerce-searchable-facet.js';
|
|
6
|
+
import { type CategoryFacetSearch, type CategoryFacetSearchState } from './headless-commerce-category-facet-search.js';
|
|
7
7
|
export type CategoryFacetOptions = Omit<CoreCommerceFacetOptions, 'toggleExcludeActionCreator' | 'toggleSelectActionCreator'> & SearchableFacetOptions;
|
|
8
8
|
/**
|
|
9
9
|
* The state of the `CategoryFacet` sub-controller.
|
|
@@ -44,4 +44,4 @@ export type CategoryFacet = Omit<CoreCommerceFacet<CategoryFacetValueRequest, Ca
|
|
|
44
44
|
* @returns A `CategoryFacet` sub-controller instance.
|
|
45
45
|
* */
|
|
46
46
|
export declare function buildCategoryFacet(engine: CommerceEngine, options: CategoryFacetOptions): CategoryFacet;
|
|
47
|
-
export declare const getCategoryFacetState: (coreState: CoreCommerceFacetState<CategoryFacetValue>, facetSearchSelector: ReturnType<typeof categoryFacetSearchStateSelector
|
|
47
|
+
export declare const getCategoryFacetState: (coreState: CoreCommerceFacetState<CategoryFacetValue>, facetSearchSelector: ReturnType<typeof categoryFacetSearchStateSelector>, request: CategoryFacetRequest | undefined) => CategoryFacetState;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { BaseFacetSearchResult } from '../../../../../api/search/facet-search/base/base-facet-search-response.js';
|
|
2
|
-
import { CategoryFacetSearchResult } from '../../../../../api/search/facet-search/category-facet-search/category-facet-search-response.js';
|
|
3
|
-
import { CommerceEngine } from '../../../../../app/commerce-engine/commerce-engine.js';
|
|
4
|
-
import { ControllerDefinitionOption, SolutionType, SubControllerDefinitionWithoutProps } from '../../../../../app/commerce-ssr-engine/types/common.js';
|
|
5
|
-
import { LocationFacetValue, RegularFacetValue } from '../../../../../features/commerce/facets/facet-set/interfaces/response.js';
|
|
6
|
-
import { CategoryFacet, CategoryFacetState } from '../category/headless-commerce-category-facet.js';
|
|
7
|
-
import { DateFacet, DateFacetState, DateFacetValue } from '../date/headless-commerce-date-facet.js';
|
|
8
|
-
import { CategoryFacetValue, FacetType, CoreCommerceFacet } from '../headless-core-commerce-facet.js';
|
|
9
|
-
import { LocationFacet, LocationFacetState } from '../location/headless-commerce-location-facet.js';
|
|
10
|
-
import { NumericFacet, NumericFacetValue, NumericFacetState } from '../numeric/headless-commerce-numeric-facet.js';
|
|
11
|
-
import { RegularFacet, RegularFacetState } from '../regular/headless-commerce-regular-facet.js';
|
|
12
|
-
import { FacetGenerator as CSRFacetGenerator, MappedGeneratedFacetController } from './headless-commerce-facet-generator.js';
|
|
1
|
+
import type { BaseFacetSearchResult } from '../../../../../api/search/facet-search/base/base-facet-search-response.js';
|
|
2
|
+
import type { CategoryFacetSearchResult } from '../../../../../api/search/facet-search/category-facet-search/category-facet-search-response.js';
|
|
3
|
+
import type { CommerceEngine } from '../../../../../app/commerce-engine/commerce-engine.js';
|
|
4
|
+
import { type ControllerDefinitionOption, SolutionType, type SubControllerDefinitionWithoutProps } from '../../../../../app/commerce-ssr-engine/types/common.js';
|
|
5
|
+
import type { LocationFacetValue, RegularFacetValue } from '../../../../../features/commerce/facets/facet-set/interfaces/response.js';
|
|
6
|
+
import type { CategoryFacet, CategoryFacetState } from '../category/headless-commerce-category-facet.js';
|
|
7
|
+
import type { DateFacet, DateFacetState, DateFacetValue } from '../date/headless-commerce-date-facet.js';
|
|
8
|
+
import type { CategoryFacetValue, FacetType, CoreCommerceFacet } from '../headless-core-commerce-facet.js';
|
|
9
|
+
import type { LocationFacet, LocationFacetState } from '../location/headless-commerce-location-facet.js';
|
|
10
|
+
import type { NumericFacet, NumericFacetValue, NumericFacetState } from '../numeric/headless-commerce-numeric-facet.js';
|
|
11
|
+
import type { RegularFacet, RegularFacetState } from '../regular/headless-commerce-regular-facet.js';
|
|
12
|
+
import type { FacetGenerator as CSRFacetGenerator, MappedGeneratedFacetController } from './headless-commerce-facet-generator.js';
|
|
13
13
|
export type { BaseFacetSearchResult, CategoryFacet, CategoryFacetState, CategoryFacetValue, CategoryFacetSearchResult, CoreCommerceFacet, DateFacet, DateFacetValue, DateFacetState, NumericFacet, NumericFacetValue, NumericFacetState, RegularFacet, RegularFacetState, RegularFacetValue, LocationFacet, LocationFacetState, LocationFacetValue, MappedGeneratedFacetController, };
|
|
14
14
|
export type FacetGeneratorState = MappedFacetStates;
|
|
15
15
|
export type MappedFacetStates = Array<MappedFacetState[FacetType]>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { CommerceEngine } from '../../../../app/commerce-engine/commerce-engine.js';
|
|
1
|
+
import type { CommerceEngine } from '../../../../app/commerce-engine/commerce-engine.js';
|
|
2
2
|
import { stateKey } from '../../../../app/state-key.js';
|
|
3
|
-
import { FacetType } from '../../../../features/commerce/facets/facet-set/interfaces/common.js';
|
|
4
|
-
import { AnyFacetRequest, CategoryFacetValueRequest, LocationFacetValueRequest } from '../../../../features/commerce/facets/facet-set/interfaces/request.js';
|
|
5
|
-
import { AnyFacetResponse, AnyFacetValueResponse, BaseFacetValue, CategoryFacetValue, DateFacetValue, LocationFacetValue, NumericFacetValue, RegularFacetValue } from '../../../../features/commerce/facets/facet-set/interfaces/response.js';
|
|
6
|
-
import { FacetValueRequest } from '../../../../features/facets/facet-set/interfaces/request.js';
|
|
7
|
-
import { AnyFacetValueRequest } from '../../../../features/facets/generic/interfaces/generic-facet-request.js';
|
|
8
|
-
import { CoreFacet as HeadlessCoreFacet, CoreFacetState } from '../../../core/facets/facet/headless-core-facet.js';
|
|
9
|
-
import { DateRangeRequest } from '../../../core/facets/range-facet/date-facet/headless-core-date-facet.js';
|
|
10
|
-
import { NumericRangeRequest } from '../../../core/facets/range-facet/numeric-facet/headless-core-numeric-facet.js';
|
|
11
|
-
import { FetchProductsActionCreator, ToggleActionCreator } from '../common.js';
|
|
3
|
+
import type { FacetType } from '../../../../features/commerce/facets/facet-set/interfaces/common.js';
|
|
4
|
+
import type { AnyFacetRequest, CategoryFacetValueRequest, LocationFacetValueRequest } from '../../../../features/commerce/facets/facet-set/interfaces/request.js';
|
|
5
|
+
import type { AnyFacetResponse, AnyFacetValueResponse, BaseFacetValue, CategoryFacetValue, DateFacetValue, LocationFacetValue, NumericFacetValue, RegularFacetValue } from '../../../../features/commerce/facets/facet-set/interfaces/response.js';
|
|
6
|
+
import type { FacetValueRequest } from '../../../../features/facets/facet-set/interfaces/request.js';
|
|
7
|
+
import type { AnyFacetValueRequest } from '../../../../features/facets/generic/interfaces/generic-facet-request.js';
|
|
8
|
+
import type { CoreFacet as HeadlessCoreFacet, CoreFacetState } from '../../../core/facets/facet/headless-core-facet.js';
|
|
9
|
+
import type { DateRangeRequest } from '../../../core/facets/range-facet/date-facet/headless-core-date-facet.js';
|
|
10
|
+
import type { NumericRangeRequest } from '../../../core/facets/range-facet/numeric-facet/headless-core-numeric-facet.js';
|
|
11
|
+
import type { FetchProductsActionCreator, ToggleActionCreator } from '../common.js';
|
|
12
12
|
export type { FacetType, FacetValueRequest, RegularFacetValue, LocationFacetValueRequest, LocationFacetValue, NumericRangeRequest, NumericFacetValue, DateRangeRequest, DateFacetValue, CategoryFacetValueRequest, CategoryFacetValue, BaseFacetValue, };
|
|
13
13
|
export interface FacetControllerType<T extends FacetType> {
|
|
14
14
|
type: T;
|
package/dist/definitions/features/commerce/facets/category-facet/category-facet-actions.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import { ToggleSelectCategoryFacetValueActionCreatorPayload, UpdateCategoryFacetNumberOfValuesActionCreatorPayload } from '../../../facets/category-facet-set/category-facet-set-actions.js';
|
|
1
|
+
import type { ToggleSelectCategoryFacetValueActionCreatorPayload, UpdateCategoryFacetNumberOfValuesActionCreatorPayload } from '../../../facets/category-facet-set/category-facet-set-actions.js';
|
|
2
2
|
export type UpdateCategoryFacetNumberOfValuesPayload = UpdateCategoryFacetNumberOfValuesActionCreatorPayload;
|
|
3
3
|
export declare const updateCategoryFacetNumberOfValues: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: UpdateCategoryFacetNumberOfValuesActionCreatorPayload], UpdateCategoryFacetNumberOfValuesActionCreatorPayload, "commerce/facets/categoryFacet/updateNumberOfValues", never, never>;
|
|
4
|
-
export type ToggleSelectCategoryFacetValuePayload = ToggleSelectCategoryFacetValueActionCreatorPayload
|
|
5
|
-
|
|
4
|
+
export type ToggleSelectCategoryFacetValuePayload = Omit<ToggleSelectCategoryFacetValueActionCreatorPayload, 'retrieveCount'> & {
|
|
5
|
+
/**
|
|
6
|
+
* The number of child values to display.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated This property is no longer used in the commerce category facet and will be removed in the next major version of headless.
|
|
9
|
+
*/
|
|
10
|
+
retrieveCount?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const toggleSelectCategoryFacetValue: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: ToggleSelectCategoryFacetValuePayload], ToggleSelectCategoryFacetValuePayload, "commerce/facets/categoryFacet/toggleSelectValue", import("@reduxjs/toolkit").SerializedError | null, never>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Parameters } from '../../parameters/parameters-actions.js';
|
|
2
|
-
import { CommerceFacetSetState } from './facet-set-state.js';
|
|
3
|
-
import { CategoryFacetRequest, CategoryFacetValueRequest } from './interfaces/request.js';
|
|
1
|
+
import type { Parameters } from '../../parameters/parameters-actions.js';
|
|
2
|
+
import type { CommerceFacetSetState } from './facet-set-state.js';
|
|
3
|
+
import type { CategoryFacetRequest, CategoryFacetValueRequest } from './interfaces/request.js';
|
|
4
4
|
export declare function restoreFromParameters(state: CommerceFacetSetState, action: {
|
|
5
5
|
payload: Parameters;
|
|
6
6
|
}): void;
|
|
@@ -8,6 +8,6 @@ export declare function buildSelectedFacetValueRequest(rawValue: string): {
|
|
|
8
8
|
state: string;
|
|
9
9
|
value: string;
|
|
10
10
|
};
|
|
11
|
-
export declare function selectPath(request: CategoryFacetRequest, path: string[], initialNumberOfValues
|
|
12
|
-
export declare function buildCurrentValuesFromPath(path: string[]
|
|
13
|
-
export declare function buildCategoryFacetValueRequest(value: string
|
|
11
|
+
export declare function selectPath(request: CategoryFacetRequest, path: string[], initialNumberOfValues?: number): void;
|
|
12
|
+
export declare function buildCurrentValuesFromPath(path: string[]): CategoryFacetValueRequest[];
|
|
13
|
+
export declare function buildCategoryFacetValueRequest(value: string): CategoryFacetValueRequest;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { CategoryFacetValueRequest } from '../../../../controllers/commerce/core/facets/headless-core-commerce-facet.js';
|
|
2
|
-
import '
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { CategoryFacetValue, LocationFacetValue } from './interfaces/response.js';
|
|
1
|
+
import type { CategoryFacetValueRequest } from '../../../../controllers/commerce/core/facets/headless-core-commerce-facet.js';
|
|
2
|
+
import { type CommerceFacetSetState } from './facet-set-state.js';
|
|
3
|
+
import type { LocationFacetValueRequest } from './interfaces/request.js';
|
|
4
|
+
import type { CategoryFacetValue, LocationFacetValue } from './interfaces/response.js';
|
|
6
5
|
export declare const commerceFacetSetReducer: import("redux").Reducer<CommerceFacetSetState> & {
|
|
7
6
|
getInitialState: () => CommerceFacetSetState;
|
|
8
7
|
};
|
|
@@ -6,11 +6,12 @@ export type FreezableFacetRequestProperties = {
|
|
|
6
6
|
preventAutoSelect: boolean;
|
|
7
7
|
freezeCurrentValues?: boolean;
|
|
8
8
|
};
|
|
9
|
-
export type CategoryFacetRequest = BaseCommerceFacetRequest<CategoryFacetValueRequest, 'hierarchical'> & CategoryFacetDelimitingCharacter & FreezableFacetRequestProperties
|
|
9
|
+
export type CategoryFacetRequest = BaseCommerceFacetRequest<CategoryFacetValueRequest, 'hierarchical'> & CategoryFacetDelimitingCharacter & FreezableFacetRequestProperties & {
|
|
10
|
+
retrieveCount?: number;
|
|
11
|
+
};
|
|
10
12
|
export interface CategoryFacetValueRequest extends BaseFacetValueRequest {
|
|
11
13
|
children: CategoryFacetValueRequest[];
|
|
12
14
|
value: string;
|
|
13
|
-
retrieveCount?: number;
|
|
14
15
|
}
|
|
15
16
|
export type DateFacetRequest = BaseCommerceFacetRequest<DateRangeRequest, 'dateRange'> & FreezableFacetRequestProperties;
|
|
16
17
|
export type NumericFacetRequest = BaseCommerceFacetRequest<NumericRangeRequest, 'numericalRange'> & NumericFacetExtraProperties & FreezableFacetRequestProperties;
|
|
@@ -21,7 +22,7 @@ export type BaseCommerceFacetRequest<Value, Type extends FacetType> = Pick<Facet
|
|
|
21
22
|
displayName?: string;
|
|
22
23
|
type: Type;
|
|
23
24
|
values: Value[];
|
|
24
|
-
initialNumberOfValues
|
|
25
|
+
initialNumberOfValues?: number;
|
|
25
26
|
numberOfValues?: number;
|
|
26
27
|
};
|
|
27
28
|
export type AnyFacetValueRequest = FacetValueRequest | LocationFacetValueRequest | CategoryFacetValueRequest | NumericRangeRequest | DateRangeRequest;
|
package/dist/esm/controllers/commerce/core/facets/category/headless-commerce-category-facet.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { stateKey } from '../../../../../app/state-key.js';
|
|
2
2
|
import { toggleSelectCategoryFacetValue, updateCategoryFacetNumberOfValues, } from '../../../../../features/commerce/facets/category-facet/category-facet-actions.js';
|
|
3
|
-
import {
|
|
3
|
+
import { facetRequestSelector } from '../../../../../features/commerce/facets/facet-set/facet-set-selector.js';
|
|
4
4
|
import { findActiveValueAncestry } from '../../../../../features/facets/category-facet-set/category-facet-utils.js';
|
|
5
5
|
import { categoryFacetSearchStateSelector } from '../../../../../features/facets/facet-search-set/category/category-facet-search-state-selector.js';
|
|
6
6
|
import { buildCoreCommerceFacet, } from '../headless-core-commerce-facet.js';
|
|
@@ -26,53 +26,63 @@ export function buildCategoryFacet(engine, options) {
|
|
|
26
26
|
});
|
|
27
27
|
const { deselectAll, isValueSelected, subscribe, toggleSelect } = coreController;
|
|
28
28
|
const { dispatch } = engine;
|
|
29
|
-
const
|
|
29
|
+
const { facetId } = options;
|
|
30
30
|
const facetSearch = buildCategoryFacetSearch(engine, {
|
|
31
|
-
options: { facetId
|
|
31
|
+
options: { facetId, ...options.facetSearch },
|
|
32
32
|
select: () => {
|
|
33
33
|
dispatch(options.fetchProductsActionCreator());
|
|
34
34
|
},
|
|
35
35
|
isForFieldSuggestions: false,
|
|
36
36
|
});
|
|
37
|
+
const getRequest = () => facetRequestSelector(engine[stateKey], facetId);
|
|
37
38
|
return {
|
|
38
39
|
deselectAll,
|
|
39
40
|
isValueSelected,
|
|
40
41
|
subscribe,
|
|
41
42
|
toggleSelect,
|
|
42
43
|
showMoreValues() {
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const { initialNumberOfValues, values, numberOfValues } = getRequest();
|
|
45
|
+
if (!initialNumberOfValues && !numberOfValues) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const newNumberOfValues = values.length + (initialNumberOfValues ?? numberOfValues);
|
|
49
|
+
dispatch(updateCategoryFacetNumberOfValues({
|
|
50
|
+
facetId,
|
|
51
|
+
numberOfValues: newNumberOfValues,
|
|
52
|
+
}));
|
|
48
53
|
dispatch(options.fetchProductsActionCreator());
|
|
49
54
|
},
|
|
50
55
|
showLessValues() {
|
|
51
|
-
const
|
|
56
|
+
const request = getRequest();
|
|
57
|
+
const numberOfValues = request.initialNumberOfValues ?? 1;
|
|
52
58
|
dispatch(updateCategoryFacetNumberOfValues({
|
|
53
59
|
facetId,
|
|
54
|
-
numberOfValues
|
|
60
|
+
numberOfValues,
|
|
55
61
|
}));
|
|
56
62
|
dispatch(options.fetchProductsActionCreator());
|
|
57
63
|
},
|
|
58
64
|
facetSearch,
|
|
59
65
|
get state() {
|
|
60
|
-
return getCategoryFacetState(coreController.state, categoryFacetSearchStateSelector(engine[stateKey],
|
|
66
|
+
return getCategoryFacetState(coreController.state, categoryFacetSearchStateSelector(engine[stateKey], facetId), getRequest());
|
|
61
67
|
},
|
|
62
68
|
type: 'hierarchical',
|
|
63
69
|
};
|
|
64
70
|
}
|
|
65
|
-
export const getCategoryFacetState = (coreState, facetSearchSelector) => {
|
|
71
|
+
export const getCategoryFacetState = (coreState, facetSearchSelector, request) => {
|
|
66
72
|
const { values } = coreState;
|
|
67
73
|
const selectedValueAncestry = findActiveValueAncestry(values);
|
|
68
74
|
const activeValue = selectedValueAncestry.length
|
|
69
75
|
? selectedValueAncestry[selectedValueAncestry.length - 1]
|
|
70
76
|
: undefined;
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
const initialNumberOfValues = request?.initialNumberOfValues;
|
|
78
|
+
const canShowLessValues = !!initialNumberOfValues &&
|
|
79
|
+
(activeValue
|
|
80
|
+
? initialNumberOfValues < activeValue.children.length
|
|
81
|
+
: initialNumberOfValues <
|
|
82
|
+
(request.numberOfValues ?? coreState.values.length));
|
|
83
|
+
const canShowMoreValues = activeValue
|
|
84
|
+
? activeValue.moreValuesAvailable
|
|
85
|
+
: coreState.canShowMoreValues;
|
|
76
86
|
return {
|
|
77
87
|
...coreState,
|
|
78
88
|
activeValue,
|
|
@@ -84,7 +94,7 @@ export const getCategoryFacetState = (coreState, facetSearchSelector) => {
|
|
|
84
94
|
query: facetSearchSelector?.options.query ?? '',
|
|
85
95
|
values: facetSearchSelector?.response.values ?? [],
|
|
86
96
|
},
|
|
87
|
-
hasActiveValues,
|
|
97
|
+
hasActiveValues: !!activeValue,
|
|
88
98
|
selectedValueAncestry,
|
|
89
99
|
type: 'hierarchical',
|
|
90
100
|
values,
|
package/dist/esm/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.js
CHANGED
|
@@ -11,12 +11,12 @@ import { isFacetLoadingResponseSelector as listingIsFacetLoadingResponseSelector
|
|
|
11
11
|
import { buildProductListing } from '../../../product-listing/headless-product-listing.js';
|
|
12
12
|
import { isFacetLoadingResponseSelector as searchIsFacetLoadingResponseSelector, facetResponseSelector as searchFacetResponseSelector, } from '../../../search/facets/headless-search-facet-options.js';
|
|
13
13
|
import { buildSearch } from '../../../search/headless-search.js';
|
|
14
|
-
import { getCategoryFacetState
|
|
15
|
-
import { getDateFacetState
|
|
16
|
-
import { getCoreFacetState
|
|
17
|
-
import { getLocationFacetState
|
|
18
|
-
import { getNumericFacetState
|
|
19
|
-
import { getRegularFacetState
|
|
14
|
+
import { getCategoryFacetState } from '../category/headless-commerce-category-facet.js';
|
|
15
|
+
import { getDateFacetState } from '../date/headless-commerce-date-facet.js';
|
|
16
|
+
import { getCoreFacetState } from '../headless-core-commerce-facet.js';
|
|
17
|
+
import { getLocationFacetState } from '../location/headless-commerce-location-facet.js';
|
|
18
|
+
import { getNumericFacetState } from '../numeric/headless-commerce-numeric-facet.js';
|
|
19
|
+
import { getRegularFacetState } from '../regular/headless-commerce-regular-facet.js';
|
|
20
20
|
/**
|
|
21
21
|
* @group Definers
|
|
22
22
|
*/
|
|
@@ -73,7 +73,7 @@ export function buildFacetGenerator(engine, options) {
|
|
|
73
73
|
const facetId = facetResponseSelector.facetId;
|
|
74
74
|
switch (facetResponseSelector.type) {
|
|
75
75
|
case 'hierarchical':
|
|
76
|
-
return getCategoryFacetState(createFacetState(facetResponseSelector), categoryFacetSearchStateSelector(getEngineState(), facetId));
|
|
76
|
+
return getCategoryFacetState(createFacetState(facetResponseSelector), categoryFacetSearchStateSelector(getEngineState(), facetId), facetRequestSelector(getEngineState(), facetId));
|
|
77
77
|
case 'dateRange':
|
|
78
78
|
return getDateFacetState(createFacetState(facetResponseSelector));
|
|
79
79
|
case 'numericalRange':
|
|
@@ -24,9 +24,6 @@ export function buildCoreCommerceFacet(engine, props) {
|
|
|
24
24
|
dispatch(props.options.toggleSelectActionCreator({
|
|
25
25
|
selection,
|
|
26
26
|
facetId,
|
|
27
|
-
...('retrieveCount' in selection
|
|
28
|
-
? { retrieveCount: selection.retrieveCount }
|
|
29
|
-
: {}),
|
|
30
27
|
}));
|
|
31
28
|
dispatch(props.options.fetchProductsActionCreator());
|
|
32
29
|
},
|
|
@@ -98,9 +98,15 @@ function restoreCategoryFacets(state, parameterFacets) {
|
|
|
98
98
|
// eslint-disable-next-line @cspell/spellchecker
|
|
99
99
|
// TODO CAPI-966: Remove delimitingCharacter
|
|
100
100
|
delimitingCharacter: '|',
|
|
101
|
+
// In the CAPI, the default retrieveCount is 5, while the default
|
|
102
|
+
// numberOfValues is 8. We explicitly set retrieveCount to 8 when
|
|
103
|
+
// restoring category facets to ensure a consistent show more / show
|
|
104
|
+
// less behavior, given that the retrieveCount is not returned in the
|
|
105
|
+
// API response.
|
|
106
|
+
retrieveCount: 8,
|
|
101
107
|
},
|
|
102
108
|
};
|
|
103
|
-
selectPath(state[facetId].request, path
|
|
109
|
+
selectPath(state[facetId].request, path);
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
112
|
function restoreFacet(facetId) {
|
|
@@ -111,7 +117,6 @@ function restoreFacet(facetId) {
|
|
|
111
117
|
field: facetId,
|
|
112
118
|
isFieldExpanded: false,
|
|
113
119
|
preventAutoSelect: false,
|
|
114
|
-
initialNumberOfValues: 10,
|
|
115
120
|
};
|
|
116
121
|
}
|
|
117
122
|
function restoreFacetValue() {
|
|
@@ -121,7 +126,6 @@ function restoreFacetValue() {
|
|
|
121
126
|
state: 'selected',
|
|
122
127
|
isAutoSelected: false,
|
|
123
128
|
isSuggested: false,
|
|
124
|
-
numberOfResults: 10,
|
|
125
129
|
moreValuesAvailable: true,
|
|
126
130
|
};
|
|
127
131
|
}
|
|
@@ -129,30 +133,29 @@ export function buildSelectedFacetValueRequest(rawValue) {
|
|
|
129
133
|
return { state: 'selected', value: rawValue };
|
|
130
134
|
}
|
|
131
135
|
export function selectPath(request, path, initialNumberOfValues) {
|
|
132
|
-
request.values = buildCurrentValuesFromPath(path
|
|
133
|
-
request.numberOfValues =
|
|
136
|
+
request.values = buildCurrentValuesFromPath(path);
|
|
137
|
+
request.numberOfValues = initialNumberOfValues;
|
|
134
138
|
request.preventAutoSelect = true;
|
|
135
139
|
}
|
|
136
|
-
export function buildCurrentValuesFromPath(path
|
|
140
|
+
export function buildCurrentValuesFromPath(path) {
|
|
137
141
|
if (!path.length) {
|
|
138
142
|
return [];
|
|
139
143
|
}
|
|
140
|
-
const root = buildCategoryFacetValueRequest(path[0]
|
|
144
|
+
const root = buildCategoryFacetValueRequest(path[0]);
|
|
141
145
|
let curr = root;
|
|
142
146
|
const [_first, ...rest] = path;
|
|
143
147
|
for (const segment of rest) {
|
|
144
|
-
const next = buildCategoryFacetValueRequest(segment
|
|
148
|
+
const next = buildCategoryFacetValueRequest(segment);
|
|
145
149
|
curr.children.push(next);
|
|
146
150
|
curr = next;
|
|
147
151
|
}
|
|
148
152
|
curr.state = 'selected';
|
|
149
153
|
return [root];
|
|
150
154
|
}
|
|
151
|
-
export function buildCategoryFacetValueRequest(value
|
|
155
|
+
export function buildCategoryFacetValueRequest(value) {
|
|
152
156
|
return {
|
|
153
157
|
children: [],
|
|
154
158
|
state: 'idle',
|
|
155
159
|
value,
|
|
156
|
-
retrieveCount,
|
|
157
160
|
};
|
|
158
161
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { createReducer } from '@reduxjs/toolkit';
|
|
2
|
-
import { defaultNumberOfValuesIncrement } from '../../../facets/category-facet-set/category-facet-set-actions.js';
|
|
3
2
|
import { selectCategoryFacetSearchResult } from '../../../facets/facet-search-set/category/category-facet-search-actions.js';
|
|
4
3
|
import { excludeFacetSearchResult, selectFacetSearchResult, } from '../../../facets/facet-search-set/specific/specific-facet-search-actions.js';
|
|
5
4
|
import { convertFacetValueToRequest } from '../../../facets/facet-set/facet-set-slice.js';
|
|
6
|
-
import { handleFacetUpdateNumberOfValues } from '../../../facets/generic/facet-reducer-helpers.js';
|
|
7
5
|
import { convertToDateRangeRequests } from '../../../facets/range-facets/date-facet-set/date-facet-set-slice.js';
|
|
8
6
|
import { findExactRangeValue } from '../../../facets/range-facets/generic/range-facet-reducers.js';
|
|
9
7
|
import { convertToNumericRangeRequests } from '../../../facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js';
|
|
@@ -13,7 +11,6 @@ import { fetchProductListing } from '../../product-listing/product-listing-actio
|
|
|
13
11
|
import { fetchQuerySuggestions } from '../../query-suggest/query-suggest-actions.js';
|
|
14
12
|
import { restoreSearchParameters } from '../../search-parameters/search-parameters-actions.js';
|
|
15
13
|
import { executeSearch } from '../../search/search-actions.js';
|
|
16
|
-
import '../category-facet/category-facet-actions.js';
|
|
17
14
|
import { toggleSelectCategoryFacetValue, updateCategoryFacetNumberOfValues, } from '../category-facet/category-facet-actions.js';
|
|
18
15
|
import { deselectAllValuesInCoreFacet, updateCoreFacetFreezeCurrentValues, updateCoreFacetIsFieldExpanded, updateCoreFacetNumberOfValues, updateAutoSelectionForAllCoreFacets, clearAllCoreFacets, deleteAllCoreFacets, } from '../core-facet/core-facet-actions.js';
|
|
19
16
|
import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, updateDateFacetValues, } from '../date-facet/date-facet-actions.js';
|
|
@@ -21,7 +18,6 @@ import { executeCommerceFieldSuggest, getFacetIdWithCommerceFieldSuggestionNames
|
|
|
21
18
|
import { toggleSelectLocationFacetValue } from '../location-facet/location-facet-actions.js';
|
|
22
19
|
import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, updateManualNumericFacetRange, updateNumericFacetValues, } from '../numeric-facet/numeric-facet-actions.js';
|
|
23
20
|
import { toggleExcludeFacetValue, toggleSelectFacetValue, } from '../regular-facet/regular-facet-actions.js';
|
|
24
|
-
import { handleCategoryFacetNestedNumberOfValuesUpdate } from './facet-set-reducer-helpers.js';
|
|
25
21
|
import { buildCategoryFacetValueRequest, buildSelectedFacetValueRequest, restoreFromParameters, selectPath, } from './facet-set-reducers.js';
|
|
26
22
|
import { getCommerceFacetSetInitialState, } from './facet-set-state.js';
|
|
27
23
|
export const commerceFacetSetReducer = createReducer(getCommerceFacetSetInitialState(), (builder) => {
|
|
@@ -99,24 +95,25 @@ export const commerceFacetSetReducer = createReducer(getCommerceFacetSetInitialS
|
|
|
99
95
|
updateExistingFacetValueState(existingValue, 'select');
|
|
100
96
|
})
|
|
101
97
|
.addCase(toggleSelectCategoryFacetValue, (state, action) => {
|
|
102
|
-
const { facetId, selection
|
|
98
|
+
const { facetId, selection } = action.payload;
|
|
103
99
|
const request = state[facetId]?.request;
|
|
104
|
-
if (!
|
|
100
|
+
if (!ensureCategoryFacetRequest(request)) {
|
|
105
101
|
return;
|
|
106
102
|
}
|
|
107
103
|
const { path } = selection;
|
|
108
104
|
const pathToSelection = path.slice(0, path.length - 1);
|
|
109
|
-
const children = ensurePathAndReturnChildren(request, pathToSelection
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
105
|
+
const children = ensurePathAndReturnChildren(request, pathToSelection);
|
|
106
|
+
let selectedValue = children.find((value) => value.value === selection.value);
|
|
107
|
+
if (!selectedValue) {
|
|
108
|
+
selectedValue = buildCategoryFacetValueRequest(selection.value);
|
|
109
|
+
children.push(selectedValue);
|
|
110
|
+
}
|
|
111
|
+
selectedValue.state =
|
|
112
|
+
selectedValue.state === 'idle' ? 'selected' : 'idle';
|
|
113
|
+
if (selectedValue.state === 'selected') {
|
|
114
|
+
request.numberOfValues = request.initialNumberOfValues;
|
|
115
|
+
request.retrieveCount = request.initialNumberOfValues;
|
|
115
116
|
}
|
|
116
|
-
const newParent = buildCategoryFacetValueRequest(selection.value, retrieveCount);
|
|
117
|
-
newParent.state = 'selected';
|
|
118
|
-
children.push(newParent);
|
|
119
|
-
request.numberOfValues = 1;
|
|
120
117
|
})
|
|
121
118
|
.addCase(toggleExcludeFacetValue, (state, action) => {
|
|
122
119
|
const { facetId, selection } = action.payload;
|
|
@@ -169,13 +166,10 @@ export const commerceFacetSetReducer = createReducer(getCommerceFacetSetInitialS
|
|
|
169
166
|
.addCase(updateCategoryFacetNumberOfValues, (state, action) => {
|
|
170
167
|
const { facetId, numberOfValues } = action.payload;
|
|
171
168
|
const request = state[facetId]?.request;
|
|
172
|
-
if (!request) {
|
|
169
|
+
if (!ensureCategoryFacetRequest(request)) {
|
|
173
170
|
return;
|
|
174
171
|
}
|
|
175
|
-
|
|
176
|
-
return handleFacetUpdateNumberOfValues(request, numberOfValues);
|
|
177
|
-
}
|
|
178
|
-
handleCategoryFacetNestedNumberOfValuesUpdate(state, action.payload);
|
|
172
|
+
handleCategoryFacetUpdateNumberOfValues(request, numberOfValues);
|
|
179
173
|
})
|
|
180
174
|
.addCase(selectFacetSearchResult, (state, action) => {
|
|
181
175
|
const { facetId, value } = action.payload;
|
|
@@ -202,8 +196,7 @@ export const commerceFacetSetReducer = createReducer(getCommerceFacetSetInitialS
|
|
|
202
196
|
const { rawValue } = value;
|
|
203
197
|
facetRequest.freezeCurrentValues = true;
|
|
204
198
|
facetRequest.preventAutoSelect = true;
|
|
205
|
-
const existingValue = facetRequest.values.find((v) => v.value ===
|
|
206
|
-
rawValue);
|
|
199
|
+
const existingValue = facetRequest.values.find((v) => v.value === rawValue);
|
|
207
200
|
if (!existingValue) {
|
|
208
201
|
insertNewValue(facetRequest, { state: 'excluded', value: rawValue });
|
|
209
202
|
return;
|
|
@@ -212,13 +205,12 @@ export const commerceFacetSetReducer = createReducer(getCommerceFacetSetInitialS
|
|
|
212
205
|
})
|
|
213
206
|
.addCase(selectCategoryFacetSearchResult, (state, action) => {
|
|
214
207
|
const { facetId, value } = action.payload;
|
|
215
|
-
const
|
|
216
|
-
if (!
|
|
217
|
-
!ensureCategoryFacetRequest(facetRequest?.request)) {
|
|
208
|
+
const request = state[facetId]?.request;
|
|
209
|
+
if (!ensureCategoryFacetRequest(request)) {
|
|
218
210
|
return;
|
|
219
211
|
}
|
|
220
212
|
const path = [...value.path, value.rawValue];
|
|
221
|
-
selectPath(
|
|
213
|
+
selectPath(request, path, request.initialNumberOfValues);
|
|
222
214
|
})
|
|
223
215
|
.addCase(updateNumericFacetValues, (state, action) => {
|
|
224
216
|
const { facetId, values } = action.payload;
|
|
@@ -301,7 +293,7 @@ function ensureDateFacetRequest(facetRequest) {
|
|
|
301
293
|
return facetRequest.type === 'dateRange';
|
|
302
294
|
}
|
|
303
295
|
function ensureCategoryFacetRequest(facetRequest) {
|
|
304
|
-
return facetRequest
|
|
296
|
+
return facetRequest?.type === 'hierarchical';
|
|
305
297
|
}
|
|
306
298
|
function handleQueryFulfilled(state, action) {
|
|
307
299
|
const existingFacets = new Set(Object.keys(state));
|
|
@@ -324,7 +316,8 @@ function handleFieldSuggestionsFulfilled(state, facetId) {
|
|
|
324
316
|
}
|
|
325
317
|
function handleDeselectAllFacetValues(request) {
|
|
326
318
|
if (request.type === 'hierarchical') {
|
|
327
|
-
request.
|
|
319
|
+
request.initialNumberOfValues = undefined;
|
|
320
|
+
request.numberOfValues = undefined;
|
|
328
321
|
request.values = [];
|
|
329
322
|
request.preventAutoSelect = true;
|
|
330
323
|
}
|
|
@@ -332,13 +325,21 @@ function handleDeselectAllFacetValues(request) {
|
|
|
332
325
|
request.values.forEach((value) => (value.state = 'idle'));
|
|
333
326
|
}
|
|
334
327
|
}
|
|
335
|
-
|
|
328
|
+
/**
|
|
329
|
+
* Traverses the request values and validates the path, building new values for
|
|
330
|
+
* missing path segments if needed, then returns the children of the last
|
|
331
|
+
* visited value.
|
|
332
|
+
*
|
|
333
|
+
* Used to navigate to a specific level in the category tree before manipulating
|
|
334
|
+
* values.
|
|
335
|
+
*/
|
|
336
|
+
function ensurePathAndReturnChildren(request, path) {
|
|
336
337
|
let children = request.values;
|
|
337
338
|
for (const segment of path) {
|
|
338
339
|
let parent = children[0];
|
|
339
340
|
const missingParent = !parent;
|
|
340
341
|
if (missingParent || segment !== parent.value) {
|
|
341
|
-
parent = buildCategoryFacetValueRequest(segment
|
|
342
|
+
parent = buildCategoryFacetValueRequest(segment);
|
|
342
343
|
children.length = 0;
|
|
343
344
|
children.push(parent);
|
|
344
345
|
}
|
|
@@ -371,11 +372,13 @@ function updateStateFromFacetResponse(state, facetResponse, facetsToRemove) {
|
|
|
371
372
|
if (!facetRequest) {
|
|
372
373
|
state[facetId] = { request: {} };
|
|
373
374
|
facetRequest = state[facetId].request;
|
|
374
|
-
facetRequest.initialNumberOfValues = facetResponse.numberOfValues;
|
|
375
375
|
}
|
|
376
376
|
else {
|
|
377
377
|
facetsToRemove.delete(facetId);
|
|
378
378
|
}
|
|
379
|
+
if (facetRequest.initialNumberOfValues === undefined) {
|
|
380
|
+
facetRequest.initialNumberOfValues = facetResponse.numberOfValues;
|
|
381
|
+
}
|
|
379
382
|
facetRequest.facetId = facetId;
|
|
380
383
|
facetRequest.displayName = facetResponse.displayName;
|
|
381
384
|
facetRequest.numberOfValues = facetResponse.numberOfValues;
|
|
@@ -407,9 +410,7 @@ function getFacetRequestValuesFromFacetResponse(facetResponse) {
|
|
|
407
410
|
case 'dateRange':
|
|
408
411
|
return convertToDateRangeRequests(facetResponse.values);
|
|
409
412
|
case 'hierarchical':
|
|
410
|
-
return facetResponse.values.
|
|
411
|
-
? []
|
|
412
|
-
: facetResponse.values.map(convertCategoryFacetValueToRequest);
|
|
413
|
+
return facetResponse.values.map(convertCategoryFacetValueToRequest);
|
|
413
414
|
case 'regular':
|
|
414
415
|
return facetResponse.values.map(convertFacetValueToRequest);
|
|
415
416
|
case 'location':
|
|
@@ -419,15 +420,12 @@ function getFacetRequestValuesFromFacetResponse(facetResponse) {
|
|
|
419
420
|
}
|
|
420
421
|
}
|
|
421
422
|
export function convertCategoryFacetValueToRequest(responseValue) {
|
|
422
|
-
const children = responseValue.children.
|
|
423
|
-
? []
|
|
424
|
-
: responseValue.children.map(convertCategoryFacetValueToRequest);
|
|
423
|
+
const children = responseValue.children.map(convertCategoryFacetValueToRequest);
|
|
425
424
|
const { state, value } = responseValue;
|
|
426
425
|
return {
|
|
427
426
|
children,
|
|
428
427
|
state,
|
|
429
428
|
value,
|
|
430
|
-
retrieveCount: defaultNumberOfValuesIncrement,
|
|
431
429
|
};
|
|
432
430
|
}
|
|
433
431
|
export function convertLocationFacetValueToRequest(facetValue) {
|
|
@@ -452,3 +450,7 @@ function clearAllFacetValues(state) {
|
|
|
452
450
|
facet.request.values = [];
|
|
453
451
|
});
|
|
454
452
|
}
|
|
453
|
+
function handleCategoryFacetUpdateNumberOfValues(facetRequest, numberOfValues) {
|
|
454
|
+
facetRequest.numberOfValues = numberOfValues;
|
|
455
|
+
facetRequest.retrieveCount = numberOfValues;
|
|
456
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "3.26.
|
|
1
|
+
export const VERSION = "3.26.2-pre.497e1d73bf" || 'Test version';
|
|
2
2
|
export const COVEO_FRAMEWORK = ['@coveo/atomic', '@coveo/quantic'];
|