Browse Source

Merge branch 'master' of ssh://code.fineres.com:7999/~teller/fineui

es6
iapyang 4 years ago
parent
commit
cb4021d91b
  1. 4
      changelog.md
  2. 2
      dist/2.0/fineui.css
  3. 4
      dist/2.0/fineui.ie.min.js
  4. 2
      dist/2.0/fineui.ie.min.js.map
  5. 4001
      dist/2.0/fineui.js
  6. 2
      dist/2.0/fineui.js.map
  7. 2
      dist/2.0/fineui.min.css
  8. 4
      dist/2.0/fineui.min.js
  9. 2
      dist/2.0/fineui.min.js.map
  10. 2
      dist/2.0/fineui_without_normalize.css
  11. 2
      dist/2.0/fineui_without_normalize.min.css
  12. 2
      dist/core.css
  13. 3971
      dist/core.js
  14. 2
      dist/core.js.map
  15. 2
      dist/demo.css
  16. 4333
      dist/demo.js
  17. 2
      dist/demo.js.map
  18. 2
      dist/fineui.css
  19. 4
      dist/fineui.ie.min.js
  20. 2
      dist/fineui.ie.min.js.map
  21. 3991
      dist/fineui.js
  22. 2
      dist/fineui.js.map
  23. 2
      dist/fineui.min.css
  24. 4
      dist/fineui.min.js
  25. 2
      dist/fineui.min.js.map
  26. 2
      dist/fineui.proxy.css
  27. 3277
      dist/fineui.proxy.js
  28. 2
      dist/fineui.proxy.js.map
  29. 2
      dist/fineui.proxy.min.css
  30. 4
      dist/fineui.proxy.min.js
  31. 2
      dist/fineui.proxy.min.js.map
  32. 3199
      dist/fineui_without_jquery_polyfill.js
  33. 2
      dist/fineui_without_jquery_polyfill.js.map
  34. 2
      dist/fineui_without_normalize.min.css
  35. 2
      dist/font.css
  36. 3
      dist/lib/base/single/editor/editor.textarea.d.ts
  37. 2
      dist/lib/core/utils/tree.d.ts
  38. 2
      dist/resource.css
  39. 217
      dist/utils.js
  40. 2
      dist/utils.js.map
  41. 4
      dist/utils.min.js
  42. 2
      dist/utils.min.js.map
  43. 74
      examples/config-render.html
  44. 106
      examples/dev.html
  45. 125
      examples/test-id.html
  46. 89
      examples/virtual-group.html
  47. 220
      examples/visible.html
  48. 18
      examples/插件设计.html
  49. 2
      package.json
  50. 150
      src/base/list/virtualgrouplist.js
  51. 37
      src/base/list/virtuallist.js
  52. 52
      src/core/4.widget.js
  53. 37
      src/core/5.shortcut.js
  54. 203
      src/core/6.inject.js
  55. 21
      src/core/7.plugin.js
  56. 12
      src/core/h.js
  57. 30
      src/core/wrapper/layout.js
  58. 26
      src/core/wrapper/layout/adapt/absolute.leftrightvertical.js
  59. 37
      src/core/wrapper/layout/adapt/adapt.leftrightvertical.js
  60. 15
      src/core/wrapper/layout/flex/flex.leftrightvertical.center.js
  61. 15
      src/core/wrapper/layout/float/float.absolute.leftrightvertical.js
  62. 2
      src/core/wrapper/layout/layout.tape.js
  63. 17
      src/less/core/utils/common.less
  64. 2
      src/snabbdom/element2Snabbdom.js
  65. 0
      src/snabbdom/snabbdom.js
  66. 2
      typescript/core/utils/tree.ts

4
changelog.md

@ -1,4 +1,8 @@
# 更新日志
2.0(2021-09)
- 支持h函数传递left、right,优化left_right_vertical_adapt布局的jsx写法
- 新增bi.virtual_group_list组件
2.0(2021-07)
- layout支持forceUpdate刷新方式
- width属性支持calc()

2
dist/2.0/fineui.css vendored

File diff suppressed because one or more lines are too long

4
dist/2.0/fineui.ie.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/2.0/fineui.ie.min.js.map vendored

File diff suppressed because one or more lines are too long

4001
dist/2.0/fineui.js vendored

File diff suppressed because it is too large Load Diff

2
dist/2.0/fineui.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/2.0/fineui.min.css vendored

File diff suppressed because one or more lines are too long

4
dist/2.0/fineui.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/2.0/fineui.min.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/2.0/fineui_without_normalize.css vendored

File diff suppressed because one or more lines are too long

2
dist/2.0/fineui_without_normalize.min.css vendored

File diff suppressed because one or more lines are too long

2
dist/core.css vendored

File diff suppressed because one or more lines are too long

3971
dist/core.js vendored

File diff suppressed because it is too large Load Diff

2
dist/core.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/demo.css vendored

File diff suppressed because one or more lines are too long

4333
dist/demo.js vendored

File diff suppressed because it is too large Load Diff

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/fineui.css vendored

File diff suppressed because one or more lines are too long

4
dist/fineui.ie.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/fineui.ie.min.js.map vendored

File diff suppressed because one or more lines are too long

3991
dist/fineui.js vendored

File diff suppressed because it is too large Load Diff

2
dist/fineui.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/fineui.min.css vendored

File diff suppressed because one or more lines are too long

4
dist/fineui.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/fineui.min.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/fineui.proxy.css vendored

File diff suppressed because one or more lines are too long

3277
dist/fineui.proxy.js vendored

File diff suppressed because it is too large Load Diff

2
dist/fineui.proxy.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/fineui.proxy.min.css vendored

File diff suppressed because one or more lines are too long

4
dist/fineui.proxy.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/fineui.proxy.min.js.map vendored

File diff suppressed because one or more lines are too long

3199
dist/fineui_without_jquery_polyfill.js vendored

File diff suppressed because it is too large Load Diff

2
dist/fineui_without_jquery_polyfill.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/fineui_without_normalize.min.css vendored

File diff suppressed because one or more lines are too long

2
dist/font.css vendored

File diff suppressed because one or more lines are too long

3
dist/lib/base/single/editor/editor.textarea.d.ts vendored

