@ibyar/core 0.2.0 → 0.3.6
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/LICENSE +1 -1
- package/README.md +18 -0
- package/annotation/decorators.d.ts +1 -1
- package/annotation/decorators.js +12 -2
- package/annotation/decorators.js.map +1 -1
- package/component/component.d.ts +4 -0
- package/component/component.js +45 -24
- package/component/component.js.map +1 -1
- package/component/custom-element.d.ts +6 -0
- package/component/custom-element.js.map +1 -1
- package/component/events.d.ts +1 -1
- package/component/events.js +11 -11
- package/component/events.js.map +1 -1
- package/component/provider.d.ts +12 -0
- package/component/provider.js +29 -0
- package/component/provider.js.map +1 -0
- package/context/stack.d.ts +2 -18
- package/context/stack.js +9 -48
- package/context/stack.js.map +1 -1
- package/directive/directive.d.ts +5 -4
- package/directive/directive.js +3 -0
- package/directive/directive.js.map +1 -1
- package/directive/providers.d.ts +7 -4
- package/directive/providers.js +3 -5
- package/directive/providers.js.map +1 -1
- package/html/expression.js +24 -12
- package/html/expression.js.map +1 -1
- package/html/update.d.ts +12 -0
- package/html/update.js +24 -0
- package/html/update.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +11 -8
- package/pipe/pipe.d.ts +3 -3
- package/pipe/pipe.js +5 -5
- package/pipe/pipe.js.map +1 -1
- package/providers/injector.js.map +1 -1
- package/providers/provider.js +9 -9
- package/providers/provider.js.map +1 -1
- package/view/base-view.js +43 -28
- package/view/base-view.js.map +1 -1
- package/view/form-view.js +1 -1
- package/view/form-view.js.map +1 -1
- package/view/render.d.ts +15 -13
- package/view/render.js +65 -35
- package/view/render.js.map +1 -1
- package/view/view.d.ts +2 -1
- package/view/view.js +26 -33
- package/view/view.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/core/providers/provider.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"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AC9B,OAAO,OAAO,CAAC;aACf;SACD;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,UAAU,CAAI,WAAmB;QAChC,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,UAAU,EAAE;YAC3C,MAAM,UAAU,GAAkB,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YAClF,IAAI,UAAU,CAAC,IAAI,KAAK,WAAW,EAAE;gBACpC,OAAO,UAAU,CAAC;aAClB;SACD;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;CACD;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,aAAa,EAAE,CAAC","sourcesContent":["\nimport {\n\tComponents, ComponentRef, DirectiveRef,\n\tPipeRef, PropertyRef, ServiceRef\n} from '../component/component.js';\nexport type ProviderType = 'component' | 'service' | 'directive' | 'pipe' | 'self';\n\nexport class ClassRegistry {\n\tviewSet: Set<Function> = new Set();\n\tcomponentSet: Set<Function> = new Set();\n\tserviceSet: Set<Function> = new Set();\n\tdirectiveSet: Set<Function> = new Set();\n\tpipeSet: Set<Function> = new Set();\n\n\tregisterView(classRef: Function): void {\n\t\tthis.viewSet.add(classRef);\n\t}\n\tregisterComponent(classRef: Function): void {\n\t\tthis.componentSet.add(classRef);\n\t}\n\tregisterService(classRef: Function): void {\n\t\tthis.serviceSet.add(classRef);\n\t}\n\tregisterDirective(classRef: Function): void {\n\t\tthis.directiveSet.add(classRef);\n\t}\n\tregisterPipe(classRef: Function): void {\n\t\tthis.pipeSet.add(classRef);\n\t}\n\n\thasComponent<T>(selector: string): boolean {\n\t\tfor (const modelClass of this.componentSet) {\n\t\t\tconst componentRef: ComponentRef<T> = Components.getComponentRef(modelClass);\n\t\t\tif (componentRef.selector === selector) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tgetComponentRef<T>(selector: string): ComponentRef<T> | undefined {\n\t\tfor (const modelClass of this.componentSet) {\n\t\t\tconst componentRef: ComponentRef<T> = Components.getComponentRef(modelClass);\n\t\t\tif (componentRef.selector === selector) {\n\t\t\t\treturn componentRef;\n\t\t\t}\n\t\t}\n\t}\n\n\tgetComponent<T>(selector: string) {\n\t\t// this.componentSet.\n\t\tfor (const modelClass of this.componentSet) {\n\t\t\tconst componentRef: ComponentRef<T> = Components.getComponentRef(modelClass);\n\t\t\tif (componentRef.selector === selector) {\n\t\t\t\treturn modelClass;\n\t\t\t}\n\t\t}\n\t}\n\n\tgetComponentView(selector: string) {\n\t\treturn this.getComponentRef(selector)?.viewClass;\n\t}\n\n\thasOutput<T>(model: Object, eventName: string): PropertyRef | false {\n\t\tif (Reflect.has(model, 'bootstrap')) {\n\t\t\tconst componentRef: ComponentRef<T> = Reflect.get(model, 'bootstrap');\n\t\t\tif (componentRef.outputs) {\n\t\t\t\tfor (const out of componentRef.outputs) {\n\t\t\t\t\tif (out.viewAttribute === eventName) {\n\t\t\t\t\t\treturn out;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\thasInput<T>(model: Object, eventName: string): PropertyRef | false {\n\t\tif (Reflect.has(model, 'bootstrap')) {\n\t\t\tconst componentRef: ComponentRef<T> = Reflect.get(model, 'bootstrap');\n\t\t\tif (componentRef.inputs) {\n\t\t\t\tfor (const input of componentRef.inputs) {\n\t\t\t\t\tif (input.viewAttribute === eventName) {\n\t\t\t\t\t\treturn input;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\thasDirective<T>(selector: string): boolean {\n\t\tfor (const directiveClass of this.directiveSet) {\n\t\t\tconst directiveRef: DirectiveRef<T> = Components.getBootstrap(directiveClass.prototype);\n\t\t\tif (directiveRef.selector === selector) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tdirectiveHasInput<T>(input: string): boolean {\n\t\tfor (const directiveClass of this.directiveSet) {\n\t\t\tconst directiveRef: DirectiveRef<T> = Components.getBootstrap(directiveClass.prototype);\n\t\t\tif (directiveRef.inputs?.filter(ref => ref.viewAttribute === input).length > 0) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tgetDirectiveRef<T>(selector: string): DirectiveRef<T> | undefined {\n\t\tfor (const directiveClass of this.directiveSet) {\n\t\t\tconst directiveRef: DirectiveRef<T> = Components.getBootstrap(directiveClass.prototype);\n\t\t\tif (directiveRef.selector === selector) {\n\t\t\t\treturn directiveRef;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\n\tgetPipe<T>(pipeName: string): PipeRef<T> | undefined {\n\t\tfor (const pipeClass of this.pipeSet) {\n\t\t\tconst pipeRef: PipeRef<T> = Components.getBootstrap(pipeClass.prototype);\n\t\t\tif (pipeRef.name === pipeName) {\n\t\t\t\treturn pipeRef;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tgetService<T>(serviceName: string): ServiceRef<T> | undefined {\n\t\tfor (const serviceClass of this.serviceSet) {\n\t\t\tconst serviceRef: ServiceRef<T> = Components.getBootstrap(serviceClass.prototype);\n\t\t\tif (serviceRef.name === serviceName) {\n\t\t\t\treturn serviceRef;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n}\n\nexport const ClassRegistryProvider = new ClassRegistry();\n"]}
|
package/view/base-view.js
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import { isAfterContentChecked, isAfterContentInit, isAfterViewChecked, isAfterViewInit, isDoCheck, isOnChanges, isOnDestroy, isOnInit } from '../component/lifecycle.js';
|
|
2
2
|
import { defineModel } from '../model/change-detection.js';
|
|
3
3
|
import { ComponentRender } from './render.js';
|
|
4
|
+
import { ElementModelReactiveScope } from '../component/provider.js';
|
|
5
|
+
import { ElementReactiveScope } from '../directive/providers.js';
|
|
6
|
+
const FACTORY_CACHE = new WeakMap();
|
|
7
|
+
function defineInstancePropertyMap(instance) {
|
|
8
|
+
if (typeof instance !== 'object') {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const prototype = Object.getPrototypeOf(instance);
|
|
12
|
+
if (!prototype) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const keys = Reflect.getMetadataKeys(prototype);
|
|
16
|
+
keys
|
|
17
|
+
.filter(key => !Reflect.has(instance, key))
|
|
18
|
+
.forEach(key => Reflect.set(instance, key, undefined));
|
|
19
|
+
}
|
|
4
20
|
export function baseFactoryView(htmlElementType) {
|
|
21
|
+
if (FACTORY_CACHE.has(htmlElementType)) {
|
|
22
|
+
return FACTORY_CACHE.get(htmlElementType);
|
|
23
|
+
}
|
|
5
24
|
class CustomView extends htmlElementType {
|
|
6
25
|
constructor(componentRef, modelClass) {
|
|
7
26
|
super();
|
|
@@ -18,13 +37,16 @@ export function baseFactoryView(htmlElementType) {
|
|
|
18
37
|
});
|
|
19
38
|
}
|
|
20
39
|
const model = new modelClass();
|
|
40
|
+
defineInstancePropertyMap(model);
|
|
21
41
|
this._model = defineModel(model);
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.
|
|
42
|
+
this._modelScope = ElementModelReactiveScope.blockScopeFor(this._model);
|
|
43
|
+
this._viewScope = new ElementReactiveScope(this);
|
|
44
|
+
if (this._componentRef.view) {
|
|
45
|
+
Reflect.set(this._model, this._componentRef.view, this);
|
|
46
|
+
}
|
|
47
|
+
this._viewScope.subscribe((viewProperty, oldValue, newValue) => {
|
|
48
|
+
this.setInputValue(viewProperty, newValue);
|
|
49
|
+
});
|
|
28
50
|
this._render = new ComponentRender(this);
|
|
29
51
|
}
|
|
30
52
|
getComponentRef() {
|
|
@@ -72,8 +94,7 @@ export function baseFactoryView(htmlElementType) {
|
|
|
72
94
|
setInputValue(viewProp, value) {
|
|
73
95
|
const inputRef = this.getInput(viewProp);
|
|
74
96
|
if (inputRef) {
|
|
75
|
-
|
|
76
|
-
this._model.emitChangeModel(inputRef.modelProperty);
|
|
97
|
+
this._modelScope.set(inputRef.modelProperty, value);
|
|
77
98
|
}
|
|
78
99
|
}
|
|
79
100
|
hasOutput(viewProp) {
|
|
@@ -91,31 +112,28 @@ export function baseFactoryView(htmlElementType) {
|
|
|
91
112
|
hasProp(propName) {
|
|
92
113
|
return Reflect.has(this._model, propName);
|
|
93
114
|
}
|
|
94
|
-
|
|
115
|
+
setAttributeHelper(attrViewName, value) {
|
|
95
116
|
if (value === null || value === undefined) {
|
|
96
|
-
|
|
117
|
+
this.removeAttribute(attrViewName);
|
|
97
118
|
}
|
|
98
|
-
if (typeof value === 'boolean') {
|
|
119
|
+
else if (typeof value === 'boolean') {
|
|
99
120
|
if (value) {
|
|
100
|
-
|
|
121
|
+
super.setAttribute(attrViewName, '');
|
|
101
122
|
}
|
|
102
123
|
else {
|
|
103
124
|
this.removeAttribute(attrViewName);
|
|
104
125
|
}
|
|
105
126
|
}
|
|
106
127
|
else {
|
|
107
|
-
|
|
128
|
+
super.setAttribute(attrViewName, value);
|
|
108
129
|
}
|
|
109
130
|
}
|
|
110
|
-
|
|
111
|
-
if (value === null || value === undefined) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
131
|
+
setAttribute(attrViewName, value) {
|
|
114
132
|
this.setInputValue(attrViewName, value);
|
|
115
|
-
this.
|
|
133
|
+
this.setAttributeHelper(attrViewName, value);
|
|
116
134
|
}
|
|
117
|
-
|
|
118
|
-
return this.getInputValue(attrViewName);
|
|
135
|
+
getAttribute(attrViewName) {
|
|
136
|
+
return this.getInputValue(attrViewName) ?? super.getAttribute(attrViewName);
|
|
119
137
|
}
|
|
120
138
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
121
139
|
if (newValue === oldValue) {
|
|
@@ -133,8 +151,8 @@ export function baseFactoryView(htmlElementType) {
|
|
|
133
151
|
connectedCallback() {
|
|
134
152
|
this._componentRef.inputs.forEach(input => {
|
|
135
153
|
const inputDefaultValue = this._model[input.modelProperty];
|
|
136
|
-
if (inputDefaultValue !== null
|
|
137
|
-
this.
|
|
154
|
+
if (inputDefaultValue !== null && inputDefaultValue !== undefined) {
|
|
155
|
+
this.setAttributeHelper(input.viewAttribute, inputDefaultValue);
|
|
138
156
|
}
|
|
139
157
|
});
|
|
140
158
|
if (!this.hasParentComponent() && this.attributes.length > 0) {
|
|
@@ -158,9 +176,6 @@ export function baseFactoryView(htmlElementType) {
|
|
|
158
176
|
}
|
|
159
177
|
if (this.childNodes.length === 0) {
|
|
160
178
|
this._render.initView();
|
|
161
|
-
if (this._componentRef.view) {
|
|
162
|
-
Reflect.set(this._model, this._componentRef.view, this);
|
|
163
|
-
}
|
|
164
179
|
this._render.initHostListener();
|
|
165
180
|
}
|
|
166
181
|
if (isAfterViewInit(this._model)) {
|
|
@@ -233,12 +248,11 @@ export function baseFactoryView(htmlElementType) {
|
|
|
233
248
|
if (isOnDestroy(this._model)) {
|
|
234
249
|
this._model.onDestroy();
|
|
235
250
|
}
|
|
236
|
-
console.log('disconnectedCallback');
|
|
237
251
|
this.emitChanges('destroy');
|
|
238
252
|
}
|
|
239
|
-
|
|
253
|
+
addEventListener(eventName, listener, options) {
|
|
240
254
|
if ('on' + eventName in this) {
|
|
241
|
-
|
|
255
|
+
super.addEventListener(eventName, (event) => {
|
|
242
256
|
listener(event);
|
|
243
257
|
}, options);
|
|
244
258
|
return;
|
|
@@ -265,6 +279,7 @@ export function baseFactoryView(htmlElementType) {
|
|
|
265
279
|
}
|
|
266
280
|
}
|
|
267
281
|
;
|
|
282
|
+
FACTORY_CACHE.set(htmlElementType, CustomView);
|
|
268
283
|
return CustomView;
|
|
269
284
|
}
|
|
270
285
|
//# sourceMappingURL=base-view.js.map
|
package/view/base-view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-view.js","sourceRoot":"","sources":["../../../src/core/view/base-view.ts"],"names":[],"mappings":"AACA,OAAO,EACN,qBAAqB,EAAE,kBAAkB,EAAE,k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C7B,IAAI,CAAC,uBAAuB,CAAC,SAAS,EAAE,CAAC,KAAY,EAAE,EAAE;oBACvD,QAAqB,CAAC,KAAK,CAAC,CAAC;gBAC/B,CAAC,EAAE,OAAO,CAAC,CAAC;gBACZ,OAAO;aACP;YACD,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAM,SAAS,CAAC,CAAC;YACzD,IAAI,WAAW,EAAE;gBAEhB,WAAW,CAAC,SAAS,CAAC,CAAC,IAAS,EAAE,EAAE;oBAClC,QAAqB,CAAC,IAAI,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC;aACH;iBACI;gBACJ,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,QAAsB,CAAC,CAAC;aAC9D;QACF,CAAC;QAED,aAAa,CAAC,SAAiB,EAAE,KAAW;YAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAM,SAAS,CAAC,CAAC;YACxD,IAAI,UAAU,EAAE;gBACf,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,OAAO;aACP;QACF,CAAC;QAED,kBAAkB,CAAC,SAAiB,EAAE,KAAW;YAEhD,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC;KACD;IAAA,CAAC;IACF,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport {\n\tisAfterContentChecked, isAfterContentInit, isAfterViewChecked,\n\tisAfterViewInit, isDoCheck, isOnChanges, isOnDestroy, isOnInit\n} from '../component/lifecycle.js';\nimport { ComponentRef, PropertyRef } from '../component/component.js';\nimport { BaseComponent, CustomElement, HTMLComponent } from '../component/custom-element.js';\nimport { EventEmitter } from '../component/events.js';\nimport { defineModel, Model } from '../model/change-detection.js';\nimport { ComponentRender } from './render.js';\n\nexport function baseFactoryView<T extends Object>(htmlElementType: TypeOf<HTMLElement>): TypeOf<HTMLComponent<T>> {\n\tclass CustomView<T> extends htmlElementType implements BaseComponent<T>, CustomElement {\n\t\t_model: T & Model & { [key: string]: any; };\n\t\t_parentComponent: HTMLComponent<object>;\n\t\t_render: ComponentRender<T>;\n\t\t_shadowRoot: ShadowRoot;\n\n\t\t_setAttributeNative: Function;\n\t\t_getAttributeNative: Function;\n\t\t_addEventListenerNative: Function;\n\n\t\t_componentRef: ComponentRef<T>;\n\n\t\tconstructor(componentRef: ComponentRef<T>, modelClass: TypeOf<T>) {\n\t\t\tsuper();\n\t\t\tthis._componentRef = componentRef;\n\t\t\tif (componentRef.isShadowDom) {\n\t\t\t\tthis._shadowRoot = this.attachShadow({\n\t\t\t\t\tmode: componentRef.shadowDomMode,\n\t\t\t\t\tdelegatesFocus: componentRef.shadowDomDelegatesFocus\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst model = new modelClass(/* resolve dependency injection*/);\n\t\t\tthis._model = defineModel(model);\n\n\t\t\tthis._setAttributeNative = this.setAttribute;\n\t\t\tthis._getAttributeNative = this.getAttribute;\n\t\t\tthis._addEventListenerNative = this.addEventListener;\n\n\t\t\tthis.setAttribute = this._setAttribute;\n\t\t\tthis.getAttribute = this._getAttribute;\n\t\t\tthis.addEventListener = this._addEventListener;\n\n\t\t\tthis._render = new ComponentRender(this);\n\t\t}\n\n\t\tdoBlockCallback = (): void => {\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck();\n\t\t\t}\n\t\t};\n\n\t\tgetComponentRef(): ComponentRef<T> {\n\t\t\treturn this._componentRef;\n\t\t}\n\n\t\tsetParentComponent(parent: HTMLComponent<any>): void {\n\t\t\tthis._parentComponent = parent;\n\t\t}\n\n\t\tgetParentComponent(): HTMLComponent<any> {\n\t\t\treturn this._parentComponent;\n\t\t}\n\n\t\thasParentComponent(): boolean {\n\t\t\treturn this._parentComponent ? true : false;\n\t\t}\n\n\t\thasInputStartWith(viewProp: string): boolean {\n\t\t\tlet dotIndex = viewProp.indexOf('.');\n\t\t\tif (dotIndex > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, dotIndex);\n\t\t\t}\n\t\t\treturn this.hasInput(viewProp);\n\t\t}\n\n\t\tgetInputStartWith(viewProp: string): PropertyRef | undefined {\n\t\t\tlet index = viewProp.indexOf('.');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\tindex = viewProp.indexOf('[');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\treturn this.getInput(viewProp);\n\t\t}\n\n\t\thasInput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.inputs.some(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.inputs.find(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInputValue(viewProp: string): any {\n\t\t\tconst inputRef = this.getInput(viewProp);\n\t\t\tif (inputRef) {\n\t\t\t\treturn this._model[inputRef.modelProperty];\n\t\t\t}\n\t\t}\n\n\t\tsetInputValue(viewProp: string, value: any): void {\n\t\t\tconst inputRef = this.getInput(viewProp);\n\t\t\tif (inputRef) {\n\t\t\t\t// console.log('about to change input', inputRef.modelProperty, value);\n\t\t\t\tReflect.set(this._model, inputRef.modelProperty, value);\n\t\t\t\t// this._changeObservable.emit(viewProp);\n\t\t\t\tthis._model.emitChangeModel(inputRef.modelProperty);\n\t\t\t}\n\t\t}\n\n\t\thasOutput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.outputs.some(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetOutput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.outputs.find(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetEventEmitter<V>(viewProp: string): EventEmitter<V> | undefined {\n\t\t\tconst outputRef = this.getOutput(viewProp);\n\t\t\tif (outputRef) {\n\t\t\t\treturn this._model[outputRef.modelProperty] as EventEmitter<V>;\n\t\t\t}\n\t\t}\n\n\t\thasProp(propName: string): boolean {\n\t\t\treturn Reflect.has(this._model, propName);\n\t\t}\n\n\t\t_setAttributeHelper(attrViewName: string, value: any): void {\n\t\t\tif (value === null || value === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (typeof value === 'boolean') {\n\t\t\t\tif (value) {\n\t\t\t\t\tthis._setAttributeNative(attrViewName, '');\n\t\t\t\t} else {\n\t\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis._setAttributeNative(attrViewName, String(value));\n\t\t\t}\n\t\t}\n\n\t\t_setAttribute(attrViewName: string, value: any): void {\n\t\t\tif (value === null || value === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.setInputValue(attrViewName, value);\n\t\t\tthis._setAttributeHelper(attrViewName, value);\n\t\t}\n\n\t\t_getAttribute(attrViewName: string): string | null {\n\t\t\treturn this.getInputValue(attrViewName);\n\t\t}\n\n\t\tattributeChangedCallback(name: string, oldValue: string, newValue: string) {\n\t\t\tif (newValue === oldValue) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// this._changeObservable.emit(name);\n\t\t\tconst inputRef = this.getInput(name);\n\t\t\tif (inputRef) {\n\t\t\t\tthis._model.emitChangeModel(inputRef.modelProperty);\n\t\t\t}\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._model.onChanges();\n\t\t\t}\n\t\t\tthis.doBlockCallback();\n\t\t}\n\n\t\tconnectedCallback() {\n\n\t\t\tthis._componentRef.inputs.forEach(input => {\n\t\t\t\tconst inputDefaultValue = this._model[input.modelProperty];\n\t\t\t\tif (inputDefaultValue !== null || inputDefaultValue !== undefined) {\n\t\t\t\t\tthis._setAttributeHelper(input.viewAttribute, inputDefaultValue);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// if (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t// \tlet oldAttrValues = Array.prototype.slice.call(this.attributes);\n\t\t\t//\toldAttrValues.forEach((attr: Attr) => {\n\t\t\t// \t\tReflect.set(this, attr.name, attr.value);\n\t\t\t// \t});\n\t\t\t// }\n\n\t\t\tif (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t\tlet attrs: Attr[] = Array.prototype.slice.call(this.attributes);\n\t\t\t\tattrs.forEach(attr => this.initOuterAttribute(attr));\n\t\t\t}\n\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._model.onChanges();\n\t\t\t}\n\t\t\tif (isOnInit(this._model)) {\n\t\t\t\tthis._model.onInit();\n\t\t\t}\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck();\n\t\t\t}\n\t\t\tif (isAfterContentInit(this._model)) {\n\t\t\t\tthis._model.afterContentInit();\n\t\t\t}\n\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\tthis._model.afterContentChecked();\n\t\t\t}\n\n\t\t\t// if (!this.hasParentComponent()) {\n\t\t\t// \tArray.prototype.slice.call(this.attributes).forEach((attr: Attr) => {\n\t\t\t// \t\tthis.initOuterAttribute(attr);\n\t\t\t// \t});\n\t\t\t// }\n\n\t\t\t// do once\n\t\t\tif (this.childNodes.length === 0) {\n\t\t\t\t// setup ui view\n\t\t\t\tthis._render.initView();\n\n\t\t\t\t// if model had view decorator\n\t\t\t\tif (this._componentRef.view) {\n\t\t\t\t\t// this._model[componentRef.view] = this;\n\t\t\t\t\tReflect.set(this._model, this._componentRef.view, this);\n\t\t\t\t}\n\n\t\t\t\t// init Host Listener events\n\t\t\t\tthis._render.initHostListener();\n\t\t\t}\n\n\t\t\tif (isAfterViewInit(this._model)) {\n\t\t\t\tthis._model.afterViewInit();\n\t\t\t}\n\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\tthis._model.afterViewChecked();\n\t\t\t}\n\t\t\tthis.doBlockCallback = () => {\n\t\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\t\tthis._model.doCheck();\n\t\t\t\t}\n\t\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\t\tthis._model.afterContentChecked();\n\t\t\t\t}\n\t\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\t\tthis._model.afterViewChecked();\n\t\t\t\t}\n\t\t\t\tthis.emitRootChanges();\n\t\t\t};\n\t\t\tthis.emitRootChanges();\n\t\t}\n\n\t\temitRootChanges(): void {\n\t\t\tthis.emitChanges(...Object.keys(this._model.__observable).filter(event => event !== 'destroy'));\n\t\t}\n\n\t\temitChanges(...events: string[]): void {\n\t\t\tconst sources: any[] = [];\n\t\t\tevents.forEach(key => {\n\t\t\t\tthis._model.emitChangeModel(key, sources);\n\t\t\t});\n\t\t}\n\n\t\tinitOuterAttribute(attr: Attr) {\n\t\t\t// [window, this] scop\n\t\t\tlet elementAttr = attr.name;\n\t\t\tlet modelProperty = attr.value;\n\t\t\tif (elementAttr.startsWith('[')) {\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\tif (Reflect.has(window, modelProperty)) {\n\t\t\t\t\tthis.setInputValue(elementAttr, Reflect.get(window, modelProperty));\n\t\t\t\t}\n\t\t\t\t// else {\n\t\t\t\t// \tlet value: any;\n\t\t\t\t// \tObject.defineProperty(window, modelProperty, {\n\t\t\t\t// \t\tset: (v: any) => {\n\t\t\t\t// \t\t\tvalue = v;\n\t\t\t\t// \t\t\tif (this) {\n\t\t\t\t// \t\t\t\tthis.setInputValue(elementAttr, v);\n\t\t\t\t// \t\t\t\t// fake connect element\n\t\t\t\t// \t\t\t\tthis.connectedCallback();\n\t\t\t\t// \t\t\t}\n\t\t\t\t// \t\t},\n\t\t\t\t// \t\tget: (): any => value\n\t\t\t\t// \t});\n\t\t\t\t// }\n\n\t\t\t}\n\t\t\telse if (elementAttr.startsWith('(')) {\n\t\t\t\t// (elementAttr)=\"modelProperty()\"\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\t// this.handleEvent(element, elementAttr, viewProperty);\n\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\tlet callback: Function = Reflect.get(window, modelProperty);\n\t\t\t\tthis.addEventListener(elementAttr, event => {\n\t\t\t\t\tcallback(event);\n\t\t\t\t});\n\t\t\t} else if (elementAttr.startsWith('on')) {\n\t\t\t\tconst modelEvent = this.getEventEmitter<any>(elementAttr.substring(2));\n\t\t\t\tif (modelEvent) {\n\t\t\t\t\t// modelEvent.subscribe(listener);\n\t\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\t\tlet listener: Function = Reflect.get(window, modelProperty);\n\t\t\t\t\tmodelEvent.subscribe((data: any) => {\n\t\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.setInputValue(attr.name, attr.value);\n\t\t\t}\n\t\t}\n\n\t\tadoptedCallback() {\n\t\t\t// restart the process\n\t\t\tthis.innerHTML = '';\n\t\t\tthis.connectedCallback();\n\t\t}\n\t\tdisconnectedCallback() {\n\t\t\t// notify first, then call model.onDestroy func\n\t\t\t// this._changeObservable.emit('destroy');\n\t\t\tif (isOnDestroy(this._model)) {\n\t\t\t\tthis._model.onDestroy();\n\t\t\t}\n\t\t\tconsole.log('disconnectedCallback');\n\t\t\tthis.emitChanges('destroy');\n\t\t}\n\n\t\t// events api\n\t\t_addEventListener(eventName: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void {\n\t\t\tif ('on' + eventName in this) {\n\t\t\t\tthis._addEventListenerNative(eventName, (event: Event) => {\n\t\t\t\t\t(listener as Function)(event);\n\t\t\t\t}, options);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst modelOutput = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelOutput) {\n\t\t\t\t// modelOutput.subscribe(listener);\n\t\t\t\tmodelOutput.subscribe((data: any) => {\n\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._model.subscribeModel(eventName, listener as () => void);\n\t\t\t}\n\t\t}\n\n\t\ttriggerOutput(eventName: string, value?: any): void {\n\t\t\tconst modelEvent = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelEvent) {\n\t\t\t\tmodelEvent.emit(value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\ttriggerModelChange(eventName: string, value?: any): void {\n\t\t\t// this._changeObservable.emit(eventName, value);\n\t\t\tthis._model.emitChangeModel(eventName);\n\t\t}\n\t};\n\treturn CustomView;\n}\n\n// const CustomViewTypes: WeakMap<TypeOf<HTMLElement>, TypeOf<HTMLComponent<any>>> = new WeakMap();\n// function createViewClass(elementType: TypeOf<HTMLElement>, isForm: boolean) {\n// if (isForm) {\n// let ViewClass = baseFormFactoryView(elementType);\n// CustomViewTypes.set(elementType, ViewClass);\n// return ViewClass;\n// }\n// else {\n// let ViewClass = baseFactoryView(elementType);\n// CustomViewTypes.set(elementType, ViewClass);\n// return ViewClass;\n// }\n// }\n\n// export function getBaseViewClassByHTMLElementType(elementType?: TypeOf<HTMLElement>, isFormAssociated?: boolean) {\n// if (elementType && CustomViewTypes.has(elementType)) {\n// return CustomViewTypes.get(elementType);\n// }\n// // start to created view class\n// else if (!elementType || elementType === HTMLElement) {\n// return createViewClass(HTMLElement, isFormAssociated || false);\n// }\n// if (CustomViewTypes.has(elementType)) {\n// return CustomViewTypes.get(elementType);\n// } else {\n\n// }\n// }\n"]}
|
|
1
|
+
{"version":3,"file":"base-view.js","sourceRoot":"","sources":["../../../src/core/view/base-view.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAC7D,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAC9D,MAAM,2BAA2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AAO;aACP;QACF,CAAC;QAED,kBAAkB,CAAC,SAAiB,EAAE,KAAW;YAEhD,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC;KACD;IAAA,CAAC;IACF,aAAa,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC/C,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { ReactiveScope } from '@ibyar/expressions';\nimport {\n\tisAfterContentChecked, isAfterContentInit, isAfterViewChecked,\n\tisAfterViewInit, isDoCheck, isOnChanges, isOnDestroy, isOnInit\n} from '../component/lifecycle.js';\nimport { ComponentRef, PropertyRef } from '../component/component.js';\nimport { BaseComponent, CustomElement, HTMLComponent } from '../component/custom-element.js';\nimport { EventEmitter } from '../component/events.js';\nimport { defineModel, Model } from '../model/change-detection.js';\nimport { ComponentRender } from './render.js';\nimport { ElementModelReactiveScope } from '../component/provider.js';\nimport { ElementReactiveScope } from '../directive/providers.js';\n\nconst FACTORY_CACHE = new WeakMap<TypeOf<HTMLElement>, TypeOf<HTMLComponent<any>>>();\n\nfunction defineInstancePropertyMap<T extends { [key: string]: any }>(instance: T) {\n\tif (typeof instance !== 'object') {\n\t\treturn;\n\t}\n\tconst prototype = Object.getPrototypeOf(instance);\n\tif (!prototype) {\n\t\treturn;\n\t}\n\tconst keys = Reflect.getMetadataKeys(prototype);\n\tkeys\n\t\t.filter(key => !Reflect.has(instance, key))\n\t\t.forEach(key => Reflect.set(instance, key, undefined));\n}\n\nexport function baseFactoryView<T extends Object>(htmlElementType: TypeOf<HTMLElement>): TypeOf<HTMLComponent<T>> {\n\n\tif (FACTORY_CACHE.has(htmlElementType)) {\n\t\treturn FACTORY_CACHE.get(htmlElementType) as TypeOf<HTMLComponent<T>>;\n\t}\n\tclass CustomView<T> extends htmlElementType implements BaseComponent<T>, CustomElement {\n\t\t_model: T & Model & { [key: string]: any; };\n\t\t_parentComponent: HTMLComponent<object>;\n\t\t_render: ComponentRender<T>;\n\t\t_shadowRoot: ShadowRoot;\n\n\t\t_componentRef: ComponentRef<T>;\n\n\t\t_modelScope: ReactiveScope<T & Model & { [key: string]: any; }>;\n\t\t_viewScope: ElementReactiveScope;\n\n\t\tconstructor(componentRef: ComponentRef<T>, modelClass: TypeOf<T>) {\n\t\t\tsuper();\n\t\t\tthis._componentRef = componentRef;\n\t\t\tif (componentRef.isShadowDom) {\n\t\t\t\tthis._shadowRoot = this.attachShadow({\n\t\t\t\t\tmode: componentRef.shadowDomMode,\n\t\t\t\t\tdelegatesFocus: componentRef.shadowDomDelegatesFocus\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst model = new modelClass(/* resolve dependency injection*/);\n\t\t\tdefineInstancePropertyMap(model);\n\t\t\tthis._model = defineModel(model);\n\n\t\t\tthis._modelScope = ElementModelReactiveScope.blockScopeFor(this._model);\n\t\t\tthis._viewScope = new ElementReactiveScope(this);\n\n\t\t\t// if model had view decorator\n\t\t\tif (this._componentRef.view) {\n\t\t\t\t// this._model[componentRef.view] = this;\n\t\t\t\tReflect.set(this._model, this._componentRef.view, this);\n\t\t\t}\n\t\t\tthis._viewScope.subscribe((viewProperty, oldValue, newValue) => {\n\t\t\t\tthis.setInputValue(viewProperty, newValue);\n\t\t\t});\n\t\t\t// this._modelScope.subscribe((modelProperty, oldValue, newValue) => {\n\t\t\t// \tconsole.log('emit model', modelProperty, oldValue, newValue);\n\t\t\t// \t// this.emitChanges(modelProperty as string);\n\t\t\t// });\n\t\t\tthis._render = new ComponentRender(this);\n\t\t}\n\n\t\tdoBlockCallback = (): void => {\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck();\n\t\t\t}\n\t\t};\n\n\t\tgetComponentRef(): ComponentRef<T> {\n\t\t\treturn this._componentRef;\n\t\t}\n\n\t\tsetParentComponent(parent: HTMLComponent<any>): void {\n\t\t\tthis._parentComponent = parent;\n\t\t}\n\n\t\tgetParentComponent(): HTMLComponent<any> {\n\t\t\treturn this._parentComponent;\n\t\t}\n\n\t\thasParentComponent(): boolean {\n\t\t\treturn this._parentComponent ? true : false;\n\t\t}\n\n\t\thasInputStartWith(viewProp: string): boolean {\n\t\t\tlet dotIndex = viewProp.indexOf('.');\n\t\t\tif (dotIndex > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, dotIndex);\n\t\t\t}\n\t\t\treturn this.hasInput(viewProp);\n\t\t}\n\n\t\tgetInputStartWith(viewProp: string): PropertyRef | undefined {\n\t\t\tlet index = viewProp.indexOf('.');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\tindex = viewProp.indexOf('[');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\treturn this.getInput(viewProp);\n\t\t}\n\n\t\thasInput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.inputs.some(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.inputs.find(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInputValue(viewProp: string): any {\n\t\t\tconst inputRef = this.getInput(viewProp);\n\t\t\tif (inputRef) {\n\t\t\t\treturn this._model[inputRef.modelProperty];\n\t\t\t}\n\t\t}\n\n\t\tsetInputValue(viewProp: PropertyKey, value: any): void {\n\t\t\tconst inputRef = this.getInput(viewProp as string);\n\t\t\tif (inputRef) {\n\t\t\t\t// console.log('about to change input', inputRef.modelProperty, value);\n\t\t\t\t// Reflect.set(this._model, inputRef.modelProperty, value);\n\t\t\t\t// this._model.emitChangeModel(inputRef.modelProperty);\n\t\t\t\tthis._modelScope.set(inputRef.modelProperty, value);\n\t\t\t}\n\t\t}\n\n\t\thasOutput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.outputs.some(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetOutput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.outputs.find(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetEventEmitter<V>(viewProp: string): EventEmitter<V> | undefined {\n\t\t\tconst outputRef = this.getOutput(viewProp);\n\t\t\tif (outputRef) {\n\t\t\t\treturn this._model[outputRef.modelProperty] as EventEmitter<V>;\n\t\t\t}\n\t\t}\n\n\t\thasProp(propName: string): boolean {\n\t\t\treturn Reflect.has(this._model, propName);\n\t\t}\n\n\t\tprivate setAttributeHelper(attrViewName: string, value: any): void {\n\t\t\tif (value === null || value === undefined) {\n\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t}\n\t\t\telse if (typeof value === 'boolean') {\n\t\t\t\tif (value) {\n\t\t\t\t\tsuper.setAttribute(attrViewName, '');\n\t\t\t\t} else {\n\t\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsuper.setAttribute(attrViewName, value);\n\t\t\t}\n\t\t}\n\n\t\tsetAttribute(attrViewName: string, value: any): void {\n\t\t\tthis.setInputValue(attrViewName, value);\n\t\t\tthis.setAttributeHelper(attrViewName, value);\n\t\t}\n\n\t\tgetAttribute(attrViewName: string): string | null {\n\t\t\treturn this.getInputValue(attrViewName) ?? super.getAttribute(attrViewName);\n\t\t}\n\n\t\tattributeChangedCallback(name: string, oldValue: string, newValue: string) {\n\t\t\tif (newValue === oldValue) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// this._changeObservable.emit(name);\n\t\t\tconst inputRef = this.getInput(name);\n\t\t\tif (inputRef) {\n\t\t\t\tthis._model.emitChangeModel(inputRef.modelProperty);\n\t\t\t}\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._model.onChanges();\n\t\t\t}\n\t\t\tthis.doBlockCallback();\n\t\t}\n\n\t\tconnectedCallback() {\n\n\t\t\tthis._componentRef.inputs.forEach(input => {\n\t\t\t\tconst inputDefaultValue = this._model[input.modelProperty];\n\t\t\t\tif (inputDefaultValue !== null && inputDefaultValue !== undefined) {\n\t\t\t\t\tthis.setAttributeHelper(input.viewAttribute, inputDefaultValue);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// if (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t// \tlet oldAttrValues = Array.prototype.slice.call(this.attributes);\n\t\t\t//\toldAttrValues.forEach((attr: Attr) => {\n\t\t\t// \t\tReflect.set(this, attr.name, attr.value);\n\t\t\t// \t});\n\t\t\t// }\n\n\t\t\tif (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t\tlet attrs: Attr[] = Array.prototype.slice.call(this.attributes);\n\t\t\t\tattrs.forEach(attr => this.initOuterAttribute(attr));\n\t\t\t}\n\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._model.onChanges();\n\t\t\t}\n\t\t\tif (isOnInit(this._model)) {\n\t\t\t\tthis._model.onInit();\n\t\t\t}\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck();\n\t\t\t}\n\t\t\tif (isAfterContentInit(this._model)) {\n\t\t\t\tthis._model.afterContentInit();\n\t\t\t}\n\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\tthis._model.afterContentChecked();\n\t\t\t}\n\n\t\t\t// if (!this.hasParentComponent()) {\n\t\t\t// \tArray.prototype.slice.call(this.attributes).forEach((attr: Attr) => {\n\t\t\t// \t\tthis.initOuterAttribute(attr);\n\t\t\t// \t});\n\t\t\t// }\n\n\t\t\t// do once\n\t\t\tif (this.childNodes.length === 0) {\n\t\t\t\t// setup ui view\n\t\t\t\tthis._render.initView();\n\n\t\t\t\t// init Host Listener events\n\t\t\t\tthis._render.initHostListener();\n\t\t\t}\n\n\t\t\tif (isAfterViewInit(this._model)) {\n\t\t\t\tthis._model.afterViewInit();\n\t\t\t}\n\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\tthis._model.afterViewChecked();\n\t\t\t}\n\t\t\tthis.doBlockCallback = () => {\n\t\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\t\tthis._model.doCheck();\n\t\t\t\t}\n\t\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\t\tthis._model.afterContentChecked();\n\t\t\t\t}\n\t\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\t\tthis._model.afterViewChecked();\n\t\t\t\t}\n\t\t\t\tthis.emitRootChanges();\n\t\t\t};\n\t\t\tthis.emitRootChanges();\n\t\t}\n\n\t\temitRootChanges(): void {\n\t\t\tthis.emitChanges(...Object.keys(this._model.__observable).filter(event => event !== 'destroy'));\n\t\t}\n\n\t\temitChanges(...events: string[]): void {\n\t\t\tconst sources: any[] = [];\n\t\t\tevents.forEach(key => {\n\t\t\t\tthis._model.emitChangeModel(key, sources);\n\t\t\t});\n\t\t}\n\n\t\tinitOuterAttribute(attr: Attr) {\n\t\t\t// [window, this] scop\n\t\t\tlet elementAttr = attr.name;\n\t\t\tlet modelProperty = attr.value;\n\t\t\tif (elementAttr.startsWith('[')) {\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\tif (Reflect.has(window, modelProperty)) {\n\t\t\t\t\tthis.setInputValue(elementAttr, Reflect.get(window, modelProperty));\n\t\t\t\t}\n\t\t\t\t// else {\n\t\t\t\t// \tlet value: any;\n\t\t\t\t// \tObject.defineProperty(window, modelProperty, {\n\t\t\t\t// \t\tset: (v: any) => {\n\t\t\t\t// \t\t\tvalue = v;\n\t\t\t\t// \t\t\tif (this) {\n\t\t\t\t// \t\t\t\tthis.setInputValue(elementAttr, v);\n\t\t\t\t// \t\t\t\t// fake connect element\n\t\t\t\t// \t\t\t\tthis.connectedCallback();\n\t\t\t\t// \t\t\t}\n\t\t\t\t// \t\t},\n\t\t\t\t// \t\tget: (): any => value\n\t\t\t\t// \t});\n\t\t\t\t// }\n\n\t\t\t}\n\t\t\telse if (elementAttr.startsWith('(')) {\n\t\t\t\t// (elementAttr)=\"modelProperty()\"\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\t// this.handleEvent(element, elementAttr, viewProperty);\n\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\tlet callback: Function = Reflect.get(window, modelProperty);\n\t\t\t\tthis.addEventListener(elementAttr, event => {\n\t\t\t\t\tcallback(event);\n\t\t\t\t});\n\t\t\t} else if (elementAttr.startsWith('on')) {\n\t\t\t\tconst modelEvent = this.getEventEmitter<any>(elementAttr.substring(2));\n\t\t\t\tif (modelEvent) {\n\t\t\t\t\t// modelEvent.subscribe(listener);\n\t\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\t\tlet listener: Function = Reflect.get(window, modelProperty);\n\t\t\t\t\tmodelEvent.subscribe((data: any) => {\n\t\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.setInputValue(attr.name, attr.value);\n\t\t\t}\n\t\t}\n\n\t\tadoptedCallback() {\n\t\t\t// restart the process\n\t\t\tthis.innerHTML = '';\n\t\t\tthis.connectedCallback();\n\t\t}\n\t\tdisconnectedCallback() {\n\t\t\t// notify first, then call model.onDestroy func\n\t\t\t// this._changeObservable.emit('destroy');\n\t\t\tif (isOnDestroy(this._model)) {\n\t\t\t\tthis._model.onDestroy();\n\t\t\t}\n\t\t\tthis.emitChanges('destroy');\n\t\t}\n\n\t\t// events api\n\t\taddEventListener(eventName: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void {\n\t\t\tif ('on' + eventName in this) {\n\t\t\t\tsuper.addEventListener(eventName, (event: Event) => {\n\t\t\t\t\t(listener as Function)(event);\n\t\t\t\t}, options);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst modelOutput = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelOutput) {\n\t\t\t\t// modelOutput.subscribe(listener);\n\t\t\t\tmodelOutput.subscribe((data: any) => {\n\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._model.subscribeModel(eventName, listener as () => void);\n\t\t\t}\n\t\t}\n\n\t\ttriggerOutput(eventName: string, value?: any): void {\n\t\t\tconst modelEvent = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelEvent) {\n\t\t\t\tmodelEvent.emit(value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\ttriggerModelChange(eventName: string, value?: any): void {\n\t\t\t// this._changeObservable.emit(eventName, value);\n\t\t\tthis._model.emitChangeModel(eventName);\n\t\t}\n\t};\n\tFACTORY_CACHE.set(htmlElementType, CustomView);\n\treturn CustomView;\n}\n\n// const CustomViewTypes: WeakMap<TypeOf<HTMLElement>, TypeOf<HTMLComponent<any>>> = new WeakMap();\n// function createViewClass(elementType: TypeOf<HTMLElement>, isForm: boolean) {\n// if (isForm) {\n// let ViewClass = baseFormFactoryView(elementType);\n// CustomViewTypes.set(elementType, ViewClass);\n// return ViewClass;\n// }\n// else {\n// let ViewClass = baseFactoryView(elementType);\n// CustomViewTypes.set(elementType, ViewClass);\n// return ViewClass;\n// }\n// }\n\n// export function getBaseViewClassByHTMLElementType(elementType?: TypeOf<HTMLElement>, isFormAssociated?: boolean) {\n// if (elementType && CustomViewTypes.has(elementType)) {\n// return CustomViewTypes.get(elementType);\n// }\n// // start to created view class\n// else if (!elementType || elementType === HTMLElement) {\n// return createViewClass(HTMLElement, isFormAssociated || false);\n// }\n// if (CustomViewTypes.has(elementType)) {\n// return CustomViewTypes.get(elementType);\n// } else {\n\n// }\n// }\n"]}
|
package/view/form-view.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { baseFactoryView } from './base-view.js';
|
|
2
2
|
export function baseFormFactoryView(htmlElementType) {
|
|
3
|
-
|
|
3
|
+
const baseViewClass = baseFactoryView(htmlElementType);
|
|
4
4
|
class BaseFormView extends baseViewClass {
|
|
5
5
|
constructor(componentRef, modelClass) {
|
|
6
6
|
super(componentRef, modelClass);
|
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":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,UAAU,mBAAmB,CAAmB,eAAoC;IACzF,
|
|
1
|
+
{"version":3,"file":"form-view.js","sourceRoot":"","sources":["../../../src/core/view/form-view.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,UAAU,mBAAmB,CAAmB,eAAoC;IACzF,MAAM,aAAa,GAAG,eAAe,CAAI,eAAe,CAAC,CAAC;IAC1D,MAAM,YAAgB,SAAQ,aAAa;QAU1C,YAAY,YAA6B,EAAE,UAAqB;YAC/D,KAAK,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QAEjC,CAAC;QAED,sBAAsB,CAAC,IAAqB;YAC3C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,CAAC;QACD,oBAAoB,CAAC,QAAiB;YACrC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,CAAC;QACD,iBAAiB;YAChB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,CAAC;QACD,wBAAwB,CAAC,KAAU,EAAE,IAAgC;YACpE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,CAAC;QAYD,IAAI,QAAQ,CAAC,QAAQ;YACpB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;YAC1B,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,QAAQ;YACX,OAAO,IAAI,CAAC,SAAS,CAAC;QACvB,CAAC;QAED,IAAI,QAAQ,CAAC,QAAQ;YACpB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;YAC1B,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAU5C,CAAC;QAED,IAAI,QAAQ;YACX,OAAO,IAAI,CAAC,SAAS,CAAC;QACvB,CAAC;QAED,IAAI,KAAK,CAAC,KAAU;YACnB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAErB,CAAC;QAED,IAAI,KAAK;YACR,OAAO,IAAI,CAAC,MAAM,CAAC;QACpB,CAAC;;IArEM,2BAAc,GAAG,IAAI,CAAC;IAuE9B,OAAO,YAAY,CAAC;AACrB,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { ComponentRef } from '../component/component.js';\nimport { CustomFormElement, HTMLFormElement, HTMLFormElementComponent } from '../component/custom-element.js';\nimport { baseFactoryView } from './base-view.js';\n\nexport function baseFormFactoryView<T extends Object>(htmlElementType: TypeOf<HTMLElement>): TypeOf<HTMLFormElementComponent<T>> {\n\tconst baseViewClass = baseFactoryView<T>(htmlElementType);\n\tclass BaseFormView<T> extends baseViewClass implements CustomFormElement {\n\n\t\t// Identify the element as a form-associated custom element\n\t\tstatic formAssociated = true;\n\n\t\t_disabled: boolean;\n\t\t_required: boolean;\n\t\t_value: any;\n\n\t\t// private internals_: ElementInternals;\n\t\tconstructor(componentRef: ComponentRef<T>, modelClass: TypeOf<T>) {\n\t\t\tsuper(componentRef, modelClass);\n\t\t\t// this.internals_ = this.attachInternals();\n\t\t}\n\n\t\tformAssociatedCallback(form: HTMLFormElement): void {\n\t\t\tthrow new Error('Method not implemented.');\n\t\t}\n\t\tformDisabledCallback(disabled: boolean): void {\n\t\t\tthrow new Error('Method not implemented.');\n\t\t}\n\t\tformResetCallback(): void {\n\t\t\tthrow new Error('Method not implemented.');\n\t\t}\n\t\tformStateRestoreCallback(value: any, mode: 'restore' | 'autocomplete'): void {\n\t\t\tthrow new Error('Method not implemented.');\n\t\t}\n\n\t\t// get form() { return this.internals_.form; }\n\t\t// get name() { return this.getAttribute('name'); }\n\t\t// get type() { return this.localName; }\n\t\t// get validity() { return this.internals_.validity; }\n\t\t// get validationMessage() { return this.internals_.validationMessage; }\n\t\t// get willValidate() { return this.internals_.willValidate; }\n\n\t\t// checkValidity() { return this.internals_.checkValidity(); }\n\t\t// reportValidity() { return this.internals_.reportValidity(); }\n\n\t\tset disabled(disabled) {\n\t\t\tthis._disabled = disabled;\n\t\t\tthis.toggleAttribute('disabled', disabled);\n\t\t}\n\n\t\tget disabled() {\n\t\t\treturn this._disabled;\n\t\t}\n\n\t\tset required(required) {\n\t\t\tthis._required = required;\n\t\t\tthis.toggleAttribute('required', required);\n\t\t\t// if (!this.value) {\n\t\t\t// this.internals.setValidity({\n\t\t\t// valueMissing: true\n\t\t\t// }, 'This field is required');\n\t\t\t// } else {\n\t\t\t// this.internals.setValidity({\n\t\t\t// valueMissing: false\n\t\t\t// });\n\t\t\t// }\n\t\t}\n\n\t\tget required() {\n\t\t\treturn this._required;\n\t\t}\n\n\t\tset value(value: any) {\n\t\t\tthis._value = value;\n\t\t\t// this.internals.setFormValue(value);\n\t\t}\n\n\t\tget value() {\n\t\t\treturn this._value;\n\t\t}\n\t}\n\treturn BaseFormView;\n}\n"]}
|
package/view/render.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExpressionNode,
|
|
1
|
+
import { ExpressionNode, Stack } from '@ibyar/expressions';
|
|
2
2
|
import { CommentNode, DOMDirectiveNode, DOMElementNode, DOMFragmentNode, DOMNode, LiveAttribute, LiveTextContent, TextContent } from '@ibyar/elements';
|
|
3
3
|
import { ComponentRef, ListenerRef } from '../component/component.js';
|
|
4
4
|
import { ElementMutation } from './mutation.js';
|
|
@@ -8,25 +8,27 @@ export declare class ComponentRender<T> {
|
|
|
8
8
|
view: HTMLComponent<T>;
|
|
9
9
|
componentRef: ComponentRef<T>;
|
|
10
10
|
template: DOMNode<ExpressionNode>;
|
|
11
|
-
templateRegExp: RegExp;
|
|
12
11
|
nativeElementMutation: ElementMutation;
|
|
13
|
-
contextStack:
|
|
12
|
+
contextStack: Stack;
|
|
13
|
+
templateRefMap: Map<string, DOMElementNode<ExpressionNode>>;
|
|
14
14
|
constructor(view: HTMLComponent<T>);
|
|
15
15
|
initView(): void;
|
|
16
|
+
isTemplateRefName(template: DOMNode<ExpressionNode>): template is DOMElementNode<ExpressionNode>;
|
|
17
|
+
initTemplateRefMap(domNode: DOMNode<ExpressionNode>): void;
|
|
16
18
|
initHostListener(): void;
|
|
17
19
|
handelHostListener(listener: ListenerRef): void;
|
|
18
20
|
addNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function): void;
|
|
19
21
|
getElementByName(name: string): any;
|
|
20
|
-
createDirective(directive: DOMDirectiveNode<ExpressionNode>, comment: Comment, directiveStack:
|
|
22
|
+
createDirective(directive: DOMDirectiveNode<ExpressionNode>, comment: Comment, directiveStack: Stack): void;
|
|
21
23
|
createComment(node: CommentNode): Comment;
|
|
22
24
|
createText(node: TextContent): Text;
|
|
23
|
-
createLiveText(textNode: LiveTextContent<ExpressionNode>, contextStack:
|
|
24
|
-
createDocumentFragment(node: DOMFragmentNode<ExpressionNode>, contextStack:
|
|
25
|
-
appendChildToParent(parent: HTMLElement | DocumentFragment, child: DOMNode<ExpressionNode>, contextStack:
|
|
26
|
-
createElementByTagName(node: DOMElementNode<ExpressionNode
|
|
27
|
-
createElement(node: DOMElementNode<ExpressionNode>, contextStack:
|
|
28
|
-
initAttribute(element: HTMLElement, node: DOMElementNode<ExpressionNode>, contextStack:
|
|
29
|
-
bind1Way(element: HTMLElement | Text, attr: LiveAttribute<ExpressionNode> | LiveTextContent<ExpressionNode>, contextStack:
|
|
30
|
-
subscribeExpressionNode(node: ExpressionNode, contextStack:
|
|
31
|
-
bind2Way(element: HTMLElement, attr: LiveAttribute<ExpressionNode>, contextStack:
|
|
25
|
+
createLiveText(textNode: LiveTextContent<ExpressionNode>, contextStack: Stack): Text;
|
|
26
|
+
createDocumentFragment(node: DOMFragmentNode<ExpressionNode>, contextStack: Stack): DocumentFragment;
|
|
27
|
+
appendChildToParent(parent: HTMLElement | DocumentFragment, child: DOMNode<ExpressionNode>, contextStack: Stack): void;
|
|
28
|
+
createElementByTagName(node: DOMElementNode<ExpressionNode>): HTMLElement;
|
|
29
|
+
createElement(node: DOMElementNode<ExpressionNode>, contextStack: Stack): HTMLElement;
|
|
30
|
+
initAttribute(element: HTMLElement, node: DOMElementNode<ExpressionNode>, contextStack: Stack): void;
|
|
31
|
+
bind1Way(element: HTMLElement | Text, attr: LiveAttribute<ExpressionNode> | LiveTextContent<ExpressionNode>, contextStack: Stack): void;
|
|
32
|
+
subscribeExpressionNode(node: ExpressionNode, contextStack: Stack, callback: SourceFollowerCallback, object?: object, attrName?: string): void;
|
|
33
|
+
bind2Way(element: HTMLElement, attr: LiveAttribute<ExpressionNode>, contextStack: Stack): void;
|
|
32
34
|
}
|
package/view/render.js
CHANGED
|
@@ -7,7 +7,7 @@ import { isOnDestroy, isOnInit } from '../component/lifecycle.js';
|
|
|
7
7
|
import { hasAttr } from '../utils/elements-util.js';
|
|
8
8
|
import { addChangeListener, isModel, subscribe1way, subscribe2way } from '../model/change-detection.js';
|
|
9
9
|
import { AsyncPipeProvider, PipeProvider } from '../pipe/pipe.js';
|
|
10
|
-
import {
|
|
10
|
+
import { ElementReactiveScope } from '../directive/providers.js';
|
|
11
11
|
function getChangeEventName(element, elementAttr) {
|
|
12
12
|
if (elementAttr === 'value') {
|
|
13
13
|
if (element instanceof HTMLInputElement) {
|
|
@@ -23,11 +23,12 @@ function getChangeEventName(element, elementAttr) {
|
|
|
23
23
|
export class ComponentRender {
|
|
24
24
|
constructor(view) {
|
|
25
25
|
this.view = view;
|
|
26
|
+
this.templateRefMap = new Map();
|
|
26
27
|
this.componentRef = this.view.getComponentRef();
|
|
27
|
-
this.
|
|
28
|
-
this.contextStack
|
|
29
|
-
this.contextStack.
|
|
30
|
-
this.contextStack.
|
|
28
|
+
this.contextStack = documentStack.copyStack();
|
|
29
|
+
this.contextStack.pushFunctionScope();
|
|
30
|
+
this.contextStack.pushScope(this.view._viewScope);
|
|
31
|
+
this.contextStack.pushScope(this.view._modelScope);
|
|
31
32
|
}
|
|
32
33
|
initView() {
|
|
33
34
|
if (this.componentRef.template) {
|
|
@@ -50,11 +51,40 @@ export class ComponentRender {
|
|
|
50
51
|
else {
|
|
51
52
|
rootRef = this.view;
|
|
52
53
|
}
|
|
54
|
+
this.initTemplateRefMap(this.template);
|
|
53
55
|
const rootFragment = document.createDocumentFragment();
|
|
54
56
|
this.appendChildToParent(rootFragment, this.template, this.contextStack);
|
|
55
57
|
rootRef.append(rootFragment);
|
|
56
58
|
}
|
|
57
59
|
}
|
|
60
|
+
isTemplateRefName(template) {
|
|
61
|
+
if (template instanceof DOMElementNode) {
|
|
62
|
+
if (template.tagName === 'template' && template.templateRefName) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
initTemplateRefMap(domNode) {
|
|
69
|
+
if (domNode instanceof DOMElementNode || domNode instanceof DOMDirectiveNode || domNode instanceof DOMFragmentNode) {
|
|
70
|
+
if (domNode.children) {
|
|
71
|
+
const toRemove = [];
|
|
72
|
+
for (let index = 0; index < domNode.children.length; index++) {
|
|
73
|
+
const child = domNode.children[index];
|
|
74
|
+
if (this.isTemplateRefName(child)) {
|
|
75
|
+
toRemove.unshift({ index, template: child });
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this.initTemplateRefMap(child);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
toRemove.forEach(info => {
|
|
82
|
+
this.templateRefMap.set(info.template.templateRefName.name, info.template);
|
|
83
|
+
domNode.children.splice(info.index, 1);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
58
88
|
initHostListener() {
|
|
59
89
|
this.componentRef.hostListeners?.forEach(listener => this.handelHostListener(listener));
|
|
60
90
|
}
|
|
@@ -113,7 +143,7 @@ export class ComponentRender {
|
|
|
113
143
|
createDirective(directive, comment, directiveStack) {
|
|
114
144
|
const directiveRef = ClassRegistryProvider.getDirectiveRef(directive.directiveName);
|
|
115
145
|
if (directiveRef) {
|
|
116
|
-
const structural = new directiveRef.modelClass(this, comment, directive, directiveStack);
|
|
146
|
+
const structural = new directiveRef.modelClass(this, comment, directive, directiveStack.copyStack());
|
|
117
147
|
if (isOnInit(structural)) {
|
|
118
148
|
structural.onInit();
|
|
119
149
|
}
|
|
@@ -132,13 +162,14 @@ export class ComponentRender {
|
|
|
132
162
|
}
|
|
133
163
|
createLiveText(textNode, contextStack) {
|
|
134
164
|
const liveText = new Text('');
|
|
135
|
-
contextStack = contextStack.
|
|
165
|
+
contextStack = contextStack.copyStack();
|
|
166
|
+
contextStack.pushBlockScopeFor({ this: liveText });
|
|
136
167
|
this.bind1Way(liveText, textNode, contextStack);
|
|
137
168
|
return liveText;
|
|
138
169
|
}
|
|
139
170
|
createDocumentFragment(node, contextStack) {
|
|
140
171
|
const fragment = document.createDocumentFragment();
|
|
141
|
-
node.children.forEach(child => this.appendChildToParent(fragment, child, contextStack)
|
|
172
|
+
node.children.forEach(child => this.appendChildToParent(fragment, child, contextStack));
|
|
142
173
|
return fragment;
|
|
143
174
|
}
|
|
144
175
|
appendChildToParent(parent, child, contextStack) {
|
|
@@ -150,7 +181,7 @@ export class ComponentRender {
|
|
|
150
181
|
parent.append(comment);
|
|
151
182
|
const lastComment = document.createComment(`end ${child.directiveName}: ${child.directiveValue}`);
|
|
152
183
|
comment.after(lastComment);
|
|
153
|
-
this.createDirective(child, comment, contextStack
|
|
184
|
+
this.createDirective(child, comment, contextStack);
|
|
154
185
|
}
|
|
155
186
|
else if (child instanceof LiveTextContent) {
|
|
156
187
|
parent.append(this.createLiveText(child, contextStack));
|
|
@@ -165,19 +196,18 @@ export class ComponentRender {
|
|
|
165
196
|
parent.append(this.createDocumentFragment(child, contextStack));
|
|
166
197
|
}
|
|
167
198
|
}
|
|
168
|
-
createElementByTagName(node
|
|
199
|
+
createElementByTagName(node) {
|
|
169
200
|
let element;
|
|
170
201
|
if (isValidCustomElementName(node.tagName)) {
|
|
171
|
-
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
});
|
|
202
|
+
const ViewClass = customElements.get(node.tagName);
|
|
203
|
+
if (ViewClass) {
|
|
204
|
+
element = new ViewClass();
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
element = document.createElement(node.tagName);
|
|
208
|
+
if (element.constructor.name === 'HTMLElement') {
|
|
209
|
+
customElements.whenDefined(node.tagName).then(() => customElements.upgrade(element));
|
|
210
|
+
}
|
|
181
211
|
}
|
|
182
212
|
}
|
|
183
213
|
else if (isTagNameNative(node.tagName)) {
|
|
@@ -192,19 +222,17 @@ export class ComponentRender {
|
|
|
192
222
|
return element;
|
|
193
223
|
}
|
|
194
224
|
createElement(node, contextStack) {
|
|
195
|
-
const element = this.createElementByTagName(node
|
|
196
|
-
const elContext = new
|
|
197
|
-
contextStack = contextStack.
|
|
198
|
-
contextStack.
|
|
225
|
+
const element = this.createElementByTagName(node);
|
|
226
|
+
const elContext = isHTMLComponent(element) ? element._viewScope : new ElementReactiveScope(element);
|
|
227
|
+
contextStack = contextStack.copyStack();
|
|
228
|
+
contextStack.pushScope(elContext);
|
|
199
229
|
this.initAttribute(element, node, contextStack);
|
|
200
230
|
if (node.templateRefName) {
|
|
201
|
-
|
|
231
|
+
Reflect.set(this.view, node.templateRefName.name, element);
|
|
232
|
+
const view = this.componentRef.viewChild.find(child => child.selector === node.templateRefName.name);
|
|
202
233
|
if (view) {
|
|
203
234
|
Reflect.set(this.view._model, view.modelName, element);
|
|
204
235
|
}
|
|
205
|
-
else {
|
|
206
|
-
view = this.componentRef.viewChild.find(child => child.selector === node.templateRefName.value);
|
|
207
|
-
}
|
|
208
236
|
}
|
|
209
237
|
if (node.children) {
|
|
210
238
|
for (const child of node.children) {
|
|
@@ -248,7 +276,9 @@ export class ComponentRender {
|
|
|
248
276
|
let listener;
|
|
249
277
|
if (typeof event.value === 'string') {
|
|
250
278
|
listener = ($event) => {
|
|
251
|
-
|
|
279
|
+
const stack = contextStack.copyStack();
|
|
280
|
+
stack.pushBlockScopeFor({ $event });
|
|
281
|
+
event.expression.get(stack, this.view._model);
|
|
252
282
|
};
|
|
253
283
|
}
|
|
254
284
|
else {
|
|
@@ -271,8 +301,8 @@ export class ComponentRender {
|
|
|
271
301
|
callback();
|
|
272
302
|
}
|
|
273
303
|
subscribeExpressionNode(node, contextStack, callback, object, attrName) {
|
|
274
|
-
node.
|
|
275
|
-
const context = contextStack.
|
|
304
|
+
node.events().forEach(eventName => {
|
|
305
|
+
const context = contextStack.findScope(eventName)?.getContext();
|
|
276
306
|
if (context) {
|
|
277
307
|
if (AsyncPipeProvider.AsyncPipeContext === context) {
|
|
278
308
|
const pipe = contextStack.get(eventName);
|
|
@@ -282,7 +312,7 @@ export class ComponentRender {
|
|
|
282
312
|
}
|
|
283
313
|
const pipeContext = {};
|
|
284
314
|
pipeContext[eventName] = pipe.transform.bind(pipe);
|
|
285
|
-
contextStack.
|
|
315
|
+
contextStack.pushBlockScopeFor(pipeContext);
|
|
286
316
|
}
|
|
287
317
|
else if (PipeProvider.PipeContext !== context) {
|
|
288
318
|
subscribe1way(context, eventName, callback, object, attrName);
|
|
@@ -297,8 +327,8 @@ export class ComponentRender {
|
|
|
297
327
|
const callback2 = () => {
|
|
298
328
|
attr.callbackExpression.get(contextStack);
|
|
299
329
|
};
|
|
300
|
-
attr.expression.
|
|
301
|
-
const context = contextStack.
|
|
330
|
+
attr.expression.events().forEach(eventName => {
|
|
331
|
+
const context = contextStack.findScope(eventName)?.getContext();
|
|
302
332
|
if (context) {
|
|
303
333
|
if (AsyncPipeProvider.AsyncPipeContext === context) {
|
|
304
334
|
const pipe = contextStack.get(eventName);
|
|
@@ -308,7 +338,7 @@ export class ComponentRender {
|
|
|
308
338
|
}
|
|
309
339
|
const pipeContext = {};
|
|
310
340
|
pipeContext[eventName] = pipe.transform.bind(pipe);
|
|
311
|
-
contextStack.
|
|
341
|
+
contextStack.pushBlockScopeFor(pipeContext);
|
|
312
342
|
}
|
|
313
343
|
else if (PipeProvider.PipeContext !== context) {
|
|
314
344
|
subscribe2way(context, eventName, callback1, element, attr.name, callback2);
|