UNPKG

2.83 kBTypeScriptView Raw
1import { CSSDeclaration, OneDArray, ProtoExtends, TColumn, TData } from './types';
2import Storage from './storage/storage';
3import Pipeline from './pipeline/pipeline';
4import Tabular from './tabular';
5import { SearchConfig } from './view/plugin/search/search';
6import { PaginationConfig } from './view/plugin/pagination';
7import Header from './header';
8import { ServerStorageOptions } from './storage/server';
9import Dispatcher from './util/dispatcher';
10import { GenericSortConfig } from './view/plugin/sort/sort';
11import { Language, Translator } from './i18n/language';
12import { ComponentChild, RefObject } from 'preact';
13import { EventEmitter } from './util/eventEmitter';
14import { GridEvents } from './events';
15export interface Config {
16 eventEmitter: EventEmitter<GridEvents>;
17 dispatcher: Dispatcher<any>;
18 /** container element that is used to mount the Grid.js to */
19 container?: Element;
20 /** gridjs-temp div which is used internally */
21 tempRef?: RefObject<HTMLDivElement>;
22 data?: TData | (() => TData) | (() => Promise<TData>);
23 server?: ServerStorageOptions;
24 header?: Header;
25 /** to parse a HTML table and load the data */
26 from: HTMLElement;
27 storage: Storage<any>;
28 pipeline: Pipeline<Tabular>;
29 /** to automatically calculate the columns width */
30 autoWidth: boolean;
31 /** sets the width of the container and table */
32 width: string;
33 search: SearchConfig;
34 pagination: PaginationConfig;
35 sort: GenericSortConfig;
36 translator: Translator;
37 style?: Partial<{
38 table: CSSDeclaration;
39 td: CSSDeclaration;
40 th: CSSDeclaration;
41 container: CSSDeclaration;
42 header: CSSDeclaration;
43 footer: CSSDeclaration;
44 }>;
45 className?: Partial<{
46 table: string;
47 th: string;
48 td: string;
49 container: string;
50 footer: string;
51 header: string;
52 }>;
53}
54interface UserConfigExtend {
55 columns?: OneDArray<TColumn | string | ComponentChild>;
56 search: SearchConfig | boolean;
57 pagination: PaginationConfig | boolean;
58 sort: GenericSortConfig | boolean;
59 language: Language;
60}
61export declare type UserConfig = ProtoExtends<Partial<Config>, Partial<UserConfigExtend>>;
62export declare class Config {
63 private _userConfig;
64 constructor(config?: Partial<Config>);
65 /**
66 * Assigns `updatedConfig` keys to the current config file
67 *
68 * @param updatedConfig
69 */
70 assign(updatedConfig: Partial<Config>): Config;
71 /**
72 * Updates the config from a UserConfig
73 *
74 * @param userConfig
75 */
76 update(userConfig: Partial<UserConfig>): Config;
77 static defaultConfig(): Config;
78 static fromUserConfig(userConfig: UserConfig): Config;
79}
80export {};
81
\No newline at end of file