zenith 1.0.0-beta.14 → 1.0.0-rc.1

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,4 +16,6 @@ export interface DerivedSignal<T> extends Signal<T> {
16
16
  * // In component cleanup:
17
17
  * removed: () => fullName.destroy()
18
18
  */
19
- export declare const derived: <T>(fn: () => T, deps: Signal<any>[]) => DerivedSignal<T>;
19
+ export declare const derived: <T>(fn: () => T, deps: {
20
+ sub(fn: () => void): () => void;
21
+ }[]) => DerivedSignal<T>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Renders children into another DOM location using an independent
3
+ * Zenith root. Useful for modals, popovers, and overlays.
4
+ *
5
+ * Unlike native portals:
6
+ * - Children do not inherit the originating component's ancestry
7
+ * or injected context.
8
+ * - Events follow the destination DOM tree.
9
+ * - An extra wrapper <div> is inserted into the target.
10
+ * - Rendering into the target is deferred to a microtask.
11
+ *
12
+ * The helper manages mounting, updates, and cleanup, but not
13
+ * stacking, positioning, focus, or accessibility.
14
+ *
15
+ * @example
16
+ * comp(DetachedRoot, {
17
+ * to: document.body, // Or a CSS selector such as '#modals'
18
+ * children: comp(Modal)
19
+ * });
20
+ */
21
+ import type { VNodeCompAttributes, VNodeCompDefinition, VNodeAny, VNodeArray } from '../vnode.defs';
22
+ interface DetachedRootAttrs extends VNodeCompAttributes {
23
+ to: string | Element;
24
+ children: VNodeAny | VNodeArray;
25
+ }
26
+ declare const definition: VNodeCompDefinition<DetachedRootAttrs>;
27
+ export declare const DetachedRoot: typeof definition;
28
+ export {};
@@ -10,4 +10,4 @@ export type { Signal } from './signal';
10
10
  export { derived } from './derived';
11
11
  export type { DerivedSignal } from './derived';
12
12
  export { router } from './router';
13
- export { Portal } from './portal';
13
+ export { DetachedRoot } from './detached-root';
@@ -15,7 +15,10 @@ export declare const diff: {
15
15
  all: number;
16
16
  };
17
17
  export declare const sync: () => void;
18
- export declare const draw: (vNode: VNodeContainer, surgical?: boolean) => void;
18
+ export declare const redraw: {
19
+ (vNode: VNodeContainer, surgical?: false): void;
20
+ (vNode: VNodeComp, surgical: true): void;
21
+ };
19
22
  export declare const elem: {
20
23
  (tag: string): VNodeElem;
21
24
  (tag: string, attrs: VNodeElemAttributes, ...args: VNodeArray): VNodeElem;
@@ -24,5 +27,5 @@ export declare const elem: {
24
27
  export declare const compDef: (componentDefinition: VNodeCompDefinition) => VNodeCompDefinition;
25
28
  export declare const comp: (componentDefinition: VNodeCompDefinition, attrs?: VNodeCompAttributes) => VNodeComp;
26
29
  export declare const node: (el: Element) => VNodeNode;
27
- export declare const bind: (el: Element, vNodeAnyOrArray: VNodeAny | VNodeArray) => VNodeComp;
30
+ export declare const bind: (el: Element, vNodeAnyOrArray: VNodeAny | VNodeArray | null) => VNodeComp;
28
31
  export { ns };
@@ -1,8 +1,9 @@
1
1
  export declare const VNODE_ELEM = 1;
2
2
  export declare const VNODE_TEXT = 2;
3
- export declare const VNODE_COMP = 3;
4
- export declare const VNODE_NODE = 4;
5
- export declare const VNODE_COMPDEF = 5;
3
+ export declare const VNODE_COMP = 4;
4
+ export declare const VNODE_NODE = 8;
5
+ export declare const VNODE_COMPDEF = 16;
6
+ export declare const VNODE_TYPE_MASK = 31;
6
7
  export interface VNodeElemAttributes {
7
8
  class?: string | string[];
8
9
  style?: string | Record<string, string | number | null | undefined>;
@@ -16,15 +17,11 @@ export interface VNodeElemAttributes {
16
17
  export interface VNodeCompAttributes {
17
18
  $key?: string | number;
18
19
  $remove?: boolean;
19
- to?: string | Element;
20
20
  [property: string]: any;
21
21
  }
22
22
  export type VNodeAttrs = VNodeElemAttributes | VNodeCompAttributes;
23
- export interface VNodeNodeAttributes {
24
- [property: string]: any;
25
- }
26
23
  export interface VNodeCompDefinition<A extends VNodeCompAttributes = VNodeCompAttributes> {
27
- $tag?: number;
24
+ $t?: number;
28
25
  init?: (vNode: VNodeComp<A>) => void;
29
26
  draw: (vNode: VNodeComp<A>, oldChildren?: VNodeFlatArray) => VNodeAnyOrArray;
30
27
  drawn?: (vNode: VNodeComp<A>, isFirstDraw?: boolean) => void;
@@ -34,36 +31,39 @@ export interface VNodeCompDefinition<A extends VNodeCompAttributes = VNodeCompAt
34
31
  }
35
32
  interface VNodeBase {
36
33
  $h?: boolean;
37
- up: VNodeContainer | null;
34
+ $p: VNodeContainer | null;
38
35
  nodes: VNodeFlatArray | null;
39
36
  el: any;
40
37
  }
41
38
  export interface VNodeElem extends VNodeBase {
42
39
  is: typeof VNODE_ELEM;
43
- $tag: string;
44
- $def: null;
40
+ $t: string;
41
+ $d: null;
45
42
  attrs: VNodeElemAttributes;
46
43
  nodes: VNodeFlatArray;
47
44
  }
48
45
  export interface VNodeText extends VNodeBase {
49
46
  is: typeof VNODE_TEXT;
50
- $tag: string;
51
- $def: null;
47
+ $t: string;
48
+ $d: null;
52
49
  attrs: null;
53
50
  nodes: null;
54
51
  }
55
52
  export interface VNodeComp<A extends VNodeCompAttributes = VNodeCompAttributes> extends VNodeBase {
56
53
  is: typeof VNODE_COMP;
57
- $tag: number;
58
- $def: VNodeCompDefinition;
54
+ $t: number;
55
+ $d: VNodeCompDefinition;
56
+ $r?: object | null;
59
57
  attrs: A;
60
58
  nodes: VNodeFlatArray;
61
59
  provide?: Record<string, any>;
60
+ /** Optional, application-managed instance state. */
61
+ state?: Record<string, any>;
62
62
  }
63
63
  export interface VNodeNode extends VNodeBase {
64
64
  is: typeof VNODE_NODE;
65
- $tag: string;
66
- $def: null;
65
+ $t: number;
66
+ $d: null;
67
67
  attrs: null;
68
68
  nodes: null;
69
69
  }
@@ -77,6 +77,6 @@ export type VNodeChild = VNodeAny | string | number | boolean | null | undefined
77
77
  export type VNodeArray = Array<VNodeChild | VNodeArray>;
78
78
  export type VNodeAnyOrArray = VNodeChild | VNodeArray;
79
79
  export interface VNodeFlatArray extends Array<VNodeAny> {
80
- $keys?: Map<any, any> | null;
80
+ $keys?: boolean;
81
81
  }
82
82
  export {};