@ibyar/core 0.8.3 → 0.8.5
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/annotation/decorators.d.ts +33 -9
- package/annotation/decorators.js +1 -0
- package/annotation/decorators.js.map +1 -1
- package/binding/binding.expressions.d.ts +3 -3
- package/binding/binding.expressions.js +9 -9
- package/binding/binding.expressions.js.map +1 -1
- package/component/component.d.ts +9 -4
- package/component/component.js +41 -12
- package/component/component.js.map +1 -1
- package/component/custom-element.d.ts +5 -5
- package/component/reflect.d.ts +2 -2
- package/component/reflect.js +9 -9
- package/component/reflect.js.map +1 -1
- package/directive/directive.d.ts +7 -3
- package/directive/directive.js +6 -3
- package/directive/directive.js.map +1 -1
- package/directive/parser.d.ts +1 -1
- package/directive/parser.js +12 -12
- package/directive/parser.js.map +1 -1
- package/directive/providers.d.ts +1 -1
- package/html/expression.js +29 -2
- package/html/expression.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/index.js.map +1 -1
- package/package.json +17 -7
- package/pipe/pipe.js +3 -3
- package/pipe/pipe.js.map +1 -1
- package/providers/provider.d.ts +1 -1
- package/render/host-binding.handler.d.ts +46 -0
- package/render/host-binding.handler.js +60 -0
- package/render/host-binding.handler.js.map +1 -0
- package/render/host-listener.handler.d.ts +16 -9
- package/render/host-listener.handler.js +17 -15
- package/render/host-listener.handler.js.map +1 -1
- package/utils/elements-util.d.ts +1 -0
- package/utils/elements-util.js +7 -1
- package/utils/elements-util.js.map +1 -1
- package/utils/path.d.ts +1 -1
- package/view/base-view.js +8 -15
- package/view/base-view.js.map +1 -1
- package/view/form-view.js +69 -66
- package/view/form-view.js.map +1 -1
- package/view/render.d.ts +20 -3
- package/view/render.js +110 -87
- package/view/render.js.map +1 -1
- package/view/utils.js +12 -12
- package/view/utils.js.map +1 -1
- package/view/view.d.ts +3 -1
- package/view/view.js +9 -1
- package/view/view.js.map +1 -1
- package/zone/bootstrap.d.ts +3 -3
- package/zone/bootstrap.js +1 -11
- package/zone/bootstrap.js.map +1 -1
- package/zone/proxy.d.ts +3 -2
- package/zone/proxy.js +6 -3
- package/zone/proxy.js.map +1 -1
- package/zone/task.js +8 -8
- package/zone/task.js.map +1 -1
- package/zone/zone.d.ts +5 -4
- package/zone/zone.js +22 -3
- package/zone/zone.js.map +1 -1
package/view/form-view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-view.js","sourceRoot":"","sources":["../../../src/core/view/form-view.ts"],"names":[],"mappings":"AAEA,OAAO,EAIN,cAAc,GACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;AAM7C,MAAM,OAAO,sBAAsB;IAElC,YAAY,KAAwC;QACnD,IAAI,CAAC,EAAE,GAAG,KAAgC,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,EAAE,CAAC,MAAO,CAAC;IACxB,CAAC;IAED,IAAI,UAAU;QACb,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAI,YAAY;QACf,OAAO,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,YAAY,CAAC,KAAiB,EAAE,KAAuC;QACtE,IAAI,CAAC,EAAE,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CAED;AAED,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;IACtC,MAAM,CAAC,cAAc,CAAC,sBAAsB,CAAC,SAAS,EAAE,QAAQ,EAAE;QACjE,GAAG,EAAE,SA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Aa,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAC9F,CAAC;YAED,sBAAsB,CAAC,IAA4B;gBAClD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YACnB,CAAC;YACD,oBAAoB,CAAC,QAAiB;gBACrC,IAAI,CAAC,aAAa,EAAE,gBAAgB,EAAE,CAAC,QAAQ,CAAC,CAAC;YAClD,CAAC;YACD,iBAAiB;gBAChB,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YACnD,CAAC;YACD,wBAAwB,CAAC,KAAU,EAAE,IAAgC;gBACpE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACjD,CAAC;SACD;QA1EA;;WAEG;QACI,iBAAc,GAAG,IAAK;WAuE7B;AACF,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { ComponentRef } from '../component/component.js';\nimport {\n\tFormAssociatedCustomElement, HTMLFormElement,\n\tFormAssociatedComponent,\n\tValueControl,\n\tisValueControl,\n} from '../component/custom-element.js';\nimport { baseFactoryView } from './base-view.js';\nimport { ARIAMixinAttributes, isFormElement } from '@ibyar/elements';\n\nexport const NOOP_CONTROL_CHANGE = () => { };\n\nexport interface NativeElementInternals extends ElementInternals {\n\n}\n\nexport class NativeElementInternals implements ElementInternals {\n\tprivate el: HTMLInputElement;\n\tconstructor(input: FormAssociatedComponent<any, any>) {\n\t\tthis.el = input as any as HTMLInputElement;\n\t}\n\n\tget form() {\n\t\treturn this.el.form;\n\t}\n\tget labels() {\n\t\treturn this.el.labels!;\n\t}\n\n\tget shadowRoot() {\n\t\treturn this.el.shadowRoot;\n\t}\n\n\tget willValidate() {\n\t\treturn this.el.willValidate;\n\t}\n\n\tsetFormValue(value: any | null, state?: File | string | FormData | null): void {\n\t\tthis.el.value = value;\n\t}\n\n}\n\nARIAMixinAttributes.forEach(ariaName => {\n\tObject.defineProperty(NativeElementInternals.prototype, ariaName, {\n\t\tenumerable: true,\n\t\tconfigurable: true,\n\t\tget: function name(this: { el: HTMLInputElement }) {\n\t\t\treturn this.el[ariaName];\n\t\t},\n\t\tset: function name(this: { el: HTMLInputElement }, value: any) {\n\t\t\treturn this.el[ariaName] = value;\n\t\t},\n\t});\n});\n\nexport function baseFormFactoryView<T extends Object>(htmlElementType: TypeOf<HTMLElement>): TypeOf<FormAssociatedComponent<T, any>> {\n\tconst baseViewClass = baseFactoryView<T>(htmlElementType);\n\treturn class BaseFormView<T> extends baseViewClass implements FormAssociatedCustomElement {\n\n\t\t/**\n\t\t * Identify the element as a form-associated custom element\n\t\t */\n\t\tstatic formAssociated = true;\n\n\t\tvalue: any;\n\n\t\tprivate _internals: ElementInternals;\n\t\tprivate _form: HTMLFormElement | null;\n\t\tprivate _valueControl?: ValueControl<T>;\n\n\t\tconstructor(componentRef: ComponentRef<T>, modelClass: TypeOf<T>) {\n\t\t\tsuper(componentRef, modelClass);\n\t\t\tif (componentRef.extend.name && isFormElement(componentRef.extend.name)) {\n\t\t\t\tthis._internals = new NativeElementInternals(this);\n\t\t\t} else {\n\t\t\t\tthis._internals = this.attachInternals();\n\t\t\t}\n\t\t\tlet valueControl: ValueControl<any> | undefined;\n\t\t\tif (typeof componentRef.formAssociated === 'function') {\n\t\t\t\tif (this._model instanceof componentRef.formAssociated) {\n\t\t\t\t\tvalueControl == this._model;\n\t\t\t\t} else {\n\t\t\t\t\tconst args: any[] = [this]; /* resolve dependency injection*/;\n\t\t\t\t\tvalueControl = new componentRef.formAssociated(args);\n\t\t\t\t}\n\t\t\t} else if (componentRef.formAssociated === true && isValueControl(this._model)) {\n\t\t\t\tvalueControl = this._model;\n\t\t\t}\n\t\t\tvalueControl && this.registerValueControl(valueControl);\n\t\t\tconst valueInput = componentRef.inputs.filter(input => input.viewAttribute === 'value').at(0);\n\t\t\tif (valueInput) {\n\t\t\t\tthis._modelScope.subscribe(valueInput.modelProperty as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis.onValueControlChange(newValue);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tget internals(): ElementInternals {\n\t\t\treturn this._internals;\n\t\t}\n\t\tget form(): HTMLFormElement | null {\n\t\t\treturn this._form;\n\t\t}\n\t\tget valueControl(): ValueControl<T> | undefined {\n\t\t\treturn this._valueControl;\n\t\t}\n\t\tregisterValueControl(valueControl: ValueControl): void {\n\t\t\tif (this.valueControl) {\n\t\t\t\tthis.valueControl.registerOnChange(NOOP_CONTROL_CHANGE);\n\t\t\t}\n\t\t\tthis._valueControl = valueControl;\n\t\t\tthis._valueControl?.registerOnChange((value: any) => this.onValueControlChange(value));\n\t\t}\n\t\tprivate onValueControlChange(value: any) {\n\t\t\tthis._internals.setFormValue(value);\n\t\t\tthis.value = value;\n\t\t\tthis.dispatchEvent(new Event('change', { bubbles: true, cancelable: true, composed: true }));\n\t\t}\n\n\t\tformAssociatedCallback(form: HTMLFormElement | null): void {\n\t\t\tthis._form = form;\n\t\t}\n\t\tformDisabledCallback(disabled: boolean): void {\n\t\t\tthis._valueControl?.setDisabledState?.(disabled);\n\t\t}\n\t\tformResetCallback(): void {\n\t\t\tthis._valueControl?.writeValue({ mode: 'reset' });\n\t\t}\n\t\tformStateRestoreCallback(value: any, mode: 'restore' | 'autocomplete'): void {\n\t\t\tthis._valueControl?.writeValue({ value, mode });\n\t\t}\n\t}\n}\n"]}
|
package/view/render.d.ts
CHANGED
|
@@ -14,20 +14,37 @@ export declare class ComponentRender<T extends object> {
|
|
|
14
14
|
initView(): void;
|
|
15
15
|
isTemplateRefName(template: DomNode): template is DomElementNode;
|
|
16
16
|
initTemplateRefMap(domNode: DomNode): void;
|
|
17
|
-
|
|
17
|
+
initViewBinding(): void;
|
|
18
18
|
addNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function): void;
|
|
19
19
|
getElementByName(name: string): any;
|
|
20
20
|
createStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<Context>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void;
|
|
21
21
|
createComment(node: CommentNode): Comment;
|
|
22
22
|
createText(node: TextContent): Text;
|
|
23
|
-
createLiveText(textNode: LiveTextContent, contextStack: Stack,
|
|
23
|
+
createLiveText(textNode: LiveTextContent, contextStack: Stack, subscriptions: ScopeSubscription<Context>[]): Text;
|
|
24
24
|
createDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): DocumentFragment;
|
|
25
25
|
appendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): void;
|
|
26
26
|
createElementByTagName(node: {
|
|
27
27
|
tagName: string;
|
|
28
28
|
is?: string;
|
|
29
29
|
}): HTMLElement;
|
|
30
|
-
createElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[],
|
|
30
|
+
createElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): HTMLElement;
|
|
31
|
+
/**
|
|
32
|
+
* use for init host bindings
|
|
33
|
+
* @param element
|
|
34
|
+
* @param node
|
|
35
|
+
* @param contextStack
|
|
36
|
+
* @param subscriptions
|
|
37
|
+
*/
|
|
38
|
+
initHtmlElement(element: HTMLElement, node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* use to init a new create html element
|
|
41
|
+
* @param element
|
|
42
|
+
* @param node
|
|
43
|
+
* @param contextStack
|
|
44
|
+
* @param subscriptions
|
|
45
|
+
* @param host is the direct html element `this.view` or a sub `structural directive` like `*if` or `*for`, etc...
|
|
46
|
+
*/
|
|
47
|
+
initHtmlElement(element: HTMLElement, node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): void;
|
|
31
48
|
private initAttributeDirectives;
|
|
32
49
|
initAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<Context>[];
|
|
33
50
|
initStructuralDirective(directive: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective, node: DomStructuralDirectiveNode | DomAttributeDirectiveNode, contextStack: Stack): ScopeSubscription<Context>[];
|
package/view/render.js
CHANGED
|
@@ -9,7 +9,6 @@ import { AttributeDirective, AttributeOnStructuralDirective } from '../directive
|
|
|
9
9
|
import { TemplateRefImpl } from '../linker/template-ref.js';
|
|
10
10
|
import { ViewContainerRefImpl } from '../linker/view-container-ref.js';
|
|
11
11
|
import { createSubscriptionDestroyer } from '../context/subscription.js';
|
|
12
|
-
import { HostListenerHandler } from '../render/host-listener.handler.js';
|
|
13
12
|
function getChangeEventName(tagName) {
|
|
14
13
|
switch (true) {
|
|
15
14
|
case tagName === 'input':
|
|
@@ -33,37 +32,38 @@ export class ComponentRender {
|
|
|
33
32
|
this.templateNameScope = this.contextStack.pushReactiveScope();
|
|
34
33
|
}
|
|
35
34
|
initView() {
|
|
36
|
-
if (this.componentRef.template) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
rootRef = Reflect.get(this.view, '_shadowRoot');
|
|
50
|
-
Reflect.deleteProperty(this.view, '_shadowRoot');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
rootRef = this.view;
|
|
55
|
-
}
|
|
56
|
-
this.initTemplateRefMap(this.template);
|
|
57
|
-
let rootFragment;
|
|
58
|
-
if (this.template instanceof DomFragmentNode) {
|
|
59
|
-
rootFragment = this.createDocumentFragment(this.template, this.contextStack, rootRef, this.subscriptions, this.view);
|
|
35
|
+
if (!this.componentRef.template) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (typeof this.componentRef.template === 'function') {
|
|
39
|
+
this.template = this.componentRef.template(this.view._model);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.template = this.componentRef.template;
|
|
43
|
+
}
|
|
44
|
+
let rootRef;
|
|
45
|
+
if (this.componentRef.isShadowDom) {
|
|
46
|
+
if (this.view.shadowRoot /* OPEN MODE */) {
|
|
47
|
+
rootRef = this.view.shadowRoot;
|
|
60
48
|
}
|
|
61
|
-
else {
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
else /* CLOSED MODE*/ {
|
|
50
|
+
rootRef = Reflect.get(this.view, '_shadowRoot');
|
|
51
|
+
Reflect.deleteProperty(this.view, '_shadowRoot');
|
|
64
52
|
}
|
|
65
|
-
rootRef.append(rootFragment);
|
|
66
53
|
}
|
|
54
|
+
else {
|
|
55
|
+
rootRef = this.view;
|
|
56
|
+
}
|
|
57
|
+
this.initTemplateRefMap(this.template);
|
|
58
|
+
let rootFragment;
|
|
59
|
+
if (this.template instanceof DomFragmentNode) {
|
|
60
|
+
rootFragment = this.createDocumentFragment(this.template, this.contextStack, rootRef, this.subscriptions, this.view);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
rootFragment = document.createDocumentFragment();
|
|
64
|
+
this.appendChildToParent(rootFragment, this.template, this.contextStack, rootRef, this.subscriptions, this.view);
|
|
65
|
+
}
|
|
66
|
+
rootRef.append(rootFragment);
|
|
67
67
|
}
|
|
68
68
|
isTemplateRefName(template) {
|
|
69
69
|
if (template instanceof DomElementNode) {
|
|
@@ -74,24 +74,24 @@ export class ComponentRender {
|
|
|
74
74
|
return false;
|
|
75
75
|
}
|
|
76
76
|
initTemplateRefMap(domNode) {
|
|
77
|
-
if (domNode instanceof DomElementNode || domNode instanceof DomFragmentNode) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
77
|
+
if (!(domNode instanceof DomElementNode || domNode instanceof DomFragmentNode) || !domNode.children) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
for (let index = 0; index < domNode.children.length; index++) {
|
|
81
|
+
const child = domNode.children[index];
|
|
82
|
+
if (this.isTemplateRefName(child)) {
|
|
83
|
+
this.templateNameScope.set(child.templateRefName.name, undefined);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.initTemplateRefMap(child);
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
initViewBinding() {
|
|
91
|
+
if (!this.componentRef.viewBindings) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.initHtmlElement(this.view, this.componentRef.viewBindings, this.contextStack, this.subscriptions);
|
|
95
95
|
}
|
|
96
96
|
addNativeEventListener(source, eventName, funcCallback) {
|
|
97
97
|
source.addEventListener(eventName, (event) => {
|
|
@@ -103,31 +103,36 @@ export class ComponentRender {
|
|
|
103
103
|
}
|
|
104
104
|
createStructuralDirective(directive, comment, directiveStack, subscriptions, parentNode, host) {
|
|
105
105
|
const directiveRef = ClassRegistryProvider.getDirectiveRef(directive.name);
|
|
106
|
-
if (directiveRef) {
|
|
107
|
-
const stack = directiveStack.copyStack();
|
|
108
|
-
const templateRef = new TemplateRefImpl(this, directive.node, stack, directive.templateExpressions ?? []);
|
|
109
|
-
const viewContainerRef = new ViewContainerRefImpl(parentNode, comment);
|
|
110
|
-
// structural directive selector
|
|
111
|
-
const StructuralDirectiveClass = directiveRef.modelClass;
|
|
112
|
-
const structural = new StructuralDirectiveClass(templateRef, viewContainerRef, host);
|
|
113
|
-
templateRef.host = structural;
|
|
114
|
-
const scope = ReactiveScope.readOnlyScopeForThis(structural);
|
|
115
|
-
stack.pushScope(scope);
|
|
116
|
-
const dSubs = this.initStructuralDirective(structural, directive, stack);
|
|
117
|
-
subscriptions.push(...dSubs);
|
|
118
|
-
if (isOnInit(structural)) {
|
|
119
|
-
structural.onInit();
|
|
120
|
-
}
|
|
121
|
-
if (directive.attributeDirectives?.length) {
|
|
122
|
-
this.initAttributeDirectives(directive.attributeDirectives, structural, stack, subscriptions);
|
|
123
|
-
}
|
|
124
|
-
if (isOnDestroy(structural)) {
|
|
125
|
-
subscriptions.push(createSubscriptionDestroyer(() => structural.onDestroy()));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
106
|
+
if (!directiveRef) {
|
|
129
107
|
// didn't find directive or it is not define yet.
|
|
130
108
|
// class registry should have 'when defined' callback
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const stack = directiveStack.copyStack();
|
|
112
|
+
const templateRef = new TemplateRefImpl(this, directive.node, stack, directive.templateExpressions ?? []);
|
|
113
|
+
const directiveZone = this.view._zone.fork(directiveRef.zone);
|
|
114
|
+
const viewContainerRef = new ViewContainerRefImpl(parentNode, comment);
|
|
115
|
+
directiveZone.onEmpty.subscribe(() => {
|
|
116
|
+
const length = viewContainerRef.length;
|
|
117
|
+
for (let index = 0; index < length; index++) {
|
|
118
|
+
viewContainerRef.get(index)?.detectChanges();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const StructuralDirectiveClass = directiveRef.modelClass;
|
|
122
|
+
const structural = directiveZone.run(() => new StructuralDirectiveClass(templateRef, viewContainerRef, host, directiveZone));
|
|
123
|
+
templateRef.host = structural;
|
|
124
|
+
const scope = ReactiveScope.readOnlyScopeForThis(structural);
|
|
125
|
+
stack.pushScope(scope);
|
|
126
|
+
const dSubs = this.initStructuralDirective(structural, directive, stack);
|
|
127
|
+
subscriptions.push(...dSubs);
|
|
128
|
+
if (isOnInit(structural)) {
|
|
129
|
+
directiveZone.run(structural.onInit, structural);
|
|
130
|
+
}
|
|
131
|
+
if (directive.attributeDirectives?.length) {
|
|
132
|
+
this.initAttributeDirectives(directive.attributeDirectives, structural, stack, subscriptions);
|
|
133
|
+
}
|
|
134
|
+
if (isOnDestroy(structural)) {
|
|
135
|
+
subscriptions.push(createSubscriptionDestroyer(() => structural.onDestroy()));
|
|
131
136
|
}
|
|
132
137
|
}
|
|
133
138
|
createComment(node) {
|
|
@@ -136,7 +141,7 @@ export class ComponentRender {
|
|
|
136
141
|
createText(node) {
|
|
137
142
|
return new Text(node.value);
|
|
138
143
|
}
|
|
139
|
-
createLiveText(textNode, contextStack,
|
|
144
|
+
createLiveText(textNode, contextStack, subscriptions) {
|
|
140
145
|
const liveText = new Text('');
|
|
141
146
|
contextStack = contextStack.copyStack();
|
|
142
147
|
contextStack.pushBlockScopeFor({ this: liveText });
|
|
@@ -163,7 +168,7 @@ export class ComponentRender {
|
|
|
163
168
|
this.templateNameScope.set(templateRefName.name, templateRef);
|
|
164
169
|
return;
|
|
165
170
|
}
|
|
166
|
-
fragmentParent.append(this.createElement(child, contextStack, subscriptions,
|
|
171
|
+
fragmentParent.append(this.createElement(child, contextStack, subscriptions, host));
|
|
167
172
|
}
|
|
168
173
|
else if (child instanceof DomStructuralDirectiveNode) {
|
|
169
174
|
const commentText = child.name + (typeof child.value == 'string' ? (' = ' + child.value) : '');
|
|
@@ -174,7 +179,7 @@ export class ComponentRender {
|
|
|
174
179
|
this.createStructuralDirective(child, comment, contextStack, subscriptions, parentNode, host);
|
|
175
180
|
}
|
|
176
181
|
else if (isLiveTextContent(child)) {
|
|
177
|
-
fragmentParent.append(this.createLiveText(child, contextStack,
|
|
182
|
+
fragmentParent.append(this.createLiveText(child, contextStack, subscriptions));
|
|
178
183
|
}
|
|
179
184
|
else if (child instanceof TextContent) {
|
|
180
185
|
fragmentParent.append(this.createText(child));
|
|
@@ -213,8 +218,12 @@ export class ComponentRender {
|
|
|
213
218
|
}
|
|
214
219
|
return element;
|
|
215
220
|
}
|
|
216
|
-
createElement(node, contextStack, subscriptions,
|
|
221
|
+
createElement(node, contextStack, subscriptions, host) {
|
|
217
222
|
const element = this.createElementByTagName(node);
|
|
223
|
+
this.initHtmlElement(element, node, contextStack, subscriptions, host);
|
|
224
|
+
return element;
|
|
225
|
+
}
|
|
226
|
+
initHtmlElement(element, node, contextStack, subscriptions, host) {
|
|
218
227
|
const elementStack = contextStack.copyStack();
|
|
219
228
|
const elementScope = isHTMLComponent(element)
|
|
220
229
|
? element._viewScope
|
|
@@ -245,25 +254,39 @@ export class ComponentRender {
|
|
|
245
254
|
if (node.attributeDirectives?.length) {
|
|
246
255
|
this.initAttributeDirectives(node.attributeDirectives, element, contextStack, subscriptions);
|
|
247
256
|
}
|
|
248
|
-
return element;
|
|
249
257
|
}
|
|
250
258
|
initAttributeDirectives(attributeDirectives, element, contextStack, subscriptions) {
|
|
251
259
|
attributeDirectives?.forEach(directiveNode => {
|
|
252
260
|
const directiveRef = ClassRegistryProvider.getDirectiveRef(directiveNode.name);
|
|
253
|
-
if (directiveRef
|
|
254
|
-
(directiveRef.modelClass.prototype instanceof AttributeDirective
|
|
255
|
-
|| directiveRef.modelClass.prototype instanceof AttributeOnStructuralDirective)) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
261
|
+
if (!directiveRef
|
|
262
|
+
|| !((directiveRef.modelClass.prototype instanceof AttributeDirective)
|
|
263
|
+
|| (directiveRef.modelClass.prototype instanceof AttributeOnStructuralDirective))) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const directiveZone = this.view._zone.fork(directiveRef.zone);
|
|
267
|
+
const directive = directiveZone.run(() => new directiveRef.modelClass(element, directiveZone));
|
|
268
|
+
const stack = contextStack.copyStack();
|
|
269
|
+
const thisScope = stack.pushReactiveScopeFor({ 'this': directive });
|
|
270
|
+
const directiveSubscriptions = this.initStructuralDirective(directive, directiveNode, stack);
|
|
271
|
+
subscriptions.push(...directiveSubscriptions);
|
|
272
|
+
if (isOnInit(directive)) {
|
|
273
|
+
directiveZone.run(directive.onInit, directive);
|
|
274
|
+
}
|
|
275
|
+
if (isOnDestroy(directive)) {
|
|
276
|
+
subscriptions.push(createSubscriptionDestroyer(() => directive.onDestroy()));
|
|
277
|
+
}
|
|
278
|
+
if (!(element instanceof HTMLElement)) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const attributeName = directiveRef.selector.replace(/[A-Z]/g, m => '-' + m.toLowerCase());
|
|
282
|
+
if (!element.hasAttribute(attributeName)) {
|
|
283
|
+
element.setAttribute(attributeName, '');
|
|
284
|
+
}
|
|
285
|
+
if (directiveRef.viewBindings) {
|
|
286
|
+
const directiveStack = stack.copyStack();
|
|
287
|
+
const directiveScope = thisScope.getInnerScope('this');
|
|
288
|
+
directiveStack.pushScope(directiveScope);
|
|
289
|
+
this.initHtmlElement(element, directiveRef.viewBindings, directiveStack, subscriptions);
|
|
267
290
|
}
|
|
268
291
|
});
|
|
269
292
|
}
|
|
@@ -272,7 +295,7 @@ export class ComponentRender {
|
|
|
272
295
|
if (node.attributes?.length) {
|
|
273
296
|
node.attributes.forEach(attr => {
|
|
274
297
|
/**
|
|
275
|
-
* <input id="23" name="person-name" />
|
|
298
|
+
* <input id="23" name="person-name" data-id="1234567890" data-user="carinaanand" data-date-of-birth />
|
|
276
299
|
*/
|
|
277
300
|
const isAttr = hasAttr(element, attr.name);
|
|
278
301
|
if (isAttr) {
|
package/view/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/view/render.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,MAA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C,YAAY,CAAC,CAAC;gBACpD,aAAa,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBAC3B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;SACH;QACD,SAAS;QACT,qBAAqB;QACrB,OAAO,aAAa,CAAC;IACtB,CAAC;CAED","sourcesContent":["import {\n\tReactiveScope, Context, ScopeSubscription, Stack\n} from '@ibyar/expressions';\nimport {\n\tCommentNode, DomStructuralDirectiveNode,\n\tDomElementNode, DomFragmentNode, DomNode, isLiveTextContent,\n\tisTagNameNative, isValidCustomElementName, LiveTextContent,\n\tTextContent, DomAttributeDirectiveNode, isFormAssociatedCustomElementByTag\n} from '@ibyar/elements';\nimport type { DomStructuralDirectiveNodeUpgrade } from '@ibyar/elements/node.js';\nimport { ComponentRef } from '../component/component.js';\nimport { HTMLComponent, isHTMLComponent } from '../component/custom-element.js';\nimport { documentStack } from '../context/stack.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { isOnDestroy, isOnInit } from '../component/lifecycle.js';\nimport { hasAttr } from '../utils/elements-util.js';\nimport { AttributeDirective, AttributeOnStructuralDirective, StructuralDirective } from '../directive/directive.js';\nimport { TemplateRef, TemplateRefImpl } from '../linker/template-ref.js';\nimport { ViewContainerRefImpl } from '../linker/view-container-ref.js';\nimport { createSubscriptionDestroyer } from '../context/subscription.js';\nimport { HostListenerHandler } from '../render/host-listener.handler.js';\n\ntype ViewContext = { [element: string]: HTMLElement };\n\nfunction getChangeEventName(tagName: string): 'input' | 'change' | undefined {\n\tswitch (true) {\n\t\tcase tagName === 'input':\n\t\t\treturn 'input';\n\t\tcase tagName === 'textarea':\n\t\tcase tagName === 'select':\n\t\tcase isFormAssociatedCustomElementByTag(tagName):\n\t\t\treturn 'change';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\nexport class ComponentRender<T extends object> {\n\tprivate componentRef: ComponentRef<T>;\n\tprivate template: DomNode;\n\tprivate contextStack: Stack;\n\tprivate templateNameScope: ReactiveScope<{ [templateName: string]: TemplateRef }>;\n\tprivate viewScope: ReactiveScope<ViewContext> = new ReactiveScope({});\n\n\tconstructor(public view: HTMLComponent<T>, private subscriptions: ScopeSubscription<Context>[]) {\n\t\tthis.componentRef = this.view.getComponentRef();\n\t\tthis.contextStack = documentStack.copyStack();\n\t\tthis.contextStack.pushScope<Context>(this.view._modelScope);\n\t\tthis.templateNameScope = this.contextStack.pushReactiveScope();\n\t}\n\tinitView(): void {\n\t\tif (this.componentRef.template) {\n\t\t\tif (typeof this.componentRef.template === 'function') {\n\t\t\t\tthis.template = this.componentRef.template(this.view._model);\n\t\t\t} else {\n\t\t\t\tthis.template = this.componentRef.template;\n\t\t\t}\n\n\t\t\tlet rootRef: HTMLElement | ShadowRoot;\n\t\t\tif (this.componentRef.isShadowDom) {\n\t\t\t\tif (this.view.shadowRoot /* OPEN MODE */) {\n\t\t\t\t\trootRef = this.view.shadowRoot;\n\t\t\t\t} else /* CLOSED MODE*/ {\n\t\t\t\t\trootRef = Reflect.get(this.view, '_shadowRoot') as ShadowRoot;\n\t\t\t\t\tReflect.deleteProperty(this.view, '_shadowRoot');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trootRef = this.view;\n\t\t\t}\n\t\t\tthis.initTemplateRefMap(this.template);\n\t\t\tlet rootFragment: DocumentFragment;\n\t\t\tif (this.template instanceof DomFragmentNode) {\n\t\t\t\trootFragment = this.createDocumentFragment(this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t\t} else {\n\t\t\t\trootFragment = document.createDocumentFragment();\n\t\t\t\tthis.appendChildToParent(rootFragment, this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t\t}\n\t\t\trootRef.append(rootFragment);\n\t\t}\n\t}\n\tisTemplateRefName(template: DomNode): template is DomElementNode {\n\t\tif (template instanceof DomElementNode) {\n\t\t\tif (template.tagName === 'template' && template.templateRefName) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tinitTemplateRefMap(domNode: DomNode) {\n\t\tif (domNode instanceof DomElementNode || domNode instanceof DomFragmentNode) {\n\t\t\tif (domNode.children) {\n\t\t\t\tfor (let index = 0; index < domNode.children.length; index++) {\n\t\t\t\t\tconst child = domNode.children[index];\n\t\t\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\t\t\tthis.templateNameScope.set(child.templateRefName!.name, undefined);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.initTemplateRefMap(child);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tinitHostListener(): void {\n\t\tconst handlers = this.componentRef.hostListeners.map(listenerRef => new HostListenerHandler(listenerRef, this.view, this.viewScope));\n\t\thandlers.forEach(handler => handler.onInit());\n\t\thandlers.forEach(handler => this.subscriptions.push(createSubscriptionDestroyer(\n\t\t\t() => handler.onDestroy(),\n\t\t\t() => handler.onDisconnect(),\n\t\t\t() => handler.onConnect(),\n\t\t)));\n\t}\n\taddNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function) {\n\t\tsource.addEventListener(eventName, (event: Event) => {\n\t\t\tthis.view._zone.run(funcCallback as () => void, this.view._model);\n\t\t});\n\t}\n\tgetElementByName(name: string) {\n\t\treturn Reflect.get(this.view, name);\n\t}\n\tcreateStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<Context>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void {\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<T>(directive.name);\n\t\tif (directiveRef) {\n\t\t\tconst stack = directiveStack.copyStack();\n\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\tthis,\n\t\t\t\tdirective.node,\n\t\t\t\tstack,\n\t\t\t\t(directive as DomStructuralDirectiveNodeUpgrade).templateExpressions ?? [],\n\t\t\t);\n\t\t\tconst viewContainerRef = new ViewContainerRefImpl(parentNode as Element, comment);\n\n\t\t\t// structural directive selector\n\t\t\tconst StructuralDirectiveClass = directiveRef.modelClass as typeof StructuralDirective;\n\t\t\tconst structural = new StructuralDirectiveClass(\n\t\t\t\ttemplateRef,\n\t\t\t\tviewContainerRef,\n\t\t\t\thost\n\t\t\t);\n\t\t\ttemplateRef.host = structural;\n\t\t\tconst scope = ReactiveScope.readOnlyScopeForThis(structural);\n\t\t\tstack.pushScope(scope);\n\n\t\t\tconst dSubs = this.initStructuralDirective(structural, directive, stack);\n\t\t\tsubscriptions.push(...dSubs);\n\t\t\tif (isOnInit(structural)) {\n\t\t\t\tstructural.onInit();\n\t\t\t}\n\t\t\tif (directive.attributeDirectives?.length) {\n\t\t\t\tthis.initAttributeDirectives(directive.attributeDirectives, structural, stack, subscriptions);\n\t\t\t}\n\t\t\tif (isOnDestroy(structural)) {\n\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => structural.onDestroy()));\n\t\t\t}\n\t\t} else {\n\t\t\t// didn't find directive or it is not define yet.\n\t\t\t// class registry should have 'when defined' callback\n\t\t}\n\t}\n\tcreateComment(node: CommentNode): Comment {\n\t\treturn document.createComment(`${node.comment}`);\n\t}\n\tcreateText(node: TextContent): Text {\n\t\treturn new Text(node.value);\n\t}\n\tcreateLiveText(textNode: LiveTextContent, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[]): Text {\n\t\tconst liveText = new Text('');\n\t\tcontextStack = contextStack.copyStack();\n\t\tcontextStack.pushBlockScopeFor({ this: liveText });\n\t\tconst textSubscriptions = textNode.expression.subscribe(contextStack, textNode.pipelineNames);\n\t\tsubscriptions.push(...textSubscriptions);\n\t\ttextNode.expression.get(contextStack);\n\t\treturn liveText;\n\t}\n\tcreateDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): DocumentFragment {\n\t\tconst fragment = document.createDocumentFragment();\n\t\tnode.children?.forEach(child => this.appendChildToParent(fragment, child, contextStack, parentNode, subscriptions, host));\n\t\treturn fragment;\n\t}\n\tappendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective) {\n\t\tif (child instanceof DomElementNode) {\n\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\tconst templateRefName = child.templateRefName!;\n\t\t\t\t// const oldRef = this.templateNameScope.get(templateRefName.name);\n\t\t\t\t// if (oldRef) {\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\t// TODO: extract template expression\n\t\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\t\tthis,\n\t\t\t\t\tnew DomFragmentNode(child.children),\n\t\t\t\t\tcontextStack.copyStack(),\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tthis.templateNameScope.set(templateRefName.name, templateRef);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfragmentParent.append(this.createElement(child, contextStack, subscriptions, parentNode, host));\n\t\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\t\tconst commentText = child.name + (typeof child.value == 'string' ? (' = ' + child.value) : '');\n\t\t\tconst comment = document.createComment(`start ${commentText}`);\n\t\t\tfragmentParent.append(comment);\n\t\t\tconst lastComment = document.createComment(`end ${commentText}`);\n\t\t\tcomment.after(lastComment);\n\t\t\tthis.createStructuralDirective(child, comment, contextStack, subscriptions, parentNode, host);\n\t\t} else if (isLiveTextContent(child)) {\n\t\t\tfragmentParent.append(this.createLiveText(child, contextStack, parentNode, subscriptions));\n\t\t} else if (child instanceof TextContent) {\n\t\t\tfragmentParent.append(this.createText(child));\n\t\t} else if (child instanceof CommentNode) {\n\t\t\tfragmentParent.append(this.createComment(child));\n\t\t} else if (child instanceof DomFragmentNode) {\n\t\t\tfragmentParent.append(this.createDocumentFragment(child, contextStack, parentNode, subscriptions, host));\n\t\t}\n\t}\n\tcreateElementByTagName(node: { tagName: string, is?: string }): HTMLElement {\n\t\tlet element: HTMLElement;\n\t\tif (isValidCustomElementName(node.tagName)) {\n\t\t\tconst ViewClass = customElements.get(node.tagName) as ((new () => HTMLElement) | undefined);\n\t\t\tif (ViewClass) {\n\t\t\t\telement = new ViewClass();\n\t\t\t} else {\n\t\t\t\telement = document.createElement(node.tagName);\n\t\t\t\tif (element.constructor.name === 'HTMLElement') {\n\t\t\t\t\tcustomElements.whenDefined(node.tagName).then(() => customElements.upgrade(element));\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isTagNameNative(node.tagName)) {\n\t\t\t// native tags // and custom tags can be used her\n\t\t\telement = document.createElement(node.tagName, node.is ? { is: node.is } : undefined);\n\t\t} else {\n\t\t\t// html unknown element\n\t\t\telement = document.createElement(node.tagName);\n\t\t}\n\t\tif (isHTMLComponent(element)) {\n\t\t\telement.setParentComponent(this.view);\n\t\t}\n\t\treturn element;\n\t}\n\tcreateElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): HTMLElement {\n\t\tconst element = this.createElementByTagName(node);\n\t\tconst elementStack = contextStack.copyStack();\n\t\tconst elementScope = isHTMLComponent(element)\n\t\t\t? element._viewScope\n\t\t\t: ReactiveScope.readOnlyScopeForThis(element);\n\t\telementStack.pushScope<Context>(elementScope);\n\t\tconst attributesSubscriptions = this.initAttribute(element, node, elementStack);\n\t\tsubscriptions.push(...attributesSubscriptions);\n\t\tconst changeEventName = getChangeEventName(node.tagName);\n\t\tif (changeEventName) {\n\t\t\tconst inputScope = elementScope.getInnerScope<ReactiveScope<HTMLInputElement>>('this')!;\n\t\t\tconst listener = (event: HTMLElementEventMap['input' | 'change']) => inputScope.emit('value', (element as HTMLInputElement).value);\n\t\t\telement.addEventListener(changeEventName, listener);\n\t\t}\n\n\t\tconst templateRefName = node.templateRefName;\n\t\tif (templateRefName) {\n\t\t\tReflect.set(this.view, templateRefName.name, element);\n\t\t\tthis.viewScope.set(templateRefName.name, element);\n\t\t\tconst view = this.componentRef.viewChild.find(child => child.selector === templateRefName.name);\n\t\t\tif (view) {\n\t\t\t\tReflect.set(this.view._model, view.modelName, element);\n\t\t\t}\n\t\t}\n\t\tif (node.children) {\n\t\t\tfor (const child of node.children) {\n\t\t\t\tthis.appendChildToParent(element, child, elementStack, element, subscriptions, host);\n\t\t\t}\n\t\t}\n\t\tif (node.attributeDirectives?.length) {\n\t\t\tthis.initAttributeDirectives(node.attributeDirectives, element, contextStack, subscriptions);\n\t\t}\n\t\treturn element;\n\t}\n\tprivate initAttributeDirectives(\n\t\tattributeDirectives: DomAttributeDirectiveNode[],\n\t\telement: HTMLElement | StructuralDirective,\n\t\tcontextStack: Stack, subscriptions: ScopeSubscription<Context>[]) {\n\t\tattributeDirectives?.forEach(directiveNode => {\n\t\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(directiveNode.name);\n\t\t\tif (directiveRef &&\n\t\t\t\t(directiveRef.modelClass.prototype instanceof AttributeDirective\n\t\t\t\t\t|| directiveRef.modelClass.prototype instanceof AttributeOnStructuralDirective\n\t\t\t\t)) {\n\t\t\t\tconst directive = new directiveRef.modelClass(element) as AttributeDirective | AttributeOnStructuralDirective;\n\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\tstack.pushReactiveScopeFor({ 'this': directive });\n\n\t\t\t\tconst directiveSubscriptions = this.initStructuralDirective(directive, directiveNode, stack);\n\t\t\t\tsubscriptions.push(...directiveSubscriptions);\n\t\t\t\tif (isOnInit(directive)) {\n\t\t\t\t\tdirective.onInit();\n\t\t\t\t}\n\t\t\t\tif (isOnDestroy(directive)) {\n\t\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => directive.onDestroy()));\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tinitAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<Context>[] {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => {\n\t\t\t\t/**\n\t\t\t\t * <input id=\"23\" name=\"person-name\" />\n\t\t\t\t */\n\t\t\t\tconst isAttr = hasAttr(element, attr.name);\n\t\t\t\tif (isAttr) {\n\t\t\t\t\tif (attr.value === false) {\n\t\t\t\t\t\telement.removeAttribute(attr.name);\n\t\t\t\t\t} else if (attr.value === true) {\n\t\t\t\t\t\telement.setAttribute(attr.name, '');\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.setAttribute(attr.name, attr.value as string);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tReflect.set(element, attr.name, attr.value);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tlet listener: Function;\n\t\t\t\t/**\n\t\t\t\t * <a (click)=\"onLinkClick($event)\"></a>\n\t\t\t\t * <a @click=\"onLinkClick($event)\"></a>\n\t\t\t\t * <input [(value)]=\"person.name\" />\n\t\t\t\t * <input (value)=\"person.name\" />\n\t\t\t\t * <!-- <input (value)=\"person.name = $event\" /> -->\n\t\t\t\t * \n\t\t\t\t * TODO: diff of event listener and back-way data binding\n\t\t\t\t */\n\t\t\t\tif (typeof event.value === 'string') {\n\t\t\t\t\tlistener = ($event: Event) => {\n\t\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\t\tthis.view._zone.run(event.expression.get, event.expression, [stack]);\n\t\t\t\t\t};\n\t\t\t\t} else /* if (typeof event.sourceHandler === 'function')*/ {\n\t\t\t\t\t// let eventName: keyof HTMLElementEventMap = event.eventName;\n\t\t\t\t\tlistener = event.value;\n\t\t\t\t}\n\t\t\t\telement.addEventListener(event.name as any, listener as any);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\treturn subscriptions;\n\t}\n\tinitStructuralDirective(\n\t\tdirective: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective,\n\t\tnode: DomStructuralDirectiveNode | DomAttributeDirectiveNode,\n\t\tcontextStack: Stack): ScopeSubscription<Context>[] {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => Reflect.set(directive, attr.name, attr.value));\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tconst listener = ($event: Event) => {\n\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\tthis.view._zone.run(event.expression.get, event.expression, [stack]);\n\t\t\t\t};\n\t\t\t\t((<any>directive)[event.name] as any).subscribe(listener);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\t// TODO: \n\t\t// check host binding\n\t\treturn subscriptions;\n\t}\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/view/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAqC,MAAM,oBAAoB,CAAC;AACtF,OAAO,EACN,WAAW,EAAE,0BAA0B,EACvC,cAAc,EAAE,eAAe,EAAW,iBAAiB,EAC3D,eAAe,EAAE,wBAAwB,EACzC,WAAW,EAA6B,kCAAkC,EAC1E,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAiB,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,8BAA8B,EAAuB,MAAM,2BAA2B,CAAC;AACpH,OAAO,EAAe,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAIzE,SAAS,kBAAkB,CAAC,OAAe;IAC1C,QAAQ,IAAI,EAAE;QACb,KAAK,OAAO,KAAK,OAAO;YACvB,OAAO,OAAO,CAAC;QAChB,KAAK,O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KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;gBACtE,CAAC,CAAC;gBACK,SAAU,CAAC,KAAK,CAAC,IAAI,CAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;SACH;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE;YAC/B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACjC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBACpD,aAAa,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBAC3B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;SACH;QACD,SAAS;QACT,qBAAqB;QACrB,OAAO,aAAa,CAAC;IACtB,CAAC;CAED","sourcesContent":["import { ReactiveScope, Context, ScopeSubscription, Stack } from '@ibyar/expressions';\nimport {\n\tCommentNode, DomStructuralDirectiveNode,\n\tDomElementNode, DomFragmentNode, DomNode, isLiveTextContent,\n\tisTagNameNative, isValidCustomElementName, LiveTextContent,\n\tTextContent, DomAttributeDirectiveNode, isFormAssociatedCustomElementByTag\n} from '@ibyar/elements';\nimport type { DomStructuralDirectiveNodeUpgrade } from '@ibyar/elements/node.js';\nimport { ComponentRef } from '../component/component.js';\nimport { HTMLComponent, isHTMLComponent } from '../component/custom-element.js';\nimport { documentStack } from '../context/stack.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { isOnDestroy, isOnInit } from '../component/lifecycle.js';\nimport { hasAttr } from '../utils/elements-util.js';\nimport { AttributeDirective, AttributeOnStructuralDirective, StructuralDirective } from '../directive/directive.js';\nimport { TemplateRef, TemplateRefImpl } from '../linker/template-ref.js';\nimport { ViewContainerRefImpl } from '../linker/view-container-ref.js';\nimport { createSubscriptionDestroyer } from '../context/subscription.js';\n\ntype ViewContext = { [element: string]: HTMLElement };\n\nfunction getChangeEventName(tagName: string): 'input' | 'change' | undefined {\n\tswitch (true) {\n\t\tcase tagName === 'input':\n\t\t\treturn 'input';\n\t\tcase tagName === 'textarea':\n\t\tcase tagName === 'select':\n\t\tcase isFormAssociatedCustomElementByTag(tagName):\n\t\t\treturn 'change';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\nexport class ComponentRender<T extends object> {\n\tprivate componentRef: ComponentRef<T>;\n\tprivate template: DomNode;\n\tprivate contextStack: Stack;\n\tprivate templateNameScope: ReactiveScope<{ [templateName: string]: TemplateRef }>;\n\tprivate viewScope: ReactiveScope<ViewContext> = new ReactiveScope({});\n\n\tconstructor(public view: HTMLComponent<T>, private subscriptions: ScopeSubscription<Context>[]) {\n\t\tthis.componentRef = this.view.getComponentRef();\n\t\tthis.contextStack = documentStack.copyStack();\n\t\tthis.contextStack.pushScope<Context>(this.view._modelScope);\n\t\tthis.templateNameScope = this.contextStack.pushReactiveScope();\n\t}\n\tinitView(): void {\n\t\tif (!this.componentRef.template) {\n\t\t\treturn;\n\t\t}\n\t\tif (typeof this.componentRef.template === 'function') {\n\t\t\tthis.template = this.componentRef.template(this.view._model);\n\t\t} else {\n\t\t\tthis.template = this.componentRef.template;\n\t\t}\n\n\t\tlet rootRef: HTMLElement | ShadowRoot;\n\t\tif (this.componentRef.isShadowDom) {\n\t\t\tif (this.view.shadowRoot /* OPEN MODE */) {\n\t\t\t\trootRef = this.view.shadowRoot;\n\t\t\t} else /* CLOSED MODE*/ {\n\t\t\t\trootRef = Reflect.get(this.view, '_shadowRoot') as ShadowRoot;\n\t\t\t\tReflect.deleteProperty(this.view, '_shadowRoot');\n\t\t\t}\n\t\t} else {\n\t\t\trootRef = this.view;\n\t\t}\n\t\tthis.initTemplateRefMap(this.template);\n\t\tlet rootFragment: DocumentFragment;\n\t\tif (this.template instanceof DomFragmentNode) {\n\t\t\trootFragment = this.createDocumentFragment(this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t} else {\n\t\t\trootFragment = document.createDocumentFragment();\n\t\t\tthis.appendChildToParent(rootFragment, this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t}\n\t\trootRef.append(rootFragment);\n\t}\n\tisTemplateRefName(template: DomNode): template is DomElementNode {\n\t\tif (template instanceof DomElementNode) {\n\t\t\tif (template.tagName === 'template' && template.templateRefName) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tinitTemplateRefMap(domNode: DomNode) {\n\t\tif (!(domNode instanceof DomElementNode || domNode instanceof DomFragmentNode) || !domNode.children) {\n\t\t\treturn;\n\t\t}\n\t\tfor (let index = 0; index < domNode.children.length; index++) {\n\t\t\tconst child = domNode.children[index];\n\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\tthis.templateNameScope.set(child.templateRefName!.name, undefined);\n\t\t\t} else {\n\t\t\t\tthis.initTemplateRefMap(child);\n\t\t\t}\n\t\t}\n\t}\n\tinitViewBinding() {\n\t\tif (!this.componentRef.viewBindings) {\n\t\t\treturn;\n\t\t}\n\t\tthis.initHtmlElement(this.view, this.componentRef.viewBindings, this.contextStack, this.subscriptions);\n\t}\n\taddNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function) {\n\t\tsource.addEventListener(eventName, (event: Event) => {\n\t\t\tthis.view._zone.run(funcCallback as () => void, this.view._model);\n\t\t});\n\t}\n\tgetElementByName(name: string) {\n\t\treturn Reflect.get(this.view, name);\n\t}\n\tcreateStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<Context>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void {\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<T>(directive.name);\n\t\tif (!directiveRef) {\n\t\t\t// didn't find directive or it is not define yet.\n\t\t\t// class registry should have 'when defined' callback\n\t\t\treturn;\n\t\t}\n\t\tconst stack = directiveStack.copyStack();\n\t\tconst templateRef = new TemplateRefImpl(\n\t\t\tthis,\n\t\t\tdirective.node,\n\t\t\tstack,\n\t\t\t(directive as DomStructuralDirectiveNodeUpgrade).templateExpressions ?? [],\n\t\t);\n\t\tconst directiveZone = this.view._zone.fork(directiveRef.zone);\n\t\tconst viewContainerRef = new ViewContainerRefImpl(parentNode as Element, comment);\n\n\t\tdirectiveZone.onEmpty.subscribe(() => {\n\t\t\tconst length = viewContainerRef.length;\n\t\t\tfor (let index = 0; index < length; index++) {\n\t\t\t\tviewContainerRef.get(index)?.detectChanges();\n\t\t\t}\n\t\t});\n\n\t\tconst StructuralDirectiveClass = directiveRef.modelClass as typeof StructuralDirective;\n\t\tconst structural = directiveZone.run(() => new StructuralDirectiveClass(\n\t\t\ttemplateRef,\n\t\t\tviewContainerRef,\n\t\t\thost,\n\t\t\tdirectiveZone,\n\t\t));\n\t\ttemplateRef.host = structural;\n\t\tconst scope = ReactiveScope.readOnlyScopeForThis(structural);\n\t\tstack.pushScope(scope);\n\n\t\tconst dSubs = this.initStructuralDirective(structural, directive, stack);\n\t\tsubscriptions.push(...dSubs);\n\t\tif (isOnInit(structural)) {\n\t\t\tdirectiveZone.run(structural.onInit, structural);\n\t\t}\n\t\tif (directive.attributeDirectives?.length) {\n\t\t\tthis.initAttributeDirectives(directive.attributeDirectives, structural, stack, subscriptions);\n\t\t}\n\t\tif (isOnDestroy(structural)) {\n\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => structural.onDestroy()));\n\t\t}\n\n\t}\n\tcreateComment(node: CommentNode): Comment {\n\t\treturn document.createComment(`${node.comment}`);\n\t}\n\tcreateText(node: TextContent): Text {\n\t\treturn new Text(node.value);\n\t}\n\tcreateLiveText(textNode: LiveTextContent, contextStack: Stack, subscriptions: ScopeSubscription<Context>[]): Text {\n\t\tconst liveText = new Text('');\n\t\tcontextStack = contextStack.copyStack();\n\t\tcontextStack.pushBlockScopeFor({ this: liveText });\n\t\tconst textSubscriptions = textNode.expression.subscribe(contextStack, textNode.pipelineNames);\n\t\tsubscriptions.push(...textSubscriptions);\n\t\ttextNode.expression.get(contextStack);\n\t\treturn liveText;\n\t}\n\tcreateDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): DocumentFragment {\n\t\tconst fragment = document.createDocumentFragment();\n\t\tnode.children?.forEach(child => this.appendChildToParent(fragment, child, contextStack, parentNode, subscriptions, host));\n\t\treturn fragment;\n\t}\n\tappendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective) {\n\t\tif (child instanceof DomElementNode) {\n\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\tconst templateRefName = child.templateRefName!;\n\t\t\t\t// const oldRef = this.templateNameScope.get(templateRefName.name);\n\t\t\t\t// if (oldRef) {\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\t// TODO: extract template expression\n\t\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\t\tthis,\n\t\t\t\t\tnew DomFragmentNode(child.children),\n\t\t\t\t\tcontextStack.copyStack(),\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tthis.templateNameScope.set(templateRefName.name, templateRef);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfragmentParent.append(this.createElement(child, contextStack, subscriptions, host));\n\t\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\t\tconst commentText = child.name + (typeof child.value == 'string' ? (' = ' + child.value) : '');\n\t\t\tconst comment = document.createComment(`start ${commentText}`);\n\t\t\tfragmentParent.append(comment);\n\t\t\tconst lastComment = document.createComment(`end ${commentText}`);\n\t\t\tcomment.after(lastComment);\n\t\t\tthis.createStructuralDirective(child, comment, contextStack, subscriptions, parentNode, host);\n\t\t} else if (isLiveTextContent(child)) {\n\t\t\tfragmentParent.append(this.createLiveText(child, contextStack, subscriptions));\n\t\t} else if (child instanceof TextContent) {\n\t\t\tfragmentParent.append(this.createText(child));\n\t\t} else if (child instanceof CommentNode) {\n\t\t\tfragmentParent.append(this.createComment(child));\n\t\t} else if (child instanceof DomFragmentNode) {\n\t\t\tfragmentParent.append(this.createDocumentFragment(child, contextStack, parentNode, subscriptions, host));\n\t\t}\n\t}\n\tcreateElementByTagName(node: { tagName: string, is?: string }): HTMLElement {\n\t\tlet element: HTMLElement;\n\t\tif (isValidCustomElementName(node.tagName)) {\n\t\t\tconst ViewClass = customElements.get(node.tagName) as ((new () => HTMLElement) | undefined);\n\t\t\tif (ViewClass) {\n\t\t\t\telement = new ViewClass();\n\t\t\t} else {\n\t\t\t\telement = document.createElement(node.tagName);\n\t\t\t\tif (element.constructor.name === 'HTMLElement') {\n\t\t\t\t\tcustomElements.whenDefined(node.tagName).then(() => customElements.upgrade(element));\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isTagNameNative(node.tagName)) {\n\t\t\t// native tags // and custom tags can be used her\n\t\t\telement = document.createElement(node.tagName, node.is ? { is: node.is } : undefined);\n\t\t} else {\n\t\t\t// html unknown element\n\t\t\telement = document.createElement(node.tagName);\n\t\t}\n\t\tif (isHTMLComponent(element)) {\n\t\t\telement.setParentComponent(this.view);\n\t\t}\n\t\treturn element;\n\t}\n\tcreateElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): HTMLElement {\n\t\tconst element = this.createElementByTagName(node);\n\t\tthis.initHtmlElement(element, node, contextStack, subscriptions, host);\n\t\treturn element;\n\t}\n\n\t/**\n\t * use for init host bindings\n\t * @param element \n\t * @param node \n\t * @param contextStack \n\t * @param subscriptions \n\t */\n\tinitHtmlElement(element: HTMLElement, node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[]): void;\n\n\t/**\n\t * use to init a new create html element\n\t * @param element \n\t * @param node \n\t * @param contextStack \n\t * @param subscriptions \n\t * @param host is the direct html element `this.view` or a sub `structural directive` like `*if` or `*for`, etc...\n\t */\n\tinitHtmlElement(element: HTMLElement, node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): void;\n\tinitHtmlElement(element: HTMLElement, node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], host?: HTMLComponent<any> | StructuralDirective): void {\n\t\tconst elementStack = contextStack.copyStack();\n\t\tconst elementScope = isHTMLComponent(element)\n\t\t\t? element._viewScope\n\t\t\t: ReactiveScope.readOnlyScopeForThis(element);\n\t\telementStack.pushScope<Context>(elementScope);\n\t\tconst attributesSubscriptions = this.initAttribute(element, node, elementStack);\n\t\tsubscriptions.push(...attributesSubscriptions);\n\t\tconst changeEventName = getChangeEventName(node.tagName);\n\t\tif (changeEventName) {\n\t\t\tconst inputScope = elementScope.getInnerScope<ReactiveScope<HTMLInputElement>>('this')!;\n\t\t\tconst listener = (event: HTMLElementEventMap['input' | 'change']) => inputScope.emit('value', (element as HTMLInputElement).value);\n\t\t\telement.addEventListener(changeEventName, listener);\n\t\t}\n\n\t\tconst templateRefName = node.templateRefName;\n\t\tif (templateRefName) {\n\t\t\tReflect.set(this.view, templateRefName.name, element);\n\t\t\tthis.viewScope.set(templateRefName.name, element);\n\t\t\tconst view = this.componentRef.viewChild.find(child => child.selector === templateRefName.name);\n\t\t\tif (view) {\n\t\t\t\tReflect.set(this.view._model, view.modelName, element);\n\t\t\t}\n\t\t}\n\t\tif (node.children) {\n\t\t\tfor (const child of node.children) {\n\t\t\t\tthis.appendChildToParent(element, child, elementStack, element, subscriptions, host!);\n\t\t\t}\n\t\t}\n\t\tif (node.attributeDirectives?.length) {\n\t\t\tthis.initAttributeDirectives(node.attributeDirectives, element, contextStack, subscriptions);\n\t\t}\n\t}\n\tprivate initAttributeDirectives(\n\t\tattributeDirectives: DomAttributeDirectiveNode[],\n\t\telement: HTMLElement | StructuralDirective,\n\t\tcontextStack: Stack,\n\t\tsubscriptions: ScopeSubscription<Context>[]) {\n\t\tattributeDirectives?.forEach(directiveNode => {\n\t\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(directiveNode.name);\n\t\t\tif (!directiveRef\n\t\t\t\t|| !((directiveRef.modelClass.prototype instanceof AttributeDirective)\n\t\t\t\t\t|| (directiveRef.modelClass.prototype instanceof AttributeOnStructuralDirective))) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst directiveZone = this.view._zone.fork(directiveRef.zone);\n\t\t\tconst directive = directiveZone.run(() => new directiveRef.modelClass(element, directiveZone) as AttributeDirective | AttributeOnStructuralDirective);\n\t\t\tconst stack = contextStack.copyStack();\n\t\t\tconst thisScope = stack.pushReactiveScopeFor({ 'this': directive });\n\n\t\t\tconst directiveSubscriptions = this.initStructuralDirective(directive, directiveNode, stack);\n\t\t\tsubscriptions.push(...directiveSubscriptions);\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirectiveZone.run(directive.onInit, directive);\n\t\t\t}\n\t\t\tif (isOnDestroy(directive)) {\n\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => directive.onDestroy()));\n\t\t\t}\n\t\t\tif (!(element instanceof HTMLElement)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst attributeName = directiveRef.selector.replace(/[A-Z]/g, m => '-' + m.toLowerCase());\n\t\t\tif (!element.hasAttribute(attributeName)) {\n\t\t\t\telement.setAttribute(attributeName, '');\n\t\t\t}\n\t\t\tif (directiveRef.viewBindings) {\n\t\t\t\tconst directiveStack = stack.copyStack();\n\t\t\t\tconst directiveScope = thisScope.getInnerScope<ReactiveScope<any>>('this')!;\n\t\t\t\tdirectiveStack.pushScope(directiveScope);\n\t\t\t\tthis.initHtmlElement(element, directiveRef.viewBindings, directiveStack, subscriptions);\n\t\t\t}\n\t\t});\n\t}\n\n\tinitAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<Context>[] {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => {\n\t\t\t\t/**\n\t\t\t\t * <input id=\"23\" name=\"person-name\" data-id=\"1234567890\" data-user=\"carinaanand\" data-date-of-birth />\n\t\t\t\t */\n\t\t\t\tconst isAttr = hasAttr(element, attr.name);\n\t\t\t\tif (isAttr) {\n\t\t\t\t\tif (attr.value === false) {\n\t\t\t\t\t\telement.removeAttribute(attr.name);\n\t\t\t\t\t} else if (attr.value === true) {\n\t\t\t\t\t\telement.setAttribute(attr.name, '');\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.setAttribute(attr.name, attr.value as string);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tReflect.set(element, attr.name, attr.value);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tlet listener: Function;\n\t\t\t\t/**\n\t\t\t\t * <a (click)=\"onLinkClick($event)\"></a>\n\t\t\t\t * <a @click=\"onLinkClick($event)\"></a>\n\t\t\t\t * <input [(value)]=\"person.name\" />\n\t\t\t\t * <input (value)=\"person.name\" />\n\t\t\t\t * <!-- <input (value)=\"person.name = $event\" /> -->\n\t\t\t\t * \n\t\t\t\t * TODO: diff of event listener and back-way data binding\n\t\t\t\t */\n\t\t\t\tif (typeof event.value === 'string') {\n\t\t\t\t\tlistener = ($event: Event) => {\n\t\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\t\tthis.view._zone.run(event.expression.get, event.expression, [stack]);\n\t\t\t\t\t};\n\t\t\t\t} else /* if (typeof event.sourceHandler === 'function')*/ {\n\t\t\t\t\t// let eventName: keyof HTMLElementEventMap = event.eventName;\n\t\t\t\t\tlistener = event.value;\n\t\t\t\t}\n\t\t\t\telement.addEventListener(event.name as any, listener as any);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\treturn subscriptions;\n\t}\n\tinitStructuralDirective(\n\t\tdirective: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective,\n\t\tnode: DomStructuralDirectiveNode | DomAttributeDirectiveNode,\n\t\tcontextStack: Stack): ScopeSubscription<Context>[] {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => Reflect.set(directive, attr.name, attr.value));\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tconst listener = ($event: Event) => {\n\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\tthis.view._zone.run(event.expression.get, event.expression, [stack]);\n\t\t\t\t};\n\t\t\t\t((<any>directive)[event.name] as any).subscribe(listener);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\t// TODO: \n\t\t// check host binding\n\t\treturn subscriptions;\n\t}\n\n}\n"]}
|
package/view/utils.js
CHANGED
|
@@ -2,19 +2,19 @@ export function isComponentModelClass(target) {
|
|
|
2
2
|
return Reflect.has(target, 'component');
|
|
3
3
|
}
|
|
4
4
|
export function getComponentView(modelClass, selector) {
|
|
5
|
-
if (isComponentModelClass(modelClass)) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
else {
|
|
14
|
-
viewClassName = Object.keys(modelClass.component)[0];
|
|
5
|
+
if (!isComponentModelClass(modelClass)) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
let viewClassName;
|
|
9
|
+
if (selector) {
|
|
10
|
+
viewClassName = modelClass.component[selector];
|
|
11
|
+
if (!viewClassName) {
|
|
12
|
+
throw new Error(`${modelClass.name} doesn't have ${selector} as view`);
|
|
15
13
|
}
|
|
16
|
-
return Reflect.get(modelClass, viewClassName);
|
|
17
14
|
}
|
|
18
|
-
|
|
15
|
+
else {
|
|
16
|
+
viewClassName = Object.keys(modelClass.component)[0];
|
|
17
|
+
}
|
|
18
|
+
return modelClass[viewClassName];
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=utils.js.map
|
package/view/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/view/utils.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,qBAAqB,CAAC,MAAqB;IAC1D,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAmB,UAAqB,EAAE,QAAiB;IAC1F,IAAI,qBAAqB,CAAC,UAAU,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/view/utils.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,qBAAqB,CAAC,MAAqB;IAC1D,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAmB,UAAqB,EAAE,QAAiB;IAC1F,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE;QACvC,OAAO;KACP;IACD,IAAI,aAAqB,CAAC;IAC1B,IAAI,QAAQ,EAAE;QACb,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,CAAC,IAAI,iBAAiB,QAAQ,UAAU,CAAC,CAAC;SACvE;KACD;SAAM;QACN,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;KACrD;IACD,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import type { HTMLComponent } from '../component/custom-element.js';\nimport type { Constructable } from '../providers/injector.js';\nimport type { TypeOf } from '../utils/typeof.js';\nimport type { ComponentModelClass } from './view.js';\n\nexport function isComponentModelClass(target: Constructable): target is ComponentModelClass {\n\treturn Reflect.has(target, 'component');\n}\n\nexport function getComponentView<T extends object>(modelClass: TypeOf<T>, selector?: string): TypeOf<HTMLComponent<T>> | undefined {\n\tif (!isComponentModelClass(modelClass)) {\n\t\treturn;\n\t}\n\tlet viewClassName: string;\n\tif (selector) {\n\t\tviewClassName = modelClass.component[selector];\n\t\tif (!viewClassName) {\n\t\t\tthrow new Error(`${modelClass.name} doesn't have ${selector} as view`);\n\t\t}\n\t} else {\n\t\tviewClassName = Object.keys(modelClass.component)[0];\n\t}\n\treturn modelClass[viewClassName];\n}\n"]}
|
package/view/view.d.ts
CHANGED
|
@@ -8,12 +8,14 @@ import { Constructable } from '../providers/injector.js';
|
|
|
8
8
|
* @param componentRef
|
|
9
9
|
*/
|
|
10
10
|
export declare function initCustomElementView<T extends Object>(modelClass: TypeOf<T>, componentRef: ComponentRef<T>): TypeOf<HTMLComponent<T>>;
|
|
11
|
-
export
|
|
11
|
+
export type ComponentModelClass = Constructable & {
|
|
12
12
|
[key: string]: string;
|
|
13
13
|
} & {
|
|
14
14
|
component: {
|
|
15
15
|
[key: string]: string;
|
|
16
16
|
};
|
|
17
|
+
} & {
|
|
18
|
+
[key: string]: TypeOf<HTMLComponent<any>>;
|
|
17
19
|
};
|
|
18
20
|
export declare function addViewToModelClass<T extends object>(modelClass: TypeOf<T>, selector: string, viewClass: TypeOf<HTMLComponent<T>>, htmlViewClassName: string): void;
|
|
19
21
|
export declare function buildViewClassNameFromSelector(selector: string): string;
|
package/view/view.js
CHANGED
|
@@ -3,6 +3,7 @@ import { ToCamelCase } from '../utils/utils.js';
|
|
|
3
3
|
import { baseFactoryView } from './base-view.js';
|
|
4
4
|
import { baseFormFactoryView } from './form-view.js';
|
|
5
5
|
import { isComponentModelClass } from './utils.js';
|
|
6
|
+
const FACTORY_CACHE = new WeakMap();
|
|
6
7
|
/**
|
|
7
8
|
*
|
|
8
9
|
* @param modelClass
|
|
@@ -13,7 +14,14 @@ export function initCustomElementView(modelClass, componentRef) {
|
|
|
13
14
|
let viewClass;
|
|
14
15
|
const viewClassName = buildViewClassNameFromSelector(componentRef.selector);
|
|
15
16
|
const htmlViewClassName = `HTML${viewClassName}Element`;
|
|
16
|
-
|
|
17
|
+
let parentClass;
|
|
18
|
+
if (FACTORY_CACHE.has(htmlParent)) {
|
|
19
|
+
parentClass = FACTORY_CACHE.get(htmlParent);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
parentClass = componentRef.formAssociated ? baseFormFactoryView(htmlParent) : baseFactoryView(htmlParent);
|
|
23
|
+
FACTORY_CACHE.set(htmlParent, parentClass);
|
|
24
|
+
}
|
|
17
25
|
viewClass = ({
|
|
18
26
|
[htmlViewClassName]: class extends parentClass {
|
|
19
27
|
constructor() { super(componentRef, modelClass); }
|