cradova 1.4.1 → 2.0.0

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 CHANGED
@@ -1,83 +1,163 @@
1
1
  declare module "cradova" {
2
- type CradovaScreenTyping = {
3
- name: string;
4
- template: Function | HTMLElement;
5
- transition?: string;
6
- persist?: boolean;
7
- /**
8
- * Cradova screen
9
- * ---
10
- * runs once after first render
11
- *
12
- */
13
- };
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>;
14
25
 
15
- type CradovaScreenType = {
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
+ );
16
53
  /**
17
- * Cradova screen
18
- * ---
19
- * runs once after first render
20
- *
54
+ * Cradova Signal
55
+ * ----
56
+ * set signal value
57
+ * @param value - signal value
58
+ * @returns void
21
59
  */
22
- effect?(fn: () => void | Promise<void>): void;
60
+ set(value: Type | ((value: Type) => Type), shouldRefRender?: boolean): void;
23
61
  /**
24
- * Cradova Screen
25
- * ---
26
- * re-renders the screen -
27
- *
28
- * first level call will only be called once
29
- * lower level calls will be continuously called
30
- * @param data .
31
- *
32
- * *
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
33
68
  */
34
-
35
- updateState(data: unknown): void;
36
- };
37
-
38
- type CradovaElementType = Record<string, any>;
39
-
40
- type RefType = {
69
+ setKey<k extends keyof Type>(
70
+ key: k,
71
+ value: any,
72
+ shouldRefRender?: boolean
73
+ ): void;
41
74
  /**
42
- * Cradova Ref
43
- * ---
44
- * returns html with cradova reference
45
- * @param data
46
- * @returns HTMLElement
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
47
80
  */
48
- render(data?: any): () => any;
81
+ createAction(
82
+ key: string | Record<string, (self?: this, data?: Type) => void>,
83
+ action?: (self?: this, data?: Type) => void
84
+ ): void;
49
85
  /**
50
- * Cradova Ref
51
- * ---
52
- * checks if element is in the dom and returns it.
53
- * @param data
54
- * @return HTMLElement
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
55
91
  */
56
- instance(): HTMLElement | null;
92
+ fireAction(key: string, data?: Type): void;
57
93
  /**
58
- * Cradova Ref
59
- * ---
60
- * update ref component with new data and update the dom.
61
- * @param data
62
- * @returns void
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
63
100
  */
64
- updateState(data: any): void;
101
+ bindRef(Ref: any, path?: string): void;
65
102
  /**
66
- * Cradova Ref
67
- * ---
68
- * remove element from the dom
69
- * @param data
70
- * @returns () => HTMLElement
103
+ * Cradova Signal
104
+ * ----
105
+ * set a update listener on value changes
106
+ * @param callback
71
107
  */
72
- remove(): void;
108
+ listen(callback: (a: any) => void): void;
73
109
  /**
74
- * Cradova Ref
75
- * ---
76
- * runs once on render
110
+ * Cradova Signal
111
+ * ----
112
+ * clear the history on local storage
77
113
  *
114
+ *
115
+ * .
78
116
  */
79
- effect(fn: (data: unknown) => Promise<void> | void): void;
80
- };
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
+
81
161
  /**
82
162
  * Cradova Router
83
163
  * ---
@@ -91,14 +171,14 @@ declare module "cradova" {
91
171
  * @param {string} path Route path.
92
172
  * @param {any} screen the cradova document tree for the route.
93
173
  */
94
- route: (path: string, screen: CradovaScreenType) => void;
174
+ route: (path: string, screen: Screen) => void;
95
175
  /**
96
176
  * get a screen ready before time.
97
177
  *
98
178
  * @param {string} path Route path.
99
179
  * @param {any} data data for the screen.
100
180
  */
101
- packageScreen: (path: string, data?: any) => void;
181
+ packageScreen: (path: string, data?: any) => Promise<void>;
102
182
  onPageShow: (callback: () => void) => void;
