diff --git a/package.json b/package.json index a727f140b..5cb32aad7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220217230329", + "version": "2.0.20220222143230", "description": "fineui", "main": "dist/fineui.min.js", "types": "dist/lib/index.d.ts", diff --git a/src/base/combination/group.virtual.js b/src/base/combination/group.virtual.js index ed21ba209..ab9b20c07 100644 --- a/src/base/combination/group.virtual.js +++ b/src/base/combination/group.virtual.js @@ -109,7 +109,9 @@ BI.VirtualGroup = BI.inherit(BI.Widget, { if (!this.layouts) { this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items))); } else { - this.layouts.populate(items); + this.layouts.populate(items, { + context: this + }); } } }); 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/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/component/form/form.field.js b/src/component/form/form.field.js index ab7e98ffc..e6c11a924 100644 --- a/src/component/form/form.field.js +++ b/src/component/form/form.field.js @@ -3,13 +3,16 @@ * @version 2.0 * Created by windy on 2022/1/11 */ -BI.FormField = BI.inherit(BI.Widget, { + BI.FormField = BI.inherit(BI.Widget, { props: { baseCls: "bi-form-field", label: "", el: {}, - validate: BI.emptyFn + labelAlign: "right", // 文字默认右对齐 + validate: function () { + return true; + } // 默认返回true }, render: function () { @@ -24,7 +27,7 @@ BI.FormField = BI.inherit(BI.Widget, { o.el.ref && o.el.ref.call(this, _ref); }, height: o.el.height || 28, - listeners: [{ + listeners: BI.concat(o.el.listeners, [{ eventName: "EVENT_CHANGE", action: function () { self.fireEvent("EVENT_CHANGE"); @@ -32,9 +35,9 @@ BI.FormField = BI.inherit(BI.Widget, { }, { eventName: "EVENT_CONFIRM", action: function () { - self.fireEvent("EVENT_CHANGE"); + self.fireEvent("EVENT_CONFIRM"); } - }] + }]) }), left: 0, bottom: 0, @@ -60,11 +63,14 @@ BI.FormField = BI.inherit(BI.Widget, { type: "bi.vertical_adapt", columnSize: ["auto", "fill"], verticalAlign: BI.VerticalAlign.Stretch, - hgap: 5, items: BI.isKey(o.label) ? [{ - type: "bi.label", - text: o.label + ":", - width: o.labelWidth + el: { + type: "bi.label", + textAlign: o.labelAlign, + text: o.label, + width: o.labelWidth, + rgap: 20 // 表单文字与右侧输入间距均为20px + } }, field] : [field] }; }, @@ -77,7 +83,7 @@ BI.FormField = BI.inherit(BI.Widget, { var isValid = this.validateWithNoTip(); !isValid && this.error.setText(this.options.tip(this.field.getValue(), this.field)); this.error.setVisible(!isValid); - this.element[isValid ? "removeClass" : "addClass"]("error"); + this.field.element[isValid ? "removeClass" : "addClass"]("bi-error"); return isValid; }, diff --git a/src/component/form/form.js b/src/component/form/form.js index 12d1a651b..87cd64236 100644 --- a/src/component/form/form.js +++ b/src/component/form/form.js @@ -3,10 +3,11 @@ * @version 2.0 * Created by windy on 2022/1/11 */ -BI.Form = BI.inherit(BI.Widget, { + BI.Form = BI.inherit(BI.Widget, { props: { baseCls: "bi-form", + labelAlign: "right", layout: { type: "bi.vertical", vgap: 20 @@ -40,6 +41,7 @@ BI.Form = BI.inherit(BI.Widget, { return { type: "bi.form_field", height: item.el.height || 28, + labelAlign: o.labelAlign, labelWidth: o.labelWidth, el: item.el, label: item.label, diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 4c94198ff..f4f32cfdd 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -492,7 +492,7 @@ BI.Layout = BI.inherit(BI.Widget, { } }, - updateChildren: function (oldCh, newCh) { + updateChildren: function (oldCh, newCh, context) { var self = this; var oldStartIdx = 0, newStartIdx = 0; var oldEndIdx = oldCh.length - 1; @@ -546,7 +546,7 @@ BI.Layout = BI.inherit(BI.Widget, { } else { var sameOldVnode = findOldVnode(oldCh, newStartVnode, oldStartIdx, oldEndIdx); if (BI.isNull(sameOldVnode[0])) { // 不存在就把新的放到左边 - var node = addNode(newStartVnode, newStartIdx); + var node = addNode(newStartVnode, newStartIdx, context); insertBefore(node, oldStartVnode); } else { // 如果新节点在旧节点区间中存在就复用一下 var sameOldIndex = sameOldVnode[1]; @@ -561,7 +561,7 @@ BI.Layout = BI.inherit(BI.Widget, { } if (oldStartIdx > oldEndIdx) { before = BI.isNull(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1]; - addVnodes(before, newCh, newStartIdx, newEndIdx); + addVnodes(before, newCh, newStartIdx, newEndIdx, context); } else if (newStartIdx > newEndIdx) { removeVnodes(oldCh, oldStartIdx, oldEndIdx); } @@ -586,15 +586,15 @@ BI.Layout = BI.inherit(BI.Widget, { } } - function addNode (vnode, index) { + function addNode (vnode, index, context) { var opt = self._getOptions(vnode); var key = opt.key == null ? index : opt.key; - return children[key] = self._newElement(index, vnode); + return children[key] = self._newElement(index, vnode, context); } - function addVnodes (before, vnodes, startIdx, endIdx) { + function addVnodes (before, vnodes, startIdx, endIdx, context) { for (; startIdx <= endIdx; ++startIdx) { - var node = addNode(vnodes[startIdx], startIdx); + var node = addNode(vnodes[startIdx], startIdx, context); insertBefore(node, before, false, startIdx); } } @@ -662,16 +662,18 @@ BI.Layout = BI.inherit(BI.Widget, { update: function (opt) { var o = this.options; var items = opt.items || []; + var context = opt.context; var oldItems = o.items; this.options.items = items; - return this.updateChildren(oldItems, items); + return this.updateChildren(oldItems, items, context); }, - stroke: function (items) { + stroke: function (items, options) { + options = options || {}; var self = this; BI.each(items, function (i, item) { if (item) { - self._addElement(i, item); + self._addElement(i, item, options.context); } }); }, @@ -702,14 +704,18 @@ BI.Layout = BI.inherit(BI.Widget, { this.options.items = []; }, - populate: function (items) { + populate: function (items, options) { items = items || []; + options = options || {}; if (this._isMounted) { - this.update({items: items}); + this.update({ + items: items, + context: options.context + }); return; } this.options.items = items; - this.stroke(items); + this.stroke(items, options); }, resize: function () { diff --git a/src/widget/singleslider/singleslider.js b/src/widget/singleslider/singleslider.js index f0fa756b2..ea51dbace 100644 --- a/src/widget/singleslider/singleslider.js +++ b/src/widget/singleslider/singleslider.js @@ -127,7 +127,7 @@ BI.SingleSlider = BI.inherit(BI.Single, { width: "100%" }, { el: { - type: "bi.vertical_adapt", + type: "bi.vertical", items: [{ type: "bi.horizontal_auto", items: [this.label]