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