@mintjamsinc/ichigojs 0.1.80 → 0.1.82

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.
@@ -32,8 +32,17 @@ export declare class VNode {
32
32
  * Walking only {@link childVNodes} keeps the traversal inside this
33
33
  * application: the internals of an expanded component were never compiled
34
34
  * here, so they are not reachable and are left to their own application.
35
- * A templatized node is skipped whole — it is a template source, and its
36
- * clones expand when they are inserted.
35
+ * The one exception is content a directive rendered outside its own
36
+ * children — scoped slot content — reached through
37
+ * {@link VDirective.expandComponents}.
38
+ *
39
+ * Only connected elements are expanded. v-if / v-for call this right after
40
+ * inserting a clone, but when that clone sits inside another clone that is
41
+ * still detached (nested directives, or slot content rendered by an outlet
42
+ * inside a component's v-if), the insertion is not into the document yet;
43
+ * the outer inserter's walk reaches the same nodes once it is. A
44
+ * templatized node (a v-if / v-for source) is not expanded itself, but its
45
+ * rendered clones are its children and are walked.
37
46
  */
38
47
  expandComponents(): void;
39
48
  /**
@@ -36,9 +36,13 @@ export interface ScopedSlotEntry {
36
36
  * microtask fires, so data() can read them. A component used without any prop
37
37
  * binding still mounts — with its declared defaults — instead of waiting forever.
38
38
  *
39
- * Slot content is captured on the first connection and cached, so a component
40
- * that is moved in the DOM (e.g. reordered by v-for) re-expands its template
41
- * and redistributes the same slot nodes on reconnection.
39
+ * Slot content is captured on the first expansion and cached. The nodes are the
40
+ * parent application's compiled nodes and are only ever moved, never cloned:
41
+ * each `<slot>` outlet the component renders moves them into place
42
+ * (VStaticSlotOutletDirective; scoped `<template v-slot>` content is rendered
43
+ * per outlet by VSlotOutletDirective instead). A component that is moved in
44
+ * the DOM (e.g. reordered by v-for) re-expands its template, and its outlets
45
+ * move the same nodes into the fresh expansion.
42
46
  *
43
47
  * Subclasses must set the static fields _template, _props, _propOptions and
44
48
  * _buildOptions before calling customElements.define(). defineComponent()
@@ -76,6 +80,13 @@ export declare class IchigoElement extends HTMLElement {
76
80
  * VSlotOutletDirective when the component template renders a `<slot>`.
77
81
  */
78
82
  get _ichigoScopedSlots(): Map<string, ScopedSlotEntry> | undefined;
83
+ /**
84
+ * The static slot content captured for the given slot name ('default'
85
+ * for the unnamed slot): the parent application's nodes, moved into place
86
+ * by VStaticSlotOutletDirective. Undefined when nothing was provided for
87
+ * that name, in which case the outlet's fallback content renders.
88
+ */
89
+ _ichigoSlotNodes(name: string): Node[] | undefined;
79
90
  /**
80
91
  * Handles RE-attachment, and nothing else.
81
92
  *
@@ -88,6 +88,14 @@ export interface VDirective {
88
88
  * The element reference is still available at this point.
89
89
  */
90
90
  get onUnmounted(): (() => void) | undefined;
91
+ /**
92
+ * Expands the components in a subtree this directive rendered but that is
93
+ * not reachable through the VNode's children — the scoped slot content of
94
+ * a `<slot>` outlet, whose VNodes belong to the parent application.
95
+ * Called by VNode.expandComponents() when it walks this directive's node.
96
+ * Optional; most directives render nothing outside their own VNode tree.
97
+ */
98
+ expandComponents?(): void;
91
99
  /**
92
100
  * Cleans up any resources used by the directive.
93
101
  * This method is called when the directive is no longer needed.
@@ -26,9 +26,9 @@ import { VDOMUpdater } from "../VDOMUpdater";
26
26
  * ```
27
27
  *
28
28
  * This directive is created only when a scoped template for the slot's name
29
- * exists (see {@link VSlotOutletDirective.tryCreate}); otherwise `<slot>`
30
- * elements keep their existing behavior (static distribution at expansion,
31
- * or fallback content compiled in the component scope).
29
+ * exists (see {@link VSlotOutletDirective.tryCreate}); otherwise plain slot
30
+ * content is moved into place by VStaticSlotOutletDirective, and a `<slot>`
31
+ * with no content at all renders its fallback in the component scope.
32
32
  *
33
33
  * Rendering happens synchronously in onMount — before the component
34
34
  * application would compile the slot's fallback children — by replacing the
@@ -111,4 +111,8 @@ export declare class VSlotOutletDirective implements VDirective {
111
111
  * @inheritdoc
112
112
  */
113
113
  destroy(): void;
114
+ /**
115
+ * @inheritdoc
116
+ */
117
+ expandComponents(): void;
114
118
  }
@@ -0,0 +1,129 @@
1
+ import type { VNode } from "../VNode";
2
+ import { VBindingsPreparer } from "../VBindingsPreparer";
3
+ import { VDirective } from "./VDirective";
4
+ import { VDOMUpdater } from "../VDOMUpdater";
5
+ /**
6
+ * Renders a static slot outlet: a `<slot>` element inside a component template
7
+ * whose host element received plain slot content from the parent — child
8
+ * nodes for the default slot, or elements carrying `slot="name"`:
9
+ *
10
+ * ```html
11
+ * <!-- component template -->
12
+ * <div v-if="open" class="body"><slot></slot></div>
13
+ *
14
+ * <!-- usage -->
15
+ * <my-dialog :open="show">
16
+ * <my-field :label="title"></my-field>
17
+ * </my-dialog>
18
+ * ```
19
+ *
20
+ * The slot content is the parent application's own nodes, compiled in the
21
+ * parent scope; it keeps its bindings, listeners and component props only as
22
+ * long as those very nodes are displayed. So the outlet MOVES them into place
23
+ * and never clones them. That is what lets a `<slot>` sit behind a v-if or
24
+ * v-for in the component template: the directive clones its template source,
25
+ * the clone carries a fresh `<slot>`, and the outlet created for that clone
26
+ * moves the live nodes in.
27
+ *
28
+ * Nodes can only be in one place, so when the same slot is rendered more than
29
+ * once (e.g. a `<slot>` inside a v-for), the outlet rendered last receives the
30
+ * content and the earlier ones are left empty. When the outlet holding the
31
+ * content goes away while others remain (its row is removed), the content
32
+ * moves to the last remaining one. For content per row, use a scoped slot
33
+ * (`<template v-slot:name="scope">`), which renders a copy per outlet
34
+ * (VSlotOutletDirective).
35
+ *
36
+ * The component application never compiles the moved nodes: they are placed
37
+ * in onMount, after the parent VNode has taken its snapshot of the children
38
+ * to compile. Components inside them belong to the parent application, which
39
+ * expands them through {@link expandComponents} once they are in the document.
40
+ * When the last outlet goes away (its v-if turns false) the nodes leave with
41
+ * the removed clone and wait there until the next outlet moves them again;
42
+ * they are not destroyed, because they are not this application's to destroy.
43
+ *
44
+ * Created only when the host captured content for the slot's name and no
45
+ * scoped template claims it; otherwise the `<slot>` element renders its
46
+ * fallback children in the component scope.
47
+ */
48
+ export declare class VStaticSlotOutletDirective implements VDirective {
49
+ #private;
50
+ /**
51
+ * Creates a static slot outlet for the given `<slot>` VNode when the host
52
+ * element captured content for its slot name. Returns undefined when there
53
+ * is none, so the `<slot>` element keeps rendering its fallback content.
54
+ */
55
+ static tryCreate(vNode: VNode): VStaticSlotOutletDirective | undefined;
56
+ private constructor();
57
+ /**
58
+ * @inheritdoc
59
+ */
60
+ get name(): string;
61
+ /**
62
+ * @inheritdoc
63
+ */
64
+ get vNode(): VNode;
65
+ /**
66
+ * @inheritdoc
67
+ */
68
+ get needsAnchor(): boolean;
69
+ /**
70
+ * @inheritdoc
71
+ */
72
+ get bindingsPreparer(): VBindingsPreparer | undefined;
73
+ /**
74
+ * @inheritdoc
75
+ */
76
+ get domUpdater(): VDOMUpdater | undefined;
77
+ /**
78
+ * @inheritdoc
79
+ */
80
+ get templatize(): boolean;
81
+ /**
82
+ * @inheritdoc
83
+ */
84
+ get dependentIdentifiers(): string[];
85
+ /**
86
+ * @inheritdoc
87
+ *
88
+ * Moves the slot content in place of the `<slot>` element — synchronously
89
+ * during VNode construction, before the component application would
90
+ * compile the slot's fallback children (which the content replaces).
91
+ */
92
+ get onMount(): (() => void) | undefined;
93
+ /**
94
+ * @inheritdoc
95
+ */
96
+ get onMounted(): (() => void) | undefined;
97
+ /**
98
+ * @inheritdoc
99
+ */
100
+ get onUpdate(): (() => void) | undefined;
101
+ /**
102
+ * @inheritdoc
103
+ */
104
+ get onUpdated(): (() => void) | undefined;
105
+ /**
106
+ * @inheritdoc
107
+ */
108
+ get onUnmount(): (() => void) | undefined;
109
+ /**
110
+ * @inheritdoc
111
+ */
112
+ get onUnmounted(): (() => void) | undefined;
113
+ /**
114
+ * @inheritdoc
115
+ *
116
+ * Expands the components in the slot content through the parent
117
+ * application's VNodes. Called by the walk of whoever inserted this
118
+ * outlet into the document (VApplication.mount, v-if, v-for), so the
119
+ * content is connected by now — unless a later outlet took it, in which
120
+ * case that outlet's walk expands it.
121
+ */
122
+ expandComponents(): void;
123
+ /**
124
+ * @inheritdoc
125
+ *
126
+ * The slot content is the parent application's; nothing to release here.
127
+ */
128
+ destroy(): void;
129
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintjamsinc/ichigojs",
3
- "version": "0.1.80",
3
+ "version": "0.1.82",
4
4
  "description": "ichigo.js - Simple and intuitive reactive framework. Lightweight, fast, and user-friendly virtual DOM library",
5
5
  "main": "./dist/ichigo.cjs",
6
6
  "module": "./dist/ichigo.esm.js",