Browse Source

Pull request #1: 从master合一下分支到es6

Merge in ~ZHENFEI.LI/fineui from master to es6

* commit '0890d11ff00ca89356a5a9655e10c184138d8a45': (46 commits)
  auto upgrade version to 2.0.20221228163952
  REPORT-85533 fix: BI.parseDateTime方法对%l:%M:%S %P这种格式的日期如果带有秒数解析出错
  auto upgrade version to 2.0.20221226102617
  auto upgrade version to 2.0.20221223112542
  BI-119128 fix: 【自适应迭代发散】小屏编辑,高度适应+自定义(1366*449),直接预览,文本控件下拉选项偏离
  auto upgrade version to 2.0.20221223092552
  BI-119112 fix:editor弹出errorbubble位置修改
  Revert "BI-119112 fix:editor可以自定义error bubble位置"
  BI-119112 fix:editor可以自定义error bubble位置
  BI-119217 fix: 【6.0.6冒烟】等比自适应-高清屏-宽度自适应预览,下拉树查看已选展示异常
  auto upgrade version to 2.0.20221221181657
  REPORT-87371 fix: 【BI6.0】【目录管理-管理首页】添加首页时模板类型的下拉框为空
  REPORT-87371 fix: 【BI6.0】【目录管理-管理首页】添加首页时模板类型的下拉框为空
  auto upgrade version to 2.0.20221221100651
  auto upgrade version to 2.0.20221218194544
  auto upgrade version to 2.0.20221216170431
  BI-118262 fix: 树过滤组件搜索过滤不生效
  BI-117667 fix: 【6.0.5冒烟】数值下拉选择多个选项,查看已选点击加载更多展示重复数据
  auto upgrade version to 2.0.20221216114354
  KERNEL-13893 feat: 颜色选择器默认色板候选调整
  ...
es6
Zhenfei.Li-李振飞 2 years ago
parent
commit
4f558b6410
  1. 3
      demo/js/widget/numbereditor/demo.number_editor.js
  2. 2
      package.json
  3. 54
      src/base/combination/combo.js
  4. 8
      src/case/colorchooser/colorpicker/button/button.colorshow.js
  5. 253
      src/case/colorchooser/colorpicker/colorpicker.hex.js
  6. 58
      src/case/colorchooser/colorpicker/editor.colorpicker.hex.js
  7. 36
      src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js
  8. 14
      src/case/colorchooser/colorpicker/editor.colorpicker.js
  9. 8
      src/case/colorchooser/colorpicker/editor.colorpicker.simple.js
  10. 10
      src/case/linearsegment/linear.segment.js
  11. 9
      src/case/segment/segment.js
  12. 2
      src/case/ztree/parttree.js
  13. 13
      src/core/2.base.js
  14. 10
      src/core/controller/controller.bubbles.js
  15. 37
      src/core/controller/controller.layer.js
  16. 310
      src/core/controller/popper.js
  17. 189
      src/core/platform/web/dom.js
  18. 3
      src/core/platform/web/function.js
  19. 15
      src/widget/multiselect/check/multiselect.display.js
  20. 22
      src/widget/multitree/multi.tree.combo.js
  21. 23
      src/widget/multitree/multi.tree.insert.combo.js
  22. 18
      src/widget/multitree/trigger/multi.tree.search.insert.pane.js
  23. 12
      src/widget/multitree/trigger/multi.tree.search.pane.js
  24. 15
      src/widget/multitree/trigger/searcher.multi.tree.js
  25. 16
      src/widget/numbereditor/number.editor.js
  26. 2
      typescript/base/single/button/button.basic.ts

3
demo/js/widget/numbereditor/demo.number_editor.js

