From ff378ed006bb513e8a10bef152c6edb107508874 Mon Sep 17 00:00:00 2001 From: treecat Date: Tue, 16 Aug 2022 15:46:24 +0800 Subject: [PATCH 01/15] =?UTF-8?q?KERNEL-9408=20feat:=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E8=87=AA=E5=AE=9A=E4=B9=89=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/base/button/demo.button.js | 144 ++++++++++++++--------- src/base/single/button/buttons/button.js | 60 +++++++--- 2 files changed, 131 insertions(+), 73 deletions(-) diff --git a/demo/js/base/button/demo.button.js b/demo/js/base/button/demo.button.js index 1f2eeec0a..420a47d77 100644 --- a/demo/js/base/button/demo.button.js +++ b/demo/js/base/button/demo.button.js @@ -1,6 +1,29 @@ +(function () { + var JokerIcon = BI.inherit(BI.Widget, { + render: function () { + var self = this; + + return { + type: "bi.label", + cls: "anim-rotate", + ref: function(ref) { + self.text = ref; + }, + }; + }, + loading: function () { + this.text.setText("🤡"); + }, + loaded: function () { + this.text.setText(""); + }, + }); + BI.shortcut("demo.joker.icon", JokerIcon); +}()); + Demo.Button = BI.inherit(BI.Widget, { props: { - baseCls: "demo-button" + baseCls: "demo-button", }, render: function () { var items = [{ @@ -16,187 +39,187 @@ Demo.Button = BI.inherit(BI.Widget, { setTimeout(() => { this.loaded(); }, 5 * 1000); - } + }, }, { type: "bi.button", text: "表示成功状态按钮", level: "success", - height: 30 + height: 30, }, { type: "bi.button", text: "表示警告状态的按钮", level: "warning", - height: 30 + height: 30, }, { type: "bi.button", text: "表示错误状态的按钮", level: "error", - height: 30 + height: 30, }, { type: "bi.button", text: "表示忽略状态的按钮", level: "ignore", - height: 30 + height: 30, }, { type: "bi.button", text: "普通灰化按钮", disabled: true, level: "success", - height: 30 + height: 30, }, { type: "bi.button", text: "忽略状态灰化按钮", disabled: true, level: "ignore", - height: 30 + height: 30, }, { type: "bi.button", text: "带图标的按钮", // level: 'ignore', iconCls: "close-font", - height: 30 + height: 30, }, { type: "bi.button", text: "一般按钮", block: true, level: "common", - height: 30 + height: 30, }, { type: "bi.button", text: "表示成功状态按钮", block: true, level: "success", - height: 30 + height: 30, }, { type: "bi.button", text: "表示警告状态的按钮", block: true, level: "warning", - height: 30 + height: 30, }, { type: "bi.button", text: "表示忽略状态的按钮", block: true, level: "ignore", - height: 30 + height: 30, }, { type: "bi.button", text: "普通灰化按钮", block: true, disabled: true, level: "success", - height: 30 + height: 30, }, { type: "bi.button", text: "忽略状态灰化按钮", block: true, disabled: true, level: "ignore", - height: 30 + height: 30, }, { type: "bi.button", text: "带图标的按钮", block: true, // level: 'ignore', iconCls: "close-font", - height: 30 + height: 30, }, { type: "bi.button", text: "一般按钮", clear: true, level: "common", - height: 30 + height: 30, }, { type: "bi.button", text: "表示成功状态按钮", clear: true, level: "success", - height: 30 + height: 30, }, { type: "bi.button", text: "表示警告状态的按钮", clear: true, level: "warning", - height: 30 + height: 30, }, { type: "bi.button", text: "表示忽略状态的按钮", clear: true, level: "ignore", - height: 30 + height: 30, }, { type: "bi.button", text: "普通灰化按钮", clear: true, disabled: true, level: "success", - height: 30 + height: 30, }, { type: "bi.button", text: "忽略状态灰化按钮", clear: true, disabled: true, level: "ignore", - height: 30 + height: 30, }, { type: "bi.button", text: "带图标的按钮", clear: true, // level: 'ignore', iconCls: "close-font", - height: 30 + height: 30, }, { type: "bi.text_button", text: "文字按钮", - height: 30 + height: 30, }, { type: "bi.button", text: "幽灵按钮(common)", ghost: true, - height: 30 + height: 30, }, { type: "bi.button", iconCls: "plus-font", text: "幽灵按钮(common)", ghost: true, - height: 30 + height: 30, }, { type: "bi.button", iconCls: "plus-font", text: "幽灵按钮(common)", ghost: true, level: "warning", - height: 30 + height: 30, }, { type: "bi.button", iconCls: "plus-font", text: "幽灵按钮(common)", ghost: true, level: "error", - height: 30 + height: 30, }, { type: "bi.button", iconCls: "plus-font", text: "幽灵按钮(common)", ghost: true, level: "success", - height: 30 + height: 30, }, { type: "bi.button", text: "幽灵按钮(common)灰化", disabled: true, ghost: true, - height: 30 + height: 30, }, { type: "bi.button", text: "弹出bubble", bubble: function () { - return BI.parseInt(Math.random() * 100) % 10 + "提示" + return BI.parseInt(Math.random() * 100) % 10 + "提示"; }, handler: function () { BI.Msg.toast("1111"); }, - height: 30 + height: 30, }, { type: "bi.button", text: "自动撑开", @@ -206,76 +229,76 @@ Demo.Button = BI.inherit(BI.Widget, { iconGap: 64, vgap: 16, hgap: 100, - iconPosition: "bottom" + iconPosition: "bottom", }, { type: "bi.button", text: "图标在下面的按钮", iconCls: "close-font", - iconPosition: "bottom" + iconPosition: "bottom", }, { type: "bi.button", text: "图标在左边的按钮", iconCls: "close-font", - iconPosition: "left" + iconPosition: "left", }, { type: "bi.button", text: "图标在右边的按钮", iconCls: "close-font", - iconPosition: "right" + iconPosition: "right", }, { type: "bi.button", text: "浅色的一般按钮", iconCls: "plus-font", - light: true + light: true, }, { type: "bi.button", text: "浅色的成功按钮", level: "success", iconCls: "plus-font", - light: true + light: true, }, { type: "bi.button", text: "浅色的警告按钮", level: "warning", iconCls: "plus-font", - light: true + light: true, }, { type: "bi.button", iconCls: "plus-font", text: "浅色的失败按钮", level: "error", cls: "hover-mask", - light: true + light: true, }, { type: "bi.button", iconCls: "plus-font", text: "朴素的按钮", level: "common", - plain: true + plain: true, }, { type: "bi.button", iconCls: "plus-font", text: "朴素的按钮", level: "success", - plain: true + plain: true, }, { type: "bi.button", iconCls: "plus-font", text: "朴素的按钮", level: "error", - plain: true + plain: true, }, { type: "bi.button", iconCls: "plus-font", text: "朴素的按钮", level: "warning", - plain: true + plain: true, }, { type: "bi.button", iconCls: "plus-font", text: "朴素的按钮", level: "ignore", - plain: true + plain: true, }, { type: "bi.button", iconCls: "plus-font", @@ -286,7 +309,7 @@ Demo.Button = BI.inherit(BI.Widget, { iconCls: "plus-font", text: "朴素的按钮", plain: true, - disabled: true + disabled: true, }, { type: "bi.button", iconCls: "plus-font", @@ -299,7 +322,7 @@ Demo.Button = BI.inherit(BI.Widget, { } this.setIcon(arr[this.i]); }, - height: 24 + height: 24, }, { type: "bi.button", text: "带加载的按钮", @@ -309,7 +332,7 @@ Demo.Button = BI.inherit(BI.Widget, { setTimeout(() => { this.loaded(); }, 5 * 1000); - } + }, }, { type: "bi.button", text: "带加载的按钮", @@ -320,7 +343,7 @@ Demo.Button = BI.inherit(BI.Widget, { setTimeout(() => { this.loaded(); }, 5 * 1000); - } + }, }, { type: "bi.button", clear: true, @@ -332,14 +355,27 @@ Demo.Button = BI.inherit(BI.Widget, { setTimeout(() => { this.loaded(); }, 5 * 1000); - } + }, }, { type: "bi.button", text: "加载中的按钮", loading: true, handler() { console.log("我是无法被触发的!"); - } + }, + }, { + type: "bi.button", + text: "自定义图标按钮(点我修改)", + icon: { + type: "demo.joker.icon", + }, + handler() { + console.log("触发点击事件"); + this.loading(); + setTimeout(() => { + this.loaded(); + }, 5 * 1000); + }, }]; return { @@ -349,10 +385,10 @@ Demo.Button = BI.inherit(BI.Widget, { hgap: 20, items: BI.map(items, function (index, value) { return { - el: value + el: value, }; - }) + }), }; - } + }, }); BI.shortcut("demo.button", Demo.Button); diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index 63b667aaa..d15051be5 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -62,6 +62,7 @@ bgap: 0, lgap: 0, rgap: 0, + icon: "", iconGap: 0, iconPosition: "left", }); @@ -90,17 +91,30 @@ } var iconInvisible = !o.loading && !o.iconCls; - this.icon = BI.createWidget({ - type: "bi.icon_label", - cls: o.loading ? loadingCls : o.iconCls, - width: this._const.iconWidth, - height: lineHeight, - lineHeight: lineHeight, - // 不设置,自定义按钮无法居中 - iconWidth: o.iconWidth, - iconHeight: o.iconHeight, - invisible: iconInvisible, - }); + if (BI.isObject(o.icon) && BI.isString(o.icon.type)) { + // FineUI 自定义 icon + this.icon = BI.createWidget(o.icon); + o.loading ? (this.icon.loading && this.icon.loading()) + : (this.icon.loaded && this.icon.loaded()); + } else { + // ReactUI 自定义的 icon + if (!o.loading && BI.isObject(o.icon)) { + this.icon = o.icon; + } else { + this.icon = BI.createWidget({ + type: "bi.icon_label", + cls: o.loading ? loadingCls : (o.iconCls || o.icon), + width: this._const.iconWidth, + height: lineHeight, + lineHeight: lineHeight, + // 不设置,自定义按钮无法居中 + iconWidth: o.iconWidth, + iconHeight: o.iconHeight, + invisible: iconInvisible, + }); + } + } + // 用于 whiteSpace var textWidth = iconInvisible && o.width ? o.width - o.hgap * 2 : null; if (BI.isNotNull(o.textWidth)) { @@ -179,23 +193,31 @@ return this.isLoading(); }, - isLoading() { + isLoading: function () { return this._loading === undefined ? this.options.loading : this._loading; }, - loading: function (loading) { + loading: function () { this._loading = true; this.element.addClass("loading"); - // loadingCls 可以覆盖 iconCls 所以不需要移除 iconCls - this.icon.element.addClass(loadingCls); - this.icon.setVisible(true); + if (this.icon.loading) { + this.icon.loading(); + } else { + // loadingCls 可以覆盖 iconCls 所以不需要移除 iconCls + this.icon.element.addClass(loadingCls); + this.icon.setVisible(true); + } }, - loaded() { + loaded: function () { this._loading = false; this.element.removeClass("loading"); - this.icon.element.removeClass(loadingCls); - this.icon.setVisible(!!this.options.iconCls); + if (this.icon.loaded) { + this.icon.loaded(); + } else { + this.icon.element.removeClass(loadingCls); + this.icon.setVisible(!!this.options.iconCls); + } }, setText: function (text) { From 6895777066f3f522075255eac5c8ca0ef539dac1 Mon Sep 17 00:00:00 2001 From: treecat Date: Tue, 16 Aug 2022 16:35:29 +0800 Subject: [PATCH 02/15] =?UTF-8?q?KERNEL-9408=20fix:=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=85=B6=E5=AE=83=E6=A1=86=E6=9E=B6=E5=AE=9E=E7=8E=B0=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/base/button/demo.button.js | 6 ++++++ src/base/single/button/buttons/button.js | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/demo/js/base/button/demo.button.js b/demo/js/base/button/demo.button.js index 420a47d77..39b27b716 100644 --- a/demo/js/base/button/demo.button.js +++ b/demo/js/base/button/demo.button.js @@ -376,6 +376,12 @@ Demo.Button = BI.inherit(BI.Widget, { this.loaded(); }, 5 * 1000); }, + }, { + type: "bi.button", + text: "图标的实现交给其他框架", + icon(element) { + element.append("🧙"); + }, }]; return { diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index d15051be5..f9aa8586e 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -91,15 +91,16 @@ } var iconInvisible = !o.loading && !o.iconCls; - if (BI.isObject(o.icon) && BI.isString(o.icon.type)) { - // FineUI 自定义 icon + if (BI.isPlainObject(o.icon)) { this.icon = BI.createWidget(o.icon); o.loading ? (this.icon.loading && this.icon.loading()) : (this.icon.loaded && this.icon.loaded()); } else { - // ReactUI 自定义的 icon - if (!o.loading && BI.isObject(o.icon)) { - this.icon = o.icon; + if (!o.loading && BI.isFunction(o.icon)) { + this.icon = BI.createWidget({ + type: "bi.layout", + }); + o.icon(this.icon.element); } else { this.icon = BI.createWidget({ type: "bi.icon_label", From e487760d6c8eb131aea96518869568f3c09c6914 Mon Sep 17 00:00:00 2001 From: treecat Date: Wed, 17 Aug 2022 11:01:00 +0800 Subject: [PATCH 03/15] =?UTF-8?q?KERNEL-9408=20fix:=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=9B=BE=E6=A0=87=E7=9A=84=E6=9C=80?= =?UTF-8?q?=E7=BB=88=E5=AE=9E=E7=8E=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/base/button/demo.button.js | 6 ---- src/base/single/button/buttons/button.js | 39 +++++++++--------------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/demo/js/base/button/demo.button.js b/demo/js/base/button/demo.button.js index 39b27b716..420a47d77 100644 --- a/demo/js/base/button/demo.button.js +++ b/demo/js/base/button/demo.button.js @@ -376,12 +376,6 @@ Demo.Button = BI.inherit(BI.Widget, { this.loaded(); }, 5 * 1000); }, - }, { - type: "bi.button", - text: "图标的实现交给其他框架", - icon(element) { - element.append("🧙"); - }, }]; return { diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index f9aa8586e..7a8ba672d 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -91,29 +91,20 @@ } var iconInvisible = !o.loading && !o.iconCls; - if (BI.isPlainObject(o.icon)) { + if (BI.isPlainObject(o.icon) && !o.loading) { this.icon = BI.createWidget(o.icon); - o.loading ? (this.icon.loading && this.icon.loading()) - : (this.icon.loaded && this.icon.loaded()); } else { - if (!o.loading && BI.isFunction(o.icon)) { - this.icon = BI.createWidget({ - type: "bi.layout", - }); - o.icon(this.icon.element); - } else { - this.icon = BI.createWidget({ - type: "bi.icon_label", - cls: o.loading ? loadingCls : (o.iconCls || o.icon), - width: this._const.iconWidth, - height: lineHeight, - lineHeight: lineHeight, - // 不设置,自定义按钮无法居中 - iconWidth: o.iconWidth, - iconHeight: o.iconHeight, - invisible: iconInvisible, - }); - } + this.icon = BI.createWidget({ + type: "bi.icon_label", + cls: o.loading ? loadingCls : (o.iconCls || o.icon), + width: this._const.iconWidth, + height: lineHeight, + lineHeight: lineHeight, + // 不设置,自定义按钮无法居中 + iconWidth: o.iconWidth, + iconHeight: o.iconHeight, + invisible: iconInvisible, + }); } // 用于 whiteSpace @@ -140,12 +131,12 @@ tgap: o.iconPosition === "top" ? o.iconGap : 0, bgap: o.iconPosition === "bottom" ? o.iconGap : 0, }; - var items = [this.icon, BI.extend({ el: this.text }, gapContainer)]; + var items = [this.icon, BI.extend({el: this.text}, gapContainer)]; if (isVertical(o.iconPosition)) { layoutType = "bi.vertical"; } if (o.iconPosition === "right" || o.iconPosition === "bottom") { - items = [BI.extend({ el: this.text }, gapContainer), this.icon]; + items = [BI.extend({el: this.text}, gapContainer), this.icon]; } // bi.center_adapt 作用:让 hgap 不影响 iconGap。 BI.createWidget({ @@ -170,7 +161,7 @@ }); if (o.minWidth > 0) { - this.element.css({ "min-width": o.minWidth / BI.pixRatio + BI.pixUnit }); + this.element.css({"min-width": o.minWidth / BI.pixRatio + BI.pixUnit}); } }, From e775c5c346a66865d62abbf3bea1769688ea2d15 Mon Sep 17 00:00:00 2001 From: zsmj Date: Wed, 17 Aug 2022 20:56:55 +0800 Subject: [PATCH 04/15] =?UTF-8?q?KERNEL-12470=20feat:=20bi.text=5Fvalue=5F?= =?UTF-8?q?combo=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/case/combo/demo.text_value_combo.js | 93 ++++++++++---- .../combo/textvaluecombo/combo.textvalue.js | 119 ++++++++++++------ src/case/trigger/trigger.text.select.js | 2 +- src/less/base/combo/combo.textvalue.less | 24 ++++ 4 files changed, 174 insertions(+), 64 deletions(-) create mode 100644 src/less/base/combo/combo.textvalue.less diff --git a/demo/js/case/combo/demo.text_value_combo.js b/demo/js/case/combo/demo.text_value_combo.js index 77414af38..50e3fea43 100644 --- a/demo/js/case/combo/demo.text_value_combo.js +++ b/demo/js/case/combo/demo.text_value_combo.js @@ -6,7 +6,7 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { baseCls: "" }, render: function () { - var combo, wrapper; + var combo1, combo2; var items = [{ text: "MVC-1", @@ -30,8 +30,8 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { items: [ this.createCombo("无初始值,带提示文字", { type: "bi.text_value_combo", - ref: function () { - combo = this; + ref: (ref) => { + this.combo1 = ref; }, defaultText: "请选择", width: 300, @@ -100,16 +100,18 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { } ] }), - this.createCombo("有初始值,value不匹配,自动标红,可以清空", { + this.createCombo("有初始值,value不匹配,自动标红,指定标红文字", { type: "bi.text_value_combo", ref: function () { combo = this; }, - defaultText: "请选择", width: 300, + text: "MVC-111", value: 111, items: items, allowClear: true, + defaultText: "请选择", + warningTitle: "value值不合法", listeners: [ { eventName: BI.TextValueCombo.EVENT_CHANGE, @@ -119,23 +121,67 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { } ] }), - this.createCombo("有初始值,value不匹配,自动标红,指定标红文字", { - type: "bi.text_value_combo", - ref: function () { - combo = this; - }, - width: 300, - text: "MVC-111", - value: 111, - items: items, - allowClear: true, - defaultText: "df", - listeners: [ + this.createCombo("无初始值,外部受控调用setValue", { + type: "bi.vertical", + items: [ { - eventName: BI.TextValueCombo.EVENT_CHANGE, - action: function () { - console.log(this.getValue()); - } + type: "bi.text_value_combo", + ref: function () { + combo1 = this; + }, + width: 300, + items: items, + allowClear: true, + defaultText: "请选择", + listeners: [ + { + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: function () { + console.log(this.getValue()); + } + } + ] + }, { + el: { + type: "bi.button", + text: "setValue(1)", + handler: function () { + combo1.setValue(); + }, + }, + vgap: 10, + } + ] + }), + this.createCombo("无初始值,外部受控调用setStatus", { + type: "bi.vertical", + items: [ + { + type: "bi.text_value_combo", + ref: function () { + combo2 = this; + }, + width: 300, + items: items, + allowClear: true, + defaultText: "请选择", + listeners: [ + { + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: function () { + console.log(this.getValue()); + } + } + ] + }, { + el: { + type: "bi.button", + text: "setStatus()", + handler: function () { + combo2.setStatus("error"); + }, + }, + vgap: 10, } ] }) @@ -155,8 +201,9 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { }, bgap: 10 }, { - el: combo - } + el: combo, + bgap: 10, + }, ] }; } diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index e29d6c094..f59714c1f 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -14,6 +14,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { value: "", defaultText: "", allowClear: false, + status: "success", // success | warning | error }); }, @@ -28,90 +29,128 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { self.populate(newValue); }) : o.items; BI.TextValueCombo.superclass._init.apply(this, arguments); - this.trigger = BI.createWidget({ + }, + + render: function () { + + const o = this.options; + + const trigger = { type: "bi.select_text_trigger", + ref: ref => this.trigger = ref, cls: "text-value-trigger", items: o.items, height: o.height, text: o.text, value: o.value, - warningTitle: o.warningTitle, + title: () => { + if (this.options.status === "error") { + return { + level: "warning", + text: o.warningTitle, + }; + } + return { + level: "success", + }; + }, allowClear: o.allowClear, defaultText: o.defaultText, listeners: [ { eventName: BI.SelectTextTrigger.EVENT_CLEAR, - action: function () { - self._clear(); - self.fireEvent(BI.TextValueCombo.EVENT_CHANGE); + action: () => { + this._clear(); + this.fireEvent(BI.TextValueCombo.EVENT_CHANGE); } } ], - }); - this.popup = BI.createWidget({ + }; + const popup = { type: "bi.text_value_combo_popup", + ref: ref => this.popup = ref, chooseType: o.chooseType, value: o.value, - items: o.items - }); - this.popup.on(BI.TextValueComboPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.textIconCombo.hideView(); - self.fireEvent(BI.TextValueCombo.EVENT_CHANGE, arguments); - }); - this.popup.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.textIconCombo = BI.createWidget({ + items: o.items, + listeners: [ + { + eventName: BI.TextValueComboPopup.EVENT_CHANGE, + action: (...args) => { + this.setValue(this.popup.getValue()); + this.combo.hideView(); + this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, args); + } + }, { + eventName: BI.Controller.EVENT_CHANGE, + action: (...args) => { + this.fireEvent(BI.Controller.EVENT_CHANGE, args); + } + } + ] + }; + + return { type: "bi.combo", + ref: ref => this.combo = ref, container: o.container, direction: o.direction, - element: this, adjustLength: 2, - el: this.trigger, + el: trigger, popup: { - el: this.popup, + el: popup, maxHeight: 240, minHeight: 25 } - }); + }; + }, + + mounted: function () { + const o = this.options; if (BI.isKey(o.value)) { this._checkError(o.value); } }, _clear: function () { - this.trigger.setValue(); - this.popup.setValue(); - this.element.removeClass("error"); - this.trigger.element.removeClass("error"); + this.combo.setValue(); + this.setStatus("success"); }, _checkError: function (v) { - v = BI.isArray(v) ? v[0] : v; - var tipType = null; + + if (BI.isNull(v)) { + this.setStatus("success"); + return; + } + + var vals = BI.isArray(v) ? v : [v]; + var result = BI.find(this.options.items, function (idx, item) { - return v === item.value; + return BI.contains(vals, item.value); }); + if (BI.isNull(result)) { - if (this.isEnabled()) { - tipType = "warning"; - } - this.element.addClass("error"); - this.trigger.element.addClass("error"); + this.setStatus("error"); } else { - this.element.removeClass("error"); - this.trigger.element.removeClass("error"); + this.setStatus("success"); } - this.trigger.setTipType(tipType); + }, + + clear: function () { + this._clear(); }, setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); + this.combo.setValue(v); this._checkError(v); }, + setStatus: function (status) { + this.element.removeClass(`bi-status-${this.options.status}`); + this.element.addClass(`bi-status-${status}`); + this.options.status = status; + }, + getValue: function () { var value = this.popup.getValue(); return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); @@ -119,7 +158,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { populate: function (items) { this.options.items = items; - this.textIconCombo.populate(items); + this.combo.populate(items); } }); BI.TextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index 52d3878fb..3be2d7757 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/src/case/trigger/trigger.text.select.js @@ -36,7 +36,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { textTgap: o.textTgap, textBgap: o.textBgap, tipType: o.tipType, - warningTitle: o.warningTitle, + title: null, allowClear: o.allowClear, listeners: [ { diff --git a/src/less/base/combo/combo.textvalue.less b/src/less/base/combo/combo.textvalue.less new file mode 100644 index 000000000..89329e60f --- /dev/null +++ b/src/less/base/combo/combo.textvalue.less @@ -0,0 +1,24 @@ +@import "../../index.less"; + +.bi-text-value-combo { + //将来统一变成combo的特性 + &.bi-status-error { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-negative; + } + + .bi-trigger .select-text-label { + color: @color-bi-text-error-text-trigger; + } + } + + &.bi-status-warning { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-warning; + } + + .bi-trigger .select-text-label { + color: @font-color-warning; + } + } +} From f96fd2a45b9062e6f13c61ec562f5d17acc79503 Mon Sep 17 00:00:00 2001 From: data Date: Thu, 18 Aug 2022 09:08:28 +0800 Subject: [PATCH 05/15] auto upgrade version to 2.0.20220818090810 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 103ff88ee..7a4c8c9c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220816172514", + "version": "2.0.20220818090810", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts", From 6432871fc1ff0373ea04c6addd867c756747542c Mon Sep 17 00:00:00 2001 From: data Date: Thu, 18 Aug 2022 10:35:23 +0800 Subject: [PATCH 06/15] auto upgrade version to 2.0.20220818103515 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7a4c8c9c9..b40437a05 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220818090810", + "version": "2.0.20220818103515", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts", From 701ab5576fb0476d87bc0638361e88a85cde37c8 Mon Sep 17 00:00:00 2001 From: zsmj Date: Thu, 18 Aug 2022 14:59:58 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E6=97=A0JIRA=20fix:=20=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=86=99=E9=94=99=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/case/combo/textvaluecombo/combo.textvalue.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index f59714c1f..b7f25ea50 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -78,12 +78,12 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { action: (...args) => { this.setValue(this.popup.getValue()); this.combo.hideView(); - this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, args); + this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); } }, { eventName: BI.Controller.EVENT_CHANGE, action: (...args) => { - this.fireEvent(BI.Controller.EVENT_CHANGE, args); + this.fireEvent(BI.Controller.EVENT_CHANGE, ...args); } } ] From 157a59b07066a3ed020af488a7d1072d2d42c535 Mon Sep 17 00:00:00 2001 From: data Date: Thu, 18 Aug 2022 15:35:12 +0800 Subject: [PATCH 08/15] auto upgrade version to 2.0.20220818153502 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b40437a05..4c270ebd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220818103515", + "version": "2.0.20220818153502", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts", From cf819306fd173e55d4713b71d6ab8ef384160910 Mon Sep 17 00:00:00 2001 From: treecat Date: Fri, 19 Aug 2022 10:38:50 +0800 Subject: [PATCH 09/15] =?UTF-8?q?KERNEL-9408=20fix:=E8=A7=A3=E5=86=B3butto?= =?UTF-8?q?n=E7=9A=84icon=E5=B1=9E=E6=80=A7=E6=9C=89=E6=97=B6=E5=A4=B1?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/button/buttons/button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index 7a8ba672d..11762c86d 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -90,7 +90,7 @@ } } - var iconInvisible = !o.loading && !o.iconCls; + var iconInvisible = !o.loading && !o.iconCls && !o.icon; if (BI.isPlainObject(o.icon) && !o.loading) { this.icon = BI.createWidget(o.icon); } else { From 67bc8f8aefd40b4a24760dabdfb8ef7c2c71e5de Mon Sep 17 00:00:00 2001 From: Kira Date: Fri, 19 Aug 2022 11:09:51 +0800 Subject: [PATCH 10/15] =?UTF-8?q?JSY-21914=20fix:=20=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/case/combo/textvaluecombo/combo.textvalue.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index b7f25ea50..97113ee49 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -152,7 +152,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - var value = this.popup.getValue(); + var value = this.combo.getValue(); return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, From b37406b60d38dc0eb25ba042490d2bd930e84d7c Mon Sep 17 00:00:00 2001 From: zsmj Date: Fri, 19 Aug 2022 11:10:28 +0800 Subject: [PATCH 11/15] =?UTF-8?q?KERNEL-12033=20feat:=20=E5=A4=8D=E9=80=89?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=B7=BB=E5=8A=A0itemFormatter=E5=B1=9E?= =?UTF-8?q?=E6=80=A7,=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/multiselect.combo.js | 2 ++ src/widget/multiselect/multiselect.loader.js | 21 +++++++++++-------- .../multiselect/multiselect.loader.nobar.js | 18 +++++++++------- .../multiselect/multiselect.popup.view.js | 1 + .../multiselect.popup.view.nobar.js | 1 + .../search/multiselect.search.loader.js | 2 +- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/widget/multiselect/multiselect.combo.js b/src/widget/multiselect/multiselect.combo.js index c370a48ee..00b035096 100644 --- a/src/widget/multiselect/multiselect.combo.js +++ b/src/widget/multiselect/multiselect.combo.js @@ -57,6 +57,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { }, }, valueFormatter: o.valueFormatter, + itemFormatter: o.itemFormatter, itemsCreator: BI.bind(this._itemsCreator4Trigger, this), itemHeight: o.itemHeight, value: this.storeValue, @@ -162,6 +163,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { itemsCreator: o.itemsCreator, itemHeight: o.itemHeight, valueFormatter: o.valueFormatter, + itemFormatter: o.itemFormatter, onLoaded: function () { BI.nextTick(function () { self.combo.adjustWidth(); diff --git a/src/widget/multiselect/multiselect.loader.js b/src/widget/multiselect/multiselect.loader.js index 3dc7229bb..7c45c68c1 100644 --- a/src/widget/multiselect/multiselect.loader.js +++ b/src/widget/multiselect/multiselect.loader.js @@ -64,7 +64,6 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { value: v, title: txt, selected: self.storeValue.type === BI.Selection.Multi, - ...opts.itemFormatter(v), }; }); if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { @@ -74,7 +73,6 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { value: startValue, title: txt, selected: true, - ...opts.itemFormatter(startValue), }); } firstItems = self._createItems(json); @@ -111,13 +109,18 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { _createItems: function (items) { var allSelected = this.isAllSelected(); - return BI.createItems(items, { - type: "bi.multi_select_item", - logic: this.options.logic, - cls: "bi-list-item-active", - height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - selected: allSelected, - iconWrapperWidth: 36 + var itemFormatter = this.options.itemFormatter; + return BI.map(items, (i, item) => { + return { + type: "bi.multi_select_item", + logic: this.options.logic, + cls: "bi-list-item-active", + height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, + selected: allSelected, + iconWrapperWidth: 36, + ...item, + ...itemFormatter(item), + }; }); }, diff --git a/src/widget/multiselect/multiselect.loader.nobar.js b/src/widget/multiselect/multiselect.loader.nobar.js index d7744d042..6d9852a35 100644 --- a/src/widget/multiselect/multiselect.loader.nobar.js +++ b/src/widget/multiselect/multiselect.loader.nobar.js @@ -113,12 +113,16 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { }, _createItems: function (items) { - return BI.createItems(items, { - type: "bi.multi_select_item", - cls: "bi-list-item-active", - logic: this.options.logic, - height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - iconWrapperWidth: 36 + return BI.map(items, (index, item) => { + return { + type: "bi.multi_select_item", + cls: "bi-list-item-active", + logic: this.options.logic, + height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, + iconWrapperWidth: 36, + ...item, + ...this.options.itemFormatter(item), + }; }); }, @@ -168,7 +172,7 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { }, resetHeight: function (h) { - this.button_group.element.css({"max-height": h / BI.pixRatio + BI.pixUnit}); + this.button_group.element.css({ "max-height": h / BI.pixRatio + BI.pixUnit }); }, resetWidth: function () { diff --git a/src/widget/multiselect/multiselect.popup.view.js b/src/widget/multiselect/multiselect.popup.view.js index cefe9f0b2..1e11376d2 100644 --- a/src/widget/multiselect/multiselect.popup.view.js +++ b/src/widget/multiselect/multiselect.popup.view.js @@ -27,6 +27,7 @@ BI.MultiSelectPopupView = BI.inherit(BI.Widget, { itemsCreator: opts.itemsCreator, itemHeight: opts.itemHeight, valueFormatter: opts.valueFormatter, + itemFormatter: opts.itemFormatter, onLoaded: opts.onLoaded, value: opts.value }); diff --git a/src/widget/multiselect/multiselect.popup.view.nobar.js b/src/widget/multiselect/multiselect.popup.view.nobar.js index 9132ae5ee..c0007f85a 100644 --- a/src/widget/multiselect/multiselect.popup.view.nobar.js +++ b/src/widget/multiselect/multiselect.popup.view.nobar.js @@ -27,6 +27,7 @@ BI.MultiSelectNoBarPopupView = BI.inherit(BI.Widget, { itemsCreator: opts.itemsCreator, itemHeight: opts.itemHeight, valueFormatter: opts.valueFormatter, + itemFormatter: opts.itemFormatter, onLoaded: opts.onLoaded, value: opts.value }); diff --git a/src/widget/multiselect/search/multiselect.search.loader.js b/src/widget/multiselect/search/multiselect.search.loader.js index 07d4cfbea..89e4cb318 100644 --- a/src/widget/multiselect/search/multiselect.search.loader.js +++ b/src/widget/multiselect/search/multiselect.search.loader.js @@ -128,7 +128,7 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, { title: v.text, value: v.value, selected: src.type === BI.Selection.All, - ...o.itemFormatter(v.value), + ...o.itemFormatter(v), }; }); }, From 250414dc23f483025f26fa6c8954fac76497dc50 Mon Sep 17 00:00:00 2001 From: zsmj Date: Fri, 19 Aug 2022 11:22:10 +0800 Subject: [PATCH 12/15] =?UTF-8?q?JSY-21914=20fix:=20=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/case/combo/textvaluecombo/combo.textvalue.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index b7f25ea50..dc39d1b1e 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -98,6 +98,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { el: trigger, popup: { el: popup, + value: o.value, maxHeight: 240, minHeight: 25 } @@ -152,7 +153,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - var value = this.popup.getValue(); + var value = this.combo.getValue(); return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, From b616c6796f0ab9cfe30c4182cfb744729caa734e Mon Sep 17 00:00:00 2001 From: data Date: Fri, 19 Aug 2022 11:35:34 +0800 Subject: [PATCH 13/15] auto upgrade version to 2.0.20220819113527 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4c270ebd9..313842244 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220818153502", + "version": "2.0.20220819113527", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts", From 3bd01018903bc8504296bd943fd8ea31d128f89b Mon Sep 17 00:00:00 2001 From: data Date: Fri, 19 Aug 2022 11:45:38 +0800 Subject: [PATCH 14/15] auto upgrade version to 2.0.20220819114527 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 313842244..4ceb09229 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220819113527", + "version": "2.0.20220819114527", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts", From be7f7bfff96cc55f840bd0b328911263df1bf68c Mon Sep 17 00:00:00 2001 From: data Date: Fri, 19 Aug 2022 14:06:50 +0800 Subject: [PATCH 15/15] auto upgrade version to 2.0.20220819140607 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ceb09229..0f1dab006 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220819114527", + "version": "2.0.20220819140607", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts",