Browse Source

Merge pull request #210998 in DEC/fineui from release/11.0 to bugfix/11.0

* commit '564ca3e7ced816c04b95464132e4ee98597b506b':
  BI-118434  fix: 临时解决一下belowMouse
  auto upgrade version to 2.0.20221208185443
  auto upgrade version to 2.0.20221208183344
  auto upgrade version to 2.0.20221208181750
  KERNEL-11877 feat: container支持函数, 修复错误
  demo
  KERNEL-11877 BI-118434 等比下scale缩放下拉偏移
  auto upgrade version to 2.0.20221208121622
  KERNEL-13782 feat: editor支持autoTrim props控制是否需要自动trim
  auto upgrade version to 2.0.20221206104638
  auto upgrade version to 2.0.20221205151529
  REPORT-85956 fix:设置textWidth属性时如果内容超过按钮宽度会溢出
  auto upgrade version to 2.0.20221205121730
  无JIRA refactor(widget): 删掉_Widget等,都换成Widget
research/test
superman 2 years ago
parent
commit
93d9bbfc8f
  1. 5
      demo/js/base/button/demo.button.js
  2. 6
      demo/js/west.js
  3. 2
      package.json
  4. 11
      src/base/combination/bubble.js
  5. 40
      src/base/combination/combo.js
  6. 18
      src/base/single/button/buttons/button.js
  7. 25
      src/base/single/editor/editor.js
  8. 6
      src/case/editor/editor.clear.js
  9. 1
      src/case/editor/editor.defaulttext.js
  10. 3
      src/case/editor/editor.shelter.js
  11. 3
      src/case/editor/editor.sign.js
  12. 3
      src/case/editor/editor.state.js
  13. 9
      src/case/editor/editor.state.simple.js
  14. 118
      src/core/platform/web/dom.js
  15. 3
      src/widget/editor/editor.search.js
  16. 3
      src/widget/editor/editor.text.js
  17. 12
      typescript/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.ts
  18. 4
      typescript/core/base.ts
  19. 4
      typescript/core/plugin.ts
  20. 404
      typescript/core/widget.ts

5
demo/js/base/button/demo.button.js

