Numeric facet sub-controller
Numeric facet sub-controller
|
|
Note
This component was introduced in version |
Create facet sub-controllers using FacetGenerator sub-controller of the Search controller.
const searchController = buildSearch(commerceEngine);
const facetGenerator = searchController.facetGenerator();
for (const facet of facetGenerator.facets) {
switch (facet.type) {
case 'regular':
// facet will be typed as RegularFacet, render it...
break;
case 'dateRange':
// facet will be typed as DateFacet, render it...
break;
case 'numericalRange':
// facet will be typed as NumericFacet, render it...
break;
case 'hierarchical':
// facet will be typed as CategoryFacet, render it...
}
}
Methods
deselectAll
Deselects all facet values.
isValueExcluded
Checks whether the specified facet value is excluded.
Parameters
-
value:
NumericFacetValueThe facet value to check.
Returns boolean: Whether the specified facet value is excluded.
isValueSelected
Checks whether the specified facet value is selected.
Parameters
-
value:
NumericFacetValueThe facet value to check.
Returns boolean: Whether the specified facet value is selected.
setRanges
Replaces the current range values with the specified ones.
Parameters
-
ranges:-
end:
stringThe end value of the range, formatted as
YYYY/MM/DD@HH:mm:ss. -
endInclusive:
booleanWhether to include the
endvalue in the range. -
start:
stringThe start value of the range, formatted as
YYYY/MM/DD@HH:mm:ss.
-
showLessValues
Sets the number of values displayed in the facet to the originally configured value.
showMoreValues
Increases the number of values displayed in the facet to the next multiple of the originally configured value.
toggleExclude
Toggles exclusion of the specified facet value.
Parameters
-
selection:
NumericFacetValueThe facet value to toggle exclusion.
toggleSelect
Toggles the specified facet value.
Parameters
-
selection:
NumericFacetValueThe facet value to toggle.
toggleSingleExclude
Excludes the specified facet value, deselecting others.
Parameters
-
selection:
NumericFacetValueThe facet value to toggle exclusion.
toggleSingleSelect
Toggles the specified facet value, deselecting others.
Parameters
-
selection:
NumericFacetValueThe facet value to toggle.
subscribe
Adds a callback that’s invoked on state change.
Parameters
-
listener:
() => voidA callback that’s invoked on state change.
Returns Unsubscribe: A function to remove the listener.
Attributes
type
The type of the facet.
state
The state of the Facet controller.
Properties
-
type:
'regular' | 'dateRange' | 'numericalRange' | 'hierarchical'The type of the facet.
-
canShowLessValues:
booleantrueif fewer values can be displayed andfalseotherwise. -
canShowMoreValues:
booleantrueif there are more values to display andfalseotherwise. -
facetId:
stringThe facet ID.
-
hasActiveValues:
booleantrueif there is at least one non-idle value andfalseotherwise. -
isLoading:
booleantrueif a search is in progress andfalseotherwise. -
values:
NumericFacetValue[]The values of the facet.
-
field:
stringThe facet field.
-
displayName?:
stringThe facet name.
-
domain?:
NumericFacetDomainThe domain of the numeric facet.
Related types
NumericFacetValue
Properties
-
numberOfResults:
numberThe number of results that have the facet value.
-
state:
'idle' | 'selected' | 'excluded'Whether a facet value is filtering results (
selected) or not (idle). -
value:
stringThe facet value.
Unsubscribe
Call signatures
-
(): void;
NumericFacetDomain
Properties
-
min:
numberThe minimum value of the domain.
-
max:
numberThe maximum value of the domain.