cradova 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +651 -59
- package/dist/index.js +1576 -377
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,59 +1,651 @@
|
|
|
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
|
-
|
|
1
|
+
declare module "cradova" {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Cradova Ajax
|
|
5
|
+
* ------------------
|
|
6
|
+
* your new axios alternative
|
|
7
|
+
* supports files upload
|
|
8
|
+
* @param url string
|
|
9
|
+
* @param {{method: string;data;header;callbacks;}} opts
|
|
10
|
+
* @returns any
|
|
11
|
+
*/
|
|
12
|
+
export function Ajax(
|
|
13
|
+
url: string | URL,
|
|
14
|
+
opts?:
|
|
15
|
+
| {
|
|
16
|
+
method?: "GET" | "POST";
|
|
17
|
+
data?: Record<string, any>;
|
|
18
|
+
header?: {
|
|
19
|
+
"content-type": string;
|
|
20
|
+
} & Record<string, any>;
|
|
21
|
+
callbacks?: Record<string, (arg: any) => void>;
|
|
22
|
+
}
|
|
23
|
+
| any
|
|
24
|
+
): Promise<unknown>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Cradova Signal
|
|
28
|
+
* ----
|
|
29
|
+
* create stateful data store.
|
|
30
|
+
* ability to:
|
|
31
|
+
* - create a store
|
|
32
|
+
* - create actions and fire them
|
|
33
|
+
* - bind a Ref or RefList
|
|
34
|
+
* - listen to changes
|
|
35
|
+
* - persist changes to localStorage
|
|
36
|
+
* - set keys instead of all values
|
|
37
|
+
* - update a cradova Ref/RefList automatically
|
|
38
|
+
* @constructor initial: any, props: {useHistory, persist}
|
|
39
|
+
*/
|
|
40
|
+
export class createSignal<Type> {
|
|
41
|
+
private callback;
|
|
42
|
+
private persistName;
|
|
43
|
+
private actions;
|
|
44
|
+
private ref;
|
|
45
|
+
private path;
|
|
46
|
+
value: Type;
|
|
47
|
+
constructor(
|
|
48
|
+
initial: Type,
|
|
49
|
+
props?: {
|
|
50
|
+
persistName?: string | undefined;
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
/**
|
|
54
|
+
* Cradova Signal
|
|
55
|
+
* ----
|
|
56
|
+
* set signal value
|
|
57
|
+
* @param value - signal value
|
|
58
|
+
* @returns void
|
|
59
|
+
*/
|
|
60
|
+
set(value: Type | ((value: Type) => Type), shouldRefRender?: boolean): void;
|
|
61
|
+
/**
|
|
62
|
+
* Cradova Signal
|
|
63
|
+
* ----
|
|
64
|
+
* set a key value if it's an object
|
|
65
|
+
* @param key - key of the key
|
|
66
|
+
* @param value - value of the key
|
|
67
|
+
* @returns void
|
|
68
|
+
*/
|
|
69
|
+
setKey<k extends keyof Type>(
|
|
70
|
+
key: k,
|
|
71
|
+
value: any,
|
|
72
|
+
shouldRefRender?: boolean
|
|
73
|
+
): void;
|
|
74
|
+
/**
|
|
75
|
+
* Cradova Signal
|
|
76
|
+
* ----
|
|
77
|
+
* set a key to signal an action
|
|
78
|
+
* @param key - key of the action
|
|
79
|
+
* @param action function to execute
|
|
80
|
+
*/
|
|
81
|
+
createAction(
|
|
82
|
+
key: string | Record<string, (data?: Type) => void>,
|
|
83
|
+
action?: (data?: Type) => void
|
|
84
|
+
): void;
|
|
85
|
+
/**
|
|
86
|
+
* Cradova Signal
|
|
87
|
+
* ----
|
|
88
|
+
* fires an action if available
|
|
89
|
+
* @param key - string key of the action
|
|
90
|
+
* @param data - data for the action
|
|
91
|
+
*/
|
|
92
|
+
fireAction(key: string, data?: Type): void;
|
|
93
|
+
/**
|
|
94
|
+
* Cradova Signal
|
|
95
|
+
* ----
|
|
96
|
+
* set a auto - rendering component for this store
|
|
97
|
+
*
|
|
98
|
+
* @param Ref component to bind to.
|
|
99
|
+
* @param path a property in the object to send to attached ref
|
|
100
|
+
*/
|
|
101
|
+
bindRef(Ref: any, path?: string): void;
|
|
102
|
+
/**
|
|
103
|
+
* Cradova Signal
|
|
104
|
+
* ----
|
|
105
|
+
* set a update listener on value changes
|
|
106
|
+
* @param callback
|
|
107
|
+
*/
|
|
108
|
+
listen(callback: (a: any) => void): void;
|
|
109
|
+
/**
|
|
110
|
+
* Cradova Signal
|
|
111
|
+
* ----
|
|
112
|
+
* clear the history on local storage
|
|
113
|
+
*
|
|
114
|
+
*
|
|
115
|
+
* .
|
|
116
|
+
*/
|
|
117
|
+
clearPersist(): void;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
type stateType =
|
|
121
|
+
| Partial<HTMLElement>
|
|
122
|
+
| {
|
|
123
|
+
class?: string;
|
|
124
|
+
text?: string;
|
|
125
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
126
|
+
tree?: Function | HTMLElement;
|
|
127
|
+
remove?: boolean;
|
|
128
|
+
};
|
|
129
|
+
type stateID = string;
|
|
130
|
+
/**
|
|
131
|
+
* Send a new state to specified element with stateID
|
|
132
|
+
*
|
|
133
|
+
* @param stateID
|
|
134
|
+
* @param state
|
|
135
|
+
* @returns element(s)
|
|
136
|
+
*/
|
|
137
|
+
export function dispatch(
|
|
138
|
+
stateID: stateID | Record<stateID, stateType>,
|
|
139
|
+
state?: stateType
|
|
140
|
+
): any;
|
|
141
|
+
|
|
142
|
+
type ElementType<T> = (
|
|
143
|
+
...VJS: (
|
|
144
|
+
| string
|
|
145
|
+
| undefined
|
|
146
|
+
| Partial<T>
|
|
147
|
+
| HTMLElement
|
|
148
|
+
| (() => HTMLElement)
|
|
149
|
+
| {
|
|
150
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
151
|
+
beforeMount?: () => void;
|
|
152
|
+
afterMount?: () => void;
|
|
153
|
+
text?: string;
|
|
154
|
+
stateID?: string;
|
|
155
|
+
shouldUpdate?: boolean;
|
|
156
|
+
assert?: any;
|
|
157
|
+
}
|
|
158
|
+
)[]
|
|
159
|
+
) => T;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Cradova Router
|
|
163
|
+
* ---
|
|
164
|
+
* Facilitates navigation within the application and initializes
|
|
165
|
+
* page views based on the matched routes.
|
|
166
|
+
*/
|
|
167
|
+
type RouterType = {
|
|
168
|
+
/**
|
|
169
|
+
* Registers a route.
|
|
170
|
+
*
|
|
171
|
+
* @param {string} path Route path.
|
|
172
|
+
* @param {any} screen the cradova document tree for the route.
|
|
173
|
+
*/
|
|
174
|
+
route: (path: string, screen: Screen) => void;
|
|
175
|
+
/**
|
|
176
|
+
* get a screen ready before time.
|
|
177
|
+
*
|
|
178
|
+
* @param {string} path Route path.
|
|
179
|
+
* @param {any} data data for the screen.
|
|
180
|
+
*/
|
|
181
|
+
packageScreen: (path: string, data?: any) => Promise<void>;
|
|
182
|
+
onPageShow: (callback: () => void) => void;
|
|
183
|
+
onPageHide: (callback: () => void) => void;
|
|
184
|
+
/**
|
|
185
|
+
* Cradova Router
|
|
186
|
+
* ------
|
|
187
|
+
*
|
|
188
|
+
* return last set router params
|
|
189
|
+
*
|
|
190
|
+
* .
|
|
191
|
+
*/
|
|
192
|
+
getParams: <D>() => { data: D | unknown; params: any };
|
|
193
|
+
/**
|
|
194
|
+
* Cradova Router
|
|
195
|
+
* ------
|
|
196
|
+
*
|
|
197
|
+
* Navigates to a designated screen in your app
|
|
198
|
+
*/
|
|
199
|
+
navigate: (
|
|
200
|
+
href: string,
|
|
201
|
+
data?: Record<string, any> | null,
|
|
202
|
+
force?: boolean
|
|
203
|
+
) => void;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Cradova
|
|
207
|
+
* ---
|
|
208
|
+
* Error Handler for your app
|
|
209
|
+
*
|
|
210
|
+
* @param callback
|
|
211
|
+
* @param path? page path
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
addErrorHandler: (callback: (error: string) => void, path?: string) => void;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Cradova Router
|
|
219
|
+
* ---
|
|
220
|
+
* Facilitates navigation within the application and initializes
|
|
221
|
+
* page views based on the matched routes.
|
|
222
|
+
*/
|
|
223
|
+
export const Router: RouterType;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
*
|
|
227
|
+
*/
|
|
228
|
+
type CradovaScreenType = {
|
|
229
|
+
/**
|
|
230
|
+
* Cradova screen
|
|
231
|
+
* ---
|
|
232
|
+
* title of the page
|
|
233
|
+
* @param data
|
|
234
|
+
* @returns void
|
|
235
|
+
*
|
|
236
|
+
*
|
|
237
|
+
* .
|
|
238
|
+
*/
|
|
239
|
+
name: string;
|
|
240
|
+
/**
|
|
241
|
+
* Cradova screen
|
|
242
|
+
* ---
|
|
243
|
+
* The component for the screen
|
|
244
|
+
* @param data
|
|
245
|
+
* @returns void
|
|
246
|
+
*
|
|
247
|
+
*
|
|
248
|
+
* .
|
|
249
|
+
*/
|
|
250
|
+
template: Function | HTMLElement;
|
|
251
|
+
/**
|
|
252
|
+
* Cradova screen
|
|
253
|
+
* ---
|
|
254
|
+
* Screen transition from the screen class
|
|
255
|
+
* @param data
|
|
256
|
+
* @returns void
|
|
257
|
+
*
|
|
258
|
+
*
|
|
259
|
+
* .
|
|
260
|
+
*/
|
|
261
|
+
transition?: string;
|
|
262
|
+
/**
|
|
263
|
+
* Cradova screen
|
|
264
|
+
* ---
|
|
265
|
+
* gets called when the the screen is displayed
|
|
266
|
+
* @param data
|
|
267
|
+
* @returns void
|
|
268
|
+
*
|
|
269
|
+
*
|
|
270
|
+
* .
|
|
271
|
+
*/
|
|
272
|
+
/**
|
|
273
|
+
* Cradova screen
|
|
274
|
+
* ---
|
|
275
|
+
* Should this screen be cached after first render?
|
|
276
|
+
* @param data
|
|
277
|
+
* @returns void
|
|
278
|
+
*
|
|
279
|
+
*
|
|
280
|
+
* .
|
|
281
|
+
*/
|
|
282
|
+
persist?: boolean;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Cradova Screen
|
|
287
|
+
* ---
|
|
288
|
+
* create instances of manageable pages and scaffolds
|
|
289
|
+
* @param name
|
|
290
|
+
* @param template
|
|
291
|
+
* @param transitions
|
|
292
|
+
*/
|
|
293
|
+
export class Screen {
|
|
294
|
+
/**
|
|
295
|
+
* this should be a cradova screen component
|
|
296
|
+
*/
|
|
297
|
+
private html;
|
|
298
|
+
/**
|
|
299
|
+
* this is the name of the screen that appears as the title
|
|
300
|
+
*/
|
|
301
|
+
private name;
|
|
302
|
+
private packed;
|
|
303
|
+
private secondaryChildren;
|
|
304
|
+
/**
|
|
305
|
+
* used internally
|
|
306
|
+
*/
|
|
307
|
+
private template;
|
|
308
|
+
private callBack;
|
|
309
|
+
private deCallBack;
|
|
310
|
+
errorHandler: (() => void) | null;
|
|
311
|
+
/**
|
|
312
|
+
* this tells cradova to persist state on the screen or not
|
|
313
|
+
* persisting is better
|
|
314
|
+
*/
|
|
315
|
+
private persist;
|
|
316
|
+
private data;
|
|
317
|
+
constructor(cradova_screen_initials: CradovaScreenType);
|
|
318
|
+
setErrorHandler(errorHandler: () => void): void;
|
|
319
|
+
package(): Promise<void>;
|
|
320
|
+
onActivate(cb: () => Promise<void> | void): void;
|
|
321
|
+
onDeactivate(cb: () => Promise<void> | void): void;
|
|
322
|
+
addChild(...addOns: any[]): void;
|
|
323
|
+
deActivate(): void;
|
|
324
|
+
Activate(force?: boolean): Promise<void>;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Cradova simpleStore
|
|
329
|
+
* ----
|
|
330
|
+
* create stateful data store.
|
|
331
|
+
* ability to:
|
|
332
|
+
* - create a store
|
|
333
|
+
* - set keys instead of all values
|
|
334
|
+
* - able to update state on any element as a property value
|
|
335
|
+
* @constructor initial: any, Ref/RefList/RefElement: any
|
|
336
|
+
*/
|
|
337
|
+
export class $<Type extends Record<string, unknown>> {
|
|
338
|
+
private ref;
|
|
339
|
+
value: Type;
|
|
340
|
+
constructor(initial: Type);
|
|
341
|
+
/**
|
|
342
|
+
* Cradova simpleStore
|
|
343
|
+
* ----
|
|
344
|
+
* set simpleStore value
|
|
345
|
+
* @param value - simpleStore value
|
|
346
|
+
* @returns void
|
|
347
|
+
*/
|
|
348
|
+
set(value: Type | ((value: Type) => Type), shouldRefRender?: boolean): void;
|
|
349
|
+
/**
|
|
350
|
+
* Cradova
|
|
351
|
+
* ---
|
|
352
|
+
* is used to bind store data to any element
|
|
353
|
+
*
|
|
354
|
+
* @param prop
|
|
355
|
+
* @returns something
|
|
356
|
+
*/
|
|
357
|
+
bind(prop: string): (string | this)[];
|
|
358
|
+
private updateState;
|
|
359
|
+
/**
|
|
360
|
+
* Cradova simpleStore
|
|
361
|
+
* ----
|
|
362
|
+
* set a key value if it's an object
|
|
363
|
+
* @param name - name of the key
|
|
364
|
+
* @param value - value of the key
|
|
365
|
+
* @returns void
|
|
366
|
+
*/
|
|
367
|
+
setKey<k extends keyof Type>(
|
|
368
|
+
name: k,
|
|
369
|
+
value: any,
|
|
370
|
+
shouldRefRender?: boolean
|
|
371
|
+
): void;
|
|
372
|
+
/**
|
|
373
|
+
* Cradova simpleStore
|
|
374
|
+
* ----
|
|
375
|
+
* set a auto - rendering component for this store
|
|
376
|
+
*
|
|
377
|
+
* @param Ref component to bind to.
|
|
378
|
+
* @param path a property in the object to send to attached ref
|
|
379
|
+
*/
|
|
380
|
+
bindRef(ref: any, key: string, prop: string): void;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export const a: ElementType<HTMLAnchorElement>;
|
|
384
|
+
export const abbr: ElementType<HTMLElement>;
|
|
385
|
+
export const address: ElementType<HTMLElement>;
|
|
386
|
+
export const area: ElementType<HTMLAreaElement>;
|
|
387
|
+
export const article: ElementType<HTMLElement>;
|
|
388
|
+
export const aside: ElementType<HTMLElement>;
|
|
389
|
+
export const audio: ElementType<HTMLAudioElement>;
|
|
390
|
+
export const b: ElementType<HTMLElement>;
|
|
391
|
+
export const base: ElementType<HTMLBaseElement>;
|
|
392
|
+
export const bdi: ElementType<HTMLElement>;
|
|
393
|
+
export const bdo: ElementType<HTMLElement>;
|
|
394
|
+
export const blockquote: ElementType<HTMLElement>;
|
|
395
|
+
export const body: ElementType<HTMLBodyElement>;
|
|
396
|
+
export const br: ElementType<HTMLBRElement>;
|
|
397
|
+
export const button: ElementType<HTMLButtonElement>;
|
|
398
|
+
export const canvas: ElementType<HTMLCanvasElement>;
|
|
399
|
+
export const caption: ElementType<HTMLTableCaptionElement>;
|
|
400
|
+
export const cite: ElementType<HTMLElement>;
|
|
401
|
+
export const code: ElementType<HTMLElement>;
|
|
402
|
+
export const col: ElementType<HTMLTableColElement>;
|
|
403
|
+
export const colgroup: ElementType<HTMLElement>;
|
|
404
|
+
export const data: ElementType<HTMLDataElement>;
|
|
405
|
+
export const datalist: ElementType<HTMLDataListElement>;
|
|
406
|
+
export const dd: ElementType<HTMLElement>;
|
|
407
|
+
export const del: ElementType<HTMLElement>;
|
|
408
|
+
export const details: ElementType<HTMLDetailsElement>;
|
|
409
|
+
export const dfn: ElementType<HTMLElement>;
|
|
410
|
+
export const dialog: ElementType<HTMLDialogElement>;
|
|
411
|
+
export const div: ElementType<HTMLDivElement>;
|
|
412
|
+
export const dl: ElementType<HTMLElement>;
|
|
413
|
+
export const dt: ElementType<HTMLElement>;
|
|
414
|
+
export const em: ElementType<HTMLElement>;
|
|
415
|
+
export const embed: ElementType<HTMLEmbedElement>;
|
|
416
|
+
export const fieldset: ElementType<HTMLFieldSetElement>;
|
|
417
|
+
export const figcaption: ElementType<HTMLElement>;
|
|
418
|
+
export const figure: ElementType<HTMLElement>;
|
|
419
|
+
export const footer: ElementType<HTMLElement>;
|
|
420
|
+
export const form: ElementType<HTMLFormElement>;
|
|
421
|
+
export const h1: ElementType<HTMLHeadingElement>;
|
|
422
|
+
export const h2: ElementType<HTMLHeadingElement>;
|
|
423
|
+
export const h3: ElementType<HTMLHeadingElement>;
|
|
424
|
+
export const h4: ElementType<HTMLHeadingElement>;
|
|
425
|
+
export const h5: ElementType<HTMLHeadingElement>;
|
|
426
|
+
export const h6: ElementType<HTMLHeadingElement>;
|
|
427
|
+
export const head: ElementType<HTMLHeadElement>;
|
|
428
|
+
export const header: ElementType<HTMLElement>;
|
|
429
|
+
export const hr: ElementType<HTMLHRElement>;
|
|
430
|
+
export const html: ElementType<HTMLHtmlElement>;
|
|
431
|
+
export const i: ElementType<HTMLElement>;
|
|
432
|
+
export const iframe: ElementType<HTMLIFrameElement>;
|
|
433
|
+
export const img: ElementType<HTMLImageElement>;
|
|
434
|
+
export const input: ElementType<HTMLInputElement>;
|
|
435
|
+
export const ins: ElementType<HTMLElement>;
|
|
436
|
+
export const kbd: ElementType<HTMLElement>;
|
|
437
|
+
export const label: ElementType<HTMLLabelElement>;
|
|
438
|
+
export const legend: ElementType<HTMLLegendElement>;
|
|
439
|
+
export const li: ElementType<HTMLLIElement>;
|
|
440
|
+
export const link: ElementType<HTMLLinkElement>;
|
|
441
|
+
export const main: ElementType<HTMLElement>;
|
|
442
|
+
export const map: ElementType<HTMLMapElement>;
|
|
443
|
+
export const mark: ElementType<HTMLElement>;
|
|
444
|
+
export const math: ElementType<HTMLElement>;
|
|
445
|
+
export const menu: ElementType<HTMLMenuElement>;
|
|
446
|
+
export const meta: ElementType<HTMLMetaElement>;
|
|
447
|
+
export const meter: ElementType<HTMLMeterElement>;
|
|
448
|
+
export const nav: ElementType<HTMLElement>;
|
|
449
|
+
export const noscript: ElementType<HTMLElement>;
|
|
450
|
+
export const object: ElementType<HTMLObjectElement>;
|
|
451
|
+
export const ol: ElementType<HTMLOListElement>;
|
|
452
|
+
export const optgroup: ElementType<HTMLOptGroupElement>;
|
|
453
|
+
export const option: ElementType<HTMLOptionElement>;
|
|
454
|
+
export const output: ElementType<HTMLOutputElement>;
|
|
455
|
+
export const p: ElementType<HTMLParagraphElement>;
|
|
456
|
+
export const picture: ElementType<HTMLPictureElement>;
|
|
457
|
+
export const portal: ElementType<HTMLElement>;
|
|
458
|
+
export const pre: ElementType<HTMLPreElement>;
|
|
459
|
+
export const progress: ElementType<HTMLProgressElement>;
|
|
460
|
+
export const q: ElementType<HTMLQuoteElement>;
|
|
461
|
+
export const rp: ElementType<HTMLElement>;
|
|
462
|
+
export const rt: ElementType<HTMLElement>;
|
|
463
|
+
export const ruby: ElementType<HTMLElement>;
|
|
464
|
+
export const s: ElementType<HTMLElement>;
|
|
465
|
+
export const samp: ElementType<HTMLElement>;
|
|
466
|
+
export const script: ElementType<HTMLScriptElement>;
|
|
467
|
+
export const section: ElementType<HTMLElement>;
|
|
468
|
+
export const select: ElementType<HTMLSelectElement>;
|
|
469
|
+
export const slot: ElementType<HTMLSlotElement>;
|
|
470
|
+
export const small: ElementType<HTMLElement>;
|
|
471
|
+
export const source: ElementType<HTMLSourceElement>;
|
|
472
|
+
export const span: ElementType<HTMLSpanElement>;
|
|
473
|
+
export const strong: ElementType<HTMLElement>;
|
|
474
|
+
export const style: ElementType<HTMLStyleElement>;
|
|
475
|
+
export const sub: ElementType<HTMLElement>;
|
|
476
|
+
export const summary: ElementType<HTMLElement>;
|
|
477
|
+
export const sup: ElementType<HTMLElement>;
|
|
478
|
+
export const table: ElementType<HTMLTableElement>;
|
|
479
|
+
export const tbody: ElementType<HTMLTableColElement>;
|
|
480
|
+
export const td: ElementType<HTMLTableCellElement>;
|
|
481
|
+
export const template: ElementType<HTMLTemplateElement>;
|
|
482
|
+
export const textarea: ElementType<HTMLTextAreaElement>;
|
|
483
|
+
export const tfoot: ElementType<HTMLElement>;
|
|
484
|
+
export const th: ElementType<HTMLTableSectionElement>;
|
|
485
|
+
export const thead: ElementType<HTMLTableSectionElement>;
|
|
486
|
+
export const time: ElementType<HTMLTimeElement>;
|
|
487
|
+
export const title: ElementType<HTMLTitleElement>;
|
|
488
|
+
export const tr: ElementType<HTMLTableRowElement>;
|
|
489
|
+
export const track: ElementType<HTMLTrackElement>;
|
|
490
|
+
export const u: ElementType<HTMLElement>;
|
|
491
|
+
export const ul: ElementType<HTMLUListElement>;
|
|
492
|
+
export const val: ElementType<HTMLElement>;
|
|
493
|
+
export const video: ElementType<HTMLVideoElement>;
|
|
494
|
+
export const wbr: ElementType<HTMLElement>;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Cradova afterMount event
|
|
498
|
+
*/
|
|
499
|
+
export let cradovaAftermountEvent: CustomEvent<unknown>;
|
|
500
|
+
/**
|
|
501
|
+
Write CSS styles in Javascript
|
|
502
|
+
@example
|
|
503
|
+
|
|
504
|
+
css("#container",
|
|
505
|
+
{
|
|
506
|
+
height: "100%",
|
|
507
|
+
height: "100%",
|
|
508
|
+
background-color: "#ff9800"
|
|
509
|
+
})
|
|
510
|
+
|
|
511
|
+
css(".btn:hover",
|
|
512
|
+
{
|
|
513
|
+
height: "100%",
|
|
514
|
+
height: "100%",
|
|
515
|
+
background-color: "#ff9800"
|
|
516
|
+
})
|
|
517
|
+
|
|
518
|
+
*/
|
|
519
|
+
export function css(
|
|
520
|
+
identifier: string,
|
|
521
|
+
properties?: Record<string, string>
|
|
522
|
+
): void;
|
|
523
|
+
/**
|
|
524
|
+
*
|
|
525
|
+
* @param {expression} condition
|
|
526
|
+
* @param {function} callback
|
|
527
|
+
*/
|
|
528
|
+
export function assert(
|
|
529
|
+
condition: any,
|
|
530
|
+
...callback: (() => any)[]
|
|
531
|
+
): "" | (() => any)[];
|
|
532
|
+
|
|
533
|
+
export function loop(
|
|
534
|
+
datalist: any[],
|
|
535
|
+
component: (value: any, index?: number, array?: any[]) => HTMLElement
|
|
536
|
+
): any;
|
|
537
|
+
|
|
538
|
+
export function svgNS(
|
|
539
|
+
type: string,
|
|
540
|
+
props: Record<string, any>,
|
|
541
|
+
...children: any
|
|
542
|
+
): HTMLElement;
|
|
543
|
+
|
|
544
|
+
export function assertOr(
|
|
545
|
+
condition: boolean,
|
|
546
|
+
ifTrue: () => any,
|
|
547
|
+
ifFalse: () => any
|
|
548
|
+
): () => any;
|
|
549
|
+
/**
|
|
550
|
+
* Cradova Ref
|
|
551
|
+
* -------
|
|
552
|
+
* create dynamic components
|
|
553
|
+
*/
|
|
554
|
+
type RefProps<D> = D | any;
|
|
555
|
+
export class Ref<D> {
|
|
556
|
+
private component;
|
|
557
|
+
private stateID;
|
|
558
|
+
private effects;
|
|
559
|
+
private effectuate;
|
|
560
|
+
private rendered;
|
|
561
|
+
private published;
|
|
562
|
+
private hasFirstStateUpdateRun;
|
|
563
|
+
private preRendered;
|
|
564
|
+
stash: D | undefined;
|
|
565
|
+
constructor(component: (data?: RefProps<D>) => any);
|
|
566
|
+
preRender(data?: RefProps<D>): void;
|
|
567
|
+
destroyPreRendered(): void;
|
|
568
|
+
/**
|
|
569
|
+
* Cradova Ref
|
|
570
|
+
* ---
|
|
571
|
+
* returns html with cradova reference
|
|
572
|
+
* @param data
|
|
573
|
+
* @returns () => HTMLElement
|
|
574
|
+
*/
|
|
575
|
+
render(data?: D, stash?: boolean): HTMLElement;
|
|
576
|
+
instance(): any;
|
|
577
|
+
/**
|
|
578
|
+
* Cradova Ref
|
|
579
|
+
* ---
|
|
580
|
+
* runs on first state update
|
|
581
|
+
*
|
|
582
|
+
*/
|
|
583
|
+
effect(fn: () => Promise<unknown>): void;
|
|
584
|
+
private effector;
|
|
585
|
+
/**
|
|
586
|
+
* Cradova Ref
|
|
587
|
+
* ---
|
|
588
|
+
* update ref component with new data and update the dom.
|
|
589
|
+
* @param data
|
|
590
|
+
* @returns void
|
|
591
|
+
*
|
|
592
|
+
*
|
|
593
|
+
* .
|
|
594
|
+
*/
|
|
595
|
+
updateState(data: D, stash?: boolean): void;
|
|
596
|
+
private Activate;
|
|
597
|
+
remove(): void;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Cradova
|
|
602
|
+
* ---
|
|
603
|
+
* Creates new cradova HTML element
|
|
604
|
+
* @example
|
|
605
|
+
* // using template
|
|
606
|
+
* const p = _("p");
|
|
607
|
+
* _("p.class");
|
|
608
|
+
* _("p#id");
|
|
609
|
+
* _("p.class#id");
|
|
610
|
+
* _("p.foo.bar#poo.loo");
|
|
611
|
+
*
|
|
612
|
+
* // using inline props
|
|
613
|
+
*
|
|
614
|
+
* _("p",{
|
|
615
|
+
* text: "am a p tag",
|
|
616
|
+
* style: {
|
|
617
|
+
* color: "blue"
|
|
618
|
+
* }
|
|
619
|
+
* })
|
|
620
|
+
* // or no style props it works!
|
|
621
|
+
* _("p",{
|
|
622
|
+
* text: "am a p tag",
|
|
623
|
+
* color: "blue"
|
|
624
|
+
* })
|
|
625
|
+
*
|
|
626
|
+
* // props and children
|
|
627
|
+
* _("p", // template first
|
|
628
|
+
* // property next if wanted
|
|
629
|
+
* {style: {color: "brown"}, // optional
|
|
630
|
+
* // the rest should be children or text
|
|
631
|
+
* _("span", " am a span tag text like so"),
|
|
632
|
+
* ...
|
|
633
|
+
* )
|
|
634
|
+
*
|
|
635
|
+
* // list of children
|
|
636
|
+
* _("p",
|
|
637
|
+
* // all children goes after
|
|
638
|
+
* _("span",
|
|
639
|
+
* {
|
|
640
|
+
* text:" am a span tag like so",
|
|
641
|
+
* color: "brown",
|
|
642
|
+
* }),
|
|
643
|
+
* ...
|
|
644
|
+
* )
|
|
645
|
+
*
|
|
646
|
+
* @param {...any[]} element_initials
|
|
647
|
+
* @returns function - cradova element
|
|
648
|
+
*/
|
|
649
|
+
const _: any;
|
|
650
|
+
export default _;
|
|
651
|
+
}
|