diff --git a/demo/js/base/button/demo.button.js b/demo/js/base/button/demo.button.js
index 981683e84..2514b949e 100644
--- a/demo/js/base/button/demo.button.js
+++ b/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 {
diff --git a/demo/js/case/combo/demo.text_value_combo.js b/demo/js/case/combo/demo.text_value_combo.js
index 15df83c54..4f8c4a92e 100644
--- a/demo/js/case/combo/demo.text_value_combo.js
+++ b/demo/js/case/combo/demo.text_value_combo.js
@@ -8,19 +8,21 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
render: function () {
var combo1, combo2;
- var items = [{
- text: "MVC-1",
- iconCls: "date-font",
- value: 1
- }, {
- text: "MVC-2",
- iconCls: "search-font",
- value: 2
- }, {
- text: "MVC-3",
- iconCls: "pull-right-font",
- value: 3
- }];
+ var items = [
+ {
+ text: "MVC-1",
+ iconCls: "date-font",
+ value: 1
+ }, {
+ text: "MVC-2",
+ iconCls: "search-font",
+ value: 2
+ }, {
+ text: "MVC-3",
+ iconCls: "pull-right-font",
+ value: 3
+ }
+ ];
// 创建下拉框各种场景用例
return {
@@ -195,6 +197,31 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
allowClear: true,
defaultText: "请选择",
chooseType: BI.Selection.Multi,
+ value: [1],
+ // allowSelectAll: false,
+ listeners: [
+ {
+ eventName: BI.TextValueCombo.EVENT_CHANGE,
+ action: function () {
+ console.log(this.getValue());
+ }
+ }
+ ]
+ }
+ ]
+ }),
+ this.createCombo("支持复选,不要全选功能", {
+ type: "bi.vertical",
+ items: [
+ {
+ type: "bi.text_value_combo",
+ width: 300,
+ items: items,
+ allowClear: true,
+ defaultText: "请选择",
+ chooseType: BI.Selection.Multi,
+ value: [1],
+ allowSelectAll: false,
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
diff --git a/demo/js/west.js b/demo/js/west.js
index d4cc9d59b..d2cd70109 100644
--- a/demo/js/west.js
+++ b/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;
@@ -70,4 +74,4 @@ Demo.West = BI.inherit(BI.Widget, {
}
});
Demo.West.EVENT_VALUE_CHANGE = "EVENT_VALUE_CHANGE";
-BI.shortcut("demo.west", Demo.West);
\ No newline at end of file
+BI.shortcut("demo.west", Demo.West);
diff --git a/dist/font/iconfont.eot b/dist/font/iconfont.eot
index 525a2255d..3a2dc8643 100644
Binary files a/dist/font/iconfont.eot and b/dist/font/iconfont.eot differ
diff --git a/dist/font/iconfont.svg b/dist/font/iconfont.svg
index 03bfcd64d..e45847d23 100644
--- a/dist/font/iconfont.svg
+++ b/dist/font/iconfont.svg
@@ -14,6 +14,30 @@
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dist/font/iconfont.ttf b/dist/font/iconfont.ttf
index e4c8c2ce8..11a6aec01 100644
Binary files a/dist/font/iconfont.ttf and b/dist/font/iconfont.ttf differ
diff --git a/dist/font/iconfont.woff b/dist/font/iconfont.woff
index 13c6cb98e..3a5514a21 100644
Binary files a/dist/font/iconfont.woff and b/dist/font/iconfont.woff differ
diff --git a/dist/font/iconfont.woff2 b/dist/font/iconfont.woff2
index 2c3383f13..8eea86c81 100644
Binary files a/dist/font/iconfont.woff2 and b/dist/font/iconfont.woff2 differ
diff --git a/package.json b/package.json
index b54ae8401..157b1a766 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "fineui",
- "version": "2.0.20221121190600",
+ "version": "2.0.20221210193709",
"description": "fineui",
"main": "dist/fineui_without_conflict.min.js",
"types": "dist/lib/index.d.ts",
diff --git a/src/base/combination/bubble.js b/src/base/combination/bubble.js
index 1af43b79c..7b5f57736 100644
--- a/src/base/combination/bubble.js
+++ b/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 = [{
- name: "offset",
- options: {
- offset: function () {
- return [o.adjustXOffset, (o.showArrow ? 12 : 0) + (o.adjustYOffset + o.adjustLength)];
+ 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",
diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js
index 7abbf77eb..c937f8f84 100644
--- a/src/base/combination/combo.js
+++ b/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: {},
@@ -161,7 +162,7 @@
this._assertPopupViewRender();
this.fireEvent(BI.Combo.EVENT_BEFORE_POPUPVIEW);
// popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下
- this.popupView.css({ left: -999999999, top: -99999999 });
+ this.popupView.css({ left: -99999, top: -99999 });
this.popupView.visible();
BI.each(needHideWhenAnotherComboOpen, function (i, combo) {
if (i !== self.getName()) {
@@ -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 = BI.DOM.getPositionRelativeContainingBlock(BI.isNull(o.container) ? this.element[0] : BI.Widget._renderEngine.createElement(BI.isFunction(o.container) ? o.container() : o.container)[0]);
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":
@@ -287,9 +290,6 @@
break;
}
- 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 +300,24 @@
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);
+
+ p.adaptHeight && (p.adaptHeight = p.adaptHeight / scaleY);
+ }
+
+ if ("adaptHeight" in p) {
+ this.resetListHeight(p.adaptHeight);
+ }
+
if ("left" in p) {
this.popupView.element.css({
left: p.left,
diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js
index a06f23191..bc1468450 100644
--- a/src/base/single/button/buttons/button.js
+++ b/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;
diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js
index ac9e779e9..c0a77c9f6 100644
--- a/src/base/single/editor/editor.js
+++ b/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 = [{
- el: {
- type: "bi.absolute",
- ref: function (_ref) {
- self.contentWrapper = _ref;
+ var items = [
+ {
+ el: {
+ type: "bi.absolute",
+ ref: function (_ref) {
+ self.contentWrapper = _ref;
+ },
+ items: [
+ {
+ el: this.editor,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0,
+ }
+ ],
},
- 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,
- }];
+ 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: [{
- el: this.watermark,
- left: 0,
- right: 0,
- top: 0,
- bottom: 0,
- }],
+ 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 () {
diff --git a/src/case/combo/bubblecombo/combo.bubble.js b/src/case/combo/bubblecombo/combo.bubble.js
index 5f0a4c720..7f2448ac0 100644
--- a/src/case/combo/bubblecombo/combo.bubble.js
+++ b/src/case/combo/bubblecombo/combo.bubble.js
@@ -53,6 +53,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, {
offsetStyle: o.offsetStyle,
showArrow: true,
comboClass: o.comboClass,
+ supportCSSTransform: o.supportCSSTransform,
el: o.el,
popup: () => BI.extend({
type: "bi.bubble_popup_view",
diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js
index 1128f4ed8..02642da1a 100644
--- a/src/case/combo/textvaluecombo/combo.textvalue.js
+++ b/src/case/combo/textvaluecombo/combo.textvalue.js
@@ -16,7 +16,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
el: {},
allowClear: false,
status: "success", // success | warning | error,
- title: null
+ title: null,
+ allowSelectAll: true,
});
},
@@ -78,6 +79,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
ref: ref => this.popup = ref,
chooseType: o.chooseType,
items: o.items,
+ allowSelectAll: o.allowSelectAll,
listeners: [
{
eventName: BI.TextValueComboPopup.EVENT_CHANGE,
diff --git a/src/case/combo/textvaluecombo/popup.textvalue.js b/src/case/combo/textvaluecombo/popup.textvalue.js
index 3f50089af..3411793a4 100644
--- a/src/case/combo/textvaluecombo/popup.textvalue.js
+++ b/src/case/combo/textvaluecombo/popup.textvalue.js
@@ -2,92 +2,132 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
_defaultConfig: function () {
return BI.extend(BI.TextValueComboPopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-text-icon-popup",
- chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+ allowSelectAll: true,
});
},
- render () {
+ render() {
var o = this.options, self = this;
if (o.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) {
return {
type: "bi.vertical",
vgap: 5,
- items: [{
- type: "bi.button_group",
- ref: (_ref) => {
- this.popup = _ref;
- },
- items: this._formatItems(o.items),
- chooseType: o.chooseType,
- layouts: [{
- type: "bi.vertical"
- }],
- value: o.value,
- listeners: [{
- eventName: BI.Controller.EVENT_CHANGE,
- action: function (type, val, obj) {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- if (type === BI.Events.CLICK) {
- self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj);
+ items: [
+ {
+ type: "bi.button_group",
+ ref: (_ref) => {
+ this.popup = _ref;
+ },
+ items: this._formatItems(o.items),
+ chooseType: o.chooseType,
+ layouts: [
+ {
+ type: "bi.vertical"
}
- }
- }]
- }]
+ ],
+ value: o.value,
+ listeners: [
+ {
+ eventName: BI.Controller.EVENT_CHANGE,
+ action: function (type, val, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj);
+ }
+ }
+ }
+ ]
+ }
+ ]
};
}
return {
type: "bi.vertical",
verticalAlign: BI.VerticalAlign.Stretch,
- rowSize: ["fill", ""],
- items: [{
- type: "bi.select_list",
- logic: {
- dynamic: true,
- innerVgap: 5,
- rowSize: ["", "fill"],
- verticalAlign: BI.VerticalAlign.Stretch
- },
- ref: (_ref) => {
- this.popup = _ref;
- },
- el: {
+ items: o.allowSelectAll ? [
+ {
+ type: "bi.select_list",
+ logic: {
+ dynamic: true,
+ innerVgap: 5,
+ rowSize: ["", "fill"],
+ verticalAlign: BI.VerticalAlign.Stretch
+ },
+ ref: (_ref) => {
+ this.popup = _ref;
+ },
el: {
- chooseType: o.chooseType
- }
- },
- items: this._formatItems(o.items),
- value: {
- type: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
- value: o.value
- },
- listeners: [{
- eventName: BI.SelectList.EVENT_CHANGE,
- action: function (val) {
- self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val);
- }
- }]
- }, {
- type: "bi.center",
- cls: "list-view-toolbar bi-high-light bi-split-top",
- height: 24,
- items: BI.createItems([{
- type: "bi.text_button",
- text: BI.i18nText("BI-Basic_Clears"),
- handler: function () {
- self.fireEvent(BI.TextValueComboPopup.EVENT_CLEAR);
- }
+ el: {
+ chooseType: o.chooseType,
+ }
+ },
+ items: this._formatItems(o.items),
+ value: {
+ type: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ value: o.value
+ },
+ height: "fill",
+ listeners: [
+ {
+ eventName: BI.SelectList.EVENT_CHANGE,
+ action: function (val) {
+ self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val);
+ }
+ }
+ ]
}, {
- type: "bi.text_button",
- text: BI.i18nText("BI-Basic_OK"),
- handler: function () {
- self.fireEvent(BI.TextValueComboPopup.EVENT_CONFIRM);
- }
- }], {
- once: false,
- shadow: true,
- isShadowShowingOnSelected: true
- })
- }]
+ type: "bi.center",
+ cls: "list-view-toolbar bi-high-light bi-split-top",
+ height: 24,
+ items: BI.createItems([
+ {
+ type: "bi.text_button",
+ text: BI.i18nText("BI-Basic_Clears"),
+ handler: function () {
+ self.fireEvent(BI.TextValueComboPopup.EVENT_CLEAR);
+ }
+ }, {
+ type: "bi.text_button",
+ text: BI.i18nText("BI-Basic_OK"),
+ handler: function () {
+ self.fireEvent(BI.TextValueComboPopup.EVENT_CONFIRM);
+ }
+ }
+ ], {
+ once: false,
+ shadow: true,
+ isShadowShowingOnSelected: true
+ })
+ }
+ ] : [
+ {
+ type: "bi.list_pane",
+ logic: {
+ dynamic: true,
+ innerVgap: 5,
+ rowSize: ["", "fill"],
+ verticalAlign: BI.VerticalAlign.Stretch
+ },
+ ref: (_ref) => {
+ this.popup = _ref;
+ },
+ el: {
+ chooseType: o.chooseType,
+ },
+ items: this._formatItems(o.items),
+ value: o.value,
+ height: "fill",
+ listeners: [
+ {
+ eventName: BI.ListPane.EVENT_CHANGE,
+ action: function (val) {
+ self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val);
+ }
+ }
+ ]
+ }
+ ],
};
},
@@ -117,6 +157,9 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
return this.popup.getValue();
}
var val = this.popup.getValue();
+ if (!this.options.allowSelectAll) {
+ return val;
+ }
if (val.type === BI.ButtonGroup.CHOOSE_TYPE_MULTI) {
return val.value;
} else {
@@ -128,6 +171,10 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
if (this.options.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) {
return this.popup.setValue(v);
}
+ if (!this.options.allowSelectAll) {
+ this.popup.setValue(v);
+ return;
+ }
this.popup.setValue({
type: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
value: v
diff --git a/src/case/editor/editor.clear.js b/src/case/editor/editor.clear.js
index 6fd199a43..e18ab9599 100644
--- a/src/case/editor/editor.clear.js
+++ b/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);
diff --git a/src/case/editor/editor.defaulttext.js b/src/case/editor/editor.defaulttext.js
index 4cfaf59a5..fe88d27bb 100644
--- a/src/case/editor/editor.defaulttext.js
+++ b/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;
diff --git a/src/case/editor/editor.shelter.js b/src/case/editor/editor.shelter.js
index 31883614c..4cb8e4d75 100644
--- a/src/case/editor/editor.shelter.js
+++ b/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",
diff --git a/src/case/editor/editor.sign.js b/src/case/editor/editor.sign.js
index 7a69a5005..0fb65fa0d 100644
--- a/src/case/editor/editor.sign.js
+++ b/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",
diff --git a/src/case/editor/editor.state.js b/src/case/editor/editor.state.js
index 8ed915716..9c3f340f9 100644
--- a/src/case/editor/editor.state.js
+++ b/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",
diff --git a/src/case/editor/editor.state.simple.js b/src/case/editor/editor.state.simple.js
index 4d17ab30e..96be87aa1 100644
--- a/src/case/editor/editor.state.simple.js
+++ b/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: [{
- el: this.text,
- left: 0,
- right: 0,
- top: 0,
- bottom: 0
- }]
+ 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);
diff --git a/src/case/linearsegment/linear.segment.js b/src/case/linearsegment/linear.segment.js
index b0b00f95b..41d282263 100644
--- a/src/case/linearsegment/linear.segment.js
+++ b/src/case/linearsegment/linear.segment.js
@@ -47,6 +47,14 @@ BI.LinearSegment = BI.inherit(BI.Widget, {
getValue: function () {
return this.buttonGroup.getValue();
- }
+ },
+
+ populate: function (buttons) {
+ var o = this.options;
+ this.buttonGroup.populate([BI.createItems(buttons, {
+ type: "bi.linear_segment_button",
+ height: o.height
+ })])
+ },
});
BI.shortcut("bi.linear_segment", BI.LinearSegment);
diff --git a/src/case/segment/segment.js b/src/case/segment/segment.js
index 3f323ffb6..2c1dda918 100644
--- a/src/case/segment/segment.js
+++ b/src/case/segment/segment.js
@@ -58,6 +58,15 @@ BI.Segment = BI.inherit(BI.Widget, {
getValue: function () {
return this.buttonGroup.getValue();
},
+
+ populate: function (buttons) {
+ var o = this.options;
+ this.buttonGroup.populate([BI.createItems(buttons, {
+ type: "bi.segment_button",
+ height: BI.toPix(o.height, 2),
+ whiteSpace: o.whiteSpace,
+ })]);
+ },
});
BI.Segment.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.segment", BI.Segment);
diff --git a/src/core/platform/web/dom.js b/src/core/platform/web/dom.js
index 05757959d..17dd9d479 100644
--- a/src/core/platform/web/dom.js
+++ b/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)
};
},
@@ -201,9 +219,9 @@
},
isRightSpaceEnough: function (combo, popup, extraWidth) {
- var viewBounds = popup.element.bounds(),
- windowBounds = BI.Widget._renderEngine.createElement("body").bounds();
- return BI.DOM.getRightPosition(combo, popup, extraWidth).left + viewBounds.width <= windowBounds.width;
+ var viewBounds = popup.element[0].getBoundingClientRect(),
+ viewportBounds = document.documentElement.getBoundingClientRect();
+ return BI.DOM.getRightPosition(combo, popup, extraWidth).left + viewBounds.width <= viewportBounds.width;
},
isInnerRightSpaceEnough: function (combo, popup, extraWidth) {
@@ -215,9 +233,9 @@
},
isBottomSpaceEnough: function (combo, popup, extraHeight) {
- var viewBounds = popup.element.bounds(),
- windowBounds = BI.Widget._renderEngine.createElement("body").bounds();
- return BI.DOM.getBottomPosition(combo, popup, extraHeight).top + viewBounds.height <= windowBounds.height;
+ var viewBounds = popup.element[0].getBoundingClientRect(),
+ viewportBounds = document.documentElement.getBoundingClientRect();
+ return BI.DOM.getBottomPosition(combo, popup, extraHeight).top + viewBounds.height <= viewportBounds.height;
},
isRightSpaceLarger: function (combo) {
@@ -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,24 +316,26 @@
};
},
- 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();
+ var comboBounds = combo.element[0].getBoundingClientRect(),
+ popupBounds = popup.element[0].getBoundingClientRect(),
+ viewportBounds = document.documentElement.getBoundingClientRect(),
+ 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;
+ top = comboBounds.top - containerBounds.top + extraHeight;
+ adaptHeight = viewportBounds.height - comboBounds.top;
} else if (BI.DOM.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
// 下方空间不足且不允许调整高度的情况下,优先使用上对齐
- top = comboOffset.top + comboBounds.height - popupBounds.height - extraHeight;
+ top = comboBounds.top + comboBounds.height - popupBounds.height - containerBounds.top - extraHeight;
dir = "top";
} else {
- top = windowBounds.height - popupBounds.height;
+ top = viewportBounds.height - popupBounds.height;
if (top < extraHeight) {
- adaptHeight = windowBounds.height - extraHeight;
+ adaptHeight = viewportBounds.height - extraHeight;
}
}
if (top < extraHeight) {
@@ -353,19 +374,21 @@
};
},
- 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;
+ top = 0 - containerBounds.top;
+ adaptHeight = comboBounds.top + comboBounds.height - extraHeight;
} else if (BI.DOM.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
// 上方空间不足且不允许调整高度的情况下,优先使用下对齐
- top = comboOffset.top + extraHeight;
+ top = comboOffset.top - containerBounds.top + extraHeight;
dir = "bottom";
} else {
top = 0;
@@ -373,7 +396,7 @@
adaptHeight = windowBounds.height - extraHeight;
}
}
- if (top < 0) {
+ if (top + containerBounds.top < 0) {
top = 0;
}
return adaptHeight ? {
@@ -446,7 +469,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 +506,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 +526,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 +545,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 +566,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) {
@@ -635,7 +658,7 @@
firstDir = "top";
}
if (leftRight[0] === "right") {
- pos = BI.DOM.getLeftAlignPosition(combo, popup, extraWidth, needAdaptHeight);
+ pos = BI.DOM.getLeftAlignPosition(combo, popup, extraWidth);
pos.top = top;
pos.dir = firstDir + "," + pos.dir;
return pos;
@@ -648,13 +671,13 @@
},
- getComboPosition: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions, offsetStyle) {
+ getComboPosition: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions, offsetStyle, positionRelativeElement) {
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"], positionRelativeElement);
switch (offsetStyle) {
case "center":
if (position.change) {
@@ -676,9 +699,35 @@
break;
}
if (needAdaptHeight === true) {
- popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top, maxHeight));
+ popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top + (positionRelativeElement ? positionRelativeElement.getBoundingClientRect().top : 0), 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);
+ },
});
})();
diff --git a/src/core/platform/web/function.js b/src/core/platform/web/function.js
index 1c74836e2..152933882 100644
--- a/src/core/platform/web/function.js
+++ b/src/core/platform/web/function.js
@@ -137,5 +137,14 @@ BI._.extend(BI, {
return version[1] * 1;
}
return 0;
+ },
+
+ getMinimumFontSize: function () {
+ const el = document.createElement('div');
+ el.style.fontSize = "0px";
+ document.body.appendChild(el);
+ const size = getComputedStyle(el).fontSize;
+ el.remove();
+ return parseInt(size);
}
});
diff --git a/src/less/core/utils/motion/zoom.less b/src/less/core/utils/motion/zoom.less
index 7e0e0ec44..edeab6df4 100644
--- a/src/less/core/utils/motion/zoom.less
+++ b/src/less/core/utils/motion/zoom.less
@@ -4,7 +4,7 @@
.make-motion(@className, @keyframeName, @duration);
.@{className}-enter,
.@{className}-appear {
- transform: scale(0); // need this by yiminghe
+ //transform: scale(0); // need this by yiminghe, but dailer did not need this
opacity: 0;
animation-timing-function: @ease-out-circ;
diff --git a/src/less/widget/multiselect/trigger/button.checkselected.less b/src/less/widget/multiselect/trigger/button.checkselected.less
index 4a36315b0..ded0da5eb 100644
--- a/src/less/widget/multiselect/trigger/button.checkselected.less
+++ b/src/less/widget/multiselect/trigger/button.checkselected.less
@@ -2,7 +2,7 @@
.bi-multi-select-check-selected-button {
z-index: 1;
- .border-radius(50%);
+ .border-radius(99999px);
&:active {
color: @color-bi-text-highlight;
diff --git a/src/less/widget/multitree/trigger/multi.tree.button.checkselected.less b/src/less/widget/multitree/trigger/multi.tree.button.checkselected.less
index 5393d7b24..dd7fe2527 100644
--- a/src/less/widget/multitree/trigger/multi.tree.button.checkselected.less
+++ b/src/less/widget/multitree/trigger/multi.tree.button.checkselected.less
@@ -6,11 +6,11 @@
z-index: 1;
}
.trigger-check-text {
- .border-radius(8px);
- .border-radius(calc(var(--css-scale, 1) * 8px));
+ .border-radius(99999px);
z-index: 1;
+
&:active {
background-color: @color-bi-background-multi-select-trigger-check-selected;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/widget/downlist/combo.downlist.js b/src/widget/downlist/combo.downlist.js
index 8b9aa4c0c..10c39bfbf 100644
--- a/src/widget/downlist/combo.downlist.js
+++ b/src/widget/downlist/combo.downlist.js
@@ -44,7 +44,8 @@
popup: {},
minWidth: 140,
maxHeight: 1000,
- destroyWhenHide: false
+ destroyWhenHide: false,
+ isDefaultInit: true,
});
},
@@ -57,7 +58,7 @@
type: "bi.combo",
trigger: o.trigger,
isNeedAdjustWidth: false,
- isDefaultInit: true,
+ isDefaultInit: o.isDefaultInit,
container: o.container,
adjustLength: o.adjustLength,
direction: o.direction,
diff --git a/src/widget/editor/editor.search.js b/src/widget/editor/editor.search.js
index 29e4983eb..bd40ae5a9 100644
--- a/src/widget/editor/editor.search.js
+++ b/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",
diff --git a/src/widget/editor/editor.text.js b/src/widget/editor/editor.text.js
index 19f51fd73..022b5f2ad 100644
--- a/src/widget/editor/editor.text.js
+++ b/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);
diff --git a/typescript/base/single/button/button.basic.ts b/typescript/base/single/button/button.basic.ts
index 95ee1a3c3..24cfc2484 100644
--- a/typescript/base/single/button/button.basic.ts
+++ b/typescript/base/single/button/button.basic.ts
@@ -38,7 +38,7 @@ export declare class BasicButton extends Single {
trigger?: string | null;
handler?: Function;
bubble?: Function | null | string;
- text?: string;
+ text?: string | ((context: any) => string);
el?: Obj;
} & Single["props"];
diff --git a/typescript/case/combo/combo.textvalue.ts b/typescript/case/combo/combo.textvalue.ts
index 0a50d2342..128ec03b6 100644
--- a/typescript/case/combo/combo.textvalue.ts
+++ b/typescript/case/combo/combo.textvalue.ts
@@ -5,5 +5,10 @@ export declare class TextValueCombo extends Widget {
static EVENT_CHANGE: string;
- populate(items: any): void;
+ clear(): void;
+ setText(text: string): void;
+ setValue(value: any): void;
+ setStatus(status: "success" | "warning" | "error"): void;
+ getValue(): any[];
+ populate(items: any[]): void;
}
diff --git a/typescript/case/combo/popup.textvalue.ts b/typescript/case/combo/popup.textvalue.ts
new file mode 100644
index 000000000..a3fe1b0d1
--- /dev/null
+++ b/typescript/case/combo/popup.textvalue.ts
@@ -0,0 +1,13 @@
+import { Pane } from "../../base/pane";
+
+export declare class TextValueComboPopup extends Pane {
+ static xtype: string;
+
+ static EVENT_CHANGE: string;
+ static EVENT_CLEAR: string;
+ static EVENT_CONFIRM: string;
+
+ populate(items: any[]): void;
+ getValue(): any;
+ setValue(value: any): void;
+}
diff --git a/typescript/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.ts b/typescript/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.ts
index 990ef0cd1..960fa6219 100644
--- a/typescript/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.ts
+++ b/typescript/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.ts
@@ -1,14 +1,4 @@
-import { Widget, _Widget } from "../../core/widget";
-
-export interface _AllValueMultiTextValueCombo extends _Widget {
- getValue(): 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;
diff --git a/typescript/core/base.ts b/typescript/core/base.ts
index 6182a0833..79dc317af 100644
--- a/typescript/core/base.ts
+++ b/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;
@@ -38,7 +38,9 @@ export interface _base {
size: (collection: any) => number;
- each: (collection: T[] | object | string, callback?: ((index: number, value: T) => void) | object | string, thisArg?: any) => any;
+ each(collection: ArrayLike, iteratee?: (index: number, value: T) => void, thisArg?: any): ArrayLike;
+ each(collection: T, iteratee?: (index: K, value: T[K]) => void, thisArg?: any): T;
+ each(collection: T, iteratee?: any, thisArg?: any): T;
map: (collection: T[] | object | string | null | undefined, callback?: ((index: number, value: T) => U) | object | string, thisArg?: any) => U[];
diff --git a/typescript/core/plugin.ts b/typescript/core/plugin.ts
index 83c1176fb..afae32a91 100644
--- a/typescript/core/plugin.ts
+++ b/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
diff --git a/typescript/core/widget.ts b/typescript/core/widget.ts
index 4c1fc9d2f..3cd8f175e 100644
--- a/typescript/core/widget.ts
+++ b/typescript/core/widget.ts
@@ -1,401 +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;
-
- /**
- * 渲染引擎
- */
- _renderEngine: RenderEngine;
-
- _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文件夹后把这块改了
/**
@@ -411,13 +15,17 @@ interface RenderEngine {
}
export declare class Widget extends OB {
- //
/**
* 注册渲染引擎
* @param engine 引擎
*/
static registerRenderEngine(engine: RenderEngine): void;
+ /**
+ * 渲染引擎
+ */
+ static _renderEngine: RenderEngine;
+
/**
* 出现loading的锁
*/
@@ -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;
};
/**
@@ -476,11 +84,6 @@ export declare class Widget extends OB {
*/
_manualSetValid: boolean;
- /**
- * 渲染引擎
- */
- _renderEngine: RenderEngine;
-
_store(): void;
// 生命周期函数
@@ -671,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;
/**
* 是否有某个子元素
diff --git a/typescript/index.ts b/typescript/index.ts
index a1b9831c9..cf63c604d 100644
--- a/typescript/index.ts
+++ b/typescript/index.ts
@@ -20,6 +20,7 @@ import { IconChangeButton } from "./case/button/icon/icon.change";
import { MultiSelectItem } from "./case/button/item.multiselect";
import { BubbleCombo } from "./case/combo/bubblecombo/combo.bubble";
import { TextValueCombo } from "./case/combo/combo.textvalue";
+import { TextValueComboPopup } from "./case/combo/popup.textvalue";
import { SmallTextValueCombo } from "./case/combo/combo.textvaluesmall";
import { SearchTextValueCombo } from "./case/combo/searchtextvaluecombo/combo.searchtextvalue";
import { SignEditor } from "./case/editor/editor.sign";
@@ -226,6 +227,7 @@ export interface BI extends _func, _i18n, _base, _inject, _var, _web, _utils {
ButtonGroup: typeof ButtonGroup;
Combo: typeof Combo;
TextValueCombo: typeof TextValueCombo;
+ TextValueComboPopup: typeof TextValueComboPopup;
SmallTextValueCombo: typeof SmallTextValueCombo;
BubbleCombo: typeof BubbleCombo;
AllValueMultiTextValueCombo: typeof AllValueMultiTextValueCombo;
@@ -464,6 +466,7 @@ export {
MultiSelectBar,
SelectList,
TextValueCombo,
+ TextValueComboPopup,
SmallTextValueCombo,
Editor,
IconLabel,