diff --git a/package.json b/package.json index 0b2d61ff9..68de4c38f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220217101535", + "version": "2.0.20220221165305", "description": "fineui", "main": "dist/fineui.min.js", "types": "dist/lib/index.d.ts", diff --git a/src/base/layer/layer.popover.js b/src/base/layer/layer.popover.js index 646758527..9109a9a4e 100644 --- a/src/base/layer/layer.popover.js +++ b/src/base/layer/layer.popover.js @@ -75,6 +75,8 @@ BI.Popover = BI.inherit(BI.Widget, { title: o.header, textAlign: "left" }, + top: 0, + bottom: 0, left: BI.SIZE_CONSANTS.H_GAP_SIZE, right: o.closable ? 0 : BI.SIZE_CONSANTS.H_GAP_SIZE }] diff --git a/src/base/layer/layer.popup.js b/src/base/layer/layer.popup.js index 509f011c9..549558d67 100644 --- a/src/base/layer/layer.popup.js +++ b/src/base/layer/layer.popup.js @@ -233,10 +233,10 @@ BI.PopupView = BI.inherit(BI.Widget, { right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 6, minRight, maxRight) }; wrapperStyle = { - bottom: o.bgap + o.vgap, + top: o.bgap + o.vgap, left: "", right: 0, - top: "", + bottom: "", }; placeholderStyle = { left: 0, diff --git a/src/case/ztree/0.treeview.js b/src/case/ztree/0.treeview.js index aa0c502a4..79ffd5bb6 100644 --- a/src/case/ztree/0.treeview.js +++ b/src/case/ztree/0.treeview.js @@ -357,15 +357,20 @@ BI.TreeView = BI.inherit(BI.Pane, { if (BI.isNull(n.title)) { n.title = n.text; } + if (n.disabled) { + n.title = n.warningTitle || n.title; + } var text = BI.createWidget(BI.extend({ - type: "bi.text", cls: "tree-node-text", css: { display: "inline" }, whiteSpace: "nowrap", - root: true - }, n)); + root: true, + keyword: o.paras.keyword + }, n, { + type: "bi.text" + })); var fragment = BI.Widget._renderEngine.createElement("
"); fragment.append(text.element[0]); n.text = fragment.html(); diff --git a/src/core/platform/web/config.js b/src/core/platform/web/config.js index 2aedd70c0..f54b1a3b3 100644 --- a/src/core/platform/web/config.js +++ b/src/core/platform/web/config.js @@ -12,6 +12,19 @@ BI.prepares.push(function () { } return _isSupportFlex; }; + // 判断浏览器是否支持sticky 属性 + var isSupportSticky = (function () { + var vendorList = ["", "-webkit-", "-ms-", "-moz-", "-o-"], + vendorListLength = vendorList.length, + stickyElement = document.createElement("div"); + for (var i = 0; i < vendorListLength; i++) { + stickyElement.style.position = vendorList[i] + "sticky"; + if (stickyElement.style.position !== "") { + return true; + } + } + return false; + })(); BI.Plugin.configWidget("bi.horizontal", function (ob) { var supportFlex = isSupportFlex(); // // 在横向自适应场景下我们需要使用table的自适应撑出滚动条的特性(flex处理不了这种情况) @@ -150,6 +163,16 @@ BI.prepares.push(function () { }) }); }); + BI.Plugin.configWidget("bi.horizontal_sticky", function (ob) { + if (!isSupportSticky) { + return BI.extend({}, ob, {type: "bi.horizontal_fill"}); + } + }); + BI.Plugin.configWidget("bi.vertical_sticky", function (ob) { + if (!isSupportSticky) { + return BI.extend({}, ob, {type: "bi.vertical_fill"}); + } + }); BI.Plugin.configWidget("bi.left_right_vertical_adapt", function (ob) { if (isSupportFlex()) { diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 92a836ddf..4c94198ff 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -55,6 +55,20 @@ BI.Layout = BI.inherit(BI.Widget, { if (this.options.right) { this.element.css("right", BI.isNumber(this.options.right) ? this.options.right / BI.pixRatio + BI.pixUnit : this.options.right); } + if (this.options.padding) { + if (this.options.padding.left) { + this.element.css("padding-left", BI.isNumber(this.options.padding.left) ? this.options.padding.left / BI.pixRatio + BI.pixUnit : this.options.padding.left); + } + if (this.options.padding.right) { + this.element.css("padding-right", BI.isNumber(this.options.padding.right) ? this.options.padding.right / BI.pixRatio + BI.pixUnit : this.options.padding.right); + } + if (this.options.padding.top) { + this.element.css("padding-top", BI.isNumber(this.options.padding.top) ? this.options.padding.top / BI.pixRatio + BI.pixUnit : this.options.padding.top); + } + if (this.options.padding.bottom) { + this.element.css("padding-bottom", BI.isNumber(this.options.padding.bottom) ? this.options.padding.bottom / BI.pixRatio + BI.pixUnit : this.options.padding.bottom); + } + } }, _init4Scroll: function () { @@ -272,8 +286,8 @@ BI.Layout = BI.inherit(BI.Widget, { "margin-top": "", "margin-bottom": "", "margin-left": "", - "margin-right": "", - }) + "margin-right": "" + }); }, _optimiseGap: function (gap) { diff --git a/src/core/wrapper/layout/sticky/sticky.horizontal.js b/src/core/wrapper/layout/sticky/sticky.horizontal.js new file mode 100644 index 000000000..f178afd6b --- /dev/null +++ b/src/core/wrapper/layout/sticky/sticky.horizontal.js @@ -0,0 +1,38 @@ +/** + * 横向黏性布局 + */ +BI.HorizontalStickyLayout = BI.inherit(BI.FlexHorizontalLayout, { + props: function () { + return BI.extend(BI.HorizontalStickyLayout.superclass.props.apply(this, arguments), { + extraCls: "bi-h-sticky", + horizontalAlign: BI.HorizontalAlign.Stretch, + verticalAlign: BI.VerticalAlign.Stretch + }); + }, + + _addElement: function (i, item) { + var o = this.options; + var w = BI.HorizontalStickyLayout.superclass._addElement.apply(this, arguments); + var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width >= 1 ? null : item.width; + if (o.columnSize.length > 0) { + if (item.width >= 1 && o.columnSize[i] >= 1 && o.columnSize[i] !== item.width) { + columnSize = null; + } + } + if (columnSize !== "fill") { + var firstItemFill = o.columnSize[0] === "fill" || o.items[0].width === "fill"; + w.element.css({ + position: "sticky", + zIndex: 1, + left: firstItemFill ? "" : 0, + right: firstItemFill ? 0 : "" + }); + } else { + w.element.css({ + overflow: "" + }); + } + return w; + } +}); +BI.shortcut("bi.horizontal_sticky", BI.HorizontalStickyLayout); diff --git a/src/core/wrapper/layout/sticky/sticky.vertical.js b/src/core/wrapper/layout/sticky/sticky.vertical.js new file mode 100644 index 000000000..d99b8828e --- /dev/null +++ b/src/core/wrapper/layout/sticky/sticky.vertical.js @@ -0,0 +1,38 @@ +/** + * 纵向黏性布局 + */ +BI.VerticalStickyLayout = BI.inherit(BI.FlexVerticalLayout, { + props: function () { + return BI.extend(BI.VerticalStickyLayout.superclass.props.apply(this, arguments), { + extraCls: "bi-v-sticky", + horizontalAlign: BI.HorizontalAlign.Stretch, + verticalAlign: BI.VerticalAlign.Stretch + }); + }, + + _addElement: function (i, item) { + var o = this.options; + var w = BI.VerticalStickyLayout.superclass._addElement.apply(this, arguments); + var rowSize = o.rowSize.length > 0 ? o.rowSize[i] : item.height >= 1 ? null : item.height; + if (o.rowSize.length > 0) { + if (item.height >= 1 && o.rowSize[i] >= 1 && o.rowSize[i] !== item.height) { + rowSize = null; + } + } + if (rowSize !== "fill") { + var firstItemFill = o.rowSize[0] === "fill" || o.items[0].height === "fill"; + w.element.css({ + position: "sticky", + zIndex: 1, + top: firstItemFill ? "" : 0, + bottom: firstItemFill ? 0 : "" + }); + } else { + w.element.css({ + overflow: "" + }); + } + return w; + } +}); +BI.shortcut("bi.vertical_sticky", BI.VerticalStickyLayout);