From 7a2c999e2b2a3c47d7413eea3cc7a95f5c054481 Mon Sep 17 00:00:00 2001 From: zsmj Date: Thu, 5 Jan 2023 14:33:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-87959=20fix:=20BI.NumberEditor?= =?UTF-8?q?=E8=B6=85=E5=87=BA=E8=8C=83=E5=9B=B4=E9=9C=80=E8=A6=81=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E7=A6=81=E7=94=A8=E5=BE=AE=E8=B0=83=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/numbereditor/number.editor.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/widget/numbereditor/number.editor.js b/src/widget/numbereditor/number.editor.js index 2624c5dc4..a2136bb10 100644 --- a/src/widget/numbereditor/number.editor.js +++ b/src/widget/numbereditor/number.editor.js @@ -137,8 +137,11 @@ BI.NumberEditor = BI.inherit(BI.Widget, { // 微调 _finetuning: function (add) { - var v = BI.parseFloat(this.getValue()); - this.setValue(BI.add(v, add)); + const { max, min } = this.options; + let v = BI.parseFloat(this.getValue()); + v = BI.add(v, add); + v = BI.clamp(v, min, max); + this.setValue(v); }, setUpEnable: function (v) { @@ -165,7 +168,8 @@ BI.NumberEditor = BI.inherit(BI.Widget, { var o = this.options; o.value = v; this.editor.setValue(o.valueFormatter(v)); - } + this._checkAdjustDisabled(o.value); + }, }); BI.NumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; From 2ba96a52d630fc0c28e7ab07943fb2fbf684c504 Mon Sep 17 00:00:00 2001 From: zsmj Date: Thu, 5 Jan 2023 14:35:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?KERNEL-14024=20feat:=20bi.number=5Feditor?= =?UTF-8?q?=20=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96,=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=94=AE=E7=9B=98=E4=B8=8A=E4=B8=8B=E9=94=AE=E5=BE=AE=E8=B0=83?= =?UTF-8?q?=E6=95=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/editor/editor.js | 2 ++ src/case/editor/editor.sign.js | 4 +++ src/widget/numbereditor/number.editor.js | 41 +++++++++++++++++++----- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index c0a77c9f6..2dfcb8b6c 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -109,6 +109,7 @@ BI.Editor = BI.inherit(BI.Single, { if (e.keyCode !== BI.KeyCode.TAB && self.watermark) { self.watermark.invisible(); } + self.fireEvent(BI.Editor.EVENT_QUICK_DOWN, arguments); }); this.editor.on(BI.Input.EVENT_VALID, function () { @@ -360,6 +361,7 @@ BI.Editor.EVENT_FOCUS = "EVENT_FOCUS"; BI.Editor.EVENT_BLUR = "EVENT_BLUR"; BI.Editor.EVENT_CLICK = "EVENT_CLICK"; BI.Editor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.Editor.EVENT_QUICK_DOWN = "EVENT_QUICK_DOWN"; BI.Editor.EVENT_SPACE = "EVENT_SPACE"; BI.Editor.EVENT_BACKSPACE = "EVENT_BACKSPACE"; diff --git a/src/case/editor/editor.sign.js b/src/case/editor/editor.sign.js index 0fb65fa0d..a624d78a2 100644 --- a/src/case/editor/editor.sign.js +++ b/src/case/editor/editor.sign.js @@ -87,6 +87,9 @@ BI.SignEditor = BI.inherit(BI.Widget, { this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { self.fireEvent(BI.SignEditor.EVENT_KEY_DOWN, arguments); }); + this.editor.on(BI.Editor.EVENT_QUICK_DOWN, function () { + self.fireEvent(BI.SignEditor.EVENT_QUICK_DOWN, arguments); + }); this.editor.on(BI.Editor.EVENT_VALID, function () { self.fireEvent(BI.SignEditor.EVENT_VALID, arguments); @@ -265,6 +268,7 @@ BI.SignEditor.EVENT_FOCUS = "EVENT_FOCUS"; BI.SignEditor.EVENT_BLUR = "EVENT_BLUR"; BI.SignEditor.EVENT_CLICK = "EVENT_CLICK"; BI.SignEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.SignEditor.EVENT_QUICK_DOWN = "EVENT_QUICK_DOWN"; BI.SignEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL"; BI.SignEditor.EVENT_START = "EVENT_START"; diff --git a/src/widget/numbereditor/number.editor.js b/src/widget/numbereditor/number.editor.js index a2136bb10..13f360baa 100644 --- a/src/widget/numbereditor/number.editor.js +++ b/src/widget/numbereditor/number.editor.js @@ -39,9 +39,33 @@ BI.NumberEditor = BI.inherit(BI.Widget, { if (o.validationChecker === BI.emptyFn && !self._checkValueInRange(parsedValue)) { return false; } + return o.validationChecker(parsedValue); }, - errorText: o.errorText + errorText: o.errorText, + listeners: [ + { + eventName: BI.SignEditor.EVENT_QUICK_DOWN, + action: e => { + if ([BI.KeyCode.UP, BI.KeyCode.DOWN].includes(e.keyCode)) { + e.preventDefault(); + } + }, + }, + { + eventName: BI.SignEditor.EVENT_KEY_DOWN, + action: (keycode) => { + if (keycode === BI.KeyCode.UP) { + this._finetuning(o.step); + + return; + } + if (keycode === BI.KeyCode.DOWN) { + this._finetuning(-o.step); + } + }, + } + ], }); this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { // 大多数时候valueFormatter往往需要配合valueParser一起使用 @@ -68,7 +92,7 @@ BI.NumberEditor = BI.inherit(BI.Widget, { forceNotSelected: true, trigger: "lclick,", debounce: false, - cls: (o.simple ? "solid-triangle-top-font " : "add-up-font bi-border-left ") + "top-button bi-list-item-active2 icon-size-12" + cls: (o.simple ? "solid-triangle-top-font " : "add-up-font bi-border-left ") + "top-button bi-list-item-active2 icon-size-12", }); this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { self._finetuning(o.step); @@ -80,7 +104,7 @@ BI.NumberEditor = BI.inherit(BI.Widget, { trigger: "lclick,", forceNotSelected: true, debounce: false, - cls: (o.simple ? "solid-triangle-bottom-font " : "minus-down-font bi-border-left ") + "bottom-button bi-list-item-active2 icon-size-12" + cls: (o.simple ? "solid-triangle-bottom-font " : "minus-down-font bi-border-left ") + "bottom-button bi-list-item-active2 icon-size-12", }); this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { self._finetuning(-o.step); @@ -101,17 +125,17 @@ BI.NumberEditor = BI.inherit(BI.Widget, { { column: 0, row: 0, - el: this.topBtn + el: this.topBtn, }, { column: 0, row: 1, - el: this.bottomBtn + el: this.bottomBtn, } - ] + ], }, - width: 23 + width: 23, } - ] + ], }); }, @@ -125,6 +149,7 @@ BI.NumberEditor = BI.inherit(BI.Widget, { _checkValueInRange: function (v) { var o = this.options; + return !!(BI.isNumeric(v) && BI.parseFloat(v) >= o.min && BI.parseFloat(v) <= o.max); }, From 8c4d2bde5e89460864e0ac01b17c284f9777154d Mon Sep 17 00:00:00 2001 From: data Date: Fri, 6 Jan 2023 11:48:21 +0800 Subject: [PATCH 3/3] auto upgrade version to 2.0.20230106114746 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f8c1b66ed..43c6b73f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20230105142517", + "version": "2.0.20230106114746", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts",