The Checkbox List Facet component renders a checkbox for each facet and may be nested depending on the configuration in the HawkSearch admin.

Tag

The tag for this component is <hawksearch-checkbox-list-facet>.

Event-Binding Attributes

Note: For Event-Binding attributes common to all facet type components, see BaseFacetComponent.

Handlebars Partials

Name Parameter
facet-checkbox-list Array<CheckboxListFacetValue>

This partial renders a checkbox for each facet value along with any applicable actions (include, exclude, toggle).

Note: For more information, see CheckboxListFacetValue.

{{#if length}}
<ul class="checkbox-list-facet__list">
{{#each this}}
{{#if visible}}
<li
class="checkbox-list-facet__list__item{{attribute ' checkbox-list-facet__list__item--excluded' excluded}}{{attribute
' checkbox-list-facet__list__item--collapsible'
hasChildren
}}"
>
<div class="checkbox-list-facet__list__item__content">
{{#if selected}}
<input id="{{@root.id}}-{{value}}" type="checkbox" checked hawksearch-facet-value value="{{value}}" />
{{else}}
<input id="{{@root.id}}-{{value}}" type="checkbox" hawksearch-facet-value value="{{value}}" />
{{/if}}
<label for="{{@root.id}}-{{value}}" class="facet__value">
<span class="facet__value__title checkbox-list-facet__list__item__title">{{title}}</span>
{{#if @root.displayCount}}
<span class="facet__value__count checkbox-list-facet__list__item__count">({{count}})</span>
{{/if}}
</label>
{{#if toggled}}
{{> facet-checkbox-list children}}
{{/if}}
</div>
{{#if (or @root.excludeEnabled hasChildren)}}
<div class="checkbox-list-facet__list__item__actions">
{{#if @root.excludeEnabled}}
{{#if excluded}}
<span hawksearch-facet-value-include="{{value}}" class="checkbox-list-facet__list__item__actions__item" title="{{@root.strings.include}}">
<hawksearch-icon name="plus" class="facet__heading__actions__item"></hawksearch-icon>
</span>
{{else}}
<span hawksearch-facet-value-exclude="{{value}}" class="checkbox-list-facet__list__item__actions__item" title="{{@root.strings.exclude}}">
<hawksearch-icon name="minus" class="facet__heading__actions__item"></hawksearch-icon>
</span>
{{/if}}
{{/if}}
{{#if hasChildren}}
<span hawksearch-facet-value-toggle="{{value}}" class="checkbox-list-facet__list__item__actions__item" title="{{if-else toggled @root.strings.collapse @root.strings.expand}}">
<hawksearch-icon name="{{if-else toggled 'chevron-down' 'chevron-right'}}" class="facet__heading__toggle"></hawksearch-icon>
</span>
{{/if}}
</div>
{{/if}}
</li>
{{/if}}
{{/each}}
</ul>
{{/if}}

Default Template

The following is the default Handlebars template for this component. To create a custom template, it is recommended to use this as a starting point.

<div class="checkbox-list-facet" {{attribute (concat 'style="max-height: ' maxHeight 'px;"') maxHeight}}>
{{> facet-checkbox-list values}}
{{#if showToggle}}
<span hawksearch-facet-toggle class="link facet__toggle">{{strings.toggle}}</span>
{{/if}}
</div>

Hierarchy

Properties

bindFromEvent: boolean = false
componentName: keyof HawkSearchComponents = 'checkbox-list-facet'

Optional instance-level configuration to override the global configuration

The data bound to the Handlebars template.

data?: Facet

The data bound to the component.

defaultHtml: string = defaultHtml
handlebars: typeof Handlebars = HawkSearch.handlebars

The Handlebars reference shared by all HawkSearch components.

state: FacetState

Accessors

  • get configuration(): undefined | TConfig
  • The optional configuration object for this component.

    Returns undefined | TConfig

  • get rootElement(): ParentNode
  • The root element which should be used for querying any child elements. This resolves to this.shadowRoot if the Shadow DOM is enabled, otherwise this.

    Returns ParentNode

Methods

  • After the component is rendered, this method is called to bind any child components.

    Returns void

  • Replaces placeholders in a given string with values from a data object.

    Parameters

    • template: string

      The template string.

    • values: Record<string, string>

      The object containing properties which will be bound to template.

    Returns string

    The template string with all placeholders replaced by the values specified in values.

  • After the component is rendered, this method is called for any additional processing (such as attaching event listeners) which needs to occur.

    Returns void

  • Optional method that can be overwritten to register Handlebars helper functions which can be accessed from the template. For more information, see Custom Helpers.

    Returns void

  • Determines whether the data meets the necessary conditions to perform data binding and render content.

    Returns boolean

    Whether the component should be rendered. If false, the component will have empty contents and be set to display: none;.