cradova 3.1.6 → 3.2.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +306 -389
  2. package/dist/index.js +19 -23
  3. package/package.json +3 -5
package/dist/index.d.ts CHANGED
@@ -1,49 +1,28 @@
1
- /*
2
- ============================================================================="
3
- ██████╗ ██████╗ █████═╗ ███████╗ ███████╗ ██╗ ██╗ █████╗
4
- ██╔════╝ ██╔══██╗ ██╔═╗██║ █ ██ ██╔═════╝█ ██║ ██║ ██╔═╗██
5
- ██║ ██████╔╝ ███████║ █ ██ ██║ ██ ██║ ██║ ██████╗
6
- ██║ ██╔══██╗ ██║ ██║ █ ██ ██║ ██ ╚██╗ ██╔╝ ██║ ██╗
7
- ╚██████╗ ██║ ██║ ██║ ██║ ███████╔╝ ████████ ╚███╔╝ ██║ ██║
8
- ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚════╝ ╚══╝ ╚═╝ ╚═╝
9
- =============================================================================
10
- Cradova FrameWork
11
- @version 3.0.0
12
- License: Apache V2
13
- Copyright 2022 Friday Candour.
14
- Repository - https://github.com/fridaycandour/cradova
15
- =============================================================================
16
- */
1
+ import * as CSS from 'csstype';
17
2
 
