import { BaseComponentConfig, HawkSearchComponents } from '../configuration'; import { BaseComponentModel } from '../models'; /** * @typeParam TConfig Component configuration * @typeParam TData Component data * @typeParam TModel Data bound to Handlebars template * * @noInheritDoc * @category Base */ export declare abstract class BaseComponent extends HTMLElement { /** * Optional instance-level configuration to override the global configuration */ configOverride?: TConfig; /** * The data bound to the component. */ data?: TData; /** * The Handlebars reference shared by all HawkSearch components. */ protected handlebars: typeof Handlebars; /** * For components that may have multiple instances with different data sources, this property is used to identify the subset of data used for binding. * * @internal */ protected eventFilter?: string; /** * The data bound to the Handlebars template. */ protected contentModel?: TModel; /** * The name of the component. This value is appended to `hawksearch-` to determine the tag name. For example, a value of `search-results` would be rendered by ``. * * @internal */ protected abstract componentName: keyof HawkSearchComponents; /** * The deprecated name of the component, if this component was previously registered under a different name. When set, the component will also respond to the deprecated tag name, configuration key, and event names. * * @internal */ protected deprecatedComponentName?: keyof HawkSearchComponents; /** * The default Handlebars template. * * @internal */ protected abstract defaultHtml: string; /** * Determines whether the component is bound by an event. If `false`, binding is performed by the parent component. * * @internal */ protected abstract bindFromEvent: boolean; /** * The optional configuration object for this component. */ protected get configuration(): TConfig | undefined; protected get useCustomStyle(): boolean; /** * Whether or not the component is rendered within the Shadow DOM. In order of preference, this is specified by {@link configuration} or {@link Models.HawkSearchConfig.shadowDom}. * * @internal * @defaultValue `true` */ protected get shadowDom(): boolean; /** * 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`. */ get rootElement(): ParentNode; /** * The name of the event that this component listens to for data binding. if {@link bindFromEvent} is `true`, this prepends `hawksearch:bind-` to {@link componentName} and appends :{@link eventFilter}, if specified. * * @internal */ private get eventName(); /** * @internal */ private bindEventHandler?; /** * @internal */ private deprecatedBindEventHandler?; /** * @internal */ private template; /** * @ignore */ connectedCallback(): void; /** * @ignore */ disconnectedCallback(): 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](https://handlebarsjs.com/guide/#custom-helpers). * * @virtual */ protected registerHelpers(): void; /** * Binds {@link contentModel} to the Handlebars template and renders the resulting HTML content. */ render(): void; /** * Determines whether the {@link data} meets the necessary conditions to perform data binding and render content. * * @virtual * @returns Whether the component should be rendered. If `false`, the component will have empty contents and be set to `display: none;`. */ protected renderContent(): boolean; /** * Gets the data to be bound to the Handlebars template. * * @internal * @returns The data bound to the Handlebars template. */ protected abstract getContentModel(): TModel; /** * After the component is rendered, this method is called to bind any child components. * * @virtual */ protected bindChildElements(): void; /** * After the component is rendered, this method is called for any additional processing (such as attaching event listeners) which needs to occur. * * @virtual */ protected onRender(): void; /** * @returns The Handlebars template HTML. In order of preference, this is specified by the child contents of the HTML element, the template specified by {@link configuration}, or the default template for the component. * * @internal */ private getCustomTemplateHtml; /** * Replaces placeholders in a given string with values from a data object. * * @param template The template string. * @param values The object containing properties which will be bound to `template`. * @returns The `template` string with all placeholders replaced by the values specified in `values`. */ protected interpolate(template: string, values: Record): string; protected triggerEvent(name: string, data: T): void; }