cradova 1.1.0 → 1.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +304 -223
  2. package/dist/index.js +692 -492
  3. package/package.json +18 -31
package/dist/index.d.ts CHANGED
@@ -1,148 +1,4 @@
1
1
  declare module "cradova" {
2
- /**
3
- * swipe
4
- * ---
5
- * Now you can detect swipes the best way possible
6
- *
7
- * @param callback
8
- * @param touching?
9
- * @param element?
10
- */
11
- export function swipe(
12
- callback: (swipe_data: Record<string, number>) => void,
13
- touching?: boolean,
14
- element?: HTMLElement
15
- ): {
16
- start(): void;
17
- stop(): void;
18
- };
19
- /**
20
- * Cradova Signal
21
- * ----
22
- * create stateful data store.
23
- * ability to:
24
- * - create a store
25
- * - create actions and fire them
26
- * - bind a Ref or RefList
27
- * - listen to changes
28
- * - persist changes to localStorage
29
- * - go back and forward in value history
30
- * - set keys instead of all values
31
- * - update a cradova Ref/RefList automatically
32
- * @constructor initial: any, props: {useHistory, persist}
33
- */
34
- export class createSignal {
35
- value: any;
36
- constructor(
37
- initial: unknown,
38
- props?: {
39
- useHistory?: boolean;
40
- persistName?: string | undefined;
41
- }
42
- );
43
- /**
44
- * Cradova Signal
45
- * ----
46
- * set signal value
47
- * @param value - signal value
48
- * @returns void
49
- */
50
- set(value: unknown, shouldRefRender?: boolean): void;
51
- /**
52
- * Cradova Signal
53
- * ----
54
- * set a key value if it's an object
55
- * @param name - name of the key
56
- * @param value - value of the key
57
- * @returns void
58
- */
59
- setKey(name: string, value: any, shouldRefRender?: boolean): void;
60
- /**
61
- * Cradova Signal
62
- * ----
63
- * set a prop value inside an object prop of the store
64
- * @param key - a prop of the store - object value
65
- * @param name - prop of the key object
66
- * @param value - value of the name
67
- * @returns void
68
- */
69
- setPath(
70
- key: string,
71
- name: string,
72
- value: any,
73
- shouldRefRender?: boolean
74
- ): void;
75
- /**
76
- * Cradova Signal
77
- * ----
78
- * set a prop value inside an array prop of the store
79
- * @param key - a prop of the store - object value
80
- * @param index - index of the key object
81
- * @param value - value of the index
82
- * @returns void
83
- */
84
- setIndex(
85
- key: string,
86
- index: number,
87
- value: any,
88
- shouldRefRender?: boolean
89
- ): void;
90
- /**
91
- * Cradova Signal
92
- * ----
93
- * set a key to signal an action
94
- * @param name - name of the action
95
- * @param action function to execute
96
- */
97
- createAction(
98
- name: string | Record<string, (self?: any, data?: any) => void>,
99
- action?: (self?: any, data?: any) => void
100
- ): void;
101
- /**
102
- * Cradova Signal
103
- * ----
104
- * fires an action if available
105
- * @param name - string name of the action
106
- * @param data - data for the action
107
- */
108
- fireAction(name: string, data?: any): void;
109
- /**
110
- * Cradova Signal
111
- * ----
112
- * set a auto - rendering component for this store
113
- *
114
- * @param Ref component to bind to.
115
- * @param path a property in the object to send to attached ref
116
- */
117
- bindRef(Ref: any, path?: string): void;
118
- /**
119
- * Cradova Signal
120
- * ----
121
- * set signal value to a future one
122
- * @returns void
123
- */
124
- forward(): void;
125
- /**
126
- * Cradova Signal
127
- * ----
128
- * set signal value to a old past one
129
- * @returns void
130
- */
131
- backward(): void;
132
- /**
133
- * Cradova Signal
134
- * ----
135
- * set a update listener on value changes
136
- * @param callback
137
- */
138
- listen(callback: (a: any) => void): void;
139
- /**
140
- * Cradova Signal
141
- * ----
142
- * clear the history on local storage
143
- */
144
- clearPersist(): void;
145
- }
146
2
  type CradovaScreenType = {
147
3
  name: string;
148
4
  template: Function | HTMLElement;
@@ -244,24 +100,34 @@ declare module "cradova" {
244
100
  ) => void;
245
101
  }
246
102
  | Record<string, any>;
247
- /**
248
- * Cradova Router
249
- * ---
250
- * Facilitates navigation within the application and initializes
251
- * page views based on the matched routes.
252
- */
253
- export const Router: RouterType;
103
+
254
104
  /**
255
105
  * @param name
256
106
  * @param template
257
107
  * @param transitions
258
108
  */
259
109
  export class Screen {
110
+ /**
111
+ * this should be a cradova screen component
112
+ */
113
+ private html;
260
114
  /**
261
115
  * this is the name of the screen that appears as the title
262
116
  */
263
117
  name: string;
118
+ private packed;
264
119
  secondaryChildren: Array<any>;
120
+ /**
121
+ * used internally
122
+ */
123
+ private template;
124
+ /**
125
+ * this a set of two class names
126
+ * one for the entry transition
127
+ * and one for the exit transition
128
+ */
129
+ private transition;
130
+ private callBack;
265
131
  static SCALE_IN: string;
266
132
  static SCALE_OUT: string;
267
133
  static CIRCLE_IN: string;
@@ -288,11 +154,258 @@ declare module "cradova" {
288
154
  deActivate(): void;
289
155
  Activate(data?: any, force?: boolean): Promise<void>;
290
156
  }
157
+
291
158
  export class Scaffold {
159
+ private history;
160
+ private Scaffolds;
292
161
  push(label: string, data?: unknown, force?: boolean): Promise<void>;
293
162
  pop(data?: unknown, force?: boolean): Promise<void>;
294
163
  addScaffolds(scaffolds: Record<string, CradovaScreenType>): Promise<void>;
295
164
  }
165
+
166
+ /**
167
+ * Cradova Router
168
+ * ---
169
+ * Facilitates navigation within the application and initializes
170
+ * page views based on the matched routes.
171
+ */
172
+ export const Router: RouterType;
173
+
174
+ /**
175
+ * Send a new state to specified element with stateID
176
+ *
177
+ * @param stateID
178
+ * @param state
179
+ * @returns element(s)
180
+ */
181
+ export function dispatch(
182
+ stateID: string | Record<string, any>,
183
+ state?: Record<string, any>
184
+ ): any;
185
+
186
+ /**
187
+ * Cradova Signal
188
+ * ----
189
+ * create stateful data store.
190
+ * ability to:
191
+ * - create a store
192
+ * - create actions and fire them
193
+ * - bind a Ref or RefList
194
+ * - listen to changes
195
+ * - persist changes to localStorage
196
+ * - go back and forward in value history
197
+ * - set keys instead of all values
198
+ * - update a cradova Ref/RefList automatically
199
+ * @constructor initial: any, props: {useHistory, persist}
200
+ */
201
+ export class Signal {
202
+ private callback;
203
+ private persistName;
204
+ private actions;
205
+ private useHistory;
206
+ private history;
207
+ private ref;
208
+ private index;
209
+ private path;
210
+ value: any;
211
+ constructor(
212
+ initial: unknown,
213
+ props?: {
214
+ useHistory?: boolean;
215
+ persistName?: string | undefined;
216
+ }
217
+ );
218
+ /**
219
+ * Cradova Signal
220
+ * ----
221
+ * set signal value
222
+ * @param value - signal value
223
+ * @returns void
224
+ */
225
+ set(value: unknown, shouldRefRender?: boolean): void;
226
+ /**
227
+ * Cradova Signal
228
+ * ----
229
+ * set a key value if it's an object
230
+ * @param name - name of the key
231
+ * @param value - value of the key
232
+ * @returns void
233
+ */
234
+ setKey(name: string, value: any, shouldRefRender?: boolean): void;
235
+ /**
236
+ * Cradova Signal
237
+ * ----
238
+ * set a prop value inside an object prop of the store
239
+ * @param key - a prop of the store - object value
240
+ * @param name - prop of the key object
241
+ * @param value - value of the name
242
+ * @returns void
243
+ */
244
+ setPath(
245
+ key: string,
246
+ name: string,
247
+ value: any,
248
+ shouldRefRender?: boolean
249
+ ): void;
250
+ /**
251
+ * Cradova Signal
252
+ * ----
253
+ * set a prop value inside an array prop of the store
254
+ * @param key - a prop of the store - object value
255
+ * @param index - index of the key object
256
+ * @param value - value of the index
257
+ * @returns void
258
+ */
259
+ setIndex(
260
+ key: string,
261
+ index: number,
262
+ value: any,
263
+ shouldRefRender?: boolean
264
+ ): void;
265
+ /**
266
+ * Cradova Signal
267
+ * ----
268
+ * set a key to signal an action
269
+ * @param name - name of the action
270
+ * @param action function to execute
271
+ */
272
+ createAction(
273
+ name: string | Record<string, (self?: any, data?: any) => void>,
274
+ action?: (self?: any, data?: any) => void
275
+ ): void;
276
+ /**
277
+ * Cradova Signal
278
+ * ----
279
+ * fires an action if available
280
+ * @param name - string name of the action
281
+ * @param data - data for the action
282
+ */
283
+ fireAction(name: string, data?: any): void;
284
+ /**
285
+ * Cradova Signal
286
+ * ----
287
+ * set a auto - rendering component for this store
288
+ *
289
+ * @param Ref component to bind to.
290
+ * @param path a property in the object to send to attached ref
291
+ */
292
+ bindRef(Ref: any, path?: string): void;
293
+ /**
294
+ * Cradova Signal
295
+ * ----
296
+ * set signal value to a future one
297
+ * @returns void
298
+ */
299
+ forward(): void;
300
+ /**
301
+ * Cradova Signal
302
+ * ----
303
+ * set signal value to a old past one
304
+ * @returns void
305
+ */
306
+ backward(): void;
307
+ /**
308
+ * Cradova Signal
309
+ * ----
310
+ * set a update listener on value changes
311
+ * @param callback
312
+ */
313
+ listen(callback: (a: any) => void): void;
314
+ /**
315
+ * Cradova Signal
316
+ * ----
317
+ * clear the history on local storage
318
+ */
319
+ clearPersist(): void;
320
+ }
321
+
322
+ /**
323
+ * Cradova simpleStore
324
+ * ----
325
+ * create stateful data store.
326
+ * ability to:
327
+ * - create a store
328
+ * - set keys instead of all values
329
+ * - update a cradova Ref/RefList/RefElement automatically
330
+ * @constructor initial: any, Ref/RefList/RefElement: any
331
+ */
332
+
333
+ export class simpleStore {
334
+ private ref;
335
+ value: any;
336
+ constructor(initial: unknown, ref: RefType);
337
+ /**
338
+ * Cradova simpleStore
339
+ * ----
340
+ * set simpleStore value
341
+ * @param value - simpleStore value
342
+ * @returns void
343
+ */
344
+ set(value: unknown, shouldRefRender?: boolean): void;
345
+ /**
346
+ * Cradova simpleStore
347
+ * ----
348
+ * set a key value if it's an object
349
+ * @param name - name of the key
350
+ * @param value - value of the key
351
+ * @returns void
352
+ */
353
+ setKey(name: string, value: any, shouldRefRender?: boolean): void;
354
+ /**
355
+ * Cradova simpleStore
356
+ * ----
357
+ * set a auto - rendering component for this store
358
+ *
359
+ * @param Ref component to bind to.
360
+ * @param path a property in the object to send to attached ref
361
+ */
362
+ bindRef(Ref: any): void;
363
+ }
364
+
365
+ /**
366
+ *
367
+ * Cradova Ajax
368
+ * ------------------
369
+ * your new axios alternative
370
+ * supports files upload
371
+ * @param url string
372
+ * @param {{method: string;data;header;callbacks;}} opts
373
+ * @returns any
374
+ */
375
+ export function Ajax(
376
+ url: string | URL,
377
+ opts?:
378
+ | {
379
+ method?: string;
380
+ data?: Record<string, any>;
381
+ header?: Record<string, any>;
382
+ callbacks?: Record<string, (arg: any) => void>;
383
+ }
384
+ | any
385
+ ): Promise<unknown>;
386
+
387
+ /**
388
+ * swipe
389
+ * ---
390
+ * Now you can detect swipes the best way possible
391
+ *
392
+ * @param callback
393
+ * @param touching?
394
+ * @param element?
395
+ */
396
+ export function swipe(
397
+ callback: (swipe_data: Record<string, number>) => void,
398
+ touching?: boolean,
399
+ element?: HTMLElement
400
+ ): {
401
+ start(): void;
402
+ stop(): void;
403
+ };
404
+
405
+ export function loadCradovaUICss(seconds?: number): void;
406
+
407
+ export function IsElementInView(element: HTMLElement): boolean;
408
+
296
409
  export const controls: () => void;
297
410
  export function uuid(): string;
298
411
  export function PromptBeforeLeave(callback?: (e: any) => void): void;
@@ -405,6 +518,10 @@ _.animate("polarization",
405
518
  exist(): void;
406
519
  };
407
520
  export class RefList {
521
+ private component;
522
+ private stateID;
523
+ private parentElement;
524
+ private datas;
408
525
  constructor(component: (...data: any) => any);
409
526
  stale(datas: any): void;
410
527
  r(d?: any): any;
@@ -422,6 +539,10 @@ _.animate("polarization",
422
539
  *
423
540
  */
424
541
  export class Ref {
542
+ private component;
543
+ private stateID;
544
+ private upcb;
545
+ private data;
425
546
  constructor(component: (...data: any) => any);
426
547
  stale(data: any): void;
427
548
  r(d?: any): () => any;
@@ -461,81 +582,41 @@ _.animate("polarization",
461
582
  type fragmentTYPE = () => (() => HTMLElement) | HTMLElement;
462
583
  export const frag: (...children: fragmentTYPE[]) => DocumentFragment;
463
584
  /**
464
- * Send a new state to specified element with stateID
585
+ * Creates new cradova HTML element
586
+ * @example
587
+ * _("p") // or _("p.class") or _("p#id") or _("p.class#id")
588
+ * using inline props
589
+ * _("p",{
590
+ * text: "am a p tag",
591
+ * style: {
592
+ * color: "blue"
593
+ * }
594
+ * )
595
+ * adding children
596
+ * _("p",
597
+ * _("span",{text:" am a span tag like so",
598
+ * {style: {color: "brown"}
599
+ * })
600
+ * )
465
601
  *
466
- * @param stateID
467
- * @param state
468
- * @returns element(s)
469
- */
470
- export function dispatch(
471
- stateID: string | Record<string, any>,
472
- state?: Record<string, any>
473
- ): any;
474
- /**
602
+ * props and children
603
+ * _("p",
604
+ * // props first
605
+ * {
606
+ * text: "am a p tag",
607
+ * style: {
608
+ * color: "blue"
609
+ * },
610
+ * // all children goes after
611
+ * _("span",{text:" am a span tag like so",
612
+ * {style: {color: "brown"}
613
+ * })
614
+ * )
475
615
  *
476
- * Cradova Ajax
477
- * ------------------
478
- * your new axios alternative
479
- * supports files upload
480
- * @param url string
481
- * @param {{method: string;data;header;callbacks;}} opts
482
- * @returns any
616
+ * @param {...any} element_initials
617
+ * @returns function - cradova element
483
618
  */
484
- export function Ajax(
485
- url: string | URL,
486
- opts?:
487
- | {
488
- method?: string;
489
- data?: Record<string, any>;
490
- header?: Record<string, any>;
491
- callbacks?: Record<string, (arg: any) => void>;
492
- }
493
- | any
494
- ): Promise<unknown>;
495
- export function IsElementInView(element: HTMLElement): boolean;
496
- export class simpleStore {
497
- value: any;
498
- constructor(initial: unknown, ref: RefType);
499
- /**
500
- * Cradova simpleStore
501
- * ----
502
- * set simpleStore value
503
- * @param value - simpleStore value
504
- * @returns void
505
- */
506
- set(value: unknown, shouldRefRender?: boolean): void;
507
- /**
508
- * Cradova simpleStore
509
- * ----
510
- * set a key value if it's an object
511
- * @param name - name of the key
512
- * @param value - value of the key
513
- * @returns void
514
- */
515
- setKey(name: string, value: any, shouldRefRender?: boolean): void;
516
- /**
517
- * Cradova simpleStore
518
- * ----
519
- * set a auto - rendering component for this store
520
- *
521
- * @param Ref component to bind to.
522
- * @param path a property in the object to send to attached ref
523
- */
524
- bindRef(Ref: any): void;
525
- }
526
- export const make: (txx: any) =>
527
- | {
528
- tag: string;
529
- className?: undefined;
530
- ID?: undefined;
531
- innerValue?: undefined;
532
- }
533
- | {
534
- tag: undefined;
535
- className: any;
536
- ID: any;
537
- innerValue: string;
538
- };
619
+
539
620
  /**
540
621
  * Creates new cradova HTML element
541
622
  * @example