@ -14,7 +14,8 @@ Demo.FileManager = BI.inherit(BI.Widget, {
}, },
height: 24, height: 24,
width: 150, width: 150,
errorText: "hahah" errorText: "hahah",
watermark: "每个人都是自己健康的第一责任人",
}); });
editor1.on(BI.NumberEditor.EVENT_CHANGE, function () { editor1.on(BI.NumberEditor.EVENT_CHANGE, function () {
if (BI.parseFloat(this.getValue()) < 1) { if (BI.parseFloat(this.getValue()) < 1) {

2
package.json

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

54
src/base/combination/combo.js

@ -38,9 +38,9 @@
adjustLength: 0, // 调整的距离 adjustLength: 0, // 调整的距离
adjustXOffset: 0, adjustXOffset: 0,
adjustYOffset: 0, adjustYOffset: 0,
supportCSSTransform: false, supportCSSTransform: true,
hideChecker: BI.emptyFn, hideChecker: BI.emptyFn,
offsetStyle: "left", // left,right,center offsetStyle: "", // "",center,middle
el: {}, el: {},
popup: {}, popup: {},
comboClass: "bi-combo-popup", comboClass: "bi-combo-popup",
@ -162,7 +162,7 @@
this._assertPopupViewRender(); this._assertPopupViewRender();
this.fireEvent(BI.Combo.EVENT_BEFORE_POPUPVIEW); this.fireEvent(BI.Combo.EVENT_BEFORE_POPUPVIEW);
// popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下 // popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下
this.popupView.css({ left: -999999999, top: -99999999 }); this.popupView.css({ left: -99999, top: -99999 });
this.popupView.visible(); this.popupView.visible();
BI.each(needHideWhenAnotherComboOpen, function (i, combo) { BI.each(needHideWhenAnotherComboOpen, function (i, combo) {
if (i !== self.getName()) { if (i !== self.getName()) {
@ -196,31 +196,33 @@
this.popupView.visible(); this.popupView.visible();
var combo = (o.belowMouse && BI.isNotNull(e)) ? { var combo = (o.belowMouse && BI.isNotNull(e)) ? {
element: { element: {
0: e.target, 0: BI.extend({}, e.target, {
offset: function () { getBoundingClientRect: function () {
return { return {
left: e.pageX, left: e.pageX,
top: e.pageY, top: e.pageY,
width: 0,
height: 0,
}; };
}, }
bounds: function () { }),
// offset为其相对于父定位元素的偏移 offset: function () {
return { return {
x: e.offsetX, left: e.pageX,
y: e.offsetY, top: e.pageY,
width: 0,
height: 24,
}; };
}, },
outerWidth: function () {
return 0;
},
outerHeight: function () {
return 24;
},
}, },
} : this.combo; } : 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;
var positionRelativeElement = BI.DOM.getPositionRelativeContainingBlock(
BI.isNull(o.container)
? this.element[0]
: BI.isWidget(o.container)
? o.container.element[0]
: BI.Widget._renderEngine.createElement(BI.isFunction(o.container) ? o.container() : o.container)[0]
);
switch (o.direction) { switch (o.direction) {
case "bottom": case "bottom":
case "bottom,right": case "bottom,right":
@ -290,10 +292,6 @@
break; break;
} }
if ("adaptHeight" in p) {
this.resetListHeight(p.adaptHeight);
}
var width = this.combo.element.outerWidth(); var width = this.combo.element.outerWidth();
var height = this.combo.element.outerHeight(); var height = this.combo.element.outerHeight();
this.popupView.setDirection && this.popupView.setDirection(p.dir, { this.popupView.setDirection && this.popupView.setDirection(p.dir, {
@ -312,8 +310,14 @@
var scaleX = positonedRect.width / positionRelativeElement.offsetWidth; var scaleX = positonedRect.width / positionRelativeElement.offsetWidth;
var scaleY = positonedRect.height / positionRelativeElement.offsetHeight; var scaleY = positonedRect.height / positionRelativeElement.offsetHeight;
p.top && (p.top = p.top / scaleY); p.top && (p.top = Math.round(p.top / scaleY + positionRelativeElement.scrollTop));
p.left && (p.left = p.left / scaleX); p.left && (p.left = Math.round(p.left / scaleX + positionRelativeElement.scrollLeft));
p.adaptHeight && (p.adaptHeight = Math.round(p.adaptHeight / scaleY));
}
if ("adaptHeight" in p) {
this.resetListHeight(p.adaptHeight);
} }
if ("left" in p) { if ("left" in p) {

8
src/case/colorchooser/colorpicker/button/button.colorshow.js

@ -6,14 +6,15 @@
BI.ColorChooserShowButton = BI.inherit(BI.BasicButton, { BI.ColorChooserShowButton = BI.inherit(BI.BasicButton, {
props: { props: {
baseCls: 'bi-color-chooser-show-button bi-border bi-list-item-effect', baseCls: 'bi-color-chooser-show-button bi-border bi-list-item-effect bi-border-radius',
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
type: 'bi.htape', type: 'bi.htape',
items: [{ items: [
{
el: { el: {
type: "bi.icon_label", type: "bi.icon_label",
ref: function (_ref) { ref: function (_ref) {
@ -28,8 +29,9 @@ BI.ColorChooserShowButton = BI.inherit(BI.BasicButton, {
type: 'bi.label', type: 'bi.label',
textAlign: 'left', textAlign: 'left',
text: o.text, text: o.text,
}]
} }
]
};
}, },
doClick: function () { doClick: function () {

253
src/case/colorchooser/colorpicker/colorpicker.hex.js

@ -11,118 +11,173 @@ BI.HexColorPicker = BI.inherit(BI.Widget, {
}, },
_items: [ _items: [
[{ [
value: "#808080" {
}, { "value": "#999999"
value: "#ffffff" },
}, { {
value: "#ffebe5" "value": "#FFFFFF"
}, { },
value: "#ffddba" {
}, { "value": "#FFE5E5"
value: "#ffeebb" },
}, { {
value: "#d4e9bf" "value": "#FFF1E5"
}, { },
value: "#c7e1e1" {
}, { "value": "#FFF9E5"
value: "#bfe3f0" },
}, { {
value: "#ccd6eb" "value": "#E9F5E9"
}], },
[{ {
value: "#616161" "value": "#EAEEFF"
}, { },
value: "#f2f2f2" {
}, { "value": "#EFEBF7"
value: "#ffd6cc" },
}, { {
value: "#ffb87a" "value": "#FCE8EF"
}, { }
value: "#ffdf91" ],
}, { [
value: "#b7d2b6" {
}, { "value": "#737373"
value: "#a3d2c9" },
}, { {
value: "#8ab6d6" "value": "#F2F2F2"
}, { },
value: "#bcbce0" {
}], "value": "#FFA6A6"
[{ },
value: "#404040" {
}, { "value": "#FFD0A6"
value: "#dedede" },
}, { {
value: "#ffab9b" "value": "#FFEDA6"
}, { },
value: "#eb8a3a" {
}, { "value": "#B3DCB2"
value: "#ffc947" },
}, { {
value: "#8aa964" "value": "#B9C6FF"
}, { },
value: "#5eaaa0" {
}, { "value": "#CABAE6"
value: "#2978b5" },
}, { {
value: "#8f8faa" "value": "#F8B1C9"
}], }
[{ ],
value: "#202020" [
}, { {
value: "#bfbfbf" "value": "#4C4C4C"
}, { },
value: "#df7461" {
}, { "value": "#D9D9D9"
value: "#cf7536" },
}, { {
value: "#e6b63b" "value": "#FF5959"
}, { },
value: "#5b8a72" {
}, { "value": "#FFA759"
value: "#3b9aa3" },
}, { {
value: "#336291" "value": "#FFDD59"
}, { },
value: "#58568f" {
}], "value": "#7EBE70"
[{ },
value: "#000000" {
}, { "value": "#7B95FF"
value: "#a1a1a1" },
}, { {
value: "#b55140" "value": "#9C7FD0"
}, { },
value: "#a6713c" {
}, { "value": "#F06D99"
value: "#ad975f" }
}, { ],
value: "#5f7d6e" [
}, { {
value: "#3b7480" "value": "#262626"
}, { },
value: "#425d78" {
}, { "value": "#BFBFBF"
value: "#62608a" },
}] {
"value": "#FF0000"
},
{
"value": "#FF7800"
},
{
"value": "#FFCB00"
},
{
"value": "#259B23"
},
{
"value": "#355CFF"
},
{
"value": "#673AB7"
},
{
"value": "#E91E63"
}
],
[
{
"value": "#000000"
},
{
"value": "#A6A6A6"
},
{
"value": "#A80000"
},
{
"value": "#B65600"
},
{
"value": "#CEB000"
},
{
"value": "#0E550C"
},
{
"value": "#09269C"
},
{
"value": "#3A1A73"
},
{
"value": "#B30072"
}
]
], ],
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
type: "bi.button_group", type: "bi.button_group",
items: this._digest(o.items || this._items), items: this._digest(o.items || this._items),
layouts: [{ layouts: [
{
type: "bi.grid", type: "bi.grid",
}], }
],
value: o.value, value: o.value,
listeners: [{ listeners: [
{
eventName: BI.ButtonGroup.EVENT_CHANGE, eventName: BI.ButtonGroup.EVENT_CHANGE,
action: function () { action: function () {
self.fireEvent(BI.HexColorPicker.EVENT_CHANGE, arguments); self.fireEvent(BI.HexColorPicker.EVENT_CHANGE, arguments);
} }
}], }
],
ref: function (_ref) { ref: function (_ref) {
self.colors = _ref; self.colors = _ref;
} }

58
src/case/colorchooser/colorpicker/editor.colorpicker.hex.js

@ -33,14 +33,15 @@ BI.HexColorPickerEditor = BI.inherit(BI.Widget, {
var Ws = BI.map(BI.range(0, 3), function () { var Ws = BI.map(BI.range(0, 3), function () {
return { return {
type: "bi.small_text_editor", type: "bi.small_text_editor",
cls: "color-picker-editor-input", cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker, validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
allowBlank: true, allowBlank: true,
value: 255, value: 255,
width: c.RGB_WIDTH, width: c.RGB_WIDTH,
height: 24, height: 24,
listeners: [{ listeners: [
{
eventName: BI.TextEditor.EVENT_CHANGE, eventName: BI.TextEditor.EVENT_CHANGE,
action: function () { action: function () {
self._checkEditors(); self._checkEditors();
@ -49,33 +50,39 @@ BI.HexColorPickerEditor = BI.inherit(BI.Widget, {
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
} }
} }
}] }
]
}; };
}); });
return { return {
type: "bi.absolute", type: "bi.absolute",
items: [{ items: [
{
el: { el: {
type: "bi.vertical", type: "bi.vertical",
tgap: 10, tgap: 10,
items: [{ items: [
{
type: 'bi.vertical_adapt', type: 'bi.vertical_adapt',
columnSize: ["fill", 'fill'], columnSize: ["fill", 'fill'],
height: 24, height: 24,
items: [{ items: [
{
type: "bi.color_picker_show_button", type: "bi.color_picker_show_button",
cls: "trans-color-icon", cls: "trans-color-icon",
height: 22, height: 22,
title: BI.i18nText("BI-Transparent_Color"), title: BI.i18nText("BI-Transparent_Color"),
text: BI.i18nText("BI-Transparent_Color"), text: BI.i18nText("BI-Transparent_Color"),
listeners: [{ listeners: [
{
eventName: BI.ColorChooserShowButton.EVENT_CHANGE, eventName: BI.ColorChooserShowButton.EVENT_CHANGE,
action: function () { action: function () {
self.setValue("transparent"); self.setValue("transparent");
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
} }
}], }
],
ref: function (_ref) { ref: function (_ref) {
self.transparent = _ref; self.transparent = _ref;
} }
@ -86,26 +93,30 @@ BI.HexColorPickerEditor = BI.inherit(BI.Widget, {
height: 22, height: 22,
title: BI.i18nText("BI-Basic_Auto"), title: BI.i18nText("BI-Basic_Auto"),
text: BI.i18nText("BI-Basic_Auto"), text: BI.i18nText("BI-Basic_Auto"),
listeners: [{ listeners: [
{
eventName: BI.ColorChooserShowButton.EVENT_CHANGE, eventName: BI.ColorChooserShowButton.EVENT_CHANGE,
action: function () { action: function () {
self.setValue(""); self.setValue("");
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
} }
}], }
],
ref: function (_ref) { ref: function (_ref) {
self.none = _ref; self.none = _ref;
} }
}, },
lgap: 10, lgap: 10,
}] }
]
}, { }, {
el: { el: {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
columnSize: [22, 10, 'fill', 12, c.RGB_WIDTH, 12, c.RGB_WIDTH, 12, c.RGB_WIDTH], columnSize: [22, 10, 'fill', 12, c.RGB_WIDTH, 12, c.RGB_WIDTH, 12, c.RGB_WIDTH],
rgap: 5, rgap: 5,
items: [{ items: [
{
el: { el: {
type: "bi.layout", type: "bi.layout",
cls: "color-picker-editor-display bi-card bi-border", cls: "color-picker-editor-display bi-card bi-border",
@ -125,13 +136,14 @@ BI.HexColorPickerEditor = BI.inherit(BI.Widget, {
ref: function (_ref) { ref: function (_ref) {
self.hexEditor = _ref; self.hexEditor = _ref;
}, },
cls: "color-picker-editor-input", cls: "color-picker-editor-input bi-border-radius",
validationChecker: this._hexChecker, validationChecker: this._hexChecker,
allowBlank: true, allowBlank: true,
errorText: BI.i18nText("BI-Color_Picker_Error_Text_Hex"), errorText: BI.i18nText("BI-Color_Picker_Error_Text_Hex"),
width: c.HEX_WIDTH, width: c.HEX_WIDTH,
height: 24, height: 24,
listeners: [{ listeners: [
{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function () { action: function () {
self._checkHexEditor(); self._checkHexEditor();
@ -141,38 +153,42 @@ BI.HexColorPickerEditor = BI.inherit(BI.Widget, {
} }
} }
}] }
]
}, RGB[0], { }, RGB[0], {
el: BI.extend(Ws[0], { el: BI.extend(Ws[0], {
ref: function (_ref) { ref: function (_ref) {
self.R = _ref self.R = _ref;
} }
}), }),
width: c.RGB_WIDTH width: c.RGB_WIDTH
}, RGB[1], { }, RGB[1], {
el: BI.extend(Ws[1], { el: BI.extend(Ws[1], {
ref: function (_ref) { ref: function (_ref) {
self.G = _ref self.G = _ref;
} }
}), }),
width: c.RGB_WIDTH width: c.RGB_WIDTH
}, RGB[2], { }, RGB[2], {
el: BI.extend(Ws[2], { el: BI.extend(Ws[2], {
ref: function (_ref) { ref: function (_ref) {
self.B = _ref self.B = _ref;
} }
}), }),
rgap: -5, rgap: -5,
width: c.RGB_WIDTH width: c.RGB_WIDTH
}]
} }
}] ]
}
}
]
}, },
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0 bottom: 0
}] }
]
}; };
}, },

36
src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js

@ -31,14 +31,15 @@ BI.SimpleHexColorPickerEditor = BI.inherit(BI.Widget, {
var Ws = BI.map(BI.range(0, 3), function () { var Ws = BI.map(BI.range(0, 3), function () {
return { return {
type: "bi.small_text_editor", type: "bi.small_text_editor",
cls: "color-picker-editor-input", cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker, validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
allowBlank: true, allowBlank: true,
value: 255, value: 255,
width: c.RGB_WIDTH, width: c.RGB_WIDTH,
height: 24, height: 24,
listeners: [{ listeners: [
{
eventName: BI.TextEditor.EVENT_CHANGE, eventName: BI.TextEditor.EVENT_CHANGE,
action: function () { action: function () {
self._checkEditors(); self._checkEditors();
@ -47,19 +48,22 @@ BI.SimpleHexColorPickerEditor = BI.inherit(BI.Widget, {
self.fireEvent(BI.SimpleColorPickerEditor.EVENT_CHANGE); self.fireEvent(BI.SimpleColorPickerEditor.EVENT_CHANGE);
} }
} }
}]
} }
]
};
}); });
return { return {
type: "bi.vertical", type: "bi.vertical",
tgap: 10, tgap: 10,
items: [{ items: [
{
el: { el: {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
rgap: 5, rgap: 5,
columnSize: [22, 10, 'fill', 12, c.RGB_WIDTH, 12, c.RGB_WIDTH, 12, c.RGB_WIDTH], columnSize: [22, 10, 'fill', 12, c.RGB_WIDTH, 12, c.RGB_WIDTH, 12, c.RGB_WIDTH],
items: [{ items: [
{
el: { el: {
type: "bi.layout", type: "bi.layout",
cls: "color-picker-editor-display bi-card bi-border", cls: "color-picker-editor-display bi-card bi-border",
@ -79,13 +83,14 @@ BI.SimpleHexColorPickerEditor = BI.inherit(BI.Widget, {
ref: function (_ref) { ref: function (_ref) {
self.hexEditor = _ref; self.hexEditor = _ref;
}, },
cls: "color-picker-editor-input", cls: "color-picker-editor-input bi-border-radius",
validationChecker: this._hexChecker, validationChecker: this._hexChecker,
allowBlank: true, allowBlank: true,
errorText: BI.i18nText("BI-Color_Picker_Error_Text_Hex"), errorText: BI.i18nText("BI-Color_Picker_Error_Text_Hex"),
width: c.HEX_WIDTH, width: c.HEX_WIDTH,
height: 24, height: 24,
listeners: [{ listeners: [
{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function () { action: function () {
self._checkHexEditor(); self._checkHexEditor();
@ -94,34 +99,37 @@ BI.SimpleHexColorPickerEditor = BI.inherit(BI.Widget, {
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
} }
} }
}] }
]
}, RGB[0], { }, RGB[0], {
el: BI.extend(Ws[0], { el: BI.extend(Ws[0], {
ref: function (_ref) { ref: function (_ref) {
self.R = _ref self.R = _ref;
} }
}), }),
width: c.RGB_WIDTH width: c.RGB_WIDTH
}, RGB[1], { }, RGB[1], {
el: BI.extend(Ws[1], { el: BI.extend(Ws[1], {
ref: function (_ref) { ref: function (_ref) {
self.G = _ref self.G = _ref;
} }
}), }),
width: c.RGB_WIDTH width: c.RGB_WIDTH
}, RGB[2], { }, RGB[2], {
el: BI.extend(Ws[2], { el: BI.extend(Ws[2], {
ref: function (_ref) { ref: function (_ref) {
self.B = _ref self.B = _ref;
} }
}), }),
rgap: -5, rgap: -5,
width: c.RGB_WIDTH width: c.RGB_WIDTH
}]
} }
}] ]
} }
}
]
};
}, },
_hexChecker: function (v) { _hexChecker: function (v) {

14
src/case/colorchooser/colorpicker/editor.colorpicker.js

@ -41,7 +41,7 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
}; };
var Ws = BI.createWidgets([{}, {}, {}], { var Ws = BI.createWidgets([{}, {}, {}], {
type: "bi.small_text_editor", type: "bi.small_text_editor",
cls: "color-picker-editor-input", cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker, validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
allowBlank: true, allowBlank: true,
@ -95,10 +95,12 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
{
el: { el: {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
items: [{ items: [
{
el: this.colorShow, el: this.colorShow,
width: 16 width: 16
}, { }, {
@ -127,13 +129,15 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
el: this.none, el: this.none,
width: 16, width: 16,
lgap: 5 lgap: 5
}] }
]
}, },
left: 10, left: 10,
right: 10, right: 10,
top: 0, top: 0,
bottom: 0 bottom: 0
}] }
]
}); });
}, },

8
src/case/colorchooser/colorpicker/editor.colorpicker.simple.js

@ -40,7 +40,7 @@ BI.SimpleColorPickerEditor = BI.inherit(BI.Widget, {
}; };
var Ws = BI.createWidgets([{}, {}, {}], { var Ws = BI.createWidgets([{}, {}, {}], {
type: "bi.small_text_editor", type: "bi.small_text_editor",
cls: "color-picker-editor-input", cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker, validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
allowBlank: true, allowBlank: true,
@ -64,7 +64,8 @@ BI.SimpleColorPickerEditor = BI.inherit(BI.Widget, {
BI.createWidget({ BI.createWidget({
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
element: this, element: this,
items: [{ items: [
{
el: this.colorShow, el: this.colorShow,
width: 16, width: 16,
lgap: 20, lgap: 20,
@ -87,7 +88,8 @@ BI.SimpleColorPickerEditor = BI.inherit(BI.Widget, {
}, { }, {
el: this.B, el: this.B,
width: c.RGB_WIDTH width: c.RGB_WIDTH
}] }
]
}); });
}, },

10
src/case/linearsegment/linear.segment.js

@ -47,6 +47,14 @@ BI.LinearSegment = BI.inherit(BI.Widget, {
getValue: function () { getValue: function () {
return this.buttonGroup.getValue(); 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); BI.shortcut("bi.linear_segment", BI.LinearSegment);

9
src/case/segment/segment.js

@ -58,6 +58,15 @@ BI.Segment = BI.inherit(BI.Widget, {
getValue: function () { getValue: function () {
return this.buttonGroup.getValue(); 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.Segment.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.segment", BI.Segment); BI.shortcut("bi.segment", BI.Segment);

2
src/case/ztree/parttree.js

@ -37,6 +37,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
var self = this, o = this.options; var self = this, o = this.options;
var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode)); var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode));
var name = this._getNodeValue(treeNode); var name = this._getNodeValue(treeNode);
this.fireEvent(BI.PartTree.EVENT_CLICK_TREE_NODE);
if (treeNode.checked === true) { if (treeNode.checked === true) {
this.options.paras.selectedValues = this._getUnionValue(); this.options.paras.selectedValues = this._getUnionValue();
// this._buildTree(self.options.paras.selectedValues, BI.concat(parentValues, name)); // this._buildTree(self.options.paras.selectedValues, BI.concat(parentValues, name));
@ -197,4 +198,5 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
} }
}); });
BI.PartTree.EVENT_CLICK_TREE_NODE = "EVENT_CLICK_TREE_NODE";
BI.shortcut("bi.part_tree", BI.PartTree); BI.shortcut("bi.part_tree", BI.PartTree);

13
src/core/2.base.js

@ -1036,11 +1036,18 @@ BI._.extend(BI, {
return MM >= 1 && MM <= 12 && DD <= MD[MM - 1]; return MM >= 1 && MM <= 12 && DD <= MD[MM - 1];
}, },
/**
*
* @param str
* @param fmt
* @returns {Date|Date}
* 年月日缺省值为当前日期, 时分秒缺省值为0
*/
parseDateTime: function (str, fmt) { parseDateTime: function (str, fmt) {
var today = BI.getDate(); var today = BI.getDate();
var y = 0; var y;
var m = 0; var m;
var d = 1; var d;
// wei : 对于fmt为‘YYYYMM’或者‘YYYYMMdd’的格式,str的值为类似'201111'的形式,因为年月之间没有分隔符,所以正则表达式分割无效,导致bug7376。 // wei : 对于fmt为‘YYYYMM’或者‘YYYYMMdd’的格式,str的值为类似'201111'的形式,因为年月之间没有分隔符,所以正则表达式分割无效,导致bug7376。
var a = str.split(/\W+/); var a = str.split(/\W+/);
if (fmt.toLowerCase() == "%y%x" || fmt.toLowerCase() == "%y%x%d") { if (fmt.toLowerCase() == "%y%x" || fmt.toLowerCase() == "%y%x%d") {

10
src/core/controller/controller.bubbles.js

@ -46,9 +46,11 @@ export default class BubblesController extends Controller {
BI.createWidget({ BI.createWidget({
type: "bi.default", type: "bi.default",
element: container, element: container,
items: [{ items: [
{
el: bubble el: bubble
}] }
]
}); });
if (this.storePoppers[name]) { if (this.storePoppers[name]) {
this.storePoppers[name].destroy(); this.storePoppers[name].destroy();
@ -66,6 +68,10 @@ export default class BubblesController extends Controller {
options: { options: {
offset: [adjustXOffset, adjustYOffset] offset: [adjustXOffset, adjustYOffset]
} }
},
{
name: "preventOverflow",
enabled: false
} }
] ]
}); });

37
src/core/controller/controller.layer.js

@ -67,41 +67,54 @@ export default class LayerController extends Controller {
const layout = BI.createWidget({ const layout = BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
invisible: true, invisible: true,
items: [{ items: [
{
el: widget, el: widget,
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0 bottom: 0
}] }
]
}, context); }, context);
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: op.container || this.options.render, element: op.container || this.options.render,
items: [{ items: [
{
el: layout, el: layout,
left: offset.left || 0, left: offset.left || 0,
right: offset.right || 0, right: offset.right || 0,
top: offset.top || 0, top: offset.top || 0,
bottom: offset.bottom || 0 bottom: offset.bottom || 0
}] }
]
}); });
if (w) { if (w) {
layout.element.addClass("bi-popup-view"); layout.element.addClass("bi-popup-view");
layout.element.css({
function getComputedPosition() {
var css = {
left: w.offset().left + (offset.left || 0), left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0), top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "", width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || "" height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || ""
}); };
const { top, left, scaleY, scaleX } = BI.DOM.getPositionRelativeContainingBlockRect(layout.element[0]);
css.top = (css.top - top) / scaleY;
css.left = (css.left - left) / scaleX;
return css;
}
layout.element.css(getComputedPosition());
layout.element.on("__resize__", function () { layout.element.on("__resize__", function () {
w.is(":visible") && w.is(":visible") &&
layout.element.css({ layout.element.css(getComputedPosition());
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || ""
});
}); });
} }
this.add(name, widget, layout); this.add(name, widget, layout);

310
src/core/controller/popper.js

@ -1,24 +1,11 @@
/** /**
* @popperjs/core v2.9.2 - MIT License * @popperjs/core v2.11.6 - MIT License
*/ */
(function (global, factory) { (function (global, factory) {
factory(BI.Popper = {}); factory(global.Popper = {});
}(this, (function (exports) { 'use strict'; }(BI, (function (exports) {
'use strict';
function getBoundingClientRect(element) {
var rect = element.getBoundingClientRect();
return {
width: rect.width,
height: rect.height,
top: rect.top,
right: rect.right,
bottom: rect.bottom,
left: rect.left,
x: rect.left,
y: rect.top
};
}
function getWindow(node) { function getWindow(node) {
if (node == null) { if (node == null) {
@ -33,16 +20,6 @@
return node; return node;
} }
function getWindowScroll(node) {
var win = getWindow(node);
var scrollLeft = win.pageXOffset;
var scrollTop = win.pageYOffset;
return {
scrollLeft: scrollLeft,
scrollTop: scrollTop
};
}
function isElement(node) { function isElement(node) {
var OwnElement = getWindow(node).Element; var OwnElement = getWindow(node).Element;
return node instanceof OwnElement || node instanceof Element; return node instanceof OwnElement || node instanceof Element;
@ -63,6 +40,74 @@
return node instanceof OwnElement || node instanceof ShadowRoot; return node instanceof OwnElement || node instanceof ShadowRoot;
} }
var max = Math.max;
var min = Math.min;
var round = Math.round;
function getUAString() {
var uaData = navigator.userAgentData;
if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
return uaData.brands.map(function (item) {
return item.brand + "/" + item.version;
}).join(' ');
}
return navigator.userAgent;
}
function isLayoutViewport() {
return !/^((?!chrome|android).)*safari/i.test(getUAString());
}
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
if (includeScale === void 0) {
includeScale = false;
}
if (isFixedStrategy === void 0) {
isFixedStrategy = false;
}
var clientRect = element.getBoundingClientRect();
var scaleX = 1;
var scaleY = 1;
if (includeScale && isHTMLElement(element)) {
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
}
var _ref = isElement(element) ? getWindow(element) : window,
visualViewport = _ref.visualViewport;
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
var width = clientRect.width / scaleX;
var height = clientRect.height / scaleY;
return {
width: width,
height: height,
top: y,
right: x + width,
bottom: y + height,
left: x,
x: x,
y: y
};
}
function getWindowScroll(node) {
var win = getWindow(node);
var scrollLeft = win.pageXOffset;
var scrollTop = win.pageYOffset;
return {
scrollLeft: scrollLeft,
scrollTop: scrollTop
};
}
function getHTMLElementScroll(element) { function getHTMLElementScroll(element) {
return { return {
scrollLeft: element.scrollLeft, scrollLeft: element.scrollLeft,
@ -113,16 +158,24 @@
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX); return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
} }
function isElementScaled(element) {
var rect = element.getBoundingClientRect();
var scaleX = round(rect.width) / element.offsetWidth || 1;
var scaleY = round(rect.height) / element.offsetHeight || 1;
return scaleX !== 1 || scaleY !== 1;
} // Returns the composite rect of an element relative to its offsetParent.
// Composite means it takes into account transforms as well as layout. // Composite means it takes into account transforms as well as layout.
function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) { function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
if (isFixed === void 0) { if (isFixed === void 0) {
isFixed = false; isFixed = false;
} }
var documentElement = getDocumentElement(offsetParent);
var rect = getBoundingClientRect(elementOrVirtualElement);
var isOffsetParentAnElement = isHTMLElement(offsetParent); var isOffsetParentAnElement = isHTMLElement(offsetParent);
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
var documentElement = getDocumentElement(offsetParent);
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
var scroll = { var scroll = {
scrollLeft: 0, scrollLeft: 0,
scrollTop: 0 scrollTop: 0
@ -139,7 +192,7 @@
} }
if (isHTMLElement(offsetParent)) { if (isHTMLElement(offsetParent)) {
offsets = getBoundingClientRect(offsetParent); offsets = getBoundingClientRect(offsetParent, true);
offsets.x += offsetParent.clientLeft; offsets.x += offsetParent.clientLeft;
offsets.y += offsetParent.clientTop; offsets.y += offsetParent.clientTop;
} else if (documentElement) { } else if (documentElement) {
@ -249,8 +302,8 @@
function getContainingBlock(element) { function getContainingBlock(element) {
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1; var isFirefox = /firefox/i.test(getUAString());
var isIE = navigator.userAgent.indexOf('Trident') !== -1; var isIE = /Trident/i.test(getUAString());
if (isIE && isHTMLElement(element)) { if (isIE && isHTMLElement(element)) {
// In IE 9, 10 and 11 fixed elements containing block is always established by the viewport // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
@ -263,6 +316,10 @@
var currentNode = getParentNode(element); var currentNode = getParentNode(element);
if (isShadowRoot(currentNode)) {
currentNode = currentNode.host;
}
while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) { while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
// create a containing block. // create a containing block.
@ -399,9 +456,13 @@
var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s'; var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available'; var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options']; var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
function validateModifiers(modifiers) { function validateModifiers(modifiers) {
modifiers.forEach(function (modifier) { modifiers.forEach(function (modifier) {
Object.keys(modifier).forEach(function (key) { [].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
.filter(function (value, index, self) {
return self.indexOf(value) === index;
}).forEach(function (key) {
switch (key) { switch (key) {
case 'name': case 'name':
if (typeof modifier.name !== 'string') { if (typeof modifier.name !== 'string') {
@ -415,6 +476,8 @@
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\"")); console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
} }
break;
case 'phase': case 'phase':
if (modifierPhases.indexOf(modifier.phase) < 0) { if (modifierPhases.indexOf(modifier.phase) < 0) {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\"")); console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
@ -430,14 +493,14 @@
break; break;
case 'effect': case 'effect':
if (typeof modifier.effect !== 'function') { if (modifier.effect != null && typeof modifier.effect !== 'function') {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\"")); console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
} }
break; break;
case 'requires': case 'requires':
if (!Array.isArray(modifier.requires)) { if (modifier.requires != null && !Array.isArray(modifier.requires)) {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\"")); console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
} }
@ -502,31 +565,21 @@
}); });
} }
function getViewportRect(element) { function getViewportRect(element, strategy) {
var win = getWindow(element); var win = getWindow(element);
var html = getDocumentElement(element); var html = getDocumentElement(element);
var visualViewport = win.visualViewport; var visualViewport = win.visualViewport;
var width = html.clientWidth; var width = html.clientWidth;
var height = html.clientHeight; var height = html.clientHeight;
var x = 0; var x = 0;
var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper var y = 0;
// can be obscured underneath it.
// Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
// if it isn't open, so if this isn't available, the popper will be detected
// to overflow the bottom of the screen too early.
if (visualViewport) { if (visualViewport) {
width = visualViewport.width; width = visualViewport.width;
height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently) height = visualViewport.height;
// In Chrome, it returns a value very close to 0 (+/-) but contains rounding var layoutViewport = isLayoutViewport();
// errors due to floating point numbers, so we need to check precision.
// Safari returns a number <= 0, usually < -1 when pinch-zoomed if (layoutViewport || !layoutViewport && strategy === 'fixed') {
// Feature detection fails in mobile emulation mode in Chrome.
// Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
// 0.001
// Fallback here: "Not Safari" userAgent
if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
x = visualViewport.offsetLeft; x = visualViewport.offsetLeft;
y = visualViewport.offsetTop; y = visualViewport.offsetTop;
} }
@ -540,10 +593,6 @@
}; };
} }
var max = Math.max;
var min = Math.min;
var round = Math.round;
// of the `<html>` and `<body>` rect bounds if horizontally scrollable // of the `<html>` and `<body>` rect bounds if horizontally scrollable
function getDocumentRect(element) { function getDocumentRect(element) {
@ -601,8 +650,8 @@
}); });
} }
function getInnerBoundingClientRect(element) { function getInnerBoundingClientRect(element, strategy) {
var rect = getBoundingClientRect(element); var rect = getBoundingClientRect(element, false, strategy === 'fixed');
rect.top = rect.top + element.clientTop; rect.top = rect.top + element.clientTop;
rect.left = rect.left + element.clientLeft; rect.left = rect.left + element.clientLeft;
rect.bottom = rect.top + element.clientHeight; rect.bottom = rect.top + element.clientHeight;
@ -614,8 +663,8 @@
return rect; return rect;
} }
function getClientRectFromMixedType(element, clippingParent) { function getClientRectFromMixedType(element, clippingParent, strategy) {
return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element))); return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
} // A "clipping parent" is an overflowable container with the characteristic of } // A "clipping parent" is an overflowable container with the characteristic of
// clipping (or hiding) overflowing elements with a position different from // clipping (or hiding) overflowing elements with a position different from
// `initial` // `initial`
@ -638,18 +687,18 @@
// clipping parents // clipping parents
function getClippingRect(element, boundary, rootBoundary) { function getClippingRect(element, boundary, rootBoundary, strategy) {
var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary); var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
var clippingParents = [].concat(mainClippingParents, [rootBoundary]); var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
var firstClippingParent = clippingParents[0]; var firstClippingParent = clippingParents[0];
var clippingRect = clippingParents.reduce(function (accRect, clippingParent) { var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
var rect = getClientRectFromMixedType(element, clippingParent); var rect = getClientRectFromMixedType(element, clippingParent, strategy);
accRect.top = max(rect.top, accRect.top); accRect.top = max(rect.top, accRect.top);
accRect.right = min(rect.right, accRect.right); accRect.right = min(rect.right, accRect.right);
accRect.bottom = min(rect.bottom, accRect.bottom); accRect.bottom = min(rect.bottom, accRect.bottom);
accRect.left = max(rect.left, accRect.left); accRect.left = max(rect.left, accRect.left);
return accRect; return accRect;
}, getClientRectFromMixedType(element, firstClippingParent)); }, getClientRectFromMixedType(element, firstClippingParent, strategy));
clippingRect.width = clippingRect.right - clippingRect.left; clippingRect.width = clippingRect.right - clippingRect.left;
clippingRect.height = clippingRect.bottom - clippingRect.top; clippingRect.height = clippingRect.bottom - clippingRect.top;
clippingRect.x = clippingRect.left; clippingRect.x = clippingRect.left;
@ -758,6 +807,8 @@
var _options = options, var _options = options,
_options$placement = _options.placement, _options$placement = _options.placement,
placement = _options$placement === void 0 ? state.placement : _options$placement, placement = _options$placement === void 0 ? state.placement : _options$placement,
_options$strategy = _options.strategy,
strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
_options$boundary = _options.boundary, _options$boundary = _options.boundary,
boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
_options$rootBoundary = _options.rootBoundary, _options$rootBoundary = _options.rootBoundary,
@ -770,11 +821,10 @@
padding = _options$padding === void 0 ? 0 : _options$padding; padding = _options$padding === void 0 ? 0 : _options$padding;
var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements)); var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
var altContext = elementContext === popper ? reference : popper; var altContext = elementContext === popper ? reference : popper;
var referenceElement = state.elements.reference;
var popperRect = state.rects.popper; var popperRect = state.rects.popper;
var element = state.elements[altBoundary ? altContext : elementContext]; var element = state.elements[altBoundary ? altContext : elementContext];
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary); var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
var referenceClientRect = getBoundingClientRect(referenceElement); var referenceClientRect = getBoundingClientRect(state.elements.reference);
var popperOffsets = computeOffsets({ var popperOffsets = computeOffsets({
reference: referenceClientRect, reference: referenceClientRect,
element: popperRect, element: popperRect,
@ -854,7 +904,8 @@
var isDestroyed = false; var isDestroyed = false;
var instance = { var instance = {
state: state, state: state,
setOptions: function setOptions(options) { setOptions: function setOptions(setOptionsAction) {
var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
cleanupModifierEffects(); cleanupModifierEffects();
state.options = Object.assign({}, defaultOptions, state.options, options); state.options = Object.assign({}, defaultOptions, state.options, options);
state.scrollParents = { state.scrollParents = {
@ -1029,7 +1080,8 @@
options: options options: options
}); });
var noopFn = function noopFn() {}; var noopFn = function noopFn() {
};
effectCleanupFns.push(cleanupFn || noopFn); effectCleanupFns.push(cleanupFn || noopFn);
} }
@ -1090,7 +1142,8 @@
name: 'eventListeners', name: 'eventListeners',
enabled: true, enabled: true,
phase: 'write', phase: 'write',
fn: function fn() {}, fn: function fn() {
},
effect: effect$2, effect: effect$2,
data: {} data: {}
}; };
@ -1134,8 +1187,8 @@
var win = window; var win = window;
var dpr = win.devicePixelRatio || 1; var dpr = win.devicePixelRatio || 1;
return { return {
x: round(round(x * dpr) / dpr) || 0, x: round(x * dpr) / dpr || 0,
y: round(round(y * dpr) / dpr) || 0 y: round(y * dpr) / dpr || 0
}; };
} }
@ -1145,18 +1198,28 @@
var popper = _ref2.popper, var popper = _ref2.popper,
popperRect = _ref2.popperRect, popperRect = _ref2.popperRect,
placement = _ref2.placement, placement = _ref2.placement,
variation = _ref2.variation,
offsets = _ref2.offsets, offsets = _ref2.offsets,
position = _ref2.position, position = _ref2.position,
gpuAcceleration = _ref2.gpuAcceleration, gpuAcceleration = _ref2.gpuAcceleration,
adaptive = _ref2.adaptive, adaptive = _ref2.adaptive,
roundOffsets = _ref2.roundOffsets; roundOffsets = _ref2.roundOffsets,
isFixed = _ref2.isFixed;
var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets, var _offsets$x = offsets.x,
_ref3$x = _ref3.x, x = _offsets$x === void 0 ? 0 : _offsets$x,
x = _ref3$x === void 0 ? 0 : _ref3$x, _offsets$y = offsets.y,
_ref3$y = _ref3.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
y = _ref3$y === void 0 ? 0 : _ref3$y;
var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
x: x,
y: y
}) : {
x: x,
y: y
};
x = _ref3.x;
y = _ref3.y;
var hasX = offsets.hasOwnProperty('x'); var hasX = offsets.hasOwnProperty('x');
var hasY = offsets.hasOwnProperty('y'); var hasY = offsets.hasOwnProperty('y');
var sideX = left; var sideX = left;
@ -1171,7 +1234,7 @@
if (offsetParent === getWindow(popper)) { if (offsetParent === getWindow(popper)) {
offsetParent = getDocumentElement(popper); offsetParent = getDocumentElement(popper);
if (getComputedStyle(offsetParent).position !== 'static') { if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
heightProp = 'scrollHeight'; heightProp = 'scrollHeight';
widthProp = 'scrollWidth'; widthProp = 'scrollWidth';
} }
@ -1180,17 +1243,19 @@
offsetParent = offsetParent; offsetParent = offsetParent;
if (placement === top) { if (placement === top || (placement === left || placement === right) && variation === end) {
sideY = bottom; // $FlowFixMe[prop-missing] sideY = bottom;
var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
y -= offsetParent[heightProp] - popperRect.height; offsetParent[heightProp];
y -= offsetY - popperRect.height;
y *= gpuAcceleration ? 1 : -1; y *= gpuAcceleration ? 1 : -1;
} }
if (placement === left) { if (placement === left || (placement === top || placement === bottom) && variation === end) {
sideX = right; // $FlowFixMe[prop-missing] sideX = right;
var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
x -= offsetParent[widthProp] - popperRect.width; offsetParent[widthProp];
x -= offsetX - popperRect.width;
x *= gpuAcceleration ? 1 : -1; x *= gpuAcceleration ? 1 : -1;
} }
} }
@ -1199,18 +1264,29 @@
position: position position: position
}, adaptive && unsetSides); }, adaptive && unsetSides);
var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
x: x,
y: y
}) : {
x: x,
y: y
};
x = _ref4.x;
y = _ref4.y;
if (gpuAcceleration) { if (gpuAcceleration) {
var _Object$assign; var _Object$assign;
return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign)); return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
} }
return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2)); return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
} }
function computeStyles(_ref4) { function computeStyles(_ref5) {
var state = _ref4.state, var state = _ref5.state,
options = _ref4.options; options = _ref5.options;
var _options$gpuAccelerat = options.gpuAcceleration, var _options$gpuAccelerat = options.gpuAcceleration,
gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
_options$adaptive = options.adaptive, _options$adaptive = options.adaptive,
@ -1230,9 +1306,11 @@
var commonStyles = { var commonStyles = {
placement: getBasePlacement(state.placement), placement: getBasePlacement(state.placement),
variation: getVariation(state.placement),
popper: state.elements.popper, popper: state.elements.popper,
popperRect: state.rects.popper, popperRect: state.rects.popper,
gpuAcceleration: gpuAcceleration gpuAcceleration: gpuAcceleration,
isFixed: state.options.strategy === 'fixed'
}; };
if (state.modifiersData.popperOffsets != null) { if (state.modifiersData.popperOffsets != null) {
@ -1408,6 +1486,7 @@
bottom: 'top', bottom: 'top',
top: 'bottom' top: 'bottom'
}; };
function getOppositePlacement(placement) { function getOppositePlacement(placement) {
return placement.replace(/left|right|bottom|top/g, function (matched) { return placement.replace(/left|right|bottom|top/g, function (matched) {
return hash$1[matched]; return hash$1[matched];
@ -1418,6 +1497,7 @@
start: 'end', start: 'end',
end: 'start' end: 'start'
}; };
function getOppositeVariationPlacement(placement) { function getOppositeVariationPlacement(placement) {
return placement.replace(/start|end/g, function (matched) { return placement.replace(/start|end/g, function (matched) {
return hash[matched]; return hash[matched];
@ -1616,6 +1696,11 @@
return max(min$1, min(value, max$1)); return max(min$1, min(value, max$1));
} }
function withinMaxClamp(min, value, max) {
var v = within(min, value, max);
return v > max ? max : v;
}
function preventOverflow(_ref) { function preventOverflow(_ref) {
var state = _ref.state, var state = _ref.state,
options = _ref.options, options = _ref.options,
@ -1649,6 +1734,14 @@
var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, { var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
placement: state.placement placement: state.placement
})) : tetherOffset; })) : tetherOffset;
var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
mainAxis: tetherOffsetValue,
altAxis: tetherOffsetValue
} : Object.assign({
mainAxis: 0,
altAxis: 0
}, tetherOffsetValue);
var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
var data = { var data = {
x: 0, x: 0,
y: 0 y: 0
@ -1658,13 +1751,15 @@
return; return;
} }
if (checkMainAxis || checkAltAxis) { if (checkMainAxis) {
var _offsetModifierState$;
var mainSide = mainAxis === 'y' ? top : left; var mainSide = mainAxis === 'y' ? top : left;
var altSide = mainAxis === 'y' ? bottom : right; var altSide = mainAxis === 'y' ? bottom : right;
var len = mainAxis === 'y' ? 'height' : 'width'; var len = mainAxis === 'y' ? 'height' : 'width';
var offset = popperOffsets[mainAxis]; var offset = popperOffsets[mainAxis];
var min$1 = popperOffsets[mainAxis] + overflow[mainSide]; var min$1 = offset + overflow[mainSide];
var max$1 = popperOffsets[mainAxis] - overflow[altSide]; var max$1 = offset - overflow[altSide];
var additive = tether ? -popperRect[len] / 2 : 0; var additive = tether ? -popperRect[len] / 2 : 0;
var minLen = variation === start ? referenceRect[len] : popperRect[len]; var minLen = variation === start ? referenceRect[len] : popperRect[len];
var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
@ -1684,37 +1779,46 @@
// width or height) // width or height)
var arrowLen = within(0, referenceRect[len], arrowRect[len]); var arrowLen = within(0, referenceRect[len], arrowRect[len]);
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue; var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue; var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow); var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0; var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0; var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset; var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue; var tetherMax = offset + maxOffset - offsetModifierValue;
if (checkMainAxis) {
var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1); var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
popperOffsets[mainAxis] = preventedOffset; popperOffsets[mainAxis] = preventedOffset;
data[mainAxis] = preventedOffset - offset; data[mainAxis] = preventedOffset - offset;
} }
if (checkAltAxis) { if (checkAltAxis) {
var _offsetModifierState$2;
var _mainSide = mainAxis === 'x' ? top : left; var _mainSide = mainAxis === 'x' ? top : left;
var _altSide = mainAxis === 'x' ? bottom : right; var _altSide = mainAxis === 'x' ? bottom : right;
var _offset = popperOffsets[altAxis]; var _offset = popperOffsets[altAxis];
var _len = altAxis === 'y' ? 'height' : 'width';
var _min = _offset + overflow[_mainSide]; var _min = _offset + overflow[_mainSide];
var _max = _offset - overflow[_altSide]; var _max = _offset - overflow[_altSide];
var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max); var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
popperOffsets[altAxis] = _preventedOffset; popperOffsets[altAxis] = _preventedOffset;
data[altAxis] = _preventedOffset - _offset; data[altAxis] = _preventedOffset - _offset;
} }
}
state.modifiersData[name] = data; state.modifiersData[name] = data;
} // eslint-disable-next-line import/no-unused-modules } // eslint-disable-next-line import/no-unused-modules

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

@ -239,22 +239,26 @@
}, },
isRightSpaceLarger: function (combo) { isRightSpaceLarger: function (combo) {
var windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); var comboBounds = combo.element[0].getBoundingClientRect(),
return windowBounds.width - combo.element.offset().left - combo.element.bounds().width >= combo.element.offset().left; viewportBounds = document.documentElement.getBoundingClientRect();
return viewportBounds.width - comboBounds.right >= comboBounds.left;
}, },
isBottomSpaceLarger: function (combo) { isBottomSpaceLarger: function (combo) {
var windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); var comboBounds = combo.element[0].getBoundingClientRect(),
return windowBounds.height - combo.element.offset().top - combo.element.bounds().height >= combo.element.offset().top; viewportBounds = document.documentElement.getBoundingClientRect();
return viewportBounds.height - comboBounds.bottom >= comboBounds.top;
}, },
_getLeftAlignPosition: function (combo, popup, extraWidth, container) { _getLeftAlignPosition: function (combo, popup, extraWidth, container) {
var viewBounds = popup.element.bounds(), var comboRect = combo.element[0].getBoundingClientRect(),
windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); popupRect = popup.element[0].getBoundingClientRect(),
var left = combo.element.offset().left - (container ? container.getBoundingClientRect().left : 0) + extraWidth; viewportRect = document.documentElement.getBoundingClientRect(),
containerRect = container ? container.getBoundingClientRect() : { left: 0 };
var left = comboRect.left - containerRect.left + extraWidth;
if (left + viewBounds.width > windowBounds.width) { if (comboRect.left + popupRect.width > viewportRect.width) {
left = windowBounds.width - viewBounds.width; left = viewportRect.width - popupRect.width - containerRect.left;
} }
return left; return left;
}, },
@ -263,12 +267,13 @@
var left = this._getLeftAlignPosition(combo, popup, extraWidth, container); var left = this._getLeftAlignPosition(combo, popup, extraWidth, container);
var dir = ""; var dir = "";
// 如果放不下,优先使用RightAlign, 如果RightAlign也放不下, 再使用left=0 // 如果放不下,优先使用RightAlign, 如果RightAlign也放不下, 再使用left=0
if (left < 0) { var containerRect = container ? container.getBoundingClientRect() : { left: 0 };
if (left + containerRect.left < 0) {
left = this._getRightAlignPosition(combo, popup, extraWidth); left = this._getRightAlignPosition(combo, popup, extraWidth);
dir = "left"; dir = "left";
} }
if (left < 0) { if (left + containerRect.left < 0) {
left = 0; left = 0 - containerRect.left;
} }
return { return {
left: left, left: left,
@ -276,26 +281,28 @@
}; };
}, },
getLeftAdaptPosition: function (combo, popup, extraWidth) { getLeftAdaptPosition: function (combo, popup, extraWidth, container) {
if (BI.DOM.isLeftSpaceEnough(combo, popup, extraWidth)) { if (BI.DOM.isLeftSpaceEnough(combo, popup, extraWidth, container)) {
return BI.DOM.getLeftPosition(combo, popup, extraWidth); return BI.DOM.getLeftPosition(combo, popup, extraWidth, container);
} }
return { return {
left: 0 left: 0
}; };
}, },
_getRightAlignPosition: function (combo, popup, extraWidth) { _getRightAlignPosition: function (combo, popup, extraWidth, container) {
var comboBounds = combo.element.bounds(), viewBounds = popup.element.bounds(); var comboBounds = combo.element[0].getBoundingClientRect(),
return combo.element.offset().left + comboBounds.width - viewBounds.width - extraWidth; viewBounds = popup.element[0].getBoundingClientRect(),
containerRect = container ? container.getBoundingClientRect() : { left: 0 };
return comboBounds.left + comboBounds.width - viewBounds.width - extraWidth - containerRect.left;
}, },
getRightAlignPosition: function (combo, popup, extraWidth) { getRightAlignPosition: function (combo, popup, extraWidth, container) {
var left = this._getRightAlignPosition(combo, popup, extraWidth); var left = this._getRightAlignPosition(combo, popup, extraWidth, container);
var dir = ""; var dir = "";
// 如果放不下,优先使用LeftAlign, 如果LeftAlign也放不下, 再使用left=0 // 如果放不下,优先使用LeftAlign, 如果LeftAlign也放不下, 再使用left=0
if (left < 0) { if (left < 0) {
left = this._getLeftAlignPosition(combo, popup, extraWidth); left = this._getLeftAlignPosition(combo, popup, extraWidth, container);
dir = "right"; dir = "right";
} }
if (left < 0) { if (left < 0) {
@ -307,27 +314,26 @@
}; };
}, },
getRightAdaptPosition: function (combo, popup, extraWidth) { getRightAdaptPosition: function (combo, popup, extraWidth, container) {
if (BI.DOM.isRightSpaceEnough(combo, popup, extraWidth)) { if (BI.DOM.isRightSpaceEnough(combo, popup, extraWidth, container)) {
return BI.DOM.getRightPosition(combo, popup, extraWidth); return BI.DOM.getRightPosition(combo, popup, extraWidth, container);
} }
return { return {
left: BI.Widget._renderEngine.createElement("body").bounds().width - popup.element.bounds().width left: document.documentElement.getBoundingClientRect().width - popup.element[0].getBoundingClientRect().width - container.getBoundingClientRect().left
}; };
}, },
getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight, container) { getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight, container) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element[0].getBoundingClientRect(), var comboBounds = combo.element[0].getBoundingClientRect(),
popupBounds = popup.element[0].getBoundingClientRect(), popupBounds = popup.element[0].getBoundingClientRect(),
viewportBounds = document.documentElement.getBoundingClientRect(), viewportBounds = document.documentElement.getBoundingClientRect(),
containerBounds = container ? container.getBoundingClientRect() : { top: 0 }; containerBounds = container ? container.getBoundingClientRect() : { top: 0 };
var top, adaptHeight, dir; var top, adaptHeight, dir;
if (BI.DOM.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) { if (BI.DOM.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top - containerBounds.top + extraHeight; top = comboBounds.top - containerBounds.top + extraHeight;
} else if (needAdaptHeight) { } else if (needAdaptHeight) {
top = comboBounds.top - containerBounds.top + extraHeight; top = comboBounds.top - containerBounds.top + extraHeight;
adaptHeight = viewportBounds.height - top; adaptHeight = viewportBounds.height - comboBounds.top;
} else if (BI.DOM.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) { } else if (BI.DOM.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
// 下方空间不足且不允许调整高度的情况下,优先使用上对齐 // 下方空间不足且不允许调整高度的情况下,优先使用上对齐
top = comboBounds.top + comboBounds.height - popupBounds.height - containerBounds.top - extraHeight; top = comboBounds.top + comboBounds.height - popupBounds.height - containerBounds.top - extraHeight;
@ -351,44 +357,45 @@
}; };
}, },
getTopAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) { getTopAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight, positionRelativeElement) {
var popupBounds = popup.element.bounds(), var comboBounds = combo.element[0].getBoundingClientRect(),
windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); popupBounds = popup.element[0].getBoundingClientRect(),
positionRelativeElementRect = positionRelativeElement.getBoundingClientRect(),
viewportBounds = document.documentElement.getBoundingClientRect();
if (BI.DOM.isTopSpaceEnough(combo, popup, extraHeight)) { if (BI.DOM.isTopSpaceEnough(combo, popup, extraHeight)) {
return BI.DOM.getTopPosition(combo, popup, extraHeight); return BI.DOM.getTopPosition(combo, popup, extraHeight);
} }
if (needAdaptHeight) { if (needAdaptHeight) {
return { return {
top: 0, top: 0 - positionRelativeElementRect.top,
adaptHeight: combo.element.offset().top - extraHeight adaptHeight: comboBounds.top - extraHeight
}; };
} }
if (popupBounds.height + extraHeight > windowBounds.height) { if (popupBounds.height + extraHeight > viewportBounds.height) {
return { return {
top: 0, top: 0 - positionRelativeElementRect.top,
adaptHeight: windowBounds.height - extraHeight adaptHeight: viewportBounds.height - extraHeight
}; };
} }
return { return {
top: 0 top: 0 - positionRelativeElementRect.top
}; };
}, },
getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight, container) { getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight, container) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element[0].getBoundingClientRect(), var comboBounds = combo.element[0].getBoundingClientRect(),
popupBounds = popup.element[0].getBoundingClientRect(), popupBounds = popup.element[0].getBoundingClientRect(),
windowBounds = BI.Widget._renderEngine.createElement("body").bounds(), windowBounds = BI.Widget._renderEngine.createElement("body").bounds(),
containerBounds = container ? container.getBoundingClientRect() : { top: 0 }; containerBounds = container ? container.getBoundingClientRect() : { top: 0 };
var top, adaptHeight, dir; var top, adaptHeight, dir;
if (BI.DOM.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) { if (BI.DOM.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + comboBounds.height - containerBounds.top - popupBounds.height; top = comboBounds.top + comboBounds.height - containerBounds.top - popupBounds.height;
} else if (needAdaptHeight) { } else if (needAdaptHeight) {
top = 0 - containerBounds.top; top = 0 - containerBounds.top;
adaptHeight = comboBounds.top + comboBounds.height - extraHeight; adaptHeight = comboBounds.top + comboBounds.height - extraHeight;
} else if (BI.DOM.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) { } else if (BI.DOM.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
// 上方空间不足且不允许调整高度的情况下,优先使用下对齐 // 上方空间不足且不允许调整高度的情况下,优先使用下对齐
top = comboOffset.top - containerBounds.top + extraHeight; top = comboBounds.top - containerBounds.top + extraHeight;
dir = "bottom"; dir = "bottom";
} else { } else {
top = 0; top = 0;
@ -409,41 +416,43 @@
}; };
}, },
getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) { getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight, positionRelativeElement) {
var comboOffset = combo.element.offset(); var comboBounds = combo.element[0].getBoundingClientRect(),
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), popupBounds = popup.element[0].getBoundingClientRect(),
windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); viewportBounds = document.documentElement.getBoundingClientRect(),
positionRelativeElementRect = positionRelativeElement.getBoundingClientRect();
if (BI.DOM.isBottomSpaceEnough(combo, popup, extraHeight)) { if (BI.DOM.isBottomSpaceEnough(combo, popup, extraHeight)) {
return BI.DOM.getBottomPosition(combo, popup, extraHeight); return BI.DOM.getBottomPosition(combo, popup, extraHeight, positionRelativeElement);
} }
if (needAdaptHeight) { if (needAdaptHeight) {
return { return {
top: comboOffset.top + comboBounds.height + extraHeight, top: comboBounds.top + comboBounds.height + extraHeight - positionRelativeElementRect.top,
adaptHeight: windowBounds.height - comboOffset.top - comboBounds.height - extraHeight adaptHeight: viewportBounds.height - comboBounds.top - comboBounds.height - extraHeight
}; };
} }
if (popupBounds.height + extraHeight > windowBounds.height) { if (popupBounds.height + extraHeight > viewportBounds.height) {
return { return {
top: extraHeight, top: extraHeight - positionRelativeElementRect.top,
adaptHeight: windowBounds.height - extraHeight adaptHeight: viewportBounds.height - extraHeight
}; };
} }
return { return {
top: windowBounds.height - popupBounds.height - extraHeight top: viewportBounds.height - popupBounds.height - extraHeight - positionRelativeElementRect.top
}; };
}, },
getCenterAdaptPosition: function (combo, popup) { getCenterAdaptPosition: function (combo, popup, positionRelativeElement) {
var comboOffset = combo.element.offset(); var comboRect = combo.element[0].getBoundingClientRect(),
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), popupRect = popup.element[0].getBoundingClientRect(),
windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); positionRelativeElementRect = positionRelativeElement.getBoundingClientRect(),
viewportBounds = document.documentElement.getBoundingClientRect();
var left; var left;
if (comboOffset.left + comboBounds.width / 2 + popupBounds.width / 2 > windowBounds.width) { if (comboRect.left + comboRect.width / 2 + popupRect.width / 2 > viewportBounds.width) {
left = windowBounds.width - popupBounds.width; left = viewportBounds.width - comboRect.width - positionRelativeElementRect.left;
} else { } else {
left = comboOffset.left + comboBounds.width / 2 - popupBounds.width / 2; left = comboRect.left + (comboRect.width - popupRect.width) / 2 - positionRelativeElementRect.left;
} }
if (left < 0) { if (left + positionRelativeElementRect.left < 0) {
left = 0; left = 0;
} }
return { return {
@ -451,17 +460,19 @@
}; };
}, },
getMiddleAdaptPosition: function (combo, popup) { getMiddleAdaptPosition: function (combo, popup, positionRelativeElement) {
var comboOffset = combo.element.offset(); var comboRect = combo.element[0].getBoundingClientRect(),
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), popupRect = popup.element[0].getBoundingClientRect(),
windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); positionRelativeElementRect = positionRelativeElement.getBoundingClientRect(),
viewportBounds = document.documentElement.getBoundingClientRect();
var top; var top;
if (comboOffset.top + comboBounds.height / 2 + popupBounds.height / 2 > windowBounds.height) { if (comboRect.top + comboRect.height / 2 + popupRect.height / 2 > viewportBounds.height) {
top = windowBounds.height - popupBounds.height; top = viewportBounds.height - popupRect.height - positionRelativeElementRect.top;
} else { } else {
top = comboOffset.top + comboBounds.height / 2 - popupBounds.height / 2; top = comboRect.top + (comboRect.height - popupRect.height) / 2 - positionRelativeElementRect.top;
} }
if (top < 0) { if (top + positionRelativeElementRect.top < 0) {
top = 0; top = 0;
} }
return { return {
@ -633,10 +644,10 @@
case "left": case "left":
case "right": case "right":
if (BI.DOM.isRightSpaceLarger(combo)) { if (BI.DOM.isRightSpaceLarger(combo)) {
left = BI.DOM.getRightAdaptPosition(combo, popup, extraWidth).left; left = BI.DOM.getRightAdaptPosition(combo, popup, extraWidth, container).left;
firstDir = "right"; firstDir = "right";
} else { } else {
left = BI.DOM.getLeftAdaptPosition(combo, popup, extraWidth).left; left = BI.DOM.getLeftAdaptPosition(combo, popup, extraWidth, container).left;
firstDir = "left"; firstDir = "left";
} }
if (topBottom[0] === "bottom") { if (topBottom[0] === "bottom") {
@ -651,19 +662,19 @@
return pos; return pos;
default : default :
if (BI.DOM.isBottomSpaceLarger(combo)) { if (BI.DOM.isBottomSpaceLarger(combo)) {
top = BI.DOM.getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight).top; top = BI.DOM.getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight, container).top;
firstDir = "bottom"; firstDir = "bottom";
} else { } else {
top = BI.DOM.getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight).top; top = BI.DOM.getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight, container).top;
firstDir = "top"; firstDir = "top";
} }
if (leftRight[0] === "right") { if (leftRight[0] === "right") {
pos = BI.DOM.getLeftAlignPosition(combo, popup, extraWidth); pos = BI.DOM.getLeftAlignPosition(combo, popup, extraWidth, container);
pos.top = top; pos.top = top;
pos.dir = firstDir + "," + pos.dir; pos.dir = firstDir + "," + pos.dir;
return pos; return pos;
} }
pos = BI.DOM.getRightAlignPosition(combo, popup, extraWidth); pos = BI.DOM.getRightAlignPosition(combo, popup, extraWidth, container);
pos.top = top; pos.top = top;
pos.dir = firstDir + "," + pos.dir; pos.dir = firstDir + "," + pos.dir;
return pos; return pos;
@ -671,35 +682,35 @@
}, },
getComboPosition: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions, offsetStyle, container) { getComboPosition: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions, offsetStyle, positionRelativeElement) {
extraWidth || (extraWidth = 0); extraWidth || (extraWidth = 0);
extraHeight || (extraHeight = 0); extraHeight || (extraHeight = 0);
var bodyHeight = BI.Widget._renderEngine.createElement("body").bounds().height - extraHeight; var viewportBounds = document.documentElement.getBoundingClientRect();
var maxHeight = Math.min(popup.attr("maxHeight") || bodyHeight, bodyHeight); var maxHeight = Math.min(popup.attr("maxHeight") || viewportBounds.height, viewportBounds.height);
popup.resetHeight && popup.resetHeight(maxHeight); popup.resetHeight && popup.resetHeight(maxHeight);
var position = BI.DOM.getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ["bottom", "top", "right", "left"], container); var position = BI.DOM.getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ["bottom", "top", "right", "left"], positionRelativeElement);
switch (offsetStyle) { switch (offsetStyle) {
case "center": case "center":
if (position.change) { if (position.change) {
var p = BI.DOM.getMiddleAdaptPosition(combo, popup); var p = BI.DOM.getMiddleAdaptPosition(combo, popup, positionRelativeElement);
position.top = p.top; position.top = p.top;
} else { } else {
var p = BI.DOM.getCenterAdaptPosition(combo, popup); var p = BI.DOM.getCenterAdaptPosition(combo, popup, positionRelativeElement);
position.left = p.left; position.left = p.left;
} }
break; break;
case "middle": case "middle":
if (position.change) { if (position.change) {
var p = BI.DOM.getCenterAdaptPosition(combo, popup); var p = BI.DOM.getCenterAdaptPosition(combo, popup, positionRelativeElement);
position.left = p.left; position.left = p.left;
} else { } else {
var p = BI.DOM.getMiddleAdaptPosition(combo, popup); var p = BI.DOM.getMiddleAdaptPosition(combo, popup, positionRelativeElement);
position.top = p.top; position.top = p.top;
} }
break; break;
} }
if (needAdaptHeight === true) { if (needAdaptHeight === true) {
popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top, maxHeight)); popup.resetHeight && popup.resetHeight(Math.min(viewportBounds.height - position.top + (positionRelativeElement ? positionRelativeElement.getBoundingClientRect().top : 0), maxHeight));
} }
return position; return position;
}, },
@ -729,5 +740,19 @@
return BI.DOM.getPositionRelativeContainingBlock(element.parentNode); return BI.DOM.getPositionRelativeContainingBlock(element.parentNode);
}, },
/**
* 获取position:fixed相对定位的元素的clientRect
*/
getPositionRelativeContainingBlockRect: function (element) {
var positionRelativeElement = BI.DOM.getPositionRelativeContainingBlock(element);
var rect = positionRelativeElement.getBoundingClientRect();
return {
...rect.toJSON(),
scaleX: rect.width / positionRelativeElement.offsetWidth,
scaleY: rect.height / positionRelativeElement.offsetHeight
};
},
}); });
})(); })();

