This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
export declare type AutocompleteClassNames = {
detachedCancelButton: string;
detachedFormContainer: string;
detachedContainer: string;
detachedOverlay: string;
detachedSearchButton: string;
detachedSearchButtonIcon: string;
detachedSearchButtonPlaceholder: string;
detachedSearchButtonQuery: string;
form: string;
input: string;
inputWrapper: string;
inputWrapperPrefix: string;
inputWrapperSuffix: string;
item: string;
label: string;
list: string;
loadingIndicator: string;
panel: string;
panelLayout: string;
clearButton: string;
root: string;
source: string;
sourceFooter: string;
sourceHeader: string;
sourceNoResults: string;
submitButton: string;
};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,6 @@
import { BaseItem } from '../core';
import { InternalAutocompleteSource } from './AutocompleteSource';
export interface AutocompleteCollection<TItem extends BaseItem> {
source: InternalAutocompleteSource<TItem>;
items: TItem[];
}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,23 @@
/// <reference types="react" />
import { HighlightHitParams } from './HighlightHitParams';
declare type AutocompleteHighlightComponent = <THit>({ hit, attribute, tagName, }: HighlightHitParams<THit>) => JSX.Element;
export declare type PublicAutocompleteComponents = Record<string, (props: any) => JSX.Element>;
export interface AutocompleteComponents extends PublicAutocompleteComponents {
/**
* Highlight matches in an Algolia hit.
*/
Highlight: AutocompleteHighlightComponent;
/**
* Reverse-highlight matches in an Algolia hit.
*/
ReverseHighlight: AutocompleteHighlightComponent;
/**
* Reverse-highlight and snippets matches in an Algolia hit.
*/
ReverseSnippet: AutocompleteHighlightComponent;
/**
* Highlight and snippet matches in an Algolia hit.
*/
Snippet: AutocompleteHighlightComponent;
}
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,106 @@
import { AutocompleteScopeApi, AutocompleteOptions as AutocompleteCoreOptions, BaseItem, GetSourcesParams } from '../core';
import { MaybePromise } from '../MaybePromise';
import { AutocompleteClassNames } from './AutocompleteClassNames';
import { PublicAutocompleteComponents } from './AutocompleteComponents';
import { AutocompletePlugin } from './AutocompletePlugin';
import { AutocompletePropGetters } from './AutocompletePropGetters';
import { AutocompleteRender } from './AutocompleteRender';
import { AutocompleteRenderer } from './AutocompleteRenderer';
import { AutocompleteSource } from './AutocompleteSource';
import { AutocompleteState } from './AutocompleteState';
import { AutocompleteTranslations } from './AutocompleteTranslations';
export interface OnStateChangeProps<TItem extends BaseItem> extends AutocompleteScopeApi<TItem> {
/**
* The current Autocomplete state.
*/
state: AutocompleteState<TItem>;
/**
* The previous Autocomplete state.
*/
prevState: AutocompleteState<TItem>;
}
export declare type GetSources<TItem extends BaseItem> = (params: GetSourcesParams<TItem>) => MaybePromise<Array<AutocompleteSource<TItem> | boolean | undefined>>;
export interface AutocompleteOptions<TItem extends BaseItem> extends AutocompleteCoreOptions<TItem>, Partial<AutocompletePropGetters<TItem>> {
/**
* The container for the Autocomplete search box.
*
* You can either pass a [CSS selector](https://developer.mozilla.org/docs/Web/CSS/CSS_Selectors) or an [Element](https://developer.mozilla.org/docs/Web/API/HTMLElement). If there are several containers matching the selector, Autocomplete picks up the first one.
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-container
*/
container: string | HTMLElement;
/**
* The container for the Autocomplete panel.
*
* You can either pass a [CSS selector](https://developer.mozilla.org/docs/Web/CSS/CSS_Selectors) or an [Element](https://developer.mozilla.org/docs/Web/API/HTMLElement). If there are several containers matching the selector, Autocomplete picks up the first one.
*
* @default document.body
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-panelcontainer
*/
panelContainer?: string | HTMLElement;
/**
* The Media Query to turn Autocomplete into a detached experience.
*
* @default "(max-width: 680px)"
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-detachedmediaquery
* @link https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
*/
detachedMediaQuery?: string;
getSources?: GetSources<TItem>;
/**
* The panel's horizontal position.
*
* @default "input-wrapper-width"
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-panelplacement
*/
panelPlacement?: 'start' | 'end' | 'full-width' | 'input-wrapper-width';
/**
* Class names to inject for each created DOM element.
*
* This is useful to style your autocomplete with external CSS frameworks.
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-classnames
*/
classNames?: Partial<AutocompleteClassNames>;
/**
* The function that renders the autocomplete panel.
*
* This is useful to customize the rendering, for example, using multi-row or multi-column layouts.
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-render
*/
render?: AutocompleteRender<TItem>;
/**
* The function that renders a no results section when there are no hits.
*
* This is useful to let the user know that the query returned no results.
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-rendernoresults
*/
renderNoResults?: AutocompleteRender<TItem>;
initialState?: Partial<AutocompleteState<TItem>>;
onStateChange?(props: OnStateChangeProps<TItem>): void;
/**
* The virtual DOM implementation to plug to Autocomplete. It defaults to Preact.
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-renderer
*/
renderer?: AutocompleteRenderer;
plugins?: Array<AutocompletePlugin<any, any>>;
/**
* Components to register in the Autocomplete rendering lifecycles.
*
* Registered components become available in [`templates`](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/templates/), [`render`](https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-render), and in [`renderNoResults`](https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-rendernoresults).
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-components
*/
components?: PublicAutocompleteComponents;
/**
* A mapping of translation strings.
*
* Defaults to English values.
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-translations
*/
translations?: Partial<AutocompleteTranslations>;
}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,13 @@
import { BaseItem } from '../core';
import { AutocompletePlugin as AutocompleteCorePlugin } from '../core/AutocompletePlugin';
import { AutocompleteOptions } from './AutocompleteOptions';
export declare type AutocompletePlugin<TItem extends BaseItem, TData> = Omit<AutocompleteCorePlugin<TItem, TData>, 'getSources'> & {
/**
* The [sources](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/) to get the suggestions from.
*
* When defined, theyre merged with the sources of your Autocomplete instance.
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/plugins/#param-getsources
*/
getSources?: AutocompleteOptions<TItem>['getSources'];
};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,33 @@
import { BaseItem, AutocompleteApi as AutocompleteCoreApi, AutocompleteScopeApi } from '../core';
import { AutocompleteState } from './AutocompleteState';
declare type PropsGetterParams<TItem extends BaseItem, TParam> = TParam & {
state: AutocompleteState<TItem>;
} & AutocompleteScopeApi<TItem>;
export declare type AutocompletePropGetters<TItem extends BaseItem> = {
getEnvironmentProps(params: PropsGetterParams<TItem, {
props: ReturnType<AutocompleteCoreApi<TItem>['getEnvironmentProps']>;
}>): ReturnType<AutocompleteCoreApi<TItem>['getEnvironmentProps']>;
getFormProps(params: PropsGetterParams<TItem, {
props: ReturnType<AutocompleteCoreApi<TItem>['getFormProps']>;
}>): ReturnType<AutocompleteCoreApi<TItem>['getFormProps']>;
getInputProps(params: PropsGetterParams<TItem, {
props: ReturnType<AutocompleteCoreApi<TItem>['getInputProps']>;
inputElement: HTMLInputElement;
}>): ReturnType<AutocompleteCoreApi<TItem>['getInputProps']>;
getItemProps(params: PropsGetterParams<TItem, {
props: ReturnType<AutocompleteCoreApi<TItem>['getItemProps']>;
}>): ReturnType<AutocompleteCoreApi<TItem>['getItemProps']>;
getLabelProps(params: PropsGetterParams<TItem, {
props: ReturnType<AutocompleteCoreApi<TItem>['getLabelProps']>;
}>): ReturnType<AutocompleteCoreApi<TItem>['getLabelProps']>;
getListProps(params: PropsGetterParams<TItem, {
props: ReturnType<AutocompleteCoreApi<TItem>['getListProps']>;
}>): ReturnType<AutocompleteCoreApi<TItem>['getListProps']>;
getPanelProps(params: PropsGetterParams<TItem, {
props: ReturnType<AutocompleteCoreApi<TItem>['getPanelProps']>;
}>): ReturnType<AutocompleteCoreApi<TItem>['getPanelProps']>;
getRootProps(params: PropsGetterParams<TItem, {
props: ReturnType<AutocompleteCoreApi<TItem>['getRootProps']>;
}>): ReturnType<AutocompleteCoreApi<TItem>['getRootProps']>;
};
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,15 @@
import { AutocompleteScopeApi, BaseItem } from '../core';
import { AutocompleteComponents } from './AutocompleteComponents';
import { HTMLTemplate, Pragma, PragmaFrag, Render, VNode } from './AutocompleteRenderer';
import { AutocompleteState } from './AutocompleteState';
export declare type AutocompleteRender<TItem extends BaseItem> = (params: AutocompleteScopeApi<TItem> & {
children: VNode;
state: AutocompleteState<TItem>;
sections: VNode[];
elements: Record<string, VNode>;
components: AutocompleteComponents;
createElement: Pragma;
Fragment: PragmaFrag;
html: HTMLTemplate;
render: Render;
}, root: HTMLElement) => void;

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,33 @@
/// <reference types="react" />
export declare type Pragma = (type: any, props: Record<string, any> | null, ...children: ComponentChildren[]) => JSX.Element;
export declare type PragmaFrag = any;
declare type ComponentChild = VNode<any> | string | number | boolean | null | undefined;
declare type ComponentChildren = ComponentChild[] | ComponentChild;
export declare type VNode<TProps = {}> = {
type: any;
key: string | number | any;
props: TProps & {
children: ComponentChildren;
};
};
export declare type Render = (vnode: ComponentChild, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text | undefined) => void;
export declare type AutocompleteRenderer = {
/**
* The function to create virtual nodes.
*
* @default preact.createElement
*/
createElement: Pragma;
/**
* The component to use to create fragments.
*
* @default preact.Fragment
*/
Fragment: PragmaFrag;
/**
* The function to render children to an element.
*/
render?: Render;
};
export declare type HTMLTemplate = (strings: TemplateStringsArray, ...values: any[]) => VNode | VNode[];
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,74 @@
import { AutocompleteSource as AutocompleteCoreSource, InternalAutocompleteSource as InternalAutocompleteCoreSource, BaseItem } from '../core';
import { AutocompleteComponents } from './AutocompleteComponents';
import { AutocompleteRenderer, HTMLTemplate, VNode } from './AutocompleteRenderer';
import { AutocompleteState } from './AutocompleteState';
declare type Template<TParams> = (params: TParams & AutocompleteRenderer & {
components: AutocompleteComponents;
html: HTMLTemplate;
}) => VNode | VNode[] | string;
/**
* Templates to display in the autocomplete panel.
*
* A template can either return a string, or perform DOM mutations (manipulating DOM elements with JavaScript and attaching events) without returning a string.
*/
export declare type SourceTemplates<TItem extends BaseItem> = {
/**
* A function that returns the template for each item of the source.
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/templates/#param-item
*/
item: Template<{
item: TItem;
state: AutocompleteState<TItem>;
}>;
/**
* A function that returns the template for the header (before the list of items).
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/templates/#param-header
*/
header?: Template<{
state: AutocompleteState<TItem>;
source: AutocompleteSource<TItem>;
items: TItem[];
}>;
/**
* A function that returns the template for the footer (after the list of items).
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/templates/#param-footer
*/
footer?: Template<{
state: AutocompleteState<TItem>;
source: AutocompleteSource<TItem>;
items: TItem[];
}>;
/**
* A function that returns the template for when there are no items.
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/templates/#param-noresults
*/
noResults?: Template<{
state: AutocompleteState<TItem>;
source: AutocompleteSource<TItem>;
}>;
};
declare type WithTemplates<TType, TItem extends BaseItem> = TType & {
/**
* A set of templates to customize how sections and their items are displayed.
*
* See [**Displaying items with Templates**](templates) for more information.
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/#param-templates
*/
templates: SourceTemplates<TItem>;
};
export interface AutocompleteCoreSourceWithDocs<TItem extends BaseItem> extends AutocompleteCoreSource<TItem> {
/**
* Unique identifier for the source.
*
* It is used as value for the `data-autocomplete-source-id` attribute of the source `section` container.
*/
sourceId: string;
}
export declare type AutocompleteSource<TItem extends BaseItem> = WithTemplates<AutocompleteCoreSourceWithDocs<TItem>, TItem>;
export declare type InternalAutocompleteSource<TItem extends BaseItem> = WithTemplates<InternalAutocompleteCoreSource<TItem>, TItem>;
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,10 @@
import { AutocompleteState as AutocompleteCoreState, BaseItem } from '../core';
import { AutocompleteCollection } from './AutocompleteCollection';
export declare type AutocompleteState<TItem extends BaseItem> = Omit<AutocompleteCoreState<TItem>, 'collections'> & {
/**
* The collections of items.
*
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/state/#param-collections
*/
collections: Array<AutocompleteCollection<TItem>>;
};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,5 @@
export declare type AutocompleteTranslations = {
detachedCancelButtonText: string;
clearButtonTitle: string;
submitButtonTitle: string;
};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,18 @@
export declare type HighlightHitParams<THit> = {
/**
* The Algolia hit whose attribute to retrieve the highlighted parts from.
*/
hit: THit;
/**
* The attribute to retrieve the highlighted parts from.
*
* You can use the array syntax to reference nested attributes.
*/
attribute: keyof THit | string[];
/**
* The tag name to use for highlighted parts.
*
* @default "mark"
*/
tagName?: string;
};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,12 @@
export * from './AutocompleteClassNames';
export * from './AutocompleteCollection';
export * from './AutocompleteComponents';
export * from './AutocompleteOptions';
export * from './AutocompletePlugin';
export * from './AutocompletePropGetters';
export * from './AutocompleteRender';
export * from './AutocompleteRenderer';
export * from './AutocompleteSource';
export * from './AutocompleteState';
export * from './AutocompleteTranslations';
export * from './HighlightHitParams';

View File

@@ -0,0 +1,12 @@
export * from './AutocompleteClassNames';
export * from './AutocompleteCollection';
export * from './AutocompleteComponents';
export * from './AutocompleteOptions';
export * from './AutocompletePlugin';
export * from './AutocompletePropGetters';
export * from './AutocompleteRender';
export * from './AutocompleteRenderer';
export * from './AutocompleteSource';
export * from './AutocompleteState';
export * from './AutocompleteTranslations';
export * from './HighlightHitParams';