j-templates 7.0.13 → 7.0.15

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/DOM/elements.d.ts CHANGED
@@ -78,4 +78,12 @@ export declare const td: <T>(config: {
78
78
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
79
79
  data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
80
80
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
81
+ export declare const img: <T>(config: {
82
+ props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLImageElement>>;
83
+ attrs?: import("../Node/vNode.types").FunctionOr<{
84
+ [name: string]: string;
85
+ }>;
86
+ on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
87
+ data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
88
+ }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
81
89
  export declare const text: (callback: () => string) => import("../Node/vNode.types").vNode;
package/DOM/elements.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.text = exports.td = exports.tr = exports.tbody = exports.table = exports.span = exports.input = exports.h1 = exports.button = exports.a = exports.div = void 0;
3
+ exports.text = exports.img = exports.td = exports.tr = exports.tbody = exports.table = exports.span = exports.input = exports.h1 = exports.button = exports.a = exports.div = void 0;
4
4
  const vNode_1 = require("../Node/vNode");
5
5
  exports.div = vNode_1.vNode.ToFunction("div");
6
6
  exports.a = vNode_1.vNode.ToFunction("a");
@@ -12,6 +12,7 @@ exports.table = vNode_1.vNode.ToFunction("table");
12
12
  exports.tbody = vNode_1.vNode.ToFunction("tbody");
13
13
  exports.tr = vNode_1.vNode.ToFunction("tr");
14
14
  exports.td = vNode_1.vNode.ToFunction("td");
15
+ exports.img = vNode_1.vNode.ToFunction("img");
15
16
  const textElement = vNode_1.vNode.ToFunction("text");
16
17
  const text = function (callback) {
17
18
  return textElement({ props: () => ({ nodeValue: callback() }) });
@@ -29,6 +29,7 @@ type ComponentConstructor<D, T, E> = {
29
29
  };
30
30
  export declare namespace Component {
31
31
  function ToFunction<D, T, E, P = HTMLElement>(type: string, constructor: ComponentConstructor<D, T, E>, namespace?: string): (config: vComponentConfig<D, E, P>, templates?: T) => vNodeType;
32
+ function Register<D = void, T = void, E = void>(name: string, constructor: ComponentConstructor<D, T, E>): void;
32
33
  function Attach(node: any, vnode: vNodeType): vNodeType;
33
34
  }
34
35
  export {};
package/Node/component.js CHANGED
@@ -65,6 +65,19 @@ exports.Component = Component;
65
65
  };
66
66
  }
67
67
  Component.ToFunction = ToFunction;
68
+ function Register(name, constructor) {
69
+ const componentFunction = ToFunction(`${name}-component`, constructor);
70
+ class WebComponent extends HTMLElement {
71
+ constructor() {
72
+ super();
73
+ const shadowRoot = this.attachShadow({ mode: "open" });
74
+ const node = componentFunction({});
75
+ Attach(shadowRoot, node);
76
+ }
77
+ }
78
+ customElements.define(name, WebComponent);
79
+ }
80
+ Component.Register = Register;
68
81
  function Attach(node, vnode) {
69
82
  return vNode_1.vNode.Attach(node, vnode);
70
83
  }
@@ -166,9 +166,6 @@ function DirtyScope(scope) {
166
166
  return;
167
167
  if (scope.async) {
168
168
  UpdateValue(scope);
169
- scope.promise.then(function () {
170
- emitter_1.Emitter.Emit(scope.emitter, scope);
171
- });
172
169
  }
173
170
  else
174
171
  emitter_1.Emitter.Emit(scope.emitter, scope);
@@ -199,6 +196,7 @@ function UpdateValue(scope) {
199
196
  if (scope.async) {
200
197
  scope.promise = value.then(function (result) {
201
198
  scope.value = result;
199
+ emitter_1.Emitter.Emit(scope.emitter, scope);
202
200
  return result;
203
201
  });
204
202
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "7.0.13",
3
+ "version": "7.0.15",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",