3
src/core/platform/web/function.js

@ -140,8 +140,9 @@ BI._.extend(BI, {
}, },
getMinimumFontSize: function () { getMinimumFontSize: function () {
// not work for firefox
const el = document.createElement('div'); const el = document.createElement('div');
el.style.fontSize = "0px"; el.style.fontSize = "1px";
document.body.appendChild(el); document.body.appendChild(el);
const size = getComputedStyle(el).fontSize; const size = getComputedStyle(el).fontSize;
el.remove(); el.remove();

15
src/widget/multiselect/check/multiselect.display.js

@ -40,10 +40,12 @@ BI.DisplaySelectedList = BI.inherit(BI.Pane, {
}, },
items: this._createItems(opts.items), items: this._createItems(opts.items),
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
layouts: [{ layouts: [
{
type: "bi.vertical", type: "bi.vertical",
lgap: 10 lgap: 10
}] }
]
}, },
itemsCreator: function (options, callback) { itemsCreator: function (options, callback) {
if (options.times === 1) { if (options.times === 1) {
@ -53,10 +55,7 @@ BI.DisplaySelectedList = BI.inherit(BI.Pane, {
if (cacheItems.length > 0) { if (cacheItems.length > 0) {
var renderedItems = cacheItems.slice(0, 100); var renderedItems = cacheItems.slice(0, 100);
cacheItems = cacheItems.slice(100); cacheItems = cacheItems.slice(100);
self.hasNext = true; self.hasNext = cacheItems.length > 0;
if (cacheItems.length === 0) {
self.hasNext = false;
}
callback(self._createItems(renderedItems)); callback(self._createItems(renderedItems));
return; return;
} }
@ -65,8 +64,8 @@ BI.DisplaySelectedList = BI.inherit(BI.Pane, {
self.hasNext = !!ob.hasNext; self.hasNext = !!ob.hasNext;
var firstItemsCount = 100 + ob.items.length % 100; var firstItemsCount = 100 + ob.items.length % 100;
if (ob.items.length > 100) { if (ob.items.length > 100) {
cacheItems = ob.items.slice(100 + ob.items.length % 100); cacheItems = ob.items.slice(firstItemsCount);
self.hasNext = true; self.hasNext = (firstItemsCount === ob.items.length) ? false : true;
} }
callback(self._createItems(ob.items.slice(0, firstItemsCount))); callback(self._createItems(ob.items.slice(0, firstItemsCount)));
}); });

22
src/widget/multitree/multi.tree.combo.js

@ -42,7 +42,15 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
}, },
searcher: { searcher: {
type: "bi.multi_tree_searcher", type: "bi.multi_tree_searcher",
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator,
listeners: [
{
eventName: BI.MultiTreeSearcher.EVENT_CLICK_TREE_NODE,
action: function () {
self._dataChange = true;
}
}
],
}, },
value: { value: o.value || {} } value: { value: o.value || {} }
}); });
@ -61,7 +69,8 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
self.trigger.setAdapter(this); self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this); self.numberCounter.setAdapter(this);
}, },
listeners: [{ listeners: [
{
eventName: BI.MultiTreePopup.EVENT_AFTERINIT, eventName: BI.MultiTreePopup.EVENT_AFTERINIT,
action: function () { action: function () {
self.numberCounter.adjustView(); self.numberCounter.adjustView();
@ -97,7 +106,8 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
self.setValue(); self.setValue();
self._defaultState(); self._defaultState();
} }
}], }
],
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
onLoaded: function () { onLoaded: function () {
BI.nextTick(function () { BI.nextTick(function () {
@ -293,7 +303,8 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
{
el: this.combo, el: this.combo,
left: 0, left: 0,
right: 0, right: 0,
@ -312,7 +323,8 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
right: o.height, right: o.height,
top: 0, top: 0,
bottom: 0 bottom: 0
}] }
]
}); });
}, },