@ -4,6 +4,9 @@ export declare class TextAreaEditor extends Single {
static EVENT_CHANGE: string;
static EVENT_FOCUS: string;
static EVENT_BLUR: string;
static EVENT_CONFIRM: string;
static EVENT_EMPTY: string;
static EVENT_KEY_DOWN: string;
focus(): void;
blur(): void;
setStyle(style: any): void;

2
dist/lib/core/utils/tree.d.ts vendored

@ -40,7 +40,7 @@ export declare class Tree {
nrPreOrderTraverse(callback: Function): void;
postOrderTraverse(callback: Function): void;
nrPostOrderTraverse(callback: Function): void;
static transformToArrayFormat(nodes: Node | Node[], pId: any): Node[];
static transformToArrayFormat<T>(nodes: T | T[], pId: any, childKey?: string): T[];
static arrayFormat(nodes: Node | Node[], pId: any): Node[];
static transformToTreeFormat<T>(sNodes: T[]): Node[];
static treeFormat(sNodes: Node | Node[]): Node[];

2
dist/resource.css vendored

File diff suppressed because one or more lines are too long

217
dist/utils.js vendored

@ -1,4 +1,4 @@
/*! time: 2021-8-30 19:40:31 */
/*! time: 2021-9-3 15:40:14 */
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
@ -82,12 +82,12 @@
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1281);
/******/ return __webpack_require__(__webpack_require__.s = 1280);
/******/ })
/************************************************************************/
/******/ ({
/***/ 1139:
/***/ 1138:
/***/ (function(module, exports) {
BI.i18n = {
@ -293,7 +293,7 @@ BI.i18n = {
/***/ }),
/***/ 1281:
/***/ 1280:
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(151);
@ -312,8 +312,8 @@ __webpack_require__(175);
__webpack_require__(176);
__webpack_require__(186);
__webpack_require__(187);
__webpack_require__(1139);
__webpack_require__(1282);
__webpack_require__(1138);
__webpack_require__(1281);
__webpack_require__(188);
__webpack_require__(189);
module.exports = __webpack_require__(190);
@ -321,7 +321,7 @@ module.exports = __webpack_require__(190);
/***/ }),
/***/ 1282:
/***/ 1281:
/***/ (function(module, exports) {
/**
@ -2310,85 +2310,163 @@ if (!_global.BI) {
};
var configFunctions = {};
BI.config = BI.config || function (type, configFn, opt) {
opt = opt || {};
// 初始化过或者系统配置需要立刻执行
if (BI.initialized || "bi.provider.system" === type) {
var runConfigFunction = BI.runConfigFunction = function (type) {
if (!type || !configFunctions[type]) {
return false;
}
var queue = configFunctions[type];
delete configFunctions[type];
var dependencies = BI.Providers.getProvider("bi.provider.system").getDependencies();
var modules = moduleInjectionMap.components[type]
|| moduleInjectionMap.constants[type]
|| moduleInjectionMap.services[type]
|| moduleInjectionMap.stores[type]
|| moduleInjectionMap.models[type]
|| moduleInjectionMap.providers[type];
for (var i = 0; i < queue.length; i++) {
var conf = queue[i];
var version = conf.opt.version;
var fn = conf.fn;
if (modules && version) {
var findVersion = false;
for (var j = 0; j < modules.length; j++) {
var module = modules[j];
if (module && dependencies[module.moduleId] && module.version === version) {
var minVersion = dependencies[module.moduleId].minVersion,
maxVersion = dependencies[module.moduleId].maxVersion;
if (minVersion && (moduleInjection[module.moduleId].version || version) < minVersion) {
findVersion = true;
break;
}
if (maxVersion && (moduleInjection[module.moduleId].version || version) > maxVersion) {
findVersion = true;
break;
}
}
}
if (findVersion === true) {
_global.console && console.error("moduleId: [" + module.moduleId + "] 接口: [" + type + "] 接口版本: [" + version + "] 已过期,版本要求为:", dependencies[module.moduleId], "=>", moduleInjection[module.moduleId]);
continue;
}
}
if (constantInjection[type]) {
return (constantInjection[type] = configFn(constantInjection[type]));
constantInjection[type] = fn(constantInjection[type]);
continue;
}
if (providerInjection[type]) {
if (!providers[type]) {
providers[type] = new providerInjection[type]();
}
// 如果config被重新配置的话,需要删除掉之前的实例
if (providerInstance[type]) {
delete providerInstance[type];
}
return configFn(providers[type]);
fn(providers[type]);
continue;
}
BI.Plugin.configWidget(type, fn);
}
};
BI.config = BI.config || function (type, configFn, opt) {
opt = opt || {};
// 系统配置直接执行
if ("bi.provider.system" === type) {
if (!providers[type]) {
providers[type] = new providerInjection[type]();
}
return BI.Plugin.configWidget(type, configFn, opt);
// 如果config被重新配置的话,需要删除掉之前的实例
if (providerInstance[type]) {
delete providerInstance[type];
}
return configFn(providers[type]);
}
if (!configFunctions[type]) {
configFunctions[type] = [];
BI.prepares.push(function () {
var queue = configFunctions[type];
var dependencies = BI.Providers.getProvider("bi.provider.system").getDependencies();
var modules = moduleInjectionMap.components[type]
|| moduleInjectionMap.constants[type]
|| moduleInjectionMap.services[type]
|| moduleInjectionMap.stores[type]
|| moduleInjectionMap.models[type]
|| moduleInjectionMap.providers[type];
for (var i = 0; i < queue.length; i++) {
var conf = queue[i];
var version = conf.opt.version;
var fn = conf.fn;
if (modules && version) {
var findVersion = false;
for (var j = 0; j < modules.length; j++) {
var module = modules[i];
if (module && dependencies[module.moduleId] && module.version === version) {
var minVersion = dependencies[module.moduleId].minVersion,
maxVersion = dependencies[module.moduleId].maxVersion;
if (minVersion && (moduleInjection[module.moduleId].version || version) < minVersion) {
findVersion = true;
break;
}
if (maxVersion && (moduleInjection[module.moduleId].version || version) > maxVersion) {
findVersion = true;
break;
}
}
}
if (findVersion === true) {
_global.console && console.error("moduleId: [" + module.moduleId + "] 接口: [" + type + "] 接口版本: [" + version + "] 已过期,版本要求为:", dependencies[module.moduleId], "=>", moduleInjection[module.moduleId]);
continue;
}
}
if (constantInjection[type]) {
constantInjection[type] = fn(constantInjection[type]);
continue;
}
if (providerInjection[type]) {
if (!providers[type]) {
providers[type] = new providerInjection[type]();
}
if (providerInstance[type]) {
delete providerInstance[type];
}
fn(providers[type]);
continue;
}
BI.Plugin.configWidget(type, fn);
}
configFunctions[type] = null;
});
}
configFunctions[type].push({
fn: configFn,
opt: opt
});
// // 初始化过或者系统配置需要立刻执行
// if (BI.initialized || "bi.provider.system" === type) {
// if (constantInjection[type]) {
// return (constantInjection[type] = configFn(constantInjection[type]));
// }
// if (providerInjection[type]) {
// if (!providers[type]) {
// providers[type] = new providerInjection[type]();
// }
// // 如果config被重新配置的话,需要删除掉之前的实例
// if (providerInstance[type]) {
// delete providerInstance[type];
// }
// return configFn(providers[type]);
// }
// return BI.Plugin.configWidget(type, configFn, opt);
// }
// if (!configFunctions[type]) {
// configFunctions[type] = [];
// BI.prepares.push(function () {
// var queue = configFunctions[type];
// var dependencies = BI.Providers.getProvider("bi.provider.system").getDependencies();
// var modules = moduleInjectionMap.components[type]
// || moduleInjectionMap.constants[type]
// || moduleInjectionMap.services[type]
// || moduleInjectionMap.stores[type]
// || moduleInjectionMap.models[type]
// || moduleInjectionMap.providers[type];
// for (var i = 0; i < queue.length; i++) {
// var conf = queue[i];
// var version = conf.opt.version;
// var fn = conf.fn;
// if (modules && version) {
// var findVersion = false;
// for (var j = 0; j < modules.length; j++) {
// var module = modules[i];
// if (module && dependencies[module.moduleId] && module.version === version) {
// var minVersion = dependencies[module.moduleId].minVersion,
// maxVersion = dependencies[module.moduleId].maxVersion;
// if (minVersion && (moduleInjection[module.moduleId].version || version) < minVersion) {
// findVersion = true;
// break;
// }
// if (maxVersion && (moduleInjection[module.moduleId].version || version) > maxVersion) {
// findVersion = true;
// break;
// }
// }
// }
// if (findVersion === true) {
// _global.console && console.error("moduleId: [" + module.moduleId + "] 接口: [" + type + "] 接口版本: [" + version + "] 已过期,版本要求为:", dependencies[module.moduleId], "=>", moduleInjection[module.moduleId]);
// continue;
// }
// }
// if (constantInjection[type]) {
// constantInjection[type] = fn(constantInjection[type]);
// continue;
// }
// if (providerInjection[type]) {
// if (!providers[type]) {
// providers[type] = new providerInjection[type]();
// }
// if (providerInstance[type]) {
// delete providerInstance[type];
// }
// fn(providers[type]);
// continue;
// }
// BI.Plugin.configWidget(type, fn);
// }
// configFunctions[type] = null;
// });
// }
// configFunctions[type].push({
// fn: configFn,
// opt: opt
// });
};
BI.getReference = BI.getReference || function (type, fn) {
@ -2451,6 +2529,7 @@ if (!_global.BI) {
if (BI.isNull(constantInjection[type])) {
_global.console && console.error("constant: [" + type + "] 未定义");
}
runConfigFunction(type);
return constantInjection[type];
}
};
@ -2498,6 +2577,7 @@ if (!_global.BI) {
if (!modelInjection[type]) {
_global.console && console.error("model: [" + type + "] 未定义");
}
runConfigFunction(type);
var inst = new modelInjection[type](config);
inst._constructor && inst._constructor(config);
inst.mixins && callPoint(inst, inst.mixins);
@ -2549,6 +2629,7 @@ if (!_global.BI) {
if (!providerInjection[type]) {
_global.console && console.error("provider: [" + type + "] 未定义");
}
runConfigFunction(type);
if (!providers[type]) {
providers[type] = new providerInjection[type]();
}

2
dist/utils.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/utils.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/utils.min.js.map vendored

File diff suppressed because one or more lines are too long

74
examples/config-render.html

@ -0,0 +1,74 @@
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="../dist/2.0/fineui.css"/>
<script src="../dist/2.0/fineui.js"></script>
</head>
<body>
<div id="wrapper"></div>
<script>
BI.Plugin.configRender("demo.parent", function (rendered) {
console.log(rendered);
return rendered;
});
var Widget = BI.inherit(BI.Widget, {
setup: function () {
var wrapper, list;
return function () {
return {
type: "bi.vertical",
items: [{
type: "bi.vertical",
invisible: true,
ref: function (_ref) {
wrapper = _ref;
},
items: [{
type: "bi.button_group",
height: 100,
ref: function (_ref) {
list = _ref;
},
items: [],
layouts: [{
type: "bi.inline",
tgap: 10,
lgap: 10
}]
}]
}, {
type: "bi.button",
text: "点击",
handler: function () {
list.populate(BI.range(10).map(function (i) {
return {
type: "bi.label",
text: i,
cls: "bi-border"
};
}));
wrapper.setVisible(true);
}
}]
};
};
}
});
BI.shortcut("demo.parent", Widget);
BI.createWidget({
type: "bi.absolute",
items: [{
el: {
type: "demo.parent"
},
top: 100,
left: 100
}],
element: "#wrapper"
});
</script>
</body>
</html>

106
examples/dev.html

@ -9,40 +9,90 @@
<body>
<div id="wrapper"></div>
<script>
!(function () {
var Widget = BI.inherit(BI.Widget, {
props: {
vdom: true
},
watch: {
text: function () {
this.reset();
var element2InstanceMap = new WeakMap();
BI.getInstanceByElement = function (element) {
return element2InstanceMap.get(element);
};
BI.Plugin.config(function (options) {
}, function (shortcut, instance) {
instance.element.attr("shortcut", shortcut);
if (instance.options.$testId) {
setIDAttribute(instance.element[0], instance.options.$testId);
}
element2InstanceMap.set(instance.element[0], instance);
});
function setIDAttribute (element, id) {
if (element.id !== "") {
throw new Error("不能修改有默认id的元素");
}
element.setAttribute("id", id);
}
function registerWidgetIdGenerator () {
const idSet = new Set();
return function (shortcut, id) {
if (idSet.has(id)) {
throw new Error("id重复了");
}
idSet.add(id);
BI.Plugin.registerObject(shortcut, function (widget) {
setIDAttribute(widget.element[0], id);
});
};
}
BI.registerWidgetId = registerWidgetIdGenerator();
}());
</script>
<script>
function setTestId (parentShortcut, childShortcut, testId) {
BI.Plugin.configRender(parentShortcut, function (rendered) {
var queue = BI.isArray(rendered) ? rendered : [rendered];// 广度遍历
while (queue.length > 0) {
var element = queue.shift();
BI.each(element, function (key, value) {
if (BI.isArray(value)) {
queue = queue.concat(value);
} else if (BI.isPlainObject(value)) {
queue.push(value);
} else if ("type" === key && value === childShortcut) {
element.$testId = testId;
}
});
}
},
return rendered;
});
}
setTestId("demo.parent", "bi.button_group", "测试testId");
var Widget = BI.inherit(BI.Widget, {
setup: function () {
var list, count = 0;
var list;
return function () {
return {
type: "bi.vertical",
items: [{
type: "bi.virtual_group",
type: "bi.button_group",
height: 100,
ref: function (_ref) {
list = _ref;
},
items: BI.range(10).map(function (item, i) {
var r = {
items: BI.range(10).map(function (i) {
return {
type: "bi.label",
text: item,
// 指定key后,会根据key值进行前后两次数据对比,否则会根据数组索引进行数据对比
key: item,
text: i,
cls: "bi-border"
};
if (i === 9) {
r.width = "fill";
r.key = "唯一的标识";
}
return r;
}),
layouts: [{
type: "bi.inline",
@ -51,22 +101,8 @@
}]
}, {
type: "bi.button",
text: "点击删除第一个元素",
text: "点击",
handler: function () {
count++;
list.populate(BI.range(10 - count).map(function (i) {
var r = {
type: "bi.label",
text: i + count,
key: i + count,
cls: "bi-border"
};
if (i + count === 9) {
r.width = "fill";
r.key = "唯一的标识";
}
return r;
}));
}
}]
};

125
examples/test-id.html

@ -0,0 +1,125 @@
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="../dist/2.0/fineui.css"/>
<script src="../dist/2.0/fineui.js"></script>
</head>
<body>
<div id="wrapper"></div>
<script>
!(function () {
var element2InstanceMap = new WeakMap();
BI.getInstanceByElement = function (element) {
return element2InstanceMap.get(element);
};
BI.Plugin.config(function (options) {
}, function (shortcut, instance) {
instance.element.attr("shortcut", shortcut);
if (instance.options.$testId) {
setIDAttribute(instance.element[0], instance.options.$testId);
}
element2InstanceMap.set(instance.element[0], instance);
});
function setIDAttribute (element, id) {
if (element.id !== "") {
throw new Error("不能修改有默认id的元素");
}
element.setAttribute("id", id);
}
function registerWidgetIdGenerator () {
const idSet = new Set();
return function (shortcut, id) {
if (idSet.has(id)) {
throw new Error("id重复了");
}
idSet.add(id);
BI.Plugin.registerObject(shortcut, function (widget) {
setIDAttribute(widget.element[0], id);
});
};
}
BI.registerWidgetId = registerWidgetIdGenerator();
}());
</script>
<script>
function setTestId (parentShortcut, childShortcut, testId) {
BI.Plugin.configRender(parentShortcut, function (rendered) {
var queue = BI.isArray(rendered) ? rendered : [rendered];// 广度遍历
while (queue.length > 0) {
var element = queue.shift();
BI.each(element, function (key, value) {
if (BI.isArray(value)) {
queue = queue.concat(value);
} else if (BI.isPlainObject(value)) {
queue.push(value);
} else if ("type" === key && value === childShortcut) {
element.$testId = testId;
}
});
}
return rendered;
});
}
setTestId("demo.parent", "bi.button_group", "测试testId");
var Widget = BI.inherit(BI.Widget, {
setup: function () {
var list;
return function () {
return {
type: "bi.vertical",
items: [{
type: "bi.button_group",
height: 100,
ref: function (_ref) {
list = _ref;
},
items: BI.range(10).map(function (i) {
return {
type: "bi.label",
text: i,
cls: "bi-border"
};
}),
layouts: [{
type: "bi.inline",
tgap: 10,
lgap: 10
}]
}, {
type: "bi.button",
text: "点击",
handler: function () {
}
}]
};
};
}
});
BI.shortcut("demo.parent", Widget);
BI.createWidget({
type: "bi.absolute",
items: [{
el: {
type: "demo.parent"
},
top: 100,
left: 100
}],
element: "#wrapper"
});
</script>
</body>
</html>

89
examples/virtual-group.html

@ -0,0 +1,89 @@
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="../dist/2.0/fineui.css"/>
<script src="../dist/2.0/fineui.js"></script>
</head>
<body>
<div id="wrapper"></div>
<script>
var Widget = BI.inherit(BI.Widget, {
props: {
vdom: true
},
watch: {
text: function () {
this.reset();
}
},
setup: function () {
var list, count = 0;
return function () {
return {
type: "bi.vertical",
items: [{
type: "bi.virtual_group",
height: 100,
ref: function (_ref) {
list = _ref;
},
items: BI.range(10).map(function (item, i) {
var r = {
type: "bi.label",
text: item,
// 指定key后,会根据key值进行前后两次数据对比,否则会根据数组索引进行数据对比
key: item,
cls: "bi-border"
};
if (i === 9) {
r.width = "fill";
r.key = "唯一的标识";
}
return r;
}),
layouts: [{
type: "bi.inline",
tgap: 10,
lgap: 10
}]
}, {
type: "bi.button",
text: "点击删除第一个元素",
handler: function () {
count++;
list.populate(BI.range(10 - count).map(function (i) {
var r = {
type: "bi.label",
text: i + count,
key: i + count,
cls: "bi-border"
};
if (i + count === 9) {
r.width = "fill";
r.key = "唯一的标识";
}
return r;
}));
}
}]
};
};
}
});
BI.shortcut("demo.parent", Widget);
BI.createWidget({
type: "bi.absolute",
items: [{
el: {
type: "demo.parent"
},
top: 100,
left: 100
}],
element: "#wrapper"
});
</script>
</body>
</html>

220
examples/visible.html

@ -0,0 +1,220 @@
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="../dist/2.0/fineui.css"/>
<script src="../dist/2.0/fineui.js"></script>
</head>
<body>
<div id="wrapper"></div>
<script>
var Item = BI.inherit(BI.BasicButton, {
props: {
baseCls: "bi-list-item-active"
},
render: function () {
var self = this;
return {
type: "bi.vertical_adapt",
items: [
{
el: {
type: "bi.label",
textAlign: "left",
text: this.options.text
},
lgap: this.options.layer * 24 + 24
}
]
};
},
getValue: function () {
return this.options.id;
}
});
BI.shortcut("bi.example.single_custom_tree.item", Item);
var Node = BI.inherit(BI.NodeButton, {
props: {
baseCls: "bi-list-item"
},
render: function () {
var self = this;
return {
type: "bi.vertical_adapt",
items: [
{
el: {
type: "bi.label",
ref: function (_ref) {
self.icon = _ref;
},
text: this.options.open ? "-" : "+",
height: 24,
width: 24
},
lgap: this.options.layer * 24
}, {
type: "bi.label",
textAlign: "left",
text: this.options.text
}
]
};
},
setOpened: function (b) {
Node.superclass.setOpened.apply(this, arguments);
this.icon.setText(b ? "-" : "+");
},
getValue: function () {
return this.options.id;
}
});
BI.shortcut("bi.example.single_custom_tree.node", Node);
var mockData = [
{
id: "无锡",
text: "无锡",
isParent: true
}, {
id: "锡山区",
text: "锡山区",
pId: "无锡",
isParent: true
}, {
id: "安镇街道",
text: "安镇街道",
pId: "锡山区"
}, {
id: "滨湖区",
text: "滨湖区",
pId: "无锡"
}, {
id: "南京",
text: "南京",
isParent: true
}, {
id: "建邺区",
text: "建邺区",
pId: "南京"
}
];
var Tree = BI.inherit(BI.Widget, {
render: function () {
var self = this;
return {
type: "bi.custom_tree",
ref: function (_ref) {
self.tree = _ref;
},
expander: {
type: "bi.expander",
isDefaultInit: false,
el: {},
popup: {
type: "bi.custom_tree"
}
},
el: {
type: "bi.button_tree",
chooseType: 0,
layouts: [
{
type: "bi.vertical"
}
]
},
items: []
};
},
_formatItems: function (items) {
var nodes = BI.map(items, function (index, item) {
return BI.extend({
type: item.isParent ? "bi.example.single_custom_tree.node" : "bi.example.single_custom_tree.item"
}, item);
});
return this.traversalLayers(BI.Tree.transformToTreeFormat(nodes), 0);
},
traversalLayers: function (items, layer) {
var self = this;
BI.each(items, function (index, item) {
item.layer = layer;
if (item.children) {
self.traversalLayers(item.children, layer + 1);
}
});
return items;
},
populate: function (items) {
this.tree.populate(this._formatItems(items));
}
});
BI.shortcut("bi.example.single_custom_tree", Tree);
var Widget = BI.inherit(BI.Widget, {
setup: function () {
var wrapper, tree;
return function () {
return {
type: "bi.vertical",
items: [{
type: "bi.vertical",
invisible: true,
ref: function (_ref) {
wrapper = _ref;
},
items: [{
type: "bi.example.single_custom_tree",
height: 100,
ref: function (_ref) {
tree = _ref;
}
}]
}, {
type: "bi.button",
text: "点击",
handler: function () {
tree.populate(mockData);
wrapper.setVisible(true);
}
}]
};
};
}
});
BI.shortcut("demo.parent", Widget);
BI.createWidget({
type: "bi.absolute",
items: [{
el: {
type: "demo.parent"
},
top: 100,
left: 100
}],
element: "#wrapper"
});
</script>
</body>
</html>

18
examples/插件设计.html

@ -3,15 +3,19 @@
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="../dist/2.0/fineui.css"/>
<!-- <script src="../dist/2.0/fineui.js"></script>-->
<script src="http://localhost:9001/fineui.js"></script>
<script src="../dist/2.0/fineui.js"></script>
<!-- <link rel="stylesheet" type="text/css" href="http://fanruan.design/fineui/2.0/fineui.min.css" />-->
<!-- <script src="http://fanruan.design/fineui/2.0/fineui.min.js"></script>-->
</head>
<body>
<div id="wrapper"></div>
<script>
BI.config("demo.parent", function (config){
BI.config("demo.parent", function (config) {
console.log("123");
return config;
return {
type: "bi.button",
text: "被替换的组件"
};
}, {
version: "1.0"
});
@ -22,7 +26,7 @@
components: {
"demo.parent": "1.0"
}
})
});
// 主线代码里加这个
BI.config("bi.provider.system", function (provider) {
@ -31,8 +35,8 @@
minVersion: "2.0",
maxVersion: "4.0"
}
})
})
});
});
</script>
<script>
var Model = BI.inherit(Fix.Model, {

2
package.json

@ -1,6 +1,6 @@
{
"name": "fineui",
"version": "2.0.20210830194150",
"version": "2.0.20210903154116",
"description": "fineui",
"main": "dist/fineui.min.js",
"types": "dist/lib/index.d.ts",

150
src/base/list/virtualgrouplist.js

@ -0,0 +1,150 @@
/**
* 同时用于virtualGroup和virtualList特性的虚拟列表
*
* Created by GUY on 2017/5/22.
* @class BI.VirtualList
* @extends BI.Widget
*/
BI.VirtualGroupList = BI.inherit(BI.Widget, {
props: function () {
return {
baseCls: "bi-virtual-group-list",
overscanHeight: 100,
blockSize: 10,
scrollTop: 0,
rowHeight: "auto",
items: []
};
},
init: function () {
var self = this;
this.renderedIndex = -1;
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [{
type: "bi.layout",
ref: function () {
self.topBlank = this;
}
}, {
type: "bi.virtual_group",
height: o.rowHeight * o.items.length,
ref: function () {
self.container = this;
},
layouts: [{
type: "bi.vertical",
scrolly: false
}]
}, {
type: "bi.layout",
ref: function () {
self.bottomBlank = this;
}
}],
element: this
};
},
// mounted之后绑定事件
mounted: function () {
var self = this, o = this.options;
this._populate();
this.element.scroll(function (e) {
o.scrollTop = self.element.scrollTop();
self._calculateBlocksToRender();
});
BI.ResizeDetector.addResizeListener(this, function () {
self._calculateBlocksToRender();
});
},
_isAutoHeight: function () {
return this.options.rowHeight === "auto";
},
_renderMoreIf: function () {
var self = this, o = this.options;
var height = this.element.height();
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.renderedIndex + 1) * o.blockSize, cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
return self.container.element.height() + self.topBlank.element.height() + self.bottomBlank.element.height();
};
while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items, this);
var addedHeight = getElementHeight() - lastHeight;
this.tree.set(cnt, addedHeight);
this.renderedIndex = cnt;
cnt++;
index += o.blockSize;
}
},
_calculateBlocksToRender: function () {
var o = this.options;
this._isAutoHeight() && this._renderMoreIf();
var height = this.element.height();
var minContentHeightFrom = o.scrollTop - o.overscanHeight;
var minContentHeightTo = o.scrollTop + height + o.overscanHeight;
var start = this.tree.greatestLowerBound(minContentHeightFrom);
var end = this.tree.leastUpperBound(minContentHeightTo);
var items = [];
var topHeight = this.tree.sumTo(Math.max(-1, start - 1));
this.topBlank.setHeight(topHeight);
if (this._isAutoHeight()) {
for (var i = (start < 0 ? 0 : start); i <= end && i <= this.renderedIndex; i++) {
var index = i * o.blockSize;
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
items.push(o.items[j]);
}
}
this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex)));
this.container.populate(items);
} else {
for (var i = (start < 0 ? 0 : start); i <= end; i++) {
var index = i * o.blockSize;
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
items.push(o.items[j]);
}
}
this.container.element.height(o.rowHeight * o.items.length - topHeight);
this.container.populate(items);
}
},
_populate: function (items) {
var o = this.options;
if (items && this.options.items !== items) {
this.options.items = items;
}
this.tree = BI.PrefixIntervalTree.uniform(Math.ceil(o.items.length / o.blockSize), this._isAutoHeight() ? 0 : o.rowHeight * o.blockSize);
this._calculateBlocksToRender();
try {
this.element.scrollTop(o.scrollTop);
} catch (e) {
}
},
restore: function () {
this.renderedIndex = -1;
this.options.scrollTop = 0;
// 依赖于cache的占位元素也要初始化
this.topBlank.setHeight(0);
this.bottomBlank.setHeight(0);
},
populate: function (items) {
this._populate(items);
}
});
BI.shortcut("bi.virtual_group_list", BI.VirtualGroupList);

