j-templates 8.0.17 → 8.0.19

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.
@@ -16,14 +16,14 @@ export type vNodeEvents<E extends {
16
16
  (events: E[P]): void;
17
17
  };
18
18
  };
19
- export type vNodeChildrenFunction<T> = ((data: T) => vNode | vNode[]) | ((data: T) => string);
19
+ export type vNodeChildrenFunction<T> = (data: T) => vNode | vNode[] | string | null | undefined;
20
20
  export type vNodeConfig<P = HTMLElement, E = HTMLElementEventMap, T = never> = {
21
21
  props?: FunctionOr<RecursivePartial<P>>;
22
22
  attrs?: FunctionOr<{
23
23
  [name: string]: string;
24
24
  }>;
25
25
  on?: FunctionOr<vNodeEvents<E>>;
26
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
26
+ data?: () => T | Array<T> | null | undefined | Promise<T | Array<T> | null | undefined>;
27
27
  };
28
28
  export type vStringNode = {
29
29
  type: typeof STRING_NODE;
@@ -78,7 +78,7 @@ export class Store {
78
78
  if (results.length > 1 || results[0].path.length > 1)
79
79
  throw `Unable to initialize root path ${rootPath} with ${results.length} results and initial path ${results[0].path}`;
80
80
  const rootData = this.cloneData ? JsonDeepClone(results[0].value) : results[0].value;
81
- const newRootObject = this.createNode({ [rootPath]: rootData });
81
+ const newRootObject = this.createNode({ [rootPath]: rootData }, false);
82
82
  this.rootMap.set(rootPath, newRootObject);
83
83
  return;
84
84
  }
@@ -38,7 +38,7 @@ export declare namespace ObservableNode {
38
38
  * @param value The plain value (object, array, or primitive) to make observable.
39
39
  * @returns A proxied version of the value that emits change events.
40
40
  */
41
- function Create<T>(value: T): T;
41
+ function Create<T>(value: T, unwrapValue?: boolean): T;
42
42
  /**
43
43
  * Returns an immutable, cached snapshot of an observable node's current value (plain
44
44
  * objects/arrays, with keyed children read through their root). The same snapshot is
@@ -104,5 +104,5 @@ export declare namespace ObservableNode {
104
104
  * @param alias Optional function to transform values before making them observable.
105
105
  * @returns A function that creates observable nodes from plain values.
106
106
  */
107
- function CreateFactory(alias?: (value: any, reactive?: boolean) => any | undefined): <T>(value: T) => T;
107
+ function CreateFactory(alias?: (value: any, reactive?: boolean) => any | undefined): <T>(value: T, unwrapValue?: boolean) => T;
108
108
  }
@@ -321,8 +321,9 @@ function CreateProxyFactory(alias) {
321
321
  return value;
322
322
  }
323
323
  }
324
- return function CreateProxy(value) {
325
- value = UnwrapProxy(value);
324
+ return function CreateProxy(value, unwrapValue = true) {
325
+ if (unwrapValue)
326
+ value = UnwrapProxy(value);
326
327
  return CreateProxyFromValue(value);
327
328
  };
328
329
  }
@@ -373,8 +374,8 @@ export var ObservableNode;
373
374
  * @param value The plain value (object, array, or primitive) to make observable.
374
375
  * @returns A proxied version of the value that emits change events.
375
376
  */
376
- function Create(value) {
377
- return DefaultCreateProxy(value);
377
+ function Create(value, unwrapValue = true) {
378
+ return DefaultCreateProxy(value, unwrapValue);
378
379
  }
379
380
  ObservableNode.Create = Create;
380
381
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "8.0.17",
3
+ "version": "8.0.19",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",