Browse Source
Merge in VISUAL/fineui from ~ZHENFEI.LI/fineui:es6 to es6 * commit '7ae79f12e34d873a2f4c058cf2fe3d880c8eb2a0': KERNEL-14001 refactor: plguin、system等es6
Zhenfei.Li-李振飞
2 years ago
8 changed files with 330 additions and 298 deletions
@ -1,9 +1,21 @@
|
||||
// export * from "../../typescript/core/decorator/decorator.ts";
|
||||
|
||||
import { shortcut as biShortcut, provider as biProvider } from "./5.inject"; |
||||
|
||||
/** |
||||
* 注册widget |
||||
*/ |
||||
import { shortcut as biShortcut } from "./5.inject"; |
||||
export function shortcut() { |
||||
return function decorator(Target) { |
||||
biShortcut(Target.xtype, Target); |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* 注册provider |
||||
*/ |
||||
export function provider() { |
||||
return function decorator(Target) { |
||||
biProvider(Target.xtype, Target); |
||||
}; |
||||
} |
||||
|
@ -1,58 +1,59 @@
|
||||
BI.Fragment = function () { |
||||
}; |
||||
import { isNotNull, isArray, isFunction, isKey, extend } from "./2.base"; |
||||
|
||||
BI.h = function (type, props, children) { |
||||
if (children != null) { |
||||
if (!BI.isArray(children)) { |
||||
export function Fragment () {} |
||||
|
||||
export function h (type, props, children) { |
||||
if (isNotNull(children)) { |
||||
if (!isArray(children)) { |
||||
children = [children]; |
||||
} |
||||
} else { |
||||
children = []; |
||||
} |
||||
if (arguments.length > 3) { |
||||
for (var i = 3; i < arguments.length; i++) { |
||||
if (BI.isArray(arguments[i])) { |
||||
for (let i = 3; i < arguments.length; i++) { |
||||
if (isArray(arguments[i])) { |
||||
children = children.concat(arguments[i]); |
||||
} else { |
||||
children.push(arguments[i]); |
||||
} |
||||
} |
||||
} |
||||
if (type === BI.Fragment) { |
||||
if (type === Fragment) { |
||||
return children; |
||||
} |
||||
if (BI.isFunction(type)) { |
||||
if (isFunction(type)) { |
||||
type = type.xtype || type; |
||||
} |
||||
if (type === "el") { |
||||
return BI.extend({ |
||||
el: children[0] |
||||
return extend({ |
||||
el: children[0], |
||||
}, props); |
||||
} |
||||
if (type === "left") { |
||||
return BI.extend({ |
||||
left: children |
||||
return extend({ |
||||
left: children, |
||||
}, props); |
||||
} |
||||
if (type === "right") { |
||||
return BI.extend({ |
||||
right: children |
||||
return extend({ |
||||
right: children, |
||||
}, props); |
||||
} |
||||
if (children.length === 1) { |
||||
if (BI.isKey(children[0])) { |
||||
return BI.extend({ |
||||
type: type |
||||
if (isKey(children[0])) { |
||||
return extend({ |
||||
type, |
||||
}, { text: children[0] }, props); |
||||
} |
||||
if (BI.isFunction(children[0])) { |
||||
return BI.extend({ |
||||
type: type |
||||
if (isFunction(children[0])) { |
||||
return extend({ |
||||
type, |
||||
}, { items: children[0] }, props); |
||||
} |
||||
} |
||||
|
||||
return BI.extend({ |
||||
type: type |
||||
return extend({ |
||||
type, |
||||
}, children.length > 0 ? { items: children } : {}, props); |
||||
}; |
||||
} |
||||
|
Loading…
Reference in new issue