diff --git a/dist/fix/fix.compact.js b/dist/fix/fix.compact.js index 6179d484b..dced5e166 100644 --- a/dist/fix/fix.compact.js +++ b/dist/fix/fix.compact.js @@ -109,13 +109,13 @@ pushTarget(this.store); return true; } - if (this._store) { + if (this._store || this.options._store) { var store = BI.Widget.findStore(this.options.context || this._parent || this.options.element || this._context); if (store) { pushTarget(store); needPop = true; } - this.store = this._store(); + this.store = (this._store || this.options._store).call(this); this.store && (this.store._widget = this); needPop && popTarget(); needPop = false; diff --git a/examples/useContext.html b/examples/useContext.html index 4f91239bd..4092713e9 100644 --- a/examples/useContext.html +++ b/examples/useContext.html @@ -22,10 +22,10 @@ state: function () { return { expand: false, - cssScale: 2.0 + cssScale: true }; }, - childContext: ["text"], + childContext: ["text", "cssScale"], computed: { text: function () { @@ -41,10 +41,20 @@ }); BI.model("demo.model", Model); + var TempModel = BI.inherit(BI.Model, { + state: function () { + return { + cssScale: false + }; + }, + childContext: ["cssScale"], + }); + BI.model("demo.temp_model", TempModel); + var oldFormat = BI.pixFormat; BI.pixFormat = function (pix, border) { var context = BI.useContext("cssScale"); - if (!context) { + if (!context || context.model.cssScale === false) { return oldFormat.apply(this, arguments); } if (!BI.isNumber(pix)) { @@ -59,8 +69,8 @@ var oldPix = BI.toPix; BI.toPix = function (pix, border) { var context = BI.useContext("cssScale"); - if (!context) { - return oldPix.apply(this, arguments); + if (!context || context.model.cssScale === false) { + return oldFormat.apply(this, arguments); } if (!BI.isNumber(pix)) { return pix; @@ -109,7 +119,7 @@ var child; var store = BI.useStore(); return function () { - this.element[0].style.setProperty('--css-scale', store.model.cssScale); + this.element[0].style.setProperty('--css-scale', 2); return { type: "bi.vertical", vgap: 20, @@ -130,6 +140,42 @@ day: 15 } } + }, { + type: "bi.down_list_combo", + cls: "bi-border", + width: 24, + height: 24, + popup: { + _store: function () { + return BI.Models.getModel("demo.temp_model"); + } + }, + value: [{value: 2}, {value: 3, childValue: 4}], + items: [[{ + text: "属于", + value: 1, + cls: "dot-e-font" + }, { + text: "不属于", + value: 2, + cls: "dot-e-font" + }], [{ + el: { + text: "大于", + value: 3, + iconCls1: "dot-e-font" + }, + value: 3, + children: [{ + text: "固定值", + value: 4, + cls: "dot-e-font" + }, { + text: "平均值", + value: 5, + cls: "dot-e-font" + }] + }]] }] }; }; diff --git a/package.json b/package.json index d8d1135eb..52d9823d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20221101100519", + "version": "2.0.20221110175602", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts", diff --git a/src/base/single/0.single.js b/src/base/single/0.single.js index 93705ca91..c13e02e81 100644 --- a/src/base/single/0.single.js +++ b/src/base/single/0.single.js @@ -19,35 +19,37 @@ BI.Single = BI.inherit(BI.Widget, { return BI.extend(conf, { readonly: false, title: null, - warningTitle: null, - tipType: null, // success或warning - belowMouse: false, // title是否跟随鼠标 + warningTitle: null, // deprecated + tipType: null, // deprecated success或warning + belowMouse: false, // title是否跟随鼠标 enableHover: false, }); }, _showToolTip: function (e, opt) { opt || (opt = {}); + var self = this; var o = this.options; - var tooltipOpt = {}; var title = this.getTitle(); - if (BI.isPlainObject(title)) { - tooltipOpt = title; + + if (title instanceof Promise) { + this.requestingTitle = title; + title.then(resolvedTitle => { + // 由于是异步的,所以无法避免Promise resolve时机问题,所以设计为:鼠标移出了则不显示,并且只显示最后一次发起的查询结果 + this.mouseOver && this.requestingTitle === title && showToolTip(this._getTooltipOptions(resolvedTitle)); + }); } else { - tooltipOpt.level = this.getTipType() || "success"; - // 由于以前的用法,存在大量disabled:true搭配warningTitle的情况,所以这里做一个兼容,disabled:true的情况下,依然优先显示warningTitle,避免只设置了warningTitle而没有设置title的情况 - if (BI.isNull(o.tipType) && !this.isEnabled()) { - tooltipOpt.text = (this.getWarningTitle() || title); - } else { - tooltipOpt.text = tooltipOpt.level === "success" ? title : (this.getWarningTitle() || title); - } + showToolTip(this._getTooltipOptions(title)); } - if (BI.isKey(tooltipOpt.text)) { - BI.Tooltips.show(e, this.getName(), tooltipOpt, this, opt); - if (o.action) { - BI.Actions.runAction(o.action, "hover", o, this); + + function showToolTip(tooltipOpt) { + if (BI.isKey(tooltipOpt.text) && !BI.Tooltips.has(self.getName())) { + BI.Tooltips.show(e, self.getName(), tooltipOpt, self, opt); + if (o.action) { + BI.Actions.runAction(o.action, "hover", o, self); + } + BI.Actions.runGlobalAction("hover", o, self); } - BI.Actions.runGlobalAction("hover", o, this); } }, @@ -91,12 +93,30 @@ BI.Single = BI.inherit(BI.Widget, { } }, + _getTooltipOptions: function (title) { + var o = this.options; + var tooltipOpt = {}; + if (BI.isPlainObject(title)) { + tooltipOpt = title; + } else { + tooltipOpt.level = this.getTipType() || "success"; + // 由于以前的用法,存在大量disabled:true搭配warningTitle的情况,所以这里做一个兼容,disabled:true的情况下,依然优先显示warningTitle,避免只设置了warningTitle而没有设置title的情况 + if (BI.isNull(o.tipType) && !this.isEnabled()) { + tooltipOpt.text = (this.getWarningTitle() || title); + } else { + tooltipOpt.text = tooltipOpt.level === "success" ? title : (this.getWarningTitle() || title); + } + } + return tooltipOpt; + }, + enableHover: function (opt) { opt || (opt = {}); var self = this; if (!this._hoverBinded) { this.element.unbind("mouseenter.title").on("mouseenter.title", function (e) { self._e = e; + self.mouseOver = true; if (self.getTipType() === "warning" || (BI.isKey(self.getWarningTitle()) && !self.isEnabled())) { delayingTooltips = self.getName(); self.showTimeout = BI.delay(function () { @@ -144,6 +164,7 @@ BI.Single = BI.inherit(BI.Widget, { }); this.element.unbind("mouseleave.title").on("mouseleave.title", function (e) { self._e = null; + self.mouseOver = false; self._clearTimeOut(); self._hideTooltip(); }); diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index 95e863430..ac9e779e9 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -344,11 +344,6 @@ BI.Editor = BI.inherit(BI.Single, { return this.editor.isValid(); }, - setValid: function (b) { - this.editor.setValid(b); - this._checkError(); - }, - destroyed: function () { BI.Bubbles.remove(this.getName()); }, diff --git a/src/case/calendar/calendar.js b/src/case/calendar/calendar.js index bfd76e2b4..88ccf198a 100644 --- a/src/case/calendar/calendar.js +++ b/src/case/calendar/calendar.js @@ -161,7 +161,8 @@ BI.Calendar = BI.inherit(BI.Widget, { once: false, forceSelected: true, value: o.year + "-" + month + "-" + td.text, - disabled: td.lastMonth || td.nextMonth || td.disabled, + disabled: td.disabled, + cls: td.lastMonth || td.nextMonth ? "not-current-month-day": "", lgap: 2, rgap: 2, tgap: 4, diff --git a/src/core/wrapper/layout/layout.tape.js b/src/core/wrapper/layout/layout.tape.js index 185af813d..9303f5865 100644 --- a/src/core/wrapper/layout/layout.tape.js +++ b/src/core/wrapper/layout/layout.tape.js @@ -217,7 +217,7 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { top: self._optimiseGap(top[i] + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) + o.vgap + o.tgap) }); - if (rowSize === "" || rowSize === "fill") { + if (BI.isNull(rowSize) || rowSize === "" || rowSize === "fill") { return true; } }); @@ -235,7 +235,7 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { bottom: self._optimiseGap(bottom[i] + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) + o.vgap + o.bgap) }); - if (rowSize === "" || rowSize === "fill") { + if (BI.isNull(rowSize) || rowSize === "" || rowSize === "fill") { return true; } }); diff --git a/src/core/wrapper/layout/sticky/sticky.horizontal.js b/src/core/wrapper/layout/sticky/sticky.horizontal.js index afdf955aa..d88f28b6d 100644 --- a/src/core/wrapper/layout/sticky/sticky.horizontal.js +++ b/src/core/wrapper/layout/sticky/sticky.horizontal.js @@ -22,7 +22,7 @@ BI.HorizontalStickyLayout = BI.inherit(BI.FlexHorizontalLayout, { } if (columnSize !== "fill") { var fillIndex; - BI.count(0, o.items.length - 1, index => { + BI.count(0, o.items.length, index => { if (BI.isNotNull(fillIndex)) { return; } diff --git a/src/core/wrapper/layout/sticky/sticky.vertical.js b/src/core/wrapper/layout/sticky/sticky.vertical.js index beb0e9d43..71dc3ed8c 100644 --- a/src/core/wrapper/layout/sticky/sticky.vertical.js +++ b/src/core/wrapper/layout/sticky/sticky.vertical.js @@ -22,7 +22,7 @@ BI.VerticalStickyLayout = BI.inherit(BI.FlexVerticalLayout, { } if (rowSize !== "fill") { var fillIndex; - BI.count(0, o.items.length - 1, index => { + BI.count(0, o.items.length, index => { if (BI.isNotNull(fillIndex)) { return; } diff --git a/src/less/case/calendar/calendar.less b/src/less/case/calendar/calendar.less new file mode 100644 index 000000000..388bcf9e3 --- /dev/null +++ b/src/less/case/calendar/calendar.less @@ -0,0 +1,5 @@ +@import "../../index.less"; + +.bi-calendar-date-item.not-current-month-day { + color: @color-bi-text-disabled-button !important; +} \ No newline at end of file diff --git a/src/less/widget/multiselect/trigger/button.checkselected.less b/src/less/widget/multiselect/trigger/button.checkselected.less index 35c00dec0..4a36315b0 100644 --- a/src/less/widget/multiselect/trigger/button.checkselected.less +++ b/src/less/widget/multiselect/trigger/button.checkselected.less @@ -2,8 +2,8 @@ .bi-multi-select-check-selected-button { z-index: 1; - min-width: 16px; - .border-radius(8px); + .border-radius(50%); + &:active { color: @color-bi-text-highlight; background-color: @color-bi-background-multi-select-trigger-check-selected; diff --git a/src/widget/date/calendar/combo.month.date.js b/src/widget/date/calendar/combo.month.date.js index 82068ceac..aac5a7fc0 100644 --- a/src/widget/date/calendar/combo.month.date.js +++ b/src/widget/date/calendar/combo.month.date.js @@ -48,6 +48,7 @@ BI.MonthDateCombo = BI.inherit(BI.Trigger, { el: { type: "bi.vertical", hgap: 6, + vgap: 5, items: [this.popup] } } diff --git a/src/widget/downlist/combo.downlist.js b/src/widget/downlist/combo.downlist.js index cf983dfc4..8b9aa4c0c 100644 --- a/src/widget/downlist/combo.downlist.js +++ b/src/widget/downlist/combo.downlist.js @@ -17,7 +17,7 @@ text: item.text, icon: item.icon, cls: item.cls, - iconCls1: item.iconCls1, + iconCls1: item.iconCls1, value: item.value }; } @@ -25,7 +25,7 @@ }); return result; } - + /** * Created by roy on 15/8/14. */ @@ -41,16 +41,17 @@ container: null, stopPropagation: false, el: {}, + popup: {}, minWidth: 140, maxHeight: 1000, destroyWhenHide: false }); }, - + _init: function () { BI.DownListCombo.superclass._init.apply(this, arguments); var self = this, o = this.options; - + this.downlistcombo = BI.createWidget({ element: this, type: "bi.combo", @@ -63,12 +64,13 @@ belowMouse: o.belowMouse, stopPropagation: o.stopPropagation, destroyWhenHide: o.destroyWhenHide, - el: BI.createWidget(o.el, { + el: { type: "bi.icon_trigger", extraCls: o.iconCls, width: o.width, - height: o.height - }), + height: o.height, + ...o.el + }, popup: { el: { type: "bi.down_list_popup", @@ -94,39 +96,40 @@ }, stopPropagation: o.stopPropagation, maxHeight: o.maxHeight, - minWidth: o.minWidth + minWidth: o.minWidth, + ...o.popup } }); - + this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW); }); }, - + hideView: function () { this.downlistcombo.hideView(); }, - + showView: function (e) { this.downlistcombo.showView(e); }, - + populate: function (items) { this.popupView.populate(items); }, - + setValue: function (v) { this.popupView.setValue(v); }, - + getValue: function () { return this.popupView.getValue(); }, - + adjustWidth: function () { this.downlistcombo.adjustWidth(); }, - + adjustHeight: function () { this.downlistcombo.adjustHeight(); } @@ -134,6 +137,6 @@ BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; - + BI.shortcut("bi.down_list_combo", BI.DownListCombo); }()); diff --git a/src/widget/editor/editor.text.js b/src/widget/editor/editor.text.js index 4525a2a7b..19f51fd73 100644 --- a/src/widget/editor/editor.text.js +++ b/src/widget/editor/editor.text.js @@ -138,10 +138,6 @@ BI.TextEditor = BI.inherit(BI.Widget, { return this.editor.isValid(); }, - setValid: function (b) { - this.editor.setValid(b); - }, - setValue: function (v) { this.editor.setValue(v); }, diff --git a/src/widget/multitree/trigger/multi.tree.button.checkselected.js b/src/widget/multitree/trigger/multi.tree.button.checkselected.js index 59522d784..5efd65b2e 100644 --- a/src/widget/multitree/trigger/multi.tree.button.checkselected.js +++ b/src/widget/multitree/trigger/multi.tree.button.checkselected.js @@ -19,8 +19,8 @@ BI.MultiTreeCheckSelectedButton = BI.inherit(BI.Single, { this.indicator = BI.createWidget({ type: "bi.icon_button", cls: "check-font trigger-check-selected icon-size-12", - width: 15, - height: 15, + width: 16, + height: 16, stopPropagation: true }); @@ -31,7 +31,6 @@ BI.MultiTreeCheckSelectedButton = BI.inherit(BI.Single, { hgap: 4, text: BI.i18nText("BI-Check_Selected"), textAlign: "center", - textHeight: 15 }); this.checkSelected.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); @@ -65,4 +64,4 @@ BI.MultiTreeCheckSelectedButton = BI.inherit(BI.Single, { }); BI.MultiTreeCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multi_tree_check_selected_button", BI.MultiTreeCheckSelectedButton); \ No newline at end of file +BI.shortcut("bi.multi_tree_check_selected_button", BI.MultiTreeCheckSelectedButton); diff --git a/src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js b/src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js index 9410d9190..956e18552 100644 --- a/src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js +++ b/src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js @@ -19,14 +19,6 @@ BI.TextValueDownListCombo = BI.inherit(BI.Widget, { if(BI.isNotNull(o.value)) { value = this._digest(o.value); } - this.trigger = BI.createWidget({ - type: "bi.down_list_select_text_trigger", - cls: "text-value-down-list-trigger", - height: BI.toPix(o.height, 2), - items: o.items, - text: o.text, - value: value - }); this.combo = BI.createWidget({ type: "bi.down_list_combo", @@ -35,7 +27,17 @@ BI.TextValueDownListCombo = BI.inherit(BI.Widget, { adjustLength: 2, width: BI.toPix(o.width, 2), height: BI.toPix(o.height, 2), - el: this.trigger, + el: { + type: "bi.down_list_select_text_trigger", + ref: function (_ref) { + self.trigger = _ref; + }, + cls: "text-value-down-list-trigger", + height: BI.toPix(o.height, 2), + items: o.items, + text: o.text, + value: value + }, value: BI.isNull(value) ? [] : [value], items: BI.deepClone(o.items) }); @@ -79,7 +81,7 @@ BI.TextValueDownListCombo = BI.inherit(BI.Widget, { setValue: function (v) { v = this._digest(v); this.combo.setValue([v]); - this.trigger.setValue(v); + this.trigger?.setValue(v); }, getValue: function () { @@ -94,4 +96,4 @@ BI.TextValueDownListCombo = BI.inherit(BI.Widget, { } }); BI.TextValueDownListCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.text_value_down_list_combo", BI.TextValueDownListCombo); \ No newline at end of file +BI.shortcut("bi.text_value_down_list_combo", BI.TextValueDownListCombo);