37
src/base/list/virtuallist.js

@ -1,5 +1,5 @@
/**
* 示当前对象
* 虚拟列
*
* Created by GUY on 2017/5/22.
* @class BI.VirtualList
@ -64,8 +64,7 @@ BI.VirtualList = BI.inherit(BI.Widget, {
var self = this, o = this.options;
var height = this.element.height();
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0,
cnt = this.renderedIndex + 1;
var index = (this.renderedIndex + 1) * o.blockSize, cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
return self.container.element.height() + self.topBlank.element.height() + self.bottomBlank.element.height();
@ -74,11 +73,6 @@ BI.VirtualList = BI.inherit(BI.Widget, {
var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items, this);
var addedHeight = getElementHeight() - lastHeight;
this.cache[cnt] = {
index: index,
scrollTop: lastHeight,
height: addedHeight
};
this.tree.set(cnt, addedHeight);
this.renderedIndex = cnt;
cnt++;
@ -94,9 +88,12 @@ BI.VirtualList = BI.inherit(BI.Widget, {
var minContentHeightTo = o.scrollTop + height + o.overscanHeight;
var start = this.tree.greatestLowerBound(minContentHeightFrom);
var end = this.tree.leastUpperBound(minContentHeightTo);
var needDestroyed = [];
var needDestroyed = [], needMount = [];
for (var i = 0; i < start; i++) {
var index = this.cache[i].index;
var index = i * o.blockSize;
if (!this.cache[i]) {
this.cache[i] = {};
}
if (!this.cache[i].destroyed) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
needDestroyed.push(this.container._children[j]);
@ -106,7 +103,10 @@ BI.VirtualList = BI.inherit(BI.Widget, {
}
}
for (var i = end + 1; i <= this.renderedIndex; i++) {
var index = this.cache[i].index;
var index = i * o.blockSize;
if (!this.cache[i]) {
this.cache[i] = {};
}
if (!this.cache[i].destroyed) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
needDestroyed.push(this.container._children[j]);
@ -119,13 +119,17 @@ BI.VirtualList = BI.inherit(BI.Widget, {
lastFragment = BI.Widget._renderEngine.createFragment();
var currentFragment = firstFragment;
for (var i = (start < 0 ? 0 : start); i <= end && i <= this.renderedIndex; i++) {
var index = this.cache[i].index;
var index = i * o.blockSize;
if (!this.cache[i]) {
this.cache[i] = {};
}
if (!this.cache[i].destroyed) {
currentFragment = lastFragment;
}
if (this.cache[i].destroyed === true) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
var w = this.container._addElement(j, BI.extend({root: true}, BI.stripEL(o.items[j])), this);
var w = this.container._addElement(j, o.items[j], this);
needMount.push(w);
currentFragment.appendChild(w.element[0]);
}
this.cache[i].destroyed = false;
@ -135,6 +139,9 @@ BI.VirtualList = BI.inherit(BI.Widget, {
this.container.element.append(lastFragment);
this.topBlank.setHeight(this.tree.sumTo(Math.max(-1, start - 1)));
this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex)));
BI.each(needMount, function (i, child) {
child && child._mount();
});
BI.each(needDestroyed, function (i, child) {
child && child._destroy();
});
@ -146,6 +153,7 @@ BI.VirtualList = BI.inherit(BI.Widget, {
this.options.items = items;
}
this.tree = BI.PrefixIntervalTree.empty(Math.ceil(o.items.length / o.blockSize));
this._calculateBlocksToRender();
try {
this.element.scrollTop(o.scrollTop);
@ -179,7 +187,8 @@ BI.VirtualList = BI.inherit(BI.Widget, {
},
destroyed: function () {
this.restore();
this.cache = {};
this.renderedIndex = -1;
}
});
BI.shortcut("bi.virtual_list", BI.VirtualList);

52
src/core/4.widget.js

@ -114,6 +114,7 @@
return;
}
initCallbackCalled = true;
function render () {
// 加个保险
if (renderCallbackCalled === true) {
@ -123,6 +124,7 @@
renderCallbackCalled = true;
self._render();
}
if (self.options.beforeRender || self.beforeRender) {
self.__async = true;
(self.options.beforeRender || self.beforeRender).call(self, render);
@ -235,27 +237,14 @@
var self = this;
var isMounted = this._isMounted;
this.__async === true && isMounted && callLifeHook(this, "beforeMount");
var render = BI.isFunction(this.options.render) ? this.options.render : this.render;
var els = render && render.call(this);
if (BI.isPlainObject(els)) {
els = [els];
}
if (BI.isArray(els)) {
if (this.options.vdom) {
var div = document.createElement("div");
var element = this.element;
element.append(div);
this.vnode = this._renderVNode();
BI.patchVNode(div, this.vnode);
// 去除这个临时的div
BI.DOM.hang([div]);
element.attr("style", self.vnode.elm.getAttribute("style"));
element.addClass(self.vnode.elm.getAttribute("class"));
element.empty();
BI.each(BI.jQuery(self.vnode.elm).children(), function (i, node) {
element.append(node);
});
} else {
if (!this._initVNode()) {
var render = BI.isFunction(this.options.render) ? this.options.render : this.render;
var els = render && render.call(this);
els = BI.Plugin.getRender(this.options.type, els);
if (BI.isPlainObject(els)) {
els = [els];
}
if (BI.isArray(els)) {
BI.each(els, function (i, el) {
if (el) {
BI._lazyCreateWidget(el, {
@ -272,10 +261,31 @@
}
},
_initVNode: function () {
if (this.options.vdom) {
var div = document.createElement("div");
var element = this.element;
element.append(div);
this.vnode = this._renderVNode();
BI.patchVNode(div, this.vnode);
// 去除这个临时的div
BI.DOM.hang([div]);
element.attr("style", this.vnode.elm.getAttribute("style"));
element.addClass(this.vnode.elm.getAttribute("class"));
element.empty();
BI.each(BI.jQuery(this.vnode.elm).children(), function (i, node) {
element.append(node);
});
return true;
}
return false;
},
_renderVNode: function () {
var self = this;
var render = BI.isFunction(this.options.render) ? this.options.render : this.render;
var els = render && render.call(this);
els = BI.Plugin.getRender(this.options.type, els);
if (BI.isPlainObject(els)) {
els = [els];
}

37
src/core/5.shortcut.js

@ -35,9 +35,6 @@
};
BI.createWidget = BI.createWidget || function (item, options, context, lazy) {
// 先把准备环境准备好
BI.init();
var el, w;
item || (item = {});
if (BI.isWidget(options)) {
context = options;
@ -45,6 +42,21 @@
} else {
options || (options = {});
}
var el, w;
if (item.type || options.type) {
el = BI.extend({}, options, item);
} else if (item.el && (item.el.type || options.type)) {
el = BI.extend({}, options, item.el);
}
if (el) {
BI.runConfigFunction(el.type);
}
// 先把准备环境准备好
BI.init();
if (BI.isEmpty(item) && BI.isEmpty(options)) {
return BI.createWidget({
type: "bi.layout"
@ -53,24 +65,7 @@
if (BI.isWidget(item)) {
return item;
}
if (item.type || options.type) {
el = BI.extend({}, options, item);
w = BI.Plugin.getWidget(el.type, el);
if (w.type === el.type) {
if (BI.Plugin.hasObject(el.type)) {
w.listeners = (w.listeners || []).concat([{
eventName: BI.Events.MOUNT,
action: function () {
BI.Plugin.getObject(el.type, this);
}
}]);
}
return createWidget(w, context, lazy);
}
return BI.createWidget(w, options, context, lazy);
}
if (item.el && (item.el.type || options.type)) {
el = BI.extend({}, options, item.el);
if (el) {
w = BI.Plugin.getWidget(el.type, el);
if (w.type === el.type) {
if (BI.Plugin.hasObject(el.type)) {

203
src/core/6.inject.js

@ -74,85 +74,163 @@
};
var configFunctions = {};
BI.config = BI.config || function (type, configFn, opt) {
opt = opt || {};
// 初始化过或者系统配置需要立刻执行
if (BI.initialized || "bi.provider.system" === type) {
var runConfigFunction = BI.runConfigFunction = function (type) {
if (!type || !configFunctions[type]) {
return false;
}
var queue = configFunctions[type];
delete configFunctions[type];
var dependencies = BI.Providers.getProvider("bi.provider.system").getDependencies();
var modules = moduleInjectionMap.components[type]
|| moduleInjectionMap.constants[type]
|| moduleInjectionMap.services[type]
|| moduleInjectionMap.stores[type]
|| moduleInjectionMap.models[type]
|| moduleInjectionMap.providers[type];
for (var i = 0; i < queue.length; i++) {
var conf = queue[i];
var version = conf.opt.version;
var fn = conf.fn;
if (modules && version) {
var findVersion = false;
for (var j = 0; j < modules.length; j++) {
var module = modules[j];
if (module && dependencies[module.moduleId] && module.version === version) {
var minVersion = dependencies[module.moduleId].minVersion,
maxVersion = dependencies[module.moduleId].maxVersion;
if (minVersion && (moduleInjection[module.moduleId].version || version) < minVersion) {
findVersion = true;
break;
}
if (maxVersion && (moduleInjection[module.moduleId].version || version) > maxVersion) {
findVersion = true;
break;
}
}
}
if (findVersion === true) {
_global.console && console.error("moduleId: [" + module.moduleId + "] 接口: [" + type + "] 接口版本: [" + version + "] 已过期,版本要求为:", dependencies[module.moduleId], "=>", moduleInjection[module.moduleId]);
continue;
}
}
if (constantInjection[type]) {
return (constantInjection[type] = configFn(constantInjection[type]));
constantInjection[type] = fn(constantInjection[type]);
continue;
}
if (providerInjection[type]) {
if (!providers[type]) {
providers[type] = new providerInjection[type]();
}
// 如果config被重新配置的话,需要删除掉之前的实例
if (providerInstance[type]) {
delete providerInstance[type];
}
return configFn(providers[type]);
fn(providers[type]);
continue;
}
BI.Plugin.configWidget(type, fn);
}
};
BI.config = BI.config || function (type, configFn, opt) {
opt = opt || {};
// 系统配置直接执行
if ("bi.provider.system" === type) {
if (!providers[type]) {
providers[type] = new providerInjection[type]();
}
// 如果config被重新配置的话,需要删除掉之前的实例
if (providerInstance[type]) {
delete providerInstance[type];
}
return BI.Plugin.configWidget(type, configFn, opt);
return configFn(providers[type]);
}
if (!configFunctions[type]) {
configFunctions[type] = [];
BI.prepares.push(function () {
var queue = configFunctions[type];
var dependencies = BI.Providers.getProvider("bi.provider.system").getDependencies();
var modules = moduleInjectionMap.components[type]
|| moduleInjectionMap.constants[type]
|| moduleInjectionMap.services[type]
|| moduleInjectionMap.stores[type]
|| moduleInjectionMap.models[type]
|| moduleInjectionMap.providers[type];
for (var i = 0; i < queue.length; i++) {
var conf = queue[i];
var version = conf.opt.version;
var fn = conf.fn;
if (modules && version) {
var findVersion = false;
for (var j = 0; j < modules.length; j++) {
var module = modules[i];
if (module && dependencies[module.moduleId] && module.version === version) {
var minVersion = dependencies[module.moduleId].minVersion,
maxVersion = dependencies[module.moduleId].maxVersion;
if (minVersion && (moduleInjection[module.moduleId].version || version) < minVersion) {
findVersion = true;
break;
}
if (maxVersion && (moduleInjection[module.moduleId].version || version) > maxVersion) {
findVersion = true;
break;
}
}
}
if (findVersion === true) {
_global.console && console.error("moduleId: [" + module.moduleId + "] 接口: [" + type + "] 接口版本: [" + version + "] 已过期,版本要求为:", dependencies[module.moduleId], "=>", moduleInjection[module.moduleId]);
continue;
}
}
if (constantInjection[type]) {
constantInjection[type] = fn(constantInjection[type]);
continue;
}
if (providerInjection[type]) {
if (!providers[type]) {
providers[type] = new providerInjection[type]();
}
if (providerInstance[type]) {
delete providerInstance[type];
}
fn(providers[type]);
continue;
}
BI.Plugin.configWidget(type, fn);
}
configFunctions[type] = null;
});
}
configFunctions[type].push({
fn: configFn,
opt: opt
});
// // 初始化过或者系统配置需要立刻执行
// if (BI.initialized || "bi.provider.system" === type) {
// if (constantInjection[type]) {
// return (constantInjection[type] = configFn(constantInjection[type]));
// }
// if (providerInjection[type]) {
// if (!providers[type]) {
// providers[type] = new providerInjection[type]();
// }
// // 如果config被重新配置的话,需要删除掉之前的实例
// if (providerInstance[type]) {
// delete providerInstance[type];
// }
// return configFn(providers[type]);
// }
// return BI.Plugin.configWidget(type, configFn, opt);
// }
// if (!configFunctions[type]) {
// configFunctions[type] = [];
// BI.prepares.push(function () {
// var queue = configFunctions[type];
// var dependencies = BI.Providers.getProvider("bi.provider.system").getDependencies();
// var modules = moduleInjectionMap.components[type]
// || moduleInjectionMap.constants[type]
// || moduleInjectionMap.services[type]
// || moduleInjectionMap.stores[type]
// || moduleInjectionMap.models[type]
// || moduleInjectionMap.providers[type];
// for (var i = 0; i < queue.length; i++) {
// var conf = queue[i];
// var version = conf.opt.version;
// var fn = conf.fn;
// if (modules && version) {
// var findVersion = false;
// for (var j = 0; j < modules.length; j++) {
// var module = modules[i];
// if (module && dependencies[module.moduleId] && module.version === version) {
// var minVersion = dependencies[module.moduleId].minVersion,
// maxVersion = dependencies[module.moduleId].maxVersion;
// if (minVersion && (moduleInjection[module.moduleId].version || version) < minVersion) {
// findVersion = true;
// break;
// }
// if (maxVersion && (moduleInjection[module.moduleId].version || version) > maxVersion) {
// findVersion = true;
// break;
// }
// }
// }
// if (findVersion === true) {
// _global.console && console.error("moduleId: [" + module.moduleId + "] 接口: [" + type + "] 接口版本: [" + version + "] 已过期,版本要求为:", dependencies[module.moduleId], "=>", moduleInjection[module.moduleId]);
// continue;
// }
// }
// if (constantInjection[type]) {
// constantInjection[type] = fn(constantInjection[type]);
// continue;
// }
// if (providerInjection[type]) {
// if (!providers[type]) {
// providers[type] = new providerInjection[type]();
// }
// if (providerInstance[type]) {
// delete providerInstance[type];
// }
// fn(providers[type]);
// continue;
// }
// BI.Plugin.configWidget(type, fn);
// }
// configFunctions[type] = null;
// });
// }
// configFunctions[type].push({
// fn: configFn,
// opt: opt
// });
};
BI.getReference = BI.getReference || function (type, fn) {
@ -215,6 +293,7 @@
if (BI.isNull(constantInjection[type])) {
_global.console && console.error("constant: [" + type + "] 未定义");
}
runConfigFunction(type);
return constantInjection[type];
}
};
@ -262,6 +341,7 @@
if (!modelInjection[type]) {
_global.console && console.error("model: [" + type + "] 未定义");
}
runConfigFunction(type);
var inst = new modelInjection[type](config);
inst._constructor && inst._constructor(config);
inst.mixins && callPoint(inst, inst.mixins);
@ -313,6 +393,7 @@
if (!providerInjection[type]) {
_global.console && console.error("provider: [" + type + "] 未定义");
}
runConfigFunction(type);
if (!providers[type]) {
providers[type] = new providerInjection[type]();
}

21
src/core/7.plugin.js

@ -3,6 +3,7 @@ BI.Plugin = BI.Plugin || {};
var _WidgetsPlugin = {};
var _ObjectPlugin = {};
var _ConfigPlugin = {};
var _ConfigRenderPlugin = {};
var _GlobalWidgetConfigFns = [];
var __GlobalObjectConfigFns = [];
BI.defaults(BI.Plugin, {
@ -47,6 +48,25 @@ BI.Plugin = BI.Plugin || {};
_ConfigPlugin[type].push(fn);
},
getRender: function (type, rendered) {
var res;
if (_ConfigRenderPlugin[type]) {
for (var i = _ConfigRenderPlugin[type].length - 1; i >= 0; i--) {
if (res = _ConfigRenderPlugin[type][i](rendered)) {
rendered = res;
}
}
}
return rendered;
},
configRender: function (type, fn) {
if (!_ConfigRenderPlugin[type]) {
_ConfigRenderPlugin[type] = [];
}
_ConfigRenderPlugin[type].push(fn);
},
// Deprecated
registerWidget: function (type, fn) {
if (!_WidgetsPlugin[type]) {
@ -58,6 +78,7 @@ BI.Plugin = BI.Plugin || {};
_WidgetsPlugin[type].push(fn);
},
// Deprecated
relieveWidget: function (type) {
delete _WidgetsPlugin[type];
},

12
src/core/h.js

@ -29,7 +29,17 @@ BI.h = function (type, props, children) {
el: children[0]
}, props);
}
if (type === "left") {
return BI.extend({
left: children
}, props);
}
if (type === "right") {
return BI.extend({
right: children
}, props);
}
return BI.extend({
type: type,
type: type
}, children.length > 0 ? {items: children} : {}, props);
};

30
src/core/wrapper/layout.js

@ -87,14 +87,17 @@ BI.Layout = BI.inherit(BI.Widget, {
return "" + index;
},
_addElement: function (i, item, context) {
_addElement: function (i, item, context, widget) {
var self = this, w;
if (widget) {
return widget;
}
if (!this.hasWidget(this._getChildName(i))) {
w = BI._lazyCreateWidget(item, context);
w.on(BI.Events.DESTROY, function () {
BI.each(self._children, function (name, child) {
if (child === w) {
BI.remove(self._children, child);
delete self._children[name];
self.removeItemAt(name | 0);
}
});
@ -106,6 +109,20 @@ BI.Layout = BI.inherit(BI.Widget, {
return w;
},
_newElement: function (i, item, context) {
var self = this;
var w = BI._lazyCreateWidget(item, context);
w.on(BI.Events.DESTROY, function () {
BI.each(self._children, function (name, child) {
if (child === w) {
delete self._children[name];
self.removeItemAt(name | 0);
}
});
});
return this._addElement(i, item, context, w);
},
_getOptions: function (item) {
if (item instanceof BI.Widget) {
item = item.options;
@ -441,16 +458,12 @@ BI.Layout = BI.inherit(BI.Widget, {
} else {
var sameOldVnode = findOldVnode(oldCh, newStartVnode, oldStartIdx, oldEndIdx);
if (BI.isNull(sameOldVnode[0])) { // 不存在就把新的放到左边
delete self._children[self._getChildName(newStartIdx)];
var node = addNode(newStartVnode, newStartIdx);
insertBefore(node, oldStartVnode);
} else { // 如果新节点在旧节点区间中存在就复用一下
var sameOldIndex = sameOldVnode[1];
updated = self.patchItem(sameOldVnode[0], newStartVnode, sameOldIndex, newStartIdx) || updated;
children[sameOldVnode[0].key == null ? newStartIdx : sameOldVnode[0].key] = self._children[self._getChildName(sameOldIndex)];
if (newStartIdx !== sameOldIndex) {
delete self._children[self._getChildName(sameOldIndex)];
}
oldCh[sameOldIndex] = undefined;
insertBefore(sameOldVnode[0], oldStartVnode);
}
@ -468,6 +481,7 @@ BI.Layout = BI.inherit(BI.Widget, {
BI.each(newCh, function (i, child) {
var node = self._getOptions(child);
var key = node.key == null ? i : node.key;
children[key]._setParent && children[key]._setParent(self);
children[key]._mount();
self._children[self._getChildName(i)] = children[key];
});
@ -486,8 +500,7 @@ BI.Layout = BI.inherit(BI.Widget, {
function addNode (vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? index : opt.key;
delete self._children[self._getChildName(index)];
return children[key] = self._addElement(index, vnode);
return children[key] = self._newElement(index, vnode);
}
function addVnodes (before, vnodes, startIdx, endIdx) {
@ -503,7 +516,6 @@ BI.Layout = BI.inherit(BI.Widget, {
if (BI.isNotNull(ch)) {
var node = self._getOptions(ch);
var key = node.key == null ? startIdx : node.key;
delete self._children[self._getChildName(startIdx)];
children[key]._destroy();
}
}

26
src/core/wrapper/layout/adapt/absolute.leftrightvertical.js

@ -27,17 +27,28 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
self.layout = _ref;
},
verticalAlign: o.verticalAlign,
items: this._formatItems(),
items: this._formatItems(o.items),
scrollx: o.scrollx,
scrolly: o.scrolly,
scrollable: o.scrollable
};
},
_formatItems: function () {
_formatItems: function (items) {
var o = this.options;
var leftItems = o.items.left || [];
var rightItems = o.items.right || [];
var left, right;
if (BI.isArray(items)) {
BI.each(items, function (i, item) {
if (item.left) {
left = item.left;
}
if (item.right) {
right = item.right;
}
});
}
var leftItems = left || items.left || [];
var rightItems = right || items.right || [];
leftItems = BI.map(leftItems, function (i, item) {
var json = {
el: BI.stripEL(item),
@ -80,7 +91,7 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
this.layout.stroke(this._formatItems())
this.layout.stroke(this._formatItems(this.options.items));
},
addItem: function () {
@ -89,8 +100,7 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
populate: function (items) {
this.options.items = items;
this.layout.populate(this._formatItems());
this.layout.populate(this._formatItems(items));
}
});
BI.shortcut("bi.absolute_left_right_vertical_adapt", BI.AbsoluteLeftRightVerticalAdaptLayout);
@ -132,7 +142,7 @@ BI.AbsoluteRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
this.layout.stroke([{}].concat(this.options.items))
this.layout.stroke([{}].concat(this.options.items));
},
addItem: function () {

37
src/core/wrapper/layout/adapt/adapt.leftrightvertical.js

@ -29,8 +29,9 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
render: function () {
var o = this.options, self = this;
BI.LeftRightVerticalAdaptLayout.superclass.render.apply(this, arguments);
var leftRight = this._getLeftRight(o.items);
var layoutArray = [];
if ("left" in o.items) {
if (leftRight.left || "left" in o.items) {
layoutArray.push({
type: "bi.left",
items: [{
@ -40,7 +41,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
self.left = _ref;
},
height: "100%",
items: o.items.left,
items: leftRight.left || o.items.left,
hgap: o.lhgap,
lgap: o.llgap,
rgap: o.lrgap,
@ -51,7 +52,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
}]
});
}
if ("right" in o.items) {
if (leftRight.right || "right" in o.items) {
layoutArray.push({
type: "bi.right",
items: [{
@ -61,7 +62,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
self.right = _ref;
},
height: "100%",
items: o.items.right,
items: leftRight.right || o.items.right,
hgap: o.rhgap,
lgap: o.rlgap,
rgap: o.rrgap,
@ -75,9 +76,28 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
return layoutArray;
},
_getLeftRight: function (items) {
var left, right;
if (BI.isArray(items)) {
BI.each(items, function (i, item) {
if (item.left) {
left = item.left;
}
if (item.right) {
right = item.right;
}
});
}
return {
left: left,
right: right
};
},
resize: function () {
this.left.stroke(this.options.items.left);
this.right.stroke(this.options.items.right);
var leftRight = this._getLeftRight(this.options.items);
this.left.stroke(leftRight.left || this.options.items.left);
this.right.stroke(leftRight.right || this.options.items.right);
},
addItem: function () {
@ -86,8 +106,9 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
populate: function (items) {
this.left.populate(items.left);
this.right.populate(items.right);
var leftRight = this._getLeftRight(items);
this.left.populate(leftRight.left || items.left);
this.right.populate(leftRight.right || items.right);
}
});
BI.shortcut("bi.left_right_vertical_adapt", BI.LeftRightVerticalAdaptLayout);

15
src/core/wrapper/layout/flex/flex.leftrightvertical.center.js

@ -34,8 +34,19 @@ BI.FlexLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
_formatItems: function (items) {
var o = this.options;
var leftItems = items.left || [];
var rightItems = items.right || [];
var left, right;
if (BI.isArray(items)) {
BI.each(items, function (i, item) {
if (item.left) {
left = item.left;
}
if (item.right) {
right = item.right;
}
});
}
var leftItems = left || items.left || [];
var rightItems = right || items.right || [];
leftItems = BI.map(leftItems, function (i, item) {
var json = {
el: BI.stripEL(item)

15
src/core/wrapper/layout/float/float.absolute.leftrightvertical.js

@ -37,8 +37,19 @@ BI.FloatAbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
_formatItems: function (items) {
var o = this.options;
var leftItems = items.left || [];
var rightItems = items.right || [];
var left, right;
if (BI.isArray(items)) {
BI.each(items, function (i, item) {
if (item.left) {
left = item.left;
}
if (item.right) {
right = item.right;
}
});
}
var leftItems = left || items.left || [];
var rightItems = right || items.right || [];
leftItems = BI.map(leftItems, function (i, item) {
var el = BI.stripEL(item);
if (o.verticalAlign === BI.VerticalAlign.Middle) {

2
src/core/wrapper/layout/layout.tape.js

@ -138,7 +138,7 @@ BI.shortcut("bi.htape", BI.HTapeLayout);
BI.VTapeLayout = BI.inherit(BI.Layout, {
props: function () {
return BI.extend(BI.VTapeLayout.superclass.props.apply(this, arguments), {
baseCls: "bi-v-tape-layout",
baseCls: "bi-v-tape",
horizontalAlign: BI.HorizontalAlign.Left,
hgap: 0,
vgap: 0,

17
src/less/core/utils/common.less

@ -500,6 +500,23 @@
display: none;
}
//& .bi-hover-visible-item {
// display: none;
//}
//&:hover .bi-hover-visible-item {
// display: block;
// &.bi-f-h, &.bi-f-v, &.bi-f-s-h, &.bi-f-s-v {
// display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
// display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
// display: -ms-flexbox; /* TWEENER - IE 10 */
// display: -webkit-flex; /* NEW - Chrome */
// display: flex; /* NEW, Spec - Opera 12.1, Firefox 20+ */
// }
// &.i-item {
// display: inline-block;
// }
//}
& .bi-hover-visible-item {
visibility: hidden;
}

