This repository has been archived by the owner on Oct 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.d.ts
166 lines (160 loc) · 5.11 KB
/
lib.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import preact from 'preact';
import 'cpanel-commons.d.ts';
declare module "@rad-commons" {
namespace radCommons {
export const config: {
userPermissions: {
canCreateContent: boolean;
canConfigureContent: boolean;
canDeleteContent: boolean;
canManageFieldsOfMultiFieldContent: boolean;
};
user: {
role: number;
};
}
export const http: {
get(url: string): Promise<Object>;
post(url: string, data: Object|string, method: string = 'POST'): Promise<Object>;
put(url: string, data: Object|string): Promise<Object>;
delete(url: string): Promise<Object>;
}
export function myFetch(url: string, settings?: Object): Promise<XMLHttpRequest>;
export const toasters: {
[key: string]: (message: string|function, level: keyof {info: 1; error: 1; message: 1;}) => any;
};
export const env: {
sessionStorage: WindowSessionStorage;
console: WindowConsole;
};
////////////////////////////////////////////////////////////////////////
export function hookForm(vm: preact.Component,
values?: {[key: string]: any},
inputs?: {[key: string]: {
value: any;
validations: Array<[string, ...any]|[[function, string], ...any]>;
label?: string;
}}): {
values: Object;
errors: Object;
classes: Object;
}
export class InputGroup extends preact.Component<
{
classes?: {invalid: boolean; focused: boolean; blurredAtLeastOnce: boolean;};
className?: string;
},
{}>
{
}
export interface InputProps {
vm: preact.Component;
myOnChange?: (state: Object) => Object;
validations?: Array<[string, ...any]>;
errorLabel?: string;
[key: string]: any;
}
export class Input extends preact.Component<
InputProps,
{}>
{
}
export class Textarea extends preact.Component<
InputProps,
{}>
{
}
export class Select extends preact.Component<
InputProps,
{}>
{
}
export class InputError extends preact.Component<
{error?: string;},
{}>
{
}
export class FormButtons extends preact.Component<
{
buttons?: Array<'submit'|'submitWithAlt'|'cancel'|preact.VNode>;
submitButtonText?: string;
altSubmitButtonText?: string;
cancelButtonText?: string;
returnTo?: string;
className?: string;
},
{}>
{
}
export class Toaster extends preact.Component<
{id?: string; autoCloseTimeoutMillis?: number;},
{}>
{
}
export class View extends preact.Component<
{},
{}>
{
}
export class Confirmation extends preact.Component<
{
onConfirm: () => any;
onCancel: () => any;
confirmButtonText?: string;
cancelButtonText?: string;
},
{}>
{
}
export class FormConfirmation extends preact.Component<
{
onConfirm: (e: UIEvent) => any;
onCancel: () => any;
confirmButtonText?: string;
cancelButtonText?: string;
},
{}>
{
}
export class FeatherSvg extends preact.Component<
{iconId: string; className?: string;},
{}>
{
}
export const dateUtils: {
getLocaleDateString(date: Date, includeTime: boolean = false): string;
getLocaleTimeString(date: Date): string;
};
export const urlUtils: {
baseUrl: string;
assetBaseUrl: string;
currentPagePath: string;
redirect(to: string, full?: boolean);
reload();
makeUrl(url: string): string;
makeAssetUrl(url: string): string;
normalizeUrl(url: string): string;
}
export class Sortable {
register(el: HTMLElement, options: Object): void;
getImpl(): Object;
}
}
export = radCommons;
}
interface SiteInfo {
baseUrl: string; // /foo/, tai /foo/index.php?q=/
assetBaseUrl: string; // /foo/
currentPagePath: string; // /
}
interface ControlPanelLoadArgs {
adminPanels: Array<FrontendPanelConfig>;
baseUrl: string;
assetBaseUrl: string;
user: Object;
userPermissions: Object;
}
interface PageLoadArgs {
contentPanels: Array<FrontendPanelConfig>;
currentPagePath: string;
}