23
src/widget/multitree/multi.tree.insert.combo.js

@ -47,7 +47,8 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
popup: { popup: {
type: "bi.multi_tree_search_insert_pane", type: "bi.multi_tree_search_insert_pane",
listeners: [{ listeners: [
{
eventName: BI.MultiTreeSearchInsertPane.EVENT_ADD_ITEM, eventName: BI.MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
action: function () { action: function () {
self.storeValue.value[self.trigger.getSearcher().getKeyword()] = {}; self.storeValue.value[self.trigger.getSearcher().getKeyword()] = {};
@ -58,7 +59,13 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
self._stopEditing(); self._stopEditing();
self._dataChange = true; self._dataChange = true;
} }
}] }, {
eventName: BI.MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE,
action: function () {
self._dataChange = true;
}
}
]
} }
}, },
value: { value: o.value || {} } value: { value: o.value || {} }
@ -79,7 +86,8 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
self.trigger.setAdapter(this); self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this); self.numberCounter.setAdapter(this);
}, },
listeners: [{ listeners: [
{
eventName: BI.MultiTreePopup.EVENT_AFTERINIT, eventName: BI.MultiTreePopup.EVENT_AFTERINIT,
action: function () { action: function () {
self.numberCounter.adjustView(); self.numberCounter.adjustView();
@ -115,7 +123,8 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
self.setValue(); self.setValue();
self._defaultState(); self._defaultState();
} }
}], }
],
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
onLoaded: function () { onLoaded: function () {
BI.nextTick(function () { BI.nextTick(function () {
@ -303,7 +312,8 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
{
el: this.combo, el: this.combo,
left: 0, left: 0,
right: 0, right: 0,
@ -322,7 +332,8 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
right: o.height, right: o.height,
top: 0, top: 0,
height: o.height, height: o.height,
}] }
]
}); });
}, },

18
src/widget/multitree/trigger/multi.tree.search.insert.pane.js

@ -25,7 +25,8 @@ BI.MultiTreeSearchInsertPane = BI.inherit(BI.Widget, {
return { return {
type: "bi.absolute", type: "bi.absolute",
items: [{ items: [
{
el: { el: {
type: "bi.text_button", type: "bi.text_button",
invisible: true, invisible: true,
@ -57,7 +58,8 @@ BI.MultiTreeSearchInsertPane = BI.inherit(BI.Widget, {
self.partTree = _ref; self.partTree = _ref;
}, },
value: opts.value, value: opts.value,
listeners: [{ listeners: [
{
eventName: BI.Controller.EVENT_CHANGE, eventName: BI.Controller.EVENT_CHANGE,
action: function () { action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -67,13 +69,20 @@ BI.MultiTreeSearchInsertPane = BI.inherit(BI.Widget, {
action: function () { action: function () {
self.fireEvent(BI.MultiTreeSearchInsertPane.EVENT_CHANGE); self.fireEvent(BI.MultiTreeSearchInsertPane.EVENT_CHANGE);
} }
}] }, {
eventName: BI.PartTree.EVENT_CLICK_TREE_NODE,
action: function () {
self.fireEvent(BI.MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE);
}
}
]
}, opts.el), }, opts.el),
left: 0, left: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
right: 0 right: 0
}] }
]
}; };
}, },
@ -115,5 +124,6 @@ BI.MultiTreeSearchInsertPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiTreeSearchInsertPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; BI.MultiTreeSearchInsertPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
BI.MultiTreeSearchInsertPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; BI.MultiTreeSearchInsertPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
BI.MultiTreeSearchInsertPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; BI.MultiTreeSearchInsertPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE = "EVENT_CLICK_TREE_NODE";
BI.shortcut("bi.multi_tree_search_insert_pane", BI.MultiTreeSearchInsertPane); BI.shortcut("bi.multi_tree_search_insert_pane", BI.MultiTreeSearchInsertPane);

12
src/widget/multitree/trigger/multi.tree.search.pane.js

@ -25,7 +25,8 @@ BI.MultiTreeSearchPane = BI.inherit(BI.Pane, {
opts.itemsCreator(op, callback); opts.itemsCreator(op, callback);
}, },
value: opts.value, value: opts.value,
listeners: [{ listeners: [
{
eventName: BI.Controller.EVENT_CHANGE, eventName: BI.Controller.EVENT_CHANGE,
action: function () { action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -35,7 +36,13 @@ BI.MultiTreeSearchPane = BI.inherit(BI.Pane, {
action: function () { action: function () {
self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE); self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE);
} }
}], }, {
eventName: BI.PartTree.EVENT_CLICK_TREE_NODE,
action: function () {
self.fireEvent(BI.MultiTreeSearchPane.EVENT_CLICK_TREE_NODE);
}
}
],
ref: function (_ref) { ref: function (_ref) {
self.partTree = _ref; self.partTree = _ref;
} }
@ -72,5 +79,6 @@ BI.MultiTreeSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiTreeSearchPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; BI.MultiTreeSearchPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
BI.MultiTreeSearchPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; BI.MultiTreeSearchPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
BI.MultiTreeSearchPane.EVENT_CLICK_TREE_NODE = "EVENT_CLICK_TREE_NODE";
BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane); BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane);

15
src/widget/multitree/trigger/searcher.multi.tree.js

@ -33,7 +33,8 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
defaultText: o.defaultText, defaultText: o.defaultText,
height: o.height height: o.height
}, },
listeners: [{ listeners: [
{
eventName: BI.MultiSelectEditor.EVENT_FOCUS, eventName: BI.MultiSelectEditor.EVENT_FOCUS,
action: function () { action: function () {
self.fireEvent(BI.MultiSelectSearcher.EVENT_FOCUS); self.fireEvent(BI.MultiSelectSearcher.EVENT_FOCUS);
@ -43,7 +44,8 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
action: function () { action: function () {
self.fireEvent(BI.MultiSelectSearcher.EVENT_BLUR); self.fireEvent(BI.MultiSelectSearcher.EVENT_BLUR);
} }
}] }
]
}); });
this.searcher = BI.createWidget({ this.searcher = BI.createWidget({
@ -67,6 +69,14 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
op.keyword = self.editor.getValue(); op.keyword = self.editor.getValue();
o.itemsCreator(op, callback); o.itemsCreator(op, callback);
}, },
listeners: [
{
eventName: BI.MultiTreeSearchPane.EVENT_CLICK_TREE_NODE,
action: function () {
self.fireEvent(BI.MultiTreeSearcher.EVENT_CLICK_TREE_NODE, arguments);
}
}
],
value: o.value value: o.value
}, o.popup), }, o.popup),
@ -206,4 +216,5 @@ BI.MultiTreeSearcher.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiTreeSearcher.EVENT_START = "EVENT_START"; BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
BI.MultiTreeSearcher.EVENT_CLICK_TREE_NODE = "EVENT_CLICK_TREE_NODE";
BI.shortcut("bi.multi_tree_searcher", BI.MultiTreeSearcher); BI.shortcut("bi.multi_tree_searcher", BI.MultiTreeSearcher);