2
src/core/element2Snabbdom.js → src/snabbdom/element2Snabbdom.js

@ -18,7 +18,7 @@
var elmAttrs = parentNode.attributes;
var elmChildren = parentNode.childNodes;
var key = parentNode.getAttribute("key");
for (i = 0, n = elmAttrs.length; i < n; i++) {
for (var i = 0, n = elmAttrs.length; i < n; i++) {
var name = elmAttrs[i].nodeName;
if (name !== "id" && name !== "class") {
attrs[name] = elmAttrs[i].nodeValue;

0
src/core/8.snabdom.js → src/snabbdom/snabbdom.js

2
typescript/core/utils/tree.ts

@ -42,7 +42,7 @@ export declare class Tree {
nrPreOrderTraverse(callback: Function): void;
postOrderTraverse(callback: Function): void;
nrPostOrderTraverse(callback: Function): void;
static transformToArrayFormat(nodes: Node | Node[], pId: any): Node[];
static transformToArrayFormat<T>(nodes: T | T[], pId: any, childKey?: string): T[];
static arrayFormat(nodes: Node | Node[], pId: any): Node[];
static transformToTreeFormat<T>(sNodes: T[]): Node[];
static treeFormat(sNodes: Node | Node[]): Node[];

Loading…
Cancel
Save