native-document 1.0.92 → 1.0.94

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 (85) hide show
  1. package/dist/native-document.components.min.js +1088 -65
  2. package/dist/native-document.dev.js +695 -142
  3. package/dist/native-document.dev.js.map +1 -1
  4. package/dist/native-document.devtools.min.js +1 -1
  5. package/dist/native-document.min.js +1 -1
  6. package/docs/advanced-components.md +814 -0
  7. package/docs/anchor.md +71 -11
  8. package/docs/cache.md +888 -0
  9. package/docs/conditional-rendering.md +91 -1
  10. package/docs/core-concepts.md +9 -2
  11. package/docs/elements.md +127 -2
  12. package/docs/extending-native-document-element.md +7 -1
  13. package/docs/filters.md +1216 -0
  14. package/docs/getting-started.md +12 -3
  15. package/docs/lifecycle-events.md +10 -2
  16. package/docs/list-rendering.md +453 -54
  17. package/docs/memory-management.md +9 -7
  18. package/docs/native-document-element.md +30 -9
  19. package/docs/native-fetch.md +744 -0
  20. package/docs/observables.md +135 -6
  21. package/docs/routing.md +7 -1
  22. package/docs/state-management.md +7 -1
  23. package/docs/validation.md +8 -1
  24. package/elements.js +1 -0
  25. package/eslint.config.js +3 -3
  26. package/index.def.js +350 -0
  27. package/package.json +3 -2
  28. package/readme.md +53 -14
  29. package/src/components/$traits/HasItems.js +42 -1
  30. package/src/components/BaseComponent.js +4 -1
  31. package/src/components/accordion/Accordion.js +112 -8
  32. package/src/components/accordion/AccordionItem.js +93 -4
  33. package/src/components/alert/Alert.js +164 -4
  34. package/src/components/avatar/Avatar.js +236 -22
  35. package/src/components/menu/index.js +1 -2
  36. package/src/core/data/ObservableArray.js +120 -2
  37. package/src/core/data/ObservableChecker.js +50 -0
  38. package/src/core/data/ObservableItem.js +124 -4
  39. package/src/core/data/ObservableWhen.js +36 -6
  40. package/src/core/data/observable-helpers/array.js +12 -3
  41. package/src/core/data/observable-helpers/computed.js +17 -4
  42. package/src/core/data/observable-helpers/object.js +19 -3
  43. package/src/core/elements/content-formatter.js +138 -1
  44. package/src/core/elements/control/for-each-array.js +20 -2
  45. package/src/core/elements/control/for-each.js +17 -5
  46. package/src/core/elements/control/show-if.js +31 -15
  47. package/src/core/elements/control/show-when.js +23 -0
  48. package/src/core/elements/control/switch.js +40 -10
  49. package/src/core/elements/description-list.js +14 -0
  50. package/src/core/elements/form.js +188 -4
  51. package/src/core/elements/html5-semantics.js +44 -1
  52. package/src/core/elements/img.js +22 -10
  53. package/src/core/elements/index.js +5 -0
  54. package/src/core/elements/interactive.js +19 -1
  55. package/src/core/elements/list.js +28 -1
  56. package/src/core/elements/medias.js +29 -0
  57. package/src/core/elements/meta-data.js +34 -0
  58. package/src/core/elements/table.js +59 -0
  59. package/src/core/utils/cache.js +5 -0
  60. package/src/core/utils/helpers.js +7 -2
  61. package/src/core/utils/memoize.js +25 -16
  62. package/src/core/utils/prototypes.js +3 -2
  63. package/src/core/wrappers/AttributesWrapper.js +1 -1
  64. package/src/core/wrappers/HtmlElementWrapper.js +2 -2
  65. package/src/core/wrappers/NDElement.js +42 -2
  66. package/src/core/wrappers/NdPrototype.js +4 -0
  67. package/src/core/wrappers/TemplateCloner.js +14 -11
  68. package/src/core/wrappers/prototypes/bind-class-extensions.js +1 -1
  69. package/src/core/wrappers/prototypes/nd-element-extensions.js +3 -0
  70. package/src/router/Route.js +9 -4
  71. package/src/router/Router.js +28 -9
  72. package/src/router/errors/RouterError.js +0 -1
  73. package/types/control-flow.d.ts +9 -6
  74. package/types/elements.d.ts +496 -111
  75. package/types/filters/index.d.ts +4 -0
  76. package/types/forms.d.ts +85 -48
  77. package/types/images.d.ts +16 -9
  78. package/types/nd-element.d.ts +5 -238
  79. package/types/observable.d.ts +9 -3
  80. package/types/router.d.ts +5 -1
  81. package/types/template-cloner.ts +1 -0
  82. package/types/validator.ts +11 -1
  83. package/utils.d.ts +2 -1
  84. package/utils.js +4 -4
  85. package/src/core/utils/service.js +0 -6
