117 lines
3.1 KiB
TypeScript
117 lines
3.1 KiB
TypeScript
import * as vue from 'vue';
|
||
import { PropType, MaybeRefOrGetter } from 'vue';
|
||
import { DocSearchProps } from '@docsearch/react';
|
||
import { LocaleConfig } from 'vuepress/shared';
|
||
import { DeepRequired } from '@vuepress/helper/shared';
|
||
|
||
type DocSearchLocaleData = DeepRequired<Pick<DocSearchProps, 'placeholder' | 'translations'>>;
|
||
|
||
/**
|
||
* DocSearch locale options
|
||
*
|
||
* DocSearch 多语言选项
|
||
*/
|
||
type DocSearchLocaleOptions = Partial<Pick<DocSearchProps, 'apiKey' | 'appId' | 'disableUserPersonalization' | 'indexName' | 'initialQuery' | 'maxResultsPerGroup' | 'placeholder' | 'searchParameters' | 'translations'>>;
|
||
/**
|
||
* DocSearch options
|
||
*
|
||
* DocSearch 选项
|
||
*/
|
||
interface DocSearchOptions extends DocSearchLocaleOptions {
|
||
/**
|
||
* Locale options
|
||
*
|
||
* 多语言选项
|
||
*/
|
||
locales?: LocaleConfig<DocSearchLocaleOptions>;
|
||
}
|
||
|
||
declare const DocSearch: vue.DefineComponent<vue.ExtractPropTypes<{
|
||
containerId: {
|
||
type: StringConstructor;
|
||
default: string;
|
||
};
|
||
options: {
|
||
type: PropType<DocSearchOptions>;
|
||
default: () => {};
|
||
};
|
||
}>, () => (vue.VNode<vue.RendererNode, vue.RendererElement, {
|
||
[key: string]: any;
|
||
}> | null)[], {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
||
containerId: {
|
||
type: StringConstructor;
|
||
default: string;
|
||
};
|
||
options: {
|
||
type: PropType<DocSearchOptions>;
|
||
default: () => {};
|
||
};
|
||
}>> & Readonly<{}>, {
|
||
containerId: string;
|
||
options: DocSearchOptions;
|
||
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
||
|
||
/**
|
||
* DocSearch client locale options
|
||
*
|
||
* DocSearch 客户端多语言选项
|
||
*/
|
||
type DocSearchClientLocaleOptions = Partial<DocSearchProps>;
|
||
/**
|
||
* DocSearch client options
|
||
*
|
||
* DocSearch 客户端选项
|
||
*/
|
||
interface DocSearchClientOptions extends DocSearchClientLocaleOptions {
|
||
/**
|
||
* Locale options
|
||
*
|
||
* 多语言选项
|
||
*/
|
||
locales?: Record<string, DocSearchClientLocaleOptions>;
|
||
}
|
||
/**
|
||
* Customize DocSearch options
|
||
*
|
||
* 自定义 DocSearch 选项
|
||
*
|
||
* @param options - DocSearch options, support plain object, ref or getter / DocSearch 选项,支持普通对象,Ref 或 Getter
|
||
*
|
||
* @example
|
||
* ```ts
|
||
* import { defineDocSearchConfig } from '@vuepress/plugin-docsearch/client'
|
||
*
|
||
* // Use plain object
|
||
* defineDocSearchConfig({
|
||
* translations: {
|
||
* button: {
|
||
* buttonText: 'Search',
|
||
* },
|
||
* },
|
||
* })
|
||
*
|
||
* // Use ref
|
||
* const options = ref({
|
||
* translations: {
|
||
* button: {
|
||
* buttonText: 'Search',
|
||
* },
|
||
* },
|
||
* })
|
||
* defineDocSearchConfig(options)
|
||
*
|
||
* // Use getter
|
||
* defineDocSearchConfig(() => ({
|
||
* translations: {
|
||
* button: {
|
||
* buttonText: isDarkMode.value ? 'Search in dark' : 'Search in light',
|
||
* },
|
||
* },
|
||
* }))
|
||
* ```
|
||
*/
|
||
declare const defineDocSearchConfig: (options: MaybeRefOrGetter<DocSearchClientOptions>) => void;
|
||
|
||
export { DocSearch, defineDocSearchConfig };
|
||
export type { DocSearchClientLocaleOptions, DocSearchClientOptions, DocSearchLocaleData, DocSearchLocaleOptions, DocSearchOptions };
|