@ -385,6 +385,11 @@ Demo.Button = BI.inherit(BI.Widget, {
type: "bi.button",
text: "小于最小宽度的按钮",
width: 50,
}, {
type: "bi.button",
text: "一个文字超级超级长的 button, 他比按钮宽度还长。",
textWidth: 500,
width: 100,
}];
return {

6
demo/js/west.js

@ -9,6 +9,10 @@ Demo.West = BI.inherit(BI.Widget, {
render: function () {
var self = this;
var selectedId = BI.Router.$router.currentRoute.params?.componentId;
return {
type: "bi.vtape",
items: [{
@ -60,7 +64,7 @@ Demo.West = BI.inherit(BI.Widget, {
self.fireEvent(Demo.West.EVENT_VALUE_CHANGE, v);
}
}],
value: Demo.showIndex,
value: selectedId || Demo.showIndex,
items: Demo.CONFIG,
ref: function (ref) {
self.tree = ref;

2
package.json

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

11
src/base/combination/bubble.js

@ -106,7 +106,8 @@
_initPullDownAction: function () {
var self = this, o = this.options;
var evs = (this.options.trigger || "").split(",");
function st (e) {
function st(e) {
if (o.stopEvent) {
e.stopEvent();
}
@ -268,7 +269,7 @@
BI.createWidget({
type: "bi.vertical",
scrolly: false,
element: this.options.container || this,
element: BI.isFunction(this.options.container) ? this.options.container() : (this.options.container || this),
items: [
{ el: this.popupView }
],
@ -344,14 +345,16 @@
if (this.popper) {
this.popper.destroy();
}
var modifiers = [{
var modifiers = [
{
name: "offset",
options: {
offset: function () {
return [o.adjustXOffset, (o.showArrow ? 12 : 0) + (o.adjustYOffset + o.adjustLength)];
},
},
}];
}
];
if (this.options.showArrow) {
modifiers.push({
name: "arrow",

40
src/base/combination/combo.js

@ -38,6 +38,7 @@
adjustLength: 0, // 调整的距离
adjustXOffset: 0,
adjustYOffset: 0,
supportCSSTransform: false,
hideChecker: BI.emptyFn,
offsetStyle: "left", // left,right,center
el: {},
@ -195,6 +196,7 @@
this.popupView.visible();
var combo = (o.belowMouse && BI.isNotNull(e)) ? {
element: {
0: e.target,
offset: function () {
return {
left: e.pageX,
@ -218,46 +220,47 @@
},
},
} : this.combo;
var positionRelativeElement = o.supportCSSTransform ? BI.DOM.getPositionRelativeContainingBlock(BI.isNull(o.container) ? this.element[0] : BI.Widget._renderEngine.createElement(BI.isFunction(o.container) ? o.container() : o.container)[0]) : null;
switch (o.direction) {
case "bottom":
case "bottom,right":
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, (o.adjustYOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["bottom", "top", "right", "left"], o.offsetStyle);
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, (o.adjustYOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["bottom", "top", "right", "left"], o.offsetStyle, positionRelativeElement);
break;
case "top":
case "top,right":
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, (o.adjustYOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["top", "bottom", "right", "left"], o.offsetStyle);
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, (o.adjustYOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["top", "bottom", "right", "left"], o.offsetStyle, positionRelativeElement);
break;
case "left":
case "left,bottom":
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["left", "right", "bottom", "top"], o.offsetStyle);
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["left", "right", "bottom", "top"], o.offsetStyle, positionRelativeElement);
break;
case "right":
case "right,bottom":
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "bottom", "top"], o.offsetStyle);
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "bottom", "top"], o.offsetStyle, positionRelativeElement);
break;
case "top,left":
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, (o.adjustYOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["top", "bottom", "left", "right"], o.offsetStyle);
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, (o.adjustYOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["top", "bottom", "left", "right"], o.offsetStyle, positionRelativeElement);
break;
case "bottom,left":
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, (o.adjustYOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["bottom", "top", "left", "right"], o.offsetStyle);
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, (o.adjustYOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["bottom", "top", "left", "right"], o.offsetStyle, positionRelativeElement);
break;
case "left,top":
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["left", "right", "top", "bottom"], o.offsetStyle);
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["left", "right", "top", "bottom"], o.offsetStyle, positionRelativeElement);
break;
case "right,top":
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "top", "bottom"], o.offsetStyle);
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "top", "bottom"], o.offsetStyle, positionRelativeElement);
break;
case "right,innerRight":
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "innerRight", "innerLeft", "bottom", "top"], o.offsetStyle);
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "innerRight", "innerLeft", "bottom", "top"], o.offsetStyle, positionRelativeElement);
break;
case "right,innerLeft":
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "innerLeft", "innerRight", "bottom", "top"], o.offsetStyle);
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "innerLeft", "innerRight", "bottom", "top"], o.offsetStyle, positionRelativeElement);
break;
case "innerRight":
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["innerRight", "innerLeft", "right", "left", "bottom", "top"], o.offsetStyle);
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["innerRight", "innerLeft", "right", "left", "bottom", "top"], o.offsetStyle, positionRelativeElement);
break;
case "innerLeft":
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["innerLeft", "innerRight", "left", "right", "bottom", "top"], o.offsetStyle);
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset + o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["innerLeft", "innerRight", "left", "right", "bottom", "top"], o.offsetStyle, positionRelativeElement);
break;
case "top,custom":
case "custom,top":
@ -290,6 +293,7 @@
if ("adaptHeight" in p) {
this.resetListHeight(p.adaptHeight);
}
var width = this.combo.element.outerWidth();
var height = this.combo.element.outerHeight();
this.popupView.setDirection && this.popupView.setDirection(p.dir, {
@ -300,6 +304,18 @@
adjustYOffset: o.adjustYOffset,
offset: this.combo.element.offset(),
});
if (o.supportCSSTransform) {
var positonedRect = positionRelativeElement.getBoundingClientRect();
var scaleX = positonedRect.width / positionRelativeElement.offsetWidth;
var scaleY = positonedRect.height / positionRelativeElement.offsetHeight;
p.top && (p.top = p.top / scaleY);
p.left && (p.left = p.left / scaleX);
}
if ("left" in p) {
this.popupView.element.css({
left: p.left,

18
src/base/single/button/buttons/button.js

@ -81,7 +81,7 @@
},
hgap: o.hgap,
vgap: o.vgap,
items: self.generateItems()
items: self.generateItems(),
});
// 如果 options 对应的属性为 true 则给元素添加 class
@ -102,7 +102,7 @@
// 由于button默认情况下有个边框,所以要主动算行高
var lineHeight, textHeight = o.textHeight;
var hasBorder = false
var hasBorder = false;
if (BI.isNumber(o.height)) {
if (!isVertical(o.iconPosition)) {
if (!(o.clear && o.block && o.light)) {
@ -121,12 +121,12 @@
var iconInvisible = !(o.loading || o.iconCls || o.icon || defaultRenderIcon);
var textWidth = o.textWidth;
if (BI.isNull(o.textWidth)) {
textWidth = (o.minWidth > 0 && o.width < o.minWidth) ? o.minWidth : o.width;
textWidth -= (o.hgap * 2 + o.iconGap)
textWidth -= iconInvisible || isVertical(o.iconPosition) ? 0 : this._const.iconWidth
}
var maxTextWidth = Math.max(o.minWidth, o.width);
maxTextWidth -= (o.hgap * 2 + o.iconGap);
// 减去图标水平占位宽度
maxTextWidth -= iconInvisible || isVertical(o.iconPosition) ? 0 : this._const.iconWidth;
var textWidth = BI.isNull(o.textWidth) ? maxTextWidth : Math.min(o.textWidth, maxTextWidth);
this.text = BI.createWidget({
type: "bi.label",
text: o.text,
@ -140,7 +140,7 @@
});
if (iconInvisible) {
return [this.text]
return [this.text];
}
this._iconRendered = true;

25
src/base/single/editor/editor.js

@ -23,6 +23,7 @@ BI.Editor = BI.inherit(BI.Single, {
allowBlank: false,
watermark: "",
errorText: "",
autoTrim: true,
});
},
@ -49,25 +50,29 @@ BI.Editor = BI.inherit(BI.Single, {
margin: "0",
});
var items = [{
var items = [
{
el: {
type: "bi.absolute",
ref: function (_ref) {
self.contentWrapper = _ref;
},
items: [{
items: [
{
el: this.editor,
left: 0,
right: 0,
top: 0,
bottom: 0,
}],
}
],
},
left: o.hgap + o.lgap,
right: o.hgap + o.rgap,
top: o.vgap + o.tgap,
bottom: o.vgap + o.bgap,
}];
}
];
BI.createWidget({
type: "bi.absolute",
@ -248,13 +253,15 @@ BI.Editor = BI.inherit(BI.Single, {
BI.createWidget({
type: "bi.absolute",
element: this.contentWrapper,
items: [{
items: [
{
el: this.watermark,
left: 0,
right: 0,
top: 0,
bottom: 0,
}],
}
],
});
}
this.watermark.setText(v);
@ -265,7 +272,7 @@ BI.Editor = BI.inherit(BI.Single, {
var o = this.options;
var errorText = o.errorText;
if (BI.isFunction(errorText)) {
errorText = errorText(BI.trim(this.editor.getValue()));
errorText = errorText(o.autoTrim ? BI.trim(this.editor.getValue()) : this.editor.getValue());
}
if (!this.disabledError && BI.isKey(errorText)) {
BI.Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, {
@ -330,10 +337,10 @@ BI.Editor = BI.inherit(BI.Single, {
getValue: function () {
if (!this.isValid()) {
return BI.trim(this.editor.getLastValidValue());
return this.options.autoTrim ? BI.trim(this.editor.getLastValidValue()) : this.editor.getLastValidValue();
}
return BI.trim(this.editor.getValue());
return this.options.autoTrim ? BI.trim(this.editor.getValue()) : this.editor.getValue();
},
isEditing: function () {

6
src/case/editor/editor.clear.js

@ -31,7 +31,8 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
errorText: o.errorText,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
value: o.value
value: o.value,
autoTrim: o.autoTrim,
});
this.clear = BI.createWidget({
type: "bi.icon_button",
@ -54,7 +55,8 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
{
el: this.clear,
width: 24
}]
}
]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);

1
src/case/editor/editor.defaulttext.js

@ -45,6 +45,7 @@ BI.DefaultTextEditor = BI.inherit(BI.Widget, {
watermark: o.watermark,
errorText: o.errorText,
invisible: true,
autoTrim: o.autoTrim,
});
var showText = BI.isFunction(o.text) ? o.text() : o.text;

3
src/case/editor/editor.shelter.js

@ -46,7 +46,8 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
errorText: o.errorText,
autoTrim: o.autoTrim,
});
this.text = BI.createWidget({
type: "bi.text_button",

3
src/case/editor/editor.sign.js

@ -46,7 +46,8 @@ BI.SignEditor = BI.inherit(BI.Widget, {
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
errorText: o.errorText,
autoTrim: o.autoTrim,
});
this.text = BI.createWidget({
type: "bi.text_button",

3
src/case/editor/editor.state.js

@ -45,7 +45,8 @@ BI.StateEditor = BI.inherit(BI.Widget, {
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
errorText: o.errorText,
autoTrim: o.autoTrim,
});
this.text = BI.createWidget({
type: "bi.text_button",

9
src/case/editor/editor.state.simple.js

@ -45,7 +45,8 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
errorText: o.errorText,
autoTrim: o.autoTrim,
});
this.text = BI.createWidget({
type: "bi.text_button",
@ -68,13 +69,15 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
items: [
{
el: this.text,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
}
]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);

118
src/core/platform/web/dom.js

@ -56,7 +56,7 @@
preloadImages: function (srcArray, onload) {
var count = 0, images = [];
function complete () {
function complete() {
count++;
if (count >= srcArray.length) {
onload();
@ -151,9 +151,15 @@
BI.extend(BI.DOM, {
getLeftPosition: function (combo, popup, extraWidth) {
getLeftPosition: function (combo, popup, extraWidth, container) {
var el = combo.element;
var popupEl = popup.element;
var elRect = el[0].getBoundingClientRect();
var popupElRect = popupEl[0].getBoundingClientRect();
var containerRect = container ? container.getBoundingClientRect() : { left: 0 };
return {
left: combo.element.offset().left - popup.element.outerWidth() - (extraWidth || 0)
left: elRect.left - containerRect.left - popupElRect.width - (extraWidth || 0)
};
},
@ -163,10 +169,13 @@
};
},
getRightPosition: function (combo, popup, extraWidth) {
getRightPosition: function (combo, popup, extraWidth, container) {
var el = combo.element;
var elRect = el[0].getBoundingClientRect();
var containerRect = container ? container.getBoundingClientRect() : { left: 0 };
return {
left: el.offset().left + el.outerWidth() + (extraWidth || 0)
left: elRect.left + elRect.width - containerRect.left + (extraWidth || 0)
};
},
@ -177,16 +186,25 @@
};
},
getTopPosition: function (combo, popup, extraHeight) {
getTopPosition: function (combo, popup, extraHeight, container) {
var el = combo.element;
var popupEl = popup.element;
var elRect = el[0].getBoundingClientRect();
var popupElRect = popupEl[0].getBoundingClientRect();
var containerRect = container ? container.getBoundingClientRect() : { top: 0 };
return {
top: combo.element.offset().top - popup.element.outerHeight() - (extraHeight || 0)
top: elRect.top - containerRect.top - popupElRect.height - (extraHeight || 0)
};
},
getBottomPosition: function (combo, popup, extraHeight) {
getBottomPosition: function (combo, popup, extraHeight, container) {
var el = combo.element;
var elRect = el[0].getBoundingClientRect();
var containerRect = container ? container.getBoundingClientRect() : { top: 0 };
return {
top: el.offset().top + el.outerHeight() + (extraHeight || 0)
top: elRect.top - containerRect.top + elRect.height + (extraHeight || 0)
};
},
@ -230,18 +248,19 @@
return windowBounds.height - combo.element.offset().top - combo.element.bounds().height >= combo.element.offset().top;
},
_getLeftAlignPosition: function (combo, popup, extraWidth) {
_getLeftAlignPosition: function (combo, popup, extraWidth, container) {
var viewBounds = popup.element.bounds(),
windowBounds = BI.Widget._renderEngine.createElement("body").bounds();
var left = combo.element.offset().left + extraWidth;
var left = combo.element.offset().left - (container ? container.getBoundingClientRect().left : 0) + extraWidth;
if (left + viewBounds.width > windowBounds.width) {
left = windowBounds.width - viewBounds.width;
}
return left;
},
getLeftAlignPosition: function (combo, popup, extraWidth) {
var left = this._getLeftAlignPosition(combo, popup, extraWidth);
getLeftAlignPosition: function (combo, popup, extraWidth, container) {
var left = this._getLeftAlignPosition(combo, popup, extraWidth, container);
var dir = "";
// 如果放不下,优先使用RightAlign, 如果RightAlign也放不下, 再使用left=0
if (left < 0) {
@ -297,13 +316,14 @@
};
},
getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight, container) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = BI.Widget._renderEngine.createElement("body").bounds();
windowBounds = BI.Widget._renderEngine.createElement("body").bounds(),
containerBounds = container ? container.getBoundingClientRect() : { top: 0 };
var top, adaptHeight, dir;
if (BI.DOM.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + extraHeight;
top = comboOffset.top - containerBounds.top + extraHeight;
} else if (needAdaptHeight) {
top = comboOffset.top + extraHeight;
adaptHeight = windowBounds.height - top;
@ -353,13 +373,15 @@
};
},
getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight, container) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = BI.Widget._renderEngine.createElement("body").bounds();
var comboBounds = combo.element[0].getBoundingClientRect(),
popupBounds = popup.element[0].getBoundingClientRect(),
windowBounds = BI.Widget._renderEngine.createElement("body").bounds(),
containerBounds = container ? container.getBoundingClientRect() : { top: 0 };
var top, adaptHeight, dir;
if (BI.DOM.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + comboBounds.height - popupBounds.height - extraHeight;
top = comboOffset.top + comboBounds.height - containerBounds.top - popupBounds.height;
} else if (needAdaptHeight) {
top = 0;
adaptHeight = comboOffset.top + comboBounds.height - extraHeight;
@ -446,7 +468,7 @@
};
},
getComboPositionByDirections: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions) {
getComboPositionByDirections: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions, container) {
extraWidth || (extraWidth = 0);
extraHeight || (extraHeight = 0);
var i, direct;
@ -483,11 +505,11 @@
if (!isNeedAdaptHeight) {
var tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? 0 : extraHeight;
if (BI.DOM.isLeftSpaceEnough(combo, popup, tW)) {
left = BI.DOM.getLeftPosition(combo, popup, tW).left;
left = BI.DOM.getLeftPosition(combo, popup, tW, container).left;
if (topBottom[0] === "bottom") {
pos = BI.DOM.getTopAlignPosition(combo, popup, tH, needAdaptHeight);
pos = BI.DOM.getTopAlignPosition(combo, popup, tH, needAdaptHeight, container);
} else {
pos = BI.DOM.getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
pos = BI.DOM.getBottomAlignPosition(combo, popup, tH, needAdaptHeight, container);
}
pos.dir = "left," + pos.dir;
if (tbFirst) {
@ -503,11 +525,11 @@
if (!isNeedAdaptHeight) {
var tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? extraWidth : extraHeight;
if (BI.DOM.isRightSpaceEnough(combo, popup, tW)) {
left = BI.DOM.getRightPosition(combo, popup, tW).left;
left = BI.DOM.getRightPosition(combo, popup, tW, container).left;
if (topBottom[0] === "bottom") {
pos = BI.DOM.getTopAlignPosition(combo, popup, tH, needAdaptHeight);
pos = BI.DOM.getTopAlignPosition(combo, popup, tH, needAdaptHeight, container);
} else {
pos = BI.DOM.getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
pos = BI.DOM.getBottomAlignPosition(combo, popup, tH, needAdaptHeight, container);
}
pos.dir = "right," + pos.dir;
if (tbFirst) {
@ -522,11 +544,11 @@
case "top":
var tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
if (BI.DOM.isTopSpaceEnough(combo, popup, tH)) {
top = BI.DOM.getTopPosition(combo, popup, tH).top;
top = BI.DOM.getTopPosition(combo, popup, tH, container).top;
if (leftRight[0] === "right") {
pos = BI.DOM.getLeftAlignPosition(combo, popup, tW, needAdaptHeight);
pos = BI.DOM.getLeftAlignPosition(combo, popup, tW, container);
} else {
pos = BI.DOM.getRightAlignPosition(combo, popup, tW);
pos = BI.DOM.getRightAlignPosition(combo, popup, tW, container);
}
pos.dir = "top," + pos.dir;
if (lrFirst) {
@ -543,11 +565,11 @@
case "bottom":
var tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
if (BI.DOM.isBottomSpaceEnough(combo, popup, tH)) {
top = BI.DOM.getBottomPosition(combo, popup, tH).top;
top = BI.DOM.getBottomPosition(combo, popup, tH, container).top;
if (leftRight[0] === "right") {
pos = BI.DOM.getLeftAlignPosition(combo, popup, tW, needAdaptHeight);
pos = BI.DOM.getLeftAlignPosition(combo, popup, tW, container);
} else {
pos = BI.DOM.getRightAlignPosition(combo, popup, tW);
pos = BI.DOM.getRightAlignPosition(combo, popup, tW, container);
}
pos.dir = "bottom," + pos.dir;
if (lrFirst) {
@ -648,13 +670,13 @@
},
getComboPosition: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions, offsetStyle) {
getComboPosition: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions, offsetStyle, container) {
extraWidth || (extraWidth = 0);
extraHeight || (extraHeight = 0);
var bodyHeight = BI.Widget._renderEngine.createElement("body").bounds().height - extraHeight;
var maxHeight = Math.min(popup.attr("maxHeight") || bodyHeight, bodyHeight);
popup.resetHeight && popup.resetHeight(maxHeight);
var position = BI.DOM.getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ["bottom", "top", "right", "left"]);
var position = BI.DOM.getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ["bottom", "top", "right", "left"], container);
switch (offsetStyle) {
case "center":
if (position.change) {
@ -679,6 +701,32 @@
popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top, maxHeight));
}
return position;
},
/**
* 获取position:fixed相对定位的元素
*/
getPositionRelativeContainingBlock: function (element) {
if (['html', 'body', '#document'].indexOf((element.nodeName || '').toLowerCase()) >= 0) {
// $FlowFixMe[incompatible-return]: assume body is always available
return element.ownerDocument.body;
}
function isExcept(node) {
var _computedStyle = getComputedStyle(node);
var transform = _computedStyle.transform;
var perspective = _computedStyle.perspective;
var filter = _computedStyle.filter;
var willChange = _computedStyle["will-change"];
return [transform, perspective, filter].some(value => value !== 'none') || (willChange === "transform");
}
if (isExcept(element)) {
return element;
}
return BI.DOM.getPositionRelativeContainingBlock(element.parentNode);
},
});
})();

3
src/widget/editor/editor.search.js

@ -27,7 +27,8 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
errorText: o.errorText,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
value: o.value
value: o.value,
autoTrim: o.autoTrim,
});
this.clear = BI.createWidget({
type: "bi.icon_button",

3
src/widget/editor/editor.text.js

@ -47,7 +47,8 @@ BI.TextEditor = BI.inherit(BI.Widget, {
watermark: o.watermark,
errorText: o.errorText,
inputType: o.inputType,
autocomplete: o.autocomplete
autocomplete: o.autocomplete,
autoTrim: o.autoTrim,
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);

12
typescript/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.ts

@ -1,14 +1,4 @@
import { Widget, _Widget } from "../../core/widget";
export interface _AllValueMultiTextValueCombo extends _Widget {
getValue<T>(): T[];
populate(items: any): void;
}
export interface _AllValueMultiTextValueComboStatic {
EVENT_CONFIRM: string;
}
import { Widget } from "../../core/widget";
export declare class AllValueMultiTextValueCombo extends Widget {
static xtype: string;

4
typescript/core/base.ts

@ -1,4 +1,4 @@
import { _Widget } from "./widget";
import { Widget } from "./widget";
export interface _base {
assert: (v: any, is: Function) => Boolean;
@ -7,7 +7,7 @@ export interface _base {
UUID: () => string;
isWidget: (widget: any) => widget is _Widget;
isWidget: (widget: any) => widget is Widget;
createWidgets: (items: any, options: any, context: any) => any;

4
typescript/core/plugin.ts

@ -1,7 +1,7 @@
import { _Widget } from "./widget";
import { Widget } from "./widget";
type configWidgetFn = (type: string, options: Obj) => void
type configObjectFn = (type: string, widget: _Widget) => void
type configObjectFn = (type: string, widget: Widget) => void
export type _config = (widgetFunction: configWidgetFn | configWidgetFn[], objectFunction: configObjectFn | configObjectFn[]) => void

404
typescript/core/widget.ts

@ -1,396 +1,5 @@
import { OB, _OB } from "./ob";
export interface _WidgetStatic {
/**
*
* @param engine
*/
registerRenderEngine(engine: RenderEngine): void;
}
export interface _Widget extends _OB {
/**
* loading的锁
*/
__asking: boolean;
/**
*
*/
__async: boolean;
/**
* widget类标识符
*/
widgetName: string | null;
/**
*
*/
_isRoot: boolean;
/**
*
*/
_parent: _Widget | null;
// TODO: 完成jquery文件夹后把这块改了
/**
* dom的类jQuery对象
*/
element: {
width(): number;
height(): number;
width(width: number | string): _Widget["element"];
height(height: number | string): _Widget["element"];
[key: string]: any;
};
/**
*
*/
_children: {
[key: string]: _Widget;
};
/**
*
*/
_isMounted: boolean;
/**
* enable
*/
_manualSetEnable: boolean;
/**
* valid
*/
_manualSetValid: boolean;
_store(): void;
// 生命周期函数
/**
*
*/
beforeInit?(cb: Function): void;
/**
*
*/
beforeCreate?(): void;
/**
*
*/
created?(): void;
/**
*
*/
render?(): any;
/**
*
*/
beforeMount?(): void;
/**
*
*/
mounted?(): void;
/**
*
*/
shouldUpdate?(...args: any[]): void;
/**
*
*/
update?(...args: any[]): void;
/**
*
*/
beforeDestroy?(): void;
/**
*
*/
destroyed?(): void;
/**
* render函数
*/
_initRender: () => void;
/**
* render函数
*/
_render: () => void;
/**
*
*/
_initRoot: () => void;
/**
*
*/
_initElementWidth: () => void;
/**
*
*/
_initElementHeight: () => void;
/**
*
*/
_initVisual: () => void;
/**
*
*/
_initEffects: () => void;
/**
* mounted锁
*/
_initState: () => void;
/**
* dom
*/
_initElement: () => void;
/**
*
*/
_setParent: () => void;
/**
* @param force
* @param deep force处理
* @param lifeHook
* @param predicate widget的回调
*/
_mount(force?: boolean, deep?: boolean, lifeHook?: boolean, predicate?: Function): boolean;
/**
*
*/
_mountChildren?(): void;
/**
*
*/
isMounted(): boolean;
/**
*
*/
setWidth(w: number): void;
/**
*
*/
setHeight(h: number): void;
/**
*
*/
_setEnable(enable: boolean): void;
/**
*
*/
_setValid(valid: boolean): void;
/**
*
*/
_setVisible(visible: boolean): void;
/**
*
*/
setEnable(enable: boolean): void;
/**
*
*/
setVisible(visible: boolean): void;
/**
*
*/
setValid(valid: boolean): void;
/**
*
* @param args arguments参数
*/
doBehavior(...args: any[]): void;
/**
*
*/
getWidth(): number;
/**
*
*/
getHeight(): number;
/**
*
*/
isValid(): boolean;
/**
*
*/
addWidget(_name: any, _widget: _Widget): _Widget;
/**
* wigetname获取子元素实例
*/
getWidgetByName(_name: string): _Widget | undefined;
/**
*
* @param nameOrWidget widgetName或widget实例
*/
removeWidget(nameOrWidget: string | _Widget): void;
/**
*
*/
hasWidget(name: string): boolean;
/**
* widgetName
*/
getName(): string;
/**
* tag
* @param tag html tag
*/
setTag(tag: string): void;
/**
* tag
*/
getTag(): string;
/**
*
* @param key
* @param value
*/
attr(key: string | { [key: string]: any }, value?: any): any;
/**
* text
*/
getText(): string;
/**
* text
*/
setText(text: string): void;
/**
*
*/
getValue(): any;
/**
*
*/
setValue(...args: any[]): void;
/**
* enable
*/
isEnabled(): boolean;
/**
*
*/
isVisible(): boolean;
/**
* disable元素
*/
disable(): void;
/**
* enable元素
*/
enable(): void;
/**
* widget合法
*/
valid(): void;
/**
* 使
*/
invalid(): void;
/**
* 使
*/
invisible(..._args: any[]): void;
/**
*
*/
visible(..._args: any[]): void;
/**
*
*/
__d(): void;
/**
*
*/
_unMount(): void;
/**
* hang元素
*/
isolate(): void;
/**
*
*/
empty(): void;
/**
*
*/
reset(): void;
/**
* destory方法
*/
_destroy(): void;
/**
* destory元素
*/
destroy(): void;
}
interface RenderEngine {
// TODO: 完成jquery文件夹后把这块改了
/**
@ -406,7 +15,6 @@ interface RenderEngine {
}
export declare class Widget extends OB {
//
/**
*
* @param engine
@ -441,7 +49,7 @@ export declare class Widget extends OB {
/**
*
*/
_parent: _Widget | null;
_parent: Widget | null;
// TODO: 完成jquery文件夹后把这块改了
/**
* dom的类jQuery对象
@ -458,7 +66,7 @@ export declare class Widget extends OB {
*
*/
_children: {
[key: string]: _Widget;
[key: string]: Widget;
};
/**
@ -666,19 +274,19 @@ export declare class Widget extends OB {
/**
*
*/
addWidget(widget: _Widget): _Widget;
addWidget(_name: any, _widget: _Widget): _Widget;
addWidget(widget: Widget): Widget;
addWidget(_name: any, _widget: Widget): Widget;
/**
* wigetname获取子元素实例
*/
getWidgetByName(_name: string): _Widget | undefined;
getWidgetByName(_name: string): Widget | undefined;
/**
*
* @param nameOrWidget widgetName或widget实例
*/
removeWidget(nameOrWidget: string | _Widget): void;
removeWidget(nameOrWidget: string | Widget): void;
/**
*

Loading…
Cancel
Save