package/types/forms.d.ts CHANGED
@@ -1,51 +1,88 @@
1
1
  // Form elements type definitions
2
- import { Attributes, ValidChild } from './elements';
3
- import { NDElement} from "./nd-element";
4
- import {ElementFunction} from "./elements";
5
-
6
- // Form Elements
7
- export declare const Form: ElementFunction & {
8
- submit(action: string | ((event: Event) => void)): HTMLFormElement & { nd: NDElement };
9
- multipartFormData(): HTMLFormElement & { nd: NDElement };
10
- post(action: string): HTMLFormElement & { nd: NDElement };
11
- get(action: string): HTMLFormElement & { nd: NDElement };
2
+ import {
3
+ ValidChild,
4
+ ElementFunction,
5
+ ElementFunctionNoChildren,
6
+ NdHTMLElement,
7
+ GlobalAttributes,
8
+ Observable
9
+ } from './elements';
10
+ import {
11
+ FormAttributes,
12
+ InputAttributes,
13
+ TextAreaAttributes,
14
+ SelectAttributes,
15
+ OptionAttributes,
16
+ ButtonAttributes,
17
+ OutputAttributes,
18
+ ProgressAttributes,
19
+ MeterAttributes,
20
+ LabelAttributes,
21
+ } from './elements';
22
+
23
+ // ─────────────────────────────────────────────
24
+ // Form
25
+ // ─────────────────────────────────────────────
26
+
27
+ export declare const Form: (
28
+ attributes?: FormAttributes,
29
+ children?: ValidChild
30
+ ) => NdHTMLElement<HTMLFormElement> & {
31
+ submit: (actionOrFn: string | ((e: SubmitEvent) => void)) => NdHTMLElement<HTMLFormElement>;
32
+ post: (action: string) => NdHTMLElement<HTMLFormElement>;
33
+ get: (action: string) => NdHTMLElement<HTMLFormElement>;
34
+ multipartFormData: () => NdHTMLElement<HTMLFormElement>;
12
35
  };
13
36
 
14
- export declare const Input: ElementFunction;
15
- export declare const TextArea: ElementFunction;
16
- export declare const Select: ElementFunction;
17
- export declare const Option: ElementFunction;
18
- export declare const Button: ElementFunction;
19
-
20
- // Specialized Input Types
21
- export declare const HiddenInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
22
- export declare const FileInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
23
- export declare const PasswordInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
24
- export declare const Checkbox: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
25
- export declare const Radio: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
26
- export declare const NumberInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
27
- export declare const EmailInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
28
- export declare const DateInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
29
- export declare const TimeInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
30
- export declare const RangeInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
31
- export declare const ColorInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
32
-
33
- export declare const ReadonlyInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
34
- export declare const DateTimeInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
35
- export declare const WeekInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
36
- export declare const MonthInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
37
- export declare const SearchInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
38
- export declare const TelInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
39
- export declare const UrlInput: (attributes?: Attributes) => HTMLInputElement & { nd: NDElement };
40
-
41
- export declare const TextInput: ElementFunction;
42
- export declare const FieldSet: ElementFunction;
43
- export declare const Legend: ElementFunction;
44
- export declare const Datalist: ElementFunction;
45
- export declare const Output: ElementFunction;
46
- export declare const Progress: ElementFunction;
47
- export declare const Meter: ElementFunction;
48
-
49
- // Specialized Button Types
50
- export declare const SimpleButton: (child: ValidChild, attributes?: Attributes) => HTMLButtonElement & { nd: NDElement };
51
- export declare const SubmitButton: (child: ValidChild, attributes?: Attributes) => HTMLButtonElement & { nd: NDElement };
37
+ // ─────────────────────────────────────────────
38
+ // Input
39
+ // ─────────────────────────────────────────────
40
+
41
+ export declare const Input: ElementFunctionNoChildren<InputAttributes, HTMLInputElement>;
42
+ export declare const ReadonlyInput: (attributes?: Omit<InputAttributes, 'type' | 'readonly' | 'readOnly'>) => NdHTMLElement<HTMLInputElement>;
43
+ export declare const HiddenInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
44
+ export declare const FileInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
45
+ export declare const PasswordInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
46
+ export declare const Checkbox: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
47
+ export declare const Radio: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
48
+ export declare const RangeInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
49
+ export declare const ColorInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
50
+ export declare const DateInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
51
+ export declare const TimeInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
52
+ export declare const DateTimeInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
53
+ export declare const WeekInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
54
+ export declare const MonthInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
55
+ export declare const SearchInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
56
+ export declare const TelInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
57
+ export declare const UrlInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
58
+ export declare const EmailInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
59
+ export declare const NumberInput: (attributes?: Omit<InputAttributes, 'type'>) => NdHTMLElement<HTMLInputElement>;
60
+
61
+ // ─────────────────────────────────────────────
62
+ // Textarea & Select
63
+ // ─────────────────────────────────────────────
64
+
65
+ export declare const TextArea: ElementFunction<TextAreaAttributes, HTMLTextAreaElement>;
66
+ export declare const TextInput: typeof TextArea;
67
+ export declare const Select: ElementFunction<SelectAttributes, HTMLSelectElement>;
68
+ export declare const Option: ElementFunction<OptionAttributes, HTMLOptionElement>;
69
+
70
+ // ─────────────────────────────────────────────
71
+ // Button
72
+ // ─────────────────────────────────────────────
73
+
74
+ export declare const Button: ElementFunction<ButtonAttributes, HTMLButtonElement>;
75
+ export declare const SimpleButton: (children?: ValidChild, attributes?: Omit<ButtonAttributes, 'type'>) => NdHTMLElement<HTMLButtonElement>;
76
+ export declare const SubmitButton: (children?: ValidChild, attributes?: Omit<ButtonAttributes, 'type'>) => NdHTMLElement<HTMLButtonElement>;
77
+
78
+ // ─────────────────────────────────────────────
79
+ // Other form elements
80
+ // ─────────────────────────────────────────────
81
+
82
+ export declare const FieldSet: ElementFunction<GlobalAttributes & { disabled?: Observable<boolean> }, HTMLFieldSetElement>;
83
+ export declare const Legend: ElementFunction<GlobalAttributes, HTMLLegendElement>;
84
+ export declare const Label: ElementFunction<LabelAttributes, HTMLLabelElement>;
85
+ export declare const Datalist: ElementFunction<GlobalAttributes, HTMLDataListElement>;
86
+ export declare const Output: ElementFunction<OutputAttributes, HTMLOutputElement>;
87
+ export declare const Progress: ElementFunction<ProgressAttributes, HTMLProgressElement>;
88
+ export declare const Meter: ElementFunction<MeterAttributes, HTMLMeterElement>;
package/types/images.d.ts CHANGED
@@ -1,16 +1,23 @@
1
1
  // Image components type definitions
2
- import {Attributes, ElementFunction, NDElement} from './elements';
3
- import {ObservableItem} from "./observable";
2
+ import { ElementFunctionNoChildren, NdHTMLElement } from './elements';
3
+ import { ImgAttributes } from './elements';
4
+ import { ObservableItem } from "./observable";
4
5
 
6
+ export declare const BaseImage: ElementFunctionNoChildren<ImgAttributes, HTMLImageElement>;
5
7
 
6
- export declare const BaseImage: ElementFunction;
8
+ export declare const Img: (
9
+ src: string | ObservableItem<string>,
10
+ attributes?: Omit<ImgAttributes, 'src'>
11
+ ) => NdHTMLElement<HTMLImageElement>;
7
12
 
8
- // Image Elements
9
- export declare const Img: (src: string | ObservableItem<string>, attributes?: Attributes) => HTMLImageElement & { nd: NDElement };
10
13
  export declare const AsyncImg: (
11
14
  src: string | ObservableItem<string>,
12
- defaultImage?: string,
13
- attributes?: Attributes,
15
+ defaultImage?: string | null,
16
+ attributes?: Omit<ImgAttributes, 'src'>,
14
17
  callback?: (error: Error | null, img?: HTMLImageElement) => void
15
- ) => HTMLImageElement & { nd: NDElement };
16
- export declare const LazyImg: (src: string | ObservableItem<string>, attributes?: Attributes) => HTMLImageElement & { nd: NDElement };
18
+ ) => NdHTMLElement<HTMLImageElement>;
19
+
20
+ export declare const LazyImg: (
21
+ src: string | ObservableItem<string>,
22
+ attributes?: Omit<ImgAttributes, 'src' | 'loading'>
23
+ ) => NdHTMLElement<HTMLImageElement>;
@@ -38,7 +38,9 @@ export interface NDElement {
38
38
  shadow(mode: ShadowMode, style?: string | null): this;
39
39
  openShadow(style?: string | null): this;
40
40
  closedShadow(style?: string | null): this;
41
- attach(bindingHydrator: BindingHydrator): HTMLElement;
41
+ attach(methodName: string, bindingHydrator: BindingHydrator): HTMLElement;
42
+
43
+ on(name: string, callback: EventListener, options?: boolean | AddEventListenerOptions): this;
42
44
 
43
45
  // Mouse Events
44
46
  onClick(callback: (event: MouseEvent) => void): this;
@@ -341,8 +343,6 @@ export interface NDElement {
341
343
  onPreventStopClick(callback?: (event: MouseEvent) => void): this;
342
344
  onPreventStopDblClick(callback?: (event: MouseEvent) => void): this;
343
345
  onPreventStopMouseDown(callback?: (event: MouseEvent) => void): this;
344
- onPreventStopMouseEnter(callback?: (event: MouseEvent) => void): this;
345
- onPreventStopMouseLeave(callback?: (event: MouseEvent) => void): this;
346
346
  onPreventStopMouseMove(callback?: (event: MouseEvent) => void): this;
347
347
  onPreventStopMouseOut(callback?: (event: MouseEvent) => void): this;
348
348
  onPreventStopMouseOver(callback?: (event: MouseEvent) => void): this;
@@ -356,17 +356,15 @@ export interface NDElement {
356
356
  onPreventStopKeyUp(callback?: (event: KeyboardEvent) => void): this;
357
357
 
358
358
  // Prevent + Stop versions for Form Events
359
- onPreventStopBlur(callback?: (event: FocusEvent) => void): this;
360
359
  onPreventStopChange(callback?: (event: Event) => void): this;
361
- onPreventStopFocus(callback?: (event: FocusEvent) => void): this;
362
- onPreventStopFocusIn(callback?: (event: FocusEvent) => void): this;
363
- onPreventStopFocusOut(callback?: (event: FocusEvent) => void): this;
364
360
  onPreventStopInput(callback?: (event: Event) => void): this;
365
361
  onPreventStopInvalid(callback?: (event: Event) => void): this;
366
362
  onPreventStopReset(callback?: (event: Event) => void): this;
367
363
  onPreventStopSearch(callback?: (event: Event) => void): this;
368
364
  onPreventStopSelect(callback?: (event: Event) => void): this;
369
365
  onPreventStopSubmit(callback?: (event: Event) => void): this;
366
+ onPreventStopFocusIn(callback?: (event: FocusEvent) => void): this;
367
+ onPreventStopFocusOut(callback?: (event: FocusEvent) => void): this;
370
368
 
371
369
  // Prevent + Stop versions for Drag Events
372
370
  onPreventStopDrag(callback?: (event: DragEvent) => void): this;
@@ -378,42 +376,8 @@ export interface NDElement {
378
376
  onPreventStopDrop(callback?: (event: DragEvent) => void): this;
379
377
 
380
378
  // Prevent + Stop versions for Window/Page Events
381
- onPreventStopAfterPrint(callback?: (event: Event) => void): this;
382
- onPreventStopBeforePrint(callback?: (event: Event) => void): this;
383
379
  onPreventStopBeforeUnload(callback?: (event: BeforeUnloadEvent) => void): this;
384
- onPreventStopError(callback?: (event: Event) => void): this;
385
380
  onPreventStopHashChange(callback?: (event: HashChangeEvent) => void): this;
386
- onPreventStopLoad(callback?: (event: Event) => void): this;
387
- onPreventStopOffline(callback?: (event: Event) => void): this;
388
- onPreventStopOnline(callback?: (event: Event) => void): this;
389
- onPreventStopPageHide(callback?: (event: PageTransitionEvent) => void): this;
390
- onPreventStopPageShow(callback?: (event: PageTransitionEvent) => void): this;
391
- onPreventStopResize(callback?: (event: UIEvent) => void): this;
392
- onPreventStopScroll(callback?: (event: Event) => void): this;
393
- onPreventStopUnload(callback?: (event: Event) => void): this;
394
-
395
- // Prevent + Stop versions for Media Events
396
- onPreventStopAbort(callback?: (event: Event) => void): this;
397
- onPreventStopCanPlay(callback?: (event: Event) => void): this;
398
- onPreventStopCanPlayThrough(callback?: (event: Event) => void): this;
399
- onPreventStopDurationChange(callback?: (event: Event) => void): this;
400
- onPreventStopEmptied(callback?: (event: Event) => void): this;
401
- onPreventStopEnded(callback?: (event: Event) => void): this;
402
- onPreventStopLoadedData(callback?: (event: Event) => void): this;
403
- onPreventStopLoadedMetadata(callback?: (event: Event) => void): this;
404
- onPreventStopLoadStart(callback?: (event: Event) => void): this;
405
- onPreventStopPause(callback?: (event: Event) => void): this;
406
- onPreventStopPlay(callback?: (event: Event) => void): this;
407
- onPreventStopPlaying(callback?: (event: Event) => void): this;
408
- onPreventStopProgress(callback?: (event: ProgressEvent) => void): this;
409
- onPreventStopRateChange(callback?: (event: Event) => void): this;
410
- onPreventStopSeeked(callback?: (event: Event) => void): this;
411
- onPreventStopSeeking(callback?: (event: Event) => void): this;
412
- onPreventStopStalled(callback?: (event: Event) => void): this;
413
- onPreventStopSuspend(callback?: (event: Event) => void): this;
414
- onPreventStopTimeUpdate(callback?: (event: Event) => void): this;
415
- onPreventStopVolumeChange(callback?: (event: Event) => void): this;
416
- onPreventStopWaiting(callback?: (event: Event) => void): this;
417
381
 
418
382
  // Prevent + Stop versions for Touch Events
419
383
  onPreventStopTouchCancel(callback?: (event: TouchEvent) => void): this;
@@ -434,201 +398,4 @@ export interface NDElement {
434
398
  onPreventStopCut(callback?: (event: ClipboardEvent) => void): this;
435
399
  onPreventStopPaste(callback?: (event: ClipboardEvent) => void): this;
436
400
 
437
- // DELEGATION METHODS - WHEN (for children)
438
-
439
- // When versions for Mouse Events
440
- whenClick(callback: (event: MouseEvent) => void): this;
441
- whenDblClick(callback: (event: MouseEvent) => void): this;
442
- whenMouseDown(callback: (event: MouseEvent) => void): this;
443
- whenMouseEnter(callback: (event: MouseEvent) => void): this;
444
- whenMouseLeave(callback: (event: MouseEvent) => void): this;
445
- whenMouseMove(callback: (event: MouseEvent) => void): this;
446
- whenMouseOut(callback: (event: MouseEvent) => void): this;
447
- whenMouseOver(callback: (event: MouseEvent) => void): this;
448
- whenMouseUp(callback: (event: MouseEvent) => void): this;
449
- whenWheel(callback: (event: WheelEvent) => void): this;
450
- whenContextMenu(callback: (event: MouseEvent) => void): this;
451
-
452
- // When versions for Keyboard Events
453
- whenKeyDown(callback: (event: KeyboardEvent) => void): this;
454
- whenKeyPress(callback: (event: KeyboardEvent) => void): this;
455
- whenKeyUp(callback: (event: KeyboardEvent) => void): this;
456
-
457
- // When versions for Form Events
458
- whenBlur(callback: (event: FocusEvent) => void): this;
459
- whenChange(callback: (event: Event) => void): this;
460
- whenFocus(callback: (event: FocusEvent) => void): this;
461
- whenFocusIn(callback: (event: FocusEvent) => void): this;
462
- whenFocusOut(callback: (event: FocusEvent) => void): this;
463
- whenInput(callback: (event: Event) => void): this;
464
- whenInvalid(callback: (event: Event) => void): this;
465
- whenReset(callback: (event: Event) => void): this;
466
- whenSearch(callback: (event: Event) => void): this;
467
- whenSelect(callback: (event: Event) => void): this;
468
- whenSubmit(callback: (event: Event) => void): this;
469
-
470
- // When versions for Drag Events
471
- whenDrag(callback: (event: DragEvent) => void): this;
472
- whenDragEnd(callback: (event: DragEvent) => void): this;
473
- whenDragEnter(callback: (event: DragEvent) => void): this;
474
- whenDragLeave(callback: (event: DragEvent) => void): this;
475
- whenDragOver(callback: (event: DragEvent) => void): this;
476
- whenDragStart(callback: (event: DragEvent) => void): this;
477
- whenDrop(callback: (event: DragEvent) => void): this;
478
-
479
- // When versions for Window/Page Events
480
- whenAfterPrint(callback: (event: Event) => void): this;
481
- whenBeforePrint(callback: (event: Event) => void): this;
482
- whenBeforeUnload(callback: (event: BeforeUnloadEvent) => void): this;
483
- whenError(callback: (event: Event) => void): this;
484
- whenHashChange(callback: (event: HashChangeEvent) => void): this;
485
- whenLoad(callback: (event: Event) => void): this;
486
- whenOffline(callback: (event: Event) => void): this;
487
- whenOnline(callback: (event: Event) => void): this;
488
- whenPageHide(callback: (event: PageTransitionEvent) => void): this;
489
- whenPageShow(callback: (event: PageTransitionEvent) => void): this;
490
- whenResize(callback: (event: UIEvent) => void): this;
491
- whenScroll(callback: (event: Event) => void): this;
492
- whenUnload(callback: (event: Event) => void): this;
493
-
494
- // When versions for Media Events
495
- whenAbort(callback: (event: Event) => void): this;
496
- whenCanPlay(callback: (event: Event) => void): this;
497
- whenCanPlayThrough(callback: (event: Event) => void): this;
498
- whenDurationChange(callback: (event: Event) => void): this;
499
- whenEmptied(callback: (event: Event) => void): this;
500
- whenEnded(callback: (event: Event) => void): this;
501
- whenLoadedData(callback: (event: Event) => void): this;
502
- whenLoadedMetadata(callback: (event: Event) => void): this;
503
- whenLoadStart(callback: (event: Event) => void): this;
504
- whenPause(callback: (event: Event) => void): this;
505
- whenPlay(callback: (event: Event) => void): this;
506
- whenPlaying(callback: (event: Event) => void): this;
507
- whenProgress(callback: (event: ProgressEvent) => void): this;
508
- whenRateChange(callback: (event: Event) => void): this;
509
- whenSeeked(callback: (event: Event) => void): this;
510
- whenSeeking(callback: (event: Event) => void): this;
511
- whenStalled(callback: (event: Event) => void): this;
512
- whenSuspend(callback: (event: Event) => void): this;
513
- whenTimeUpdate(callback: (event: Event) => void): this;
514
- whenVolumeChange(callback: (event: Event) => void): this;
515
- whenWaiting(callback: (event: Event) => void): this;
516
-
517
- // When versions for Touch Events
518
- whenTouchCancel(callback: (event: TouchEvent) => void): this;
519
- whenTouchEnd(callback: (event: TouchEvent) => void): this;
520
- whenTouchMove(callback: (event: TouchEvent) => void): this;
521
- whenTouchStart(callback: (event: TouchEvent) => void): this;
522
-
523
- // When versions for Animation Events
524
- whenAnimationEnd(callback: (event: AnimationEvent) => void): this;
525
- whenAnimationIteration(callback: (event: AnimationEvent) => void): this;
526
- whenAnimationStart(callback: (event: AnimationEvent) => void): this;
527
-
528
- // When versions for Transition Events
529
- whenTransitionEnd(callback: (event: TransitionEvent) => void): this;
530
-
531
- // When versions for Clipboard Events
532
- whenCopy(callback: (event: ClipboardEvent) => void): this;
533
- whenCut(callback: (event: ClipboardEvent) => void): this;
534
- whenPaste(callback: (event: ClipboardEvent) => void): this;
535
-
536
- // CAPTURE METHODS (for parents)
537
-
538
- // Capture versions for Mouse Events
539
- captureClick(directHandler?: (event: MouseEvent) => void): this;
540
- captureDblClick(directHandler?: (event: MouseEvent) => void): this;
541
- captureMouseDown(directHandler?: (event: MouseEvent) => void): this;
542
- captureMouseEnter(directHandler?: (event: MouseEvent) => void): this;
543
- captureMouseLeave(directHandler?: (event: MouseEvent) => void): this;
544
- captureMouseMove(directHandler?: (event: MouseEvent) => void): this;
545
- captureMouseOut(directHandler?: (event: MouseEvent) => void): this;
546
- captureMouseOver(directHandler?: (event: MouseEvent) => void): this;
547
- captureMouseUp(directHandler?: (event: MouseEvent) => void): this;
548
- captureWheel(directHandler?: (event: WheelEvent) => void): this;
549
- captureContextMenu(directHandler?: (event: MouseEvent) => void): this;
550
-
551
- // Capture versions for Keyboard Events
552
- captureKeyDown(directHandler?: (event: KeyboardEvent) => void): this;
553
- captureKeyPress(directHandler?: (event: KeyboardEvent) => void): this;
554
- captureKeyUp(directHandler?: (event: KeyboardEvent) => void): this;
555
-
556
- // Capture versions for Form Events
557
- captureBlur(directHandler?: (event: FocusEvent) => void): this;
558
- captureChange(directHandler?: (event: Event) => void): this;
559
- captureFocus(directHandler?: (event: FocusEvent) => void): this;
560
- captureFocusIn(directHandler?: (event: FocusEvent) => void): this;
561
- captureFocusOut(directHandler?: (event: FocusEvent) => void): this;
562
- captureInput(directHandler?: (event: Event) => void): this;
563
- captureInvalid(directHandler?: (event: Event) => void): this;
564
- captureReset(directHandler?: (event: Event) => void): this;
565
- captureSearch(directHandler?: (event: Event) => void): this;
566
- captureSelect(directHandler?: (event: Event) => void): this;
567
- captureSubmit(directHandler?: (event: Event) => void): this;
568
-
569
- // Capture versions for Drag Events
570
- captureDrag(directHandler?: (event: DragEvent) => void): this;
571
- captureDragEnd(directHandler?: (event: DragEvent) => void): this;
572
- captureDragEnter(directHandler?: (event: DragEvent) => void): this;
573
- captureDragLeave(directHandler?: (event: DragEvent) => void): this;
574
- captureDragOver(directHandler?: (event: DragEvent) => void): this;
575
- captureDragStart(directHandler?: (event: DragEvent) => void): this;
576
- captureDrop(directHandler?: (event: DragEvent) => void): this;
577
-
578
- // Capture versions for Window/Page Events
579
- captureAfterPrint(directHandler?: (event: Event) => void): this;
580
- captureBeforePrint(directHandler?: (event: Event) => void): this;
581
- captureBeforeUnload(directHandler?: (event: BeforeUnloadEvent) => void): this;
582
- captureError(directHandler?: (event: Event) => void): this;
583
- captureHashChange(directHandler?: (event: HashChangeEvent) => void): this;
584
- captureLoad(directHandler?: (event: Event) => void): this;
585
- captureOffline(directHandler?: (event: Event) => void): this;
586
- captureOnline(directHandler?: (event: Event) => void): this;
587
- capturePageHide(directHandler?: (event: PageTransitionEvent) => void): this;
588
- capturePageShow(directHandler?: (event: PageTransitionEvent) => void): this;
589
- captureResize(directHandler?: (event: UIEvent) => void): this;
590
- captureScroll(directHandler?: (event: Event) => void): this;
591
- captureUnload(directHandler?: (event: Event) => void): this;
592
-
593
- // Capture versions for Media Events
594
- captureAbort(directHandler?: (event: Event) => void): this;
595
- captureCanPlay(directHandler?: (event: Event) => void): this;
596
- captureCanPlayThrough(directHandler?: (event: Event) => void): this;
597
- captureDurationChange(directHandler?: (event: Event) => void): this;
598
- captureEmptied(directHandler?: (event: Event) => void): this;
599
- captureEnded(directHandler?: (event: Event) => void): this;
600
- captureLoadedData(directHandler?: (event: Event) => void): this;
601
- captureLoadedMetadata(directHandler?: (event: Event) => void): this;
602
- captureLoadStart(directHandler?: (event: Event) => void): this;
603
- capturePause(directHandler?: (event: Event) => void): this;
604
- capturePlay(directHandler?: (event: Event) => void): this;
605
- capturePlaying(directHandler?: (event: Event) => void): this;
606
- captureProgress(directHandler?: (event: ProgressEvent) => void): this;
607
- captureRateChange(directHandler?: (event: Event) => void): this;
608
- captureSeeked(directHandler?: (event: Event) => void): this;
609
- captureSeeking(directHandler?: (event: Event) => void): this;
610
- captureStalled(directHandler?: (event: Event) => void): this;
611
- captureSuspend(directHandler?: (event: Event) => void): this;
612
- captureTimeUpdate(directHandler?: (event: Event) => void): this;
613
- captureVolumeChange(directHandler?: (event: Event) => void): this;
614
- captureWaiting(directHandler?: (event: Event) => void): this;
615
-
616
- // Capture versions for Touch Events
617
- captureTouchCancel(directHandler?: (event: TouchEvent) => void): this;
618
- captureTouchEnd(directHandler?: (event: TouchEvent) => void): this;
619
- captureTouchMove(directHandler?: (event: TouchEvent) => void): this;
620
- captureTouchStart(directHandler?: (event: TouchEvent) => void): this;
621
-
622
- // Capture versions for Animation Events
623
- captureAnimationEnd(directHandler?: (event: AnimationEvent) => void): this;
624
- captureAnimationIteration(directHandler?: (event: AnimationEvent) => void): this;
625
- captureAnimationStart(directHandler?: (event: AnimationEvent) => void): this;
626
-
627
- // Capture versions for Transition Events
628
- captureTransitionEnd(directHandler?: (event: TransitionEvent) => void): this;
629
-
630
- // Capture versions for Clipboard Events
631
- captureCopy(directHandler?: (event: ClipboardEvent) => void): this;
632
- captureCut(directHandler?: (event: ClipboardEvent) => void): this;
633
- capturePaste(directHandler?: (event: ClipboardEvent) => void): this;
634
401
  }
@@ -23,7 +23,12 @@ export interface ObservableItem<T = any> {
23
23
 
24
24
  check<U>(callback: (value: T) => U): ObservableChecker<U>;
25
25
  get<U>(callback: (value: T) => U): ObservableChecker<U>;
26
- when(value: T): { $target: T; $observer: ObservableItem<T> };
26
+ when(value: T): ObservableWhen<T>;
27
+ off(value: T, callback?: Function): void;
28
+ once(predicate: T | ((value: T) => boolean), callback: (value: T) => void): void;
29
+ onCleanup(callback: () => void): void;
30
+ intercept(callback: (newValue: T, currentValue: T) => T | undefined): this;
31
+ disconnectAll(): void;
27
32
 
28
33
  toString(): string;
29
34
  equals(value: any): boolean;
@@ -41,7 +46,7 @@ export class ObservableWhen<T = any> {
41
46
 
42
47
  subscribe(callback: (value: boolean) => void): Unsubscribe;
43
48
  val(): boolean;
44
- isMath(): boolean;
49
+ isMatch(): boolean;
45
50
  isActive(): boolean;
46
51
  }
47
52
 
@@ -64,6 +69,8 @@ export interface ObservableChecker<T = any> {
64
69
  }
65
70
 
66
71
  export interface ObservableArray<T> extends ObservableItem<T[]> {
72
+ readonly length: number;
73
+
67
74
  push(...items: T[]): number;
68
75
  pop(): T | undefined;
69
76
  shift(): T | undefined;
@@ -78,7 +85,6 @@ export interface ObservableArray<T> extends ObservableItem<T[]> {
78
85
  removeItem(item: T): T[];
79
86
  remove(index: number): T[];
80
87
  swap(indexA: number, indexB: number): boolean;
81
- length(): number;
82
88
  count(condition: (item:T, index?:number) => boolean): number;
83
89
  populateAndRender(iteration: number, callback: (index: number) => T): void;
84
90
 
package/types/router.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // Router system type definitions
2
2
  import { ValidChild } from './elements';
3
3
  import { NDElement } from './nd-element';
4
+ import {ValidChildren} from "./validator";
4
5
 
5
6
  export interface RouteParams {
6
7
  [key: string]: string;
@@ -21,6 +22,7 @@ export interface Route {
21
22
  middlewares(): Function[];
22
23
  shouldRebuild(): boolean;
23
24
  path(): string;
25
+ layout(): Function | null;
24
26
  match(path: string): RouteParams | false;
25
27
  url(configs: { params?: RouteParams; query?: QueryParams; basePath?: string }): string;
26
28
  }
@@ -30,6 +32,7 @@ export interface RouterState {
30
32
  params: RouteParams | null;
31
33
  query: QueryParams | null;
32
34
  path: string | null;
35
+ hash: string | null;
33
36
  }
34
37
 
35
38
  export interface Router {
@@ -41,9 +44,10 @@ export interface Router {
41
44
  middlewares?: Function[];
42
45
  shouldRebuild?: boolean;
43
46
  with?: Record<string, string>;
47
+ layout?: (children: ValidChild) => ValidChild ;
44
48
  }): this;
45
49
 
46
- group(suffix: string, options: { middlewares?: Function[]; name?: string, layout?: Function }, callback: () => void): this;
50
+ group(suffix: string, options: { middlewares?: Function[]; name?: string; layout?: Function }, callback: () => void): this;
47
51
 
48
52
  generateUrl(name: string, params?: RouteParams, query?: QueryParams): string;
49
53
  resolve(target: string | { name: string; params?: RouteParams; query?: QueryParams }): {
@@ -29,6 +29,7 @@ export declare class TemplateCloner {
29
29
  style(fn: (...data: any[]) => any): BindingHydrator;
30
30
  class(fn: (...data: any[]) => any): BindingHydrator;
31
31
  value(callbackOrProperty: string | ((...data: any[]) => any)): BindingHydrator;
32
+ text(callbackOrProperty: string | ((...data: any[]) => any)): BindingHydrator;
32
33
  attr(fn: (...data: any[]) => any): BindingHydrator;
33
34
  event(fn: (event: Event, ...data: any[]) => void): BindingHydrator;
34
35
 
@@ -1,4 +1,4 @@
1
- import {ObservableChecker, ObservableItem, ObservableProxy} from "./observable";
1
+ import {ObservableArray, ObservableChecker, ObservableItem, ObservableProxy} from "./observable";
2
2
  import { ValidChild } from "./elements";
3
3
  import { NDElement } from "./nd-element";
4
4
 
@@ -14,6 +14,16 @@ declare const Validator: {
14
14
 
15
15
  isObservableChecker(value: any): value is ObservableChecker;
16
16
 
17
+ isTemplateBinding(value: any): boolean;
18
+
19
+ isObservableWhenResult(value: any): boolean;
20
+
21
+ isArrayObservable(value: any): value is ObservableArray<any>;
22
+
23
+ isObservableOrProxy(value: any): value is ObservableItem | ObservableProxy<any>;
24
+
25
+ isAnchor(value: any): boolean;
26
+
17
27
  isArray(value: any): value is Array<any>;
18
28
 
19
29
  isString(value: any): value is string;
package/utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
 
2
2
  export * from './types/native-fetch';
3
- export * from './types/service';
3
+ export * from './types/service';
4
+ export * as filters from './types/filters/index';
package/utils.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import NativeFetch from "./src/fetch/NativeFetch";
2
- import { Service } from "./src/core/utils/service";
3
- import * as Filters from "./src/core/utils/filters/index";
2
+ import * as Cache from "./src/core/utils/cache";
3
+ import * as filters from "./src/core/utils/filters/index";
4
4
 
5
5
 
6
6
  export {
7
7
  NativeFetch,
8
- Service,
9
- Filters,
8
+ Cache,
9
+ filters,
10
10
  };
@@ -1,6 +0,0 @@
1
- import { autoMemoize, autoOnce } from "./memoize.js";
2
-
3
- export const Service = {
4
- once: fn => autoOnce(fn),
5
- memoize: fn => autoMemoize(fn)
6
- };