16
src/widget/numbereditor/number.editor.js

@ -18,7 +18,8 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
errorText: "", errorText: "",
step: 1, step: 1,
min: BI.MIN, min: BI.MIN,
max: BI.MAX max: BI.MAX,
watermark: "",
}); });
}, },
@ -30,6 +31,7 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
height: BI.toPix(o.height, 2), height: BI.toPix(o.height, 2),
simple: o.simple, simple: o.simple,
allowBlank: o.allowBlank, allowBlank: o.allowBlank,
watermark: o.watermark,
value: o.valueFormatter(o.value), value: o.valueFormatter(o.value),
validationChecker: function (v) { validationChecker: function (v) {
// 不设置validationChecker就自动检测 // 不设置validationChecker就自动检测
@ -89,12 +91,14 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
type: "bi.htape", type: "bi.htape",
height: BI.toPix(o.height, 2), height: BI.toPix(o.height, 2),
element: this, element: this,
items: [this.editor, { items: [
this.editor, {
el: { el: {
type: "bi.grid", type: "bi.grid",
columns: 1, columns: 1,
rows: 2, rows: 2,
items: [{ items: [
{
column: 0, column: 0,
row: 0, row: 0,
el: this.topBtn el: this.topBtn
@ -102,10 +106,12 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
column: 0, column: 0,
row: 1, row: 1,
el: this.bottomBtn el: this.bottomBtn
}] }
]
}, },
width: 23 width: 23
}] }
]
}); });
}, },

2
typescript/base/single/button/button.basic.ts

@ -38,7 +38,7 @@ export declare class BasicButton extends Single {
trigger?: string | null; trigger?: string | null;
handler?: Function; handler?: Function;
bubble?: Function | null | string; bubble?: Function | null | string;
text?: string; text?: string | ((context: any) => string);
el?: Obj; el?: Obj;
} & Single["props"]; } & Single["props"];

Loading…
Cancel
Save