diff --git a/bi.lessconfig.json b/bi.lessconfig.json index cbb1aabcf..44b1ca0f6 100644 --- a/bi.lessconfig.json +++ b/bi.lessconfig.json @@ -46,5 +46,6 @@ "@font-trigger-triangle": "e924", "@font-solid-bottom": "e905", "@font-solid-right": "e906", - "@font-dot": "e762" + "@font-dot": "e762", + "@font-down-triangle": "e70b" } diff --git a/bin/cli/worker/template/main_thread.helper.t b/bin/cli/worker/template/main_thread.helper.t index 19ac36016..2ee06acb7 100644 --- a/bin/cli/worker/template/main_thread.helper.t +++ b/bin/cli/worker/template/main_thread.helper.t @@ -2,7 +2,7 @@ import { ${WorkerName}MainThreadWorker } from './main_thread/${workerName}_main_ // 不需要一起打包的话则不需要引入这行 // FuiWorkerPlugin中的属性会同步到fui-worker中,同时支持loader行内传入属性 // 根据实际需求传入inline,返回格式 true -> blob url,false -> servicePath -import { workerUrl } from 'fui-worker!./worker_thread/${workerName}_worker_thread'; +import workerUrl from 'fui-worker!./worker_thread/${workerName}_worker_thread'; export class ${WorkerName}WorkerHelper { private worker: ${WorkerName}MainThreadWorker; diff --git a/demo/js/case/combo/demo.text_value_combo.js b/demo/js/case/combo/demo.text_value_combo.js index 50e3fea43..15df83c54 100644 --- a/demo/js/case/combo/demo.text_value_combo.js +++ b/demo/js/case/combo/demo.text_value_combo.js @@ -146,7 +146,7 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { type: "bi.button", text: "setValue(1)", handler: function () { - combo1.setValue(); + combo1.setValue(1); }, }, vgap: 10, @@ -184,6 +184,27 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { vgap: 10, } ] + }), + this.createCombo("支持复选", { + type: "bi.vertical", + items: [ + { + type: "bi.text_value_combo", + width: 300, + items: items, + allowClear: true, + defaultText: "请选择", + chooseType: BI.Selection.Multi, + listeners: [ + { + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: function () { + console.log(this.getValue()); + } + } + ] + } + ] }) ] }; diff --git a/demo/js/widget/downlist/demo.downlist.js b/demo/js/widget/downlist/demo.downlist.js index 6c5382842..df01a9a28 100644 --- a/demo/js/widget/downlist/demo.downlist.js +++ b/demo/js/widget/downlist/demo.downlist.js @@ -1,3 +1,15 @@ +(function () { + var CustomIcon = BI.inherit(BI.Widget, { + render: function () { + return { + type: "bi.label", + text: "✨", + }; + }, + }); + BI.shortcut("demo.downlist.icon", CustomIcon); +}()); + Demo.Downlist = BI.inherit(BI.Widget, { props: { baseCls: "demo-downlist" @@ -22,9 +34,9 @@ Demo.Downlist = BI.inherit(BI.Widget, { render: function () { var self = this; - // test + return { - type: "bi.horizontal_adapt", + type: "bi.left", items: [{ type: "bi.down_list_combo", ref: function (_ref) { @@ -35,11 +47,9 @@ Demo.Downlist = BI.inherit(BI.Widget, { width: 100, items: [ [{ - el: { - text: "column 1111", - iconCls1: "dot-e-font", - value: 12 - }, + text: "column 1111", + iconCls1: "dot-e-font", + value: 12, children: [{ text: "column 1.1", value: 21, @@ -131,7 +141,49 @@ Demo.Downlist = BI.inherit(BI.Widget, { // }] }] - ] + ], + }, { + type: "bi.down_list_combo", + el: { + type: "bi.button", + ghost: true, + iconPosition: "right", + icon: "column-next-page-h-font", + text: "自定义 trigger 和 icon 的级联下拉框", + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function (v) { + console.log("触发值", v); + } + }, { + eventName: "EVENT_SON_VALUE_CHANGE", + action: function(v) { + console.log("二级菜单触发值", v) + } + }], + items: [ + [{ + text: "选项一", + value: 1, + icon: { + type: "demo.downlist.icon", + }, + children: [{ + text: "选项一", + value: 11, + icon: { + type: "demo.downlist.icon", + }, + }, { + text: "选项二", + value: 12, + }], + }, { + text: "选项二", + value: 2, + }] + ], }, { type: "bi.multi_layer_down_list_combo", ref: function (_ref) { diff --git a/demo/js/widget/numbereditor/demo.number_editor.js b/demo/js/widget/numbereditor/demo.number_editor.js index c78238052..9a57706bd 100644 --- a/demo/js/widget/numbereditor/demo.number_editor.js +++ b/demo/js/widget/numbereditor/demo.number_editor.js @@ -7,7 +7,7 @@ Demo.FileManager = BI.inherit(BI.Widget, { }, render: function () { - var editor = BI.createWidget({ + var editor1 = BI.createWidget({ type: "bi.number_editor", validationChecker: function (v) { return BI.parseFloat(v) <= 100 && BI.parseFloat(v) >= 0; @@ -16,21 +16,50 @@ Demo.FileManager = BI.inherit(BI.Widget, { width: 150, errorText: "hahah" }); - editor.on(BI.NumberEditor.EVENT_CHANGE, function () { + editor1.on(BI.NumberEditor.EVENT_CHANGE, function () { if (BI.parseFloat(this.getValue()) < 1) { - editor.setDownEnable(false); + editor1.setDownEnable(false); } else { - editor.setDownEnable(true); + editor1.setDownEnable(true); } - BI.Msg.toast(editor.getValue()); + BI.Msg.toast(editor1.getValue()); }); + + + var editor2 = BI.createWidget({ + type: "bi.number_editor", + validationChecker: function (v) { + return BI.parseFloat(v) <= 100 && BI.parseFloat(v) >= 0; + }, + valueFormatter: (v) => `${v}$`, + valueParser: (v) => v.replace(/\$\s?|(,*)/g, ''), + height: 24, + width: 150, + errorText: "hahah" + }); + editor2.on(BI.NumberEditor.EVENT_CHANGE, function () { + if (BI.parseFloat(this.getValue()) < 1) { + editor2.setDownEnable(false); + } else { + editor2.setDownEnable(true); + } + BI.Msg.toast(editor2.getValue()); + }); + return { type: "bi.vertical", - items: [{ - el: editor, - height: 24 - }] + hgap: 20, + vgap: 20, + items: [ + { + el: editor1, + height: 24 + }, { + el: editor2, + height: 24 + } + ] }; } }); -BI.shortcut("demo.number_editor", Demo.FileManager); \ No newline at end of file +BI.shortcut("demo.number_editor", Demo.FileManager); diff --git a/demo/js/widget/slider/demo.slider.js b/demo/js/widget/slider/demo.slider.js index 61ebe57e7..2116ff99e 100644 --- a/demo/js/widget/slider/demo.slider.js +++ b/demo/js/widget/slider/demo.slider.js @@ -17,16 +17,11 @@ Demo.Slider = BI.inherit(BI.Widget, { digit: 0, width: o.width, height: o.height, - cls: "layout-bg-white" - }); - - singleSlider.setMinAndMax({ + cls: "layout-bg-white", + value: 30, min: 10, - max: o.max + max: 100 }); - - singleSlider.setValue(30); - singleSlider.populate(); singleSlider.on(BI.SingleSlider.EVENT_CHANGE, function () { console.log(this.getValue()); }); @@ -35,14 +30,14 @@ Demo.Slider = BI.inherit(BI.Widget, { type: "bi.single_slider_normal", width: o.width, height: 30, - cls: "layout-bg-white" - }); - normalSingleSlider.setMinAndMax({ + cls: "layout-bg-white", min: o.min, - max: o.max + max: o.max, + value: 30, + }); + normalSingleSlider.on(BI.SingleSliderNormal.EVENT_DRAG, function () { + console.log(this.getValue()); }); - normalSingleSlider.setValue(10); - normalSingleSlider.populate(); var singleSliderLabel = BI.createWidget({ type: "bi.single_slider_label", @@ -50,47 +45,38 @@ Demo.Slider = BI.inherit(BI.Widget, { height: o.height, digit: 0, unit: "个", - cls: "layout-bg-white" - }); - singleSliderLabel.setMinAndMax({ + cls: "layout-bg-white", min: o.min, - max: o.max + max: o.max, + value: 10, }); - singleSliderLabel.setValue(10); - singleSliderLabel.populate(); var intervalSlider = BI.createWidget({ type: "bi.interval_slider", width: o.width, digit: 0, - cls: "layout-bg-white" - }); - intervalSlider.setMinAndMax({ + cls: "layout-bg-white", min: o.min, - max: o.max - }); - intervalSlider.setValue({ - min: 10, - max: 120 + max: o.max, + value: { + min: 10, + max: 70 + } }); - intervalSlider.populate(); var intervalSliderLabel = BI.createWidget({ type: "bi.interval_slider", width: o.width, unit: "px", cls: "layout-bg-white", - digit: 1 - }); - intervalSliderLabel.setMinAndMax({ + digit: 1, min: 0, - max: 120 - }); - intervalSliderLabel.setValue({ - min: 10, - max: 120 + max: 120, + value: { + min: 60, + max: 120 + } }); - intervalSliderLabel.populate(); return { @@ -126,4 +112,4 @@ Demo.Slider = BI.inherit(BI.Widget, { }; } }); -BI.shortcut("demo.slider", Demo.Slider); \ No newline at end of file +BI.shortcut("demo.slider", Demo.Slider); diff --git a/lodash.md b/lodash.md index 8faeb0142..411585265 100644 --- a/lodash.md +++ b/lodash.md @@ -1 +1 @@ -lodash core plus="debounce,throttle,get,set,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy,before,after,unescape,chunk" +lodash core plus="debounce,throttle,get,set,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy,before,after,unescape,chunk,pick,pickBy,identity" diff --git a/package.json b/package.json index 6ccd9486e..0f1a7a51f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220826175704", + "version": "2.0.20221009164825", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts", @@ -11,8 +11,10 @@ "@babel/core": "^7.17.4", "@babel/polyfill": "7.6.0", "@fui/babel-preset-fineui": "^2.0.0", - "@fui/eslint-plugin": "^1.0.15", + "@fui/eslint-plugin": "^1.0.19", "@types/node": "15.6.1", + "@typescript-eslint/eslint-plugin": "2.33.0", + "@typescript-eslint/parser": "2.33.0", "autoprefixer": "9.6.1", "babel-loader": "8.0.6", "chai": "4.2.0", diff --git a/plugins/webpack-fui-worker-plugin/worker-loader.js b/plugins/webpack-fui-worker-plugin/worker-loader.js index 23be31927..c9dad87d5 100644 --- a/plugins/webpack-fui-worker-plugin/worker-loader.js +++ b/plugins/webpack-fui-worker-plugin/worker-loader.js @@ -117,16 +117,13 @@ function loader() { // 添加 @ts-nocheck 避免 ts-check 报错 // 修复export const 下 const不会被转译的问题 `// @ts-nocheck - const blob = new Blob([${JSON.stringify(compilation.assets[entry].source())}]); - const workerUrl = window.URL.createObjectURL(blob); - export default workerUrl; + export default window.URL.createObjectURL(new Blob([${JSON.stringify(compilation.assets[entry].source())}])); ` ) : callback( null, `// @ts-nocheck - const servicePath = __webpack_public_path__ + ${JSON.stringify(entry)}; - export default servicePath; + export default __webpack_public_path__ + ${JSON.stringify(entry)}; ` ) }); diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index 0ad681faa..8f6835aa9 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -16,6 +16,9 @@ BI.CollectionView = BI.inherit(BI.Widget, { scrolly: false, overflowX: true, overflowY: true, + el: { + type: "bi.vertical" + }, cellSizeAndPositionGetter: BI.emptyFn, horizontalOverscanSize: 0, verticalOverscanSize: 0, @@ -65,7 +68,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { scrollable = "x"; } } - BI._lazyCreateWidget({ + BI._lazyCreateWidget(o.el, { type: "bi.vertical", element: this, scrollable: scrollable, @@ -124,7 +127,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { _cellRenderers: function (height, width, x, y) { this._lastRenderedCellIndices = this._sectionManager.getCellIndices(height, width, x, y); - + return this._cellGroupRenderer(); }, @@ -135,7 +138,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { var cellMetadata = self._sectionManager.getCellMetadata(index); rendered.push(cellMetadata); }); - + return rendered; }, diff --git a/src/base/combination/bubble.js b/src/base/combination/bubble.js index d4c240b17..d3bc2975a 100644 --- a/src/base/combination/bubble.js +++ b/src/base/combination/bubble.js @@ -83,6 +83,7 @@ BI.createWidget(BI.extend({ element: this, + scrolly: false, }, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, { items: [ { el: this.combo } diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 5fc2f8008..7abbf77eb 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -93,6 +93,7 @@ BI.createWidget(BI.extend({ element: this, + scrolly: false, }, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, { items: [ { el: this.combo } @@ -152,7 +153,7 @@ o.hideWhenClickOutside && BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName()); BI.EVENT_BLUR && o.hideWhenBlur && BI.Widget._renderEngine.createElement(window).unbind("blur." + this.getName()); - this.fireEvent(BI.Combo.EVENT_AFTER_HIDEVIEW); + this.fireEvent(BI.Combo.EVENT_AFTER_HIDEVIEW, e); }, _popupView: function (e) { diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index 81853b77a..edeb8a8f3 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -16,6 +16,9 @@ BI.GridView = BI.inherit(BI.Widget, { scrolly: false, overflowX: true, overflowY: true, + el: { + type: "bi.vertical" + }, overscanColumnCount: 0, overscanRowCount: 0, rowHeightGetter: BI.emptyFn, // number类型或function类型 @@ -68,7 +71,7 @@ BI.GridView = BI.inherit(BI.Widget, { scrollable = "x"; } } - BI._lazyCreateWidget({ + BI._lazyCreateWidget(o.el, { type: "bi.vertical", element: this, scrollable: scrollable, @@ -93,6 +96,12 @@ BI.GridView = BI.inherit(BI.Widget, { this.element.scrollLeft(o.scrollLeft); } }, + + destroyed: function () { + BI.each(this.renderedCells, function(i, cell) { + cell.el._destroy(); + }) + }, _calculateSizeAndPositionData: function () { var o = this.options; diff --git a/src/base/layer/layer.popover.js b/src/base/layer/layer.popover.js index 2a4453472..4244a1efb 100644 --- a/src/base/layer/layer.popover.js +++ b/src/base/layer/layer.popover.js @@ -158,15 +158,17 @@ BI.Popover = BI.inherit(BI.Widget, { mounted: function () { var self = this; this.dragger.element.mousedown(function (e) { - self.startX = self.element[0].offsetLeft; - self.startY = self.element[0].offsetTop; - self.tracker.captureMouseMoves(e); + if (self.options.draggable !== false) { + self.startX = self.element[0].offsetLeft; + self.startY = self.element[0].offsetTop; + self.tracker.captureMouseMoves(e); + } }); }, _getSuitableBodyHeight: function (height) { var o = this.options; - + return BI.clamp(height, 0, BI.Widget._renderEngine.createElement("body")[0].clientHeight - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap); }, @@ -207,6 +209,10 @@ BI.Popover = BI.inherit(BI.Widget, { }; }, + setDraggable: function (b) { + this.options.draggable = b; + }, + hide: function () { }, @@ -224,9 +230,6 @@ BI.Popover = BI.inherit(BI.Widget, { setZindex: function (zindex) { this.element.css({ "z-index": zindex }); }, - - destroyed: function () { - }, }); BI.shortcut("bi.popover", BI.Popover); diff --git a/src/base/list/virtualgrouplist.js b/src/base/list/virtualgrouplist.js index a1836ba94..34b11e800 100644 --- a/src/base/list/virtualgrouplist.js +++ b/src/base/list/virtualgrouplist.js @@ -27,7 +27,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { render: function () { var self = this, o = this.options; - + return { type: "bi.vertical", items: [{ @@ -79,7 +79,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { }, _isAutoHeight: function () { - return this.options.rowHeight === "auto"; + return !BI.isNumber(this.options.rowHeight); }, _renderMoreIf: function () { @@ -97,12 +97,13 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { this.container[self.renderedIndex === -1 ? "populate" : "addItems"](items.map(function (item, i) { return o.itemFormatter(item, index + i); }), this); - var addedHeight = getElementHeight() - lastHeight; + var elementHeight = getElementHeight(); + var addedHeight = elementHeight - lastHeight; this.tree.set(cnt, addedHeight); this.renderedIndex = cnt; cnt++; index += o.blockSize; - lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight(); + lastHeight = this.renderedIndex === -1 ? 0 : elementHeight; } }, diff --git a/src/base/pager/pager.js b/src/base/pager/pager.js index 129db1b8d..06514fb99 100644 --- a/src/base/pager/pager.js +++ b/src/base/pager/pager.js @@ -235,6 +235,7 @@ BI.Pager = BI.inherit(BI.Widget, { setAllPages: function (pages) { this.options.pages = pages; + this._populate(); }, hasPrev: function (v) { diff --git a/src/base/single/button/button.basic.js b/src/base/single/button/button.basic.js index 8fa304890..77bfd1036 100644 --- a/src/base/single/button/button.basic.js +++ b/src/base/single/button/button.basic.js @@ -26,6 +26,7 @@ BI.BasicButton = BI.inherit(BI.Single, { trigger: null, handler: BI.emptyFn, bubble: null, + debounce: true }); }, @@ -222,10 +223,10 @@ BI.BasicButton = BI.inherit(BI.Single, { }); // 之后的300ms点击无效 - var onClick = BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { + var onClick = o.debounce ? BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { "leading": true, "trailing": false, - }); + }) : this._doClick; function ev(e) { if (o.stopEvent) { diff --git a/src/base/single/button/buttons/button.text.js b/src/base/single/button/buttons/button.text.js index 38470c291..15bdde250 100644 --- a/src/base/single/button/buttons/button.text.js +++ b/src/base/single/button/buttons/button.text.js @@ -42,6 +42,7 @@ BI.TextButton = BI.inherit(BI.BasicButton, { value: o.value, py: o.py, keyword: o.keyword, + title: null, }); }, diff --git a/src/base/single/button/listitem/blankiconicontextitem.js b/src/base/single/button/listitem/blankiconicontextitem.js index 1f6419008..580c96d11 100644 --- a/src/base/single/button/listitem/blankiconicontextitem.js +++ b/src/base/single/button/listitem/blankiconicontextitem.js @@ -62,6 +62,7 @@ BI.BlankIconIconTextItem = BI.inherit(BI.BasicButton, { value: o.value, keyword: o.keyword, height: o.height, + title: null, }, }], }; diff --git a/src/base/single/button/listitem/blankicontexticonitem.js b/src/base/single/button/listitem/blankicontexticonitem.js index 34dc9e7d8..d8be21237 100644 --- a/src/base/single/button/listitem/blankicontexticonitem.js +++ b/src/base/single/button/listitem/blankicontexticonitem.js @@ -56,6 +56,7 @@ BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, { value: o.value, keyword: o.keyword, height: o.height, + title: null, }, }, { type: "bi.icon_label", diff --git a/src/base/single/button/listitem/blankicontextitem.js b/src/base/single/button/listitem/blankicontextitem.js index 08f13d22d..e51e31ed2 100644 --- a/src/base/single/button/listitem/blankicontextitem.js +++ b/src/base/single/button/listitem/blankicontextitem.js @@ -55,6 +55,7 @@ BI.BlankIconTextItem = BI.inherit(BI.BasicButton, { value: o.value, keyword: o.keyword, height: o.height, + title: null, }, }], }; diff --git a/src/base/single/button/listitem/icontexticonitem.js b/src/base/single/button/listitem/icontexticonitem.js index 425f47d90..fb510ea9c 100644 --- a/src/base/single/button/listitem/icontexticonitem.js +++ b/src/base/single/button/listitem/icontexticonitem.js @@ -52,6 +52,7 @@ BI.IconTextIconItem = BI.inherit(BI.BasicButton, { value: o.value, keyword: o.keyword, height: o.height, + title: null, }, }, { type: "bi.icon_label", diff --git a/src/base/single/button/listitem/icontextitem.js b/src/base/single/button/listitem/icontextitem.js index 8fff16335..6e7fbc454 100644 --- a/src/base/single/button/listitem/icontextitem.js +++ b/src/base/single/button/listitem/icontextitem.js @@ -53,6 +53,7 @@ BI.IconTextItem = BI.inherit(BI.BasicButton, { value: o.value, keyword: o.keyword, height: o.height, + title: null, }, }], }; diff --git a/src/base/single/button/listitem/texticonitem.js b/src/base/single/button/listitem/texticonitem.js index a0ece74e6..50cf665ae 100644 --- a/src/base/single/button/listitem/texticonitem.js +++ b/src/base/single/button/listitem/texticonitem.js @@ -46,6 +46,7 @@ BI.TextIconItem = BI.inherit(BI.BasicButton, { value: o.value, keyword: o.keyword, height: o.height, + title: null, }, }, { type: "bi.icon_label", diff --git a/src/base/single/button/listitem/textitem.js b/src/base/single/button/listitem/textitem.js index c4c810295..1362160d5 100644 --- a/src/base/single/button/listitem/textitem.js +++ b/src/base/single/button/listitem/textitem.js @@ -39,6 +39,7 @@ BI.TextItem = BI.inherit(BI.BasicButton, { value: o.value, keyword: o.keyword, py: o.py, + title: null, }); }, diff --git a/src/base/single/button/node/icontexticonnode.js b/src/base/single/button/node/icontexticonnode.js index 7569490eb..0131405b0 100644 --- a/src/base/single/button/node/icontexticonnode.js +++ b/src/base/single/button/node/icontexticonnode.js @@ -50,6 +50,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, { value: o.value, keyword: o.keyword, height: o.height, + title: null, }, }, { type: "bi.icon_label", diff --git a/src/base/single/button/node/icontextnode.js b/src/base/single/button/node/icontextnode.js index 16383cc7d..0f0599a71 100644 --- a/src/base/single/button/node/icontextnode.js +++ b/src/base/single/button/node/icontextnode.js @@ -50,6 +50,7 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, { value: o.value, keyword: o.keyword, height: o.height, + title: null, }, }], }; diff --git a/src/base/single/button/node/texticonnode.js b/src/base/single/button/node/texticonnode.js index 01167b009..e70077f03 100644 --- a/src/base/single/button/node/texticonnode.js +++ b/src/base/single/button/node/texticonnode.js @@ -42,6 +42,7 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, { value: o.value, keyword: o.keyword, height: o.height, + title: null, }, }, { type: "bi.icon_label", diff --git a/src/base/single/button/node/textnode.js b/src/base/single/button/node/textnode.js index 6ecaa3fbf..bb5762f72 100644 --- a/src/base/single/button/node/textnode.js +++ b/src/base/single/button/node/textnode.js @@ -38,6 +38,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, { value: o.value, keyword: o.keyword, py: o.py, + title: null, }); }, diff --git a/src/base/single/editor/editor.textarea.js b/src/base/single/editor/editor.textarea.js index 9f91b0ce4..d3838d29e 100644 --- a/src/base/single/editor/editor.textarea.js +++ b/src/base/single/editor/editor.textarea.js @@ -79,7 +79,7 @@ BI.TextAreaEditor = BI.inherit(BI.Single, { BI.Widget._renderEngine.createElement(document).unbind("mousedown." + self.getName()); }); this.content.element.keydown(function () { - // 水印快速消失 + // 水印快速消失 self._checkWaterMark(); }); this.content.element.keyup(function (e) { @@ -111,7 +111,6 @@ BI.TextAreaEditor = BI.inherit(BI.Single, { cls: "bi-water-mark textarea-watermark", textAlign: "left", whiteSpace: o.scrolly ? "normal" : "nowrap", - title: o.watermark, text: o.watermark, invalid: o.invalid, disabled: o.disabled, diff --git a/src/base/single/label/abstract.label.js b/src/base/single/label/abstract.label.js index c0443b39d..ab67a671a 100644 --- a/src/base/single/label/abstract.label.js +++ b/src/base/single/label/abstract.label.js @@ -24,23 +24,6 @@ }); }, - getTitle: function () { - var title = this.options.title; - var text = this.options.text; - if (BI.isFunction(title)) { - return title(); - } - if (BI.isNotNull(title)) { - return title; - } - - if (BI.isFunction(text)) { - return text(); - } - - return text; - }, - _createJson: function () { var o = this.options; diff --git a/src/base/single/label/label.js b/src/base/single/label/label.js index 98bfa3707..905efd29a 100644 --- a/src/base/single/label/label.js +++ b/src/base/single/label/label.js @@ -10,6 +10,23 @@ BI.Label = BI.inherit(BI.AbstractLabel, { keyword: "", }, + getTitle: function () { + var title = this.options.title; + var text = this.options.text; + if (BI.isFunction(title)) { + return title(); + } + if (BI.isNotNull(title)) { + return title; + } + + if (BI.isFunction(text)) { + return text(); + } + + return text; + }, + doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, diff --git a/src/base/single/tip/tip.tooltip.js b/src/base/single/tip/tip.tooltip.js index 70c710497..eadbd05e9 100644 --- a/src/base/single/tip/tip.tooltip.js +++ b/src/base/single/tip/tip.tooltip.js @@ -53,6 +53,7 @@ BI.Tooltip = BI.inherit(BI.Tip, { whiteSpace: "normal", text: text, textHeight: 18, + title: null, }; }), }); @@ -63,6 +64,7 @@ BI.Tooltip = BI.inherit(BI.Tip, { textAlign: o.textAlign, whiteSpace: "normal", text: o.text, + title: null, textHeight: 18, hgap: this._const.hgap, vgap: this._const.vgap, diff --git a/src/case/button/icon/icon.change.js b/src/case/button/icon/icon.change.js index 8790008e2..e65160879 100644 --- a/src/case/button/icon/icon.change.js +++ b/src/case/button/icon/icon.change.js @@ -31,8 +31,11 @@ BI.IconChangeButton = BI.inherit(BI.Single, { }, _init: function () { - BI.IconChangeButton.superclass._init.apply(this, arguments); var self = this, o = this.options; + o.iconCls = BI.isFunction(o.iconCls) ? this.__watch(o.iconCls, function (context, newValue) { + self.setIcon(newValue); + }) : o.iconCls; + BI.IconChangeButton.superclass._init.apply(this, arguments); this.button = BI.createWidget({ type: "bi.icon_button", element: this, @@ -80,4 +83,4 @@ BI.IconChangeButton = BI.inherit(BI.Single, { } }); BI.IconChangeButton.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.icon_change_button", BI.IconChangeButton); \ No newline at end of file +BI.shortcut("bi.icon_change_button", BI.IconChangeButton); diff --git a/src/case/button/icon/iconhalf/icon.half.js b/src/case/button/icon/iconhalf/icon.half.js index 6a46b165e..f8c23afc4 100644 --- a/src/case/button/icon/iconhalf/icon.half.js +++ b/src/case/button/icon/iconhalf/icon.half.js @@ -7,20 +7,34 @@ BI.HalfButton = BI.inherit(BI.BasicButton, { _defaultConfig: function () { var conf = BI.HalfIconButton.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { - extraCls: "bi-half-button bi-high-light-border", - height: 14, + selected: false, width: 14, - selected: false + height: 14, + iconWidth: 14, + iconHeight: 14, }); }, + render: function () { + var o = this.options; + return { + type: "bi.center_adapt", + items: [{ + type: "bi.default", + cls: "bi-half-button bi-high-light-border", + width: o.iconWidth, + height: o.iconHeight, + }], + }; + }, + doClick: function () { BI.HalfButton.superclass.doClick.apply(this, arguments); - if(this.isValid()) { + if (this.isValid()) { this.fireEvent(BI.HalfButton.EVENT_CHANGE); } } }); BI.HalfButton.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.half_button", BI.HalfButton); \ No newline at end of file +BI.shortcut("bi.half_button", BI.HalfButton); diff --git a/src/case/button/switch.js b/src/case/button/switch.js index 2cfbf8839..1ca2bd2b6 100644 --- a/src/case/button/switch.js +++ b/src/case/button/switch.js @@ -77,7 +77,7 @@ BI.Switch = BI.inherit(BI.BasicButton, { doClick: function () { BI.Switch.superclass.doClick.apply(this, arguments); - this.fireEvent(BI.Switch.EVENT_CHANGE); + this.fireEvent(BI.Switch.EVENT_CHANGE, this.isSelected()); } }); BI.Switch.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/case/colorchooser/colorchooser.js b/src/case/colorchooser/colorchooser.js index 991be4a77..df4d9eb1b 100644 --- a/src/case/colorchooser/colorchooser.js +++ b/src/case/colorchooser/colorchooser.js @@ -39,7 +39,7 @@ BI.ColorChooser = BI.inherit(BI.Widget, { width: o.el.type ? o.width : o.width - 2, height: o.el.type ? o.height : o.height - 2 }, o.el), - popup: { + popup: () => ({ el: BI.extend({ type: "bi.hex_color_chooser_popup", recommendColorsGetter: o.recommendColorsGetter, @@ -64,13 +64,13 @@ BI.ColorChooser = BI.inherit(BI.Widget, { }, o.popup), value: o.value, width: 300 - }, + }), value: o.value }); var fn = function () { var color = self.colorPicker.getValue(); - self.trigger.setValue(color); + self.setValue(color); }; this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { @@ -98,7 +98,8 @@ BI.ColorChooser = BI.inherit(BI.Widget, { }, setValue: function (color) { - this.combo.setValue((color || "").toLowerCase()); + this.options.value = (color || "").toLowerCase(); + this.combo.setValue(this.options.value); }, getValue: function () { diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index d6c80ac95..8acb19eb0 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -13,9 +13,10 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { text: "", value: "", defaultText: "", + el: {}, allowClear: false, status: "success", // success | warning | error, - title: null, + title: null }); }, @@ -43,11 +44,11 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { if (this.options.status === "error") { return { level: "warning", - text: o.warningTitle, + text: o.warningTitle }; } return { - level: "success", + level: "success" }; }; @@ -71,7 +72,9 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { } } ], + ...o.el }; + let changeTag = false; const popup = { type: "bi.text_value_combo_popup", ref: ref => this.popup = ref, @@ -81,15 +84,34 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { { eventName: BI.TextValueComboPopup.EVENT_CHANGE, action: (...args) => { - this.setValue(this.popup.getValue()); - this.combo.hideView(); - this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); + changeTag = true; + const value = this.popup.getValue(); + this.setValue(value); + if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) { + this.combo.hideView(...args); + this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); + } + if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_MULTI && BI.isEmptyArray(value)) { + this._clear(); + } } }, { eventName: BI.Controller.EVENT_CHANGE, action: (...args) => { this.fireEvent(BI.Controller.EVENT_CHANGE, ...args); } + }, { + eventName: BI.TextValueComboPopup.EVENT_CLEAR, + action: (...args) => { + changeTag = true; + this._clear(); + this.combo.hideView(); + } + }, { + eventName: BI.TextValueComboPopup.EVENT_CONFIRM, + action: (...args) => { + this.combo.hideView(); + } } ] }; @@ -101,6 +123,21 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { direction: o.direction, adjustLength: 2, el: trigger, + listeners: [ + { + eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, + action: () => { + changeTag = false; + } + }, { + eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, + action: (...args) => { + if (o.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_SINGLE && changeTag) { + this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); + } + } + } + ], popup: { el: popup, value: o.value, @@ -112,12 +149,13 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { mounted: function () { const o = this.options; - if (BI.isKey(o.value)) { + if (BI.isKey(o.value) || BI.isObject(o.value)) { this._checkError(o.value); } }, _clear: function () { + this.trigger.setText(""); this.combo.setValue(); this.setStatus("success"); }, @@ -131,11 +169,9 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { var vals = BI.isArray(v) ? v : [v]; - var result = BI.find(this.options.items, function (idx, item) { - return BI.contains(vals, item.value); - }); + var result = BI.intersection(BI.map(this.options.items, "value"), vals); - if (BI.isNull(result)) { + if (result.length !== vals.length) { this.setStatus("error"); } else { this.setStatus("success"); @@ -146,6 +182,10 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { this._clear(); }, + setText: function (text) { + this.trigger.setText(text); + }, + setValue: function (v) { this.combo.setValue(v); this._checkError(v); diff --git a/src/case/combo/textvaluecombo/combo.textvaluesmall.js b/src/case/combo/textvaluecombo/combo.textvaluesmall.js index b6609544b..155b124ce 100644 --- a/src/case/combo/textvaluecombo/combo.textvaluesmall.js +++ b/src/case/combo/textvaluecombo/combo.textvaluesmall.js @@ -15,65 +15,45 @@ BI.SmallTextValueCombo = BI.inherit(BI.Widget, { }); }, - _init: function () { - var self = this, o = this.options; - o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { - self.setValue(newValue); - }) : o.value; - o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { - self.populate(newValue); - }) : o.items; - BI.SmallTextValueCombo.superclass._init.apply(this, arguments); - this.trigger = BI.createWidget(o.el, { - type: "bi.small_select_text_trigger", - items: o.items, + render: function () { + var o = this.options; + return { + type: "bi.text_value_combo", + ref: (_ref) => { + this.combo = _ref; + }, height: o.height, - text: o.text - }); - this.popup = BI.createWidget({ - type: "bi.text_value_combo_popup", chooseType: o.chooseType, - items: o.items - }); - this.popup.on(BI.TextValueComboPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.SmallTextValueCombo.hideView(); - self.fireEvent(BI.SmallTextValueCombo.EVENT_CHANGE); - }); - this.popup.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.SmallTextValueCombo = BI.createWidget({ - type: "bi.combo", - element: this, - container: o.container, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup, - maxHeight: 240, - minHeight: 25 - } - }); - - if(BI.isKey(o.value)){ - this.setValue(o.value); + el: { + type: "bi.small_select_text_trigger", + ...o.el + }, + text: o.text, + value: o.value, + defaultText: o.defaultText, + allowClear: o.allowClear, + status: o.status, + title: o.title, + listeners: [{ + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: (...args) => { + this.fireEvent(BI.SmallTextValueCombo.EVENT_CHANGE, ...args); + } + }] } }, setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); + this.combo.setValue(v); }, getValue: function () { - return this.popup.getValue(); + return this.combo.getValue(); }, populate: function (items) { - this.options.items = items; - this.SmallTextValueCombo.populate(items); + this.combo.populate(items); } }); BI.SmallTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo); \ No newline at end of file +BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo); diff --git a/src/case/combo/textvaluecombo/popup.textvalue.js b/src/case/combo/textvaluecombo/popup.textvalue.js index 6702f8bfa..9ea5eaa58 100644 --- a/src/case/combo/textvaluecombo/popup.textvalue.js +++ b/src/case/combo/textvaluecombo/popup.textvalue.js @@ -6,40 +6,101 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, { }); }, - _init: function () { - BI.TextValueComboPopup.superclass._init.apply(this, arguments); + render () { var o = this.options, self = this; - this.popup = BI.createWidget({ - type: "bi.button_group", - items: this._formatItems(o.items), - chooseType: o.chooseType, - layouts: [{ - type: "bi.vertical" - }], - value: o.value - }); + if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) { + return { + type: "bi.vertical", + vgap: 5, + items: [{ + type: "bi.button_group", + ref: (_ref) => { + this.popup = _ref; + }, + items: this._formatItems(o.items), + chooseType: o.chooseType, + layouts: [{ + type: "bi.vertical" + }], + value: o.value, + listeners: [{ + eventName: BI.Controller.EVENT_CHANGE, + action: function (type, val, obj) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj); + } + } + }] + }] + }; + } + return { + type: "bi.vertical", + verticalAlign: BI.VerticalAlign.Stretch, + rowSize: ["fill", ""], + items: [{ + type: "bi.select_list", + logic: { + dynamic: true, + innerVgap: 5, + rowSize: ["", "fill"], + verticalAlign: BI.VerticalAlign.Stretch + }, + ref: (_ref) => { + this.popup = _ref; + }, + el: { + el: { + chooseType: o.chooseType + } + }, + items: this._formatItems(o.items), + value: { + type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + value: o.value + }, + listeners: [{ + eventName: BI.SelectList.EVENT_CHANGE, + action: function (val) { + self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val); + } + }] + }, { + type: "bi.center", + cls: "list-view-toolbar bi-high-light bi-split-top", + height: 24, + items: BI.createItems([{ + type: "bi.text_button", + text: BI.i18nText("BI-Basic_Clears"), + handler: function () { + self.fireEvent(BI.TextValueComboPopup.EVENT_CLEAR); + } + }, { + type: "bi.text_button", + text: BI.i18nText("BI-Basic_OK"), + handler: function () { + self.fireEvent(BI.TextValueComboPopup.EVENT_CONFIRM); + } + }], { + once: false, + shadow: true, + isShadowShowingOnSelected: true + }) + }] + }; + }, - this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj); - } - }); + mounted: function () { this.check(); - - BI.createWidget({ - type: "bi.vertical", - element: this, - vgap: 5, - items: [this.popup] - }); }, _formatItems: function (items) { var o = this.options; return BI.map(items, function (i, item) { return BI.extend({ - type: "bi.single_select_item", + type: o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE ? "bi.single_select_item" : "bi.multi_select_item", + iconWrapperWidth: 36, textAlign: o.textAlign, title: item.title || item.text }, item); @@ -52,13 +113,29 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, { }, getValue: function () { - return this.popup.getValue(); + if (this.options.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) { + return this.popup.getValue(); + } + var val = this.popup.getValue(); + if (val.type === BI.ButtonGroup.CHOOSE_TYPE_MULTI) { + return val.value; + } else { + return val.assist; + } }, setValue: function (v) { - this.popup.setValue(v); + if (this.options.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) { + return this.popup.setValue(v); + } + this.popup.setValue({ + type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + value: v + }); } }); BI.TextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.TextValueComboPopup.EVENT_CLEAR = "EVENT_CLEAR"; +BI.TextValueComboPopup.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.shortcut("bi.text_value_combo_popup", BI.TextValueComboPopup); diff --git a/src/case/pager/pager.js b/src/case/pager/pager.detail.js similarity index 99% rename from src/case/pager/pager.js rename to src/case/pager/pager.detail.js index 0f6bac9b5..36e8392f6 100644 --- a/src/case/pager/pager.js +++ b/src/case/pager/pager.detail.js @@ -223,6 +223,7 @@ BI.DetailPager = BI.inherit(BI.Widget, { setAllPages: function (pages) { this.options.pages = pages; + this._populate(); }, hasPrev: function (v) { diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index 3be2d7757..005ac241b 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/src/case/trigger/trigger.text.select.js @@ -20,15 +20,14 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { _init: function () { BI.SelectTextTrigger.superclass._init.apply(this, arguments); var self = this, o = this.options; - var obj = this._digest(o.value, o.items); + var text = this._digest(o.value, o.items); this.trigger = BI.createWidget({ type: "bi.text_trigger", element: this, height: o.height, readonly: o.readonly, - text: obj.text, + text: text, defaultText: o.defaultText, - textCls: obj.textCls, textHgap: o.textHgap, textVgap: o.textVgap, textLgap: o.textLgap, @@ -52,40 +51,31 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { _digest: function (val, items) { var o = this.options; - val = BI.isArray(val) ? val[0] : val; + + val = BI.isArray(val) ? val.slice() : [val]; + + var result = []; // 提升valueFormatter的优先级 if (o.valueFormatter !== BI.emptyFn && BI.isFunction(o.valueFormatter)) { - return { - text: o.valueFormatter(val), - }; + BI.each(val, function (index, v) { + result.push(o.valueFormatter(v)); + }); + return result.join(","); } - var result = []; - var formatItems = BI.Tree.transformToArrayFormat(items); BI.each(formatItems, function (i, item) { - if (val === item.value && !BI.contains(result, item.text || item.value)) { + if (BI.contains(val, item.value) && !BI.contains(result, item.text || item.value)) { result.push(item.text || item.value); + BI.remove(val, item.value); } }); - if (result.length > 0) { - return { - textCls: "", - text: result.join(","), - }; + if (result.length > 0 && val.length === 0) { + return result.join(","); } else { - var text = BI.isFunction(o.text) ? o.text() : o.text; - if (BI.isEmptyString(text)) { - return { - textCls: "bi-tips", - text: "" - }; - } - return { - text: o.text - }; + return BI.isFunction(o.text) ? o.text() : o.text; } }, @@ -95,9 +85,8 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { }, setValue: function (val) { - var formatValue = this._digest(val, this.options.items); - this.trigger.setTextCls(formatValue.textCls); - this.trigger.setText(formatValue.text); + var formatText = this._digest(val, this.options.items); + this.trigger.setText(formatText); }, setTipType: function (v) { diff --git a/src/component/treevaluechooser/abstract.treevaluechooser.js b/src/component/treevaluechooser/abstract.treevaluechooser.js index dc9fe21ae..f1a7665d5 100644 --- a/src/component/treevaluechooser/abstract.treevaluechooser.js +++ b/src/component/treevaluechooser/abstract.treevaluechooser.js @@ -532,70 +532,81 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { var checkState = op.checkState || {}; var parentValues = op.parentValues || []; var selectedValues = op.selectedValues || {}; - var valueMap = {}; - // if (judgeState(parentValues, selectedValues, checkState)) { - valueMap = dealWithSelectedValue(parentValues, selectedValues); - // } - var nodes = this._getChildren(parentValues); - for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { - var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState); - result.push({ - id: nodes[i].id, - pId: nodes[i].pId, - value: nodes[i].value, - text: nodes[i].text, - times: 1, - isParent: nodes[i].getChildrenLength() > 0, - checked: state[0], - halfCheck: state[1], - open: o.open, - disabled: nodes[i].disabled, - title: nodes[i].title || nodes[i].text, - warningTitle: nodes[i].warningTitle, - }); - } - // 如果指定节点全部打开 - if (o.open) { - var allNodes = []; - // 获取所有节点 - BI.each(nodes, function (idx, node) { - allNodes = BI.concat(allNodes, self._getAllChildren(parentValues.concat([node.value]))); - }); - var lastFind; - BI.each(allNodes, function (idx, node) { - var valueMap = dealWithSelectedValue(node.parentValues, selectedValues); - // REPORT-24409 fix: 设置节点全部展开,添加的节点没有给状态 - var parentCheckState = {}; - var find = BI.find(result, function (idx, pNode) { - return pNode.id === node.pId; - }); - if (find) { - parentCheckState.checked = find.halfCheck ? false : find.checked; - parentCheckState.half = find.halfCheck; - // 默认展开也需要重置父节点的halfCheck - if (BI.isNotNull(lastFind) && (lastFind !== find || allNodes.length - 1 === idx)) { - lastFind.half = lastFind.halfCheck; - lastFind.halfCheck = false; - } - } - lastFind = find; - var state = getCheckState(node.value, node.parentValues, valueMap, parentCheckState); + function getResult(parentValues, checkState) { + var valueMap = {}; + // if (judgeState(parentValues, selectedValues, checkState)) { + valueMap = dealWithSelectedValue(parentValues, selectedValues); + // } + var nodes = self._getChildren(parentValues); + for (var i = (times - 1) * self._const.perPage; nodes[i] && i < times * self._const.perPage; i++) { + var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState); + var openState = o.open || nodes[i].open; result.push({ - id: node.id, - pId: node.pId, - value: node.value, - text: node.text, + id: nodes[i].id, + pId: nodes[i].pId, + value: nodes[i].value, + text: nodes[i].text, times: 1, - isParent: node.getChildrenLength() > 0, + isParent: nodes[i].isParent || nodes[i].getChildrenLength() > 0, checked: state[0], - halfCheck: state[1], - open: self.options.open, - disabled: node.disabled, - title: node.title || node.text, - warningTitle: node.warningTitle, + half: state[1], + halfCheck: openState ? false : state[1], + open: openState, + disabled: nodes[i].disabled, + title: nodes[i].title || nodes[i].text, + warningTitle: nodes[i].warningTitle, }); - }); + if (openState) { + getResult(parentValues.concat([nodes[i].value]), {checked: state[0], half: state[1]}); + } + } } + + getResult(parentValues, checkState); + + // 如果指定节点全部打开 + // if (o.open) { + // var allNodes = []; + // // 获取所有节点 + // BI.each(nodes, function (idx, node) { + // allNodes = BI.concat(allNodes, self._getAllChildren(parentValues.concat([node.value]))); + // }); + // var lastFind; + // BI.each(allNodes, function (idx, node) { + // var valueMap = dealWithSelectedValue(node.parentValues, selectedValues); + // // REPORT-24409 fix: 设置节点全部展开,添加的节点没有给状态 + // var parentCheckState = {}; + // var find = BI.find(result, function (idx, pNode) { + // return pNode.id === node.pId; + // }); + // if (find) { + // parentCheckState.checked = find.halfCheck ? false : find.checked; + // parentCheckState.half = find.halfCheck; + // // 默认展开也需要重置父节点的halfCheck + // if (BI.isNotNull(lastFind) && (lastFind !== find || allNodes.length - 1 === idx)) { + // lastFind.half = lastFind.halfCheck; + // lastFind.halfCheck = false; + // } + // } + // lastFind = find; + // var state = getCheckState(node.value, node.parentValues, valueMap, parentCheckState); + // result.push({ + // id: node.id, + // pId: node.pId, + // value: node.value, + // text: node.text, + // times: 1, + // isParent: node.getChildrenLength() > 0, + // checked: state[0], + // halfCheck: state[1], + // open: true, + // disabled: node.disabled, + // title: node.title || node.text, + // warningTitle: node.warningTitle, + // }); + // }); + // } + // 深层嵌套的比较麻烦,这边先实现的是在根节点添加 if (parentValues.length === 0 && times === 1) { result = BI.concat(self._getAddedValueNode(parentValues, selectedValues), result); @@ -603,17 +614,17 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { BI.nextTick(function () { callback({ items: result, - hasNext: nodes.length > times * self._const.perPage + hasNext: self._getChildren(parentValues).length > times * self._const.perPage }); }); - function judgeState(parentValues, selected_value, checkState) { - var checked = checkState.checked, half = checkState.half; - if (parentValues.length > 0 && !checked) { - return false; - } - return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value)); - } + // function judgeState(parentValues, selected_value, checkState) { + // var checked = checkState.checked, half = checkState.half; + // if (parentValues.length > 0 && !checked) { + // return false; + // } + // return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value)); + // } function dealWithSelectedValue(parentValues, selectedValues) { var valueMap = {}, parents = (parentValues || []).slice(0); @@ -840,6 +851,40 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { return this._getChildren(parentValues).length; }, + assertSelectedValue: function (selectedValues, items = []) { + if (BI.isPlainObject(selectedValues)) { + return selectedValues; + } + + var tree = BI.Tree.transformToTreeFormat(items); + var value2ParentMap = {}; + BI.Tree.traversal(tree, function (index, node, pNode) { + value2ParentMap[node.value] = pNode; + }); + + var result = {}; + BI.each(selectedValues, function (index, value) { + var curr = value; + var parentPath = []; + while (curr) { + parentPath.unshift(curr); + curr = value2ParentMap[curr]?.value; + } + BI.each(parentPath, function (index) { + if (BI.isNull(BI.get(result, parentPath.slice(0, index + 1)))) { + BI.set(result, parentPath.slice(0, index + 1), {}); + } + }); + // 执行完一条路径,check一下 + var lengths = BI.size(BI.get(result, parentPath.slice(0, -1))); + if (lengths === value2ParentMap[value]?.children?.length) { + BI.set(result, parentPath.slice(0, -1), {}); + } + }); + + return result; + }, + buildCompleteTree: function (selectedValues) { var self = this; var result = {}; diff --git a/src/component/treevaluechooser/combo.treevaluechooser.js b/src/component/treevaluechooser/combo.treevaluechooser.js index 33cb4e520..7b42f3d74 100644 --- a/src/component/treevaluechooser/combo.treevaluechooser.js +++ b/src/component/treevaluechooser/combo.treevaluechooser.js @@ -30,7 +30,7 @@ BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, { text: o.text, defaultText: o.defaultText, allowEdit: o.allowEdit, - value: o.value, + value: this.assertSelectedValue(o.value, o.items), watermark: o.watermark, element: this, itemsCreator: BI.bind(this._itemsCreator, this), diff --git a/src/component/treevaluechooser/pane.treevaluechooser.js b/src/component/treevaluechooser/pane.treevaluechooser.js index e6fc4f07a..8171c04d8 100644 --- a/src/component/treevaluechooser/pane.treevaluechooser.js +++ b/src/component/treevaluechooser/pane.treevaluechooser.js @@ -29,6 +29,10 @@ BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, { this.pane.on(BI.MultiSelectTree.EVENT_CHANGE, function () { self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE); }); + if (BI.isNotNull(o.value)) { + var selectedValues = this.assertSelectedValue(o.value, o.items); + this.pane.setSelectedValue(selectedValues); + } if (BI.isNotNull(o.items)) { this._initData(o.items); this.pane.populate(); diff --git a/src/core/1.lodash.js b/src/core/1.lodash.js index 934448ac6..1fdf1bbc4 100644 --- a/src/core/1.lodash.js +++ b/src/core/1.lodash.js @@ -1,13 +1,13 @@ /** * @license * Lodash (Custom Build) - * Build: `lodash core plus="debounce,throttle,get,set,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy,before,after,unescape,chunk"` + * Build: `lodash core plus="debounce,throttle,get,set,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy,before,after,unescape,chunk,pick,pickBy,identity"` * Copyright JS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ -;(function () { +;(function() { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -191,7 +191,7 @@ var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ - var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); /** Used to identify `toStringTag` values of typed arrays. */ var typedArrayTags = {}; @@ -269,11 +269,10 @@ var freeProcess = moduleExports && freeGlobal.process; /** Used to access faster Node.js helpers. */ - var nodeUtil = (function () { + var nodeUtil = (function() { try { return freeProcess && freeProcess.binding && freeProcess.binding('util'); - } catch (e) { - } + } catch (e) {} }()); /* Node.js helper references. */ @@ -297,14 +296,10 @@ */ function apply(func, thisArg, args) { switch (args.length) { - case 0: - return func.call(thisArg); - case 1: - return func.call(thisArg, args[0]); - case 2: - return func.call(thisArg, args[0], args[1]); - case 3: - return func.call(thisArg, args[0], args[1], args[2]); + case 0: return func.call(thisArg); + case 1: return func.call(thisArg, args[0]); + case 2: return func.call(thisArg, args[0], args[1]); + case 3: return func.call(thisArg, args[0], args[1], args[2]); } return func.apply(thisArg, args); } @@ -551,7 +546,7 @@ */ function baseFindKey(collection, predicate, eachFunc) { var result; - eachFunc(collection, function (value, key, collection) { + eachFunc(collection, function(value, key, collection) { if (predicate(value, key, collection)) { result = key; return false; @@ -617,7 +612,7 @@ * @returns {Function} Returns the new accessor function. */ function baseProperty(key) { - return function (object) { + return function(object) { return object == null ? undefined : object[key]; }; } @@ -630,7 +625,7 @@ * @returns {Function} Returns the new accessor function. */ function basePropertyOf(object) { - return function (key) { + return function(key) { return object == null ? undefined : object[key]; }; } @@ -649,7 +644,7 @@ * @returns {*} Returns the accumulated value. */ function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { - eachFunc(collection, function (value, index, collection) { + eachFunc(collection, function(value, index, collection) { accumulator = initAccum ? (initAccum = false, value) : iteratee(accumulator, value, index, collection); @@ -704,7 +699,7 @@ * @returns {Function} Returns the new capped function. */ function baseUnary(func) { - return function (value) { + return function(value) { return func(value); }; } @@ -720,7 +715,7 @@ * @returns {Object} Returns the array of property values. */ function baseValues(object, props) { - return arrayMap(props, function (key) { + return arrayMap(props, function(key) { return object[key]; }); } @@ -750,8 +745,7 @@ var index = -1, length = strSymbols.length; - while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) { - } + while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} return index; } @@ -767,8 +761,7 @@ function charsEndIndex(strSymbols, chrSymbols) { var index = strSymbols.length; - while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) { - } + while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} return index; } @@ -852,7 +845,7 @@ var index = -1, result = Array(map.size); - map.forEach(function (value, key) { + map.forEach(function(value, key) { result[++index] = [key, value]; }); return result; @@ -867,7 +860,7 @@ * @returns {Function} Returns the new function. */ function overArg(func, transform) { - return function (arg) { + return function(arg) { return func(transform(arg)); }; } @@ -922,7 +915,7 @@ var index = -1, result = Array(set.size); - set.forEach(function (value) { + set.forEach(function(value) { result[++index] = value; }); return result; @@ -1031,7 +1024,7 @@ var idCounter = 0; /** Used to detect methods masquerading as native. */ - var maskSrcKey = (function () { + var maskSrcKey = (function() { var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); return uid ? ('Symbol(src)_1.' + uid) : ''; }()); @@ -1068,13 +1061,12 @@ symIterator = Symbol ? Symbol.iterator : undefined, symToStringTag = Symbol ? Symbol.toStringTag : undefined; - var defineProperty = (function () { + var defineProperty = (function() { try { var func = getNative(Object, 'defineProperty'); func({}, '', {}); return func; - } catch (e) { - } + } catch (e) {} }()); /* Built-in method references for those with the same name as other `lodash` methods. */ @@ -1255,11 +1247,9 @@ * @param {Object} proto The object to inherit from. * @returns {Object} Returns the new object. */ - var baseCreate = (function () { - function object() { - } - - return function (proto) { + var baseCreate = (function() { + function object() {} + return function(proto) { if (!isObject(proto)) { return {}; } @@ -2002,7 +1992,7 @@ * @returns {Function} Returns `accumulator`. */ function baseAggregator(collection, setter, iteratee, accumulator) { - baseEach(collection, function (value, key, collection) { + baseEach(collection, function(value, key, collection) { setter(accumulator, value, iteratee(value), collection); }); return accumulator; @@ -2164,7 +2154,7 @@ stack.set(value, result); if (isSet(value)) { - value.forEach(function (subValue) { + value.forEach(function(subValue) { result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); }); @@ -2172,7 +2162,7 @@ } if (isMap(value)) { - value.forEach(function (subValue, key) { + value.forEach(function(subValue, key) { result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); }); @@ -2184,7 +2174,7 @@ : (isFlat ? keysIn : keys); var props = isArr ? undefined : keysFunc(value); - arrayEach(props || value, function (subValue, key) { + arrayEach(props || value, function(subValue, key) { if (props) { key = subValue; subValue = value[key]; @@ -2209,9 +2199,7 @@ if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } - return setTimeout(function () { - func.apply(undefined, args); - }, wait); + return setTimeout(function() { func.apply(undefined, args); }, wait); } /** @@ -2242,7 +2230,8 @@ if (comparator) { includes = arrayIncludesWith; isCommon = false; - } else if (values.length >= LARGE_ARRAY_SIZE) { + } + else if (values.length >= LARGE_ARRAY_SIZE) { includes = cacheHas; isCommon = false; values = new SetCache(values); @@ -2261,7 +2250,8 @@ } } result.push(value); - } else if (!includes(values, computed, comparator)) { + } + else if (!includes(values, computed, comparator)) { result.push(value); } } @@ -2289,7 +2279,7 @@ */ function baseEvery(collection, predicate) { var result = true; - baseEach(collection, function (value, index, collection) { + baseEach(collection, function(value, index, collection) { result = !!predicate(value, index, collection); return result; }); @@ -2335,7 +2325,7 @@ */ function baseFilter(collection, predicate) { var result = []; - baseEach(collection, function (value, index, collection) { + baseEach(collection, function(value, index, collection) { if (predicate(value, index, collection)) { result.push(value); } @@ -2436,7 +2426,7 @@ * @returns {Array} Returns the function names. */ function baseFunctions(object, props) { - return arrayFilter(props, function (key) { + return arrayFilter(props, function(key) { return isFunction(object[key]); }); } @@ -2605,7 +2595,7 @@ * @returns {Function} Returns `accumulator`. */ function baseInverter(object, setter, iteratee, accumulator) { - baseForOwn(object, function (value, key, object) { + baseForOwn(object, function(value, key, object) { setter(accumulator, iteratee(value), key, object); }); return accumulator; @@ -2939,7 +2929,7 @@ var index = -1, result = isArrayLike(collection) ? Array(collection.length) : []; - baseEach(collection, function (value, key, collection) { + baseEach(collection, function(value, key, collection) { result[++index] = iteratee(value, key, collection); }); return result; @@ -2957,7 +2947,7 @@ if (matchData.length == 1 && matchData[0][2]) { return matchesStrictComparable(matchData[0][0], matchData[0][1]); } - return function (object) { + return function(object) { return object === source || baseIsMatch(object, source, matchData); }; } @@ -2974,7 +2964,7 @@ if (isKey(path) && isStrictComparable(srcValue)) { return matchesStrictComparable(toKey(path), srcValue); } - return function (object) { + return function(object) { var objValue = get(object, path); return (objValue === undefined && objValue === srcValue) ? hasIn(object, path) @@ -2997,11 +2987,12 @@ if (object === source) { return; } - baseFor(source, function (srcValue, key) { + baseFor(source, function(srcValue, key) { if (isObject(srcValue)) { stack || (stack = new Stack); baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); - } else { + } + else { var newValue = customizer ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) : undefined; @@ -3053,25 +3044,32 @@ if (isArr || isBuff || isTyped) { if (isArray(objValue)) { newValue = objValue; - } else if (isArrayLikeObject(objValue)) { + } + else if (isArrayLikeObject(objValue)) { newValue = copyArray(objValue); - } else if (isBuff) { + } + else if (isBuff) { isCommon = false; newValue = cloneBuffer(srcValue, true); - } else if (isTyped) { + } + else if (isTyped) { isCommon = false; newValue = cloneTypedArray(srcValue, true); - } else { + } + else { newValue = []; } - } else if (isPlainObject(srcValue) || isArguments(srcValue)) { + } + else if (isPlainObject(srcValue) || isArguments(srcValue)) { newValue = objValue; if (isArguments(objValue)) { newValue = toPlainObject(objValue); - } else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { + } + else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { newValue = initCloneObject(srcValue); } - } else { + } + else { isCommon = false; } } @@ -3097,14 +3095,14 @@ var index = -1; iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee)); - var result = baseMap(collection, function (value, key, collection) { - var criteria = arrayMap(iteratees, function (iteratee) { + var result = baseMap(collection, function(value, key, collection) { + var criteria = arrayMap(iteratees, function(iteratee) { return iteratee(value); }); return { 'criteria': criteria, 'index': ++index, 'value': value }; }); - return baseSortBy(result, function (object, other) { + return baseSortBy(result, function(object, other) { return compareMultiple(object, other, orders); }); } @@ -3119,7 +3117,7 @@ * @returns {Object} Returns the new object. */ function basePick(object, paths) { - return basePickBy(object, paths, function (value, path) { + return basePickBy(object, paths, function(value, path) { return hasIn(object, path); }); } @@ -3157,7 +3155,7 @@ * @returns {Function} Returns the new accessor function. */ function basePropertyDeep(path) { - return function (object) { + return function(object) { return baseGet(object, path); }; } @@ -3258,7 +3256,7 @@ * @param {*} data The metadata. * @returns {Function} Returns `func`. */ - var baseSetData = !metaMap ? identity : function (func, data) { + var baseSetData = !metaMap ? identity : function(func, data) { metaMap.set(func, data); return func; }; @@ -3271,7 +3269,7 @@ * @param {Function} string The `toString` result. * @returns {Function} Returns `func`. */ - var baseSetToString = !defineProperty ? identity : function (func, string) { + var baseSetToString = !defineProperty ? identity : function(func, string) { return defineProperty(func, 'toString', { 'configurable': true, 'enumerable': false, @@ -3322,7 +3320,7 @@ function baseSome(collection, predicate) { var result; - baseEach(collection, function (value, index, collection) { + baseEach(collection, function(value, index, collection) { result = predicate(value, index, collection); return !result; }); @@ -3373,7 +3371,8 @@ if (comparator) { isCommon = false; includes = arrayIncludesWith; - } else if (length >= LARGE_ARRAY_SIZE) { + } + else if (length >= LARGE_ARRAY_SIZE) { var set = iteratee ? null : createSet(array); if (set) { return setToArray(set); @@ -3381,7 +3380,8 @@ isCommon = false; includes = cacheHas; seen = new SetCache; - } else { + } + else { seen = iteratee ? [] : result; } outer: @@ -3401,7 +3401,8 @@ seen.push(computed); } result.push(value); - } else if (!includes(seen, computed, comparator)) { + } + else if (!includes(seen, computed, comparator)) { if (seen !== result) { seen.push(computed); } @@ -3440,7 +3441,7 @@ if (result instanceof LazyWrapper) { result = result.value(); } - return arrayReduce(actions, function (result, action) { + return arrayReduce(actions, function(result, action) { return action.func.apply(action.thisArg, arrayPush([result], action.args)); }, result); } @@ -3829,7 +3830,7 @@ * @returns {Function} Returns the new aggregator function. */ function createAggregator(setter, initializer) { - return function (collection, iteratee) { + return function(collection, iteratee) { var func = isArray(collection) ? arrayAggregator : baseAggregator, accumulator = initializer ? initializer() : {}; @@ -3845,7 +3846,7 @@ * @returns {Function} Returns the new assigner function. */ function createAssigner(assigner) { - return baseRest(function (object, sources) { + return baseRest(function(object, sources) { var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : undefined, @@ -3879,7 +3880,7 @@ * @returns {Function} Returns the new base function. */ function createBaseEach(eachFunc, fromRight) { - return function (collection, iteratee) { + return function(collection, iteratee) { if (collection == null) { return collection; } @@ -3907,7 +3908,7 @@ * @returns {Function} Returns the new base function. */ function createBaseFor(fromRight) { - return function (object, iteratee, keysFunc) { + return function(object, iteratee, keysFunc) { var index = -1, iterable = Object(object), props = keysFunc(object), @@ -3941,7 +3942,6 @@ var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; return fn.apply(isBind ? thisArg : this, arguments); } - return wrapper; } @@ -3954,28 +3954,20 @@ * @returns {Function} Returns the new wrapped function. */ function createCtor(Ctor) { - return function () { + return function() { // Use a `switch` statement to work with class constructors. See // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist // for more details. var args = arguments; switch (args.length) { - case 0: - return new Ctor; - case 1: - return new Ctor(args[0]); - case 2: - return new Ctor(args[0], args[1]); - case 3: - return new Ctor(args[0], args[1], args[2]); - case 4: - return new Ctor(args[0], args[1], args[2], args[3]); - case 5: - return new Ctor(args[0], args[1], args[2], args[3], args[4]); - case 6: - return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); - case 7: - return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + case 0: return new Ctor; + case 1: return new Ctor(args[0]); + case 2: return new Ctor(args[0], args[1]); + case 3: return new Ctor(args[0], args[1], args[2]); + case 4: return new Ctor(args[0], args[1], args[2], args[3]); + case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); + case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); + case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); } var thisBinding = baseCreate(Ctor.prototype), result = Ctor.apply(thisBinding, args); @@ -4020,7 +4012,6 @@ var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; return apply(fn, this, args); } - return wrapper; } @@ -4032,14 +4023,12 @@ * @returns {Function} Returns the new find function. */ function createFind(findIndexFunc) { - return function (collection, predicate, fromIndex) { + return function(collection, predicate, fromIndex) { var iterable = Object(collection); if (!isArrayLike(collection)) { var iteratee = baseIteratee(predicate, 3); collection = keys(collection); - predicate = function (key) { - return iteratee(iterable[key], key, iterable); - }; + predicate = function(key) { return iteratee(iterable[key], key, iterable); }; } var index = findIndexFunc(collection, predicate, fromIndex); return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; @@ -4116,7 +4105,6 @@ } return fn.apply(thisBinding, args); } - return wrapper; } @@ -4129,7 +4117,7 @@ * @returns {Function} Returns the new inverter function. */ function createInverter(setter, toIteratee) { - return function (object, iteratee) { + return function(object, iteratee) { return baseInverter(object, setter, toIteratee(iteratee), {}); }; } @@ -4166,7 +4154,6 @@ } return apply(fn, isBind ? thisArg : this, args); } - return wrapper; } @@ -4178,7 +4165,7 @@ * @returns {Function} Returns the new range function. */ function createRange(fromRight) { - return function (start, end, step) { + return function(start, end, step) { if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { end = step = undefined; } @@ -4245,7 +4232,7 @@ * @param {Array} values The values to add to the set. * @returns {Object} Returns the new set. */ - var createSet = !(Set && (1 / setToArray(new Set([, -0]))[1]) == INFINITY) ? noop : function (values) { + var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { return new Set(values); }; @@ -4418,7 +4405,7 @@ } // Recursively compare arrays (susceptible to call stack limits). if (seen) { - if (!arraySome(other, function (othValue, othIndex) { + if (!arraySome(other, function(othValue, othIndex) { if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { return seen.push(othIndex); @@ -4640,7 +4627,7 @@ * @param {Function} func The function to query. * @returns {*} Returns the metadata for `func`. */ - var getData = !metaMap ? noop : function (func) { + var getData = !metaMap ? noop : function(func) { return metaMap.get(func); }; @@ -4740,8 +4727,7 @@ try { value[symToStringTag] = undefined; var unmasked = true; - } catch (e) { - } + } catch (e) {} var result = nativeObjectToString.call(value); if (unmasked) { @@ -4761,12 +4747,12 @@ * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ - var getSymbols = !nativeGetSymbols ? stubArray : function (object) { + var getSymbols = !nativeGetSymbols ? stubArray : function(object) { if (object == null) { return []; } object = Object(object); - return arrayFilter(nativeGetSymbols(object), function (symbol) { + return arrayFilter(nativeGetSymbols(object), function(symbol) { return propertyIsEnumerable.call(object, symbol); }); }; @@ -4778,7 +4764,7 @@ * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ - var getSymbolsIn = !nativeGetSymbols ? stubArray : function (object) { + var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { var result = []; while (object) { arrayPush(result, getSymbols(object)); @@ -4802,23 +4788,18 @@ (Promise && getTag(Promise.resolve()) != promiseTag) || (Set && getTag(new Set) != setTag) || (WeakMap && getTag(new WeakMap) != weakMapTag)) { - getTag = function (value) { + getTag = function(value) { var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : undefined, ctorString = Ctor ? toSource(Ctor) : ''; if (ctorString) { switch (ctorString) { - case dataViewCtorString: - return dataViewTag; - case mapCtorString: - return mapTag; - case promiseCtorString: - return promiseTag; - case setCtorString: - return setTag; - case weakMapCtorString: - return weakMapTag; + case dataViewCtorString: return dataViewTag; + case mapCtorString: return mapTag; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag; + case weakMapCtorString: return weakMapTag; } } return result; @@ -4844,18 +4825,10 @@ size = data.size; switch (data.type) { - case 'drop': - start += size; - break; - case 'dropRight': - end -= size; - break; - case 'take': - end = nativeMin(end, start + size); - break; - case 'takeRight': - start = nativeMax(start, end - size); - break; + case 'drop': start += size; break; + case 'dropRight': end -= size; break; + case 'take': end = nativeMin(end, start + size); break; + case 'takeRight': start = nativeMax(start, end - size); break; } } return { 'start': start, 'end': end }; @@ -4961,15 +4934,9 @@ case dataViewTag: return cloneDataView(object, isDeep); - case float32Tag: - case float64Tag: - case int8Tag: - case int16Tag: - case int32Tag: - case uint8Tag: - case uint8ClampedTag: - case uint16Tag: - case uint32Tag: + case float32Tag: case float64Tag: + case int8Tag: case int16Tag: case int32Tag: + case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: return cloneTypedArray(object, isDeep); case mapTag: @@ -5167,7 +5134,7 @@ * @returns {Function} Returns the new spec function. */ function matchesStrictComparable(key, srcValue) { - return function (object) { + return function(object) { if (object == null) { return false; } @@ -5185,7 +5152,7 @@ * @returns {Function} Returns the new memoized function. */ function memoizeCapped(func) { - var result = memoize(func, function (key) { + var result = memoize(func, function(key) { if (cache.size === MAX_MEMOIZE_SIZE) { cache.clear(); } @@ -5308,7 +5275,7 @@ */ function overRest(func, start, transform) { start = nativeMax(start === undefined ? (func.length - 1) : start, 0); - return function () { + return function() { var args = arguments, index = -1, length = nativeMax(args.length - start, 0), @@ -5415,7 +5382,7 @@ var count = 0, lastCalled = 0; - return function () { + return function() { var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled); @@ -5438,12 +5405,12 @@ * @param {string} string The string to convert. * @returns {Array} Returns the property path array. */ - var stringToPath = memoizeCapped(function (string) { + var stringToPath = memoizeCapped(function(string) { var result = []; if (string.charCodeAt(0) === 46 /* . */) { result.push(''); } - string.replace(rePropName, function (match, number, quote, subString) { + string.replace(rePropName, function(match, number, quote, subString) { result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); }); return result; @@ -5475,12 +5442,10 @@ if (func != null) { try { return funcToString.call(func); - } catch (e) { - } + } catch (e) {} try { return (func + ''); - } catch (e) { - } + } catch (e) {} } return ''; } @@ -5494,7 +5459,7 @@ * @returns {Array} Returns `details`. */ function updateWrapDetails(details, bitmask) { - arrayEach(wrapFlags, function (pair) { + arrayEach(wrapFlags, function(pair) { var value = '_.' + pair[0]; if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { details.push(value); @@ -5516,7 +5481,7 @@ } var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); result.__actions__ = copyArray(wrapper.__actions__); - result.__index__ = wrapper.__index__; + result.__index__ = wrapper.__index__; result.__values__ = wrapper.__values__; return result; } @@ -5652,7 +5617,7 @@ * _.difference([2, 1], [2, 3]); * // => [1] */ - var difference = baseRest(function (array, values) { + var difference = baseRest(function(array, values) { return isArrayLikeObject(array) ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) : []; @@ -5920,7 +5885,7 @@ * _.intersection([2, 1], [2, 3]); * // => [2] */ - var intersection = baseRest(function (arrays) { + var intersection = baseRest(function(arrays) { var mapped = arrayMap(arrays, castArrayLikeObject); return (mapped.length && mapped[0] === arrays[0]) ? baseIntersection(mapped) @@ -5997,7 +5962,8 @@ if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { start = 0; end = length; - } else { + } + else { start = start == null ? 0 : toInteger(start); end = end === undefined ? length : toInteger(end); } @@ -6088,7 +6054,7 @@ * _.union([2], [1, 2]); * // => [2, 1] */ - var union = baseRest(function (arrays) { + var union = baseRest(function(arrays) { return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); }); @@ -6165,13 +6131,13 @@ return []; } var length = 0; - array = arrayFilter(array, function (group) { + array = arrayFilter(array, function(group) { if (isArrayLikeObject(group)) { length = nativeMax(group.length, length); return true; } }); - return baseTimes(length, function (index) { + return baseTimes(length, function(index) { return arrayMap(array, baseProperty(index)); }); } @@ -6196,7 +6162,7 @@ * _.without([2, 1, 2, 3], 1, 2); * // => [3] */ - var without = baseRest(function (array, values) { + var without = baseRest(function(array, values) { return isArrayLikeObject(array) ? baseDifference(array, values) : []; @@ -6348,13 +6314,11 @@ * _(object).at(['a[0].b.c', 'a[1]']).value(); * // => [3, 4] */ - var wrapperAt = flatRest(function (paths) { + var wrapperAt = flatRest(function(paths) { var length = paths.length, start = length ? paths[0] : 0, value = this.__wrapped__, - interceptor = function (object) { - return baseAt(object, paths); - }; + interceptor = function(object) { return baseAt(object, paths); }; if (length > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex(start)) { @@ -6366,7 +6330,7 @@ 'args': [interceptor], 'thisArg': undefined }); - return new LodashWrapper(value, this.__chain__).thru(function (array) { + return new LodashWrapper(value, this.__chain__).thru(function(array) { if (length && !array.length) { array.push(undefined); } @@ -6613,7 +6577,7 @@ * _.countBy(['one', 'two', 'three'], 'length'); * // => { '3': 2, '5': 1 } */ - var countBy = createAggregator(function (result, value, key) { + var countBy = createAggregator(function(result, value, key) { if (hasOwnProperty.call(result, key)) { ++result[key]; } else { @@ -6808,7 +6772,7 @@ * _.groupBy(['one', 'two', 'three'], 'length'); * // => { '3': ['one', 'two'], '5': ['three'] } */ - var groupBy = createAggregator(function (result, value, key) { + var groupBy = createAggregator(function(result, value, key) { if (hasOwnProperty.call(result, key)) { result[key].push(value); } else { @@ -7054,7 +7018,7 @@ * _.sortBy(users, ['user', 'age']); * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] */ - var sortBy = baseRest(function (collection, iteratees) { + var sortBy = baseRest(function(collection, iteratees) { if (collection == null) { return []; } @@ -7085,7 +7049,7 @@ * }, _.now()); * // => Logs the number of milliseconds it took for the deferred invocation. */ - var now = function () { + var now = function() { return root.Date.now(); }; @@ -7120,7 +7084,7 @@ throw new TypeError(FUNC_ERROR_TEXT); } n = toInteger(n); - return function () { + return function() { if (--n < 1) { return func.apply(this, arguments); } @@ -7150,7 +7114,7 @@ throw new TypeError(FUNC_ERROR_TEXT); } n = toInteger(n); - return function () { + return function() { if (--n > 0) { result = func.apply(this, arguments); } @@ -7196,7 +7160,7 @@ * bound('hi'); * // => 'hi fred!' */ - var bind = baseRest(function (func, thisArg, partials) { + var bind = baseRest(function(func, thisArg, partials) { var bitmask = WRAP_BIND_FLAG; if (partials.length) { var holders = replaceHolders(partials, getHolder(bind)); @@ -7378,7 +7342,6 @@ } return result; } - debounced.cancel = cancel; debounced.flush = flush; return debounced; @@ -7402,7 +7365,7 @@ * }, 'deferred'); * // => Logs 'deferred' after one millisecond. */ - var defer = baseRest(function (func, args) { + var defer = baseRest(function(func, args) { return baseDelay(func, 1, args); }); @@ -7425,7 +7388,7 @@ * }, 1000, 'later'); * // => Logs 'later' after one second. */ - var delay = baseRest(function (func, wait, args) { + var delay = baseRest(function(func, wait, args) { return baseDelay(func, toNumber(wait) || 0, args); }); @@ -7477,7 +7440,7 @@ if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { throw new TypeError(FUNC_ERROR_TEXT); } - var memoized = function () { + var memoized = function() { var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache; @@ -7520,17 +7483,13 @@ if (typeof predicate != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } - return function () { + return function() { var args = arguments; switch (args.length) { - case 0: - return !predicate.call(this); - case 1: - return !predicate.call(this, args[0]); - case 2: - return !predicate.call(this, args[0], args[1]); - case 3: - return !predicate.call(this, args[0], args[1], args[2]); + case 0: return !predicate.call(this); + case 1: return !predicate.call(this, args[0]); + case 2: return !predicate.call(this, args[0], args[1]); + case 3: return !predicate.call(this, args[0], args[1], args[2]); } return !predicate.apply(this, args); }; @@ -7761,9 +7720,7 @@ * _.isArguments([1, 2, 3]); * // => false */ - var isArguments = baseIsArguments(function () { - return arguments; - }()) ? baseIsArguments : function (value) { + var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); }; @@ -8652,7 +8609,7 @@ * _.assignIn({ 'a': 0 }, new Foo, new Bar); * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } */ - var assignIn = createAssigner(function (object, source) { + var assignIn = createAssigner(function(object, source) { copyObject(source, keysIn(source), object); }); @@ -8716,7 +8673,7 @@ * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ - var defaults = baseRest(function (object, sources) { + var defaults = baseRest(function(object, sources) { object = Object(object); var index = -1; @@ -8766,7 +8723,7 @@ * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); * // => { 'a': { 'b': 2, 'c': 3 } } */ - var defaultsDeep = baseRest(function (args) { + var defaultsDeep = baseRest(function(args) { args.push(undefined, customDefaultsMerge); return apply(mergeWith, undefined, args); }); @@ -8958,7 +8915,7 @@ * _.invert(object); * // => { '1': 'c', '2': 'b' } */ - var invert = createInverter(function (result, value, key) { + var invert = createInverter(function(result, value, key) { if (value != null && typeof value.toString != 'function') { value = nativeObjectToString.call(value); @@ -8993,7 +8950,7 @@ * }); * // => { 'group1': ['a', 'c'], 'group2': ['b'] } */ - var invertBy = createInverter(function (result, value, key) { + var invertBy = createInverter(function(result, value, key) { if (value != null && typeof value.toString != 'function') { value = nativeObjectToString.call(value); @@ -9096,7 +9053,7 @@ * _.merge(object, other); * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } */ - var merge = createAssigner(function (object, source, srcIndex) { + var merge = createAssigner(function(object, source, srcIndex) { baseMerge(object, source, srcIndex); }); @@ -9131,7 +9088,7 @@ * _.mergeWith(object, other, customizer); * // => { 'a': [1, 3], 'b': [2, 4] } */ - var mergeWith = createAssigner(function (object, source, srcIndex, customizer) { + var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { baseMerge(object, source, srcIndex, customizer); }); @@ -9155,13 +9112,13 @@ * _.omit(object, ['a', 'c']); * // => { 'b': '2' } */ - var omit = flatRest(function (object, paths) { + var omit = flatRest(function(object, paths) { var result = {}; if (object == null) { return result; } var isDeep = false; - paths = arrayMap(paths, function (path) { + paths = arrayMap(paths, function(path) { path = castPath(path, object); isDeep || (isDeep = path.length > 1); return path; @@ -9218,7 +9175,7 @@ * _.pick(object, ['a', 'c']); * // => { 'a': 1, 'c': 3 } */ - var pick = flatRest(function (object, paths) { + var pick = flatRest(function(object, paths) { return object == null ? {} : basePick(object, paths); }); @@ -9244,11 +9201,11 @@ if (object == null) { return {}; } - var props = arrayMap(getAllKeysIn(object), function (prop) { + var props = arrayMap(getAllKeysIn(object), function(prop) { return [prop]; }); predicate = baseIteratee(predicate); - return basePickBy(object, props, function (value, path) { + return basePickBy(object, props, function(value, path) { return predicate(value, path[0]); }); } @@ -9442,7 +9399,8 @@ if (typeof upper == 'boolean') { floating = upper; upper = undefined; - } else if (typeof lower == 'boolean') { + } + else if (typeof lower == 'boolean') { floating = lower; lower = undefined; } @@ -9450,7 +9408,8 @@ if (lower === undefined && upper === undefined) { lower = 0; upper = 1; - } else { + } + else { lower = toFinite(lower); if (upper === undefined) { upper = lower; @@ -9594,7 +9553,7 @@ * // => true */ function constant(value) { - return function () { + return function() { return value; }; } @@ -9747,11 +9706,11 @@ var chain = !(isObject(options) && 'chain' in options) || !!options.chain, isFunc = isFunction(object); - arrayEach(methodNames, function (methodName) { + arrayEach(methodNames, function(methodName) { var func = source[methodName]; object[methodName] = func; if (isFunc) { - object.prototype[methodName] = function () { + object.prototype[methodName] = function() { var chainAll = this.__chain__; if (chain || chainAll) { var result = object(this.__wrapped__), @@ -10024,6 +9983,7 @@ lodash.omitBy = omitBy; lodash.once = once; lodash.pick = pick; + lodash.pickBy = pickBy; lodash.range = range; lodash.reject = reject; lodash.rest = rest; @@ -10105,9 +10065,9 @@ lodash.each = forEach; lodash.first = head; - mixin(lodash, (function () { + mixin(lodash, (function() { var source = {}; - baseForOwn(lodash, function (func, methodName) { + baseForOwn(lodash, function(func, methodName) { if (!hasOwnProperty.call(lodash.prototype, methodName)) { source[methodName] = func; } @@ -10127,8 +10087,8 @@ lodash.VERSION = VERSION; // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. - arrayEach(['drop', 'take'], function (methodName, index) { - LazyWrapper.prototype[methodName] = function (n) { + arrayEach(['drop', 'take'], function(methodName, index) { + LazyWrapper.prototype[methodName] = function(n) { n = n === undefined ? 1 : nativeMax(toInteger(n), 0); var result = (this.__filtered__ && !index) @@ -10146,17 +10106,17 @@ return result; }; - LazyWrapper.prototype[methodName + 'Right'] = function (n) { + LazyWrapper.prototype[methodName + 'Right'] = function(n) { return this.reverse()[methodName](n).reverse(); }; }); // Add `LazyWrapper` methods that accept an `iteratee` value. - arrayEach(['filter', 'map', 'takeWhile'], function (methodName, index) { + arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { var type = index + 1, isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; - LazyWrapper.prototype[methodName] = function (iteratee) { + LazyWrapper.prototype[methodName] = function(iteratee) { var result = this.clone(); result.__iteratees__.push({ 'iteratee': getIteratee(iteratee, 3), @@ -10168,49 +10128,49 @@ }); // Add `LazyWrapper` methods for `_.head` and `_.last`. - arrayEach(['head', 'last'], function (methodName, index) { + arrayEach(['head', 'last'], function(methodName, index) { var takeName = 'take' + (index ? 'Right' : ''); - LazyWrapper.prototype[methodName] = function () { + LazyWrapper.prototype[methodName] = function() { return this[takeName](1).value()[0]; }; }); // Add `LazyWrapper` methods for `_.initial` and `_.tail`. - arrayEach(['initial', 'tail'], function (methodName, index) { + arrayEach(['initial', 'tail'], function(methodName, index) { var dropName = 'drop' + (index ? '' : 'Right'); - LazyWrapper.prototype[methodName] = function () { + LazyWrapper.prototype[methodName] = function() { return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); }; }); - LazyWrapper.prototype.compact = function () { + LazyWrapper.prototype.compact = function() { return this.filter(identity); }; - LazyWrapper.prototype.find = function (predicate) { + LazyWrapper.prototype.find = function(predicate) { return this.filter(predicate).head(); }; - LazyWrapper.prototype.findLast = function (predicate) { + LazyWrapper.prototype.findLast = function(predicate) { return this.reverse().find(predicate); }; - LazyWrapper.prototype.invokeMap = baseRest(function (path, args) { + LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { if (typeof path == 'function') { return new LazyWrapper(this); } - return this.map(function (value) { + return this.map(function(value) { return baseInvoke(value, path, args); }); }); - LazyWrapper.prototype.reject = function (predicate) { + LazyWrapper.prototype.reject = function(predicate) { return this.filter(negate(getIteratee(predicate))); }; - LazyWrapper.prototype.slice = function (start, end) { + LazyWrapper.prototype.slice = function(start, end) { start = toInteger(start); var result = this; @@ -10229,16 +10189,16 @@ return result; }; - LazyWrapper.prototype.takeRightWhile = function (predicate) { + LazyWrapper.prototype.takeRightWhile = function(predicate) { return this.reverse().takeWhile(predicate).reverse(); }; - LazyWrapper.prototype.toArray = function () { + LazyWrapper.prototype.toArray = function() { return this.take(MAX_ARRAY_LENGTH); }; // Add `LazyWrapper` methods to `lodash.prototype`. - baseForOwn(LazyWrapper.prototype, function (func, methodName) { + baseForOwn(LazyWrapper.prototype, function(func, methodName) { var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), isTaker = /^(?:head|last)$/.test(methodName), lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], @@ -10247,14 +10207,14 @@ if (!lodashFunc) { return; } - lodash.prototype[methodName] = function () { + lodash.prototype[methodName] = function() { var value = this.__wrapped__, args = isTaker ? [1] : arguments, isLazy = value instanceof LazyWrapper, iteratee = args[0], useLazy = isLazy || isArray(value); - var interceptor = function (value) { + var interceptor = function(value) { var result = lodashFunc.apply(lodash, arrayPush([value], args)); return (isTaker && chainAll) ? result[0] : result; }; @@ -10283,25 +10243,25 @@ }); // Add `Array` methods to `lodash.prototype`. - arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function (methodName) { + arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { var func = arrayProto[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', retUnwrapped = /^(?:pop|shift)$/.test(methodName); - lodash.prototype[methodName] = function () { + lodash.prototype[methodName] = function() { var args = arguments; if (retUnwrapped && !this.__chain__) { var value = this.value(); return func.apply(isArray(value) ? value : [], args); } - return this[chainName](function (value) { + return this[chainName](function(value) { return func.apply(isArray(value) ? value : [], args); }); }; }); // Map minified method names to their real names. - baseForOwn(LazyWrapper.prototype, function (func, methodName) { + baseForOwn(LazyWrapper.prototype, function(func, methodName) { var lodashFunc = lodash[methodName]; if (lodashFunc) { var key = (lodashFunc.name + ''), @@ -10336,11 +10296,11 @@ // loaded by a script tag in the presence of an AMD loader. // See http://requirejs.org/docs/errors.html#mismatch for more details. // Use `_.noConflict` to remove Lodash from the global object. - BI._ = lodash; + root._ = lodash; // Define as an anonymous module so, through path mapping, it can be // referenced as the "underscore" module. - define(function () { + define(function() { return lodash; }); } @@ -10350,7 +10310,8 @@ (freeModule.exports = lodash)._ = lodash; // Export for CommonJS support. freeExports._ = lodash; - } else { + } + else { // Export to the global object. BI._ = lodash; } diff --git a/src/core/4.widget.js b/src/core/4.widget.js index d24c01566..3c28a3976 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -360,6 +360,7 @@ var workerMode = BI.Providers.getProvider("bi.provider.system").getWorkerMode(); var render = BI.isFunction(this.options.render) ? this.options.render : (workerMode ? (this.$render || this.render) : this.render); var els = render && render.call(this); + els = this.options.configRender ? this.options.configRender(els) : els; els = BI.Plugin.getRender(this.options.type, els); if (BI.isPlainObject(els)) { els = [els]; @@ -743,12 +744,22 @@ }, _unMount: function () { + this._assetMounted(); this.__destroy(); this.fireEvent(BI.Events.UNMOUNT); this.purgeListeners(); }, + _assetMounted: function () { + if (!this.isVisible()) { + this._setVisible(true); + this._mount(false, false, false); + this._setVisible(false); + } + }, + _empty: function () { + this._assetMounted(); BI.each(this._children, function (i, widget) { widget && widget._unMount && widget._unMount(); }); @@ -790,6 +801,7 @@ }); }); this._watchers && (this._watchers = []); + this._assetMounted(); this.__d(); this.element.empty(); this.element.unbind(); @@ -799,6 +811,7 @@ }, _destroy: function () { + this._assetMounted(); this.__destroy(); this.element.destroy(); this.purgeListeners(); @@ -806,6 +819,7 @@ destroy: function () { var self = this, o = this.options; + this._assetMounted(); this.__destroy(); if (o.animation) { this._innerSetVisible(false); diff --git a/src/core/5.inject.js b/src/core/5.inject.js index 9e0ae8503..0554740f7 100644 --- a/src/core/5.inject.js +++ b/src/core/5.inject.js @@ -411,7 +411,7 @@ // 根据配置属性生成widget var createWidget = function (config, context, lazy) { - var cls = kv[config.type]; + var cls = BI.isFunction(config.type) ? config.type : kv[config.type]; if (!cls) { throw new Error("组件: [" + config.type + "] 未定义"); @@ -449,9 +449,10 @@ } else if (item.el && (item.el.type || options.type)) { el = BI.extend({}, options, item.el); } - + if (el) { - runConfigFunction(el.type); + var elType = (el.type && el.type.xtype) || el.type; + runConfigFunction(elType); } // 先把准备环境准备好 @@ -466,13 +467,14 @@ return item; } if (el) { - w = BI.Plugin.getWidget(el.type, el); - if (w.type === el.type) { - if (BI.Plugin.hasObject(el.type)) { + w = BI.Plugin.getWidget(elType, el); + var wType = (w.type && w.type.xtype) || w.type; + if (wType === elType) { + if (BI.Plugin.hasObject(elType)) { w.listeners = (w.listeners || []).concat([{ eventName: BI.Events.MOUNT, action: function () { - BI.Plugin.getObject(el.type, this); + BI.Plugin.getObject(elType, this); } }]); } diff --git a/src/core/logic/logic.layout.js b/src/core/logic/logic.layout.js index 21ce0f9b8..8b4abc85a 100644 --- a/src/core/logic/logic.layout.js +++ b/src/core/logic/logic.layout.js @@ -32,7 +32,7 @@ BI.VerticalLayoutLogic = BI.inherit(BI.Logic, { } else { layout = "bi.vtape"; } - return { + return BI._.pickBy({ type: layout, scrollable: o.scrollable, scrolly: o.scrolly, @@ -45,8 +45,12 @@ BI.VerticalLayoutLogic = BI.inherit(BI.Logic, { bgap: o.bgap, innerHgap: o.innerHgap, innerVgap: o.innerVgap, - items: o.items - }; + items: o.items, + horizontalAlign: o.horizontalAlign, + verticalAlign: o.verticalAlign, + columnSize: o.columnSize, + rowSize: o.rowSize + }, BI._.identity); } }); @@ -85,7 +89,7 @@ BI.HorizontalLayoutLogic = BI.inherit(BI.Logic, { } else { layout = "bi.htape"; } - return { + return BI._.pickBy({ type: layout, scrollable: o.scrollable, scrolly: o.scrolly, @@ -98,8 +102,12 @@ BI.HorizontalLayoutLogic = BI.inherit(BI.Logic, { bgap: o.bgap, innerHgap: o.innerHgap, innerVgap: o.innerVgap, - items: o.items - }; + items: o.items, + horizontalAlign: o.horizontalAlign, + verticalAlign: o.verticalAlign, + columnSize: o.columnSize, + rowSize: o.rowSize + }, BI._.identity); } }); @@ -135,19 +143,21 @@ BI.TableLayoutLogic = BI.inherit(BI.Logic, { } else { layout = "bi.window"; } - return { + return BI._.pickBy({ type: layout, scrollable: o.scrollable, scrolly: o.scrolly, scrollx: o.scrollx, columns: o.columns, rows: o.rows, - columnSize: o.columnSize, - rowSize: o.rowSize, hgap: o.hgap, vgap: o.vgap, - items: o.items - }; + items: o.items, + horizontalAlign: o.horizontalAlign, + verticalAlign: o.verticalAlign, + columnSize: o.columnSize, + rowSize: o.rowSize + }, BI._.identity); } }); @@ -188,9 +198,8 @@ BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, { } else { layout = "bi.htape"; } - return { + return BI._.pickBy({ type: layout, - columnSize: columnSize, scrollable: o.scrollable, scrolly: o.scrolly, scrollx: o.scrollx, @@ -202,7 +211,11 @@ BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, { bgap: o.bgap, innerHgap: o.innerHgap, innerVgap: o.innerVgap, - items: o.items - }; + items: o.items, + horizontalAlign: o.horizontalAlign, + verticalAlign: o.verticalAlign, + columnSize: columnSize, + rowSize: o.rowSize + }, BI._.identity); } }); diff --git a/src/core/platform/web/config.js b/src/core/platform/web/config.js index 6a955a27e..66440ccf8 100644 --- a/src/core/platform/web/config.js +++ b/src/core/platform/web/config.js @@ -62,6 +62,13 @@ }) }); } + if (ob.verticalAlign === BI.VerticalAlign.Stretch) { + if (isSupportFlex()) { + return BI.extend({ + horizontalAlign: BI.HorizontalAlign.Stretch, + }, ob, { type: "bi.flex_vertical" }); + } + } return ob; }); BI.Plugin.configWidget("bi.inline", function (ob) { @@ -229,7 +236,7 @@ return ob; }); BI.Plugin.configWidget("bi.flex_horizontal", function (ob) { - if (ob.scrollable === true || ob.scrollx !== false) { + if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { if (ob.hgap > 0 || ob.lgap > 0 || ob.rgap > 0) { if (BI.Providers.getProvider("bi.provider.system").getResponsiveMode()) { return BI.extend({}, ob, { type: "bi.responsive_flex_scrollable_horizontal" }); @@ -242,7 +249,7 @@ } }); BI.Plugin.configWidget("bi.flex_vertical", function (ob) { - if (ob.scrollable === true || ob.scrollx === true) { + if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { if (ob.hgap > 0 || ob.lgap > 0 || ob.rgap > 0) { return BI.extend({}, ob, { type: "bi.flex_scrollable_vertical" }); } diff --git a/src/core/platform/web/detectElementResize.js b/src/core/platform/web/detectElementResize.js index b34d21771..7137bb50c 100644 --- a/src/core/platform/web/detectElementResize.js +++ b/src/core/platform/web/detectElementResize.js @@ -112,7 +112,21 @@ }; var addResizeListener = function (element, fn) { - if (attachEvent) { + if (window.ResizeObserver) { + if (!element.__resizeObserver__) { + var resizeObserver = new window.ResizeObserver(function () { + element.__resizeListeners__.forEach(function (listener) { + listener(); + }); + }); + resizeObserver.observe(element); + element.__resizeObserver__ = resizeObserver; + } + if (!element.__resizeListeners__) { + element.__resizeListeners__ = []; + } + element.__resizeListeners__.push(fn); + } else if (attachEvent) { element.attachEvent("onresize", fn); BI.nextTick(fn); } else { @@ -137,8 +151,17 @@ } }; var removeResizeListener = function (element, fn) { - if (attachEvent) element.detachEvent("onresize", fn); - else { + if (window.ResizeObserver) { + var index = element.__resizeListeners__.indexOf(fn); + if (index >= 0) { + element.__resizeListeners__.splice(index, 1); + if (!element.__resizeListeners__.length) { + element.__resizeObserver__ && element.__resizeObserver__.unobserve(element); + } + } + } else if (attachEvent) { + element.detachEvent("onresize", fn); + } else { element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1); if (!element.__resizeListeners__.length) { element.removeEventListener("scroll", scrollListener); diff --git a/src/core/platform/web/jquery/_jquery.js b/src/core/platform/web/jquery/_jquery.js index 8c83f4356..9888c50f7 100644 --- a/src/core/platform/web/jquery/_jquery.js +++ b/src/core/platform/web/jquery/_jquery.js @@ -1,5 +1,5 @@ /*! - * jQuery JavaScript Library v1.12.4 + * jQuery JavaScript Library v3.6.1 * http://jquery.com/ * * Includes Sizzle.js @@ -63,16 +63,15 @@ var support = {}; - var - version = "1.12.4", + version = "3.6.1", // Define a local copy of jQuery - jQuery = function( selector, context ) { + jQuery = function (selector, context) { // The jQuery object is actually just the init constructor 'enhanced' // Need init if jQuery is called (just allow error to be thrown if not included) - return new jQuery.fn.init( selector, context ); + return new jQuery.fn.init(selector, context); }, // Support: Android<4.1, IE<9 @@ -10358,20 +10357,27 @@ function createStandardXHR() { try { return new window.XMLHttpRequest(); - } catch ( e ) {} + } catch (e) { + } } function createActiveXHR() { try { - return new window.ActiveXObject( "Microsoft.XMLHTTP" ); - } catch ( e ) {} + return new window.ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) { + } } - +// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) + jQuery.ajaxPrefilter(function (s) { + if (s.crossDomain) { + s.contents.script = false; + } + }); // Install script dataType - jQuery.ajaxSetup( { + jQuery.ajaxSetup({ accepts: { script: "text/javascript, application/javascript, " + "application/ecmascript, application/x-ecmascript" @@ -10537,54 +10543,82 @@ s.jsonpCallback = originalSettings.jsonpCallback; // save the callback name for future use - oldCallbacks.push( callbackName ); + oldCallbacks.push(callbackName); } // Call if it was a function and we have a response - if ( responseContainer && jQuery.isFunction( overwritten ) ) { - overwritten( responseContainer[ 0 ] ); + if (responseContainer && jQuery.isFunction(overwritten)) { + overwritten(responseContainer[0]); } responseContainer = overwritten = undefined; - } ); + }); // Delegate to script return "script"; } - } ); - + }); +// Support: Safari 8 only +// In Safari 8 documents created via document.implementation.createHTMLDocument +// collapse sibling forms: the second one becomes a child of the first one. +// Because of that, this security measure has to be disabled in Safari 8. +// https://bugs.webkit.org/show_bug.cgi?id=137337 + support.createHTMLDocument = (function () { + var body = document.implementation.createHTMLDocument("").body; + body.innerHTML = "
"; + return body.childNodes.length === 2; + })(); // data: string of html // context (optional): If specified, the fragment will be created in this context, // defaults to document // keepScripts (optional): If true, will include scripts passed in the html string - jQuery.parseHTML = function( data, context, keepScripts ) { - if ( !data || typeof data !== "string" ) { + jQuery.parseHTML = function (data, context, keepScripts) { + if (!data || typeof data !== "string") { return null; } - if ( typeof context === "boolean" ) { + if (typeof context === "boolean") { keepScripts = context; context = false; } - context = context || document; - var parsed = rsingleTag.exec( data ), - scripts = !keepScripts && []; + var base, parsed, scripts; + + if (!context) { + + // Stop scripts or inline event handlers from being executed immediately + // by using document.implementation + if (support.createHTMLDocument) { + context = document.implementation.createHTMLDocument(""); + + // Set the base href for the created document + // so any parsed elements with URLs + // are based on the document's URL (gh-2965) + base = context.createElement("base"); + base.href = document.location.href; + context.head.appendChild(base); + } else { + context = document; + } + } + + parsed = rsingleTag.exec(data); + scripts = !keepScripts && []; // Single tag - if ( parsed ) { - return [ context.createElement( parsed[ 1 ] ) ]; + if (parsed) { + return [context.createElement(parsed[1])]; } - parsed = buildFragment( [ data ], context, scripts ); + parsed = buildFragment([data], context, scripts); - if ( scripts && scripts.length ) { - jQuery( scripts ).remove(); + if (scripts && scripts.length) { + jQuery(scripts).remove(); } - return jQuery.merge( [], parsed.childNodes ); + return jQuery.merge([], parsed.childNodes); }; diff --git a/src/core/utils/i18n.js b/src/core/utils/i18n.js index 9cec7cc48..8611ec0a9 100644 --- a/src/core/utils/i18n.js +++ b/src/core/utils/i18n.js @@ -1,5 +1,8 @@ !(function () { var i18nStore = {}; + + var i18nFormatters = {}; + BI._.extend(BI, { changeI18n: function (i18n) { if (i18n) { @@ -9,6 +12,7 @@ addI18n: function (i18n) { BI.extend(i18nStore, i18n); }, + i18nText: function (key) { var localeText = i18nStore[key] || (BI.i18n && BI.i18n[key]) || ""; if (!localeText) { @@ -16,10 +20,18 @@ } var len = arguments.length; if (len > 1) { - if (localeText.indexOf("{R1}") > -1) { + if (localeText.indexOf("{R1") > -1) { for (var i = 1; i < len; i++) { - var key = "{R" + i + "}"; - localeText = BI.replaceAll(localeText, key, arguments[i] + ""); + var reg = new RegExp(`{R${i},(.*?)}`, "g"); + + var result = reg.exec(localeText); + + if (result) { + var formatName = result[1]; + localeText = BI.replaceAll(localeText, reg, i18nFormatters[formatName](key, arguments[i])); + } else { + localeText = BI.replaceAll(localeText, `{R${i}}`, arguments[i] + ""); + } } } else { var args = Array.prototype.slice.call(arguments); @@ -30,6 +42,10 @@ } } return localeText; + }, + + addI18nFormatter: function (formatName, fn) { + i18nFormatters[formatName] = fn; } }); })(); diff --git a/src/less/base/single/html.less b/src/less/base/single/html.less index 3159bc630..0a4279397 100644 --- a/src/less/base/single/html.less +++ b/src/less/base/single/html.less @@ -18,8 +18,6 @@ canvas, video { display: inline-block; - *display: inline; - *zoom: 1 } audio:not([controls]) { display: none; @@ -180,7 +178,6 @@ border: 0; padding: 0; white-space: normal; - *margin-left: -7px } button, input, @@ -189,7 +186,6 @@ font-size: 100%; margin: 0; vertical-align: baseline; - *vertical-align: middle } button, input { @@ -201,7 +197,6 @@ input[type="submit"] { -webkit-appearance: button; cursor: pointer; - *overflow: visible } button[disabled], input[disabled] { @@ -211,8 +206,8 @@ input[type="radio"] { box-sizing: border-box; padding: 0; - *height: 13px; - *width: 13px + height: 13px; + width: 13px } input[type="search"] { -webkit-appearance: textfield; @@ -237,4 +232,4 @@ border-collapse: collapse; border-spacing: 0 } -} \ No newline at end of file +} diff --git a/src/less/base/tree/ztree.less b/src/less/base/tree/ztree.less index 6f6fa77c7..e300e0be4 100644 --- a/src/less/base/tree/ztree.less +++ b/src/less/base/tree/ztree.less @@ -130,7 +130,6 @@ margin: 0; font-size: 12px; border: 1px #7EC4CC solid; - *border: 0px } .ztree li span { @@ -315,42 +314,36 @@ margin-right: 2px; background-position: -110px -16px; vertical-align: top; - *vertical-align: middle } .ztree li span.button.ico_close { margin-right: 2px; background-position: -110px 0; vertical-align: top; - *vertical-align: middle } .ztree li span.button.ico_docu { margin-right: 2px; background-position: -110px -32px; vertical-align: top; - *vertical-align: middle } .ztree li span.button.edit { margin-right: 2px; background-position: -110px -48px; vertical-align: top; - *vertical-align: middle } .ztree li span.button.remove { margin-right: 2px; background-position: -110px -64px; vertical-align: top; - *vertical-align: middle } .ztree li span.button.ico_loading { width: 0px; margin-right: 2px; vertical-align: top; - *vertical-align: middle } ul.tmpTargetzTree { diff --git a/src/less/base/trigger/trigger.less b/src/less/base/trigger/trigger.less index bcd89590a..70e1f277f 100644 --- a/src/less/base/trigger/trigger.less +++ b/src/less/base/trigger/trigger.less @@ -1,7 +1,7 @@ @import "../../index.less"; .bi-trigger{ - & .bi-trigger-icon-button{ + & .bi-trigger-icon-button, &.bi-trigger-icon-button { font-size: @font-size-16; } -} \ No newline at end of file +} diff --git a/src/less/core/utils/common.less b/src/less/core/utils/common.less index 76a93b316..0a0b0e53b 100644 --- a/src/less/core/utils/common.less +++ b/src/less/core/utils/common.less @@ -2,6 +2,19 @@ .base-disabled { cursor: not-allowed !important; + .cursor-pointer { + cursor: not-allowed !important; + } + .cursor-default { + cursor: not-allowed !important; + } + .cursor-move { + cursor: not-allowed !important; + } + .cursor-text{ + cursor: not-allowed !important; + } + color: @color-bi-text-disabled !important; & .bi-input { @@ -41,6 +54,18 @@ .base-invalid { cursor: default !important; + .cursor-pointer { + cursor: default !important; + } + .cursor-default { + cursor: default !important; + } + .cursor-move { + cursor: default !important; + } + .cursor-text{ + cursor: default !important; + } } //focus时边框高亮 diff --git a/src/less/widget/multilayersingletree/multilayersingletree.combo.less b/src/less/widget/multilayersingletree/multilayersingletree.combo.less index 15df50877..b190d19c1 100644 --- a/src/less/widget/multilayersingletree/multilayersingletree.combo.less +++ b/src/less/widget/multilayersingletree/multilayersingletree.combo.less @@ -1,6 +1,16 @@ @import "../../index.less"; +@val: transform .3s ease; .bi-multilayer-single-tree-combo { + + // 此combo的trigger_button是absolute上去的,与bi-combo在同一层级,独立写一下 + & .bi-combo.bi-combo-popup + .bi-trigger-icon-button { + & .x-icon { + .rotate(180deg); + .transition(@val); + } + } + &.status-error { &.bi-border, &.bi-border-bottom { border-color: @border-color-negative; diff --git a/src/router/router.js b/src/router/router.js index 40ca8f3c4..4a2cf0c2f 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -2326,7 +2326,7 @@ route.matched[lastRouteIndex] === current.matched[lastCurrentIndex] ) { this.ensureURL(); - return abort(createNavigationDuplicatedError(current, route)) + return; } var ref = resolveQueue( diff --git a/src/widget/downlist/combo.downlist.js b/src/widget/downlist/combo.downlist.js index be615e6ea..cf983dfc4 100644 --- a/src/widget/downlist/combo.downlist.js +++ b/src/widget/downlist/combo.downlist.js @@ -1,110 +1,139 @@ -/** - * Created by roy on 15/8/14. - */ -BI.DownListCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-down-list-combo", - height: 24, - items: [], - adjustLength: 0, - direction: "bottom", - trigger: "click", - container: null, - stopPropagation: false, - el: {}, - minWidth: 140, - maxHeight: 1000, - destroyWhenHide: false +(function() { + function transformItems(items) { + if (!items) return items; + var result = BI.cloneDeep(items); + var isComplexItmes = BI.some(items, function (_, item) { + return BI.isArray(item); }); - }, - - _init: function () { - BI.DownListCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.downlistcombo = BI.createWidget({ - element: this, - type: "bi.combo", - trigger: o.trigger, - isNeedAdjustWidth: false, - isDefaultInit: true, - container: o.container, - adjustLength: o.adjustLength, - direction: o.direction, - belowMouse: o.belowMouse, - stopPropagation: o.stopPropagation, - destroyWhenHide: o.destroyWhenHide, - el: BI.createWidget(o.el, { - type: "bi.icon_trigger", - extraCls: o.iconCls, - width: o.width, - height: o.height - }), - popup: { - el: { - type: "bi.down_list_popup", - ref: function (ref) { - self.popupView = ref; - }, - items: o.items, - chooseType: o.chooseType, - value: o.value, - listeners: [{ - eventName: BI.DownListPopup.EVENT_CHANGE, - action: function (value) { - self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value); - self.downlistcombo.hideView(); - } - }, { - eventName: BI.DownListPopup.EVENT_SON_VALUE_CHANGE, - action: function (value, fatherValue) { - self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue); - self.downlistcombo.hideView(); - } - }] - }, - stopPropagation: o.stopPropagation, - maxHeight: o.maxHeight, - minWidth: o.minWidth - } - }); - - this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW); + // 传一维数组,帮转二维 + if (!isComplexItmes) { + result = [result]; + } + // 帮转 el + BI.each(result, function (_, arr) { + BI.each(arr, function (_, item) { + if (item.children && !item.el) { + item.el = { + text: item.text, + icon: item.icon, + cls: item.cls, + iconCls1: item.iconCls1, + value: item.value + }; + } + }); }); - }, - - 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(); + return result; } -}); -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); + + /** + * Created by roy on 15/8/14. + */ + BI.DownListCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-down-list-combo", + height: 24, + items: [], + adjustLength: 0, + direction: "bottom", + trigger: "click", + container: null, + stopPropagation: false, + el: {}, + 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", + trigger: o.trigger, + isNeedAdjustWidth: false, + isDefaultInit: true, + container: o.container, + adjustLength: o.adjustLength, + direction: o.direction, + belowMouse: o.belowMouse, + stopPropagation: o.stopPropagation, + destroyWhenHide: o.destroyWhenHide, + el: BI.createWidget(o.el, { + type: "bi.icon_trigger", + extraCls: o.iconCls, + width: o.width, + height: o.height + }), + popup: { + el: { + type: "bi.down_list_popup", + ref: function (ref) { + self.popupView = ref; + }, + items: transformItems(o.items), + chooseType: o.chooseType, + value: o.value, + listeners: [{ + eventName: BI.DownListPopup.EVENT_CHANGE, + action: function (value) { + self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value); + self.downlistcombo.hideView(); + } + }, { + eventName: BI.DownListPopup.EVENT_SON_VALUE_CHANGE, + action: function (value, fatherValue) { + self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue); + self.downlistcombo.hideView(); + } + }] + }, + stopPropagation: o.stopPropagation, + maxHeight: o.maxHeight, + minWidth: o.minWidth + } + }); + + 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(); + } + }); + 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/downlist/item.downlist.js b/src/widget/downlist/item.downlist.js index 068c94fab..531806ca0 100644 --- a/src/widget/downlist/item.downlist.js +++ b/src/widget/downlist/item.downlist.js @@ -33,17 +33,21 @@ BI.DownListItem = BI.inherit(BI.BasicButton, { keyword: o.keyword, height: o.height }); + + + var icon = BI.isPlainObject(o.icon) ? o.icon : { + type: "bi.icon", + width: o.iconWidth, + height: o.iconHeight, + } + this.icon = BI.createWidget({ type: "bi.center_adapt", width: 36, height: o.height, items: [{ - el: { - type: "bi.icon", - width: o.iconWidth, - height: o.iconHeight - } - }] + el: icon, + }], }); BI.createWidget(BI.extend({ diff --git a/src/widget/downlist/item.downlistgroup.js b/src/widget/downlist/item.downlistgroup.js index e142a72b7..df4a09ac7 100644 --- a/src/widget/downlist/item.downlistgroup.js +++ b/src/widget/downlist/item.downlistgroup.js @@ -8,11 +8,11 @@ BI.DownListGroupItem = BI.inherit(BI.BasicButton, { }, // invalid: true, iconCls1: "dot-e-font", + icon: "", iconCls2: "pull-right-e-font" }); }, - _init: function () { - BI.DownListGroupItem.superclass._init.apply(this, arguments); + render: function () { var o = this.options; var self = this; this.text = BI.createWidget({ @@ -21,20 +21,29 @@ BI.DownListGroupItem = BI.inherit(BI.BasicButton, { textAlign: "left", text: o.text, value: o.value, - height: o.height - }); - - this.icon1 = BI.createWidget({ - type: "bi.icon_button", - cls: o.iconCls1, - width: 36, height: o.height, - iconHeight: o.iconHeight, - iconWidth: 36, - disableSelected: true, - selected: this._digest(o.value) }); + if (BI.isPlainObject(o.icon)) { + this.icon1 = BI.createWidget({ + width: 36, + height: o.height, + type: "bi.center_adapt", + items: [o.icon], + }); + } else { + this.icon1 = BI.createWidget({ + type: "bi.icon_button", + cls: o.iconCls1, + width: 36, + height: o.height, + iconHeight: o.iconHeight, + iconWidth: 36, + disableSelected: true, + selected: this._digest(o.value), + }); + } + this.icon2 = BI.createWidget({ type: "bi.icon_button", cls: o.iconCls2, @@ -42,27 +51,6 @@ BI.DownListGroupItem = BI.inherit(BI.BasicButton, { forceNotSelected: true }); - var blank = BI.createWidget({ - type: "bi.layout", - width: 24 - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.icon2, - top: 0, - bottom: 0, - right: 0 - }] - }); - - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon1, this.text, blank) - })))); - this.element.hover(function () { if (self.isEnabled()) { self.hover(); @@ -72,6 +60,12 @@ BI.DownListGroupItem = BI.inherit(BI.BasicButton, { self.dishover(); } }); + + return { + type: "bi.horizontal_fill", + columnSize: [36, "fill", 24], + items: [this.icon1, this.text, this.icon2] + } }, _getLevel: function () { @@ -117,8 +111,8 @@ BI.DownListGroupItem = BI.inherit(BI.BasicButton, { }, setValue: function (v) { - this.icon1.setSelected(this._digest(v)); - } + this.icon1.setSelected && this.icon1.setSelected(this._digest(v)); + }, }); BI.DownListGroupItem.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.down_list_group_item", BI.DownListGroupItem); \ No newline at end of file +BI.shortcut("bi.down_list_group_item", BI.DownListGroupItem); diff --git a/src/widget/dynamicdate/dynamicdate.param.item.js b/src/widget/dynamicdate/dynamicdate.param.item.js index c8771e908..fed229fa2 100644 --- a/src/widget/dynamicdate/dynamicdate.param.item.js +++ b/src/widget/dynamicdate/dynamicdate.param.item.js @@ -20,7 +20,7 @@ BI.DynamicDateParamItem = BI.inherit(BI.Widget, { items: [{ el: { type: "bi.sign_editor", - cls: "bi-border", + cls: "bi-border bi-focus-shadow bi-border-radius", height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT - 2, validationChecker: function (v) { return BI.isNaturalNumber(v); diff --git a/src/widget/dynamicdate/dynamicdate.trigger.js b/src/widget/dynamicdate/dynamicdate.trigger.js index 1412fae69..012f6c722 100644 --- a/src/widget/dynamicdate/dynamicdate.trigger.js +++ b/src/widget/dynamicdate/dynamicdate.trigger.js @@ -9,7 +9,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { iconWidth: 24 }, - props: { + props: () => ({ extraCls: "bi-date-trigger", min: "1900-01-01", // 最小日期 max: "2099-12-31", // 最大日期 @@ -17,8 +17,8 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { iconWidth: 24, format: "", // 显示的日期格式化方式 allowEdit: true, // 是否允许编辑 - watermark: "" - }, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + }), _init: function () { BI.DynamicDateTrigger.superclass._init.apply(this, arguments); @@ -44,7 +44,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { hgap: c.hgap, vgap: c.vgap, allowBlank: true, - watermark: BI.isKey(o.watermark) ? o.watermark : BI.i18nText("BI-Basic_Unrestricted"), + watermark: o.watermark, errorText: function (v) { var str = ""; if (!BI.isKey(o.format)) { diff --git a/src/widget/intervalslider/intervalslider.js b/src/widget/intervalslider/intervalslider.js index 68f098f37..130165680 100644 --- a/src/widget/intervalslider/intervalslider.js +++ b/src/widget/intervalslider/intervalslider.js @@ -15,7 +15,23 @@ BI.IntervalSlider = BI.inherit(BI.Single, { props: { baseCls: "bi-interval-slider bi-slider-track", digit: false, - unit: "" + unit: "", + min: 0, + max: 100, + value: { + min: "", + max: "", + } + }, + + beforeMount: function () { + const { value, min, max } = this.options; + this.setMinAndMax({ + min, + max, + }); + this.setValue(value); + this.populate(); }, render: function () { @@ -25,13 +41,8 @@ BI.IntervalSlider = BI.inherit(BI.Single, { this.enable = false; this.valueOne = ""; this.valueTwo = ""; - this.calculation = new BI.AccurateCalculationModel(); - // this.backgroundTrack = BI.createWidget({ - // type: "bi.layout", - // cls: "background-track", - // height: c.TRACK_HEIGHT - // }); + this.calculation = new BI.AccurateCalculationModel(); this.grayTrack = BI.createWidget({ type: "bi.layout", cls: "gray-track", @@ -539,4 +550,4 @@ BI.IntervalSlider = BI.inherit(BI.Single, { } }); BI.IntervalSlider.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.interval_slider", BI.IntervalSlider); \ No newline at end of file +BI.shortcut("bi.interval_slider", BI.IntervalSlider); diff --git a/src/widget/multilayerdownlist/popup.downlist.js b/src/widget/multilayerdownlist/popup.downlist.js index 7483349de..8fbacd285 100644 --- a/src/widget/multilayerdownlist/popup.downlist.js +++ b/src/widget/multilayerdownlist/popup.downlist.js @@ -99,7 +99,7 @@ BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { item.el.logic = { dynamic: true }; - item.el.height = sourceItem.el.height || self.constants.height; + item.el.height = sourceItem.el.height || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT; item.el.iconCls2 = self.constants.nextIcon; item.popup = { lgap: 1, @@ -183,7 +183,7 @@ BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { if (BI.isNotEmptyArray(child.children)) { item.type = "bi.down_list_group_item"; item.iconCls2 = self.constants.nextIcon; - item.height = child.height || self.constants.height; + item.height = child.height || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT; self._createChildren(item, child); } targetItem.items.push(item); diff --git a/src/widget/multilayerselecttree/multilayerselecttree.combo.js b/src/widget/multilayerselecttree/multilayerselecttree.combo.js index e748ee1c5..7263346b0 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.combo.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.combo.js @@ -35,7 +35,6 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { var baseConfig = this._getBaseConfig(); - if (o.allowEdit) { return { type: "bi.absolute", @@ -210,7 +209,7 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { var self = this, o = this.options; return { type: "bi.trigger_icon_button", - cls: "trigger-icon-button", + cls: "bi-trigger trigger-icon-button", ref: function (_ref) { self.triggerBtn = _ref; }, diff --git a/src/widget/multilayersingletree/multilayersingletree.combo.js b/src/widget/multilayersingletree/multilayersingletree.combo.js index 364f1e008..d06f1a8c6 100644 --- a/src/widget/multilayersingletree/multilayersingletree.combo.js +++ b/src/widget/multilayersingletree/multilayersingletree.combo.js @@ -33,14 +33,48 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { render: function () { var self = this, o = this.options; - return (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); + var cls = (o.simple ? "bi-border-bottom " : "bi-border bi-border-radius ") + (BI.isKey(o.status) ? ("status-" + o.status) : ""); + + var baseConfig = this._getBaseConfig(); + + if (o.allowEdit) { + return { + type: "bi.absolute", + cls, + items: [ + { + el: BI.extend(baseConfig, this._getSearchConfig()), + top: 0, bottom: 0, right: 0, left: 0 + }, { + el: self._getTriggerIconButton(), + top: 0, bottom: 0, right: 0, + }, + ] + }; + } + + return BI.extend(baseConfig, { + el: { + type: "bi.single_tree_trigger", + ref: function (_ref) { + self.textTrigger = _ref; + }, + text: o.text, + defaultText: o.defaultText, + height: o.height, + items: o.items, + value: o.value, + tipType: o.tipType, + warningTitle: o.warningTitle, + valueFormatter: o.valueFormatter, + }, + }, { cls }); }, _getBaseConfig: function () { var self = this, o = this.options; return { type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius ") + (BI.isKey(o.status) ? ("status-" + o.status) : ""), container: o.container, destroyWhenHide: o.destroyWhenHide, adjustLength: 2, @@ -152,7 +186,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { // IE11下,popover(position: fixed)下放置下拉控件(position: fixed), 滚动的时候会异常卡顿 // 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以 // 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪 - return !(o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0); + return (o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0) ? false : self.triggerBtn?.element.find(e.target).length === 0; }, listeners: [{ eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, @@ -168,46 +202,29 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { }; }, - _getSyncConfig: function () { - var o = this.options, self = this; - var baseConfig = this._getBaseConfig(); - return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : { - el: { - type: "bi.single_tree_trigger", - ref: function (_ref) { - self.textTrigger = _ref; - }, - text: o.text, - defaultText: o.defaultText, - height: o.height, - items: o.items, - value: o.value, - tipType: o.tipType, - warningTitle: o.warningTitle, - valueFormatter: o.valueFormatter, - }, - }); - }, - - _getAsyncConfig: function () { - var o = this.options, self = this; - var baseConfig = this._getBaseConfig(); - return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : { - el: { - type: "bi.single_tree_trigger", - ref: function (_ref) { - self.textTrigger = _ref; - }, - text: o.text, - defaultText: o.defaultText, - height: o.height, - items: o.items, - value: o.value, - tipType: o.tipType, - warningTitle: o.warningTitle, - valueFormatter: o.valueFormatter, + _getTriggerIconButton: function () { + var self = this, o = this.options; + return { + type: "bi.trigger_icon_button", + cls: "bi-trigger trigger-icon-button", + ref: function (_ref) { + self.triggerBtn = _ref; }, - }); + width: o.height, + height: o.height, + listeners: [ + { + eventName: BI.TriggerIconButton.EVENT_CHANGE, + action: function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + } + } + ] + }; }, getSearcher: function () { diff --git a/src/widget/multilayersingletree/multilayersingletree.trigger.js b/src/widget/multilayersingletree/multilayersingletree.trigger.js index b4f5c8dd9..617c70d7b 100644 --- a/src/widget/multilayersingletree/multilayersingletree.trigger.js +++ b/src/widget/multilayersingletree/multilayersingletree.trigger.js @@ -102,17 +102,8 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }] }, width: "fill", - }, { - el: { - type: "bi.trigger_icon_button", - cls: "trigger-icon-button", - ref: function (_ref) { - self.triggerBtn = _ref; - }, - width: 24, - }, - width: 24 - } + rgap: 24, + }, ] }; }, diff --git a/src/widget/multiselect/multiselect.combo.js b/src/widget/multiselect/multiselect.combo.js index 00b035096..836193f96 100644 --- a/src/widget/multiselect/multiselect.combo.js +++ b/src/widget/multiselect/multiselect.combo.js @@ -35,7 +35,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { self.trigger.getSearcher().setState(self.storeValue); self.numberCounter.setButtonChecked(self.storeValue); }; - this.storeValue = o.value || {}; + this.storeValue = BI.deepClone(o.value) || {}; this._assertValue(this.storeValue); diff --git a/src/widget/multiselect/multiselect.combo.nobar.js b/src/widget/multiselect/multiselect.combo.nobar.js index b06a40662..c2a0851c6 100644 --- a/src/widget/multiselect/multiselect.combo.nobar.js +++ b/src/widget/multiselect/multiselect.combo.nobar.js @@ -34,7 +34,7 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, { }; this.storeValue = { type: BI.Selection.Multi, - value: o.value || [] + value: BI.deepClone(o.value) || [] }; // 标记正在请求数据 this.requesting = false; diff --git a/src/widget/multiselect/multiselect.insert.combo.js b/src/widget/multiselect/multiselect.insert.combo.js index 329c0f3f9..eee22c4db 100644 --- a/src/widget/multiselect/multiselect.insert.combo.js +++ b/src/widget/multiselect/multiselect.insert.combo.js @@ -33,7 +33,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, { self.trigger.getSearcher().setState(self.storeValue); self.numberCounter.setButtonChecked(self.storeValue); }; - this.storeValue = o.value || {}; + this.storeValue = BI.deepClone(o.value) || {}; // 标记正在请求数据 this.requesting = false; diff --git a/src/widget/multiselect/multiselect.insert.combo.nobar.js b/src/widget/multiselect/multiselect.insert.combo.nobar.js index 1b92a9622..bb4a71ac1 100644 --- a/src/widget/multiselect/multiselect.insert.combo.nobar.js +++ b/src/widget/multiselect/multiselect.insert.combo.nobar.js @@ -34,7 +34,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, { }; this.storeValue = { type: BI.Selection.Multi, - value: o.value || [] + value: BI.deepClone(o.value) || [] }; // 标记正在请求数据 this.requesting = false; diff --git a/src/widget/multiselectlist/multiselectlist.insert.js b/src/widget/multiselectlist/multiselectlist.insert.js index 3311d3536..cc905c88f 100644 --- a/src/widget/multiselectlist/multiselectlist.insert.js +++ b/src/widget/multiselectlist/multiselectlist.insert.js @@ -15,7 +15,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, { BI.MultiSelectInsertList.superclass._init.apply(this, arguments); var self = this, o = this.options; - this.storeValue = this._assertValue(o.value || {}); + this.storeValue = this._assertValue(BI.deepClone(o.value) || {}); var assertShowValue = function () { BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue)); diff --git a/src/widget/multiselectlist/multiselectlist.insert.nobar.js b/src/widget/multiselectlist/multiselectlist.insert.nobar.js index e2c8f2008..be87999ad 100644 --- a/src/widget/multiselectlist/multiselectlist.insert.nobar.js +++ b/src/widget/multiselectlist/multiselectlist.insert.nobar.js @@ -16,7 +16,7 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, { var self = this, o = this.options; this.storeValue = { type: BI.Selection.Multi, - value: o.value || [] + value: BI.deepClone(o.value) || [] }; var assertShowValue = function () { @@ -363,4 +363,4 @@ BI.extend(BI.MultiSelectInsertNoBarList, { }); BI.MultiSelectInsertNoBarList.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multi_select_insert_no_bar_list", BI.MultiSelectInsertNoBarList); \ No newline at end of file +BI.shortcut("bi.multi_select_insert_no_bar_list", BI.MultiSelectInsertNoBarList); diff --git a/src/widget/multiselectlist/multiselectlist.js b/src/widget/multiselectlist/multiselectlist.js index eb0baaed1..7255963df 100644 --- a/src/widget/multiselectlist/multiselectlist.js +++ b/src/widget/multiselectlist/multiselectlist.js @@ -15,7 +15,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, { BI.MultiSelectList.superclass._init.apply(this, arguments); var self = this, o = this.options; - this.storeValue = {}; + this.storeValue = this._assertValue(BI.deepClone(o.value) || {}); var assertShowValue = function () { BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue)); @@ -31,6 +31,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, { logic: { dynamic: false }, + value: o.value, isDefaultInit: true, // onLoaded: o.onLoaded, el: {} @@ -198,6 +199,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, { val || (val = {}); val.type || (val.type = BI.Selection.Multi); val.value || (val.value = []); + return val; }, _makeMap: function (values) { diff --git a/src/widget/multitree/multi.tree.combo.js b/src/widget/multitree/multi.tree.combo.js index f222e6f6e..1b533525d 100644 --- a/src/widget/multitree/multi.tree.combo.js +++ b/src/widget/multitree/multi.tree.combo.js @@ -80,6 +80,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { }; self.trigger.getSearcher().setState(val); self.numberCounter.setButtonChecked(val); + self.storeValue = { value: self.combo.getValue() }; self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM, self.combo.getValue()); } }, { diff --git a/src/widget/multitree/multi.tree.insert.combo.js b/src/widget/multitree/multi.tree.insert.combo.js index 5159c60dd..692505da0 100644 --- a/src/widget/multitree/multi.tree.insert.combo.js +++ b/src/widget/multitree/multi.tree.insert.combo.js @@ -97,7 +97,8 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { }; self.trigger.getSearcher().setState(val); self.numberCounter.setButtonChecked(val); - self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue()); + self.storeValue = { value: self.combo.getValue() }; + self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.getValue()); } }, { eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, diff --git a/src/widget/multitree/multi.tree.list.combo.js b/src/widget/multitree/multi.tree.list.combo.js index e22c5a7e0..bf7eaaf78 100644 --- a/src/widget/multitree/multi.tree.list.combo.js +++ b/src/widget/multitree/multi.tree.list.combo.js @@ -114,7 +114,8 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { }; self.trigger.getSearcher().setState(val); self.numberCounter.setButtonChecked(val); - self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue()); + self.storeValue = { value: self.combo.getValue() }; + self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.getValue()); } }, { eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, diff --git a/src/widget/numbereditor/number.editor.js b/src/widget/numbereditor/number.editor.js index 596105947..3e99c6677 100644 --- a/src/widget/numbereditor/number.editor.js +++ b/src/widget/numbereditor/number.editor.js @@ -10,6 +10,9 @@ BI.NumberEditor = BI.inherit(BI.Widget, { valueFormatter: function (v) { return v; }, + valueParser: function (v) { + return v; + }, value: 0, allowBlank: false, errorText: "", @@ -30,14 +33,19 @@ BI.NumberEditor = BI.inherit(BI.Widget, { value: o.valueFormatter(o.value), validationChecker: function (v) { // 不设置validationChecker就自动检测 - if(o.validationChecker === BI.emptyFn && !self._checkValueInRange(v)) { + var parsedValue = o.valueParser(v); + if (o.validationChecker === BI.emptyFn && !self._checkValueInRange(parsedValue)) { return false; } - return o.validationChecker(v); + return o.validationChecker(parsedValue); }, errorText: o.errorText }); this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { + // 大多数时候valueFormatter往往需要配合valueParser一起使用 + var value = this.getValue(); + var parsedValue = o.valueParser(value); + this.setValue(o.valueFormatter(parsedValue)); self.fireEvent(BI.NumberEditor.EVENT_CHANGE); }); this.editor.on(BI.TextEditor.EVENT_ERROR, function () { @@ -57,6 +65,7 @@ BI.NumberEditor = BI.inherit(BI.Widget, { type: "bi.icon_button", 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" }); this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { @@ -68,6 +77,7 @@ BI.NumberEditor = BI.inherit(BI.Widget, { type: "bi.icon_button", 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" }); this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { @@ -154,4 +164,4 @@ BI.NumberEditor = BI.inherit(BI.Widget, { }); BI.NumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.NumberEditor.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.number_editor", BI.NumberEditor); \ No newline at end of file +BI.shortcut("bi.number_editor", BI.NumberEditor); diff --git a/src/widget/singleslider/singleslider.js b/src/widget/singleslider/singleslider.js index ea51dbace..a330115b9 100644 --- a/src/widget/singleslider/singleslider.js +++ b/src/widget/singleslider/singleslider.js @@ -16,7 +16,20 @@ BI.SingleSlider = BI.inherit(BI.Single, { props: { baseCls: "bi-single-slider bi-slider-track", digit: false, - unit: "" + unit: "", + value: "", + min: 0, + max: 100, + }, + + beforeMount: function () { + const { value, min, max } = this.options; + this.setMinAndMax({ + min, + max, + }); + this.setValue(value); + this.populate(); }, render: function () { @@ -340,4 +353,4 @@ BI.SingleSlider = BI.inherit(BI.Single, { } }); BI.SingleSlider.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.single_slider", BI.SingleSlider); \ No newline at end of file +BI.shortcut("bi.single_slider", BI.SingleSlider); diff --git a/src/widget/singleslider/singleslider.label.js b/src/widget/singleslider/singleslider.label.js index fce46f013..d6b8aa639 100644 --- a/src/widget/singleslider/singleslider.label.js +++ b/src/widget/singleslider/singleslider.label.js @@ -13,16 +13,27 @@ BI.SingleSliderLabel = BI.inherit(BI.Single, { TRACK_GAP_HALF: 7, TRACK_GAP: 14 }, - _defaultConfig: function () { - return BI.extend(BI.SingleSliderLabel.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-slider-label bi-slider-track", - digit: false, - unit: "" + + props: { + baseCls: "bi-single-slider-label bi-slider-track", + digit: false, + unit: "", + value: "", + min: 0, + max: 100, + }, + + beforeMount: function () { + const { value, min, max } = this.options; + this.setMinAndMax({ + min, + max, }); + this.setValue(value); + this.populate(); }, - _init: function () { - BI.SingleSliderLabel.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; var c = this._constant; this.enable = false; @@ -83,9 +94,8 @@ BI.SingleSliderLabel = BI.inherit(BI.Single, { }); this._setVisible(false); - BI.createWidget({ + return ({ type: "bi.absolute", - element: this, items: [{ el: { type: "bi.vertical", @@ -308,4 +318,4 @@ BI.SingleSliderLabel = BI.inherit(BI.Single, { } }); BI.SingleSliderLabel.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.single_slider_label", BI.SingleSliderLabel); \ No newline at end of file +BI.shortcut("bi.single_slider_label", BI.SingleSliderLabel); diff --git a/src/widget/singleslider/singleslider.normal.js b/src/widget/singleslider/singleslider.normal.js index 2ba74c8b9..095a5fadf 100644 --- a/src/widget/singleslider/singleslider.normal.js +++ b/src/widget/singleslider/singleslider.normal.js @@ -16,16 +16,27 @@ BI.SingleSliderNormal = BI.inherit(BI.Single, { props: { baseCls: "bi-single-slider-normal bi-slider-track", - minMax: { - min: 0, - max: 100 - } + min: 0, + max: 100, + value: "", // color: "#3f8ce8" }, + beforeMount: function () { + const { value, min, max } = this.options; + this.setMinAndMax({ + min, + max, + }); + this.setValue(value); + this.populate(); + }, + render: function () { var self = this; + var o = this.options; var c = this._constant; + var track = this._createTrack(); this.slider = BI.createWidget({ type: "bi.single_slider_button" @@ -282,4 +293,4 @@ BI.SingleSliderNormal = BI.inherit(BI.Single, { } }); BI.SingleSliderNormal.EVENT_DRAG = "EVENT_DRAG"; -BI.shortcut("bi.single_slider_normal", BI.SingleSliderNormal); \ No newline at end of file +BI.shortcut("bi.single_slider_normal", BI.SingleSliderNormal); diff --git a/src/widget/time/time.trigger.js b/src/widget/time/time.trigger.js index cd8e25cd4..6b089fa86 100644 --- a/src/widget/time/time.trigger.js +++ b/src/widget/time/time.trigger.js @@ -23,12 +23,13 @@ DEFAULT_HOUR: "00" }, - props: { + props: () => ({ extraCls: "bi-time-trigger", value: {}, format: "", - allowEdit: false - }, + allowEdit: false, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + }), render: function () { var self = this, o = this.options; @@ -52,7 +53,7 @@ value: this._formatValue(o.value), hgap: 4, allowBlank: true, - watermark: BI.isKey(o.watermark) ? o.watermark : BI.i18nText("BI-Basic_Unrestricted"), + watermark: o.watermark, title: BI.bind(this._getTitle, this), listeners: [{ eventName: "EVENT_KEY_DOWN", @@ -185,7 +186,7 @@ focus: function () { this.editor.focus(); }, - + blur: function () { this.editor.blur(); }, @@ -195,4 +196,4 @@ } }); BI.shortcut("bi.time_trigger", BI.TimeTrigger); -})(); \ No newline at end of file +})(); diff --git a/src/widget/timeinterval/dateinterval.js b/src/widget/timeinterval/dateinterval.js index e20188d37..f6b2176c6 100644 --- a/src/widget/timeinterval/dateinterval.js +++ b/src/widget/timeinterval/dateinterval.js @@ -24,8 +24,8 @@ BI.DateInterval = BI.inherit(BI.Single, { BI.DateInterval.superclass._init.apply(this, arguments); o.value = o.value || {}; - this.left = this._createCombo(o.value.start); - this.right = this._createCombo(o.value.end); + this.left = this._createCombo(o.value.start, o.watermark?.start); + this.right = this._createCombo(o.value.end, o.watermark?.end); this.label = BI.createWidget({ type: "bi.label", height: o.height, @@ -65,7 +65,7 @@ BI.DateInterval = BI.inherit(BI.Single, { }); }, - _createCombo: function (v) { + _createCombo: function (v, watermark) { var self = this, o = this.options; var combo = BI.createWidget({ type: "bi.dynamic_date_combo", @@ -74,7 +74,7 @@ BI.DateInterval = BI.inherit(BI.Single, { maxDate: o.maxDate, simple: o.simple, behaviors: o.behaviors, - watermark: o.watermark, + watermark: watermark, value: v, height: o.height, listeners: [{ diff --git a/src/widget/timeinterval/timeinterval.js b/src/widget/timeinterval/timeinterval.js index 95fd88bfe..3910c77e8 100644 --- a/src/widget/timeinterval/timeinterval.js +++ b/src/widget/timeinterval/timeinterval.js @@ -24,8 +24,8 @@ BI.TimeInterval = BI.inherit(BI.Single, { BI.TimeInterval.superclass._init.apply(this, arguments); o.value = o.value || {}; - this.left = this._createCombo(o.value.start); - this.right = this._createCombo(o.value.end); + this.left = this._createCombo(o.value.start, o.watermark?.start); + this.right = this._createCombo(o.value.end, o.watermark?.end); this.label = BI.createWidget({ type: "bi.label", height: o.height, @@ -65,7 +65,7 @@ BI.TimeInterval = BI.inherit(BI.Single, { }); }, - _createCombo: function (v) { + _createCombo: function (v, watermark) { var self = this, o = this.options; var combo = BI.createWidget({ type: "bi.dynamic_date_time_combo", @@ -74,7 +74,7 @@ BI.TimeInterval = BI.inherit(BI.Single, { minDate: o.minDate, maxDate: o.maxDate, behaviors: o.behaviors, - watermark: o.watermark, + watermark: watermark, value: v, height: o.height, }); @@ -202,4 +202,4 @@ BI.TimeInterval = BI.inherit(BI.Single, { BI.TimeInterval.EVENT_VALID = "EVENT_VALID"; BI.TimeInterval.EVENT_ERROR = "EVENT_ERROR"; BI.TimeInterval.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.time_interval", BI.TimeInterval); \ No newline at end of file +BI.shortcut("bi.time_interval", BI.TimeInterval); diff --git a/src/widget/timeinterval/timeperiods.js b/src/widget/timeinterval/timeperiods.js index 45c5a970f..5a0edf56d 100644 --- a/src/widget/timeinterval/timeperiods.js +++ b/src/widget/timeinterval/timeperiods.js @@ -51,7 +51,7 @@ ref: function (_ref) { self.left = _ref; } - }, this._createCombo(o.value.start)), + }, this._createCombo(o.value.start, o.watermark?.start)), left: this.constants.offset, right: 0, top: 0, @@ -64,7 +64,7 @@ ref: function (_ref) { self.right = _ref; } - }, this._createCombo(o.value.end)), + }, this._createCombo(o.value.end, o.watermark?.end)), left: 0, right: this.constants.offset, top: 0, @@ -80,13 +80,14 @@ }; }, - _createCombo: function (v) { + _createCombo: function (v, watermark) { var self = this; var o = this.options; return { type: "bi.time_combo", value: v, height: o.height, + watermark: watermark, listeners: [{ eventName: BI.TimeCombo.EVENT_BEFORE_POPUPVIEW, action: function () { @@ -119,4 +120,4 @@ BI.TimePeriods.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.TimePeriods.EVENT_CHANGE = "EVENT_CHANGE"; BI.shortcut("bi.time_periods", BI.TimePeriods); -})(); \ No newline at end of file +})(); diff --git a/src/widget/yearinterval/yearinterval.js b/src/widget/yearinterval/yearinterval.js index 7c27f24f4..9f48d7f5f 100644 --- a/src/widget/yearinterval/yearinterval.js +++ b/src/widget/yearinterval/yearinterval.js @@ -23,8 +23,8 @@ BI.YearInterval = BI.inherit(BI.Single, { var self = this, o = this.options; o.value = o.value || {}; - this.left = this._createCombo(o.value.start); - this.right = this._createCombo(o.value.end); + this.left = this._createCombo(o.value.start, o.watermark?.start); + this.right = this._createCombo(o.value.end, o.watermark?.end); return [{ type: "bi.center", @@ -63,7 +63,7 @@ BI.YearInterval = BI.inherit(BI.Single, { }] }, - _createCombo: function (v) { + _createCombo: function (v, watermark) { var self = this, o = this.options; var combo = BI.createWidget({ type: "bi.dynamic_year_combo", @@ -73,6 +73,7 @@ BI.YearInterval = BI.inherit(BI.Single, { height: o.height, behaviors: o.behaviors, value: v, + watermark: watermark, listeners: [{ eventName: BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW, action: function () { @@ -206,4 +207,4 @@ BI.YearInterval.EVENT_VALID = "EVENT_VALID"; BI.YearInterval.EVENT_ERROR = "EVENT_ERROR"; BI.YearInterval.EVENT_CHANGE = "EVENT_CHANGE"; BI.YearInterval.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.year_interval", BI.YearInterval); \ No newline at end of file +BI.shortcut("bi.year_interval", BI.YearInterval); diff --git a/src/widget/yearmonth/card.static.yearmonth.js b/src/widget/yearmonth/card.static.yearmonth.js index 09ff4ac2f..251b5871c 100644 --- a/src/widget/yearmonth/card.static.yearmonth.js +++ b/src/widget/yearmonth/card.static.yearmonth.js @@ -9,13 +9,7 @@ BI.StaticYearMonthCard = BI.inherit(BI.Widget, { var self = this; // 纵向排列月 var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12]; - var items = []; - items.push(month.slice(0, 2)); - items.push(month.slice(2, 4)); - items.push(month.slice(4, 6)); - items.push(month.slice(6, 8)); - items.push(month.slice(8, 10)); - items.push(month.slice(10, 12)); + var items = BI.chunk(month, 2); return BI.map(items, function (i, item) { return BI.map(item, function (j, td) { return { @@ -57,10 +51,7 @@ BI.StaticYearMonthCard = BI.inherit(BI.Widget, { action: function () { var value = this.getValue(); self._checkMonthStatus(value); - self.setValue({ - year: value, - month: self.selectedMonth - }); + self._setYear(value); } }] }, { @@ -106,7 +97,8 @@ BI.StaticYearMonthCard = BI.inherit(BI.Widget, { var o = this.options; var minDate = BI.parseDateTime(o.min, "%Y-%X-%d"), maxDate = BI.parseDateTime(o.max, "%Y-%X-%d"); var minYear = minDate.getFullYear(), maxYear = maxDate.getFullYear(); - var minMonth = 0; var maxMonth = 11; + var minMonth = 0; + var maxMonth = 11; minYear === year && (minMonth = minDate.getMonth()); maxYear === year && (maxMonth = maxDate.getMonth()); var yearInvalid = year < minYear || year > maxYear; @@ -116,6 +108,22 @@ BI.StaticYearMonthCard = BI.inherit(BI.Widget, { }); }, + _setYear: function (year) { + var o = this.options; + + var dateVoid = BI.checkDateVoid(year, this.selectedMonth, 1, o.min, o.max); + + // 在切换年的时候,如果月份不在区间内了,取消选中 + if (BI.contains(["y", "m"], dateVoid[0])) { + this.selectedYear = year; + this.month.setValue(); + return; + } + + this.selectedYear = year; + this.month.setValue(this.selectedMonth); + }, + setMinDate: function (minDate) { if (this.options.min !== minDate) { this.options.min = minDate; diff --git a/src/widget/yearmonth/combo.yearmonth.js b/src/widget/yearmonth/combo.yearmonth.js index 45431225b..a6de2de6f 100644 --- a/src/widget/yearmonth/combo.yearmonth.js +++ b/src/widget/yearmonth/combo.yearmonth.js @@ -23,7 +23,8 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, { min: o.minDate, max: o.maxDate, height: o.height - border, - value: o.value || "" + value: o.value || "", + watermark: o.watermark, }); this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN, function () { self.combo.isViewVisible() && self.combo.hideView(); diff --git a/src/widget/yearmonth/trigger.yearmonth.js b/src/widget/yearmonth/trigger.yearmonth.js index 56a6b420a..7995a007b 100644 --- a/src/widget/yearmonth/trigger.yearmonth.js +++ b/src/widget/yearmonth/trigger.yearmonth.js @@ -5,12 +5,16 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { iconWidth: 24 }, - props: { + props: () => ({ extraCls: "bi-year-month-trigger", min: "1900-01-01", // 最小日期 max: "2099-12-31", // 最大日期 - height: 24 - }, + height: 24, + watermark: { + year: BI.i18nText("BI-Basic_Unrestricted"), + month: BI.i18nText("BI-Basic_Unrestricted"), + }, + }), beforeInit: function (callback) { var o = this.options; @@ -80,7 +84,7 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { quitChecker: function () { return false; }, - watermark: BI.i18nText("BI-Basic_Unrestricted"), + watermark: isYear ? o.watermark?.year : o.watermark.month, errorText: function (v) { var year = isYear ? v : self.yearEditor.getValue(); var month = isYear ? self.monthEditor.getValue() : v; @@ -288,4 +292,4 @@ BI.DynamicYearMonthTrigger.EVENT_START = "EVENT_START"; BI.DynamicYearMonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicYearMonthTrigger.EVENT_STOP = "EVENT_STOP"; BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger); \ No newline at end of file +BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger); diff --git a/src/widget/yearmonthinterval/yearmonthinterval.js b/src/widget/yearmonthinterval/yearmonthinterval.js index c915c51f3..85e982e22 100644 --- a/src/widget/yearmonthinterval/yearmonthinterval.js +++ b/src/widget/yearmonthinterval/yearmonthinterval.js @@ -19,8 +19,8 @@ BI.YearMonthInterval = BI.inherit(BI.Single, { BI.YearMonthInterval.superclass._init.apply(this, arguments); o.value = o.value || {}; - this.left = this._createCombo(o.value.start); - this.right = this._createCombo(o.value.end); + this.left = this._createCombo(o.value.start, o.watermark?.start); + this.right = this._createCombo(o.value.end, o.watermark?.end); this.label = BI.createWidget({ type: "bi.label", height: o.height, @@ -61,7 +61,7 @@ BI.YearMonthInterval = BI.inherit(BI.Single, { }); }, - _createCombo: function (v) { + _createCombo: function (v, watermark) { var self = this, o = this.options; var combo = BI.createWidget({ type: "bi.dynamic_year_month_combo", @@ -71,6 +71,7 @@ BI.YearMonthInterval = BI.inherit(BI.Single, { maxDate: o.maxDate, behaviors: o.behaviors, value: v, + watermark: watermark, listeners: [{ eventName: BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW, action: function () { diff --git a/src/widget/yearquarter/combo.yearquarter.js b/src/widget/yearquarter/combo.yearquarter.js index 16537990c..9ec93454b 100644 --- a/src/widget/yearquarter/combo.yearquarter.js +++ b/src/widget/yearquarter/combo.yearquarter.js @@ -26,7 +26,8 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, { min: o.minDate, max: o.maxDate, height: o.height - border, - value: o.value || "" + value: o.value || "", + watermark: o.watermark, }); this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN, function () { self.combo.isViewVisible() && self.combo.hideView(); diff --git a/src/widget/yearquarter/trigger.yearquarter.js b/src/widget/yearquarter/trigger.yearquarter.js index ea7cb6f4e..84bda3b3f 100644 --- a/src/widget/yearquarter/trigger.yearquarter.js +++ b/src/widget/yearquarter/trigger.yearquarter.js @@ -5,12 +5,16 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, { iconWidth: 24 }, - props: { + props: () => ({ extraCls: "bi-year-quarter-trigger", min: "1900-01-01", // 最小日期 max: "2099-12-31", // 最大日期 - height: 24 - }, + height: 24, + watermark: { + year: BI.i18nText("BI-Basic_Unrestricted"), + quarter: BI.i18nText("BI-Basic_Unrestricted"), + }, + }), _init: function () { BI.DynamicYearQuarterTrigger.superclass._init.apply(this, arguments); @@ -96,7 +100,7 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, { BI.getQuarter(end) ); }, - watermark: BI.i18nText("BI-Basic_Unrestricted"), + watermark: isYear ? o.watermark?.year : o.watermark?.quarter, hgap: c.hgap, vgap: c.vgap, allowBlank: true @@ -272,4 +276,4 @@ BI.DynamicYearQuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicYearQuarterTrigger.EVENT_STOP = "EVENT_STOP"; BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicYearQuarterTrigger.EVENT_VALID = "EVENT_VALID"; -BI.shortcut("bi.dynamic_year_quarter_trigger", BI.DynamicYearQuarterTrigger); \ No newline at end of file +BI.shortcut("bi.dynamic_year_quarter_trigger", BI.DynamicYearQuarterTrigger); diff --git a/src/widget/yearquarterinterval/yearquarterinterval.js b/src/widget/yearquarterinterval/yearquarterinterval.js index e148a92f0..f23134a09 100644 --- a/src/widget/yearquarterinterval/yearquarterinterval.js +++ b/src/widget/yearquarterinterval/yearquarterinterval.js @@ -23,8 +23,8 @@ BI.YearQuarterInterval = BI.inherit(BI.Single, { var self = this, o = this.options; o.value = o.value || {}; - this.left = this._createCombo(o.value.start); - this.right = this._createCombo(o.value.end); + this.left = this._createCombo(o.value.start, o.watermark?.start); + this.right = this._createCombo(o.value.end, o.watermark?.end); return [{ type: "bi.center", @@ -63,7 +63,7 @@ BI.YearQuarterInterval = BI.inherit(BI.Single, { }] }, - _createCombo: function (v) { + _createCombo: function (v, watermark) { var self = this, o = this.options; var combo = BI.createWidget({ type: "bi.dynamic_year_quarter_combo", @@ -73,6 +73,7 @@ BI.YearQuarterInterval = BI.inherit(BI.Single, { behaviors: o.behaviors, value: v, height: o.height, + watermark: watermark, listeners: [{ eventName: BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW, action: function () { @@ -204,4 +205,4 @@ BI.YearQuarterInterval.EVENT_VALID = "EVENT_VALID"; BI.YearQuarterInterval.EVENT_ERROR = "EVENT_ERROR"; BI.YearQuarterInterval.EVENT_CHANGE = "EVENT_CHANGE"; BI.YearQuarterInterval.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.year_quarter_interval", BI.YearQuarterInterval); \ No newline at end of file +BI.shortcut("bi.year_quarter_interval", BI.YearQuarterInterval); diff --git a/typescript/base/single/button/buttons/button.ts b/typescript/base/single/button/buttons/button.ts index 9b357ae0c..102db20cb 100644 --- a/typescript/base/single/button/buttons/button.ts +++ b/typescript/base/single/button/buttons/button.ts @@ -10,8 +10,11 @@ export declare class Button extends BasicButton { minWidth?: number; readonly?: boolean; iconCls?: string; - level?: 'common' | 'success' | 'warning' |'ignore', + level?: 'common' | 'success' | 'warning' | 'error' | 'ignore', block?: boolean; // 是否块状显示,即不显示边框,没有最小宽度的限制 + loading?: boolean, // 是否处于加载中 + light?: boolean, // 是否使用浅色 + plain?: boolean, // 是否是朴素按钮,和 clear 的区别是 plain 有悬浮效果 clear?: boolean; // 是否去掉边框和背景 ghost?: boolean; // 是否幽灵显示, 即正常状态无背景 iconGap?: number; diff --git a/typescript/base/single/label/abstract.label.ts b/typescript/base/single/label/abstract.label.ts index 431d79ab6..60d6ee8fc 100644 --- a/typescript/base/single/label/abstract.label.ts +++ b/typescript/base/single/label/abstract.label.ts @@ -10,7 +10,7 @@ export declare class AbstractLabel extends Single { textHeight?: number | null; highLight?: boolean; handler?: Function | null; - text?: string; + text?: string | ((context: any) => string); } & Single['props'] doRedMark(...args: any[]): void; diff --git a/typescript/shims-tsx.ts b/typescript/shims-tsx.ts index e77dceffb..cabf21b78 100644 --- a/typescript/shims-tsx.ts +++ b/typescript/shims-tsx.ts @@ -13,6 +13,12 @@ interface UIProps { bgap: number; vgap: number; hgap: number; + _rgap: number; + _lgap: number; + _tgap: number; + _bgap: number; + _hgap: number; + _vgap: number; inset: number | string; } diff --git a/webpack/attachments.js b/webpack/attachments.js index cf26e9d09..94274e1b3 100644 --- a/webpack/attachments.js +++ b/webpack/attachments.js @@ -7,8 +7,13 @@ const workerCompact = './dist/fix/worker.compact.js'; const lodashJs = "src/core/1.lodash.js"; const jqueryJs = "src/core/platform/web/jquery/_jquery.js"; +const runtimePolyfill = ["@babel/polyfill", "es6-promise/auto"]; + const basicAttachmentMap = { - polyfill: sync(["src/core/0.foundation.js", "src/polyfill/**/*.js"]).concat(["@babel/polyfill", "es6-promise/auto"]), + polyfill: sync([ + "src/core/0.foundation.js", + "src/polyfill/**/*.js", + ]).concat(runtimePolyfill), core: sync([ "src/less/core/**/*.less", "src/less/theme/**/*.less", @@ -202,6 +207,7 @@ const fineuiProxy = [].concat( ); const fineuiWithoutJqueryAndPolyfillJs = [].concat( + runtimePolyfill, sync([ "src/core/0.foundation.js", lodashJs, @@ -227,13 +233,13 @@ const demo = [].concat( basicAttachmentMap.polyfill, basicAttachmentMap.core, basicAttachmentMap.fix, + basicAttachmentMap.config, basicAttachmentMap.base, basicAttachmentMap.case, basicAttachmentMap.widget, basicAttachmentMap.router, sync(["public/less/app.less", "public/less/**/*.less"]), [fixCompact, workerCompact], - basicAttachmentMap.config, basicAttachmentMap.ts, sync(["demo/less/*.less", "demo/less/**/*.less", "demo/app.js", "demo/js/**/*.js", "demo/config.js"]), );