sync working code, and import type-doc

This commit is contained in:
2023-07-17 17:24:49 +08:00
parent 7ab7a7094a
commit 3e9ee59178
43 changed files with 1024 additions and 1553 deletions

87
lib/ui/grid/grid.d.ts vendored
View File

@ -1,64 +1,15 @@
import { DropdownOptions } from "../dropdown";
import { GridColumnDefinition } from "./column"
interface GridItem {
export interface GridItem {
value: any;
displayValue: string;
}
interface GridSourceItem {
export interface GridSourceItem {
value: string;
text: string;
}
declare var GridColumn: {
create(): HTMLElement;
createEdit(trigger: (e: any) => void, col: GridColumnDefinition, body: HTMLElement): HTMLElement;
setValue(element: HTMLElement, val: any, item: GridItem | any, col: GridColumnDefinition): void;
getValue(e: any): any;
setStyle(element: HTMLElement, style: { [key: string]: string }): void;
setEnabled(element: HTMLElement, enabled?: boolean): void;
}
interface GridColumnType {
0: "Common";
1: "Input";
2: "Dropdown";
3: "Checkbox";
4: "Icon";
5: "Text";
}
interface GridColumnDefinition {
key?: string;
type?: keyof GridColumnType | typeof GridColumn;
caption?: string;
width?: Number;
align?: "left" | "center" | "right";
enabled?: boolean | string | ((item: GridItem | any) => boolean);
css?: { [key: string]: string };
styleFilter?: (item: GridItem | any) => { [key: string]: string };
textStyle?: { [key: string]: string };
visible?: boolean;
resizable?: boolean;
sortable?: boolean;
orderable?: boolean;
allcheck?: boolean;
events?: { [event: string]: any };
attrs?: { [key: string]: string } | ((item: GridItem | any) => { [key: string]: string });
allowFilter?: boolean;
filter?: (item: GridItem | any) => any;
sortFilter?: (a: GridItem | any, b: GridItem | any) => -1 | 0 | 1;
bgFilter?: (item: GridItem | any) => string;
dropOptions?: DropdownOptions;
source?: Array<any> | ((item: GridItem | any) => Array<any> | Promise<Array<GridSourceItem>>);
iconType?: string;
className?: string | ((item: GridItem | any) => string);
text?: string;
tooltip?: string;
onallchecked?: (this: Grid, col: GridColumnDefinition, flag: boolean) => void;
onchanged?: (this: Grid, item: GridItem | any, value: boolean | any) => void;
}
interface GridColumnDirection {
[-1]: Number,
1: Number
@ -70,7 +21,17 @@ interface GridColumnColumnEventMap {
"sort": string
}
interface Grid {
export class Grid {
static ColumnTypes: {
Common: 0,
Input: 1,
Dropdown: 2,
Checkbox: 3,
Icon: 4,
Text: 5,
isCheckbox(type: Number): boolean;
};
columns: Array<GridColumnDefinition>;
langs?: { all: string, ok: string, reset: string };
virtualCount?: Number;
@ -88,6 +49,8 @@ interface Grid {
sortIndex?: Number;
sortDirection?: keyof GridColumnDirection;
constructor(container: HTMLElement);
willSelect?: (index: Number, colIndex: Number) => boolean;
selectedRowChanged?: (index?: Number) => void;
cellDblClicked?: (index: Number, colIndex: Number) => void;
@ -115,20 +78,4 @@ interface Grid {
refresh(): void;
resetChange(): void;
sortColumn(reload?: boolean): void;
}
declare var Grid: {
ColumnTypes: {
Common: 0,
Input: 1,
Dropdown: 2,
Checkbox: 3,
Icon: 4,
Text: 5,
isCheckbox(type: Number): boolean;
};
GridColumn: typeof GridColumn;
new(container: HTMLElement): Grid;
}
export default Grid;
}