dothtml-interfaces 0.1.16 → 0.1.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dothtml-interfaces",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Dependency injection interfaces for DOTHtml.",
5
5
  "main": "src/index.d.ts",
6
6
  "types": "src/index.d.ts",
@@ -3,17 +3,19 @@ import { IDotElement, IDotGenericElement } from "./i-dot";
3
3
  import IDotCss from "./i-dot-css";
4
4
 
5
5
  export interface FrameworkItems {
6
+ /**
7
+ * The root element of the component.
8
+ */
6
9
  el: HTMLElement;
7
- css: IDotCss;
8
- html: IDotGenericElement;
9
10
  refs: { [key: string]: HTMLElement };
11
+ emit: (event: string, ...args: Array<any>)=>void;
10
12
  restyle(): void;
13
+ // css: IDotCss;
14
+ // html: IDotGenericElement;
11
15
  }
12
16
 
13
17
  export default interface IComponent {
14
18
  // Properties
15
- props?: { [key: string]: any };
16
- bindings?: { [key: string]: any };
17
19
  events?: Array<string>;
18
20
 
19
21
  readonly $?: FrameworkItems;
package/src/i-dot.d.ts CHANGED
@@ -6,9 +6,11 @@ import IObservable from "./i-observable";
6
6
 
7
7
  type DotContentPrimitive = string|number|boolean;
8
8
  type DotContentBasic = DotContentPrimitive|Node|Element|NodeList|IComponent|IDotDocument//typeof DotDocument;
9
- export type DotContent = DotContentBasic|Array<DotContent>|IObservable|(()=>DotContent);
9
+ export type DotContent = DotContentBasic|Array<DotContent>|IObservable;//|(()=>DotContent);
10
10
 
11
- // Global interface containing elements:
11
+ /**
12
+ * Global interface containing elements.
13
+ */
12
14
  export interface IDotDocument
13
15
  {
14
16
  // Creating a blank DotDocument.
@@ -46,13 +48,18 @@ export interface IDotDocument
46
48
  * Creates a text node that will render as a string, rather than being parsed as markup.
47
49
  */
48
50
  text(content: string|number|boolean|IObservable): IDotDocument;
51
+ /**
52
+ * Mounts a component.
53
+ */
54
+ mount(component: IComponent): IMountedComponent;
49
55
  /**
50
56
  * Iterates n times, appending the result of each iteration to the VDBO.
51
57
  * @param n The number of iterations.
52
58
  * @param callback The markup-generating callback.
53
59
  */
54
60
  iterate(n: number, callback: (i: number)=>DotContent): IDotDocument;
55
- each<T>(a: Array<T>|{[key: string|number]: T}|IObservable<any, Array<T>|{[key: string|number]: T}>, callback: (x: T, i: string|number, k: string|number)=>DotContent): IDotDocument;
61
+ each<T>(a: Array<T>|{[key: string|number]: T}, callback: (x: T, i: number, k: string|number)=>DotContent): IDotDocument;
62
+ each<T>(a: IObservable<any, Array<T>|{[key: string|number]: T}>, callback: (x: T, i: IObservable<number>, k: string|number)=>DotContent): IDotDocument;
56
63
 
57
64
  /**
58
65
  * Removes the targeted document and everything in it.
@@ -67,16 +74,8 @@ export interface IDotDocument
67
74
  */
68
75
  empty(): IDotDocument;
69
76
 
70
- /**
71
- * Executes a function immediately.
72
- */
73
- script(callback: Function): IDotDocument;
74
-
75
77
  scopeClass(prefix: number|string|null, content: DotContent): IDotDocument;
76
78
 
77
- wait(timeout, callback);
78
- defer(callback);
79
-
80
79
  // Tags.
81
80
  a(content?: DotContent): IDotA;
82
81
 
@@ -223,7 +222,9 @@ export interface IDotDocument
223
222
  wbr(content?: DotContent): IDotElementDocument<IDotGenericElement>;
224
223
  }
225
224
 
226
- // Interface for the dot object:
225
+ /**
226
+ * Interface for the dot object.
227
+ */
227
228
  export interface IDotCore extends IDotDocument
228
229
  {
229
230
  (targetSelector: string|Element|Node|NodeList|Array<Node|Element>): IDotElementDocument<IDotGenericElement>;
@@ -237,7 +238,7 @@ export interface IDotCore extends IDotDocument
237
238
 
238
239
  observe<Ti = IObservable|Array<any>|{[key: string|number]: any}|string|number|boolean, To = Ti>(props?: {value: Ti, key?: string, transformer?: (value: Ti)=>To}): IObservable<Ti, To>;
239
240
 
240
- component<T extends {new(...args: any[]): (IComponent)}>(ComponentClass: T): T&{new(...args: any[]): ({$: FrameworkItems})};
241
+ component<T extends IComponent>(ComponentClass: new(...args: any[])=>T): (new(...args: any[])=>(T&{readonly $:FrameworkItems}));
241
242
  }
242
243
 
243
244
  export interface IDotWindowBuilder{
@@ -271,11 +272,6 @@ export interface IDotElementDocument<T extends IDotDocument> extends IDotDocumen
271
272
  // TODO: I'd really like to enable this. Unfortunately it's not terribly easy to implement.
272
273
  // Might be impossible in ES5 (notwithstanding some possible hackery).
273
274
  //(content?: DotContent): IDotElementDocument<IDotGenericElement>;
274
-
275
- /**
276
- * A conditional function, analogous to if. Renders the specified DOT if a condition is met. Dynamic binding is possible when condition and callback are functions.
277
- */
278
- when(condition: IObservable|boolean, callback: DotContent): IDotConditionalDocument;
279
275
 
280
276
  // TODO: this will erase element context, which could be a bug.
281
277
  // It can be duplicated multiple times below, or find a new solution.
@@ -382,6 +378,12 @@ export interface IDotElementDocument<T extends IDotDocument> extends IDotDocumen
382
378
  export interface IDotGenericElement extends IDotElementDocument<IDotGenericElement>{}
383
379
 
384
380
  // Interface for specific elements:
381
+
382
+ interface IMountedComponent extends IDotDocument{
383
+ on(event: string, callback: (...args: Array<any>)=>void): IMountedComponent;
384
+ prop(name: string, value: any): IMountedComponent;
385
+ }
386
+
385
387
  interface IDotA extends IDotElementDocument<IDotA>{
386
388
  download(value: unknown): IDotA;
387
389
  hRef(value: unknown): IDotA;