dom-render
Advanced tools
Comparing version 1.0.85 to 1.0.86
@@ -1,13 +0,13 @@ | ||
import { Config } from './Config'; | ||
import { Config } from './configs/Config'; | ||
import { ConstructorType } from './types/Types'; | ||
import { RawSet } from './RawSet'; | ||
export declare class DomRender { | ||
static run<T extends object>(obj: T, target?: Node, config?: Config): T; | ||
static run<T extends object>(obj: T, target?: Node | null, oConfig?: Omit<Config, 'window'>): T; | ||
static createComponent(param: { | ||
type: ConstructorType<any>; | ||
type: ConstructorType<any> | any; | ||
tagName?: string; | ||
template?: string; | ||
styles?: string[] | string; | ||
}, config: Config): import("./Config").TargetElement; | ||
static createAttribute(attrName: string, getThisObj: (element: Element, attrValue: string, obj: any, rawSet: RawSet) => any, factory: (element: Element, attrValue: string, obj: any, rawSet: RawSet) => DocumentFragment): import("./Config").TargetAttr; | ||
}): import("./configs/TargetElement").TargetElement; | ||
static createAttribute(attrName: string, getThisObj: (element: Element, attrValue: string, obj: any, rawSet: RawSet) => any, factory: (element: Element, attrValue: string, obj: any, rawSet: RawSet) => DocumentFragment): import("./configs/TargetAttr").TargetAttr; | ||
} |
@@ -22,3 +22,3 @@ "use strict"; | ||
} | ||
DomRender.run = function (obj, target, config) { | ||
DomRender.run = function (obj, target, oConfig) { | ||
var _a, _b, _c; | ||
@@ -33,5 +33,9 @@ var robj = obj; | ||
} | ||
var config = oConfig; | ||
if (!config) { | ||
config = { window: window }; | ||
} | ||
if (config && !config.window) { | ||
config.window = window; | ||
} | ||
config.routerType = config.routerType || 'none'; | ||
@@ -51,8 +55,9 @@ config.messenger = Types_1.DomRenderFinalProxy.final((_a = config.messenger) !== null && _a !== void 0 ? _a : new DefaultMessenger_1.DefaultMessenger(config)); | ||
}; | ||
DomRender.createComponent = function (param, config) { | ||
DomRender.createComponent = function (param) { | ||
var _a, _b; | ||
var component = RawSet_1.RawSet.createComponentTargetElement((_a = param.tagName) !== null && _a !== void 0 ? _a : param.type.name, function (e, o, r2, counstructorParam) { | ||
// console.log('===>', typeof param.type, param.type.name, param.type.constructor.name) | ||
var component = RawSet_1.RawSet.createComponentTargetElement((_a = param.tagName) !== null && _a !== void 0 ? _a : (typeof param.type === 'function' ? param.type.name : param.type.constructor.name), function (e, o, r2, counstructorParam) { | ||
var _a; | ||
return new ((_a = param.type).bind.apply(_a, __spreadArray([void 0], counstructorParam, false)))(); | ||
}, (_b = param.template) !== null && _b !== void 0 ? _b : '', Array.isArray(param.styles) ? param.styles : (param.styles ? [param.styles] : undefined), config); | ||
return typeof param.type === 'function' ? new ((_a = param.type).bind.apply(_a, __spreadArray([void 0], counstructorParam, false)))() : param.type; | ||
}, (_b = param.template) !== null && _b !== void 0 ? _b : '', Array.isArray(param.styles) ? param.styles : (param.styles ? [param.styles] : undefined)); | ||
return component; | ||
@@ -59,0 +64,0 @@ }; |
import { RawSet } from './RawSet'; | ||
import { Config } from './Config'; | ||
import { Config } from './configs/Config'; | ||
export declare class DomRenderProxy<T extends object> implements ProxyHandler<T> { | ||
@@ -10,3 +10,3 @@ _domRender_origin: T; | ||
_targets: Set<Node>; | ||
constructor(_domRender_origin: T, target: Node | undefined, config: Config); | ||
constructor(_domRender_origin: T, target: Node | null | undefined, config: Config); | ||
static unFinal<T = any>(obj: T): T; | ||
@@ -13,0 +13,0 @@ static final<T = any>(obj: T): T; |
@@ -1,2 +0,2 @@ | ||
import { Config } from '../Config'; | ||
import { Config } from '../configs/Config'; | ||
export declare class EventManager { | ||
@@ -3,0 +3,0 @@ static ownerVariablePathAttrName: string; |
@@ -1,4 +0,4 @@ | ||
import { Config } from '../Config'; | ||
import { Config } from '../configs/Config'; | ||
export interface OnProxyDomRender { | ||
onProxyDomRender(config: Config): void; | ||
} |
import { ConstructorType } from '../types/Types'; | ||
import { Config } from '../Config'; | ||
import { Config } from '../configs/Config'; | ||
declare enum CallBackType { | ||
@@ -4,0 +4,0 @@ FILTER = 0, |
@@ -33,3 +33,3 @@ "use strict"; | ||
if (targetElement) { | ||
var documentFragment = targetElement.callBack(this.elementSource.element, this.source.obj, this.rawSet, this.elementSource.attrs); | ||
var documentFragment = targetElement.callBack(this.elementSource.element, this.source.obj, this.rawSet, this.elementSource.attrs, this.source.config); | ||
if (documentFragment) { | ||
@@ -36,0 +36,0 @@ // const targetAttrMap = this.elementSource.element.getAttribute(EventManager.normalAttrMapAttrName); |
import { AttrInitCallBack, Attrs, ElementInitCallBack, RawSet, Render } from '../RawSet'; | ||
import { ComponentSet } from '../components/ComponentSet'; | ||
import { Config } from '../Config'; | ||
import { Config } from '../configs/Config'; | ||
export declare enum ExecuteState { | ||
@@ -5,0 +5,0 @@ EXECUTE = 0, |
{ | ||
"name": "dom-render", | ||
"version": "1.0.85", | ||
"version": "1.0.86", | ||
"main": "DomRender.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -1,3 +0,5 @@ | ||
import { Config, TargetAttr, TargetElement } from './Config'; | ||
import { Config } from './configs/Config'; | ||
import { ComponentSet } from './components/ComponentSet'; | ||
import { TargetElement } from './configs/TargetElement'; | ||
import { TargetAttr } from './configs/TargetAttr'; | ||
export declare enum DestroyOptionType { | ||
@@ -148,3 +150,3 @@ NO_DESTROY = "NO_DESTROY", | ||
static createComponentTargetAttribute(name: string, getThisObj: (element: Element, attrValue: string, obj: any, rawSet: RawSet) => any, factory: (element: Element, attrValue: string, obj: any, rawSet: RawSet) => DocumentFragment): TargetAttr; | ||
static createComponentTargetElement(name: string, objFactory: (element: Element, obj: any, rawSet: RawSet, counstructorParam: any[]) => any, template: string | undefined, styles: string[] | undefined, config: Config): TargetElement; | ||
static createComponentTargetElement(name: string, objFactory: (element: Element, obj: any, rawSet: RawSet, counstructorParam: any[]) => any, template?: string, styles?: string[]): TargetElement; | ||
static isExporesion(data: string | null): boolean; | ||
@@ -151,0 +153,0 @@ static exporesionGrouops(data: string | null): RegExpExecArray[]; |
@@ -672,3 +672,3 @@ "use strict"; | ||
}; | ||
RawSet.createComponentTargetElement = function (name, objFactory, template, styles, config) { | ||
RawSet.createComponentTargetElement = function (name, objFactory, template, styles) { | ||
if (template === void 0) { template = ''; } | ||
@@ -680,3 +680,3 @@ if (styles === void 0) { styles = []; } | ||
template: template, | ||
callBack: function (element, obj, rawSet, attrs) { | ||
callBack: function (element, obj, rawSet, attrs, config) { | ||
var _a, _b, _c, _d, _e, _f; | ||
@@ -683,0 +683,0 @@ // console.log('callback------->', element) |
@@ -10,3 +10,3 @@ DOM-RENDER | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/dom-render@1.0.85/dist/bundle.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/dom-render@1.0.86/dist/bundle.js"></script> | ||
``` | ||
@@ -22,3 +22,3 @@ ```html | ||
${this.name}$ | ||
<script src="https://cdn.jsdelivr.net/npm/dom-render@1.0.85/dist/bundle.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/dom-render@1.0.86/dist/bundle.js"></script> | ||
<script> | ||
@@ -409,5 +409,5 @@ let data = { | ||
config.targetElements = [ | ||
DomRender.createComponent({type: Main, tagName: 'page-main', template: MainTemplate}, config), | ||
DomRender.createComponent({type: Second, tagName: 'page-second', template: SecondTemplate}, config), | ||
DomRender.createComponent({type: Detail, tagName: 'page-detail', template: DetailTemplate}, config) | ||
DomRender.createComponent({type: Main, tagName: 'page-main', template: MainTemplate}), | ||
DomRender.createComponent({type: Second, tagName: 'page-second', template: SecondTemplate}), | ||
DomRender.createComponent({type: Detail, tagName: 'page-detail', template: DetailTemplate}) | ||
] | ||
@@ -650,4 +650,4 @@ config.routerType = 'hash'; // 'hash' | 'path' | 'none'; | ||
config.targetElements = [ | ||
DomRender.createComponent({type: Profile, template: ProfileTemplate}, config), | ||
DomRender.createComponent({type: Home, template: HomeTemplate, styles: HomeStyle}, config) | ||
DomRender.createComponent({type: Profile, template: ProfileTemplate}), | ||
DomRender.createComponent({type: Home, template: HomeTemplate, styles: HomeStyle}) | ||
] | ||
@@ -654,0 +654,0 @@ |
Sorry, the diff of this file is too big to display
555808
165
10482