103
183
  onPageHide: (callback: () => void) => void;
104
184
  /**
@@ -109,7 +189,7 @@ declare module "cradova" {
109
189
  *
110
190
  * .
111
191
  */
112
- getParams: () => unknown;
192
+ getParams: <D>() => { data: D | unknown; params: any };
113
193
  /**
114
194
  * Cradova Router
115
195
  * ------
@@ -134,72 +214,6 @@ declare module "cradova" {
134
214
  addErrorHandler: (callback: (error: string) => void, path?: string) => void;
135
215
  };
136
216
 
137
- /**
138
- * Cradova
139
- * ---
140
- * Cradova afterMount event
141
- *
142
- * dispatch this manually if you are not using a cradova screen object
143
- *
144
- */
145
-
146
- export const cradovaAftermountEvent: CustomEvent<string>;
147
-
148
- /**
149
- * Cradova Screen
150
- * ---
151
- * create instances of manageable pages
152
- * @param name
153
- * @param template
154
- * @param transitions
155
- */
156
- export class Screen {
157
- static SCALE_IN: string;
158
- static SCALE_OUT: string;
159
- static CIRCLE_IN: string;
160
- static CIRCLE_OUT: string;
161
- static FADE_OUT: string;
162
- static FADE_IN: string;
163
- static SLIDE_UP: string;
164
- static SLIDE_DOWN: string;
165
- static SLIDE_LEFT: string;
166
- static SLIDE_RIGHT: string;
167
- /**
168
- * Cradova Screen
169
- * ---
170
- * create instances of manageable pages
171
- * @param name
172
- * @param template
173
- * @param transitions
174
- */
175
- constructor(cradova_screen_initials: CradovaScreenTyping);
176
- /**
177
- * Cradova Screen
178
- * ---
179
- * runs once after first render
180
- *
181
- */
182
- effect(fn: () => void | Promise<void>): void;
183
- package(data?: any): Promise<void>;
184
- onActivate(cb: (data: any) => void): void;
185
- addChild(...addOns: any[]): void;
186
- deActivate(): void;
187
- Activate(data?: any, force?: boolean): Promise<void>;
188
- /**
189
- * Cradova Screen
190
- * ---
191
- * re-renders the screen -
192
- *
193
- * first level call will only be called once
194
- * lower level calls will be continuously called
195
- * @param data .
196
- *
197
- * *
198
- */
199
-
200
- updateState(data: unknown): void;
201
- }
202
-
203
217
  /**
204
218
  * Cradova Router
205
219
  * ---
@@ -209,151 +223,105 @@ declare module "cradova" {
209
223
  export const Router: RouterType;
210
224
 
211
225
  /**
212
- * Send a new state to specified element with stateID
213
226
  *
214
- * @param stateID
215
- * @param state
216
- * @returns element(s)
217
227
  */