18
- import * as CSS from "csstype";
19
-
20
- declare module "cradova" {
21
- /**
22
- * Cradova Signal
23
- * ----
24
- * Create stateful data store.
25
- * Features:
26
- * - create a store
27
- * - create actions and fire them
28
- * - bind a Ref and elements
29
- * - listen to updates
30
- * - set object keys instead of all values
31
- * - persist changes to localStorage
32
- * - update a cradova Ref automatically
33
- * @constructor initial: unknown, props: {useHistory, persist}
34
- */
35
- export class createSignal<Type extends Record<string, unknown>> {
3
+ /**
4
+ * Cradova Signal
5
+ * ----
6
+ * Create stateful data store.
7
+ * Features:
8
+ * - create a store
9
+ * - create actions and fire them
10
+ * - bind a Ref and elements
11
+ * - listen to updates
12
+ * - set object keys instead of all values
13
+ * - persist changes to localStorage
14
+ * - update a cradova Ref automatically
15
+ * @constructor initial: unknown, props: {useHistory, persist}
16
+ */
17
+ declare class createSignal<Type extends Record<string, unknown>> {
36
18
  private callback;
37
19
  private persistName;
38
20
  private actions;
39
21
  private ref;
40
22
  value: Type;
41
- constructor(
42
- initial: Type,
43
- props?: {
23
+ constructor(initial: Type, props?: {
44
24
  persistName?: string | undefined;
45
- }
46
- );
25
+ });
47
26
  /**
48
27
  * Cradova Signal
49
28
  * ----
@@ -60,11 +39,7 @@ declare module "cradova" {
60
39
  * @param value - value of the key
61
40
  * @returns void
62
41
  */
63
- setKey<k extends keyof Type>(
64
- key: k,
65
- value: unknown,
66
- shouldRefRender?: boolean
67
- ): void;
42
+ setKey<k extends keyof Type>(key: k, value: unknown, shouldRefRender?: boolean): void;
68
43
  /**
69
44
  * Cradova Signal
70
45
  * ----
@@ -107,14 +82,11 @@ declare module "cradova" {
107
82
  * @param Ref component to bind to.
108
83
  * @param path a property in the object to send to attached ref
109
84
  */
110
- bindRef(
111
- ref: Partial<Ref<unknown>>,
112
- binding?: {
85
+ bindRef(ref: Partial<Ref<unknown>>, binding?: {
113
86
  event?: string;
114
87
  signalProperty: string;
115
88
  _element_property: string;
116
- }
117
- ): void;
89
+ }): void;
118
90
  /**
119
91
  * Cradova Signal
120
92
  * ----
@@ -129,51 +101,35 @@ declare module "cradova" {
129
101
  *
130
102
  */
131
103
  clearPersist(): void;
132
- }
104
+ }
133
105
 
134
- export const isNode: (element: unknown) => boolean;
135
- /**
136
- * Cradova event
137
- */
138
- export class cradovaEvent {
106
+ declare const isNode: (element: unknown) => boolean;
107
+ /**
108
+ * Cradova event
109
+ */
110
+ declare class cradovaEvent {
139
111
  private listeners;
140
112
  addEventListener(eventName: string, callback: () => void): Promise<void>;
141
113
  dispatchEvent(eventName: string, eventArgs?: unknown): Promise<void>;
142
- }
143
- export const CradovaEvent: cradovaEvent;
144
- export function Rhoda(
145
- l: VJSType<HTMLElement>[] | (() => any)[] | Ref<unknown>[] | HTMLElement[]
146
- ): DocumentFragment;
147
- export function css(identifier: string | TemplateStringsArray): void;
148
- /**
149
- *
150
- * @param {expression} condition
151
- * @param {function} elements[]
152
- */
153
- export function assert<Type>(
154
- condition: boolean,
155
- ...elements: VJS_Child_TYPE<Type | HTMLElement>[]
156
- ): HTMLElement[] | undefined;
157
- export function assertOr<Type>(
158
- condition: boolean,
159
- ifTrue: VJS_Child_TYPE<Type | HTMLElement>,
160
- ifFalse: VJS_Child_TYPE<Type | HTMLElement>
161
- ): VJS_Child_TYPE<HTMLElement | Type>;
162
- type LoopData<Type> = Type[];
163
- export function loop<Type>(
164
- datalist: LoopData<Type>,
165
- component: (
166
- value: Type,
167
- index?: number,
168
- array?: LoopData<Type>
169
- ) => HTMLElement | DocumentFragment | undefined
170
- ): HTMLElement[] | undefined;
171
- /**
172
- * Cradova Ref
173
- * -------
174
- * create dynamic components
175
- */
176
- export class Ref<D> {
114
+ }
115
+ declare const CradovaEvent: cradovaEvent;
116
+ declare function Rhoda(l: VJSType<HTMLElement>[] | (() => any)[] | Ref<unknown>[] | HTMLElement[]): DocumentFragment;
117
+ declare function css(identifier: string | TemplateStringsArray): void;
118
+ /**
119
+ *
120
+ * @param {expression} condition
121
+ * @param {function} elements[]
122
+ */
123
+ declare function assert<Type>(condition: boolean, ...elements: VJS_Child_TYPE<Type | HTMLElement>[]): HTMLElement[] | undefined;
124
+ declare function assertOr<Type>(condition: boolean, ifTrue: VJS_Child_TYPE<Type | HTMLElement>, ifFalse: VJS_Child_TYPE<Type | HTMLElement>): VJS_Child_TYPE<HTMLElement | Type>;
125
+ type LoopData<Type> = Type[];
126
+ declare function loop<Type>(datalist: LoopData<Type>, component: (value: Type, index?: number, array?: LoopData<Type>) => HTMLElement | DocumentFragment | undefined): HTMLElement[] | undefined;
127
+ /**
128
+ * Cradova Ref
129
+ * -------
130
+ * create dynamic components
131
+ */
132
+ declare class Ref<D> {
177
133
  private component;
178
134
  private effects;
179
135
  private effectuate;
@@ -181,17 +137,16 @@ declare module "cradova" {
181
137
  private published;
182
138
  private preRendered;
183
139
  private reference;
140
+ private current_id?;
184
141
  Signal: createSignal<any> | undefined;
185
142
  _state: D[];
186
143
  _state_track: {
187
- [x: number]: boolean;
144
+ [x: number]: boolean;
188
145
  };
189
146
  _state_index: number;
190
147
  stash: D | undefined;
191
- constructor(
192
- component: (this: Ref<D>, data: D) => HTMLElement | DocumentFragment
193
- );
194
- preRender(data?: D): void;
148
+ constructor(component: (this: Ref<D>, data: D) => HTMLElement | DocumentFragment);
149
+ preRender(data?: D, stash?: boolean): void;
195
150
  destroyPreRendered(): void;
196
151
  /**
197
152
  * Cradova Ref
@@ -215,82 +170,86 @@ declare module "cradova" {
215
170
  */
216
171
  updateState(data?: D, stash?: boolean): void;
217
172
  private Activate;
218
- }
219
- /**
220
- * Document fragment
221
- * @param children
222
- * @returns
223
- */
224
- export const frag: (children: VJSType<HTMLElement>[]) => DocumentFragment;
225
- /**
226
- * cradova
227
- * ---
228
- * lazy load a file
229
- */
230
- export class lazy<Type> {
173
+ }
174
+ /**
175
+ * Document fragment
176
+ * @param children
177
+ * @returns
178
+ */
179
+ declare const frag: (children: VJSType<HTMLElement>[]) => DocumentFragment;
180
+ /**
181
+ * cradova
182
+ * ---
183
+ * lazy load a file
184
+ */
185
+ declare class lazy<Type> {
231
186
  content: Type | undefined;
232
187
  private _cb;
233
188
  constructor(cb: () => Promise<unknown>);
234
189
  load(): Promise<void>;
235
- }
236
- /**
237
- * Cradova
238
- * ---
239
- * make reference to dom elements
240
- */
241
- export class reference {
190
+ }
191
+ /**
192
+ * Cradova
193
+ * ---
194
+ * make reference to dom elements
195
+ */
196
+ declare class reference {
242
197
  [x: string]: Record<string, any>;
198
+ /**
199
+ * Bind a DOM element to a reference name.
200
+ * @param name - The name to reference the DOM element by.
201
+ */
243
202
  bindAs(name: string): reference;
244
- dom<ElementType>(name: string): ElementType | undefined;
245
- _appendDomForce(name: string, Element: HTMLElement): void;
246
- }
247
- /**
248
- * Cradova
249
- * ---
250
- * Allows functional components to manage state by providing a state value and a function to update it.
251
- * @param initialValue
252
- * @param ActiveRef
253
- * @returns [state, setState]
254
- */
255
- export function useState<S = unknown>(
256
- initialValue: S,
257
- ActiveRef: Ref<unknown>
258
- ): [S, (newState: S) => void];
259
- /**
260
- * Cradova
261
- * ---
262
- Allows side effects to be performed in functional components (Refs), such as fetching data or subscribing to events.
263
- * @param effect
264
- * @returns
203
+ /**
204
+ * Retrieve a referenced DOM element.
205
+ * @param name - The name of the referenced DOM element.
265
206
  */
266
- export function useEffect(effect: () => void, ActiveRef: Ref<unknown>): void;
267
- /**
268
- * Cradova
269
- * ---
270
- Returns a mutable reference object of dom elements that persists across component renders.
271
- * @returns reference
207
+ dom<ElementType extends HTMLElement>(name: string): ElementType | undefined;
208
+ /**
209
+ * Append a DOM element to the reference, overwriting any existing reference.
210
+ * @param name - The name to reference the DOM element by.
211
+ * @param element - The DOM element to reference.
272
212
  */
273
- export function useRef(): Record<string, HTMLElement | undefined>;
213
+ _appendDomForce(name: string, Element: HTMLElement): void;
214
+ }
215
+ /**
216
+ * Cradova
217
+ * ---
218
+ * Allows functional components to manage state by providing a state value and a function to update it.
219
+ * @param initialValue
220
+ * @param ActiveRef
221
+ * @returns [state, setState]
222
+ */
223
+ declare function useState<S = unknown>(initialValue: S, ActiveRef: Ref<unknown>): [S, (newState: S) => void];
224
+ /**
225
+ * Cradova
226
+ * ---
227
+ Allows side effects to be performed in functional components (Refs), such as fetching data or subscribing to events.
228
+ * @param effect
229
+ * @returns
230
+ */
231
+ declare function useEffect(effect: () => void, ActiveRef: Ref<unknown>): void;
232
+ /**
233
+ * Cradova
234
+ * ---
235
+ Returns a mutable reference object of dom elements that persists across component renders.
236
+ * @returns reference
237
+ */
238
+ declare function useRef(): Record<string, HTMLElement | undefined>;
274
239
 
275
- /**
276
- * Cradova Screen
277
- * ---
278
- * create instances of manageable pages and scaffolds
279
- * @param name
280
- * @param template
281
- * @param transitions
282
- */
283
- export class Screen {
240
+ /**
241
+ * Cradova Screen
242
+ * ---
243
+ * create instances of manageable pages and scaffolds
244
+ * @param name
245
+ * @param template
246
+ * @param transitions
247
+ */
248
+ declare class Screen {
284
249
  /**
285
250
  * this should be a cradova screen component
286
251
  */
287
- _html:
288
- | ((this: Screen, data?: unknown) => HTMLElement | DocumentFragment)
289
- | HTMLElement
290
- | DocumentFragment;
291
- /**
292
- * this is a set of added html to the screen
293
- */
252
+ _html: ((this: Screen, data?: unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment;
294
253
  /**
295
254
  * error handler for the screen
296
255
  */
@@ -315,73 +274,48 @@ declare module "cradova" {
315
274
  onActivate(cb: () => Promise<void> | void): void;
316
275
  onDeactivate(cb: () => Promise<void> | void): void;
317
276
  _deActivate(): Promise<void>;
318
- drop(state: boolean): boolean | undefined;
277
+ drop(state?: boolean): boolean | undefined;
319
278
  _Activate(force?: boolean): Promise<void>;
320
- }
279
+ }
321
280
 
322
- type DataAttributes = {
281
+ type DataAttributes = {
323
282
  [key: `data-${string}`]: string;
324
- };
325
- type AriaAttributes = {
283
+ };
284
+ type AriaAttributes = {
326
285
  [key: `aria-${string}`]: string;
327
- };
328
- type VJSType<T> = (
329
- ...VJS: (
330
- | undefined
331
- | string
332
- | HTMLElement
333
- | HTMLElement[]
334
- | DocumentFragment
335
- | DocumentFragment[]
336
- | TemplateStringsArray
337
- | Partial<T>
338
- | (() => HTMLElement)
339
- | Partial<DataAttributes>
340
- | Partial<AriaAttributes>
341
- | CSS.Properties
342
- | {
343
- style?: CSS.Properties;
344
- onmount?: (this: T) => void;
345
- reference?: reference;
346
- }
347
- )[]
348
- ) => T;
349
- type VJS_params_TYPE<T> = (
350
- | undefined
351
- | string
352
- | HTMLElement
353
- | HTMLElement[]
354
- | DocumentFragment
355
- | DocumentFragment[]
356
- | TemplateStringsArray
357
- | Partial<T>
358
- | (() => HTMLElement)
359
- | Partial<DataAttributes>
360
- | Partial<AriaAttributes>
361
- | CSS.Properties<string | number>
362
- | {
363
- src?: string;
364
- href?: string;
365
- placeholder?: string;
366
- type?: string;
367
- action?: string;
368
- name?: string;
369
- alt?: string;
370
- for?: string;
371
- method?: string;
372
- rows?: string;
373
- value?: string;
374
- target?: string;
375
- rel?: string;
376
- required?: string;
377
- frameBorder?: string;
378
- style?: CSS.Properties;
379
- onmount?: (this: T) => void;
380
- reference?: reference;
381
- }
382
- )[];
383
- type VJS_Child_TYPE<T> = undefined | string | T | (() => T);
384
- type CradovaScreenType<T = unknown> = {
286
+ };
287
+ type VJSType<T> = (...VJS: (undefined | string | HTMLElement | HTMLElement[] | Ref<unknown> | Ref<unknown>[] | DocumentFragment | DocumentFragment[] | TemplateStringsArray | Partial<T> | (() => HTMLElement) | Partial<DataAttributes> | Partial<AriaAttributes> | CSS.Properties | {
288
+ style?: CSS.Properties;
289
+ onmount?: (this: T) => void;
290
+ reference?: reference;
291
+ })[]) => T;
292
+ type VJS_params_TYPE<T> = (undefined | string | HTMLElement | HTMLElement[] | Ref<unknown> | Ref<unknown>[] | DocumentFragment | DocumentFragment[] | TemplateStringsArray | Partial<T> | (() => HTMLElement) | Partial<DataAttributes> | Partial<AriaAttributes> | CSS.Properties<string | number> | {
293
+ src?: string;
294
+ href?: string;
295
+ placeholder?: string;
296
+ type?: string;
297
+ action?: string;
298
+ name?: string;
299
+ alt?: string;
300
+ for?: string;
301
+ method?: string;
302
+ rows?: string;
303
+ value?: string;
304
+ target?: string;
305
+ rel?: string;
306
+ required?: string;
307
+ frameBorder?: string;
308
+ style?: CSS.Properties;
309
+ onmount?: (this: T) => void;
310
+ reference?: reference;
311
+ })[];
312
+ type VJS_Child_TYPE<T> = undefined | string | T | (() => T);
313
+ type VJS_props_TYPE = {
314
+ style?: CSS.Properties;
315
+ onmount?: () => void;
316
+ reference?: reference;
317
+ };
318
+ type CradovaScreenType<T = unknown> = {
385
319
  /**
386
320
  * Cradova screen
387
321
  * ---
@@ -405,10 +339,7 @@ declare module "cradova" {
405
339
  * @returns void
406
340
  * .
407
341
  */
408
- template:
409
- | ((this: Screen, data?: T | unknown) => HTMLElement | DocumentFragment)
410
- | HTMLElement
411
- | DocumentFragment;
342
+ template: ((this: Screen, data?: T | unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment;
412
343
  /**
413
344
  * Cradova screen
414
345
  * ---
@@ -428,93 +359,16 @@ declare module "cradova" {
428
359
  * .
429
360
  */
430
361
  persist?: boolean;
431
- };
432
-
433
- export const makeElement: <E extends HTMLElement>(
434
- element: E & HTMLElement,
435
- ElementChildrenAndPropertyList: VJS_params_TYPE<E>
436
- ) => E;
437
- export const make: (descriptor: any) => any[];
438
- export const a: VJSType<HTMLAnchorElement>;
439
- export const area: VJSType<HTMLAreaElement>;
440
- export const article: VJSType<HTMLElement>;
441
- export const aside: VJSType<HTMLElement>;
442
- export const audio: VJSType<HTMLAudioElement>;
443
- export const b: VJSType<HTMLElement>;
444
- export const base: VJSType<HTMLBaseElement>;
445
- export const blockquote: VJSType<HTMLElement>;
446
- export const br: VJSType<HTMLBRElement>;
447
- export const button: VJSType<HTMLButtonElement>;
448
- export const canvas: VJSType<HTMLCanvasElement>;
449
- export const caption: VJSType<HTMLTableCaptionElement>;
450
- export const code: VJSType<HTMLElement>;
451
- export const col: VJSType<HTMLTableColElement>;
452
- export const colgroup: VJSType<HTMLOptGroupElement>;
453
- export const data: VJSType<HTMLDataElement>;
454
- export const datalist: VJSType<HTMLDataListElement>;
455
- export const details: VJSType<HTMLDetailsElement>;
456
- export const dialog: VJSType<HTMLDialogElement>;
457
- export const div: VJSType<HTMLDivElement>;
458
- export const em: VJSType<HTMLElement>;
459
- export const embed: VJSType<HTMLEmbedElement>;
460
- export const figure: VJSType<HTMLElement>;
461
- export const footer: VJSType<HTMLElement>;
462
- export const form: VJSType<HTMLFormElement>;
463
- export const h1: VJSType<HTMLHeadingElement>;
464
- export const h2: VJSType<HTMLHeadingElement>;
465
- export const h3: VJSType<HTMLHeadingElement>;
466
- export const h4: VJSType<HTMLHeadingElement>;
467
- export const h5: VJSType<HTMLHeadingElement>;
468
- export const h6: VJSType<HTMLHeadingElement>;
469
- export const head: VJSType<HTMLHeadElement>;
470
- export const header: VJSType<HTMLHeadElement>;
471
- export const hr: VJSType<HTMLHRElement>;
472
- export const i: VJSType<HTMLLIElement>;
473
- export const iframe: VJSType<HTMLIFrameElement>;
474
- export const img: VJSType<HTMLImageElement>;
475
- export const input: VJSType<HTMLInputElement>;
476
- export const label: VJSType<HTMLLabelElement>;
477
- export const legend: VJSType<HTMLLegendElement>;
478
- export const li: VJSType<HTMLLIElement>;
479
- export const link: VJSType<HTMLLinkElement>;
480
- export const main: VJSType<HTMLElement>;
481
- export const menu: VJSType<HTMLMenuElement>;
482
- export const nav: VJSType<HTMLElement>;
483
- export const object: VJSType<HTMLObjectElement>;
484
- export const ol: VJSType<HTMLOListElement>;
485
- export const optgroup: VJSType<HTMLOptGroupElement>;
486
- export const option: VJSType<HTMLOptionElement>;
487
- export const p: VJSType<HTMLParagraphElement>;
488
- export const pre: VJSType<HTMLPreElement>;
489
- export const progress: VJSType<HTMLProgressElement>;
490
- export const q: VJSType<HTMLQuoteElement>;
491
- export const section: VJSType<HTMLElement>;
492
- export const select: VJSType<HTMLSelectElement>;
493
- export const source: VJSType<HTMLSourceElement>;
494
- export const span: VJSType<HTMLSpanElement>;
495
- export const strong: VJSType<HTMLElement>;
496
- export const summary: VJSType<HTMLElement>;
497
- export const table: VJSType<HTMLTableElement>;
498
- export const tbody: VJSType<HTMLTableColElement>;
499
- export const td: VJSType<HTMLTableCellElement>;
500
- export const template: VJSType<HTMLTemplateElement>;
501
- export const textarea: VJSType<HTMLTextAreaElement>;
502
- export const th: VJSType<HTMLTableSectionElement>;
503
- export const title: VJSType<HTMLTitleElement>;
504
- export const tr: VJSType<HTMLTableRowElement>;
505
- export const track: VJSType<HTMLTrackElement>;
506
- export const u: VJSType<HTMLUListElement>;
507
- export const ul: VJSType<HTMLUListElement>;
508
- export const video: VJSType<HTMLVideoElement>;
362
+ };
509
363
 
510
- /** cradova router
511
- * ---
512
- * Registers a route.
513
- *
514
- * @param {string} path Route path.
515
- * @param screen the cradova document tree for the route.
516
- */
517
- export class Router {
364
+ /** cradova router
365
+ * ---
366
+ * Registers a route.
367
+ *
368
+ * @param {string} path Route path.
369
+ * @param screen the cradova document tree for the route.
370
+ */
371
+ declare class Router {
518
372
  /** cradova router
519
373
  * ---
520
374
  * Registers a route.
@@ -526,20 +380,20 @@ declare module "cradova" {
526
380
  */
527
381
  static BrowserRoutes(obj: Record<string, any>): void;
528
382
  /**
529
- Go back in Navigation history
530
- */
383
+ Go back in Navigation history
384
+ */
531
385
  static back(): void;
532
386
  /**
533
- Go forward in Navigation history
534
- */
387
+ Go forward in Navigation history
388
+ */
535
389
  static forward(): void;
536
390
  /**
537
- Pause navigation
538
- */
391
+ Pause navigation
392
+ */
539
393
  static pauseNaviagtion(): void;
540
394
  /**
541
- resume navigation
542
- */
395
+ resume navigation
396
+ */
543
397
  static resumeNaviagtion(): void;
544
398
  /**
545
399
  * Cradova Router
@@ -551,11 +405,7 @@ declare module "cradova" {
551
405
  * @param data object
552
406
  * @param force boolean
553
407
  */
554
- static navigate(
555
- href: string,
556
- data?: Record<string, unknown> | null,
557
- force?: boolean
558
- ): void;
408
+ static navigate(href: string, data?: Record<string, unknown> | null, force?: boolean): void;
559
409
  /**
560
410
  * Cradova Router
561
411
  * ------
@@ -589,10 +439,7 @@ declare module "cradova" {
589
439
  * @param {string} path Route path.
590
440
  * @param data data for the screen.
591
441
  */
592
- static packageScreen(
593
- path: string,
594
- data?: Record<string, unknown>
595
- ): Promise<void>;
442
+ static packageScreen(path: string, data?: Record<string, unknown>): Promise<void>;
596
443
  /**
597
444
  * Cradova Router
598
445
  * ------
@@ -612,66 +459,136 @@ declare module "cradova" {
612
459
  */
613
460
  static addErrorHandler(callback: (err: unknown) => void): void;
614
461
  static _mount(): void;
615
- }
462
+ }
616
463
 
617
- /**
618
- *
619
- * Cradova Ajax
620
- * ------------------
621
- * your new axios alternative
622
- * supports files upload
623
- * @param url string
624
- * @param {{method: string;data;header;callbacks;}} opts
625
- * @returns unknown
626
- */
627
- export function Ajax(
628
- url: string | URL,
629
- opts?: {
630
- method?: "GET" | "POST";
631
- data?: Record<string, unknown>;
632
- header?: {
464
+ declare const makeElement: <E extends HTMLElement>(element: E & HTMLElement, ElementChildrenAndPropertyList: VJS_params_TYPE<E>) => E;
465
+ declare const make: (descriptor: any) => any[];
466
+ declare const a: VJSType<HTMLAnchorElement>;
467
+ declare const area: VJSType<HTMLAreaElement>;
468
+ declare const article: VJSType<HTMLElement>;
469
+ declare const aside: VJSType<HTMLElement>;
470
+ declare const audio: VJSType<HTMLAudioElement>;
471
+ declare const b: VJSType<HTMLElement>;
472
+ declare const base: VJSType<HTMLBaseElement>;
473
+ declare const blockquote: VJSType<HTMLElement>;
474
+ declare const br: VJSType<HTMLBRElement>;
475
+ declare const button: VJSType<HTMLButtonElement>;
476
+ declare const canvas: VJSType<HTMLCanvasElement>;
477
+ declare const caption: VJSType<HTMLTableCaptionElement>;
478
+ declare const code: VJSType<HTMLElement>;
479
+ declare const col: VJSType<HTMLTableColElement>;
480
+ declare const colgroup: VJSType<HTMLOptGroupElement>;
481
+ declare const data: VJSType<HTMLDataElement>;
482
+ declare const datalist: VJSType<HTMLDataListElement>;
483
+ declare const details: VJSType<HTMLDetailsElement>;
484
+ declare const dialog: VJSType<HTMLDialogElement>;
485
+ declare const div: VJSType<HTMLDivElement>;
486
+ declare const em: VJSType<HTMLElement>;
487
+ declare const embed: VJSType<HTMLEmbedElement>;
488
+ declare const figure: VJSType<HTMLElement>;
489
+ declare const footer: VJSType<HTMLElement>;
490
+ declare const form: VJSType<HTMLFormElement>;
491
+ declare const h1: VJSType<HTMLHeadingElement>;
492
+ declare const h2: VJSType<HTMLHeadingElement>;
493
+ declare const h3: VJSType<HTMLHeadingElement>;
494
+ declare const h4: VJSType<HTMLHeadingElement>;
495
+ declare const h5: VJSType<HTMLHeadingElement>;
496
+ declare const h6: VJSType<HTMLHeadingElement>;
497
+ declare const head: VJSType<HTMLHeadElement>;
498
+ declare const header: VJSType<HTMLHeadElement>;
499
+ declare const hr: VJSType<HTMLHRElement>;
500
+ declare const i: VJSType<HTMLLIElement>;
501
+ declare const iframe: VJSType<HTMLIFrameElement>;
502
+ declare const img: VJSType<HTMLImageElement>;
503
+ declare const input: VJSType<HTMLInputElement>;
504
+ declare const label: VJSType<HTMLLabelElement>;
505
+ declare const legend: VJSType<HTMLLegendElement>;
506
+ declare const li: VJSType<HTMLLIElement>;
507
+ declare const link: VJSType<HTMLLinkElement>;
508
+ declare const main: VJSType<HTMLElement>;
509
+ declare const menu: VJSType<HTMLMenuElement>;
510
+ declare const nav: VJSType<HTMLElement>;
511
+ declare const object: VJSType<HTMLObjectElement>;
512
+ declare const ol: VJSType<HTMLOListElement>;
513
+ declare const optgroup: VJSType<HTMLOptGroupElement>;
514
+ declare const option: VJSType<HTMLOptionElement>;
515
+ declare const p: VJSType<HTMLParagraphElement>;
516
+ declare const pre: VJSType<HTMLPreElement>;
517
+ declare const progress: VJSType<HTMLProgressElement>;
518
+ declare const q: VJSType<HTMLQuoteElement>;
519
+ declare const section: VJSType<HTMLElement>;
520
+ declare const select: VJSType<HTMLSelectElement>;
521
+ declare const source: VJSType<HTMLSourceElement>;
522
+ declare const span: VJSType<HTMLSpanElement>;
523
+ declare const strong: VJSType<HTMLElement>;
524
+ declare const summary: VJSType<HTMLElement>;
525
+ declare const table: VJSType<HTMLTableElement>;
526
+ declare const tbody: VJSType<HTMLTableColElement>;
527
+ declare const td: VJSType<HTMLTableCellElement>;
528
+ declare const template: VJSType<HTMLTemplateElement>;
529
+ declare const textarea: VJSType<HTMLTextAreaElement>;
530
+ declare const th: VJSType<HTMLTableSectionElement>;
531
+ declare const title: VJSType<HTMLTitleElement>;
532
+ declare const tr: VJSType<HTMLTableRowElement>;
533
+ declare const track: VJSType<HTMLTrackElement>;
534
+ declare const u: VJSType<HTMLUListElement>;
535
+ declare const ul: VJSType<HTMLUListElement>;
536
+ declare const video: VJSType<HTMLVideoElement>;
537
+ declare const svg: (svg: string, properties?: VJS_props_TYPE) => HTMLSpanElement;
538
+
539
+ /**
540
+ *
541
+ * Cradova Ajax
542
+ * ------------------
543
+ * your new axios alternative
544
+ * supports files upload
545
+ * @param url string
546
+ * @param {{method: string;data;header;callbacks;}} opts
547
+ * @returns unknown
548
+ */
549
+ declare function Ajax(url: string | URL, opts?: {
550
+ method?: "GET" | "POST";
551
+ data?: Record<string, unknown>;
552
+ header?: {
633
553
  "content-type"?: string;
634
- } & Record<string, string>;
635
- callbacks?: Record<string, (arg: Function) => void>;
636
- }
637
- ): Promise<string>;
554
+ } & Record<string, string>;
555
+ callbacks?: Record<string, (arg: Function) => void>;
556
+ }): Promise<string>;
638
557
 
639
- type TemplateType = <E extends HTMLElement>(
640
- ...element_initials: VJS_params_TYPE<E | HTMLElement>
641
- ) => E | HTMLElement | DocumentFragment;
642
- /**
643
- * Cradova
644
- * ---
645
- * Creates new cradova HTML element
646
- * @example
647
- * // using template
648
- * const p = _("p");
649
- * _("p.class");
650
- * _("p#id");
651
- * _("p.class#id");
652
- * _("p.foo.bar#poo.loo");
653
- *
654
- * // using inline props
655
- *
656
- * _("p",{
657
- * text: "am a p tag",
658
- * style: {
659
- * color: "blue"
660
- * }
661
- * })
662
- *
663
- * // props and children
664
- * _("p", // template first
665
- * // property next if wanted
666
- * {style: {color: "brown"}, // optional
667
- * // the rest should be children or text
668
- * _("span", " am a span tag text like so"),
669
- * ...
670
- * )
671
- *
672
- * @param element_initials
673
- * @returns function - cradova element
674
- */
675
- const _: TemplateType;
676
- export default _;
677
- }
558
+ type TemplateType = <E extends HTMLElement>(...element_initials: VJS_params_TYPE<E | HTMLElement>) => E | HTMLElement | DocumentFragment;
559
+ /**
560
+ * Cradova
561
+ * ---
562
+ * Creates new cradova HTML element
563
+ * @example
564
+ * // using template
565
+ * const p = _("p");
566
+ * _("p.class");
567
+ * _("p#id");
568
+ * _("p.class#id");
569
+ * _("p.foo.bar#poo.loo");
570
+ *
571
+ * // using inline props
572
+ *
573
+ * _("p",{
574
+ * text: "am a p tag",
575
+ * style: {
576
+ * color: "blue"
577
+ * }
578
+ * })
579
+ *
580
+ * // props and children
581
+ * _("p", // template first
582
+ * // property next if wanted
583
+ * {style: {color: "brown"}, // optional
584
+ * // the rest should be children or text
585
+ * _("span", " am a span tag text like so"),
586
+ * ...
587
+ * )
588
+ *
589
+ * @param element_initials
590
+ * @returns function - cradova element
591
+ */
592
+ declare const _: TemplateType;
593
+
594
+ export { Ajax, CradovaEvent, Ref, Rhoda, Router, Screen, a, area, article, aside, assert, assertOr, audio, b, base, blockquote, br, button, canvas, caption, code, col, colgroup, createSignal, css, data, datalist, _ as default, details, dialog, div, em, embed, figure, footer, form, frag, h1, h2, h3, h4, h5, h6, head, header, hr, i, iframe, img, input, isNode, label, lazy, legend, li, link, loop, main, make, makeElement, menu, nav, object, ol, optgroup, option, p, pre, progress, q, reference, section, select, source, span, strong, summary, svg, table, tbody, td, template, textarea, th, title, tr, track, u, ul, useEffect, useRef, useState, video };
package/dist/index.js CHANGED
@@ -125,13 +125,9 @@ var Ref = class {
125
125
  this._state_track = {};
126
126
  this._state_index = 0;
127
127
  this.component = component.bind(this);
128
- const Recusr = () => {
129
- CradovaEvent.addEventListener("onTransition", () => {
130
- this.current_id = SNRU(location.href);
131
- Recusr();
132
- });
133
- };
134
- Recusr();
128
+ CradovaEvent.addEventListener("onTransition", () => {
129
+ this.current_id = SNRU(location.href);
130
+ });
135
131
  }
136
132
  preRender(data2, stash) {
137
133
  this.reference._appendDomForce(
@@ -163,6 +159,7 @@ var Ref = class {
163
159
  this.stash = data2;
164
160
  }
165
161
  if (isNode(html)) {
162
+ this.current_id = SNRU(location.href);
166
163
  this.reference._appendDomForce(
167
164
  this.current_id,
168
165
  html
@@ -176,7 +173,8 @@ var Ref = class {
176
173
  return html;
177
174
  }
178
175
  instance() {
179
- return this.reference.html;
176
+ this.current_id = SNRU(location.href);
177
+ return this.reference[this.current_id];
180
178
  }
181
179
  _setExtra(Extra) {
182
180
  this.Signal = Extra;
@@ -212,10 +210,10 @@ var Ref = class {
212
210
  * @returns
213
211
  */
214
212
  updateState(data2, stash) {
215
- this.current_id = SNRU(location.href);
216
213
  if (!this.rendered) {
217
214
  this.effectuate = () => {
218
215
  if (this.published) {
216
+ this.current_id = SNRU(location.href);
219
217
  this.Activate(data2);
220
218
  }
221
219
  };
@@ -239,8 +237,11 @@ var Ref = class {
239
237
  html = html();
240
238
  }
241
239
  if (isNode(html)) {
242
- this.reference.html.insertAdjacentElement("beforebegin", html);
243
- this.reference.html.remove();
240
+ this.reference[this.current_id].insertAdjacentElement(
241
+ "beforebegin",
242
+ html
243
+ );
244
+ this.reference[this.current_id].remove();
244
245
  this.published = true;
245
246
  this.reference._appendDomForce(
246
247
  this.current_id,
@@ -636,10 +637,6 @@ var createSignal = class {
636
637
  var localTree = new reference();
637
638
  var Screen = class {
638
639
  constructor(cradova_screen_initials) {
639
- /**
640
- * this is a set of added html to the screen
641
- */
642
- // private _secondaryChildren: VJSType<HTMLElement>[] = [];
643
640
  /**
644
641
  * error handler for the screen
645
642
  */
@@ -704,13 +701,13 @@ var Screen = class {
704
701
  onDeactivate(cb) {
705
702
  this._deCallBack = cb;
706
703
  }
707
- // addChildren(...addOns: VJSType<HTMLElement>[]) {
708
- // this._secondaryChildren.push(...addOns);
709
- // }
710
704
  async _deActivate() {
711
705
  if (this._deCallBack) {
712
706
  await this._deCallBack();
713
707
  }
708
+ if (this._transition) {
709
+ this._template.classList.remove(this._transition);
710
+ }
714
711
  }
715
712
  drop(state) {
716
713
  if (typeof state === "boolean") {
@@ -761,7 +758,6 @@ RouterBox["routes"] = {};
761
758
  RouterBox["pageevents"] = [];
762
759
  RouterBox["paused"] = false;
763
760
  RouterBox["start_pageevents"] = async function(url) {
764
- CradovaEvent.dispatchEvent("onTransition");
765
761
  setTimeout(() => {
766
762
  for (let ci = 0; ci < RouterBox["pageevents"].length; ci++) {
767
763
  RouterBox["pageevents"][ci](url);
@@ -858,6 +854,7 @@ RouterBox.router = async function(_e, _force) {
858
854
  template: route._html
859
855
  });
860
856
  RouterBox.routes[url] = route;
857
+ CradovaEvent.dispatchEvent("onTransition");
861
858
  }
862
859
  if (params) {
863
860
  RouterBox.params.params = params;
@@ -1334,9 +1331,9 @@ var track = cra("track");
1334
1331
  var u = cra("u");
1335
1332
  var ul = cra("ul");
1336
1333
  var video = cra("video");
1337
- var ___svg = (svg, properties) => {
1334
+ var svg = (svg2, properties) => {
1338
1335
  const span2 = document.createElement("span");
1339
- span2.innerHTML = svg;
1336
+ span2.innerHTML = svg2;
1340
1337
  return makeElement(span2, [properties]);
1341
1338
  };
1342
1339
 
@@ -1421,8 +1418,7 @@ var _2 = (...element_initials) => {
1421
1418
  }
1422
1419
  return makeElement(element, element_initials);
1423
1420
  };
1424
- _2.__proto__.svg = ___svg;
1425
1421
  var lib_default = _2;
1426
1422
  //! get url hash here and scroll into view
1427
1423
 
1428
- export { Ajax, CradovaEvent, Ref, Rhoda, Router, Screen, ___svg, a, area, article, aside, assert, assertOr, audio, b, base, blockquote, br, button, canvas, caption, code, col, colgroup, createSignal, css, data, datalist, lib_default as default, details, dialog, div, em, embed, figure, footer, form, frag, h1, h2, h3, h4, h5, h6, head, header, hr, i, iframe, img, input, isNode, label, lazy, legend, li, link, loop, main, make, makeElement, menu, nav, object, ol, optgroup, option, p, pre, progress, q, reference, section, select, source, span, strong, summary, table, tbody, td, template, textarea, th, title, tr, track, u, ul, useEffect, useRef, useState, video };
1424
+ export { Ajax, CradovaEvent, Ref, Rhoda, Router, Screen, a, area, article, aside, assert, assertOr, audio, b, base, blockquote, br, button, canvas, caption, code, col, colgroup, createSignal, css, data, datalist, lib_default as default, details, dialog, div, em, embed, figure, footer, form, frag, h1, h2, h3, h4, h5, h6, head, header, hr, i, iframe, img, input, isNode, label, lazy, legend, li, link, loop, main, make, makeElement, menu, nav, object, ol, optgroup, option, p, pre, progress, q, reference, section, select, source, span, strong, summary, svg, table, tbody, td, template, textarea, th, title, tr, track, u, ul, useEffect, useRef, useState, video };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.1.6",
3
+ "version": "3.2.0",
4
4
  "description": "Web framework for building web apps and PWAs",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -13,10 +13,8 @@
13
13
  "url": "git+https://github.com/FridayCandour/cradova.git"
14
14
  },
15
15
  "scripts": {
16
- "build": "tsup lib/index.ts && npm run cp:typedef",
17
- "build:ts": "tsup lib/index.ts",
18
- "cp:typedef": "cp cradova.d.ts dist/index.d.ts",
19
- "cp:types": "cp lib/types.ts dist/types.ts",
16
+ "build": "tsup lib/index.ts",
17
+ "pub": "tsup lib/index.ts && npm publish",
20
18
  "lint": "eslint . --fix"
21
19
  },
22
20
  "keywords": [