218
- export function dispatch(
219
- stateID: string | Record<string, any>,
220
- state?: Record<string, any>
221
- ): any;
222
-
223
- /**
224
- * Cradova Signal
225
- * ----
226
- * create stateful data store.
227
- * ability to:
228
- * - create a store
229
- * - create actions and fire them
230
- * - bind a Ref
231
- * - listen to changes
232
- * - persist changes to localStorage
233
- * - go back and forward in value history
234
- * - set keys instead of all values
235
- * - update a cradova Ref automatically
236
- * @constructor initial: any, props: {useHistory, persist}
237
- */
238
- export class createSignal {
239
- private callback;
240
- private persistName;
241
- private actions;
242
- private useHistory;
243
- private history;
244
- private ref;
245
- private index;
246
- private path;
247
- value: any;
248
- constructor(
249
- initial: unknown,
250
- props?: {
251
- useHistory?: boolean;
252
- persistName?: string | undefined;
253
- }
254
- );
228
+ type CradovaScreenType = {
255
229
  /**
256
- * Cradova Signal
257
- * ----
258
- * set signal value
259
- * @param value - signal value
230
+ * Cradova screen
231
+ * ---
232
+ * title of the page
233
+ * @param data
260
234
  * @returns void
235
+ *
236
+ *
237
+ * .
261
238
  */
262
- set(value: unknown, shouldRefRender?: boolean): void;
239
+ name: string;
263
240
  /**
264
- * Cradova Signal
265
- * ----
266
- * set a key value if it's an object
267
- * @param name - name of the key
268
- * @param value - value of the key
241
+ * Cradova screen
242
+ * ---
243
+ * The component for the screen
244
+ * @param data
269
245
  * @returns void
246
+ *
247
+ *
248
+ * .
270
249
  */
271
- setKey(name: string, value: any, shouldRefRender?: boolean): void;
250
+ template: Function | HTMLElement;
272
251
  /**
273
- * Cradova Signal
274
- * ----
275
- * set a prop value inside an object prop of the store
276
- * @param key - a prop of the store - object value
277
- * @param name - prop of the key object
278
- * @param value - value of the name
252
+ * Cradova screen
253
+ * ---
254
+ * Screen transition from the screen class
255
+ * @param data
279
256
  * @returns void
257
+ *
258
+ *
259
+ * .
280
260
  */
281
- setPath(
282
- key: string,
283
- name: string,
284
- value: any,
285
- shouldRefRender?: boolean
286
- ): void;
261
+ transition?: string;
287
262
  /**
288
- * Cradova Signal
289
- * ----
290
- * set a prop value inside an array prop of the store
291
- * @param key - a prop of the store - object value
292
- * @param index - index of the key object
293
- * @param value - value of the index
263
+ * Cradova screen
264
+ * ---
265
+ * gets called when the the screen is displayed
266
+ * @param data
294
267
  * @returns void
268
+ *
269
+ *
270
+ * .
295
271
  */
296
- setIndex(
297
- key: string,
298
- index: number,
299
- value: any,
300
- shouldRefRender?: boolean
301
- ): void;
302
- /**
303
- * Cradova Signal
304
- * ----
305
- * set a key to signal an action
306
- * @param name - name of the action
307
- * @param action function to execute
308
- */
309
- createAction(
310
- name: string | Record<string, (self?: any, data?: any) => void>,
311
- action?: (self?: any, data?: any) => void
312
- ): void;
313
- /**
314
- * Cradova Signal
315
- * ----
316
- * fires an action if available
317
- * @param name - string name of the action
318
- * @param data - data for the action
319
- */
320
- fireAction(name: string, data?: any): void;
321
272
  /**
322
- * Cradova Signal
323
- * ----
324
- * set a auto - rendering component for this store
273
+ * Cradova screen
274
+ * ---
275
+ * Should this screen be cached after first render?
276
+ * @param data
277
+ * @returns void
325
278
  *
326
- * @param Ref component to bind to.
327
- * @param path a property in the object to send to attached ref
279
+ *
280
+ * .
328
281
  */
329
- bindRef(Ref: any, path?: string): void;
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 {
330
294
  /**
331
- * Cradova Signal
332
- * ----
333
- * set signal value to a future one
334
- * @returns void
295
+ * this should be a cradova screen component
335
296
  */
336
- forward(): void;
297
+ private html;
337
298
  /**
338
- * Cradova Signal
339
- * ----
340
- * set signal value to a old past one
341
- * @returns void
299
+ * this is the name of the screen that appears as the title
342
300
  */
343
- backward(): void;
301
+ private name;
302
+ private packed;
303
+ private secondaryChildren;
344
304
  /**
345
- * Cradova Signal
346
- * ----
347
- * set a update listener on value changes
348
- * @param callback
305
+ * used internally
349
306
  */
350
- listen(callback: (a: any) => void): void;
307
+ private template;
308
+ private callBack;
309
+ private deCallBack;
310
+ errorHandler: (() => void) | null;
351
311
  /**
352
- * Cradova Signal
353
- * ----
354
- * clear the history on local storage
312
+ * this tells cradova to persist state on the screen or not
313
+ * persisting is better
355
314
  */
356
- clearPersist(): void;
315
+ private persist;
316
+ private data;
317
+ constructor(cradova_screen_initials: CradovaScreenType);
318
+ setErrorHandler(errorHandler: () => void): void;
319
+ package(): Promise<void>;
320
+ onActivate(cb: (data: any) => Promise<void>): void;
321
+ onDeactivate(cb: (data: any) => Promise<void>): void;
322
+ addChild(...addOns: any[]): void;
323
+ deActivate(): void;
324
+ Activate(force?: boolean): Promise<void>;
357
325
  }
358
326
 
359
327
  /**
@@ -363,14 +331,13 @@ declare module "cradova" {
363
331
  * ability to:
364
332
  * - create a store
365
333
  * - set keys instead of all values
366
- * - update a cradova Ref automatically
367
- * @constructor initial: any, Ref: any
334
+ * - able to update state on any element as a property value
335
+ * @constructor initial: any, Ref/RefList/RefElement: any
368
336
  */
369
-
370
- export class $ {
337
+ export class $<Type extends Record<string, unknown>> {
371
338
  private ref;
372
- value: any;
373
- constructor(initial: unknown);
339
+ value: Type;
340
+ constructor(initial: Type);
374
341
  /**
375
342
  * Cradova simpleStore
376
343
  * ----
@@ -378,7 +345,17 @@ declare module "cradova" {
378
345
  * @param value - simpleStore value
379
346
  * @returns void
380
347
  */
381
- set(value: unknown, shouldRefRender?: boolean): void;
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;
382
359
  /**
383
360
  * Cradova simpleStore
384
361
  * ----
@@ -387,44 +364,140 @@ declare module "cradova" {
387
364
  * @param value - value of the key
388
365
  * @returns void
389
366
  */
390
- setKey(name: string, value: any, shouldRefRender?: boolean): void;
367
+ setKey<k extends keyof Type>(
368
+ name: k,
369
+ value: any,
370
+ shouldRefRender?: boolean
371
+ ): void;
391
372
  /**
392
373
  * Cradova simpleStore
393
- * ---
394
- * is used to bind store data to any element
374
+ * ----
375
+ * set a auto - rendering component for this store
395
376
  *
396
- * @param prop
397
- * @returns something
377
+ * @param Ref component to bind to.
378
+ * @param path a property in the object to send to attached ref
398
379
  */
399
-
400
- bind(prop: string): void;
380
+ bindRef(ref: any, key: string, prop: string): void;
401
381
  }
402
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 svg: ElementType<HTMLOrSVGElement>;
479
+ export const table: ElementType<HTMLTableElement>;
480
+ export const tbody: ElementType<HTMLTableColElement>;
481
+ export const td: ElementType<HTMLTableCellElement>;
482
+ export const template: ElementType<HTMLTemplateElement>;
483
+ export const textarea: ElementType<HTMLTextAreaElement>;
484
+ export const tfoot: ElementType<HTMLElement>;
485
+ export const th: ElementType<HTMLTableSectionElement>;
486
+ export const thead: ElementType<HTMLTableSectionElement>;
487
+ export const time: ElementType<HTMLTimeElement>;
488
+ export const title: ElementType<HTMLTitleElement>;
489
+ export const tr: ElementType<HTMLTableRowElement>;
490
+ export const track: ElementType<HTMLTrackElement>;
491
+ export const u: ElementType<HTMLElement>;
492
+ export const ul: ElementType<HTMLUListElement>;
493
+ export const val: ElementType<HTMLElement>;
494
+ export const video: ElementType<HTMLVideoElement>;
495
+ export const wbr: ElementType<HTMLElement>;
496
+
403
497
  /**
404
- *
405
- * Cradova Ajax
406
- * ------------------
407
- * your new axios alternative
408
- * supports files upload
409
- * @param url string
410
- * @param {{method: string;data;header;callbacks;}} opts
411
- * @returns any
498
+ * Cradova afterMount event
412
499
  */
413
- export function Ajax(
414
- url: string | URL,
415
- opts?:
416
- | {
417
- method?: string;
418
- data?: Record<string, any>;
419
- header?: Record<string, any>;
420
- callbacks?: Record<string, (arg: any) => void>;
421
- }
422
- | any
423
- ): Promise<unknown>;
424
-
425
- export function loadCradovaUICss(seconds?: number): void;
426
- export function uuid(): string;
427
-
500
+ export let cradovaAftermountEvent: CustomEvent<unknown>;
428
501
  /**
429
502
  Write CSS styles in Javascript
430
503
  @example
@@ -458,69 +531,59 @@ css(".btn:hover",
458
531
  ...callback: (() => any)[]
459
532
  ): "" | (() => any)[];
460
533
  export function assertOr(
461
- condition: any,
534
+ condition: boolean,
462
535
  ifTrue: () => any,
463
536
  ifFalse: () => any
464
537
  ): () => any;
465
- /**
466
- * Create element and get a callback to update their state
467
- * no need to manage stateIDs
468
- * ----------------------------------------------------------------
469
- *
470
- * @param element_initials
471
- * @param props
472
- * @returns
473
- */
474
-
475
- export const ls: Record<string, Function>;
476
-
477
538
  /**
478
539
  * Cradova Ref
479
540
  * -------
480
541
  * create dynamic components
481
- *
482
542
  */
483
- export class Ref {
484
- constructor(component: (...data: any) => any);
543
+ type RefProps<D> = D | any;
544
+ export class Ref<D> {
545
+ private component;
546
+ private stateID;
547
+ private effects;
548
+ private effectuate;
549
+ private rendered;
550
+ private published;
551
+ private hasFirstStateUpdateRun;
552
+ private preRendered;
553
+ stash: D | undefined;
554
+ constructor(component: (data?: RefProps<D>) => any);
555
+ preRender(data?: RefProps<D>): void;
556
+ destroyPreRendered(): void;
485
557
  /**
486
558
  * Cradova Ref
487
559
  * ---
488
560
  * returns html with cradova reference
489
561
  * @param data
490
- * @returns HTMLElement
562
+ * @returns () => HTMLElement
491
563
  */
492
- render(data?: any): () => any;
564
+ render(data?: D, stash?: boolean): HTMLElement;
565
+ instance(): any;
493
566
  /**
494
567
  * Cradova Ref
495
568
  * ---
496
- * checks if element is in the dom and returns it.
497
- * @param data
498
- * @return HTMLElement
569
+ * runs on first state update
570
+ *
499
571
  */
500
- instance(): HTMLElement | null;
572
+ effect(fn: () => Promise<unknown>): void;
573
+ private effector;
501
574
  /**
502
575
  * Cradova Ref
503
576
  * ---
504
577
  * update ref component with new data and update the dom.
505
578
  * @param data
506
579
  * @returns void
507
- */
508
- updateState(data: any): void;
509
- /**
510
- * Cradova Ref
511
- * ---
512
- * remove element from the dom
513
- * @param data
514
- * @returns () => HTMLElement
515
- */
516
- remove(): void;
517
- /**
518
- * Cradova Ref
519
- * ---
520
- * runs once on render
521
580
  *
581
+ *
582
+ * .
522
583
  */
523
- effect(fn: (data: unknown) => Promise<void> | void): void;
584
+ updateState(data: D, stash?: boolean): void;
585
+ private Activate;
586
+ remove(): void;
524
587
  }
525
588
 
526
589
  /**
@@ -572,7 +635,6 @@ css(".btn:hover",
572
635
  * @param {...any[]} element_initials
573
636
  * @returns function - cradova element
574
637
  */
575
-
576
638
  const _: any;
577
639
  export default _;
578
640
  }