diff --git a/changelog.md b/changelog.md index f6824f6d6..dbcca9ccd 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,19 @@ # 更新日志 + +3.0(2022-05) +- 下拉选择框支持清空 + +3.0(2022-03) +- 支持响应式 +- 全面支持Typescript +- 增加JSX支持 +- 布局组件支持更多动态特性 +- 底层API支持动画 +- 增加WebWorker支持 +- 支持路由 +- 插件支持版本控制 +- Fix数据流支持proxy版本 + 2.0(2022-01) - 提供自定义表单 diff --git a/demo/less/face.less b/demo/less/face.less index 6c0577491..b9c4fe499 100644 --- a/demo/less/face.less +++ b/demo/less/face.less @@ -1,4 +1,4 @@ -@import "index"; +@import "index.less"; .demo-face { .face-config { diff --git a/demo/less/index.less b/demo/less/index.less index 6c2ad3201..9c7a9a367 100644 --- a/demo/less/index.less +++ b/demo/less/index.less @@ -1 +1 @@ -@import "../../src/less/index"; \ No newline at end of file +@import "../../src/less/index.less"; \ No newline at end of file diff --git a/demo/less/main.less b/demo/less/main.less index 184d3c197..4e6cb4376 100644 --- a/demo/less/main.less +++ b/demo/less/main.less @@ -1,4 +1,4 @@ -@import "index"; +@import "index.less"; .layout-bg-white { background-color: #ffffff; } diff --git a/demo/less/north.less b/demo/less/north.less index 1991671f5..0114afd65 100644 --- a/demo/less/north.less +++ b/demo/less/north.less @@ -1,4 +1,4 @@ -@import "index"; +@import "index.less"; .demo-north { background-color: #3c8dbc; diff --git a/demo/less/preview.less b/demo/less/preview.less index 50f9e79dc..600ec4476 100644 --- a/demo/less/preview.less +++ b/demo/less/preview.less @@ -1,4 +1,4 @@ -@import "index"; +@import "index.less"; .demo-preview { } \ No newline at end of file diff --git a/demo/less/vm.less b/demo/less/vm.less index 22ff13396..45094646a 100644 --- a/demo/less/vm.less +++ b/demo/less/vm.less @@ -1,4 +1,4 @@ -@import "index"; +@import "index.less"; .mvc-button { &:hover, &.hover { diff --git a/demo/less/west.less b/demo/less/west.less index a3ed9a55e..c9f6477ee 100644 --- a/demo/less/west.less +++ b/demo/less/west.less @@ -1,4 +1,4 @@ -@import "index"; +@import "index.less"; .demo-west { } diff --git a/package.json b/package.json index 42955fcce..30ec11f85 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220427103402", + "version": "2.0.20220513150627", "description": "fineui", "main": "dist/fineui.min.js", "types": "dist/lib/index.d.ts", diff --git a/private/less/app.less b/private/less/app.less index d086387ac..dd4d62029 100644 --- a/private/less/app.less +++ b/private/less/app.less @@ -1,2 +1,2 @@ -@import "../../src/less/resource/app"; -@import "var"; +@import "../../src/less/resource/app.less"; +@import "var.less"; diff --git a/private/less/background.less b/private/less/background.less index 996147127..0897148ea 100644 --- a/private/less/background.less +++ b/private/less/background.less @@ -1,2 +1,2 @@ -@import "../../src/less/resource/background"; -@import "var"; +@import "../../src/less/resource/background.less"; +@import "var.less"; diff --git a/private/less/font.less b/private/less/font.less index c236f82ed..d7399c46e 100644 --- a/private/less/font.less +++ b/private/less/font.less @@ -1,2 +1,2 @@ -@import "../../src/less/resource/font"; -@import "var"; +@import "../../src/less/resource/font.less"; +@import "var.less"; diff --git a/private/less/icon.less b/private/less/icon.less index 43e3123c5..8aa44a2ae 100644 --- a/private/less/icon.less +++ b/private/less/icon.less @@ -1,5 +1,5 @@ -@import "../../src/less/resource/icon"; -@import "var"; +@import "../../src/less/resource/icon.less"; +@import "var.less"; diff --git a/public/less/app.less b/public/less/app.less index d086387ac..dd4d62029 100644 --- a/public/less/app.less +++ b/public/less/app.less @@ -1,2 +1,2 @@ -@import "../../src/less/resource/app"; -@import "var"; +@import "../../src/less/resource/app.less"; +@import "var.less"; diff --git a/public/less/background.less b/public/less/background.less index 996147127..0897148ea 100644 --- a/public/less/background.less +++ b/public/less/background.less @@ -1,2 +1,2 @@ -@import "../../src/less/resource/background"; -@import "var"; +@import "../../src/less/resource/background.less"; +@import "var.less"; diff --git a/public/less/font.less b/public/less/font.less index c236f82ed..d7399c46e 100644 --- a/public/less/font.less +++ b/public/less/font.less @@ -1,2 +1,2 @@ -@import "../../src/less/resource/font"; -@import "var"; +@import "../../src/less/resource/font.less"; +@import "var.less"; diff --git a/public/less/icon.less b/public/less/icon.less index 43e3123c5..8aa44a2ae 100644 --- a/public/less/icon.less +++ b/public/less/icon.less @@ -1,5 +1,5 @@ -@import "../../src/less/resource/icon"; -@import "var"; +@import "../../src/less/resource/icon.less"; +@import "var.less"; diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index 41e1ca0de..e868a5747 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -206,14 +206,29 @@ BI.Input = BI.inherit(BI.Single, { this._lastValue = this.getValue(); }, - _checkValidationOnValueChange: function () { - var o = this.options; + _checkValidationOnValueChange: function (callback) { + var self = this, o = this.options; var v = this.getValue(); - this.setValid( - (o.allowBlank === true && BI.trim(v) == "") || ( - BI.isNotEmptyString(BI.trim(v)) && o.validationChecker.apply(this, [BI.trim(v)]) !== false - ) - ); + if (o.allowBlank === true && BI.trim(v) == "") { + this.setValid(true); + callback && callback(); + return; + } + if (BI.trim(v) == "") { + this.setValid(false); + callback && callback(); + return; + } + var checker = o.validationChecker.apply(this, [BI.trim(v)]); + if (checker instanceof Promise) { + checker.then(function (validate) { + self.setValid(validate !== false); + callback && callback(); + }) + } else { + this.setValid(checker !== false); + callback && callback(); + } }, focus: function () { @@ -245,14 +260,16 @@ BI.Input = BI.inherit(BI.Single, { }, setValue: function (textValue) { + var self = this; this.element.val(textValue); - BI.nextTick(BI.bind(function () { - this._checkValidationOnValueChange(); - this._defaultState(); - if (this.isValid()) { - this._lastValidValue = this._lastSubmitValue = this.getValue(); - } - }, this)); + BI.nextTick(function () { + self._checkValidationOnValueChange(function () { + self._defaultState(); + if (self.isValid()) { + self._lastValidValue = self._lastSubmitValue = self.getValue(); + } + }); + }); }, getValue: function () { diff --git a/src/case/button/node/node.plus.js b/src/case/button/node/node.plus.js index ec38ca0e0..708ad4300 100644 --- a/src/case/button/node/node.plus.js +++ b/src/case/button/node/node.plus.js @@ -15,7 +15,6 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, { id: "", pId: "", open: false, - iconWrapperWidth: null, height: 24 }); }, diff --git a/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js b/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js index ac3fad335..b3e6ddc95 100644 --- a/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js +++ b/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js @@ -11,6 +11,7 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, { items: [], tipType: "", warningTitle: "", + allowClear: false, }, render: function () { @@ -21,105 +22,81 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, { o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { self.populate(newValue); }) : o.items; + return { - type: "bi.absolute", - items: [{ + type: "bi.combo", + cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-focus-shadow", + container: o.container, + adjustLength: 2, + toggle: false, + ref: function () { + self.combo = this; + }, + el: { + type: "bi.search_text_value_trigger", + cls: "search-text-value-trigger", + watermark: o.watermark, + ref: function () { + self.trigger = this; + }, + items: o.items, + height: o.height - (o.simple ? 1 : 2), + text: o.text, + defaultText: o.defaultText, + value: o.value, + tipType: o.tipType, + warningTitle: o.warningTitle, + title: o.title, + allowClear: o.allowClear, + listeners: [{ + eventName: BI.SearchTextValueTrigger.EVENT_CHANGE, + action: function () { + self.setValue(this.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } + }, { + eventName: BI.SearchTextValueTrigger.EVENT_CLEAR, + action: function () { + self._clear(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } + }] + }, + popup: { el: { - type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-focus-shadow", - container: o.container, - adjustLength: 2, - toggle: false, + type: "bi.text_value_combo_popup", + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + value: o.value, + items: o.items, ref: function () { - self.combo = this; - }, - el: { - type: "bi.search_text_value_trigger", - cls: "search-text-value-trigger", - watermark: o.watermark, - ref: function () { - self.trigger = this; - }, - items: o.items, - height: o.height - (o.simple ? 1 : 2), - text: o.text, - defaultText: o.defaultText, - value: o.value, - tipType: o.tipType, - warningTitle: o.warningTitle, - title: o.title, - listeners: [{ - eventName: BI.SearchTextValueTrigger.EVENT_CHANGE, - action: function () { - self.setValue(this.getValue()); - self.combo.hideView(); - self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); - } - }] - }, - popup: { - el: { - type: "bi.text_value_combo_popup", - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, - value: o.value, - items: o.items, - ref: function () { - self.popup = this; - self.trigger.getSearcher().setAdapter(self.popup); - }, - listeners: [{ - eventName: BI.TextValueComboPopup.EVENT_CHANGE, - action: function () { - self.setValue(this.getValue()); - self.combo.hideView(); - self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); - } - }] - }, - value: o.value, - maxHeight: 252, - minHeight: 25 + self.popup = this; + self.trigger.getSearcher().setAdapter(self.popup); }, listeners: [{ - eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, - action: function () { - self.trigger.stopEditing(); - } - }, { - eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, + eventName: BI.TextValueComboPopup.EVENT_CHANGE, action: function () { - self.fireEvent(BI.SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW); - } - }], - hideChecker: function (e) { - return self.triggerBtn.element.find(e.target).length === 0; - } - }, - left: 0, - right: 0, - bottom: 0, - top: 0 - }, { - el: { - type: "bi.trigger_icon_button", - cls: "trigger-icon-button", - ref: function () { - self.triggerBtn = this; - }, - width: o.height, - height: o.height, - handler: function () { - if (self.combo.isViewVisible()) { + self.setValue(this.getValue()); self.combo.hideView(); - } else { - self.combo.showView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); } - } + }] }, - right: 0, - bottom: 0, - top: 0 - }] + value: o.value, + maxHeight: 252, + minHeight: 25 + }, + listeners: [{ + eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, + action: function () { + self.trigger.stopEditing(); + } + }, { + eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, + action: function () { + self.fireEvent(BI.SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW); + } + }], }; }, @@ -130,6 +107,11 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, { } }, + _clear: function () { + this.trigger.attr("text", ""); + this.setValue([]); + }, + _checkError: function (v) { if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { this.trigger.options.tipType = "success"; diff --git a/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js b/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js index 7e84a4452..2dd67933a 100644 --- a/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js +++ b/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js @@ -5,16 +5,32 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { props: function () { return { - extraCls: "bi-search-text-value-trigger", + baseCls: "bi-search-text-value-trigger", height: 24, - watermark: BI.i18nText("BI-Basic_Search") + watermark: BI.i18nText("BI-Basic_Search"), + allowClear: false, }; }, render: function () { var self = this, o = this.options; + + var triggerButton = { + type: "bi.trigger_icon_button", + cls: "trigger-icon-button", + ref: function () { + self.triggerBtn = this; + }, + width: o.height, + height: o.height, + width: 24, + }; + + var stateText = this._digest(o.value, o.items); + return { - type: "bi.htape", + type: "bi.horizontal_fill", + columnSize: ["fill", 24], items: [ { el: { @@ -30,7 +46,7 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { }, watermark: o.watermark, defaultText: o.defaultText, - text: this._digest(o.value, o.items), + text: stateText, value: o.value, height: o.height, tipText: "" @@ -55,10 +71,30 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { }] } }, { - el: { - type: "bi.layout", - width: 24 - }, + el: o.allowClear ? { + type: "bi.vertical_adapt", + horizontalAlign: "left", + scrollable: false, + items: [ + { + el: { + type: "bi.icon_button", + ref: function (_ref) { + self.clearBtn = _ref; + }, + cls: "close-h-font " + (o.allowClear ? "clear-button" : ""), + stopPropagation: true, + invisible: !BI.isNotEmptyString(stateText), + width: o.height, + handler: function () { + self.fireEvent(BI.SearchTextValueTrigger.EVENT_CLEAR); + }, + }, + }, { + el: triggerButton, + } + ] + } : triggerButton, width: 24 } ] @@ -100,7 +136,9 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { }, setValue: function (vals) { - this._setState(this._digest(vals, this.options.items)); + var stateText = this._digest(vals, this.options.items); + this._setState(stateText); + this.options.allowClear && this.clearBtn.setVisible(BI.isNotEmptyString(stateText)); }, getValue: function () { @@ -111,4 +149,5 @@ BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP"; BI.SearchTextValueTrigger.EVENT_START = "EVENT_START"; BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.SearchTextValueTrigger.EVENT_CLEAR = "EVENT_CLEAR"; BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger); diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index 6b9ef321b..c49785126 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -12,6 +12,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, text: "", value: "", + allowClear: false, }); }, @@ -33,7 +34,17 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { height: o.height, text: o.text, value: o.value, - warningTitle: o.warningTitle + warningTitle: o.warningTitle, + allowClear: o.allowClear, + listeners: [ + { + eventName: BI.SelectTextTrigger.EVENT_CLEAR, + action: function () { + self._clear(); + self.fireEvent(BI.TextValueCombo.EVENT_CHANGE); + } + } + ], }); this.popup = BI.createWidget({ type: "bi.text_value_combo_popup", @@ -62,15 +73,20 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { minHeight: 25 } }); - if(BI.isKey(o.value)) { + if (BI.isKey(o.value)) { this._checkError(o.value); } }, + _clear: function () { + this.setValue(); + }, + _checkError: function (v) { - if(BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { + if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { this.trigger.options.tipType = "success"; - this.element.removeClass("combo-error"); + this.element.removeClass("error"); + this.trigger.element.removeClass("error"); } else { v = BI.isArray(v) ? v : [v]; var result = BI.find(this.options.items, function (idx, item) { @@ -78,10 +94,12 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }); if (BI.isNull(result)) { this.trigger.setTipType("warning"); - this.element.removeClass("combo-error").addClass("combo-error"); + this.element.addClass("error"); + this.trigger.element.addClass("error"); } else { this.trigger.setTipType("success"); - this.element.removeClass("combo-error"); + this.element.removeClass("error"); + this.trigger.element.removeClass("error"); } } }, diff --git a/src/case/list/list.select.js b/src/case/list/list.select.js index 12037b9a9..bab4a15af 100644 --- a/src/case/list/list.select.js +++ b/src/case/list/list.select.js @@ -94,7 +94,7 @@ BI.SelectList = BI.inherit(BI.Widget, { var hasNext = this.list.hasNext(); var isAlreadyAllSelected = this.toolbar.isSelected(); var isHalf = selectLength > 0 && notSelectLength > 0; - var allSelected = isAlreadyAllSelected; + var allSelected = selectLength > 0 && notSelectLength <= 0 && (!hasNext || isAlreadyAllSelected); if (this.isAllSelected() === false) { hasNext && (isHalf = selectLength > 0); diff --git a/src/case/trigger/trigger.text.js b/src/case/trigger/trigger.text.js index e8ee789df..52da67200 100644 --- a/src/case/trigger/trigger.text.js +++ b/src/case/trigger/trigger.text.js @@ -7,25 +7,27 @@ */ BI.TextTrigger = BI.inherit(BI.Trigger, { - _defaultConfig: function () { + props: function () { var self = this; - var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-text-trigger", + return { + baseCls: "bi-text-trigger", height: 24, textHgap: 6, textCls: "", + allowClear: false, title: function () { return self.text.getText(); } - }); + }; }, - _init: function () { - BI.TextTrigger.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options, c = this._const; - this.text = BI.createWidget({ + var text = { type: "bi.label", + ref: function (_ref) { + self.text = _ref; + }, cls: "select-text-label" + (BI.isKey(o.textCls) ? (" " + o.textCls) : ""), textAlign: "left", height: o.height, @@ -39,32 +41,58 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { tgap: o.textTgap, bgap: o.textBgap, readonly: o.readonly - }); - this.trigerButton = BI.createWidget({ + }; + + var triggerButton = { type: "bi.trigger_icon_button", + ref: function (_ref) { + self.triggerButton = _ref; + }, width: o.triggerWidth || o.height - }); + }; - BI.createWidget({ - element: this, + return ({ type: "bi.horizontal_fill", + columnSize: ["fill", o.triggerWidth || o.height], items: [ { - el: this.text, + el: text, width: "fill" }, { - el: this.trigerButton, - width: o.triggerWidth || o.height + el: o.allowClear ? { + type: "bi.vertical_adapt", + horizontalAlign: "left", + scrollable: false, + items: [ + { + el: { + type: "bi.icon_button", + ref: function (_ref) { + self.clearBtn = _ref; + }, + cls: "close-h-font " + (o.allowClear ? "clear-button" : ""), + stopPropagation: true, + width: o.triggerWidth || o.height, + invisible: !BI.isNotEmptyString(o.text), + handler: function () { + self.fireEvent(BI.TextTrigger.EVENT_CLEAR); + }, + }, + }, { + el: triggerButton, + } + ] + } : triggerButton, } ] }); }, - getTextor: function() { + getTextor: function () { return this.text; }, - setTextCls: function(cls) { + setTextCls: function (cls) { var o = this.options; var oldCls = o.textCls; o.textCls = cls; @@ -73,6 +101,9 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { setText: function (text) { this.text.setText(text); + if (this.options.allowClear) { + this.clearBtn.setVisible(BI.isNotEmptyString(text)); + } }, setTipType: function (v) { @@ -80,4 +111,6 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { this.options.tipType = v; } }); + +BI.TextTrigger.EVENT_CLEAR = "EVENT_CLEAR"; BI.shortcut("bi.text_trigger", BI.TextTrigger); diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index 8b24c1c9c..5461292c1 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/src/case/trigger/trigger.text.select.js @@ -11,6 +11,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { return BI.extend(BI.SelectTextTrigger.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-select-text-trigger", height: 24, + allowClear: false, }); }, @@ -32,11 +33,21 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { textTgap: o.textTgap, textBgap: o.textBgap, tipType: o.tipType, - warningTitle: o.warningTitle + warningTitle: o.warningTitle, + allowClear: o.allowClear, + listeners: [ + { + eventName: BI.TextTrigger.EVENT_CLEAR, + action: function () { + self.setText(""); + self.fireEvent(BI.SelectTextTrigger.EVENT_CLEAR); + } + } + ] }); }, - _digest: function(vals, items){ + _digest: function (vals, items) { var o = this.options; vals = BI.isArray(vals) ? vals : [vals]; var result = []; @@ -51,15 +62,20 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { return { textCls: "", text: result.join(",") - } + }; } else { return { textCls: "bi-water-mark", text: BI.isFunction(o.text) ? o.text() : o.text - } + }; } }, + setText: function (text) { + this.options.text = text; + this.trigger.setText(text); + }, + setValue: function (vals) { var formatValue = this._digest(vals, this.options.items); this.trigger.setTextCls(formatValue.textCls); @@ -67,10 +83,11 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { }, setTipType: function (v) { + this.options.tipType = v; this.trigger.setTipType(v); }, - getTextor: function() { + getTextor: function () { return this.trigger.getTextor(); }, @@ -78,4 +95,6 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { this.options.items = items; } }); + +BI.SelectTextTrigger.EVENT_CLEAR = "EVENT_CLEAR"; BI.shortcut("bi.select_text_trigger", BI.SelectTextTrigger); diff --git a/src/core/system.js b/src/core/system.js index 123bd88be..652a9c256 100644 --- a/src/core/system.js +++ b/src/core/system.js @@ -7,6 +7,7 @@ !(function () { var system = { dependencies: {}, + layoutOptimize: false, responsiveMode: false, workerMode: false, size: { @@ -24,7 +25,7 @@ // 具体尺寸还没定,先写着 var sizeMap = { "S": 10, - "M" : 20, + "M": 20, "L": 24 }; @@ -44,6 +45,10 @@ system.workerMode = !!mode; }; + this.setLayoutOptimize = function (layoutOptimize) { + system.layoutOptimize = layoutOptimize; + }; + this.addDependency = function (moduleId, minVersion, maxVersion) { system.dependencies[moduleId] = { min: minVersion, @@ -77,6 +82,10 @@ return system.workerMode; }, + getLayoutOptimize: function () { + return system.layoutOptimize; + }, + getDependencies: function () { return system.dependencies; } diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 2bb053c6d..786e522d1 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -16,7 +16,7 @@ BI.Layout = BI.inherit(BI.Widget, { scrolly: false, // true, false items: [], innerHgap: 0, - innerVgap: 0, + innerVgap: 0 }; }, @@ -292,6 +292,43 @@ BI.Layout = BI.inherit(BI.Widget, { return (gap > 0 && gap < 1) ? (gap * 100).toFixed(1) + "%" : gap / BI.pixRatio + BI.pixUnit; }, + _optimiseItemLgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? item.lgap : item._lgap) || 0; + } + return (item._lgap || 0) + (item.lgap || 0); + }, + _optimiseItemRgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? item.rgap : item._rgap) || 0; + } + return (item._rgap || 0) + (item.rgap || 0); + }, + _optimiseItemTgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? item.tgap : item._tgap) || 0; + } + return (item._tgap || 0) + (item.tgap || 0); + }, + _optimiseItemBgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? item.bgap : item._bgap) || 0; + } + return (item._bgap || 0) + (item.bgap || 0); + }, + _optimiseItemHgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? item.hgap : item._hgap) || 0; + } + return (item._hgap || 0) + (item.hgap || 0); + }, + _optimiseItemVgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? item.vgap : item._vgap) || 0; + } + return (item._vgap || 0) + (item.vgap || 0); + }, + _handleGap: function (w, item, hIndex, vIndex) { var o = this.options; var innerLgap, innerRgap, innerTgap, innerBgap; @@ -304,26 +341,26 @@ BI.Layout = BI.inherit(BI.Widget, { innerTgap = vIndex === 0 ? o.innerVgap : 0; innerBgap = vIndex === o.items.length - 1 ? o.innerVgap : 0; } - if (o.vgap + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - var top = ((BI.isNull(vIndex) || vIndex === 0) ? o.vgap : 0) + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0); + if (o.vgap + o.tgap + innerTgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { + var top = ((BI.isNull(vIndex) || vIndex === 0) ? o.vgap : 0) + o.tgap + innerTgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); w.element.css({ "margin-top": this._optimiseGap(top) }); } - if (o.hgap + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - var left = ((BI.isNull(hIndex) || hIndex === 0) ? o.hgap : 0) + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0); + if (o.hgap + o.lgap + innerLgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { + var left = ((BI.isNull(hIndex) || hIndex === 0) ? o.hgap : 0) + o.lgap + innerLgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); w.element.css({ "margin-left": this._optimiseGap(left) }); } - if (o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - var right = o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0); + if (o.hgap + o.rgap + innerRgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { + var right = o.hgap + o.rgap + innerRgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); w.element.css({ "margin-right": this._optimiseGap(right) }); } - if (o.vgap + o.bgap + innerBgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - var bottom = o.vgap + o.bgap + innerBgap + (item.bgap || 0) + (item.vgap || 0); + if (o.vgap + o.bgap + innerBgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { + var bottom = o.vgap + o.bgap + innerBgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); w.element.css({ "margin-bottom": this._optimiseGap(bottom) }); @@ -337,27 +374,27 @@ BI.Layout = BI.inherit(BI.Widget, { innerLgap = innerRgap = o.innerHgap; innerTgap = index === 0 ? o.innerVgap : 0; innerBgap = index === o.items.length - 1 ? o.innerVgap : 0; - if (o.vgap + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - var top = (index === 0 ? o.vgap : 0) + (index === 0 ? o.tgap : 0) + innerTgap + (item.tgap || 0) + (item.vgap || 0); + if (o.vgap + o.tgap + innerTgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { + var top = (index === 0 ? o.vgap : 0) + (index === 0 ? o.tgap : 0) + innerTgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); w.element.css({ "margin-top": this._optimiseGap(top) }); } - if (o.hgap + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - var left = o.hgap + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0); + if (o.hgap + o.lgap + innerLgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { + var left = o.hgap + o.lgap + innerLgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); w.element.css({ "margin-left": this._optimiseGap(left) }); } - if (o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - var right = o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0); + if (o.hgap + o.rgap + innerRgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { + var right = o.hgap + o.rgap + innerRgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); w.element.css({ "margin-right": this._optimiseGap(right) }); } // 这里的代码是关键 - if (o.vgap + o.hgap + o.bgap + innerBgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - var bottom = (index === o.items.length - 1 ? o.vgap : o.hgap) + (index === o.items.length - 1 ? o.bgap : 0) + innerBgap + (item.bgap || 0) + (item.vgap || 0); + if (o.vgap + o.hgap + o.bgap + innerBgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { + var bottom = (index === o.items.length - 1 ? o.vgap : o.hgap) + (index === o.items.length - 1 ? o.bgap : 0) + innerBgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); w.element.css({ "margin-bottom": this._optimiseGap(bottom) }); diff --git a/src/core/wrapper/layout/adapt/absolute.center.js b/src/core/wrapper/layout/adapt/absolute.center.js index 67d37c4bc..14a122f00 100644 --- a/src/core/wrapper/layout/adapt/absolute.center.js +++ b/src/core/wrapper/layout/adapt/absolute.center.js @@ -30,10 +30,10 @@ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, { var w = BI.AbsoluteCenterLayout.superclass._addElement.apply(this, arguments); w.element.css({ position: "absolute", - left: this._optimiseGap(o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0)), - right: this._optimiseGap(o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)), - top: this._optimiseGap(o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)), - bottom: this._optimiseGap(o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)), + left: this._optimiseGap(o.hgap + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item)), + right: this._optimiseGap(o.hgap + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item)), + top: this._optimiseGap(o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item)), + bottom: this._optimiseGap(o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item)), margin: "auto" }); return w; diff --git a/src/core/wrapper/layout/adapt/absolute.leftrightvertical.js b/src/core/wrapper/layout/adapt/absolute.leftrightvertical.js index 148897cfe..25d5aab94 100644 --- a/src/core/wrapper/layout/adapt/absolute.leftrightvertical.js +++ b/src/core/wrapper/layout/adapt/absolute.leftrightvertical.js @@ -37,7 +37,7 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { }, _formatItems: function (items) { - var o = this.options; + var self = this, o = this.options; var left, right; if (BI.isArray(items)) { BI.each(items, function (i, item) { @@ -56,17 +56,17 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { el: BI.stripEL(item), width: item.width }; - if (o.lvgap + o.ltgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - json.tgap = o.lvgap + o.ltgap + (item.tgap || 0) + (item.vgap || 0); + if (o.lvgap + o.ltgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) !== 0) { + json.tgap = o.lvgap + o.ltgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item); } - if (o.lhgap + o.llgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + (item.lgap || 0) + (item.hgap || 0); + if (o.lhgap + o.llgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { + json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item); } - if (o.lhgap + o.lrgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - json.rgap = o.lhgap + o.lrgap + (item.rgap || 0) + (item.hgap || 0); + if (o.lhgap + o.lrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { + json.rgap = o.lhgap + o.lrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item); } - if (o.lvgap + o.lbgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - json.bgap = o.lvgap + o.lbgap + (item.bgap || 0) + (item.vgap || 0); + if (o.lvgap + o.lbgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) !== 0) { + json.bgap = o.lvgap + o.lbgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item); } return json; }); @@ -75,17 +75,17 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { el: BI.stripEL(item), width: item.width }; - if (o.rvgap + o.rtgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - json.tgap = o.rvgap + o.rtgap + (item.tgap || 0) + (item.vgap || 0); + if (o.rvgap + o.rtgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) !== 0) { + json.tgap = o.rvgap + o.rtgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item); } - if (o.rhgap + o.rlgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - json.lgap = (i === 0 ? o.rhgap : 0) + o.rlgap + (item.lgap || 0) + (item.hgap || 0); + if (o.rhgap + o.rlgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { + json.lgap = (i === 0 ? o.rhgap : 0) + o.rlgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item); } - if (o.rhgap + o.rrgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - json.rgap = o.rhgap + o.rrgap + (item.rgap || 0) + (item.hgap || 0); + if (o.rhgap + o.rrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { + json.rgap = o.rhgap + o.rrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item); } - if (o.rvgap + o.rbgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - json.bgap = o.rvgap + o.rbgap + (item.bgap || 0) + (item.vgap || 0); + if (o.rvgap + o.rbgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) !== 0) { + json.bgap = o.rvgap + o.rbgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item); } return json; }); diff --git a/src/core/wrapper/layout/adapt/adapt.table.js b/src/core/wrapper/layout/adapt/adapt.table.js index 9af2aa8cc..5691840af 100644 --- a/src/core/wrapper/layout/adapt/adapt.table.js +++ b/src/core/wrapper/layout/adapt/adapt.table.js @@ -70,8 +70,8 @@ BI.TableAdaptLayout = BI.inherit(BI.Layout, { td.element.width(width); } if (o.verticalAlign === BI.VerticalAlign.Stretch) { - var top = o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0), - bottom = o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0); + var top = o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item), + bottom = o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); w.element.css("height", "calc(100% - " + this._optimiseGap(top + bottom) + ")"); } // 对于表现为td的元素设置最大宽度,有几点需要注意 diff --git a/src/core/wrapper/layout/fill/auto.vtape.js b/src/core/wrapper/layout/fill/auto.vtape.js index 16491ebab..efc784f5d 100644 --- a/src/core/wrapper/layout/fill/auto.vtape.js +++ b/src/core/wrapper/layout/fill/auto.vtape.js @@ -60,10 +60,10 @@ BI.AutoVerticalTapeLayout = BI.inherit(BI.Layout, { if (preRowSize === "") { preRowSize = self.layout.getWidgetByName(self._getChildName(i - 1)).element.height(); } - top[i] = top[i - 1] + preRowSize + (items[i - 1].tgap || 0) + (items[i - 1].bgap || 0) + 2 * (items[i - 1].vgap || 0) + o.vgap + o.tgap + o.bgap; + top[i] = top[i - 1] + preRowSize + self._optimiseItemTgap(items[i - 1]) + self._optimiseItemBgap(items[i - 1]) + 2 * self._optimiseItemVgap(items[i - 1]) + o.vgap + o.tgap + o.bgap; } w.element.css({ - top: self._optimiseGap(top[i] + (item.vgap || 0) + (item.tgap || 0) + o.vgap + o.tgap) + top: self._optimiseGap(top[i] + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) + o.vgap + o.tgap) }); if (rowSize === "fill") { @@ -81,10 +81,10 @@ BI.AutoVerticalTapeLayout = BI.inherit(BI.Layout, { if (nextRowSize === "") { nextRowSize = self.layout.getWidgetByName(self._getChildName(i + 1)).element.height(); } - bottom[i] = bottom[i + 1] + nextRowSize + (items[i + 1].tgap || 0) + (items[i + 1].bgap || 0) + 2 * (items[i + 1].vgap || 0) + o.vgap + o.tgap + o.bgap; + bottom[i] = bottom[i + 1] + nextRowSize + self._optimiseItemTgap(items[i + 1]) + self._optimiseItemBgap(items[i + 1]) + 2 * self._optimiseItemVgap(items[i + 1]) + o.vgap + o.tgap + o.bgap; } w.element.css({ - bottom: self._optimiseGap(bottom[i] + (item.vgap || 0) + (item.bgap || 0) + o.vgap + o.bgap), + bottom: self._optimiseGap(bottom[i] + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) + o.vgap + o.bgap), }); if (rowSize === "fill") { diff --git a/src/core/wrapper/layout/fill/float.fill.horizontal.js b/src/core/wrapper/layout/fill/float.fill.horizontal.js index d6607703b..512ffb627 100644 --- a/src/core/wrapper/layout/fill/float.fill.horizontal.js +++ b/src/core/wrapper/layout/fill/float.fill.horizontal.js @@ -45,41 +45,41 @@ BI.FloatHorizontalFillLayout = BI.inherit(BI.Layout, { } else { var w = BI._lazyCreateWidget(item); } - if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { + if (o.vgap + o.tgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) !== 0) { w.element.css({ - "margin-top": self._optimiseGap(o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) + "margin-top": self._optimiseGap(o.vgap + o.tgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item)) }); } if (desc) { - if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { + if (o.hgap + o.rgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { w.element.css({ - "margin-right": self._optimiseGap((i === o.items.length - 1 ? o.hgap : 0) + o.rgap + (item.rgap || 0) + (item.hgap || 0)) + "margin-right": self._optimiseGap((i === o.items.length - 1 ? o.hgap : 0) + o.rgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item)) }); } - if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { + if (o.hgap + o.lgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { w.element.css({ - "margin-left": self._optimiseGap(o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0)) + "margin-left": self._optimiseGap(o.hgap + o.lgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item)) }); } } else { - if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { + if (o.hgap + o.lgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { w.element.css({ - "margin-left": self._optimiseGap((i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0)) + "margin-left": self._optimiseGap((i === 0 ? o.hgap : 0) + o.lgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item)) }); } - if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { + if (o.hgap + o.rgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { w.element.css({ - "margin-right": self._optimiseGap(o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) + "margin-right": self._optimiseGap(o.hgap + o.rgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item)) }); } } - if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { + if (o.vgap + o.bgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) !== 0) { w.element.css({ - "margin-bottom": self._optimiseGap(o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) + "margin-bottom": self._optimiseGap(o.vgap + o.bgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item)) }); } - var top = o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0), - bottom = o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0); + var top = o.vgap + o.tgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item), + bottom = o.vgap + o.bgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item); if (o.verticalAlign === BI.VerticalAlign.Stretch && BI.isNull(item.height)) { w.element.css({ height: "calc(100% - " + self._optimiseGap(top + bottom) + ")" diff --git a/src/core/wrapper/layout/flex/flex.horizontal.js b/src/core/wrapper/layout/flex/flex.horizontal.js index 1228e7e59..7d53dfe0e 100644 --- a/src/core/wrapper/layout/flex/flex.horizontal.js +++ b/src/core/wrapper/layout/flex/flex.horizontal.js @@ -81,7 +81,6 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { } if (columnSize === "fill") { w.element.addClass("f-f"); - w.element.css({ minWidth: 0 }); } w.element.addClass("c-e"); if (i === 0) { diff --git a/src/core/wrapper/layout/flex/flex.leftrightvertical.center.js b/src/core/wrapper/layout/flex/flex.leftrightvertical.center.js index 322d48fb4..01a462707 100644 --- a/src/core/wrapper/layout/flex/flex.leftrightvertical.center.js +++ b/src/core/wrapper/layout/flex/flex.leftrightvertical.center.js @@ -35,7 +35,7 @@ BI.FlexLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { }, _formatItems: function (items) { - var o = this.options; + var self = this, o = this.options; var left, right; if (BI.isArray(items)) { BI.each(items, function (i, item) { @@ -53,17 +53,17 @@ BI.FlexLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { var json = { el: BI.stripEL(item) }; - if (o.lvgap + o.ltgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - json.tgap = o.lvgap + o.ltgap + (item.tgap || 0) + (item.vgap || 0); + if (o.lvgap + o.ltgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) !== 0) { + json.tgap = o.lvgap + o.ltgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item); } - if (o.lhgap + o.llgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + (item.lgap || 0) + (item.hgap || 0); + if (o.lhgap + o.llgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { + json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item); } - if (o.lhgap + o.lrgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - json.rgap = o.lhgap + o.lrgap + (item.rgap || 0) + (item.hgap || 0); + if (o.lhgap + o.lrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { + json.rgap = o.lhgap + o.lrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item); } - if (o.lvgap + o.lbgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - json.bgap = o.lvgap + o.lbgap + (item.bgap || 0) + (item.vgap || 0); + if (o.lvgap + o.lbgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) !== 0) { + json.bgap = o.lvgap + o.lbgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item); } return json; }); diff --git a/src/core/wrapper/layout/flex/flex.vertical.js b/src/core/wrapper/layout/flex/flex.vertical.js index 40f252ed2..46b175e9b 100644 --- a/src/core/wrapper/layout/flex/flex.vertical.js +++ b/src/core/wrapper/layout/flex/flex.vertical.js @@ -80,7 +80,6 @@ BI.FlexVerticalLayout = BI.inherit(BI.Layout, { } if (rowSize === "fill") { w.element.addClass("f-f"); - w.element.css({ minHeight: 0 }); } w.element.addClass("c-e"); if (i === 0) { diff --git a/src/core/wrapper/layout/float/float.absolute.leftrightvertical.js b/src/core/wrapper/layout/float/float.absolute.leftrightvertical.js index 26bea2558..9de105651 100644 --- a/src/core/wrapper/layout/float/float.absolute.leftrightvertical.js +++ b/src/core/wrapper/layout/float/float.absolute.leftrightvertical.js @@ -38,7 +38,7 @@ BI.FloatAbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { }, _formatItems: function (items) { - var o = this.options; + var self = this, o = this.options; var left, right; if (BI.isArray(items)) { BI.each(items, function (i, item) { @@ -68,11 +68,11 @@ BI.FloatAbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { // if (o.lvgap + o.ltgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { // json.tgap = o.lvgap + o.ltgap + (item.tgap || 0) + (item.vgap || 0); // } - if (o.lhgap + o.llgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + (item.lgap || 0) + (item.hgap || 0); + if (o.lhgap + o.llgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { + json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item); } - if (o.lhgap + o.lrgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - json.rgap = o.lhgap + o.lrgap + (item.rgap || 0) + (item.hgap || 0); + if (o.lhgap + o.lrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { + json.rgap = o.lhgap + o.lrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item); } // if (o.lvgap + o.lbgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { // json.bgap = o.lvgap + o.lbgap + (item.bgap || 0) + (item.vgap || 0); @@ -95,11 +95,11 @@ BI.FloatAbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { // if (o.rvgap + o.rtgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { // json.tgap = o.rvgap + o.rtgap + (item.tgap || 0) + (item.vgap || 0); // } - if (o.rhgap + o.rlgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - json.lgap = (i === 0 ? o.rhgap : 0) + o.rlgap + (item.lgap || 0) + (item.hgap || 0); + if (o.rhgap + o.rlgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { + json.lgap = (i === 0 ? o.rhgap : 0) + o.rlgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item); } - if (o.rhgap + o.rrgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - json.rgap = o.rhgap + o.rrgap + (item.rgap || 0) + (item.hgap || 0); + if (o.rhgap + o.rrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { + json.rgap = o.rhgap + o.rrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item); } // if (o.rvgap + o.rbgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { // json.bgap = o.rvgap + o.rbgap + (item.bgap || 0) + (item.vgap || 0); diff --git a/src/core/wrapper/layout/layout.flow.js b/src/core/wrapper/layout/layout.flow.js index 4efc35123..e3c26638d 100644 --- a/src/core/wrapper/layout/layout.flow.js +++ b/src/core/wrapper/layout/layout.flow.js @@ -56,26 +56,26 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, { if (BI.isNotNull(item.bottom)) { w.element.css({bottom: BI.isNumber(item.bottom) ? this._optimiseGap(item.bottom) : item.bottom}); } - if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - var top = o.vgap / 2 + o.tgap + (item.tgap || 0) + (item.vgap || 0); + if (o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { + var top = o.vgap / 2 + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); w.element.css({ "margin-top": this._optimiseGap(top) }); } - if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - var left = o.hgap / 2 + o.lgap + (item.lgap || 0) + (item.hgap || 0); + if (o.hgap + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { + var left = o.hgap / 2 + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); w.element.css({ "margin-left": this._optimiseGap(left) }); } - if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - var right = o.hgap / 2 + o.rgap + (item.rgap || 0) + (item.hgap || 0); + if (o.hgap + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { + var right = o.hgap / 2 + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); w.element.css({ "margin-right": this._optimiseGap(right) }); } - if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - var bottom = o.vgap / 2 + o.bgap + (item.bgap || 0) + (item.vgap || 0); + if (o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { + var bottom = o.vgap / 2 + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); w.element.css({ "margin-bottom": this._optimiseGap(bottom) }); @@ -148,24 +148,28 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, { if (BI.isNotNull(item.bottom)) { w.element.css({bottom: BI.isNumber(item.bottom) ? item.bottom / BI.pixRatio + BI.pixUnit : item.bottom}); } - if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { + if (o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { + var top = o.vgap / 2 + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); w.element.css({ - "margin-top": (o.vgap / 2 + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit + "margin-top": this._optimiseGap(top) }); } - if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { + if (o.hgap + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { + var left = o.hgap / 2 + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); w.element.css({ - "margin-left": (o.hgap / 2 + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit + "margin-left": this._optimiseGap(left) }); } - if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { + if (o.hgap + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { + var right = o.hgap / 2 + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); w.element.css({ - "margin-right": (o.hgap / 2 + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit + "margin-right": this._optimiseGap(right) }); } - if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { + if (o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { + var bottom = o.vgap / 2 + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); w.element.css({ - "margin-bottom": (o.vgap / 2 + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit + "margin-bottom": this._optimiseGap(bottom) }); } return w; diff --git a/src/core/wrapper/layout/layout.inline.js b/src/core/wrapper/layout/layout.inline.js index a1d889337..99fa1b96e 100644 --- a/src/core/wrapper/layout/layout.inline.js +++ b/src/core/wrapper/layout/layout.inline.js @@ -40,7 +40,7 @@ BI.InlineLayout = BI.inherit(BI.Layout, { _addElement: function (i, item) { var o = this.options; var w = BI.InlineLayout.superclass._addElement.apply(this, arguments); - var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width >= 1 ? null : item.width; + var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width; if (o.columnSize.length > 0) { if (item.width >= 1 && o.columnSize[i] >= 1 && o.columnSize[i] !== item.width) { columnSize = null; @@ -66,7 +66,7 @@ BI.InlineLayout = BI.inherit(BI.Layout, { autoCount++; cz = 0; } - gap += o.hgap + o.lgap + o.rgap + (o.items[k].lgap || 0) + (o.items[k].rgap || 0) + (o.items[k].hgap || 0); + gap += o.hgap + o.lgap + o.rgap + this._optimiseItemLgap(o.items[k]) + this._optimiseItemRgap(o.items[k]) + this._optimiseItemHgap(o.items[k]); length += cz; } length = length > 0 && length < 1 ? (length * 100).toFixed(1) + "%" : length / BI.pixRatio + BI.pixUnit; @@ -84,8 +84,8 @@ BI.InlineLayout = BI.inherit(BI.Layout, { } this._handleGap(w, item, i); if (o.verticalAlign === BI.VerticalAlign.Stretch && BI.isNull(item.height)) { - var top = o.innerVgap + o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0), - bottom = o.innerVgap + o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0); + var top = o.innerVgap + o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item), + bottom = o.innerVgap + o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); var gap = (top + bottom) > 0 && (top + bottom) < 1 ? ((top + bottom) * 100).toFixed(1) + "%" : (top + bottom) / BI.pixRatio + BI.pixUnit; w.element.css("height", "calc(100% - " + gap + ")"); } diff --git a/src/core/wrapper/layout/layout.tape.js b/src/core/wrapper/layout/layout.tape.js index 8652862da..a3fa8bcf0 100644 --- a/src/core/wrapper/layout/layout.tape.js +++ b/src/core/wrapper/layout/layout.tape.js @@ -53,8 +53,8 @@ BI.HTapeLayout = BI.inherit(BI.Layout, { } w.element.css({ position: "absolute", - top: self._optimiseGap((item.vgap || 0) + (item.tgap || 0) + o.innerVgap + o.vgap + o.tgap), - bottom: self._optimiseGap((item.bgap || 0) + (item.vgap || 0) + o.innerVgap + o.vgap + o.bgap), + top: self._optimiseGap(self._optimiseItemTgap(item) + self._optimiseItemVgap(item) + o.innerVgap + o.vgap + o.tgap), + bottom: self._optimiseGap(self._optimiseItemBgap(item) + self._optimiseItemVgap(item) + o.innerVgap + o.vgap + o.bgap), width: BI.isNumber(columnSize) ? self._optimiseGap(columnSize) : "" }); if (o.verticalAlign === BI.VerticalAlign.Middle) { @@ -86,10 +86,10 @@ BI.HTapeLayout = BI.inherit(BI.Layout, { } if (BI.isNull(left[i])) { var preColumnSize = o.columnSize.length > 0 ? o.columnSize[i - 1] : items[i - 1].width; - left[i] = left[i - 1] + preColumnSize + (items[i - 1].lgap || 0) + (items[i - 1].rgap || 0) + 2 * (items[i - 1].hgap || 0) + o.hgap + o.lgap + o.rgap; + left[i] = left[i - 1] + preColumnSize + self._optimiseItemLgap(items[i - 1]) + self._optimiseItemRgap(items[i - 1]) + 2 * self._optimiseItemHgap(items[i - 1]) + o.hgap + o.lgap + o.rgap; } w.element.css({ - left: self._optimiseGap(left[i] + (item.lgap || 0) + (item.hgap || 0) + o.hgap + o.lgap) + left: self._optimiseGap(left[i] + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) + o.hgap + o.lgap) }); if (columnSize === "" || columnSize === "fill") { @@ -104,10 +104,10 @@ BI.HTapeLayout = BI.inherit(BI.Layout, { var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width; if (BI.isNull(right[i])) { var nextColumnSize = o.columnSize.length > 0 ? o.columnSize[i + 1] : items[i + 1].width; - right[i] = right[i + 1] + nextColumnSize + (items[i + 1].lgap || 0) + (items[i + 1].rgap || 0) + 2 * (items[i + 1].hgap || 0) + o.hgap + o.lgap + o.rgap; + right[i] = right[i + 1] + nextColumnSize + self._optimiseItemLgap(items[i + 1]) + self._optimiseItemRgap(items[i + 1]) + 2 * self._optimiseItemHgap(items[i + 1]) + o.hgap + o.lgap + o.rgap; } w.element.css({ - right: self._optimiseGap(right[i] + (item.rgap || 0) + (item.hgap || 0) + o.hgap + o.rgap) + right: self._optimiseGap(right[i] + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) + o.hgap + o.rgap) }); if (columnSize === "" || columnSize === "fill") { @@ -178,8 +178,8 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { } w.element.css({ position: "absolute", - left: self._optimiseGap((item.lgap || 0) + (item.hgap || 0) + o.innerHgap + o.hgap + o.lgap), - right: self._optimiseGap((item.hgap || 0) + (item.rgap || 0) + o.innerHgap + o.hgap + o.rgap), + left: self._optimiseGap(self._optimiseItemLgap(item) + self._optimiseItemHgap(item) + o.innerHgap + o.hgap + o.lgap), + right: self._optimiseGap(self._optimiseItemRgap(item) + self._optimiseItemHgap(item) + o.innerHgap + o.hgap + o.rgap), height: BI.isNumber(rowSize) ? self._optimiseGap(rowSize) : "" }); if (o.horizontalAlign === BI.HorizontalAlign.Center) { @@ -211,10 +211,10 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { } if (BI.isNull(top[i])) { var preRowSize = o.rowSize.length > 0 ? o.rowSize[i - 1] : items[i - 1].height; - top[i] = top[i - 1] + preRowSize + (items[i - 1].tgap || 0) + (items[i - 1].bgap || 0) + 2 * (items[i - 1].vgap || 0) + o.vgap + o.tgap + o.bgap; + top[i] = top[i - 1] + preRowSize + self._optimiseItemTgap(items[i - 1]) + self._optimiseItemBgap(items[i - 1]) + 2 * self._optimiseItemVgap(items[i - 1]) + o.vgap + o.tgap + o.bgap; } w.element.css({ - top: self._optimiseGap(top[i] + (item.vgap || 0) + (item.tgap || 0) + o.vgap + o.tgap) + top: self._optimiseGap(top[i] + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) + o.vgap + o.tgap) }); if (rowSize === "" || rowSize === "fill") { @@ -229,10 +229,10 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { var rowSize = o.rowSize.length > 0 ? o.rowSize[i] : item.height; if (BI.isNull(bottom[i])) { var nextRowSize = o.rowSize.length > 0 ? o.rowSize[i + 1] : items[i + 1].height; - bottom[i] = bottom[i + 1] + nextRowSize + (items[i + 1].tgap || 0) + (items[i + 1].bgap || 0) + 2 * (items[i + 1].vgap || 0) + o.vgap + o.tgap + o.bgap; + bottom[i] = bottom[i + 1] + nextRowSize + self._optimiseItemTgap(items[i + 1]) + self._optimiseItemBgap(items[i + 1]) + 2 * self._optimiseItemVgap(items[i + 1]) + o.vgap + o.tgap + o.bgap; } w.element.css({ - bottom: self._optimiseGap(bottom[i] + (item.vgap || 0) + (item.bgap || 0) + o.vgap + o.bgap) + bottom: self._optimiseGap(bottom[i] + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) + o.vgap + o.bgap) }); if (rowSize === "" || rowSize === "fill") { diff --git a/src/core/wrapper/layout/layout.td.js b/src/core/wrapper/layout/layout.td.js index 17a469754..cb3221570 100644 --- a/src/core/wrapper/layout/layout.td.js +++ b/src/core/wrapper/layout/layout.td.js @@ -92,8 +92,8 @@ BI.TdLayout = BI.inherit(BI.Layout, { for (var i = 0; i < arr.length; i++) { var w = BI._lazyCreateWidget(arr[i]); if (o.verticalAlign === BI.VerticalAlign.Stretch) { - var top = o.vgap + o.tgap + (arr[i].tgap || 0) + (arr[i].vgap || 0), - bottom = o.vgap + o.bgap + (arr[i].bgap || 0) + (arr[i].vgap || 0); + var top = o.vgap + o.tgap + this._optimiseItemTgap(arr[i]) + this._optimiseItemVgap(arr[i]), + bottom = o.vgap + o.bgap + this._optimiseItemBgap(arr[i]) + this._optimiseItemVgap(arr[i]); w.element.css("height", "calc(100% - " + this._optimiseGap(top + bottom) + ")"); } w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"}); diff --git a/src/core/wrapper/layout/sticky/sticky.horizontal.js b/src/core/wrapper/layout/sticky/sticky.horizontal.js index c5b644542..a59dd6edf 100644 --- a/src/core/wrapper/layout/sticky/sticky.horizontal.js +++ b/src/core/wrapper/layout/sticky/sticky.horizontal.js @@ -5,7 +5,8 @@ BI.HorizontalStickyLayout = BI.inherit(BI.FlexHorizontalLayout, { props: function () { return BI.extend(BI.HorizontalStickyLayout.superclass.props.apply(this, arguments), { extraCls: "bi-h-sticky", - horizontalAlign: BI.HorizontalAlign.Stretch, + scrollx: true, + // horizontalAlign: BI.HorizontalAlign.Stretch, verticalAlign: BI.VerticalAlign.Stretch }); }, diff --git a/src/core/wrapper/layout/sticky/sticky.vertical.js b/src/core/wrapper/layout/sticky/sticky.vertical.js index a5ba3d837..970d84eef 100644 --- a/src/core/wrapper/layout/sticky/sticky.vertical.js +++ b/src/core/wrapper/layout/sticky/sticky.vertical.js @@ -5,8 +5,9 @@ BI.VerticalStickyLayout = BI.inherit(BI.FlexVerticalLayout, { props: function () { return BI.extend(BI.VerticalStickyLayout.superclass.props.apply(this, arguments), { extraCls: "bi-v-sticky", + scrolly: true, horizontalAlign: BI.HorizontalAlign.Stretch, - verticalAlign: BI.VerticalAlign.Stretch + // verticalAlign: BI.VerticalAlign.Stretch }); }, diff --git a/src/less/base/colorchooser/colorchooser.popup.less b/src/less/base/colorchooser/colorchooser.popup.less index c1dd8ecda..6568f8319 100644 --- a/src/less/base/colorchooser/colorchooser.popup.less +++ b/src/less/base/colorchooser/colorchooser.popup.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-color-chooser-popup { & .disable-mask { diff --git a/src/less/base/colorchooser/colorchooser.trigger.less b/src/less/base/colorchooser/colorchooser.trigger.less index 95739ca30..a647bb9f2 100644 --- a/src/less/base/colorchooser/colorchooser.trigger.less +++ b/src/less/base/colorchooser/colorchooser.trigger.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-color-chooser-trigger { .border-radius(2px); diff --git a/src/less/base/colorchooser/colorpicker/button.colorpicker.less b/src/less/base/colorchooser/colorpicker/button.colorpicker.less index 3e85065bc..05219eb3e 100644 --- a/src/less/base/colorchooser/colorpicker/button.colorpicker.less +++ b/src/less/base/colorchooser/colorpicker/button.colorpicker.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-color-picker-button { & .color-picker-button-mask { diff --git a/src/less/base/colorchooser/colorpicker/button.colorshow.less b/src/less/base/colorchooser/colorpicker/button.colorshow.less index 85aac4635..c754a42cd 100644 --- a/src/less/base/colorchooser/colorpicker/button.colorshow.less +++ b/src/less/base/colorchooser/colorpicker/button.colorshow.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-color-chooser-show-button { &.active, &:active { diff --git a/src/less/base/colorchooser/colorpicker/editor.colorpicker.less b/src/less/base/colorchooser/colorpicker/editor.colorpicker.less index 12239c7de..ce0979d5b 100644 --- a/src/less/base/colorchooser/colorpicker/editor.colorpicker.less +++ b/src/less/base/colorchooser/colorpicker/editor.colorpicker.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-color-picker-editor { & .color-picker-editor-display { diff --git a/src/less/base/colorchooser/farbtastic/farbtastic.less b/src/less/base/colorchooser/farbtastic/farbtastic.less index 38e719ea6..757d57599 100644 --- a/src/less/base/colorchooser/farbtastic/farbtastic.less +++ b/src/less/base/colorchooser/farbtastic/farbtastic.less @@ -1,5 +1,5 @@ -@import "../../../index"; -@import "../../../image"; +@import "../../../index.less"; +@import "../../../image.less"; .bi-farbtastic { & * { diff --git a/src/less/base/combo/combo.bubble.less b/src/less/base/combo/combo.bubble.less index a6f21add1..c3c14ac0a 100644 --- a/src/less/base/combo/combo.bubble.less +++ b/src/less/base/combo/combo.bubble.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; // .bi-bubble-combo { // & .button-combo-triangle-wrapper { diff --git a/src/less/base/combo/combo.less b/src/less/base/combo/combo.less index e6b8bcded..206953d4b 100644 --- a/src/less/base/combo/combo.less +++ b/src/less/base/combo/combo.less @@ -1,19 +1,22 @@ -@import "../../index"; +@import "../../index.less"; + @val: transform .3s ease; .bi-combo { & > .bi-trigger { - & .bi-trigger-icon-button{ + & .bi-trigger-icon-button { & .x-icon { .rotate(0deg); .transition(@val); } } } + &.bi-combo-popup { display: block !important; visibility: visible !important; + & > .bi-trigger { - & .bi-trigger-icon-button{ + & .bi-trigger-icon-button { & .x-icon { .rotate(180deg); .transition(@val); @@ -21,11 +24,13 @@ } } } + &.bi-combo-popup, &.bi-combo-hover, &:hover { &.bi-border, &.bi-border-bottom { border-color: @color-bi-border-hover-combo; } } + &.disabled { &.bi-combo-hover, &:hover { &.bi-border, &.bi-border-bottom { @@ -33,6 +38,36 @@ } } } + + &.error { + &.bi-combo-hover, &:hover { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-negative; + } + } + } + + + // 将来统一变成combo的特性 + //&.status-error { + // &.bi-border, &.bi-border-bottom { + // border-color: @border-color-negative; + // } + // + // .bi-trigger .select-text-label { + // color: @color-bi-text-error-text-trigger; + // } + //} + // + //&.status-warning { + // &.bi-border, &.bi-border-bottom { + // border-color: @border-color-warning; + // } + // + // .bi-trigger .select-text-label { + // color: @font-color-warning; + // } + //} } .bi-theme-dark { diff --git a/src/less/base/combo/combo.searchtextvalue.less b/src/less/base/combo/combo.searchtextvalue.less index de0ec79b3..5d5a5524c 100644 --- a/src/less/base/combo/combo.searchtextvalue.less +++ b/src/less/base/combo/combo.searchtextvalue.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; @val: transform .3s ease; .bi-search-text-value-combo{ & .trigger-icon-button{ diff --git a/src/less/base/combo/combo.textvalue.icon.less b/src/less/base/combo/combo.textvalue.icon.less index 79fef76ed..9d32d4971 100644 --- a/src/less/base/combo/combo.textvalue.icon.less +++ b/src/less/base/combo/combo.textvalue.icon.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-icon-text-value-combo{ &.combo-error { diff --git a/src/less/base/combo/combo.textvalue.less b/src/less/base/combo/combo.textvalue.less deleted file mode 100644 index dbf76aaa0..000000000 --- a/src/less/base/combo/combo.textvalue.less +++ /dev/null @@ -1,14 +0,0 @@ -@import "../../index"; - -.bi-text-value-combo { - &.combo-error { - & .bi-select-text-trigger { - & .select-text-label { - color: @color-bi-text-error-hover-text-value-combo; - } - } - &.bi-border, &.bi-border-bottom { - border-color: @border-color-negative; - } - } -} \ No newline at end of file diff --git a/src/less/base/combo/combo.textvaluecheck.less b/src/less/base/combo/combo.textvaluecheck.less index 9965f103f..7bed7c0db 100644 --- a/src/less/base/combo/combo.textvaluecheck.less +++ b/src/less/base/combo/combo.textvaluecheck.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-text-value-check-combo { &.bi-combo-popup, &:hover { diff --git a/src/less/base/combo/combo.textvaluedownlist.less b/src/less/base/combo/combo.textvaluedownlist.less index 823410272..be66b4294 100644 --- a/src/less/base/combo/combo.textvaluedownlist.less +++ b/src/less/base/combo/combo.textvaluedownlist.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-text-value-down-list-combo { &.bi-combo-popup, &:hover { diff --git a/src/less/base/combo/popup.bubble.less b/src/less/base/combo/popup.bubble.less index 2bfd50acc..09b440c28 100644 --- a/src/less/base/combo/popup.bubble.less +++ b/src/less/base/combo/popup.bubble.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-bubble-popup-view { &.bi-popup-view > .list-view-shadow { diff --git a/src/less/base/dom.less b/src/less/base/dom.less index 6dc909e1a..ffac75ef8 100644 --- a/src/less/base/dom.less +++ b/src/less/base/dom.less @@ -1,2 +1,2 @@ -@import "../index"; -@import "../lib/colors"; +@import "../index.less"; +@import "../lib/colors.less"; diff --git a/src/less/base/editor/editor.search.less b/src/less/base/editor/editor.search.less index f9094473b..cf29965b0 100644 --- a/src/less/base/editor/editor.search.less +++ b/src/less/base/editor/editor.search.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; /*************BI.SearchEditor******************/ .bi-search-editor { .border-radius(2px); diff --git a/src/less/base/editor/editor.search.small.less b/src/less/base/editor/editor.search.small.less index 234609f99..4eadc15aa 100644 --- a/src/less/base/editor/editor.search.small.less +++ b/src/less/base/editor/editor.search.small.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-small-search-editor { & .bi-editor { diff --git a/src/less/base/foundation/bi.message.less b/src/less/base/foundation/bi.message.less index 1e48abe01..c1605f47b 100644 --- a/src/less/base/foundation/bi.message.less +++ b/src/less/base/foundation/bi.message.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-message-title { font-size: @font-size-14; diff --git a/src/less/base/layer/layer.multiselect.less b/src/less/base/layer/layer.multiselect.less index 50b0f492e..adabe161e 100644 --- a/src/less/base/layer/layer.multiselect.less +++ b/src/less/base/layer/layer.multiselect.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-multi-list-view{ & .bi-button-mask{ diff --git a/src/less/base/layer/panel.less b/src/less/base/layer/panel.less index 79332582f..a76212335 100644 --- a/src/less/base/layer/panel.less +++ b/src/less/base/layer/panel.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-panel{ .border-radius(2px); diff --git a/src/less/base/loader/sort.list.less b/src/less/base/loader/sort.list.less index 14dc71457..a8239b708 100644 --- a/src/less/base/loader/sort.list.less +++ b/src/less/base/loader/sort.list.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-sortable-holder { border: 1px dashed @color-bi-border-sortable-holder; diff --git a/src/less/base/pager/pager.all.count.less b/src/less/base/pager/pager.all.count.less index 717c2f5ec..71a90bb9a 100644 --- a/src/less/base/pager/pager.all.count.less +++ b/src/less/base/pager/pager.all.count.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-all-count-pager { & .all-pager-prev { diff --git a/src/less/base/pager/pager.direction.less b/src/less/base/pager/pager.direction.less index c558a3472..5c946cd29 100644 --- a/src/less/base/pager/pager.direction.less +++ b/src/less/base/pager/pager.direction.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-direction-pager { & .direction-pager-prev { diff --git a/src/less/base/pager/pager.less b/src/less/base/pager/pager.less index 8b4530186..bd4b5abcc 100644 --- a/src/less/base/pager/pager.less +++ b/src/less/base/pager/pager.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-pager{ & .page-item{ diff --git a/src/less/base/pane.less b/src/less/base/pane.less index a83e80756..ea7783f0a 100644 --- a/src/less/base/pane.less +++ b/src/less/base/pane.less @@ -1,6 +1,6 @@ -@import "../index"; -@import "../image"; -@import "../lib/icon"; +@import "../index.less"; +@import "../image.less"; +@import "../lib/icon.less"; .bi-pane { min-height: 25px; &.loading-status{ diff --git a/src/less/base/segment/button.segment.less b/src/less/base/segment/button.segment.less index acb0a7b43..451d65f33 100644 --- a/src/less/base/segment/button.segment.less +++ b/src/less/base/segment/button.segment.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-segment-button { @transition: color 0.3s, background 0.3s, border-color 0.3s, box-shadow 0.3s; diff --git a/src/less/base/segment/segment.less b/src/less/base/segment/segment.less index cfbf6c77e..f106ddc75 100644 --- a/src/less/base/segment/segment.less +++ b/src/less/base/segment/segment.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-segment{ & > .center-element{ diff --git a/src/less/base/single/button/button.half.less b/src/less/base/single/button/button.half.less index 3f8c1377f..b652328fb 100644 --- a/src/less/base/single/button/button.half.less +++ b/src/less/base/single/button/button.half.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-half-button { .border-radius(2px); diff --git a/src/less/base/single/button/button.less b/src/less/base/single/button/button.less index d8f511c01..e34c4f5f0 100644 --- a/src/less/base/single/button/button.less +++ b/src/less/base/single/button/button.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; @hoverVal: opacity .3s ease; @activeVal: transform .5s ease, opacity 1s ease; @activeStopVal: transform 0s; diff --git a/src/less/base/single/button/item.singleselect.icontext.less b/src/less/base/single/button/item.singleselect.icontext.less index 94228aaf8..2f698d894 100644 --- a/src/less/base/single/button/item.singleselect.icontext.less +++ b/src/less/base/single/button/item.singleselect.icontext.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-single-select-icon-text-item{ &:active, &.active { diff --git a/src/less/base/single/button/switch.less b/src/less/base/single/button/switch.less index 22ba538c9..f7101201a 100644 --- a/src/less/base/single/button/switch.less +++ b/src/less/base/single/button/switch.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-switch { font-size: @font-size-12; diff --git a/src/less/base/single/editor/editor.multifile.less b/src/less/base/single/editor/editor.multifile.less index fea7b2e9e..1bf507ca7 100644 --- a/src/less/base/single/editor/editor.multifile.less +++ b/src/less/base/single/editor/editor.multifile.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-multifile-editor { .multifile-editor { diff --git a/src/less/base/single/editor/editor.textarea.less b/src/less/base/single/editor/editor.textarea.less index 2ba0dd548..dc0a77a03 100644 --- a/src/less/base/single/editor/editor.textarea.less +++ b/src/less/base/single/editor/editor.textarea.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-textarea-editor { .overflow-hidden(); diff --git a/src/less/base/single/html.less b/src/less/base/single/html.less index 0af012d03..3159bc630 100644 --- a/src/less/base/single/html.less +++ b/src/less/base/single/html.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-html { article, diff --git a/src/less/base/single/input/checkbox.less b/src/less/base/single/input/checkbox.less index 89c9b205b..7141d75a9 100644 --- a/src/less/base/single/input/checkbox.less +++ b/src/less/base/single/input/checkbox.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-checkbox { & .checkbox-content, &.checkbox-content { diff --git a/src/less/base/single/input/file.less b/src/less/base/single/input/file.less index 4a4e31aef..03488689f 100644 --- a/src/less/base/single/input/file.less +++ b/src/less/base/single/input/file.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-file{ .opacity(0); diff --git a/src/less/base/single/input/input.less b/src/less/base/single/input/input.less index 6d4017e5c..504088485 100644 --- a/src/less/base/single/input/input.less +++ b/src/less/base/single/input/input.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-input, .bi-textarea{ border: none; diff --git a/src/less/base/single/input/radio.less b/src/less/base/single/input/radio.less index 1f5383177..8e48818e7 100644 --- a/src/less/base/single/input/radio.less +++ b/src/less/base/single/input/radio.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-radio { & .radio-content, &.radio-content { diff --git a/src/less/base/single/label.less b/src/less/base/single/label.less index 726d2a208..e0d6982d5 100644 --- a/src/less/base/single/label.less +++ b/src/less/base/single/label.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-label { .overflow-hidden(); diff --git a/src/less/base/single/text.less b/src/less/base/single/text.less index ec0841923..bd4aada73 100644 --- a/src/less/base/single/text.less +++ b/src/less/base/single/text.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-text { .overflow-hidden(); diff --git a/src/less/base/single/tip/tip.bubble.less b/src/less/base/single/tip/tip.bubble.less index ea40fd784..e18e3ffc9 100644 --- a/src/less/base/single/tip/tip.bubble.less +++ b/src/less/base/single/tip/tip.bubble.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-bubble { z-index: @zIndex-tip; diff --git a/src/less/base/single/tip/tip.less b/src/less/base/single/tip/tip.less index 087f342a6..209fbb664 100644 --- a/src/less/base/single/tip/tip.less +++ b/src/less/base/single/tip/tip.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-tip{ position: fixed !important; diff --git a/src/less/base/single/tip/tip.toast.less b/src/less/base/single/tip/tip.toast.less index 49b174614..875dfa586 100644 --- a/src/less/base/single/tip/tip.toast.less +++ b/src/less/base/single/tip/tip.toast.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-toast{ color: @color-bi-color-toast-text; diff --git a/src/less/base/single/tip/tip.tooltip.less b/src/less/base/single/tip/tip.tooltip.less index d78cd410f..bd1b22f98 100644 --- a/src/less/base/single/tip/tip.tooltip.less +++ b/src/less/base/single/tip/tip.tooltip.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-tooltip{ max-width: 250px; diff --git a/src/less/base/tree/tree.branch.less b/src/less/base/tree/tree.branch.less index 8c4ba3b9c..7328be6f5 100644 --- a/src/less/base/tree/tree.branch.less +++ b/src/less/base/tree/tree.branch.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-branch-tree{ & .bi-branch-tree-view{ min-width: 300px; diff --git a/src/less/base/tree/tree.display.less b/src/less/base/tree/tree.display.less index 20124e7d6..2343d4054 100644 --- a/src/less/base/tree/tree.display.less +++ b/src/less/base/tree/tree.display.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-display-tree{ .ztree * { diff --git a/src/less/base/tree/tree.expander.less b/src/less/base/tree/tree.expander.less index 67aac48d3..04bdd64ac 100644 --- a/src/less/base/tree/tree.expander.less +++ b/src/less/base/tree/tree.expander.less @@ -1,6 +1,6 @@ -@import "../../index"; -@import "../../image"; -@import "../../lib/icon"; +@import "../../index.less"; +@import "../../image.less"; +@import "../../lib/icon.less"; .bi-tree-expander-popup.line:before { position: absolute; content: ""; diff --git a/src/less/base/tree/tree.list.display.less b/src/less/base/tree/tree.list.display.less index e58d3a5dd..0a6b114d2 100644 --- a/src/less/base/tree/tree.list.display.less +++ b/src/less/base/tree/tree.list.display.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-list-display-tree{ diff --git a/src/less/base/tree/ztree.less b/src/less/base/tree/ztree.less index 630c48b45..4d3cfc877 100644 --- a/src/less/base/tree/ztree.less +++ b/src/less/base/tree/ztree.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .ztree * { padding: 0; diff --git a/src/less/base/trigger/trigger.less b/src/less/base/trigger/trigger.less index 1d25e3fd0..bcd89590a 100644 --- a/src/less/base/trigger/trigger.less +++ b/src/less/base/trigger/trigger.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-trigger{ & .bi-trigger-icon-button{ diff --git a/src/less/base/trigger/trigger.searchtextvalue.less b/src/less/base/trigger/trigger.searchtextvalue.less new file mode 100644 index 000000000..33508ae3b --- /dev/null +++ b/src/less/base/trigger/trigger.searchtextvalue.less @@ -0,0 +1,11 @@ +@import "../../index.less"; + +.bi-search-text-value-trigger { + &.error .select-text-label { + color: @color-bi-text-error-text-trigger; + } + + &:where(:not(&:hover)) .clear-button { + display: none; + } +} diff --git a/src/less/base/trigger/trigger.selecttext.less b/src/less/base/trigger/trigger.selecttext.less index 309aa7ef5..2c353833e 100644 --- a/src/less/base/trigger/trigger.selecttext.less +++ b/src/less/base/trigger/trigger.selecttext.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-select-text-trigger{ .border-radius(2px); diff --git a/src/less/base/trigger/trigger.selecttextsmall.less b/src/less/base/trigger/trigger.selecttextsmall.less index a4480d44e..749fd67f9 100644 --- a/src/less/base/trigger/trigger.selecttextsmall.less +++ b/src/less/base/trigger/trigger.selecttextsmall.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-small-select-text-trigger{ .border-radius(2px); diff --git a/src/less/base/trigger/trigger.text.less b/src/less/base/trigger/trigger.text.less new file mode 100644 index 000000000..9e2040512 --- /dev/null +++ b/src/less/base/trigger/trigger.text.less @@ -0,0 +1,11 @@ +@import "../../index.less"; + +.bi-text-trigger { + &.error .select-text-label { + color: @color-bi-text-error-text-trigger; + } + + &:where(:not(&:hover)) .clear-button { + display: none; + } +} diff --git a/src/less/base/view/drawer.less b/src/less/base/view/drawer.less index 80a8ca1be..76ab23d18 100644 --- a/src/less/base/view/drawer.less +++ b/src/less/base/view/drawer.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-drawer { .box-shadows(-6px 0 16px -8px #00000014, -9px 0 28px #0000000d, -12px 0 48px 16px #00000008); diff --git a/src/less/base/view/popover.less b/src/less/base/view/popover.less index 27b65a895..98dedcc7a 100644 --- a/src/less/base/view/popover.less +++ b/src/less/base/view/popover.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-popover { border: 1px solid transparent; diff --git a/src/less/base/view/popupview.less b/src/less/base/view/popupview.less index c9aeb1333..676e19f1d 100644 --- a/src/less/base/view/popupview.less +++ b/src/less/base/view/popupview.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-popup-view { position: fixed !important; diff --git a/src/less/component/form/form.less b/src/less/component/form/form.less index b4e77e0a8..5dfc027b2 100644 --- a/src/less/component/form/form.less +++ b/src/less/component/form/form.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-form { & .bi-form-field.error { diff --git a/src/less/core/normalize2.less b/src/less/core/normalize2.less index 11c876b5c..e2bea8699 100644 --- a/src/less/core/normalize2.less +++ b/src/less/core/normalize2.less @@ -1,4 +1,4 @@ -@import "../index"; +@import "../index.less"; a { outline: none; diff --git a/src/less/core/utils/animation.less b/src/less/core/utils/animation.less index 22bd65cde..809604ee2 100644 --- a/src/less/core/utils/animation.less +++ b/src/less/core/utils/animation.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; /** 循环旋转动画 **/ .anim-rotate { .animation(rotate 1s infinite linear both); diff --git a/src/less/core/utils/common.less b/src/less/core/utils/common.less index 5d9b11c3e..fd9b61c4a 100644 --- a/src/less/core/utils/common.less +++ b/src/less/core/utils/common.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .base-disabled { cursor: not-allowed !important; diff --git a/src/less/core/utils/list-item.less b/src/less/core/utils/list-item.less index 8964830cd..c084ac275 100644 --- a/src/less/core/utils/list-item.less +++ b/src/less/core/utils/list-item.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; // hover的时候背景变化,文字变黑 .bi-list-item { diff --git a/src/less/core/utils/motion/fade.less b/src/less/core/utils/motion/fade.less index d51a68c75..5f0fee5ff 100644 --- a/src/less/core/utils/motion/fade.less +++ b/src/less/core/utils/motion/fade.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .fade-motion(@className, @keyframeName) { .make-motion(@className, @keyframeName); diff --git a/src/less/core/utils/motion/move.less b/src/less/core/utils/motion/move.less index 3024c2a8b..eac06e005 100644 --- a/src/less/core/utils/motion/move.less +++ b/src/less/core/utils/motion/move.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .move-motion(@className, @keyframeName) { .make-motion(@className, @keyframeName); diff --git a/src/less/core/utils/motion/slide.less b/src/less/core/utils/motion/slide.less index 0fa6567a4..fd62e95fe 100644 --- a/src/less/core/utils/motion/slide.less +++ b/src/less/core/utils/motion/slide.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .slide-motion(@className, @keyframeName) { .make-motion(@className, @keyframeName); diff --git a/src/less/core/utils/motion/zoom.less b/src/less/core/utils/motion/zoom.less index 2407b8428..7e0e0ec44 100644 --- a/src/less/core/utils/motion/zoom.less +++ b/src/less/core/utils/motion/zoom.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .zoom-motion(@className, @keyframeName, @duration: @animation-duration-base) { .make-motion(@className, @keyframeName, @duration); diff --git a/src/less/core/utils/position.less b/src/less/core/utils/position.less index a9693147e..12f687077 100644 --- a/src/less/core/utils/position.less +++ b/src/less/core/utils/position.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .display-block { display: block; diff --git a/src/less/core/utils/size.less b/src/less/core/utils/size.less index e14cca14c..575729c28 100644 --- a/src/less/core/utils/size.less +++ b/src/less/core/utils/size.less @@ -1,5 +1,5 @@ -@import "../../lib/constant"; -@import "../../image"; +@import "../../lib/constant.less"; +@import "../../image.less"; .iconSize(icon-size-12, @font-size-12); .iconSize(icon-size-13, @font-size-13); diff --git a/src/less/core/utils/sizing.less b/src/less/core/utils/sizing.less index 643984a57..e199658b2 100644 --- a/src/less/core/utils/sizing.less +++ b/src/less/core/utils/sizing.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; /*类似ie6的盒子模型 可以在有百分比的时候加border 支持到ie8*/ .border-sizing{ .box-sizing(border-box); diff --git a/src/less/core/utils/typographic.less b/src/less/core/utils/typographic.less index e15f24cf9..ebdedf85e 100644 --- a/src/less/core/utils/typographic.less +++ b/src/less/core/utils/typographic.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .y-overflow-auto { overflow-y: auto; diff --git a/src/less/core/wrapper/flex.horizontal.less b/src/less/core/wrapper/flex.horizontal.less index b6a8ccc97..24d8862f6 100644 --- a/src/less/core/wrapper/flex.horizontal.less +++ b/src/less/core/wrapper/flex.horizontal.less @@ -169,6 +169,9 @@ } > .f-f { + &:not(.f-s-n) { + min-width: 0; + } -webkit-flex-grow: 1; -moz-flex-grow: 1; -ms-flex-grow: 1; diff --git a/src/less/core/wrapper/flex.vertical.less b/src/less/core/wrapper/flex.vertical.less index c8fbefa6b..007396436 100644 --- a/src/less/core/wrapper/flex.vertical.less +++ b/src/less/core/wrapper/flex.vertical.less @@ -168,6 +168,9 @@ } > .f-f { + &:not(.f-s-n) { + min-height: 0; + } -webkit-flex-grow: 1; -moz-flex-grow: 1; -ms-flex-grow: 1; diff --git a/src/less/core/wrapper/flex.wrapper.horizontal.less b/src/less/core/wrapper/flex.wrapper.horizontal.less index 89de62f88..09926f54b 100644 --- a/src/less/core/wrapper/flex.wrapper.horizontal.less +++ b/src/less/core/wrapper/flex.wrapper.horizontal.less @@ -265,6 +265,9 @@ } > .f-f { + &:not(.f-s-n) { + min-width: 0; + } -webkit-flex-grow: 1; -moz-flex-grow: 1; -ms-flex-grow: 1; diff --git a/src/less/core/wrapper/flex.wrapper.vertical.less b/src/less/core/wrapper/flex.wrapper.vertical.less index 477891105..118759152 100644 --- a/src/less/core/wrapper/flex.wrapper.vertical.less +++ b/src/less/core/wrapper/flex.wrapper.vertical.less @@ -259,6 +259,9 @@ } > .f-f { + &:not(.f-s-n) { + min-height: 0; + } -webkit-flex-grow: 1; -moz-flex-grow: 1; -ms-flex-grow: 1; diff --git a/src/less/image.less b/src/less/image.less index 0e4a7d49f..bd2bcfabc 100644 --- a/src/less/image.less +++ b/src/less/image.less @@ -1,4 +1,4 @@ -@import "var"; +@import "var.less"; .imagePath(none) { background: none; diff --git a/src/less/index.less b/src/less/index.less index 3644b8e34..47f735cef 100644 --- a/src/less/index.less +++ b/src/less/index.less @@ -1,8 +1,8 @@ -@import "position"; -@import "box-model"; -@import "typographic"; -@import "visual"; -@import "motion"; -@import "var"; -@import "lib/colors"; -@import "lib/theme"; +@import "position.less"; +@import "box-model.less"; +@import "typographic.less"; +@import "visual.less"; +@import "motion.less"; +@import "var.less"; +@import "lib/colors.less"; +@import "lib/theme.less"; diff --git a/src/less/lib/colors.less b/src/less/lib/colors.less index 394bb5f66..060768c03 100644 --- a/src/less/lib/colors.less +++ b/src/less/lib/colors.less @@ -1,4 +1,4 @@ -@import "constant"; +@import "constant.less"; // 通用色彩库。从constant.less中获取相关颜色,不要出现#xxxxxx diff --git a/src/less/lib/theme-modern.less b/src/less/lib/theme-modern.less index 000a92253..c2f3d9c55 100644 --- a/src/less/lib/theme-modern.less +++ b/src/less/lib/theme-modern.less @@ -1,4 +1,4 @@ -@import "colors"; +@import "colors.less"; // 专属组件色彩库,通用配色中有的用通用配色,否则选constant自定义配色 diff --git a/src/less/lib/theme.less b/src/less/lib/theme.less index 9fddef950..3c85b8031 100644 --- a/src/less/lib/theme.less +++ b/src/less/lib/theme.less @@ -1,4 +1,4 @@ -@import "colors"; +@import "colors.less"; // 专属组件色彩库,通用配色中有的用通用配色,否则选constant自定义配色 @@ -179,6 +179,7 @@ @color-bi-border-hover-text-value-down-list-combo: @color-bi-border-highlight; @color-bi-border-hover-text-value-check-combo: @color-bi-border-highlight; @color-bi-text-error-hover-text-value-combo: @color-bi-text-failure; +@color-bi-text-error-text-trigger: @color-bi-text-failure; @color-bi-text-error-hover-text-value-icon-combo: @color-bi-text-failure; @color-bi-text-error-hover-search-text-value-combo: @color-bi-text-failure; @color-bi-background-bubble-combo-triangle: @color-bi-background-default; diff --git a/src/less/resource/app.less b/src/less/resource/app.less index 4d80b12b9..4f61322d1 100644 --- a/src/less/resource/app.less +++ b/src/less/resource/app.less @@ -1,4 +1,4 @@ -@import "../index"; +@import "../index.less"; html { height: 100%; diff --git a/src/less/resource/background.less b/src/less/resource/background.less index 4e1c6a51e..8aca40b17 100644 --- a/src/less/resource/background.less +++ b/src/less/resource/background.less @@ -1,6 +1,6 @@ -@import "../image"; -@import "../lib/icon"; -@import "../lib/background"; +@import "../image.less"; +@import "../lib/icon.less"; +@import "../lib/background.less"; @import "../base/tree/tree.expander.less"; .bi-display-tree { diff --git a/src/less/resource/font.less b/src/less/resource/font.less index 7e7e4e91c..a6551f864 100644 --- a/src/less/resource/font.less +++ b/src/less/resource/font.less @@ -1,7 +1,7 @@ -@import "../lib/font"; -@import "../lib/colors"; -@import "../lib/theme"; -@import "../image"; +@import "../lib/font.less"; +@import "../lib/colors.less"; +@import "../lib/theme.less"; +@import "../image.less"; .addFontRes(); .activateFont(); diff --git a/src/less/resource/icon.less b/src/less/resource/icon.less index a97b429da..be2f6885d 100644 --- a/src/less/resource/icon.less +++ b/src/less/resource/icon.less @@ -1,5 +1,5 @@ -@import "../image"; -@import "../lib/icon"; +@import "../image.less"; +@import "../lib/icon.less"; //Tree Widget .icon(tree-collapse-icon-type1, @icon-tree-collapse-type1); diff --git a/src/less/theme/dark.less b/src/less/theme/dark.less index ed4bc3c67..a0149a1f9 100644 --- a/src/less/theme/dark.less +++ b/src/less/theme/dark.less @@ -1,4 +1,4 @@ -@import "../index"; +@import "../index.less"; .bi-theme-dark { color: @color-bi-text-theme-dark; diff --git a/src/less/theme/default.less b/src/less/theme/default.less index 303dfa0a4..ad1daefb1 100644 --- a/src/less/theme/default.less +++ b/src/less/theme/default.less @@ -1,4 +1,4 @@ -@import "../index"; +@import "../index.less"; .bi-theme-default{ diff --git a/src/less/theme/light.less b/src/less/theme/light.less index 0accbb8b3..50210951d 100644 --- a/src/less/theme/light.less +++ b/src/less/theme/light.less @@ -1,4 +1,4 @@ -@import "../index"; +@import "../index.less"; .bi-theme-light { } \ No newline at end of file diff --git a/src/less/widget/date/trigger.date.less b/src/less/widget/date/trigger.date.less index 99162d9c2..50e341418 100644 --- a/src/less/widget/date/trigger.date.less +++ b/src/less/widget/date/trigger.date.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-date-trigger { .border-radius(2px); diff --git a/src/less/widget/downlist/popup.downlist.less b/src/less/widget/downlist/popup.downlist.less index cdddf37da..ba48525f2 100644 --- a/src/less/widget/downlist/popup.downlist.less +++ b/src/less/widget/downlist/popup.downlist.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-down-list-popup { & .list-group-item-text { diff --git a/src/less/widget/dynamicdatecombo/dynamicdatepopup.less b/src/less/widget/dynamicdatecombo/dynamicdatepopup.less index 81b8893a2..4c4cb053e 100644 --- a/src/less/widget/dynamicdatecombo/dynamicdatepopup.less +++ b/src/less/widget/dynamicdatecombo/dynamicdatepopup.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-dynamic-date-popup{ & .dynamic-date-pane { diff --git a/src/less/widget/dynamicdatecombo/dynamicdatetime.combo.less b/src/less/widget/dynamicdatecombo/dynamicdatetime.combo.less index d15ab68dc..79bbf4542 100644 --- a/src/less/widget/dynamicdatecombo/dynamicdatetime.combo.less +++ b/src/less/widget/dynamicdatecombo/dynamicdatetime.combo.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-dynamic-date-combo { & .date-font { diff --git a/src/less/widget/dynamicdatecombo/dynamicdatetimepopup.less b/src/less/widget/dynamicdatecombo/dynamicdatetimepopup.less index 81a06aff7..100770f16 100644 --- a/src/less/widget/dynamicdatecombo/dynamicdatetimepopup.less +++ b/src/less/widget/dynamicdatecombo/dynamicdatetimepopup.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-dynamic-date-time-popup{ & .dynamic-date-pane { diff --git a/src/less/widget/month/trigger.month.less b/src/less/widget/month/trigger.month.less index ff75d4df7..17796dbd5 100644 --- a/src/less/widget/month/trigger.month.less +++ b/src/less/widget/month/trigger.month.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-month-trigger{ .border-radius(2px); } \ No newline at end of file diff --git a/src/less/widget/multilayerselecttree/multilayerselecttree.combo.less b/src/less/widget/multilayerselecttree/multilayerselecttree.combo.less index 4a725cd98..4ac60cf49 100644 --- a/src/less/widget/multilayerselecttree/multilayerselecttree.combo.less +++ b/src/less/widget/multilayerselecttree/multilayerselecttree.combo.less @@ -1,20 +1,24 @@ -@import "../../index"; -@val: transform .3s ease; +@import "../../index.less"; + .bi-multilayer-select-tree-combo { - & .trigger-icon-button{ - font-size: @font-size-16; - } - // 此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; + } + + .bi-trigger .select-text-label { + color: @color-bi-text-error-text-trigger; } } - & .bi-combo + .bi-trigger-icon-button { - & .x-icon { - .rotate(0deg); - .transition(@val); + + &.status-warning { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-warning; + } + + .bi-trigger .select-text-label { + color: @font-color-warning; } } } diff --git a/src/less/widget/multilayersingletree/multilayersingletree.combo.less b/src/less/widget/multilayersingletree/multilayersingletree.combo.less index a589309fd..6a1390230 100644 --- a/src/less/widget/multilayersingletree/multilayersingletree.combo.less +++ b/src/less/widget/multilayersingletree/multilayersingletree.combo.less @@ -1,20 +1,23 @@ -@import "../../index"; -@val: transform .3s ease; +@import "../../index.less"; + .bi-multilayer-single-tree-combo { - & .trigger-icon-button{ - font-size: @font-size-16; - } - // 此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; + } + + .bi-trigger .select-text-label { + color: @color-bi-text-error-text-trigger; } } - & .bi-combo + .bi-trigger-icon-button { - & .x-icon { - .rotate(0deg); - .transition(@val); + + &.status-warning { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-warning; + } + + .bi-trigger .select-text-label { + color: @font-color-warning; } } } diff --git a/src/less/widget/multiselect/check/multiselect.check.pane.less b/src/less/widget/multiselect/check/multiselect.check.pane.less index 7f0db5920..f64d2e8c2 100644 --- a/src/less/widget/multiselect/check/multiselect.check.pane.less +++ b/src/less/widget/multiselect/check/multiselect.check.pane.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-multi-select-check-pane { & .multi-select-check-selected { diff --git a/src/less/widget/multiselect/multiselect.combo.less b/src/less/widget/multiselect/multiselect.combo.less index 643062ec9..0399dd67a 100644 --- a/src/less/widget/multiselect/multiselect.combo.less +++ b/src/less/widget/multiselect/multiselect.combo.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; @val: transform .3s ease; .bi-multi-select-combo{ & .multi-select-trigger-icon-button{ diff --git a/src/less/widget/multiselect/multiselect.insert.combo.less b/src/less/widget/multiselect/multiselect.insert.combo.less index ed721fce8..ae89eed14 100644 --- a/src/less/widget/multiselect/multiselect.insert.combo.less +++ b/src/less/widget/multiselect/multiselect.insert.combo.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; @val: transform .3s ease; .bi-multi-select-insert-combo{ & .multi-select-trigger-icon-button{ diff --git a/src/less/widget/multiselect/search/multiselect.search.pane.less b/src/less/widget/multiselect/search/multiselect.search.pane.less index 97dfa3ace..27560e350 100644 --- a/src/less/widget/multiselect/search/multiselect.search.pane.less +++ b/src/less/widget/multiselect/search/multiselect.search.pane.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-multi-select-search-pane{ diff --git a/src/less/widget/multiselect/trigger/button.checkselected.less b/src/less/widget/multiselect/trigger/button.checkselected.less index deea8a46b..35c00dec0 100644 --- a/src/less/widget/multiselect/trigger/button.checkselected.less +++ b/src/less/widget/multiselect/trigger/button.checkselected.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-multi-select-check-selected-button { z-index: 1; diff --git a/src/less/widget/multistringlist/multistringlist.insert.less b/src/less/widget/multistringlist/multistringlist.insert.less index 0f33e2779..63362ff92 100644 --- a/src/less/widget/multistringlist/multistringlist.insert.less +++ b/src/less/widget/multistringlist/multistringlist.insert.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-multi-select-insert-list{ & .bi-search-editor{ .border-corner-bottom-radius(0px, 0px) diff --git a/src/less/widget/multistringlist/multistringlist.less b/src/less/widget/multistringlist/multistringlist.less index fb8e5030e..b21d88709 100644 --- a/src/less/widget/multistringlist/multistringlist.less +++ b/src/less/widget/multistringlist/multistringlist.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-multi-select-list{ & .bi-search-editor{ .border-corner-bottom-radius(0px, 0px) diff --git a/src/less/widget/multitree/check/multi.tree.check.pane.less b/src/less/widget/multitree/check/multi.tree.check.pane.less index 3d40ae597..e193fb210 100644 --- a/src/less/widget/multitree/check/multi.tree.check.pane.less +++ b/src/less/widget/multitree/check/multi.tree.check.pane.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-multi-tree-check-pane { & .multi-tree-continue-select { diff --git a/src/less/widget/multitree/multi.tree.combo.less b/src/less/widget/multitree/multi.tree.combo.less index 73db11ef5..7e193b7d3 100644 --- a/src/less/widget/multitree/multi.tree.combo.less +++ b/src/less/widget/multitree/multi.tree.combo.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; @val: transform .3s ease; .bi-multi-tree-combo{ & .multi-select-trigger-icon-button{ diff --git a/src/less/widget/multitree/popup.multi.tree.less b/src/less/widget/multitree/popup.multi.tree.less index c19617edd..e1a55ac69 100644 --- a/src/less/widget/multitree/popup.multi.tree.less +++ b/src/less/widget/multitree/popup.multi.tree.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-multi-tree-popup{ & .popup-view-tree{ diff --git a/src/less/widget/multitree/trigger/multi.tree.button.checkselected.less b/src/less/widget/multitree/trigger/multi.tree.button.checkselected.less index b4903d3ba..55207b67a 100644 --- a/src/less/widget/multitree/trigger/multi.tree.button.checkselected.less +++ b/src/less/widget/multitree/trigger/multi.tree.button.checkselected.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-multi-tree-check-selected-button { & .trigger-check-selected{ diff --git a/src/less/widget/numbereditor/number.editor.less b/src/less/widget/numbereditor/number.editor.less index 6a86c5372..ba8ab84ac 100644 --- a/src/less/widget/numbereditor/number.editor.less +++ b/src/less/widget/numbereditor/number.editor.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-number-editor { .border-radius(2px); diff --git a/src/less/widget/numberinterval/numberinterval.less b/src/less/widget/numberinterval/numberinterval.less index 811caf679..67b5a835a 100644 --- a/src/less/widget/numberinterval/numberinterval.less +++ b/src/less/widget/numberinterval/numberinterval.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-number-interval { &.hack { diff --git a/src/less/widget/quarter/trigger.quarter.less b/src/less/widget/quarter/trigger.quarter.less index 7d50e896c..f50734871 100644 --- a/src/less/widget/quarter/trigger.quarter.less +++ b/src/less/widget/quarter/trigger.quarter.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-quarter-trigger{ .border-radius(2px); } \ No newline at end of file diff --git a/src/less/widget/searchmultiselect/searchmultiselect.less b/src/less/widget/searchmultiselect/searchmultiselect.less index ff7a3c41c..bd43f3a11 100644 --- a/src/less/widget/searchmultiselect/searchmultiselect.less +++ b/src/less/widget/searchmultiselect/searchmultiselect.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-search-multi-text-value-combo{ & .multi-select-trigger-icon-button{ diff --git a/src/less/widget/singleselect/search/singleselect.search.pane.less b/src/less/widget/singleselect/search/singleselect.search.pane.less index 0ac8837e0..e9fcd04ec 100644 --- a/src/less/widget/singleselect/search/singleselect.search.pane.less +++ b/src/less/widget/singleselect/search/singleselect.search.pane.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-single-select-search-pane{ diff --git a/src/less/widget/singleselect/singleselect.combo.less b/src/less/widget/singleselect/singleselect.combo.less index c32f46b04..c75ee780f 100644 --- a/src/less/widget/singleselect/singleselect.combo.less +++ b/src/less/widget/singleselect/singleselect.combo.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; @val: transform .3s ease; .bi-single-select-combo{ & .single-select-trigger-icon-button{ diff --git a/src/less/widget/singleslider/slider/widget.slider.less b/src/less/widget/singleslider/slider/widget.slider.less index 9ecc523d8..dc6f563b4 100644 --- a/src/less/widget/singleslider/slider/widget.slider.less +++ b/src/less/widget/singleslider/slider/widget.slider.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-single-slider-button { & .slider-button { diff --git a/src/less/widget/singleslider/track/widget.track.less b/src/less/widget/singleslider/track/widget.track.less index ba1fdebb3..833fdb4be 100644 --- a/src/less/widget/singleslider/track/widget.track.less +++ b/src/less/widget/singleslider/track/widget.track.less @@ -1,4 +1,4 @@ -@import "../../../index"; +@import "../../../index.less"; .bi-slider-track { & .gray-track { diff --git a/src/less/widget/timecombo/timecombo.less b/src/less/widget/timecombo/timecombo.less index 6ed973121..4929b415d 100644 --- a/src/less/widget/timecombo/timecombo.less +++ b/src/less/widget/timecombo/timecombo.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-time-trigger{ & .show-text { diff --git a/src/less/widget/timeinterval/dateinterval.less b/src/less/widget/timeinterval/dateinterval.less index 0680ad971..f39baa3f5 100644 --- a/src/less/widget/timeinterval/dateinterval.less +++ b/src/less/widget/timeinterval/dateinterval.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-date-interval{ &.time-error .bi-input{ diff --git a/src/less/widget/timeinterval/timeinterval.less b/src/less/widget/timeinterval/timeinterval.less index 81e252c20..6f64b0ae7 100644 --- a/src/less/widget/timeinterval/timeinterval.less +++ b/src/less/widget/timeinterval/timeinterval.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-time-interval{ & .bi-date-time-trigger{ diff --git a/src/less/widget/year/popup.year.less b/src/less/widget/year/popup.year.less index 814878f89..148f40508 100644 --- a/src/less/widget/year/popup.year.less +++ b/src/less/widget/year/popup.year.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-year-popup { & .year-popup-navigation { diff --git a/src/less/widget/year/trigger.year.less b/src/less/widget/year/trigger.year.less index 8b1c1296e..ed8d0d442 100644 --- a/src/less/widget/year/trigger.year.less +++ b/src/less/widget/year/trigger.year.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-year-trigger{ .border-radius(2px); } \ No newline at end of file diff --git a/src/less/widget/yearinterval/yearinterval.less b/src/less/widget/yearinterval/yearinterval.less index 8a4929dac..e2f7a497e 100644 --- a/src/less/widget/yearinterval/yearinterval.less +++ b/src/less/widget/yearinterval/yearinterval.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-year-interval{ &.time-error .bi-input{ diff --git a/src/less/widget/yearmonth/popup.yearmonth.less b/src/less/widget/yearmonth/popup.yearmonth.less index 614fbd4c8..1ec1ab0b0 100644 --- a/src/less/widget/yearmonth/popup.yearmonth.less +++ b/src/less/widget/yearmonth/popup.yearmonth.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-year-month-popup{ & .dynamic-year-month-pane { diff --git a/src/less/widget/yearmonthinterval/yearmonthinterval.less b/src/less/widget/yearmonthinterval/yearmonthinterval.less index 12db6801c..807140f67 100644 --- a/src/less/widget/yearmonthinterval/yearmonthinterval.less +++ b/src/less/widget/yearmonthinterval/yearmonthinterval.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-year-month-interval{ &.time-error .bi-input{ diff --git a/src/less/widget/yearquarter/popup.yearquarter.less b/src/less/widget/yearquarter/popup.yearquarter.less index 37c00f9dc..7c9d97ffb 100644 --- a/src/less/widget/yearquarter/popup.yearquarter.less +++ b/src/less/widget/yearquarter/popup.yearquarter.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-year-quarter-popup{ & .dynamic-year-quarter-pane { diff --git a/src/less/widget/yearquarterinterval/yearquarterinterval.less b/src/less/widget/yearquarterinterval/yearquarterinterval.less index 380e59fbe..35508cb67 100644 --- a/src/less/widget/yearquarterinterval/yearquarterinterval.less +++ b/src/less/widget/yearquarterinterval/yearquarterinterval.less @@ -1,4 +1,4 @@ -@import "../../index"; +@import "../../index.less"; .bi-year-quarter-interval{ &.time-error .bi-input{ diff --git a/src/router/router.js b/src/router/router.js index 54488f77f..7a44bb5d9 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -4,1846 +4,1846 @@ * @license MIT */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory()); -}(this, (function () { 'use strict'; - - /* */ - - function assert (condition, message) { - if (!condition) { - throw new Error(("[vue-router] " + message)) - } - } - - function warn (condition, message) { - if (!condition) { - typeof console !== 'undefined' && console.warn(("[vue-router] " + message)); - } - } - - function extend (a, b) { - for (var key in b) { - a[key] = b[key]; - } - return a - } - - /* */ - - var encodeReserveRE = /[!'()*]/g; - var encodeReserveReplacer = function (c) { return '%' + c.charCodeAt(0).toString(16); }; - var commaRE = /%2C/g; - - // fixed encodeURIComponent which is more conformant to RFC3986: - // - escapes [!'()*] - // - preserve commas - var encode = function (str) { return encodeURIComponent(str) - .replace(encodeReserveRE, encodeReserveReplacer) - .replace(commaRE, ','); }; - - function decode (str) { - try { - return decodeURIComponent(str) - } catch (err) { - { - warn(false, ("Error decoding \"" + str + "\". Leaving it intact.")); + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory()); + }(this, (function () { 'use strict'; + + /* */ + + function assert (condition, message) { + if (!condition) { + throw new Error(("[vue-router] " + message)) + } + } + + function warn (condition, message) { + if (!condition) { + typeof console !== 'undefined' && console.warn(("[vue-router] " + message)); } } - return str - } - - function resolveQuery ( + + function extend (a, b) { + for (var key in b) { + a[key] = b[key]; + } + return a + } + + /* */ + + var encodeReserveRE = /[!'()*]/g; + var encodeReserveReplacer = function (c) { return '%' + c.charCodeAt(0).toString(16); }; + var commaRE = /%2C/g; + + // fixed encodeURIComponent which is more conformant to RFC3986: + // - escapes [!'()*] + // - preserve commas + var encode = function (str) { return encodeURIComponent(str) + .replace(encodeReserveRE, encodeReserveReplacer) + .replace(commaRE, ','); }; + + function decode (str) { + try { + return decodeURIComponent(str) + } catch (err) { + { + warn(false, ("Error decoding \"" + str + "\". Leaving it intact.")); + } + } + return str + } + + function resolveQuery ( query, extraQuery, _parseQuery - ) { - if ( extraQuery === void 0 ) extraQuery = {}; - - var parse = _parseQuery || parseQuery; - var parsedQuery; - try { - parsedQuery = parse(query || ''); - } catch (e) { - warn(false, e.message); - parsedQuery = {}; - } - for (var key in extraQuery) { - var value = extraQuery[key]; - parsedQuery[key] = Array.isArray(value) + ) { + if ( extraQuery === void 0 ) extraQuery = {}; + + var parse = _parseQuery || parseQuery; + var parsedQuery; + try { + parsedQuery = parse(query || ''); + } catch (e) { + warn(false, e.message); + parsedQuery = {}; + } + for (var key in extraQuery) { + var value = extraQuery[key]; + parsedQuery[key] = Array.isArray(value) ? value.map(castQueryParamValue) : castQueryParamValue(value); + } + return parsedQuery } - return parsedQuery - } - - var castQueryParamValue = function (value) { return (value == null || typeof value === 'object' ? value : String(value)); }; - - function parseQuery (query) { - var res = {}; - - query = query.trim().replace(/^(\?|#|&)/, ''); - - if (!query) { + + var castQueryParamValue = function (value) { return (value == null || typeof value === 'object' ? value : String(value)); }; + + function parseQuery (query) { + var res = {}; + + query = query.trim().replace(/^(\?|#|&)/, ''); + + if (!query) { + return res + } + + query.split('&').forEach(function (param) { + var parts = param.replace(/\+/g, ' ').split('='); + var key = decode(parts.shift()); + var val = parts.length > 0 ? decode(parts.join('=')) : null; + + if (res[key] === undefined) { + res[key] = val; + } else if (Array.isArray(res[key])) { + res[key].push(val); + } else { + res[key] = [res[key], val]; + } + }); + return res } - - query.split('&').forEach(function (param) { - var parts = param.replace(/\+/g, ' ').split('='); - var key = decode(parts.shift()); - var val = parts.length > 0 ? decode(parts.join('=')) : null; - - if (res[key] === undefined) { - res[key] = val; - } else if (Array.isArray(res[key])) { - res[key].push(val); - } else { - res[key] = [res[key], val]; - } - }); - - return res - } - - function stringifyQuery (obj) { - var res = obj + + function stringifyQuery (obj) { + var res = obj ? Object.keys(obj) - .map(function (key) { - var val = obj[key]; - - if (val === undefined) { - return '' - } - - if (val === null) { - return encode(key) - } - - if (Array.isArray(val)) { - var result = []; - val.forEach(function (val2) { - if (val2 === undefined) { - return - } - if (val2 === null) { - result.push(encode(key)); - } else { - result.push(encode(key) + '=' + encode(val2)); - } - }); - return result.join('&') - } - - return encode(key) + '=' + encode(val) - }) - .filter(function (x) { return x.length > 0; }) - .join('&') + .map(function (key) { + var val = obj[key]; + + if (val === undefined) { + return '' + } + + if (val === null) { + return encode(key) + } + + if (Array.isArray(val)) { + var result = []; + val.forEach(function (val2) { + if (val2 === undefined) { + return + } + if (val2 === null) { + result.push(encode(key)); + } else { + result.push(encode(key) + '=' + encode(val2)); + } + }); + return result.join('&') + } + + return encode(key) + '=' + encode(val) + }) + .filter(function (x) { return x.length > 0; }) + .join('&') : null; - return res ? ("?" + res) : '' - } - - /* */ - - var trailingSlashRE = /\/?$/; - - function createRoute ( + return res ? ("?" + res) : '' + } + + /* */ + + var trailingSlashRE = /\/?$/; + + function createRoute ( record, location, redirectedFrom, router - ) { - var stringifyQuery = router && router.options.stringifyQuery; - - var query = location.query || {}; - try { - query = clone(query); - } catch (e) {} - - var route = { - name: location.name || (record && record.name), - meta: (record && record.meta) || {}, - path: location.path || '/', - hash: location.hash || '', - query: query, - params: location.params || {}, - fullPath: getFullPath(location, stringifyQuery), - matched: record ? formatMatch(record) : [] - }; - if (redirectedFrom) { - route.redirectedFrom = getFullPath(redirectedFrom, stringifyQuery); - } - return Object.freeze(route) - } - - function clone (value) { - if (Array.isArray(value)) { - return value.map(clone) - } else if (value && typeof value === 'object') { - var res = {}; - for (var key in value) { - res[key] = clone(value[key]); + ) { + var stringifyQuery = router && router.options.stringifyQuery; + + var query = location.query || {}; + try { + query = clone(query); + } catch (e) {} + + var route = { + name: location.name || (record && record.name), + meta: (record && record.meta) || {}, + path: location.path || '/', + hash: location.hash || '', + query: query, + params: location.params || {}, + fullPath: getFullPath(location, stringifyQuery), + matched: record ? formatMatch(record) : [] + }; + if (redirectedFrom) { + route.redirectedFrom = getFullPath(redirectedFrom, stringifyQuery); + } + return Object.freeze(route) + } + + function clone (value) { + if (Array.isArray(value)) { + return value.map(clone) + } else if (value && typeof value === 'object') { + var res = {}; + for (var key in value) { + res[key] = clone(value[key]); + } + return res + } else { + return value + } + } + + // the starting route that represents the initial state + var START = createRoute(null, { + path: '/' + }); + + function formatMatch (record) { + var res = []; + while (record) { + res.unshift(record); + record = record.parent; } return res - } else { - return value - } - } - - // the starting route that represents the initial state - var START = createRoute(null, { - path: '/' - }); - - function formatMatch (record) { - var res = []; - while (record) { - res.unshift(record); - record = record.parent; - } - return res - } - - function getFullPath ( + } + + function getFullPath ( ref, _stringifyQuery - ) { - var path = ref.path; - var query = ref.query; if ( query === void 0 ) query = {}; - var hash = ref.hash; if ( hash === void 0 ) hash = ''; - - var stringify = _stringifyQuery || stringifyQuery; - return (path || '/') + stringify(query) + hash - } - - function isSameRoute (a, b, onlyPath) { - if (b === START) { - return a === b - } else if (!b) { - return false - } else if (a.path && b.path) { - return a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') && (onlyPath || + ) { + var path = ref.path; + var query = ref.query; if ( query === void 0 ) query = {}; + var hash = ref.hash; if ( hash === void 0 ) hash = ''; + + var stringify = _stringifyQuery || stringifyQuery; + return (path || '/') + stringify(query) + hash + } + + function isSameRoute (a, b, onlyPath) { + if (b === START) { + return a === b + } else if (!b) { + return false + } else if (a.path && b.path) { + return a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') && (onlyPath || a.hash === b.hash && isObjectEqual(a.query, b.query)) - } else if (a.name && b.name) { - return ( + } else if (a.name && b.name) { + return ( a.name === b.name && (onlyPath || ( - a.hash === b.hash && - isObjectEqual(a.query, b.query) && - isObjectEqual(a.params, b.params)) + a.hash === b.hash && + isObjectEqual(a.query, b.query) && + isObjectEqual(a.params, b.params)) ) - ) - } else { - return false + ) + } else { + return false + } } - } - - function isObjectEqual (a, b) { - if ( a === void 0 ) a = {}; - if ( b === void 0 ) b = {}; - - // handle null value #1566 - if (!a || !b) { return a === b } - var aKeys = Object.keys(a).sort(); - var bKeys = Object.keys(b).sort(); - if (aKeys.length !== bKeys.length) { - return false + + function isObjectEqual (a, b) { + if ( a === void 0 ) a = {}; + if ( b === void 0 ) b = {}; + + // handle null value #1566 + if (!a || !b) { return a === b } + var aKeys = Object.keys(a).sort(); + var bKeys = Object.keys(b).sort(); + if (aKeys.length !== bKeys.length) { + return false + } + return aKeys.every(function (key, i) { + var aVal = a[key]; + var bKey = bKeys[i]; + if (bKey !== key) { return false } + var bVal = b[key]; + // query values can be null and undefined + if (aVal == null || bVal == null) { return aVal === bVal } + // check nested equality + if (typeof aVal === 'object' && typeof bVal === 'object') { + return isObjectEqual(aVal, bVal) + } + return String(aVal) === String(bVal) + }) } - return aKeys.every(function (key, i) { - var aVal = a[key]; - var bKey = bKeys[i]; - if (bKey !== key) { return false } - var bVal = b[key]; - // query values can be null and undefined - if (aVal == null || bVal == null) { return aVal === bVal } - // check nested equality - if (typeof aVal === 'object' && typeof bVal === 'object') { - return isObjectEqual(aVal, bVal) - } - return String(aVal) === String(bVal) - }) - } - - function isIncludedRoute (current, target) { - return ( + + function isIncludedRoute (current, target) { + return ( current.path.replace(trailingSlashRE, '/').indexOf( - target.path.replace(trailingSlashRE, '/') + target.path.replace(trailingSlashRE, '/') ) === 0 && (!target.hash || current.hash === target.hash) && queryIncludes(current.query, target.query) - ) - } - - function queryIncludes (current, target) { - for (var key in target) { - if (!(key in current)) { - return false + ) + } + + function queryIncludes (current, target) { + for (var key in target) { + if (!(key in current)) { + return false + } } + return true } - return true - } - - function handleRouteEntered (route) { - for (var i = 0; i < route.matched.length; i++) { - var record = route.matched[i]; - for (var name in record.instances) { - var instance = record.instances[name]; - var cbs = record.enteredCbs[name]; - if (!instance || !cbs) { continue } - delete record.enteredCbs[name]; - for (var i$1 = 0; i$1 < cbs.length; i$1++) { - if (!instance._isBeingDestroyed) { cbs[i$1](instance); } + + function handleRouteEntered (route) { + for (var i = 0; i < route.matched.length; i++) { + var record = route.matched[i]; + for (var name in record.instances) { + var instance = record.instances[name]; + var cbs = record.enteredCbs[name]; + if (!instance || !cbs) { continue } + delete record.enteredCbs[name]; + for (var i$1 = 0; i$1 < cbs.length; i$1++) { + if (!instance._isBeingDestroyed) { cbs[i$1](instance); } + } } } } - } - - // var View = { - // name: 'RouterView', - // functional: true, - // props: { - // name: { - // type: String, - // default: 'default' - // } - // }, - // render: function render (_, ref) { - // var props = ref.props; - // var children = ref.children; - // var parent = ref.parent; - // var data = ref.data; - - // // used by devtools to display a router-view badge - // data.routerView = true; - - // // directly use parent context's createElement() function - // // so that components rendered by router-view can resolve named slots - // var h = parent.$createElement; - // var name = props.name; - // var route = parent.$route; - // var cache = parent._routerViewCache || (parent._routerViewCache = {}); - - // // determine current view depth, also check to see if the tree - // // has been toggled inactive but kept-alive. - // var depth = 0; - // var inactive = false; - // while (parent && parent._routerRoot !== parent) { - // var vnodeData = parent.$vnode ? parent.$vnode.data : {}; - // if (vnodeData.routerView) { - // depth++; - // } - // if (vnodeData.keepAlive && parent._directInactive && parent._inactive) { - // inactive = true; - // } - // parent = parent.$parent; - // } - // data.routerViewDepth = depth; - - // // render previous view if the tree is inactive and kept-alive - // if (inactive) { - // var cachedData = cache[name]; - // var cachedComponent = cachedData && cachedData.component; - // if (cachedComponent) { - // // #2301 - // // pass props - // if (cachedData.configProps) { - // fillPropsinData(cachedComponent, data, cachedData.route, cachedData.configProps); - // } - // return h(cachedComponent, data, children) - // } else { - // // render previous empty view - // return h() - // } - // } - - // var matched = route.matched[depth]; - // var component = matched && matched.components[name]; - - // // render empty node if no matched route or no config component - // if (!matched || !component) { - // cache[name] = null; - // return h() - // } - - // // cache component - // cache[name] = { component: component }; - - // // attach instance registration hook - // // this will be called in the instance's injected lifecycle hooks - // data.registerRouteInstance = function (vm, val) { - // // val could be undefined for unregistration - // var current = matched.instances[name]; - // if ( - // (val && current !== vm) || - // (!val && current === vm) - // ) { - // matched.instances[name] = val; - // } - // } - - // // also register instance in prepatch hook - // // in case the same component instance is reused across different routes - // ;(data.hook || (data.hook = {})).prepatch = function (_, vnode) { - // matched.instances[name] = vnode.componentInstance; - // }; - - // // register instance in init hook - // // in case kept-alive component be actived when routes changed - // data.hook.init = function (vnode) { - // if (vnode.data.keepAlive && - // vnode.componentInstance && - // vnode.componentInstance !== matched.instances[name] - // ) { - // matched.instances[name] = vnode.componentInstance; - // } - - // // if the route transition has already been confirmed then we weren't - // // able to call the cbs during confirmation as the component was not - // // registered yet, so we call it here. - // handleRouteEntered(route); - // }; - - // var configProps = matched.props && matched.props[name]; - // // save route and configProps in cache - // if (configProps) { - // extend(cache[name], { - // route: route, - // configProps: configProps - // }); - // fillPropsinData(component, data, route, configProps); - // } - - // return h(component, data, children) - // } - // }; - - // function fillPropsinData (component, data, route, configProps) { - // // resolve props - // var propsToPass = data.props = resolveProps(route, configProps); - // if (propsToPass) { - // // clone to prevent mutation - // propsToPass = data.props = extend({}, propsToPass); - // // pass non-declared props as attrs - // var attrs = data.attrs = data.attrs || {}; - // for (var key in propsToPass) { - // if (!component.props || !(key in component.props)) { - // attrs[key] = propsToPass[key]; - // delete propsToPass[key]; - // } - // } - // } - // } - - // function resolveProps (route, config) { - // switch (typeof config) { - // case 'undefined': - // return - // case 'object': - // return config - // case 'function': - // return config(route) - // case 'boolean': - // return config ? route.params : undefined - // default: - // { - // warn( - // false, - // "props in \"" + (route.path) + "\" is a " + (typeof config) + ", " + - // "expecting an object, function or boolean." - // ); - // } - // } - // } - - /* */ - - function resolvePath ( + + // var View = { + // name: 'RouterView', + // functional: true, + // props: { + // name: { + // type: String, + // default: 'default' + // } + // }, + // render: function render (_, ref) { + // var props = ref.props; + // var children = ref.children; + // var parent = ref.parent; + // var data = ref.data; + + // // used by devtools to display a router-view badge + // data.routerView = true; + + // // directly use parent context's createElement() function + // // so that components rendered by router-view can resolve named slots + // var h = parent.$createElement; + // var name = props.name; + // var route = parent.$route; + // var cache = parent._routerViewCache || (parent._routerViewCache = {}); + + // // determine current view depth, also check to see if the tree + // // has been toggled inactive but kept-alive. + // var depth = 0; + // var inactive = false; + // while (parent && parent._routerRoot !== parent) { + // var vnodeData = parent.$vnode ? parent.$vnode.data : {}; + // if (vnodeData.routerView) { + // depth++; + // } + // if (vnodeData.keepAlive && parent._directInactive && parent._inactive) { + // inactive = true; + // } + // parent = parent.$parent; + // } + // data.routerViewDepth = depth; + + // // render previous view if the tree is inactive and kept-alive + // if (inactive) { + // var cachedData = cache[name]; + // var cachedComponent = cachedData && cachedData.component; + // if (cachedComponent) { + // // #2301 + // // pass props + // if (cachedData.configProps) { + // fillPropsinData(cachedComponent, data, cachedData.route, cachedData.configProps); + // } + // return h(cachedComponent, data, children) + // } else { + // // render previous empty view + // return h() + // } + // } + + // var matched = route.matched[depth]; + // var component = matched && matched.components[name]; + + // // render empty node if no matched route or no config component + // if (!matched || !component) { + // cache[name] = null; + // return h() + // } + + // // cache component + // cache[name] = { component: component }; + + // // attach instance registration hook + // // this will be called in the instance's injected lifecycle hooks + // data.registerRouteInstance = function (vm, val) { + // // val could be undefined for unregistration + // var current = matched.instances[name]; + // if ( + // (val && current !== vm) || + // (!val && current === vm) + // ) { + // matched.instances[name] = val; + // } + // } + + // // also register instance in prepatch hook + // // in case the same component instance is reused across different routes + // ;(data.hook || (data.hook = {})).prepatch = function (_, vnode) { + // matched.instances[name] = vnode.componentInstance; + // }; + + // // register instance in init hook + // // in case kept-alive component be actived when routes changed + // data.hook.init = function (vnode) { + // if (vnode.data.keepAlive && + // vnode.componentInstance && + // vnode.componentInstance !== matched.instances[name] + // ) { + // matched.instances[name] = vnode.componentInstance; + // } + + // // if the route transition has already been confirmed then we weren't + // // able to call the cbs during confirmation as the component was not + // // registered yet, so we call it here. + // handleRouteEntered(route); + // }; + + // var configProps = matched.props && matched.props[name]; + // // save route and configProps in cache + // if (configProps) { + // extend(cache[name], { + // route: route, + // configProps: configProps + // }); + // fillPropsinData(component, data, route, configProps); + // } + + // return h(component, data, children) + // } + // }; + + // function fillPropsinData (component, data, route, configProps) { + // // resolve props + // var propsToPass = data.props = resolveProps(route, configProps); + // if (propsToPass) { + // // clone to prevent mutation + // propsToPass = data.props = extend({}, propsToPass); + // // pass non-declared props as attrs + // var attrs = data.attrs = data.attrs || {}; + // for (var key in propsToPass) { + // if (!component.props || !(key in component.props)) { + // attrs[key] = propsToPass[key]; + // delete propsToPass[key]; + // } + // } + // } + // } + + // function resolveProps (route, config) { + // switch (typeof config) { + // case 'undefined': + // return + // case 'object': + // return config + // case 'function': + // return config(route) + // case 'boolean': + // return config ? route.params : undefined + // default: + // { + // warn( + // false, + // "props in \"" + (route.path) + "\" is a " + (typeof config) + ", " + + // "expecting an object, function or boolean." + // ); + // } + // } + // } + + /* */ + + function resolvePath ( relative, base, append - ) { - var firstChar = relative.charAt(0); - if (firstChar === '/') { - return relative - } - - if (firstChar === '?' || firstChar === '#') { - return base + relative - } - - var stack = base.split('/'); - - // remove trailing segment if: - // - not appending - // - appending to trailing slash (last segment is empty) - if (!append || !stack[stack.length - 1]) { - stack.pop(); - } - - // resolve relative path - var segments = relative.replace(/^\//, '').split('/'); - for (var i = 0; i < segments.length; i++) { - var segment = segments[i]; - if (segment === '..') { + ) { + var firstChar = relative.charAt(0); + if (firstChar === '/') { + return relative + } + + if (firstChar === '?' || firstChar === '#') { + return base + relative + } + + var stack = base.split('/'); + + // remove trailing segment if: + // - not appending + // - appending to trailing slash (last segment is empty) + if (!append || !stack[stack.length - 1]) { stack.pop(); - } else if (segment !== '.') { - stack.push(segment); - } - } - - // ensure leading slash - if (stack[0] !== '') { - stack.unshift(''); - } - - return stack.join('/') - } - - function parsePath (path) { - var hash = ''; - var query = ''; - - var hashIndex = path.indexOf('#'); - if (hashIndex >= 0) { - hash = path.slice(hashIndex); - path = path.slice(0, hashIndex); - } - - var queryIndex = path.indexOf('?'); - if (queryIndex >= 0) { - query = path.slice(queryIndex + 1); - path = path.slice(0, queryIndex); - } - - return { - path: path, - query: query, - hash: hash - } - } - - function cleanPath (path) { - return path.replace(/\/\//g, '/') - } - - var isarray = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) == '[object Array]'; - }; - - /** - * Expose `pathToRegexp`. - */ - var pathToRegexp_1 = pathToRegexp; - var parse_1 = parse; - var compile_1 = compile; - var tokensToFunction_1 = tokensToFunction; - var tokensToRegExp_1 = tokensToRegExp; - - /** - * The main path matching regexp utility. - * - * @type {RegExp} - */ - var PATH_REGEXP = new RegExp([ - // Match escaped characters that would otherwise appear in future matches. - // This allows the user to escape special characters that won't transform. - '(\\\\.)', - // Match Express-style parameters and un-named parameters with a prefix - // and optional suffixes. Matches appear as: - // - // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined] - // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined] - // "/*" => ["/", undefined, undefined, undefined, undefined, "*"] - '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))' - ].join('|'), 'g'); - - /** - * Parse a string for the raw tokens. - * - * @param {string} str - * @param {Object=} options - * @return {!Array} - */ - function parse (str, options) { - var tokens = []; - var key = 0; - var index = 0; - var path = ''; - var defaultDelimiter = options && options.delimiter || '/'; - var res; - - while ((res = PATH_REGEXP.exec(str)) != null) { - var m = res[0]; - var escaped = res[1]; - var offset = res.index; - path += str.slice(index, offset); - index = offset + m.length; - - // Ignore already escaped sequences. - if (escaped) { - path += escaped[1]; - continue - } - - var next = str[index]; - var prefix = res[2]; - var name = res[3]; - var capture = res[4]; - var group = res[5]; - var modifier = res[6]; - var asterisk = res[7]; - - // Push the current path onto the tokens. + } + + // resolve relative path + var segments = relative.replace(/^\//, '').split('/'); + for (var i = 0; i < segments.length; i++) { + var segment = segments[i]; + if (segment === '..') { + stack.pop(); + } else if (segment !== '.') { + stack.push(segment); + } + } + + // ensure leading slash + if (stack[0] !== '') { + stack.unshift(''); + } + + return stack.join('/') + } + + function parsePath (path) { + var hash = ''; + var query = ''; + + var hashIndex = path.indexOf('#'); + if (hashIndex >= 0) { + hash = path.slice(hashIndex); + path = path.slice(0, hashIndex); + } + + var queryIndex = path.indexOf('?'); + if (queryIndex >= 0) { + query = path.slice(queryIndex + 1); + path = path.slice(0, queryIndex); + } + + return { + path: path, + query: query, + hash: hash + } + } + + function cleanPath (path) { + return path.replace(/\/\//g, '/') + } + + var isarray = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; + }; + + /** + * Expose `pathToRegexp`. + */ + var pathToRegexp_1 = pathToRegexp; + var parse_1 = parse; + var compile_1 = compile; + var tokensToFunction_1 = tokensToFunction; + var tokensToRegExp_1 = tokensToRegExp; + + /** + * The main path matching regexp utility. + * + * @type {RegExp} + */ + var PATH_REGEXP = new RegExp([ + // Match escaped characters that would otherwise appear in future matches. + // This allows the user to escape special characters that won't transform. + '(\\\\.)', + // Match Express-style parameters and un-named parameters with a prefix + // and optional suffixes. Matches appear as: + // + // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined] + // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined] + // "/*" => ["/", undefined, undefined, undefined, undefined, "*"] + '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))' + ].join('|'), 'g'); + + /** + * Parse a string for the raw tokens. + * + * @param {string} str + * @param {Object=} options + * @return {!Array} + */ + function parse (str, options) { + var tokens = []; + var key = 0; + var index = 0; + var path = ''; + var defaultDelimiter = options && options.delimiter || '/'; + var res; + + while ((res = PATH_REGEXP.exec(str)) != null) { + var m = res[0]; + var escaped = res[1]; + var offset = res.index; + path += str.slice(index, offset); + index = offset + m.length; + + // Ignore already escaped sequences. + if (escaped) { + path += escaped[1]; + continue + } + + var next = str[index]; + var prefix = res[2]; + var name = res[3]; + var capture = res[4]; + var group = res[5]; + var modifier = res[6]; + var asterisk = res[7]; + + // Push the current path onto the tokens. + if (path) { + tokens.push(path); + path = ''; + } + + var partial = prefix != null && next != null && next !== prefix; + var repeat = modifier === '+' || modifier === '*'; + var optional = modifier === '?' || modifier === '*'; + var delimiter = res[2] || defaultDelimiter; + var pattern = capture || group; + + tokens.push({ + name: name || key++, + prefix: prefix || '', + delimiter: delimiter, + optional: optional, + repeat: repeat, + partial: partial, + asterisk: !!asterisk, + pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?') + }); + } + + // Match any characters still remaining. + if (index < str.length) { + path += str.substr(index); + } + + // If the path exists, push it onto the end. if (path) { tokens.push(path); - path = ''; - } - - var partial = prefix != null && next != null && next !== prefix; - var repeat = modifier === '+' || modifier === '*'; - var optional = modifier === '?' || modifier === '*'; - var delimiter = res[2] || defaultDelimiter; - var pattern = capture || group; - - tokens.push({ - name: name || key++, - prefix: prefix || '', - delimiter: delimiter, - optional: optional, - repeat: repeat, - partial: partial, - asterisk: !!asterisk, - pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?') - }); + } + + return tokens + } + + /** + * Compile a string to a template function for the path. + * + * @param {string} str + * @param {Object=} options + * @return {!function(Object=, Object=)} + */ + function compile (str, options) { + return tokensToFunction(parse(str, options), options) + } + + /** + * Prettier encoding of URI path segments. + * + * @param {string} + * @return {string} + */ + function encodeURIComponentPretty (str) { + return encodeURI(str).replace(/[\/?#]/g, function (c) { + return '%' + c.charCodeAt(0).toString(16).toUpperCase() + }) } - - // Match any characters still remaining. - if (index < str.length) { - path += str.substr(index); - } - - // If the path exists, push it onto the end. - if (path) { - tokens.push(path); - } - - return tokens - } - - /** - * Compile a string to a template function for the path. - * - * @param {string} str - * @param {Object=} options - * @return {!function(Object=, Object=)} - */ - function compile (str, options) { - return tokensToFunction(parse(str, options), options) - } - - /** - * Prettier encoding of URI path segments. - * - * @param {string} - * @return {string} - */ - function encodeURIComponentPretty (str) { - return encodeURI(str).replace(/[\/?#]/g, function (c) { - return '%' + c.charCodeAt(0).toString(16).toUpperCase() - }) - } - - /** - * Encode the asterisk parameter. Similar to `pretty`, but allows slashes. - * - * @param {string} - * @return {string} - */ - function encodeAsterisk (str) { - return encodeURI(str).replace(/[?#]/g, function (c) { - return '%' + c.charCodeAt(0).toString(16).toUpperCase() - }) - } - - /** - * Expose a method for transforming tokens into the path function. - */ - function tokensToFunction (tokens, options) { - // Compile all the tokens into regexps. - var matches = new Array(tokens.length); - - // Compile all the patterns before compilation. - for (var i = 0; i < tokens.length; i++) { - if (typeof tokens[i] === 'object') { - matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$', flags(options)); - } - } - - return function (obj, opts) { - var path = ''; - var data = obj || {}; - var options = opts || {}; - var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent; - + + /** + * Encode the asterisk parameter. Similar to `pretty`, but allows slashes. + * + * @param {string} + * @return {string} + */ + function encodeAsterisk (str) { + return encodeURI(str).replace(/[?#]/g, function (c) { + return '%' + c.charCodeAt(0).toString(16).toUpperCase() + }) + } + + /** + * Expose a method for transforming tokens into the path function. + */ + function tokensToFunction (tokens, options) { + // Compile all the tokens into regexps. + var matches = new Array(tokens.length); + + // Compile all the patterns before compilation. for (var i = 0; i < tokens.length; i++) { - var token = tokens[i]; - - if (typeof token === 'string') { - path += token; - - continue + if (typeof tokens[i] === 'object') { + matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$', flags(options)); } - - var value = data[token.name]; - var segment; - - if (value == null) { - if (token.optional) { - // Prepend partial segment prefixes. - if (token.partial) { - path += token.prefix; - } - + } + + return function (obj, opts) { + var path = ''; + var data = obj || {}; + var options = opts || {}; + var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent; + + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + + if (typeof token === 'string') { + path += token; + continue - } else { - throw new TypeError('Expected "' + token.name + '" to be defined') - } - } - - if (isarray(value)) { - if (!token.repeat) { - throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`') } - - if (value.length === 0) { + + var value = data[token.name]; + var segment; + + if (value == null) { if (token.optional) { + // Prepend partial segment prefixes. + if (token.partial) { + path += token.prefix; + } + continue } else { - throw new TypeError('Expected "' + token.name + '" to not be empty') + throw new TypeError('Expected "' + token.name + '" to be defined') } } - - for (var j = 0; j < value.length; j++) { - segment = encode(value[j]); - - if (!matches[i].test(segment)) { - throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`') + + if (isarray(value)) { + if (!token.repeat) { + throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`') + } + + if (value.length === 0) { + if (token.optional) { + continue + } else { + throw new TypeError('Expected "' + token.name + '" to not be empty') + } } - - path += (j === 0 ? token.prefix : token.delimiter) + segment; + + for (var j = 0; j < value.length; j++) { + segment = encode(value[j]); + + if (!matches[i].test(segment)) { + throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`') + } + + path += (j === 0 ? token.prefix : token.delimiter) + segment; + } + + continue } - - continue - } - - segment = token.asterisk ? encodeAsterisk(value) : encode(value); - - if (!matches[i].test(segment)) { - throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"') + + segment = token.asterisk ? encodeAsterisk(value) : encode(value); + + if (!matches[i].test(segment)) { + throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"') + } + + path += token.prefix + segment; } - - path += token.prefix + segment; - } - - return path - } - } - - /** - * Escape a regular expression string. - * - * @param {string} str - * @return {string} - */ - function escapeString (str) { - return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1') - } - - /** - * Escape the capturing group by escaping special characters and meaning. - * - * @param {string} group - * @return {string} - */ - function escapeGroup (group) { - return group.replace(/([=!:$\/()])/g, '\\$1') - } - - /** - * Attach the keys as a property of the regexp. - * - * @param {!RegExp} re - * @param {Array} keys - * @return {!RegExp} - */ - function attachKeys (re, keys) { - re.keys = keys; - return re - } - - /** - * Get the flags for a regexp from the options. - * - * @param {Object} options - * @return {string} - */ - function flags (options) { - return options && options.sensitive ? '' : 'i' - } - - /** - * Pull out keys from a regexp. - * - * @param {!RegExp} path - * @param {!Array} keys - * @return {!RegExp} - */ - function regexpToRegexp (path, keys) { - // Use a negative lookahead to match only capturing groups. - var groups = path.source.match(/\((?!\?)/g); - - if (groups) { - for (var i = 0; i < groups.length; i++) { - keys.push({ - name: i, - prefix: null, - delimiter: null, - optional: false, - repeat: false, - partial: false, - asterisk: false, - pattern: null - }); + + return path } } - - return attachKeys(path, keys) - } - - /** - * Transform an array into a regexp. - * - * @param {!Array} path - * @param {Array} keys - * @param {!Object} options - * @return {!RegExp} - */ - function arrayToRegexp (path, keys, options) { - var parts = []; - - for (var i = 0; i < path.length; i++) { - parts.push(pathToRegexp(path[i], keys, options).source); - } - - var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options)); - - return attachKeys(regexp, keys) - } - - /** - * Create a path regexp from string input. - * - * @param {string} path - * @param {!Array} keys - * @param {!Object} options - * @return {!RegExp} - */ - function stringToRegexp (path, keys, options) { - return tokensToRegExp(parse(path, options), keys, options) - } - - /** - * Expose a function for taking tokens and returning a RegExp. - * - * @param {!Array} tokens - * @param {(Array|Object)=} keys - * @param {Object=} options - * @return {!RegExp} - */ - function tokensToRegExp (tokens, keys, options) { - if (!isarray(keys)) { - options = /** @type {!Object} */ (keys || options); - keys = []; - } - - options = options || {}; - - var strict = options.strict; - var end = options.end !== false; - var route = ''; - - // Iterate over the tokens and create our regexp string. - for (var i = 0; i < tokens.length; i++) { - var token = tokens[i]; - - if (typeof token === 'string') { - route += escapeString(token); - } else { - var prefix = escapeString(token.prefix); - var capture = '(?:' + token.pattern + ')'; - - keys.push(token); - - if (token.repeat) { - capture += '(?:' + prefix + capture + ')*'; + + /** + * Escape a regular expression string. + * + * @param {string} str + * @return {string} + */ + function escapeString (str) { + return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1') + } + + /** + * Escape the capturing group by escaping special characters and meaning. + * + * @param {string} group + * @return {string} + */ + function escapeGroup (group) { + return group.replace(/([=!:$\/()])/g, '\\$1') + } + + /** + * Attach the keys as a property of the regexp. + * + * @param {!RegExp} re + * @param {Array} keys + * @return {!RegExp} + */ + function attachKeys (re, keys) { + re.keys = keys; + return re + } + + /** + * Get the flags for a regexp from the options. + * + * @param {Object} options + * @return {string} + */ + function flags (options) { + return options && options.sensitive ? '' : 'i' + } + + /** + * Pull out keys from a regexp. + * + * @param {!RegExp} path + * @param {!Array} keys + * @return {!RegExp} + */ + function regexpToRegexp (path, keys) { + // Use a negative lookahead to match only capturing groups. + var groups = path.source.match(/\((?!\?)/g); + + if (groups) { + for (var i = 0; i < groups.length; i++) { + keys.push({ + name: i, + prefix: null, + delimiter: null, + optional: false, + repeat: false, + partial: false, + asterisk: false, + pattern: null + }); } - - if (token.optional) { - if (!token.partial) { - capture = '(?:' + prefix + '(' + capture + '))?'; + } + + return attachKeys(path, keys) + } + + /** + * Transform an array into a regexp. + * + * @param {!Array} path + * @param {Array} keys + * @param {!Object} options + * @return {!RegExp} + */ + function arrayToRegexp (path, keys, options) { + var parts = []; + + for (var i = 0; i < path.length; i++) { + parts.push(pathToRegexp(path[i], keys, options).source); + } + + var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options)); + + return attachKeys(regexp, keys) + } + + /** + * Create a path regexp from string input. + * + * @param {string} path + * @param {!Array} keys + * @param {!Object} options + * @return {!RegExp} + */ + function stringToRegexp (path, keys, options) { + return tokensToRegExp(parse(path, options), keys, options) + } + + /** + * Expose a function for taking tokens and returning a RegExp. + * + * @param {!Array} tokens + * @param {(Array|Object)=} keys + * @param {Object=} options + * @return {!RegExp} + */ + function tokensToRegExp (tokens, keys, options) { + if (!isarray(keys)) { + options = /** @type {!Object} */ (keys || options); + keys = []; + } + + options = options || {}; + + var strict = options.strict; + var end = options.end !== false; + var route = ''; + + // Iterate over the tokens and create our regexp string. + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + + if (typeof token === 'string') { + route += escapeString(token); + } else { + var prefix = escapeString(token.prefix); + var capture = '(?:' + token.pattern + ')'; + + keys.push(token); + + if (token.repeat) { + capture += '(?:' + prefix + capture + ')*'; + } + + if (token.optional) { + if (!token.partial) { + capture = '(?:' + prefix + '(' + capture + '))?'; + } else { + capture = prefix + '(' + capture + ')?'; + } } else { - capture = prefix + '(' + capture + ')?'; + capture = prefix + '(' + capture + ')'; } - } else { - capture = prefix + '(' + capture + ')'; + + route += capture; } - - route += capture; - } - } - - var delimiter = escapeString(options.delimiter || '/'); - var endsWithDelimiter = route.slice(-delimiter.length) === delimiter; - - // In non-strict mode we allow a slash at the end of match. If the path to - // match already ends with a slash, we remove it for consistency. The slash - // is valid at the end of a path match, not in the middle. This is important - // in non-ending mode, where "/test/" shouldn't match "/test//route". - if (!strict) { - route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?'; - } - - if (end) { - route += '$'; - } else { - // In non-ending mode, we need the capturing groups to match as much as - // possible by using a positive lookahead to the end or next path segment. - route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)'; - } - - return attachKeys(new RegExp('^' + route, flags(options)), keys) - } - - /** - * Normalize the given path string, returning a regular expression. - * - * An empty array can be passed in for the keys, which will hold the - * placeholder key descriptions. For example, using `/user/:id`, `keys` will - * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`. - * - * @param {(string|RegExp|Array)} path - * @param {(Array|Object)=} keys - * @param {Object=} options - * @return {!RegExp} - */ - function pathToRegexp (path, keys, options) { - if (!isarray(keys)) { - options = /** @type {!Object} */ (keys || options); - keys = []; - } - - options = options || {}; - - if (path instanceof RegExp) { - return regexpToRegexp(path, /** @type {!Array} */ (keys)) - } - - if (isarray(path)) { - return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options) - } - - return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options) - } - pathToRegexp_1.parse = parse_1; - pathToRegexp_1.compile = compile_1; - pathToRegexp_1.tokensToFunction = tokensToFunction_1; - pathToRegexp_1.tokensToRegExp = tokensToRegExp_1; - - /* */ - - // $flow-disable-line - var regexpCompileCache = Object.create(null); - - function fillParams ( + } + + var delimiter = escapeString(options.delimiter || '/'); + var endsWithDelimiter = route.slice(-delimiter.length) === delimiter; + + // In non-strict mode we allow a slash at the end of match. If the path to + // match already ends with a slash, we remove it for consistency. The slash + // is valid at the end of a path match, not in the middle. This is important + // in non-ending mode, where "/test/" shouldn't match "/test//route". + if (!strict) { + route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?'; + } + + if (end) { + route += '$'; + } else { + // In non-ending mode, we need the capturing groups to match as much as + // possible by using a positive lookahead to the end or next path segment. + route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)'; + } + + return attachKeys(new RegExp('^' + route, flags(options)), keys) + } + + /** + * Normalize the given path string, returning a regular expression. + * + * An empty array can be passed in for the keys, which will hold the + * placeholder key descriptions. For example, using `/user/:id`, `keys` will + * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`. + * + * @param {(string|RegExp|Array)} path + * @param {(Array|Object)=} keys + * @param {Object=} options + * @return {!RegExp} + */ + function pathToRegexp (path, keys, options) { + if (!isarray(keys)) { + options = /** @type {!Object} */ (keys || options); + keys = []; + } + + options = options || {}; + + if (path instanceof RegExp) { + return regexpToRegexp(path, /** @type {!Array} */ (keys)) + } + + if (isarray(path)) { + return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options) + } + + return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options) + } + pathToRegexp_1.parse = parse_1; + pathToRegexp_1.compile = compile_1; + pathToRegexp_1.tokensToFunction = tokensToFunction_1; + pathToRegexp_1.tokensToRegExp = tokensToRegExp_1; + + /* */ + + // $flow-disable-line + var regexpCompileCache = Object.create(null); + + function fillParams ( path, params, routeMsg - ) { - params = params || {}; - try { - var filler = + ) { + params = params || {}; + try { + var filler = regexpCompileCache[path] || (regexpCompileCache[path] = pathToRegexp_1.compile(path)); - - // Fix #2505 resolving asterisk routes { name: 'not-found', params: { pathMatch: '/not-found' }} - // and fix #3106 so that you can work with location descriptor object having params.pathMatch equal to empty string - if (typeof params.pathMatch === 'string') { params[0] = params.pathMatch; } - - return filler(params, { pretty: true }) - } catch (e) { - { - // Fix #3072 no warn if `pathMatch` is string - warn(typeof params.pathMatch === 'string', ("missing param for " + routeMsg + ": " + (e.message))); - } - return '' - } finally { - // delete the 0 if it was added - delete params[0]; - } - } - - /* */ - - function normalizeLocation ( + + // Fix #2505 resolving asterisk routes { name: 'not-found', params: { pathMatch: '/not-found' }} + // and fix #3106 so that you can work with location descriptor object having params.pathMatch equal to empty string + if (typeof params.pathMatch === 'string') { params[0] = params.pathMatch; } + + return filler(params, { pretty: true }) + } catch (e) { + { + // Fix #3072 no warn if `pathMatch` is string + warn(typeof params.pathMatch === 'string', ("missing param for " + routeMsg + ": " + (e.message))); + } + return '' + } finally { + // delete the 0 if it was added + delete params[0]; + } + } + + /* */ + + function normalizeLocation ( raw, current, append, router - ) { - var next = typeof raw === 'string' ? { path: raw } : raw; - // named target - if (next._normalized) { - return next - } else if (next.name) { - next = extend({}, raw); - var params = next.params; - if (params && typeof params === 'object') { - next.params = extend({}, params); - } - return next - } - - // relative params - if (!next.path && next.params && current) { - next = extend({}, next); - next._normalized = true; - var params$1 = extend(extend({}, current.params), next.params); - if (current.name) { - next.name = current.name; - next.params = params$1; - } else if (current.matched.length) { - var rawPath = current.matched[current.matched.length - 1].path; - next.path = fillParams(rawPath, params$1, ("path " + (current.path))); - } else { - warn(false, "relative params navigation requires a current route."); + ) { + var next = typeof raw === 'string' ? { path: raw } : raw; + // named target + if (next._normalized) { + return next + } else if (next.name) { + next = extend({}, raw); + var params = next.params; + if (params && typeof params === 'object') { + next.params = extend({}, params); + } + return next } - return next - } - - var parsedPath = parsePath(next.path || ''); - var basePath = (current && current.path) || '/'; - var path = parsedPath.path + + // relative params + if (!next.path && next.params && current) { + next = extend({}, next); + next._normalized = true; + var params$1 = extend(extend({}, current.params), next.params); + if (current.name) { + next.name = current.name; + next.params = params$1; + } else if (current.matched.length) { + var rawPath = current.matched[current.matched.length - 1].path; + next.path = fillParams(rawPath, params$1, ("path " + (current.path))); + } else { + warn(false, "relative params navigation requires a current route."); + } + return next + } + + var parsedPath = parsePath(next.path || ''); + var basePath = (current && current.path) || '/'; + var path = parsedPath.path ? resolvePath(parsedPath.path, basePath, append || next.append) : basePath; - - var query = resolveQuery( + + var query = resolveQuery( parsedPath.query, next.query, router && router.options.parseQuery - ); - - var hash = next.hash || parsedPath.hash; - if (hash && hash.charAt(0) !== '#') { - hash = "#" + hash; - } - - return { - _normalized: true, - path: path, - query: query, - hash: hash - } - } - - // var toTypes = [String, Object]; - // var eventTypes = [String, Array]; - - // var noop = function () {}; - - // var warnedCustomSlot; - // var warnedTagProp; - // var warnedEventProp; - - // var Link = { - // name: 'RouterLink', - // props: { - // to: { - // type: toTypes, - // required: true - // }, - // tag: { - // type: String, - // default: 'a' - // }, - // custom: Boolean, - // exact: Boolean, - // exactPath: Boolean, - // append: Boolean, - // replace: Boolean, - // activeClass: String, - // exactActiveClass: String, - // ariaCurrentValue: { - // type: String, - // default: 'page' - // }, - // event: { - // type: eventTypes, - // default: 'click' - // } - // }, - // render: function render (h) { - // var this$1 = this; - - // var router = this.$router; - // var current = this.$route; - // var ref = router.resolve( - // this.to, - // current, - // this.append - // ); - // var location = ref.location; - // var route = ref.route; - // var href = ref.href; - - // var classes = {}; - // var globalActiveClass = router.options.linkActiveClass; - // var globalExactActiveClass = router.options.linkExactActiveClass; - // // Support global empty active class - // var activeClassFallback = - // globalActiveClass == null ? 'router-link-active' : globalActiveClass; - // var exactActiveClassFallback = - // globalExactActiveClass == null - // ? 'router-link-exact-active' - // : globalExactActiveClass; - // var activeClass = - // this.activeClass == null ? activeClassFallback : this.activeClass; - // var exactActiveClass = - // this.exactActiveClass == null - // ? exactActiveClassFallback - // : this.exactActiveClass; - - // var compareTarget = route.redirectedFrom - // ? createRoute(null, normalizeLocation(route.redirectedFrom), null, router) - // : route; - - // classes[exactActiveClass] = isSameRoute(current, compareTarget, this.exactPath); - // classes[activeClass] = this.exact || this.exactPath - // ? classes[exactActiveClass] - // : isIncludedRoute(current, compareTarget); - - // var ariaCurrentValue = classes[exactActiveClass] ? this.ariaCurrentValue : null; - - // var handler = function (e) { - // if (guardEvent(e)) { - // if (this$1.replace) { - // router.replace(location, noop); - // } else { - // router.push(location, noop); - // } - // } - // }; - - // var on = { click: guardEvent }; - // if (Array.isArray(this.event)) { - // this.event.forEach(function (e) { - // on[e] = handler; - // }); - // } else { - // on[this.event] = handler; - // } - - // var data = { class: classes }; - - // var scopedSlot = - // !this.$scopedSlots.$hasNormal && - // this.$scopedSlots.default && - // this.$scopedSlots.default({ - // href: href, - // route: route, - // navigate: handler, - // isActive: classes[activeClass], - // isExactActive: classes[exactActiveClass] - // }); - - // if (scopedSlot) { - // if (!this.custom) { - // !warnedCustomSlot && warn(false, 'In Vue Router 4, the v-slot API will by default wrap its content with an element. Use the custom prop to remove this warning:\n\n'); - // warnedCustomSlot = true; - // } - // if (scopedSlot.length === 1) { - // return scopedSlot[0] - // } else if (scopedSlot.length > 1 || !scopedSlot.length) { - // { - // warn( - // false, - // (" with to=\"" + (this.to) + "\" is trying to use a scoped slot but it didn't provide exactly one child. Wrapping the content with a span element.") - // ); - // } - // return scopedSlot.length === 0 ? h() : h('span', {}, scopedSlot) - // } - // } - - // { - // if ('tag' in this.$options.propsData && !warnedTagProp) { - // warn( - // false, - // "'s tag prop is deprecated and has been removed in Vue Router 4. Use the v-slot API to remove this warning: https://next.router.vuejs.org/guide/migration/#removal-of-event-and-tag-props-in-router-link." - // ); - // warnedTagProp = true; - // } - // if ('event' in this.$options.propsData && !warnedEventProp) { - // warn( - // false, - // "'s event prop is deprecated and has been removed in Vue Router 4. Use the v-slot API to remove this warning: https://next.router.vuejs.org/guide/migration/#removal-of-event-and-tag-props-in-router-link." - // ); - // warnedEventProp = true; - // } - // } - - // if (this.tag === 'a') { - // data.on = on; - // data.attrs = { href: href, 'aria-current': ariaCurrentValue }; - // } else { - // // find the first child and apply listener and href - // var a = findAnchor(this.$slots.default); - // if (a) { - // // in case the is a static node - // a.isStatic = false; - // var aData = (a.data = extend({}, a.data)); - // aData.on = aData.on || {}; - // // transform existing events in both objects into arrays so we can push later - // for (var event in aData.on) { - // var handler$1 = aData.on[event]; - // if (event in on) { - // aData.on[event] = Array.isArray(handler$1) ? handler$1 : [handler$1]; - // } - // } - // // append new listeners for router-link - // for (var event$1 in on) { - // if (event$1 in aData.on) { - // // on[event] is always a function - // aData.on[event$1].push(on[event$1]); - // } else { - // aData.on[event$1] = handler; - // } - // } - - // var aAttrs = (a.data.attrs = extend({}, a.data.attrs)); - // aAttrs.href = href; - // aAttrs['aria-current'] = ariaCurrentValue; - // } else { - // // doesn't have child, apply listener to self - // data.on = on; - // } - // } - - // return h(this.tag, data, this.$slots.default) - // } - // }; - - function guardEvent (e) { - // don't redirect with control keys - if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) { return } - // don't redirect when preventDefault called - if (e.defaultPrevented) { return } - // don't redirect on right click - if (e.button !== undefined && e.button !== 0) { return } - // don't redirect if `target="_blank"` - if (e.currentTarget && e.currentTarget.getAttribute) { - var target = e.currentTarget.getAttribute('target'); - if (/\b_blank\b/i.test(target)) { return } - } - // this may be a Weex event which doesn't have this method - if (e.preventDefault) { - e.preventDefault(); - } - return true - } - - function findAnchor (children) { - if (children) { - var child; - for (var i = 0; i < children.length; i++) { - child = children[i]; - if (child.tag === 'a') { - return child - } - if (child.children && (child = findAnchor(child.children))) { - return child + ); + + var hash = next.hash || parsedPath.hash; + if (hash && hash.charAt(0) !== '#') { + hash = "#" + hash; + } + + return { + _normalized: true, + path: path, + query: query, + hash: hash + } + } + + // var toTypes = [String, Object]; + // var eventTypes = [String, Array]; + + // var noop = function () {}; + + // var warnedCustomSlot; + // var warnedTagProp; + // var warnedEventProp; + + // var Link = { + // name: 'RouterLink', + // props: { + // to: { + // type: toTypes, + // required: true + // }, + // tag: { + // type: String, + // default: 'a' + // }, + // custom: Boolean, + // exact: Boolean, + // exactPath: Boolean, + // append: Boolean, + // replace: Boolean, + // activeClass: String, + // exactActiveClass: String, + // ariaCurrentValue: { + // type: String, + // default: 'page' + // }, + // event: { + // type: eventTypes, + // default: 'click' + // } + // }, + // render: function render (h) { + // var this$1 = this; + + // var router = this.$router; + // var current = this.$route; + // var ref = router.resolve( + // this.to, + // current, + // this.append + // ); + // var location = ref.location; + // var route = ref.route; + // var href = ref.href; + + // var classes = {}; + // var globalActiveClass = router.options.linkActiveClass; + // var globalExactActiveClass = router.options.linkExactActiveClass; + // // Support global empty active class + // var activeClassFallback = + // globalActiveClass == null ? 'router-link-active' : globalActiveClass; + // var exactActiveClassFallback = + // globalExactActiveClass == null + // ? 'router-link-exact-active' + // : globalExactActiveClass; + // var activeClass = + // this.activeClass == null ? activeClassFallback : this.activeClass; + // var exactActiveClass = + // this.exactActiveClass == null + // ? exactActiveClassFallback + // : this.exactActiveClass; + + // var compareTarget = route.redirectedFrom + // ? createRoute(null, normalizeLocation(route.redirectedFrom), null, router) + // : route; + + // classes[exactActiveClass] = isSameRoute(current, compareTarget, this.exactPath); + // classes[activeClass] = this.exact || this.exactPath + // ? classes[exactActiveClass] + // : isIncludedRoute(current, compareTarget); + + // var ariaCurrentValue = classes[exactActiveClass] ? this.ariaCurrentValue : null; + + // var handler = function (e) { + // if (guardEvent(e)) { + // if (this$1.replace) { + // router.replace(location, noop); + // } else { + // router.push(location, noop); + // } + // } + // }; + + // var on = { click: guardEvent }; + // if (Array.isArray(this.event)) { + // this.event.forEach(function (e) { + // on[e] = handler; + // }); + // } else { + // on[this.event] = handler; + // } + + // var data = { class: classes }; + + // var scopedSlot = + // !this.$scopedSlots.$hasNormal && + // this.$scopedSlots.default && + // this.$scopedSlots.default({ + // href: href, + // route: route, + // navigate: handler, + // isActive: classes[activeClass], + // isExactActive: classes[exactActiveClass] + // }); + + // if (scopedSlot) { + // if (!this.custom) { + // !warnedCustomSlot && warn(false, 'In Vue Router 4, the v-slot API will by default wrap its content with an element. Use the custom prop to remove this warning:\n\n'); + // warnedCustomSlot = true; + // } + // if (scopedSlot.length === 1) { + // return scopedSlot[0] + // } else if (scopedSlot.length > 1 || !scopedSlot.length) { + // { + // warn( + // false, + // (" with to=\"" + (this.to) + "\" is trying to use a scoped slot but it didn't provide exactly one child. Wrapping the content with a span element.") + // ); + // } + // return scopedSlot.length === 0 ? h() : h('span', {}, scopedSlot) + // } + // } + + // { + // if ('tag' in this.$options.propsData && !warnedTagProp) { + // warn( + // false, + // "'s tag prop is deprecated and has been removed in Vue Router 4. Use the v-slot API to remove this warning: https://next.router.vuejs.org/guide/migration/#removal-of-event-and-tag-props-in-router-link." + // ); + // warnedTagProp = true; + // } + // if ('event' in this.$options.propsData && !warnedEventProp) { + // warn( + // false, + // "'s event prop is deprecated and has been removed in Vue Router 4. Use the v-slot API to remove this warning: https://next.router.vuejs.org/guide/migration/#removal-of-event-and-tag-props-in-router-link." + // ); + // warnedEventProp = true; + // } + // } + + // if (this.tag === 'a') { + // data.on = on; + // data.attrs = { href: href, 'aria-current': ariaCurrentValue }; + // } else { + // // find the first child and apply listener and href + // var a = findAnchor(this.$slots.default); + // if (a) { + // // in case the is a static node + // a.isStatic = false; + // var aData = (a.data = extend({}, a.data)); + // aData.on = aData.on || {}; + // // transform existing events in both objects into arrays so we can push later + // for (var event in aData.on) { + // var handler$1 = aData.on[event]; + // if (event in on) { + // aData.on[event] = Array.isArray(handler$1) ? handler$1 : [handler$1]; + // } + // } + // // append new listeners for router-link + // for (var event$1 in on) { + // if (event$1 in aData.on) { + // // on[event] is always a function + // aData.on[event$1].push(on[event$1]); + // } else { + // aData.on[event$1] = handler; + // } + // } + + // var aAttrs = (a.data.attrs = extend({}, a.data.attrs)); + // aAttrs.href = href; + // aAttrs['aria-current'] = ariaCurrentValue; + // } else { + // // doesn't have child, apply listener to self + // data.on = on; + // } + // } + + // return h(this.tag, data, this.$slots.default) + // } + // }; + + function guardEvent (e) { + // don't redirect with control keys + if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) { return } + // don't redirect when preventDefault called + if (e.defaultPrevented) { return } + // don't redirect on right click + if (e.button !== undefined && e.button !== 0) { return } + // don't redirect if `target="_blank"` + if (e.currentTarget && e.currentTarget.getAttribute) { + var target = e.currentTarget.getAttribute('target'); + if (/\b_blank\b/i.test(target)) { return } + } + // this may be a Weex event which doesn't have this method + if (e.preventDefault) { + e.preventDefault(); + } + return true + } + + function findAnchor (children) { + if (children) { + var child; + for (var i = 0; i < children.length; i++) { + child = children[i]; + if (child.tag === 'a') { + return child + } + if (child.children && (child = findAnchor(child.children))) { + return child + } } } } - } - - // var _Vue; - - // function install (Vue) { - // if (install.installed && _Vue === Vue) { return } - // install.installed = true; - - // _Vue = Vue; - - // var isDef = function (v) { return v !== undefined; }; - - // var registerInstance = function (vm, callVal) { - // var i = vm.$options._parentVnode; - // if (isDef(i) && isDef(i = i.data) && isDef(i = i.registerRouteInstance)) { - // i(vm, callVal); - // } - // }; - - // Vue.mixin({ - // beforeCreate: function beforeCreate () { - // if (isDef(this.$options.router)) { - // this._routerRoot = this; - // this._router = this.$options.router; - // this._router.init(this); - // Vue.util.defineReactive(this, '_route', this._router.history.current); - // } else { - // this._routerRoot = (this.$parent && this.$parent._routerRoot) || this; - // } - // registerInstance(this, this); - // }, - // destroyed: function destroyed () { - // registerInstance(this); - // } - // }); - - // Object.defineProperty(Vue.prototype, '$router', { - // get: function get () { return this._routerRoot._router } - // }); - - // Object.defineProperty(Vue.prototype, '$route', { - // get: function get () { return this._routerRoot._route } - // }); - - // Vue.component('RouterView', View); - // Vue.component('RouterLink', Link); - - // var strats = Vue.config.optionMergeStrategies; - // // use the same hook merging strategy for route hooks - // strats.beforeRouteEnter = strats.beforeRouteLeave = strats.beforeRouteUpdate = strats.created; - // } - - /* */ - - var inBrowser = typeof window !== 'undefined'; - - /* */ - - function createRouteMap ( + + // var _Vue; + + // function install (Vue) { + // if (install.installed && _Vue === Vue) { return } + // install.installed = true; + + // _Vue = Vue; + + // var isDef = function (v) { return v !== undefined; }; + + // var registerInstance = function (vm, callVal) { + // var i = vm.$options._parentVnode; + // if (isDef(i) && isDef(i = i.data) && isDef(i = i.registerRouteInstance)) { + // i(vm, callVal); + // } + // }; + + // Vue.mixin({ + // beforeCreate: function beforeCreate () { + // if (isDef(this.$options.router)) { + // this._routerRoot = this; + // this._router = this.$options.router; + // this._router.init(this); + // Vue.util.defineReactive(this, '_route', this._router.history.current); + // } else { + // this._routerRoot = (this.$parent && this.$parent._routerRoot) || this; + // } + // registerInstance(this, this); + // }, + // destroyed: function destroyed () { + // registerInstance(this); + // } + // }); + + // Object.defineProperty(Vue.prototype, '$router', { + // get: function get () { return this._routerRoot._router } + // }); + + // Object.defineProperty(Vue.prototype, '$route', { + // get: function get () { return this._routerRoot._route } + // }); + + // Vue.component('RouterView', View); + // Vue.component('RouterLink', Link); + + // var strats = Vue.config.optionMergeStrategies; + // // use the same hook merging strategy for route hooks + // strats.beforeRouteEnter = strats.beforeRouteLeave = strats.beforeRouteUpdate = strats.created; + // } + + /* */ + + var inBrowser = typeof window !== 'undefined'; + + /* */ + + function createRouteMap ( routes, oldPathList, oldPathMap, oldNameMap, parentRoute - ) { - // the path list is used to control path matching priority - var pathList = oldPathList || []; - // $flow-disable-line - var pathMap = oldPathMap || Object.create(null); - // $flow-disable-line - var nameMap = oldNameMap || Object.create(null); - - routes.forEach(function (route) { - addRouteRecord(pathList, pathMap, nameMap, route, parentRoute); - }); - - // ensure wildcard routes are always at the end - for (var i = 0, l = pathList.length; i < l; i++) { - if (pathList[i] === '*') { - pathList.push(pathList.splice(i, 1)[0]); - l--; - i--; - } - } - - { - // warn if routes do not include leading slashes - var found = pathList - // check for missing leading slash + ) { + // the path list is used to control path matching priority + var pathList = oldPathList || []; + // $flow-disable-line + var pathMap = oldPathMap || Object.create(null); + // $flow-disable-line + var nameMap = oldNameMap || Object.create(null); + + routes.forEach(function (route) { + addRouteRecord(pathList, pathMap, nameMap, route, parentRoute); + }); + + // ensure wildcard routes are always at the end + for (var i = 0, l = pathList.length; i < l; i++) { + if (pathList[i] === '*') { + pathList.push(pathList.splice(i, 1)[0]); + l--; + i--; + } + } + + { + // warn if routes do not include leading slashes + var found = pathList + // check for missing leading slash .filter(function (path) { return path && path.charAt(0) !== '*' && path.charAt(0) !== '/'; }); - - if (found.length > 0) { - var pathNames = found.map(function (path) { return ("- " + path); }).join('\n'); - warn(false, ("Non-nested routes must include a leading slash character. Fix the following routes: \n" + pathNames)); + + if (found.length > 0) { + var pathNames = found.map(function (path) { return ("- " + path); }).join('\n'); + warn(false, ("Non-nested routes must include a leading slash character. Fix the following routes: \n" + pathNames)); + } + } + + return { + pathList: pathList, + pathMap: pathMap, + nameMap: nameMap } } - - return { - pathList: pathList, - pathMap: pathMap, - nameMap: nameMap - } - } - - function addRouteRecord ( + + function addRouteRecord ( pathList, pathMap, nameMap, route, parent, matchAs - ) { - var path = route.path; - var name = route.name; - { - assert(path != null, "\"path\" is required in a route configuration."); - assert( + ) { + var path = route.path; + var name = route.name; + { + assert(path != null, "\"path\" is required in a route configuration."); + assert( typeof route.component !== 'string', "route config \"component\" for path: " + (String( - path || name + path || name )) + " cannot be a " + "string id. Use an actual component instead." - ); - - warn( + ); + + warn( // eslint-disable-next-line no-control-regex !/[^\u0000-\u007F]+/.test(path), "Route with path \"" + path + "\" contains unencoded characters, make sure " + - "your path is correctly encoded before passing it to the router. Use " + - "encodeURI to encode static segments of your path." - ); - } - - var pathToRegexpOptions = + "your path is correctly encoded before passing it to the router. Use " + + "encodeURI to encode static segments of your path." + ); + } + + var pathToRegexpOptions = route.pathToRegexpOptions || {}; - var normalizedPath = normalizePath(path, parent, pathToRegexpOptions.strict); - - if (typeof route.caseSensitive === 'boolean') { - pathToRegexpOptions.sensitive = route.caseSensitive; - } - - var record = { - path: normalizedPath, - regex: compileRouteRegex(normalizedPath, pathToRegexpOptions), - components: route.components || { default: route.component }, - alias: route.alias + var normalizedPath = normalizePath(path, parent, pathToRegexpOptions.strict); + + if (typeof route.caseSensitive === 'boolean') { + pathToRegexpOptions.sensitive = route.caseSensitive; + } + + var record = { + path: normalizedPath, + regex: compileRouteRegex(normalizedPath, pathToRegexpOptions), + components: route.components || { default: route.component }, + alias: route.alias ? typeof route.alias === 'string' - ? [route.alias] - : route.alias + ? [route.alias] + : route.alias : [], - instances: {}, - enteredCbs: {}, - name: name, - parent: parent, - matchAs: matchAs, - redirect: route.redirect, - beforeEnter: route.beforeEnter, - meta: route.meta || {}, - props: + instances: {}, + enteredCbs: {}, + name: name, + parent: parent, + matchAs: matchAs, + redirect: route.redirect, + beforeEnter: route.beforeEnter, + meta: route.meta || {}, + props: route.props == null - ? {} - : route.components + ? {} + : route.components ? route.props : { default: route.props } - }; - - if (route.children) { - // Warn if route is named, does not redirect and has a default child route. - // If users navigate to this route by name, the default child will - // not be rendered (GH Issue #629) - { - if ( + }; + + if (route.children) { + // Warn if route is named, does not redirect and has a default child route. + // If users navigate to this route by name, the default child will + // not be rendered (GH Issue #629) + { + if ( route.name && !route.redirect && route.children.some(function (child) { return /^\/?$/.test(child.path); }) - ) { - warn( + ) { + warn( false, "Named Route '" + (route.name) + "' has a default child route. " + - "When navigating to this named route (:to=\"{name: '" + (route.name) + "'\"), " + - "the default child route will not be rendered. Remove the name from " + - "this route and use the name of the default child route for named " + - "links instead." - ); + "When navigating to this named route (:to=\"{name: '" + (route.name) + "'\"), " + + "the default child route will not be rendered. Remove the name from " + + "this route and use the name of the default child route for named " + + "links instead." + ); + } } - } - route.children.forEach(function (child) { - var childMatchAs = matchAs + route.children.forEach(function (child) { + var childMatchAs = matchAs ? cleanPath((matchAs + "/" + (child.path))) : undefined; - addRouteRecord(pathList, pathMap, nameMap, child, record, childMatchAs); - }); - } - - if (!pathMap[record.path]) { - pathList.push(record.path); - pathMap[record.path] = record; - } - - if (route.alias !== undefined) { - var aliases = Array.isArray(route.alias) ? route.alias : [route.alias]; - for (var i = 0; i < aliases.length; ++i) { - var alias = aliases[i]; - if (alias === path) { - warn( + addRouteRecord(pathList, pathMap, nameMap, child, record, childMatchAs); + }); + } + + if (!pathMap[record.path]) { + pathList.push(record.path); + pathMap[record.path] = record; + } + + if (route.alias !== undefined) { + var aliases = Array.isArray(route.alias) ? route.alias : [route.alias]; + for (var i = 0; i < aliases.length; ++i) { + var alias = aliases[i]; + if (alias === path) { + warn( false, ("Found an alias with the same value as the path: \"" + path + "\". You have to remove that alias. It will be ignored in development.") - ); - // skip in dev to make it work - continue - } - - var aliasRoute = { - path: alias, - children: route.children - }; - addRouteRecord( + ); + // skip in dev to make it work + continue + } + + var aliasRoute = { + path: alias, + children: route.children + }; + addRouteRecord( pathList, pathMap, nameMap, aliasRoute, parent, record.path || '/' // matchAs - ); + ); + } } - } - - if (name) { - if (!nameMap[name]) { - nameMap[name] = record; - } else if (!matchAs) { - warn( + + if (name) { + if (!nameMap[name]) { + nameMap[name] = record; + } else if (!matchAs) { + warn( false, "Duplicate named routes definition: " + - "{ name: \"" + name + "\", path: \"" + (record.path) + "\" }" - ); + "{ name: \"" + name + "\", path: \"" + (record.path) + "\" }" + ); + } } } - } - - function compileRouteRegex ( + + function compileRouteRegex ( path, pathToRegexpOptions - ) { - var regex = pathToRegexp_1(path, [], pathToRegexpOptions); - { - var keys = Object.create(null); - regex.keys.forEach(function (key) { - warn( + ) { + var regex = pathToRegexp_1(path, [], pathToRegexpOptions); + { + var keys = Object.create(null); + regex.keys.forEach(function (key) { + warn( !keys[key.name], ("Duplicate param keys in route with path: \"" + path + "\"") - ); - keys[key.name] = true; - }); + ); + keys[key.name] = true; + }); + } + return regex } - return regex - } - - function normalizePath ( + + function normalizePath ( path, parent, strict - ) { - if (!strict) { path = path.replace(/\/$/, ''); } - if (path[0] === '/') { return path } - if (parent == null) { return path } - return cleanPath(((parent.path) + "/" + path)) - } - - /* */ - - - - function createMatcher ( + ) { + if (!strict) { path = path.replace(/\/$/, ''); } + if (path[0] === '/') { return path } + if (parent == null) { return path } + return cleanPath(((parent.path) + "/" + path)) + } + + /* */ + + + + function createMatcher ( routes, router - ) { - var ref = createRouteMap(routes); - var pathList = ref.pathList; - var pathMap = ref.pathMap; - var nameMap = ref.nameMap; - - function addRoutes (routes) { - createRouteMap(routes, pathList, pathMap, nameMap); - } - - function addRoute (parentOrRoute, route) { - var parent = (typeof parentOrRoute !== 'object') ? nameMap[parentOrRoute] : undefined; - // $flow-disable-line - createRouteMap([route || parentOrRoute], pathList, pathMap, nameMap, parent); - - // add aliases of parent - if (parent && parent.alias.length) { - createRouteMap( + ) { + var ref = createRouteMap(routes); + var pathList = ref.pathList; + var pathMap = ref.pathMap; + var nameMap = ref.nameMap; + + function addRoutes (routes) { + createRouteMap(routes, pathList, pathMap, nameMap); + } + + function addRoute (parentOrRoute, route) { + var parent = (typeof parentOrRoute !== 'object') ? nameMap[parentOrRoute] : undefined; + // $flow-disable-line + createRouteMap([route || parentOrRoute], pathList, pathMap, nameMap, parent); + + // add aliases of parent + if (parent && parent.alias.length) { + createRouteMap( // $flow-disable-line route is defined if parent is parent.alias.map(function (alias) { return ({ path: alias, children: [route] }); }), pathList, pathMap, nameMap, parent - ); + ); + } } - } - - function getRoutes () { - return pathList.map(function (path) { return pathMap[path]; }) - } - - function match ( + + function getRoutes () { + return pathList.map(function (path) { return pathMap[path]; }) + } + + function match ( raw, currentRoute, redirectedFrom - ) { - var location = normalizeLocation(raw, currentRoute, false, router); - var name = location.name; - - if (name) { - var record = nameMap[name]; - { - warn(record, ("Route with name '" + name + "' does not exist")); - } - if (!record) { return _createRoute(null, location) } - var paramNames = record.regex.keys + ) { + var location = normalizeLocation(raw, currentRoute, false, router); + var name = location.name; + + if (name) { + var record = nameMap[name]; + { + warn(record, ("Route with name '" + name + "' does not exist")); + } + if (!record) { return _createRoute(null, location) } + var paramNames = record.regex.keys .filter(function (key) { return !key.optional; }) .map(function (key) { return key.name; }); - - if (typeof location.params !== 'object') { - location.params = {}; - } - - if (currentRoute && typeof currentRoute.params === 'object') { - for (var key in currentRoute.params) { - if (!(key in location.params) && paramNames.indexOf(key) > -1) { - location.params[key] = currentRoute.params[key]; + + if (typeof location.params !== 'object') { + location.params = {}; + } + + if (currentRoute && typeof currentRoute.params === 'object') { + for (var key in currentRoute.params) { + if (!(key in location.params) && paramNames.indexOf(key) > -1) { + location.params[key] = currentRoute.params[key]; + } } } - } - - location.path = fillParams(record.path, location.params, ("named route \"" + name + "\"")); - return _createRoute(record, location, redirectedFrom) - } else if (location.path) { - location.params = {}; - for (var i = 0; i < pathList.length; i++) { - var path = pathList[i]; - var record$1 = pathMap[path]; - if (matchRoute(record$1.regex, location.path, location.params)) { - return _createRoute(record$1, location, redirectedFrom) + + location.path = fillParams(record.path, location.params, ("named route \"" + name + "\"")); + return _createRoute(record, location, redirectedFrom) + } else if (location.path) { + location.params = {}; + for (var i = 0; i < pathList.length; i++) { + var path = pathList[i]; + var record$1 = pathMap[path]; + if (matchRoute(record$1.regex, location.path, location.params)) { + return _createRoute(record$1, location, redirectedFrom) + } } } + // no match + return _createRoute(null, location) } - // no match - return _createRoute(null, location) - } - - function redirect ( + + function redirect ( record, location - ) { - var originalRedirect = record.redirect; - var redirect = typeof originalRedirect === 'function' + ) { + var originalRedirect = record.redirect; + var redirect = typeof originalRedirect === 'function' ? originalRedirect(createRoute(record, location, null, router)) : originalRedirect; - - if (typeof redirect === 'string') { - redirect = { path: redirect }; - } - - if (!redirect || typeof redirect !== 'object') { - { - warn( - false, ("invalid redirect option: " + (JSON.stringify(redirect))) - ); + + if (typeof redirect === 'string') { + redirect = { path: redirect }; } - return _createRoute(null, location) - } - - var re = redirect; - var name = re.name; - var path = re.path; - var query = location.query; - var hash = location.hash; - var params = location.params; - query = re.hasOwnProperty('query') ? re.query : query; - hash = re.hasOwnProperty('hash') ? re.hash : hash; - params = re.hasOwnProperty('params') ? re.params : params; - - if (name) { - // resolved named direct - var targetRecord = nameMap[name]; - { - assert(targetRecord, ("redirect failed: named route \"" + name + "\" not found.")); + + if (!redirect || typeof redirect !== 'object') { + { + warn( + false, ("invalid redirect option: " + (JSON.stringify(redirect))) + ); + } + return _createRoute(null, location) } - return match({ - _normalized: true, - name: name, - query: query, - hash: hash, - params: params - }, undefined, location) - } else if (path) { - // 1. resolve relative redirect - var rawPath = resolveRecordPath(path, record); - // 2. resolve params - var resolvedPath = fillParams(rawPath, params, ("redirect route with path \"" + rawPath + "\"")); - // 3. rematch with existing query and hash - return match({ - _normalized: true, - path: resolvedPath, - query: query, - hash: hash - }, undefined, location) - } else { - { - warn(false, ("invalid redirect option: " + (JSON.stringify(redirect)))); + + var re = redirect; + var name = re.name; + var path = re.path; + var query = location.query; + var hash = location.hash; + var params = location.params; + query = re.hasOwnProperty('query') ? re.query : query; + hash = re.hasOwnProperty('hash') ? re.hash : hash; + params = re.hasOwnProperty('params') ? re.params : params; + + if (name) { + // resolved named direct + var targetRecord = nameMap[name]; + { + assert(targetRecord, ("redirect failed: named route \"" + name + "\" not found.")); + } + return match({ + _normalized: true, + name: name, + query: query, + hash: hash, + params: params + }, undefined, location) + } else if (path) { + // 1. resolve relative redirect + var rawPath = resolveRecordPath(path, record); + // 2. resolve params + var resolvedPath = fillParams(rawPath, params, ("redirect route with path \"" + rawPath + "\"")); + // 3. rematch with existing query and hash + return match({ + _normalized: true, + path: resolvedPath, + query: query, + hash: hash + }, undefined, location) + } else { + { + warn(false, ("invalid redirect option: " + (JSON.stringify(redirect)))); + } + return _createRoute(null, location) } - return _createRoute(null, location) } - } - - function alias ( + + function alias ( record, location, matchAs - ) { - var aliasedPath = fillParams(matchAs, location.params, ("aliased route with path \"" + matchAs + "\"")); - var aliasedMatch = match({ - _normalized: true, - path: aliasedPath - }); - if (aliasedMatch) { - var matched = aliasedMatch.matched; - var aliasedRecord = matched[matched.length - 1]; - location.params = aliasedMatch.params; - return _createRoute(aliasedRecord, location) + ) { + var aliasedPath = fillParams(matchAs, location.params, ("aliased route with path \"" + matchAs + "\"")); + var aliasedMatch = match({ + _normalized: true, + path: aliasedPath + }); + if (aliasedMatch) { + var matched = aliasedMatch.matched; + var aliasedRecord = matched[matched.length - 1]; + location.params = aliasedMatch.params; + return _createRoute(aliasedRecord, location) + } + return _createRoute(null, location) } - return _createRoute(null, location) - } - - function _createRoute ( + + function _createRoute ( record, location, redirectedFrom - ) { - if (record && record.redirect) { - return redirect(record, redirectedFrom || location) + ) { + if (record && record.redirect) { + return redirect(record, redirectedFrom || location) + } + if (record && record.matchAs) { + return alias(record, location, record.matchAs) + } + return createRoute(record, location, redirectedFrom, router) } - if (record && record.matchAs) { - return alias(record, location, record.matchAs) + + return { + match: match, + addRoute: addRoute, + getRoutes: getRoutes, + addRoutes: addRoutes } - return createRoute(record, location, redirectedFrom, router) - } - - return { - match: match, - addRoute: addRoute, - getRoutes: getRoutes, - addRoutes: addRoutes } - } - - function matchRoute ( + + function matchRoute ( regex, path, params - ) { - var m = path.match(regex); - - if (!m) { - return false - } else if (!params) { + ) { + var m = path.match(regex); + + if (!m) { + return false + } else if (!params) { + return true + } + + for (var i = 1, len = m.length; i < len; ++i) { + var key = regex.keys[i - 1]; + if (key) { + // Fix #1994: using * with props: true generates a param named 0 + params[key.name || 'pathMatch'] = typeof m[i] === 'string' ? decode(m[i]) : m[i]; + } + } + return true } - - for (var i = 1, len = m.length; i < len; ++i) { - var key = regex.keys[i - 1]; - if (key) { - // Fix #1994: using * with props: true generates a param named 0 - params[key.name || 'pathMatch'] = typeof m[i] === 'string' ? decode(m[i]) : m[i]; - } - } - - return true - } - - function resolveRecordPath (path, record) { - return resolvePath(path, record.parent ? record.parent.path : '/', true) - } - - /* */ - - // use User Timing api (if present) for more accurate key precision - var Time = + + function resolveRecordPath (path, record) { + return resolvePath(path, record.parent ? record.parent.path : '/', true) + } + + /* */ + + // use User Timing api (if present) for more accurate key precision + var Time = inBrowser && window.performance && window.performance.now - ? window.performance - : Date; - - function genStateKey () { - return Time.now().toFixed(3) - } - - var _key = genStateKey(); - - function getStateKey () { - return _key - } - - function setStateKey (key) { - return (_key = key) - } - - /* */ - - var positionStore = Object.create(null); - - function setupScroll () { - // Prevent browser scroll behavior on History popstate - if ('scrollRestoration' in window.history) { - window.history.scrollRestoration = 'manual'; - } - // Fix for #1585 for Firefox - // Fix for #2195 Add optional third attribute to workaround a bug in safari https://bugs.webkit.org/show_bug.cgi?id=182678 - // Fix for #2774 Support for apps loaded from Windows file shares not mapped to network drives: replaced location.origin with - // window.location.protocol + '//' + window.location.host - // location.host contains the port and location.hostname doesn't - var protocolAndPath = window.location.protocol + '//' + window.location.host; - var absolutePath = window.location.href.replace(protocolAndPath, ''); - // preserve existing history state as it could be overriden by the user - var stateCopy = extend({}, window.history.state); - stateCopy.key = getStateKey(); - window.history.replaceState(stateCopy, '', absolutePath); - window.addEventListener('popstate', handlePopState); - return function () { - window.removeEventListener('popstate', handlePopState); - } - } - - function handleScroll ( + ? window.performance + : Date; + + function genStateKey () { + return Time.now().toFixed(3) + } + + var _key = genStateKey(); + + function getStateKey () { + return _key + } + + function setStateKey (key) { + return (_key = key) + } + + /* */ + + var positionStore = Object.create(null); + + function setupScroll () { + // Prevent browser scroll behavior on History popstate + if ('scrollRestoration' in window.history) { + window.history.scrollRestoration = 'manual'; + } + // Fix for #1585 for Firefox + // Fix for #2195 Add optional third attribute to workaround a bug in safari https://bugs.webkit.org/show_bug.cgi?id=182678 + // Fix for #2774 Support for apps loaded from Windows file shares not mapped to network drives: replaced location.origin with + // window.location.protocol + '//' + window.location.host + // location.host contains the port and location.hostname doesn't + var protocolAndPath = window.location.protocol + '//' + window.location.host; + var absolutePath = window.location.href.replace(protocolAndPath, ''); + // preserve existing history state as it could be overriden by the user + var stateCopy = extend({}, window.history.state); + stateCopy.key = getStateKey(); + window.history.replaceState(stateCopy, '', absolutePath); + window.addEventListener('popstate', handlePopState); + return function () { + window.removeEventListener('popstate', handlePopState); + } + } + + function handleScroll ( router, to, from, isPop - ) { - if (!router.app) { - return - } - - var behavior = router.options.scrollBehavior; - if (!behavior) { - return - } - - { - assert(typeof behavior === 'function', "scrollBehavior must be a function"); - } - - // wait until re-render finishes before scrolling - BI.nextTick(function () { - var position = getScrollPosition(); - var shouldScroll = behavior.call( + ) { + if (!router.app) { + return + } + + var behavior = router.options.scrollBehavior; + if (!behavior) { + return + } + + { + assert(typeof behavior === 'function', "scrollBehavior must be a function"); + } + + // wait until re-render finishes before scrolling + BI.nextTick(function () { + var position = getScrollPosition(); + var shouldScroll = behavior.call( router, to, from, isPop ? position : null - ); - - if (!shouldScroll) { - return - } - - if (typeof shouldScroll.then === 'function') { - shouldScroll + ); + + if (!shouldScroll) { + return + } + + if (typeof shouldScroll.then === 'function') { + shouldScroll .then(function (shouldScroll) { scrollToPosition((shouldScroll), position); }) @@ -1852,413 +1852,413 @@ assert(false, err.toString()); } }); - } else { - scrollToPosition(shouldScroll, position); + } else { + scrollToPosition(shouldScroll, position); + } + }); + } + + function saveScrollPosition () { + var key = getStateKey(); + if (key) { + positionStore[key] = { + x: window.pageXOffset, + y: window.pageYOffset + }; + } + } + + function handlePopState (e) { + saveScrollPosition(); + if (e.state && e.state.key) { + setStateKey(e.state.key); + } + } + + function getScrollPosition () { + var key = getStateKey(); + if (key) { + return positionStore[key] + } + } + + function getElementPosition (el, offset) { + var docEl = document.documentElement; + var docRect = docEl.getBoundingClientRect(); + var elRect = el.getBoundingClientRect(); + return { + x: elRect.left - docRect.left - offset.x, + y: elRect.top - docRect.top - offset.y + } + } + + function isValidPosition (obj) { + return isNumber(obj.x) || isNumber(obj.y) + } + + function normalizePosition (obj) { + return { + x: isNumber(obj.x) ? obj.x : window.pageXOffset, + y: isNumber(obj.y) ? obj.y : window.pageYOffset } - }); - } - - function saveScrollPosition () { - var key = getStateKey(); - if (key) { - positionStore[key] = { - x: window.pageXOffset, - y: window.pageYOffset - }; } - } - - function handlePopState (e) { - saveScrollPosition(); - if (e.state && e.state.key) { - setStateKey(e.state.key); - } - } - - function getScrollPosition () { - var key = getStateKey(); - if (key) { - return positionStore[key] - } - } - - function getElementPosition (el, offset) { - var docEl = document.documentElement; - var docRect = docEl.getBoundingClientRect(); - var elRect = el.getBoundingClientRect(); - return { - x: elRect.left - docRect.left - offset.x, - y: elRect.top - docRect.top - offset.y - } - } - - function isValidPosition (obj) { - return isNumber(obj.x) || isNumber(obj.y) - } - - function normalizePosition (obj) { - return { - x: isNumber(obj.x) ? obj.x : window.pageXOffset, - y: isNumber(obj.y) ? obj.y : window.pageYOffset - } - } - - function normalizeOffset (obj) { - return { - x: isNumber(obj.x) ? obj.x : 0, - y: isNumber(obj.y) ? obj.y : 0 - } - } - - function isNumber (v) { - return typeof v === 'number' - } - - var hashStartsWithNumberRE = /^#\d/; - - function scrollToPosition (shouldScroll, position) { - var isObject = typeof shouldScroll === 'object'; - if (isObject && typeof shouldScroll.selector === 'string') { - // getElementById would still fail if the selector contains a more complicated query like #main[data-attr] - // but at the same time, it doesn't make much sense to select an element with an id and an extra selector - var el = hashStartsWithNumberRE.test(shouldScroll.selector) // $flow-disable-line + + function normalizeOffset (obj) { + return { + x: isNumber(obj.x) ? obj.x : 0, + y: isNumber(obj.y) ? obj.y : 0 + } + } + + function isNumber (v) { + return typeof v === 'number' + } + + var hashStartsWithNumberRE = /^#\d/; + + function scrollToPosition (shouldScroll, position) { + var isObject = typeof shouldScroll === 'object'; + if (isObject && typeof shouldScroll.selector === 'string') { + // getElementById would still fail if the selector contains a more complicated query like #main[data-attr] + // but at the same time, it doesn't make much sense to select an element with an id and an extra selector + var el = hashStartsWithNumberRE.test(shouldScroll.selector) // $flow-disable-line ? document.getElementById(shouldScroll.selector.slice(1)) // $flow-disable-line : document.querySelector(shouldScroll.selector); - - if (el) { - var offset = + + if (el) { + var offset = shouldScroll.offset && typeof shouldScroll.offset === 'object' - ? shouldScroll.offset - : {}; - offset = normalizeOffset(offset); - position = getElementPosition(el, offset); - } else if (isValidPosition(shouldScroll)) { + ? shouldScroll.offset + : {}; + offset = normalizeOffset(offset); + position = getElementPosition(el, offset); + } else if (isValidPosition(shouldScroll)) { + position = normalizePosition(shouldScroll); + } + } else if (isObject && isValidPosition(shouldScroll)) { position = normalizePosition(shouldScroll); } - } else if (isObject && isValidPosition(shouldScroll)) { - position = normalizePosition(shouldScroll); - } - - if (position) { - // $flow-disable-line - if ('scrollBehavior' in document.documentElement.style) { - window.scrollTo({ - left: position.x, - top: position.y, - // $flow-disable-line - behavior: shouldScroll.behavior - }); - } else { - window.scrollTo(position.x, position.y); + + if (position) { + // $flow-disable-line + if ('scrollBehavior' in document.documentElement.style) { + window.scrollTo({ + left: position.x, + top: position.y, + // $flow-disable-line + behavior: shouldScroll.behavior + }); + } else { + window.scrollTo(position.x, position.y); + } } } - } - - /* */ - - var supportsPushState = + + /* */ + + var supportsPushState = inBrowser && (function () { var ua = window.navigator.userAgent; - + if ( - (ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && - ua.indexOf('Mobile Safari') !== -1 && - ua.indexOf('Chrome') === -1 && - ua.indexOf('Windows Phone') === -1 + (ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && + ua.indexOf('Mobile Safari') !== -1 && + ua.indexOf('Chrome') === -1 && + ua.indexOf('Windows Phone') === -1 ) { return false } - + return window.history && typeof window.history.pushState === 'function' })(); - - function pushState (url, replace) { - saveScrollPosition(); - // try...catch the pushState call to get around Safari - // DOM Exception 18 where it limits to 100 pushState calls - var history = window.history; - try { - if (replace) { - // preserve existing history state as it could be overriden by the user - var stateCopy = extend({}, history.state); - stateCopy.key = getStateKey(); - history.replaceState(stateCopy, '', url); - } else { - history.pushState({ key: setStateKey(genStateKey()) }, '', url); - } - } catch (e) { - window.location[replace ? 'replace' : 'assign'](url); - } - } - - function replaceState (url) { - pushState(url, true); - } - - /* */ - - function runQueue (queue, fn, cb) { - var step = function (index) { - if (index >= queue.length) { - cb(); - } else { - if (queue[index]) { - fn(queue[index], function () { - step(index + 1); - }); + + function pushState (url, replace) { + saveScrollPosition(); + // try...catch the pushState call to get around Safari + // DOM Exception 18 where it limits to 100 pushState calls + var history = window.history; + try { + if (replace) { + // preserve existing history state as it could be overriden by the user + var stateCopy = extend({}, history.state); + stateCopy.key = getStateKey(); + history.replaceState(stateCopy, '', url); } else { - step(index + 1); + history.pushState({ key: setStateKey(genStateKey()) }, '', url); } + } catch (e) { + window.location[replace ? 'replace' : 'assign'](url); } + } + + function replaceState (url) { + pushState(url, true); + } + + /* */ + + function runQueue (queue, fn, cb) { + var step = function (index) { + if (index >= queue.length) { + cb(); + } else { + if (queue[index]) { + fn(queue[index], function () { + step(index + 1); + }); + } else { + step(index + 1); + } + } + }; + step(0); + } + + // When changing thing, also edit router.d.ts + var NavigationFailureType = { + redirected: 2, + aborted: 4, + cancelled: 8, + duplicated: 16 }; - step(0); - } - - // When changing thing, also edit router.d.ts - var NavigationFailureType = { - redirected: 2, - aborted: 4, - cancelled: 8, - duplicated: 16 - }; - - function createNavigationRedirectedError (from, to) { - return createRouterError( + + function createNavigationRedirectedError (from, to) { + return createRouterError( from, to, NavigationFailureType.redirected, ("Redirected when going from \"" + (from.fullPath) + "\" to \"" + (stringifyRoute( - to + to )) + "\" via a navigation guard.") - ) - } - - function createNavigationDuplicatedError (from, to) { - var error = createRouterError( + ) + } + + function createNavigationDuplicatedError (from, to) { + var error = createRouterError( from, to, NavigationFailureType.duplicated, ("Avoided redundant navigation to current location: \"" + (from.fullPath) + "\".") - ); - // backwards compatible with the first introduction of Errors - error.name = 'NavigationDuplicated'; - return error - } - - function createNavigationCancelledError (from, to) { - return createRouterError( + ); + // backwards compatible with the first introduction of Errors + error.name = 'NavigationDuplicated'; + return error + } + + function createNavigationCancelledError (from, to) { + return createRouterError( from, to, NavigationFailureType.cancelled, ("Navigation cancelled from \"" + (from.fullPath) + "\" to \"" + (to.fullPath) + "\" with a new navigation.") - ) - } - - function createNavigationAbortedError (from, to) { - return createRouterError( + ) + } + + function createNavigationAbortedError (from, to) { + return createRouterError( from, to, NavigationFailureType.aborted, ("Navigation aborted from \"" + (from.fullPath) + "\" to \"" + (to.fullPath) + "\" via a navigation guard.") - ) - } - - function createRouterError (from, to, type, message) { - var error = new Error(message); - error._isRouter = true; - error.from = from; - error.to = to; - error.type = type; - - return error - } - - var propertiesToLog = ['params', 'query', 'hash']; - - function stringifyRoute (to) { - if (typeof to === 'string') { return to } - if ('path' in to) { return to.path } - var location = {}; - propertiesToLog.forEach(function (key) { - if (key in to) { location[key] = to[key]; } - }); - return JSON.stringify(location, null, 2) - } - - function isError (err) { - return Object.prototype.toString.call(err).indexOf('Error') > -1 - } - - function isNavigationFailure (err, errorType) { - return ( + ) + } + + function createRouterError (from, to, type, message) { + var error = new Error(message); + error._isRouter = true; + error.from = from; + error.to = to; + error.type = type; + + return error + } + + var propertiesToLog = ['params', 'query', 'hash']; + + function stringifyRoute (to) { + if (typeof to === 'string') { return to } + if ('path' in to) { return to.path } + var location = {}; + propertiesToLog.forEach(function (key) { + if (key in to) { location[key] = to[key]; } + }); + return JSON.stringify(location, null, 2) + } + + function isError (err) { + return Object.prototype.toString.call(err).indexOf('Error') > -1 + } + + function isNavigationFailure (err, errorType) { + return ( isError(err) && err._isRouter && (errorType == null || err.type === errorType) - ) - } - - /* */ - - function resolveAsyncComponents (matched) { - return function (to, from, next) { - var hasAsync = false; - var pending = 0; - var error = null; - - flatMapComponents(matched, function (def, _, match, key) { - // if it's a function and doesn't have cid attached, - // assume it's an async component resolve function. - // we are not using Vue's default async resolving mechanism because - // we want to halt the navigation until the incoming component has been - // resolved. - if (typeof def === 'function' && def.cid === undefined) { - hasAsync = true; - pending++; - - var resolve = once(function (resolvedDef) { - if (isESModule(resolvedDef)) { - resolvedDef = resolvedDef.default; - } - // save resolved on async factory in case it's used elsewhere - def.resolved = resolvedDef; - match.components[key] = resolvedDef; - pending--; - if (pending <= 0) { - next(); - } - }); - - var reject = once(function (reason) { - var msg = "Failed to resolve async component " + key + ": " + reason; - warn(false, msg); - if (!error) { - error = isError(reason) + ) + } + + /* */ + + function resolveAsyncComponents (matched) { + return function (to, from, next) { + var hasAsync = false; + var pending = 0; + var error = null; + + flatMapComponents(matched, function (def, _, match, key) { + // if it's a function and doesn't have cid attached, + // assume it's an async component resolve function. + // we are not using Vue's default async resolving mechanism because + // we want to halt the navigation until the incoming component has been + // resolved. + if (typeof def === 'function' && def.cid === undefined) { + hasAsync = true; + pending++; + + var resolve = once(function (resolvedDef) { + if (isESModule(resolvedDef)) { + resolvedDef = resolvedDef.default; + } + // save resolved on async factory in case it's used elsewhere + def.resolved = resolvedDef; + match.components[key] = resolvedDef; + pending--; + if (pending <= 0) { + next(); + } + }); + + var reject = once(function (reason) { + var msg = "Failed to resolve async component " + key + ": " + reason; + warn(false, msg); + if (!error) { + error = isError(reason) ? reason : new Error(msg); - next(error); + next(error); + } + }); + + var res; + try { + res = def(resolve, reject); + } catch (e) { + reject(e); } - }); - - var res; - try { - res = def(resolve, reject); - } catch (e) { - reject(e); - } - if (res) { - if (typeof res.then === 'function') { - res.then(resolve, reject); - } else { - // new syntax in Vue 2.3 - var comp = res.component; - if (comp && typeof comp.then === 'function') { - comp.then(resolve, reject); + if (res) { + if (typeof res.then === 'function') { + res.then(resolve, reject); + } else { + // new syntax in Vue 2.3 + var comp = res.component; + if (comp && typeof comp.then === 'function') { + comp.then(resolve, reject); + } } } } - } - }); - - if (!hasAsync) { next(); } + }); + + if (!hasAsync) { next(); } + } } - } - - function flatMapComponents ( + + function flatMapComponents ( matched, fn - ) { - return flatten(matched.map(function (m) { - return Object.keys(m.components).map(function (key) { return fn( + ) { + return flatten(matched.map(function (m) { + return Object.keys(m.components).map(function (key) { return fn( m.components[key], m.instances[key], m, key - ); }) - })) - } - - function flatten (arr) { - return Array.prototype.concat.apply([], arr) - } - - var hasSymbol = + ); }) + })) + } + + function flatten (arr) { + return Array.prototype.concat.apply([], arr) + } + + var hasSymbol = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; - - function isESModule (obj) { - return obj.__esModule || (hasSymbol && obj[Symbol.toStringTag] === 'Module') - } - - // in Webpack 2, require.ensure now also returns a Promise - // so the resolve/reject functions may get called an extra time - // if the user uses an arrow function shorthand that happens to - // return that Promise. - function once (fn) { - var called = false; - return function () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - if (called) { return } - called = true; - return fn.apply(this, args) - } - } - - /* */ - - var History = function History (router, base) { - this.router = router; - this.base = normalizeBase(base); - // start with a route object that stands for "nowhere" - this.current = START; - this.pending = null; - this.ready = false; - this.readyCbs = []; - this.readyErrorCbs = []; - this.errorCbs = []; - this.listeners = []; - }; - - History.prototype.listen = function listen (cb) { - this.cb = cb; - }; - - History.prototype.onReady = function onReady (cb, errorCb) { - if (this.ready) { - cb(); - } else { - this.readyCbs.push(cb); - if (errorCb) { - this.readyErrorCbs.push(errorCb); - } - } - }; - - History.prototype.onError = function onError (errorCb) { - this.errorCbs.push(errorCb); - }; - - History.prototype.transitionTo = function transitionTo ( + + function isESModule (obj) { + return obj.__esModule || (hasSymbol && obj[Symbol.toStringTag] === 'Module') + } + + // in Webpack 2, require.ensure now also returns a Promise + // so the resolve/reject functions may get called an extra time + // if the user uses an arrow function shorthand that happens to + // return that Promise. + function once (fn) { + var called = false; + return function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + if (called) { return } + called = true; + return fn.apply(this, args) + } + } + + /* */ + + var History = function History (router, base) { + this.router = router; + this.base = normalizeBase(base); + // start with a route object that stands for "nowhere" + this.current = START; + this.pending = null; + this.ready = false; + this.readyCbs = []; + this.readyErrorCbs = []; + this.errorCbs = []; + this.listeners = []; + }; + + History.prototype.listen = function listen (cb) { + this.cb = cb; + }; + + History.prototype.onReady = function onReady (cb, errorCb) { + if (this.ready) { + cb(); + } else { + this.readyCbs.push(cb); + if (errorCb) { + this.readyErrorCbs.push(errorCb); + } + } + }; + + History.prototype.onError = function onError (errorCb) { + this.errorCbs.push(errorCb); + }; + + History.prototype.transitionTo = function transitionTo ( location, onComplete, onAbort - ) { - var this$1 = this; - - var route; - // catch redirect option https://github.com/vuejs/vue-router/issues/3201 - try { - route = this.router.match(location, this.current); - } catch (e) { - this.errorCbs.forEach(function (cb) { - cb(e); - }); - // Exception should still be thrown - throw e - } - var prev = this.current; - this.confirmTransition( + ) { + var this$1 = this; + + var route; + // catch redirect option https://github.com/vuejs/vue-router/issues/3201 + try { + route = this.router.match(location, this.current); + } catch (e) { + this.errorCbs.forEach(function (cb) { + cb(e); + }); + // Exception should still be thrown + throw e + } + var prev = this.current; + this.confirmTransition( route, function () { this$1.updateRoute(route); @@ -2267,7 +2267,7 @@ this$1.router.afterHooks.forEach(function (hook) { hook && hook(route, prev); }); - + // fire ready cbs once if (!this$1.ready) { this$1.ready = true; @@ -2293,51 +2293,51 @@ } } } - ); - }; - - History.prototype.confirmTransition = function confirmTransition (route, onComplete, onAbort) { - var this$1 = this; - - var current = this.current; - this.pending = route; - var abort = function (err) { - // changed after adding errors with - // https://github.com/vuejs/vue-router/pull/3047 before that change, - // redirect and aborted navigation would produce an err == null - if (!isNavigationFailure(err) && isError(err)) { - if (this$1.errorCbs.length) { - this$1.errorCbs.forEach(function (cb) { - cb(err); - }); - } else { - warn(false, 'uncaught error during route navigation:'); - console.error(err); - } - } - onAbort && onAbort(err); + ); }; - var lastRouteIndex = route.matched.length - 1; - var lastCurrentIndex = current.matched.length - 1; - if ( + + History.prototype.confirmTransition = function confirmTransition (route, onComplete, onAbort) { + var this$1 = this; + + var current = this.current; + this.pending = route; + var abort = function (err) { + // changed after adding errors with + // https://github.com/vuejs/vue-router/pull/3047 before that change, + // redirect and aborted navigation would produce an err == null + if (!isNavigationFailure(err) && isError(err)) { + if (this$1.errorCbs.length) { + this$1.errorCbs.forEach(function (cb) { + cb(err); + }); + } else { + warn(false, 'uncaught error during route navigation:'); + console.error(err); + } + } + onAbort && onAbort(err); + }; + var lastRouteIndex = route.matched.length - 1; + var lastCurrentIndex = current.matched.length - 1; + if ( isSameRoute(route, current) && // in the case the route map has been dynamically appended to lastRouteIndex === lastCurrentIndex && route.matched[lastRouteIndex] === current.matched[lastCurrentIndex] - ) { - this.ensureURL(); - return abort(createNavigationDuplicatedError(current, route)) - } - - var ref = resolveQueue( + ) { + this.ensureURL(); + return abort(createNavigationDuplicatedError(current, route)) + } + + var ref = resolveQueue( this.current.matched, route.matched - ); - var updated = ref.updated; - var deactivated = ref.deactivated; - var activated = ref.activated; - - var queue = [].concat( + ); + var updated = ref.updated; + var deactivated = ref.deactivated; + var activated = ref.activated; + + var queue = [].concat( // in-component leave guards extractLeaveGuards(deactivated), // global before hooks @@ -2348,367 +2348,367 @@ activated.map(function (m) { return m.beforeEnter; }), // async components resolveAsyncComponents(activated) - ); - - var iterator = function (hook, next) { - if (this$1.pending !== route) { - return abort(createNavigationCancelledError(current, route)) - } - try { - hook(route, current, function (to) { - if (to === false) { - // next(false) -> abort navigation, ensure current URL - this$1.ensureURL(true); - abort(createNavigationAbortedError(current, route)); - } else if (isError(to)) { - this$1.ensureURL(true); - abort(to); - } else if ( + ); + + var iterator = function (hook, next) { + if (this$1.pending !== route) { + return abort(createNavigationCancelledError(current, route)) + } + try { + hook(route, current, function (to) { + if (to === false) { + // next(false) -> abort navigation, ensure current URL + this$1.ensureURL(true); + abort(createNavigationAbortedError(current, route)); + } else if (isError(to)) { + this$1.ensureURL(true); + abort(to); + } else if ( typeof to === 'string' || (typeof to === 'object' && - (typeof to.path === 'string' || typeof to.name === 'string')) - ) { - // next('/') or next({ path: '/' }) -> redirect - abort(createNavigationRedirectedError(current, route)); - if (typeof to === 'object' && to.replace) { - this$1.replace(to); + (typeof to.path === 'string' || typeof to.name === 'string')) + ) { + // next('/') or next({ path: '/' }) -> redirect + abort(createNavigationRedirectedError(current, route)); + if (typeof to === 'object' && to.replace) { + this$1.replace(to); + } else { + this$1.push(to); + } } else { - this$1.push(to); + // confirm transition and pass on the value + next(to); } - } else { - // confirm transition and pass on the value - next(to); + }); + } catch (e) { + abort(e); + } + }; + + runQueue(queue, iterator, function () { + // wait until async components are resolved before + // extracting in-component enter guards + var enterGuards = extractEnterGuards(activated); + var queue = enterGuards.concat(this$1.router.resolveHooks); + runQueue(queue, iterator, function () { + if (this$1.pending !== route) { + return abort(createNavigationCancelledError(current, route)) + } + this$1.pending = null; + onComplete(route); + if (this$1.router.app) { + BI.nextTick(function () { + handleRouteEntered(route); + }); } }); - } catch (e) { - abort(e); - } + }); }; - - runQueue(queue, iterator, function () { - // wait until async components are resolved before - // extracting in-component enter guards - var enterGuards = extractEnterGuards(activated); - var queue = enterGuards.concat(this$1.router.resolveHooks); - runQueue(queue, iterator, function () { - if (this$1.pending !== route) { - return abort(createNavigationCancelledError(current, route)) - } - this$1.pending = null; - onComplete(route); - if (this$1.router.app) { - BI.nextTick(function () { - handleRouteEntered(route); - }); - } + + History.prototype.updateRoute = function updateRoute (route) { + this.current = route; + this.cb && this.cb(route); + }; + + History.prototype.setupListeners = function setupListeners () { + // Default implementation is empty + }; + + History.prototype.teardown = function teardown () { + // clean up event listeners + // https://github.com/vuejs/vue-router/issues/2341 + this.listeners.forEach(function (cleanupListener) { + cleanupListener(); }); - }); - }; - - History.prototype.updateRoute = function updateRoute (route) { - this.current = route; - this.cb && this.cb(route); - }; - - History.prototype.setupListeners = function setupListeners () { - // Default implementation is empty - }; - - History.prototype.teardown = function teardown () { - // clean up event listeners - // https://github.com/vuejs/vue-router/issues/2341 - this.listeners.forEach(function (cleanupListener) { - cleanupListener(); - }); - this.listeners = []; - - // reset current history route - // https://github.com/vuejs/vue-router/issues/3294 - this.current = START; - this.pending = null; - }; - - function normalizeBase (base) { - if (!base) { - if (inBrowser) { - // respect tag - var baseEl = document.querySelector('base'); - base = (baseEl && baseEl.getAttribute('href')) || '/'; - // strip full URL origin - base = base.replace(/^https?:\/\/[^\/]+/, ''); - } else { - base = '/'; + this.listeners = []; + + // reset current history route + // https://github.com/vuejs/vue-router/issues/3294 + this.current = START; + this.pending = null; + }; + + function normalizeBase (base) { + if (!base) { + if (inBrowser) { + // respect tag + var baseEl = document.querySelector('base'); + base = (baseEl && baseEl.getAttribute('href')) || '/'; + // strip full URL origin + base = base.replace(/^https?:\/\/[^\/]+/, ''); + } else { + base = '/'; + } } + // make sure there's the starting slash + if (base.charAt(0) !== '/') { + base = '/' + base; + } + // remove trailing slash + return base.replace(/\/$/, '') } - // make sure there's the starting slash - if (base.charAt(0) !== '/') { - base = '/' + base; - } - // remove trailing slash - return base.replace(/\/$/, '') - } - - function resolveQueue ( + + function resolveQueue ( current, next - ) { - var i; - var max = Math.max(current.length, next.length); - for (i = 0; i < max; i++) { - if (current[i] !== next[i]) { - break - } - } - return { - updated: next.slice(0, i), - activated: next.slice(i), - deactivated: current.slice(i) - } - } - - function extractGuards ( + ) { + var i; + var max = Math.max(current.length, next.length); + for (i = 0; i < max; i++) { + if (current[i] !== next[i]) { + break + } + } + return { + updated: next.slice(0, i), + activated: next.slice(i), + deactivated: current.slice(i) + } + } + + function extractGuards ( records, name, bind, reverse - ) { - var guards = flatMapComponents(records, function (def, instance, match, key) { - var guard = extractGuard(def, name); - if (guard) { - return Array.isArray(guard) + ) { + var guards = flatMapComponents(records, function (def, instance, match, key) { + var guard = extractGuard(def, name); + if (guard) { + return Array.isArray(guard) ? guard.map(function (guard) { return bind(guard, instance, match, key); }) : bind(guard, instance, match, key) - } - }); - return flatten(reverse ? guards.reverse() : guards) - } - - function extractGuard ( + } + }); + return flatten(reverse ? guards.reverse() : guards) + } + + function extractGuard ( def, key - ) { - if (typeof def !== 'function') { - // extend now so that global mixins are applied. - // def = _Vue.extend(def); - } - return def[key] - } - - function extractLeaveGuards (deactivated) { - return extractGuards(deactivated, 'beforeRouteLeave', bindGuard, true) - } - - function extractUpdateHooks (updated) { - return extractGuards(updated, 'beforeRouteUpdate', bindGuard) - } - - function bindGuard (guard, instance) { - if (instance) { - return function boundRouteGuard () { - return guard.apply(instance, arguments) - } - } - } - - function extractEnterGuards ( + ) { + if (typeof def !== 'function') { + // extend now so that global mixins are applied. + // def = _Vue.extend(def); + } + return def[key] + } + + function extractLeaveGuards (deactivated) { + return extractGuards(deactivated, 'beforeRouteLeave', bindGuard, true) + } + + function extractUpdateHooks (updated) { + return extractGuards(updated, 'beforeRouteUpdate', bindGuard) + } + + function bindGuard (guard, instance) { + if (instance) { + return function boundRouteGuard () { + return guard.apply(instance, arguments) + } + } + } + + function extractEnterGuards ( activated - ) { - return extractGuards( + ) { + return extractGuards( activated, 'beforeRouteEnter', function (guard, _, match, key) { return bindEnterGuard(guard, match, key) } - ) - } - - function bindEnterGuard ( + ) + } + + function bindEnterGuard ( guard, match, key - ) { - return function routeEnterGuard (to, from, next) { - return guard(to, from, function (cb) { - if (typeof cb === 'function') { - if (!match.enteredCbs[key]) { - match.enteredCbs[key] = []; + ) { + return function routeEnterGuard (to, from, next) { + return guard(to, from, function (cb) { + if (typeof cb === 'function') { + if (!match.enteredCbs[key]) { + match.enteredCbs[key] = []; + } + match.enteredCbs[key].push(cb); } - match.enteredCbs[key].push(cb); - } - next(cb); - }) + next(cb); + }) + } } - } - - /* */ - - var HTML5History = /*@__PURE__*/(function (History) { - function HTML5History (router, base) { - History.call(this, router, base); - - this._startLocation = getLocation(this.base); - } - - if ( History ) HTML5History.__proto__ = History; - HTML5History.prototype = Object.create( History && History.prototype ); - HTML5History.prototype.constructor = HTML5History; - - HTML5History.prototype.setupListeners = function setupListeners () { - var this$1 = this; - - if (this.listeners.length > 0) { - return + + /* */ + + var HTML5History = /*@__PURE__*/(function (History) { + function HTML5History (router, base) { + History.call(this, router, base); + + this._startLocation = getLocation(this.base); } - - var router = this.router; - var expectScroll = router.options.scrollBehavior; - var supportsScroll = supportsPushState && expectScroll; - - if (supportsScroll) { - this.listeners.push(setupScroll()); - } - - var handleRoutingEvent = function () { - var current = this$1.current; - - // Avoiding first `popstate` event dispatched in some browsers but first - // history route not updated since async guard at the same time. - var location = getLocation(this$1.base); - if (this$1.current === START && location === this$1._startLocation) { + + if ( History ) HTML5History.__proto__ = History; + HTML5History.prototype = Object.create( History && History.prototype ); + HTML5History.prototype.constructor = HTML5History; + + HTML5History.prototype.setupListeners = function setupListeners () { + var this$1 = this; + + if (this.listeners.length > 0) { return } - - this$1.transitionTo(location, function (route) { - if (supportsScroll) { - handleScroll(router, route, current, true); + + var router = this.router; + var expectScroll = router.options.scrollBehavior; + var supportsScroll = supportsPushState && expectScroll; + + if (supportsScroll) { + this.listeners.push(setupScroll()); + } + + var handleRoutingEvent = function () { + var current = this$1.current; + + // Avoiding first `popstate` event dispatched in some browsers but first + // history route not updated since async guard at the same time. + var location = getLocation(this$1.base); + if (this$1.current === START && location === this$1._startLocation) { + return } + + this$1.transitionTo(location, function (route) { + if (supportsScroll) { + handleScroll(router, route, current, true); + } + }); + }; + window.addEventListener('popstate', handleRoutingEvent); + this.listeners.push(function () { + window.removeEventListener('popstate', handleRoutingEvent); }); }; - window.addEventListener('popstate', handleRoutingEvent); - this.listeners.push(function () { - window.removeEventListener('popstate', handleRoutingEvent); - }); - }; - - HTML5History.prototype.go = function go (n) { - window.history.go(n); - }; - - HTML5History.prototype.push = function push (location, onComplete, onAbort) { - var this$1 = this; - - var ref = this; - var fromRoute = ref.current; - this.transitionTo(location, function (route) { - pushState(cleanPath(this$1.base + route.fullPath)); - handleScroll(this$1.router, route, fromRoute, false); - onComplete && onComplete(route); - }, onAbort); - }; - - HTML5History.prototype.replace = function replace (location, onComplete, onAbort) { - var this$1 = this; - - var ref = this; - var fromRoute = ref.current; - this.transitionTo(location, function (route) { - replaceState(cleanPath(this$1.base + route.fullPath)); - handleScroll(this$1.router, route, fromRoute, false); - onComplete && onComplete(route); - }, onAbort); - }; - - HTML5History.prototype.ensureURL = function ensureURL (push) { - if (getLocation(this.base) !== this.current.fullPath) { - var current = cleanPath(this.base + this.current.fullPath); - push ? pushState(current) : replaceState(current); - } - }; - - HTML5History.prototype.getCurrentLocation = function getCurrentLocation () { - return getLocation(this.base) - }; - - return HTML5History; - }(History)); - - function getLocation (base) { - var path = window.location.pathname; - var pathLowerCase = path.toLowerCase(); - var baseLowerCase = base.toLowerCase(); - // base="/a" shouldn't turn path="/app" into "/a/pp" - // https://github.com/vuejs/vue-router/issues/3555 - // so we ensure the trailing slash in the base - if (base && ((pathLowerCase === baseLowerCase) || + + HTML5History.prototype.go = function go (n) { + window.history.go(n); + }; + + HTML5History.prototype.push = function push (location, onComplete, onAbort) { + var this$1 = this; + + var ref = this; + var fromRoute = ref.current; + this.transitionTo(location, function (route) { + pushState(cleanPath(this$1.base + route.fullPath)); + handleScroll(this$1.router, route, fromRoute, false); + onComplete && onComplete(route); + }, onAbort); + }; + + HTML5History.prototype.replace = function replace (location, onComplete, onAbort) { + var this$1 = this; + + var ref = this; + var fromRoute = ref.current; + this.transitionTo(location, function (route) { + replaceState(cleanPath(this$1.base + route.fullPath)); + handleScroll(this$1.router, route, fromRoute, false); + onComplete && onComplete(route); + }, onAbort); + }; + + HTML5History.prototype.ensureURL = function ensureURL (push) { + if (getLocation(this.base) !== this.current.fullPath) { + var current = cleanPath(this.base + this.current.fullPath); + push ? pushState(current) : replaceState(current); + } + }; + + HTML5History.prototype.getCurrentLocation = function getCurrentLocation () { + return getLocation(this.base) + }; + + return HTML5History; + }(History)); + + function getLocation (base) { + var path = window.location.pathname; + var pathLowerCase = path.toLowerCase(); + var baseLowerCase = base.toLowerCase(); + // base="/a" shouldn't turn path="/app" into "/a/pp" + // https://github.com/vuejs/vue-router/issues/3555 + // so we ensure the trailing slash in the base + if (base && ((pathLowerCase === baseLowerCase) || (pathLowerCase.indexOf(cleanPath(baseLowerCase + '/')) === 0))) { - path = path.slice(base.length); - } - return (path || '/') + window.location.search + window.location.hash - } - - /* */ - - var HashHistory = /*@__PURE__*/(function (History) { - function HashHistory (router, base, fallback) { - History.call(this, router, base); - // check history fallback deeplinking - if (fallback && checkFallback(this.base)) { - return + path = path.slice(base.length); } - ensureSlash(); - } - - if ( History ) HashHistory.__proto__ = History; - HashHistory.prototype = Object.create( History && History.prototype ); - HashHistory.prototype.constructor = HashHistory; - - // this is delayed until the app mounts - // to avoid the hashchange listener being fired too early - HashHistory.prototype.setupListeners = function setupListeners () { - var this$1 = this; - - if (this.listeners.length > 0) { - return + return (path || '/') + window.location.search + window.location.hash + } + + /* */ + + var HashHistory = /*@__PURE__*/(function (History) { + function HashHistory (router, base, fallback) { + History.call(this, router, base); + // check history fallback deeplinking + if (fallback && checkFallback(this.base)) { + return + } + ensureSlash(); } - - var router = this.router; - var expectScroll = router.options.scrollBehavior; - var supportsScroll = supportsPushState && expectScroll; - - if (supportsScroll) { - this.listeners.push(setupScroll()); - } - - var handleRoutingEvent = function () { - var current = this$1.current; - if (!ensureSlash()) { + + if ( History ) HashHistory.__proto__ = History; + HashHistory.prototype = Object.create( History && History.prototype ); + HashHistory.prototype.constructor = HashHistory; + + // this is delayed until the app mounts + // to avoid the hashchange listener being fired too early + HashHistory.prototype.setupListeners = function setupListeners () { + var this$1 = this; + + if (this.listeners.length > 0) { return } - this$1.transitionTo(getHash(), function (route) { - if (supportsScroll) { - handleScroll(this$1.router, route, current, true); - } - if (!supportsPushState) { - replaceHash(route.fullPath); + + var router = this.router; + var expectScroll = router.options.scrollBehavior; + var supportsScroll = supportsPushState && expectScroll; + + if (supportsScroll) { + this.listeners.push(setupScroll()); + } + + var handleRoutingEvent = function () { + var current = this$1.current; + if (!ensureSlash()) { + return } - }); - }; - var eventType = supportsPushState ? 'popstate' : 'hashchange'; - window.addEventListener( + this$1.transitionTo(getHash(), function (route) { + if (supportsScroll) { + handleScroll(this$1.router, route, current, true); + } + if (!supportsPushState) { + replaceHash(route.fullPath); + } + }); + }; + var eventType = supportsPushState ? 'popstate' : 'hashchange'; + window.addEventListener( eventType, handleRoutingEvent - ); - this.listeners.push(function () { - window.removeEventListener(eventType, handleRoutingEvent); - }); - }; - - HashHistory.prototype.push = function push (location, onComplete, onAbort) { - var this$1 = this; - - var ref = this; - var fromRoute = ref.current; - this.transitionTo( + ); + this.listeners.push(function () { + window.removeEventListener(eventType, handleRoutingEvent); + }); + }; + + HashHistory.prototype.push = function push (location, onComplete, onAbort) { + var this$1 = this; + + var ref = this; + var fromRoute = ref.current; + this.transitionTo( location, function (route) { pushHash(route.fullPath); @@ -2716,15 +2716,15 @@ onComplete && onComplete(route); }, onAbort - ); - }; - - HashHistory.prototype.replace = function replace (location, onComplete, onAbort) { - var this$1 = this; - - var ref = this; - var fromRoute = ref.current; - this.transitionTo( + ); + }; + + HashHistory.prototype.replace = function replace (location, onComplete, onAbort) { + var this$1 = this; + + var ref = this; + var fromRoute = ref.current; + this.transitionTo( location, function (route) { replaceHash(route.fullPath); @@ -2732,97 +2732,97 @@ onComplete && onComplete(route); }, onAbort - ); - }; - - HashHistory.prototype.go = function go (n) { - window.history.go(n); - }; - - HashHistory.prototype.ensureURL = function ensureURL (push) { - var current = this.current.fullPath; - if (getHash() !== current) { - push ? pushHash(current) : replaceHash(current); + ); + }; + + HashHistory.prototype.go = function go (n) { + window.history.go(n); + }; + + HashHistory.prototype.ensureURL = function ensureURL (push) { + var current = this.current.fullPath; + if (getHash() !== current) { + push ? pushHash(current) : replaceHash(current); + } + }; + + HashHistory.prototype.getCurrentLocation = function getCurrentLocation () { + return getHash() + }; + + return HashHistory; + }(History)); + + function checkFallback (base) { + var location = getLocation(base); + if (!/^\/#/.test(location)) { + window.location.replace(cleanPath(base + '/#' + location)); + return true } - }; - - HashHistory.prototype.getCurrentLocation = function getCurrentLocation () { - return getHash() - }; - - return HashHistory; - }(History)); - - function checkFallback (base) { - var location = getLocation(base); - if (!/^\/#/.test(location)) { - window.location.replace(cleanPath(base + '/#' + location)); - return true } - } - - function ensureSlash () { - var path = getHash(); - if (path.charAt(0) === '/') { - return true + + function ensureSlash () { + var path = getHash(); + if (path.charAt(0) === '/') { + return true + } + replaceHash('/' + path); + return false + } + + function getHash () { + // We can't use window.location.hash here because it's not + // consistent across browsers - Firefox will pre-decode it! + var href = window.location.href; + var index = href.indexOf('#'); + // empty path + if (index < 0) { return '' } + + href = href.slice(index + 1); + + return href + } + + function getUrl (path) { + var href = window.location.href; + var i = href.indexOf('#'); + var base = i >= 0 ? href.slice(0, i) : href; + return (base + "#" + path) + } + + function pushHash (path) { + if (supportsPushState) { + pushState(getUrl(path)); + } else { + window.location.hash = path; + } + } + + function replaceHash (path) { + if (supportsPushState) { + replaceState(getUrl(path)); + } else { + window.location.replace(getUrl(path)); + } } - replaceHash('/' + path); - return false - } - - function getHash () { - // We can't use window.location.hash here because it's not - // consistent across browsers - Firefox will pre-decode it! - var href = window.location.href; - var index = href.indexOf('#'); - // empty path - if (index < 0) { return '' } - - href = href.slice(index + 1); - - return href - } - - function getUrl (path) { - var href = window.location.href; - var i = href.indexOf('#'); - var base = i >= 0 ? href.slice(0, i) : href; - return (base + "#" + path) - } - - function pushHash (path) { - if (supportsPushState) { - pushState(getUrl(path)); - } else { - window.location.hash = path; - } - } - - function replaceHash (path) { - if (supportsPushState) { - replaceState(getUrl(path)); - } else { - window.location.replace(getUrl(path)); - } - } - - /* */ - - var AbstractHistory = /*@__PURE__*/(function (History) { - function AbstractHistory (router, base) { - History.call(this, router, base); - this.stack = []; - this.index = -1; - } - - if ( History ) AbstractHistory.__proto__ = History; - AbstractHistory.prototype = Object.create( History && History.prototype ); - AbstractHistory.prototype.constructor = AbstractHistory; - - AbstractHistory.prototype.push = function push (location, onComplete, onAbort) { - var this$1 = this; - - this.transitionTo( + + /* */ + + var AbstractHistory = /*@__PURE__*/(function (History) { + function AbstractHistory (router, base) { + History.call(this, router, base); + this.stack = []; + this.index = -1; + } + + if ( History ) AbstractHistory.__proto__ = History; + AbstractHistory.prototype = Object.create( History && History.prototype ); + AbstractHistory.prototype.constructor = AbstractHistory; + + AbstractHistory.prototype.push = function push (location, onComplete, onAbort) { + var this$1 = this; + + this.transitionTo( location, function (route) { this$1.stack = this$1.stack.slice(0, this$1.index + 1).concat(route); @@ -2830,31 +2830,31 @@ onComplete && onComplete(route); }, onAbort - ); - }; - - AbstractHistory.prototype.replace = function replace (location, onComplete, onAbort) { - var this$1 = this; - - this.transitionTo( + ); + }; + + AbstractHistory.prototype.replace = function replace (location, onComplete, onAbort) { + var this$1 = this; + + this.transitionTo( location, function (route) { this$1.stack = this$1.stack.slice(0, this$1.index).concat(route); onComplete && onComplete(route); }, onAbort - ); - }; - - AbstractHistory.prototype.go = function go (n) { - var this$1 = this; - - var targetIndex = this.index + n; - if (targetIndex < 0 || targetIndex >= this.stack.length) { - return - } - var route = this.stack[targetIndex]; - this.confirmTransition( + ); + }; + + AbstractHistory.prototype.go = function go (n) { + var this$1 = this; + + var targetIndex = this.index + n; + if (targetIndex < 0 || targetIndex >= this.stack.length) { + return + } + var route = this.stack[targetIndex]; + this.confirmTransition( route, function () { var prev = this$1.current; @@ -2869,337 +2869,338 @@ this$1.index = targetIndex; } } - ); + ); + }; + + AbstractHistory.prototype.getCurrentLocation = function getCurrentLocation () { + var current = this.stack[this.stack.length - 1]; + return current ? current.fullPath : '/' + }; + + AbstractHistory.prototype.ensureURL = function ensureURL () { + // noop + }; + + return AbstractHistory; + }(History)); + + /* */ + + var VueRouter = function VueRouter (options) { + if ( options === void 0 ) options = {}; + + this.app = null; + this.apps = []; + this.options = options; + this.beforeHooks = []; + this.resolveHooks = []; + this.afterHooks = []; + this.matcher = createMatcher(options.routes || [], this); + + var mode = options.mode || 'hash'; + this.fallback = + mode === 'history' && !supportsPushState && options.fallback !== false; + if (this.fallback) { + mode = 'hash'; + } + if (!inBrowser) { + mode = 'abstract'; + } + this.mode = mode; + + switch (mode) { + case 'history': + this.history = new HTML5History(this, options.base); + break + case 'hash': + this.history = new HashHistory(this, options.base, this.fallback); + break + case 'abstract': + this.history = new AbstractHistory(this, options.base); + break + default: + { + assert(false, ("invalid mode: " + mode)); + } + } }; - - AbstractHistory.prototype.getCurrentLocation = function getCurrentLocation () { - var current = this.stack[this.stack.length - 1]; - return current ? current.fullPath : '/' + + var prototypeAccessors = { currentRoute: { configurable: true } }; + + VueRouter.prototype.match = function match (raw, current, redirectedFrom) { + return this.matcher.match(raw, current, redirectedFrom) }; - - AbstractHistory.prototype.ensureURL = function ensureURL () { - // noop + + prototypeAccessors.currentRoute.get = function () { + return this.history && this.history.current }; - - return AbstractHistory; - }(History)); - - /* */ - - var VueRouter = function VueRouter (options) { - if ( options === void 0 ) options = {}; - - this.app = null; - this.apps = []; - this.options = options; - this.beforeHooks = []; - this.resolveHooks = []; - this.afterHooks = []; - this.matcher = createMatcher(options.routes || [], this); - - var mode = options.mode || 'hash'; - this.fallback = - mode === 'history' && !supportsPushState && options.fallback !== false; - if (this.fallback) { - mode = 'hash'; - } - if (!inBrowser) { - mode = 'abstract'; - } - this.mode = mode; - - switch (mode) { - case 'history': - this.history = new HTML5History(this, options.base); - break - case 'hash': - this.history = new HashHistory(this, options.base, this.fallback); - break - case 'abstract': - this.history = new AbstractHistory(this, options.base); - break - default: - { - assert(false, ("invalid mode: " + mode)); - } - } - }; - - var prototypeAccessors = { currentRoute: { configurable: true } }; - - VueRouter.prototype.match = function match (raw, current, redirectedFrom) { - return this.matcher.match(raw, current, redirectedFrom) - }; - - prototypeAccessors.currentRoute.get = function () { - return this.history && this.history.current - }; - - VueRouter.prototype.init = function init (app /* Vue component instance */) { - var this$1 = this; - - this.apps.push(app); - - // set up app destroyed handler - // https://github.com/vuejs/vue-router/issues/2639 - app.once('hook:destroyed', function () { - // clean out app from this.apps array once destroyed - var index = this$1.apps.indexOf(app); - if (index > -1) { this$1.apps.splice(index, 1); } - // ensure we still have a main app or null if no apps - // we do not release the router so it can be reused - if (this$1.app === app) { this$1.app = this$1.apps[0] || null; } - - if (!this$1.app) { this$1.history.teardown(); } - }); - - // main app previously initialized - // return as we don't need to set up new history listener - if (this.app) { - return - } - - this.app = app; - - var history = this.history; - - if (history instanceof HTML5History || history instanceof HashHistory) { - var handleInitialScroll = function (routeOrError) { - var from = history.current; - var expectScroll = this$1.options.scrollBehavior; - var supportsScroll = supportsPushState && expectScroll; - - if (supportsScroll && 'fullPath' in routeOrError) { - handleScroll(this$1, routeOrError, from, false); - } - }; - var setupListeners = function (routeOrError) { - history.setupListeners(); - handleInitialScroll(routeOrError); - }; - history.transitionTo( + + VueRouter.prototype.init = function init (app /* Vue component instance */) { + var this$1 = this; + + this.apps.push(app); + + // set up app destroyed handler + // https://github.com/vuejs/vue-router/issues/2639 + app.once('hook:destroyed', function () { + // clean out app from this.apps array once destroyed + var index = this$1.apps.indexOf(app); + if (index > -1) { this$1.apps.splice(index, 1); } + // ensure we still have a main app or null if no apps + // we do not release the router so it can be reused + if (this$1.app === app) { this$1.app = this$1.apps[0] || null; } + + if (!this$1.app) { this$1.history.teardown(); } + }); + + // main app previously initialized + // return as we don't need to set up new history listener + if (this.app) { + return + } + + this.app = app; + + var history = this.history; + + if (history instanceof HTML5History || history instanceof HashHistory) { + var handleInitialScroll = function (routeOrError) { + var from = history.current; + var expectScroll = this$1.options.scrollBehavior; + var supportsScroll = supportsPushState && expectScroll; + + if (supportsScroll && 'fullPath' in routeOrError) { + handleScroll(this$1, routeOrError, from, false); + } + }; + var setupListeners = function (routeOrError) { + history.setupListeners(); + handleInitialScroll(routeOrError); + }; + history.transitionTo( history.getCurrentLocation(), setupListeners, setupListeners - ); - } - - history.listen(function (route) { - this$1.apps.forEach(function (app) { - app._router.history.current = route; + ); + } + + history.listen(function (route) { + this$1.apps.forEach(function (app) { + app._router.history.current = route; + }); }); - }); - }; - - VueRouter.prototype.beforeEach = function beforeEach (fn) { - return registerHook(this.beforeHooks, fn) - }; - - VueRouter.prototype.beforeResolve = function beforeResolve (fn) { - return registerHook(this.resolveHooks, fn) - }; - - VueRouter.prototype.afterEach = function afterEach (fn) { - return registerHook(this.afterHooks, fn) - }; - - VueRouter.prototype.onReady = function onReady (cb, errorCb) { - this.history.onReady(cb, errorCb); - }; - - VueRouter.prototype.onError = function onError (errorCb) { - this.history.onError(errorCb); - }; - - VueRouter.prototype.push = function push (location, onComplete, onAbort) { - var this$1 = this; - - // $flow-disable-line - if (!onComplete && !onAbort && typeof Promise !== 'undefined') { - return new Promise(function (resolve, reject) { - this$1.history.push(location, resolve, reject); - }) - } else { - this.history.push(location, onComplete, onAbort); - } - }; - - VueRouter.prototype.replace = function replace (location, onComplete, onAbort) { - var this$1 = this; - - // $flow-disable-line - if (!onComplete && !onAbort && typeof Promise !== 'undefined') { - return new Promise(function (resolve, reject) { - this$1.history.replace(location, resolve, reject); - }) - } else { - this.history.replace(location, onComplete, onAbort); - } - }; - - VueRouter.prototype.go = function go (n) { - this.history.go(n); - }; - - VueRouter.prototype.back = function back () { - this.go(-1); - }; - - VueRouter.prototype.forward = function forward () { - this.go(1); - }; - - VueRouter.prototype.getMatchedComponents = function getMatchedComponents (to) { - var route = to + }; + + VueRouter.prototype.beforeEach = function beforeEach (fn) { + return registerHook(this.beforeHooks, fn) + }; + + VueRouter.prototype.beforeResolve = function beforeResolve (fn) { + return registerHook(this.resolveHooks, fn) + }; + + VueRouter.prototype.afterEach = function afterEach (fn) { + return registerHook(this.afterHooks, fn) + }; + + VueRouter.prototype.onReady = function onReady (cb, errorCb) { + this.history.onReady(cb, errorCb); + }; + + VueRouter.prototype.onError = function onError (errorCb) { + this.history.onError(errorCb); + }; + + VueRouter.prototype.push = function push (location, onComplete, onAbort) { + var this$1 = this; + + // $flow-disable-line + if (!onComplete && !onAbort && typeof Promise !== 'undefined') { + return new Promise(function (resolve, reject) { + this$1.history.push(location, resolve, reject); + }) + } else { + this.history.push(location, onComplete, onAbort); + } + }; + + VueRouter.prototype.replace = function replace (location, onComplete, onAbort) { + var this$1 = this; + + // $flow-disable-line + if (!onComplete && !onAbort && typeof Promise !== 'undefined') { + return new Promise(function (resolve, reject) { + this$1.history.replace(location, resolve, reject); + }) + } else { + this.history.replace(location, onComplete, onAbort); + } + }; + + VueRouter.prototype.go = function go (n) { + this.history.go(n); + }; + + VueRouter.prototype.back = function back () { + this.go(-1); + }; + + VueRouter.prototype.forward = function forward () { + this.go(1); + }; + + VueRouter.prototype.getMatchedComponents = function getMatchedComponents (to) { + var route = to ? to.matched - ? to - : this.resolve(to).route + ? to + : this.resolve(to).route : this.currentRoute; - if (!route) { - return [] - } - return [].concat.apply( + if (!route) { + return [] + } + return [].concat.apply( [], route.matched.map(function (m) { return Object.keys(m.components).map(function (key) { return m.components[key] }) }) - ) - }; - - VueRouter.prototype.resolve = function resolve ( + ) + }; + + VueRouter.prototype.resolve = function resolve ( to, current, append - ) { - current = current || this.history.current; - var location = normalizeLocation(to, current, append, this); - var route = this.match(location, current); - var fullPath = route.redirectedFrom || route.fullPath; - var base = this.history.base; - var href = createHref(base, fullPath, this.mode); - return { - location: location, - route: route, - href: href, - // for backwards compat - normalizedTo: location, - resolved: route - } - }; - - VueRouter.prototype.getRoutes = function getRoutes () { - return this.matcher.getRoutes() - }; - - VueRouter.prototype.addRoute = function addRoute (parentOrRoute, route) { - this.matcher.addRoute(parentOrRoute, route); - if (this.history.current !== START) { - this.history.transitionTo(this.history.getCurrentLocation()); - } - }; - - Object.defineProperties( VueRouter.prototype, prototypeAccessors ); - - function registerHook (list, fn) { - list.push(fn); - return function () { - var i = list.indexOf(fn); - if (i > -1) { list.splice(i, 1); } - } - } - - function createHref (base, fullPath, mode) { - var path = mode === 'hash' ? '#' + fullPath : fullPath; - return base ? cleanPath(base + '/' + path) : path - } - - // VueRouter.install = install; - VueRouter.version = '3.5.2'; - VueRouter.isNavigationFailure = isNavigationFailure; - VueRouter.NavigationFailureType = NavigationFailureType; - VueRouter.START_LOCATION = START; - - - var $router, cbs = []; - BI.RouterWidget = BI.inherit(BI.Widget, { - init: function () { - this.$router = this._router = BI.Router.$router = $router = new VueRouter({ - mode: this.options.mode, - routes: this.options.routes, - base: this.options.base, - }); - this.$router.beforeEach(function (to, from, next) { - if (to.matched.length === 0) { - //如果上级也未匹配到路由则跳转主页面,如果上级能匹配到则转上级路由 - from.path ? next({ path: from.path }) : next('/'); - } else { - //如果匹配到正确跳转 - next(); - } - }); - this.$router.afterEach(function () { - cbs.forEach(function (cb) {cb();}); - }); - this.$router.init(this); - } - }); - BI.shortcut("bi.router", BI.RouterWidget); - - BI.RouterView = BI.inherit(BI.Widget, { - props: { - baseCls: 'bi-router-view', - deps: 0, - name: 'default' - }, - created: function () { - var self = this, o = this.options; - cbs.push(this._callbackListener = function () { - var current = $router.history.current; - // 匹配的路径名(/component/:id) - var matchedPath = current.matched[o.deps] && current.matched[o.deps].path; - var component = current.matched[o.deps] && current.matched[o.deps].components[o.name]; - - if (BI.isNotNull(component)) { - if (matchedPath) { - BI.each(current.params, function (key, value) { - // 把 :id 替换成具体的值(/component/demo.td) - matchedPath = matchedPath.replace(`:${key}`, value); - }); - } - self.tab.setSelect(matchedPath || "/"); - } - }); - // "bi.router_view"是由"bi.tab"实现的,cardCreator是一个异步过程,在"bi.router_view"创建之前,cbs里不会有创建子组件的方法,在初始化路由时,没法直接渲染到子组件,所以这里手动加了一次调用 - this._callbackListener(); - }, - render: function () { - var self = this, o = this.options; + ) { + current = current || this.history.current; + var location = normalizeLocation(to, current, append, this); + var route = this.match(location, current); + var fullPath = route.redirectedFrom || route.fullPath; + var base = this.history.base; + var href = createHref(base, fullPath, this.mode); return { - type: "bi.tab", - ref: function (_ref) { - self.tab = _ref; - }, - single: o.single, // 是不是单页面 - keepAlives: o.keepAlives, - logic: { - dynamic: false - }, - showIndex: false, - cardCreator: function (v) { - return $router.history.current.matched[o.deps].components[o.name]; - } - }; - }, - destroyed: function () { - BI.remove(cbs, this._callbackListener); - } - }); - BI.shortcut("bi.router_view", BI.RouterView); - - BI.Router = BI.Router || VueRouter; - BI.Router.isSameRoute = isSameRoute; - return VueRouter; - -}))); + location: location, + route: route, + href: href, + // for backwards compat + normalizedTo: location, + resolved: route + } + }; + + VueRouter.prototype.getRoutes = function getRoutes () { + return this.matcher.getRoutes() + }; + + VueRouter.prototype.addRoute = function addRoute (parentOrRoute, route) { + this.matcher.addRoute(parentOrRoute, route); + if (this.history.current !== START) { + this.history.transitionTo(this.history.getCurrentLocation()); + } + }; + + Object.defineProperties( VueRouter.prototype, prototypeAccessors ); + + function registerHook (list, fn) { + list.push(fn); + return function () { + var i = list.indexOf(fn); + if (i > -1) { list.splice(i, 1); } + } + } + + function createHref (base, fullPath, mode) { + var path = mode === 'hash' ? '#' + fullPath : fullPath; + return base ? cleanPath(base + '/' + path) : path + } + + // VueRouter.install = install; + VueRouter.version = '3.5.2'; + VueRouter.isNavigationFailure = isNavigationFailure; + VueRouter.NavigationFailureType = NavigationFailureType; + VueRouter.START_LOCATION = START; + + + var $router, cbs = []; + BI.RouterWidget = BI.inherit(BI.Widget, { + init: function () { + this.$router = this._router = BI.Router.$router = $router = new VueRouter({ + mode: this.options.mode, + routes: this.options.routes, + base: this.options.base, + }); + this.$router.beforeEach(function (to, from, next) { + if (to.matched.length === 0) { + //如果上级也未匹配到路由则跳转主页面,如果上级能匹配到则转上级路由 + from.path ? next({ path: from.path }) : next('/'); + } else { + //如果匹配到正确跳转 + next(); + } + }); + this.$router.afterEach(function () { + cbs.forEach(function (cb) {cb();}); + }); + this.$router.init(this); + } + }); + BI.shortcut("bi.router", BI.RouterWidget); + + BI.RouterView = BI.inherit(BI.Widget, { + props: { + baseCls: 'bi-router-view', + deps: 0, + name: 'default' + }, + created: function () { + var self = this, o = this.options; + cbs.push(this._callbackListener = function () { + var current = $router.history.current; + // 匹配的路径名(/component/:id) + var matchedPath = current.matched[o.deps] && current.matched[o.deps].path; + var component = current.matched[o.deps] && current.matched[o.deps].components[o.name]; + + if (BI.isNotNull(component)) { + if (matchedPath) { + BI.each(current.params, function (key, value) { + // 把 :id 替换成具体的值(/component/demo.td) + matchedPath = matchedPath.replace(`:${key}`, value); + }); + } + self.tab.setSelect(matchedPath || "/"); + } + }); + // "bi.router_view"是由"bi.tab"实现的,cardCreator是一个异步过程,在"bi.router_view"创建之前,cbs里不会有创建子组件的方法,在初始化路由时,没法直接渲染到子组件,所以这里手动加了一次调用 + this._callbackListener(); + }, + render: function () { + var self = this, o = this.options; + return { + type: "bi.tab", + ref: function (_ref) { + self.tab = _ref; + }, + single: o.single, // 是不是单页面 + keepAlives: o.keepAlives, + logic: { + dynamic: false + }, + showIndex: false, + cardCreator: function (v) { + return $router.history.current.matched[o.deps].components[o.name]; + } + }; + }, + destroyed: function () { + BI.remove(cbs, this._callbackListener); + } + }); + BI.shortcut("bi.router_view", BI.RouterView); + + BI.Router = BI.Router || VueRouter; + BI.Router.isSameRoute = isSameRoute; + return VueRouter; + + }))); + \ No newline at end of file diff --git a/src/widget/multilayerselecttree/multilayerselecttree.combo.js b/src/widget/multilayerselecttree/multilayerselecttree.combo.js index 6365ef484..8230ace71 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.combo.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.combo.js @@ -16,66 +16,29 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { allowEdit: false, allowSearchValue: false, allowInsertValue: false, - isNeedAdjustWidth: true + isNeedAdjustWidth: true, + status: "", // "error","warning" }); }, _init: function () { var o = this.options; - if (this._shouldWrapper()) { - o.height -= 2; - BI.isNumeric(o.width) && (o.width -= 2); - } + BI.isNumeric(o.width) && (o.width -= 2); + BI.isNumeric(o.height) && (o.height -= 2); BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments); }, render: function () { var self = this, o = this.options; - var combo = (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); - - return this._shouldWrapper() ? combo : { - type: "bi.absolute", - items: [{ - el: combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.trigger_icon_button", - cls: "trigger-icon-button", - ref: function (_ref) { - self.triggerBtn = _ref; - }, - width: o.height, - height: o.height, - handler: function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - } - }, - right: 0, - bottom: 0, - top: 0 - }] - }; - }, - - _shouldWrapper: function () { - var o = this.options; - return !o.allowEdit && o.itemsCreator === BI.emptyFn; + return (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); }, _getBaseConfig: function () { var self = this, o = this.options; return { type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + 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, @@ -122,7 +85,7 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { }; }, - _getSearchConfig: function() { + _getSearchConfig: function () { var self = this, o = this.options; return { el: { @@ -139,7 +102,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, watermark: o.watermark, - height: o.height - (o.simple ? 1 : 2), + // height: o.height - (o.simple ? 1 : 2), + height: o.height, text: o.text, value: o.value, tipType: o.tipType, @@ -184,7 +148,7 @@ BI.MultiLayerSelectTreeCombo = 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) ? false : self.triggerBtn.element.find(e.target).length === 0; + return !(o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0); }, listeners: [{ @@ -198,7 +162,7 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW); } }] - } + }; }, _getSyncConfig: function () { @@ -207,13 +171,15 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : { el: { type: "bi.single_tree_trigger", - ref: function(_ref) { + ref: function (_ref) { self.textTrigger = _ref; }, text: o.text, height: o.height, items: o.items, - value: o.value + value: o.value, + tipType: o.tipType, + warningTitle: o.warningTitle, } }); }, @@ -236,6 +202,22 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { return this.trigger ? this.trigger.getSearcher() : this.textTrigger.getTextor(); }, + clear: function () { + // do some work + }, + + setStatus: function (status) { + if (BI.isKey(this.options.status)) { + this.element.removeClass("status-" + this.options.status); + } + this.element.addClass("status-" + status); + this.options.status = status; + }, + + setTipType: function (v) { + this.trigger ? this.trigger.setTipType(v) : this.textTrigger.setTipType(v); + }, + populate: function (items) { this.combo.populate(items); }, diff --git a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js index 4b66b58f7..11789b5ac 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js @@ -3,7 +3,7 @@ */ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { - props: function() { + props: function () { return { extraCls: "bi-multi-layer-select-tree-trigger", height: 24, @@ -16,11 +16,12 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { render: function () { var self = this, o = this.options; - if(o.itemsCreator === BI.emptyFn) { + if (o.itemsCreator === BI.emptyFn) { this._initData(); } - var content = { - type: "bi.htape", + + return { + type: "bi.horizontal_fill", items: [ { el: { @@ -86,7 +87,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }, onSearch: function (obj, callback) { var keyword = obj.keyword; - if(o.itemsCreator === BI.emptyFn) { + if (o.itemsCreator === BI.emptyFn) { callback(self._getSearchItems(keyword)); o.allowInsertValue && self.popup.setKeyword(keyword); } else { @@ -99,51 +100,37 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE); } }] - } + }, + width: "fill", }, { el: { - type: "bi.layout", - width: 24 + type: "bi.trigger_icon_button", + cls: "trigger-icon-button", + ref: function (_ref) { + self.triggerBtn = _ref; + }, + width: 24, }, - width: 24 + width: 24, } ] }; - - return o.allowEdit ? content : { - type: "bi.absolute", - items: [{ - el: content, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.layout" - }, - left: 0, - right: 24, - top: 0, - bottom: 0 - }] - }; }, - _initData: function() { + _initData: function () { var o = this.options; this.tree = new BI.Tree(); this.nodes = BI.Tree.treeFormat(BI.deepClone(o.items)); this.tree.initTree(this.nodes); }, - _getSearchItems: function(keyword) { + _getSearchItems: function (keyword) { var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); - if(find.find.length > 0 || find.match.length > 0) { + if (find.find.length > 0 || find.match.length > 0) { items.push(node); return true; } @@ -151,7 +138,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { return this._fillTreeStructure4Search(items, "id"); }, - _createJson: function(node, open) { + _createJson: function (node, open) { return { id: node.id, pId: node.pId, @@ -159,10 +146,10 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { value: node.value, isParent: BI.isNotEmptyArray(node.children), open: open - } + }; }, - _getChildren: function(node) { + _getChildren: function (node) { var self = this; node.children = node.children || []; var nodes = []; @@ -179,7 +166,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { var result = []; var queue = []; BI.each(leaves, function (idx, node) { - queue.push({pId: node.pId}); + queue.push({ pId: node.pId }); result.push(node); result = result.concat(self._getChildren(node)); }); @@ -188,7 +175,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id"); if (pNode != null) { pNode.open = true; - queue.push({pId: pNode.pId}); + queue.push({ pId: pNode.pId }); result.push(pNode); } } @@ -259,4 +246,4 @@ BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP"; BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START"; BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; -BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger); \ No newline at end of file +BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger); diff --git a/src/widget/multilayersingletree/multilayersingletree.combo.js b/src/widget/multilayersingletree/multilayersingletree.combo.js index 779e645bf..2060eeaa6 100644 --- a/src/widget/multilayersingletree/multilayersingletree.combo.js +++ b/src/widget/multilayersingletree/multilayersingletree.combo.js @@ -25,17 +25,15 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { _init: function () { var o = this.options; - if (this._shouldWrapper()) { - o.height -= 2; - BI.isNumeric(o.width) && (o.width -= 2); - } + BI.isNumeric(o.width) && (o.width -= 2); + BI.isNumeric(o.height) && (o.height -= 2); BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments); }, render: function () { var self = this, o = this.options; - var combo = (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); + return (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); return this._shouldWrapper() ? combo : { type: "bi.absolute", @@ -79,7 +77,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { var self = this, o = this.options; return { type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + 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, @@ -125,7 +123,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { }; }, - _getSearchConfig: function() { + _getSearchConfig: function () { var self = this, o = this.options; return { el: { @@ -142,7 +140,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { items: o.items, itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, - height: o.height - (o.simple ? 1 : 2), + height: o.height, text: o.text, value: o.value, tipType: o.tipType, @@ -186,7 +184,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) ? false : self.triggerBtn.element.find(e.target).length === 0 + return !(o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0); }, listeners: [{ eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, @@ -199,7 +197,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW); } }] - } + }; }, _getSyncConfig: function () { @@ -208,13 +206,15 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : { el: { type: "bi.single_tree_trigger", - ref: function(_ref) { + ref: function (_ref) { self.textTrigger = _ref; }, text: o.text, height: o.height, items: o.items, - value: o.value + value: o.value, + tipType: o.tipType, + warningTitle: o.warningTitle, } }); }, @@ -237,6 +237,18 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { return this.combo.getValue(); }, + setStatus: function (status) { + if (BI.isKey(this.options.status)) { + this.element.removeClass("status-" + this.options.status); + } + this.element.addClass("status-" + status); + this.options.status = status; + }, + + setTipType: function (v) { + this.trigger ? this.trigger.setTipType(v) : this.textTrigger.setTipType(v); + }, + populate: function (items) { this.combo.populate(items); }, diff --git a/src/widget/multilayersingletree/multilayersingletree.trigger.js b/src/widget/multilayersingletree/multilayersingletree.trigger.js index 75a515129..8c58b0c8c 100644 --- a/src/widget/multilayersingletree/multilayersingletree.trigger.js +++ b/src/widget/multilayersingletree/multilayersingletree.trigger.js @@ -3,7 +3,7 @@ */ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { - props: function() { + props: function () { return { extraCls: "bi-multi-layer-single-tree-trigger", height: 24, @@ -16,11 +16,12 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { render: function () { var self = this, o = this.options; - if(o.itemsCreator === BI.emptyFn) { + if (o.itemsCreator === BI.emptyFn) { this._initData(); } - var content = { - type: "bi.htape", + + return { + type: "bi.horizontal_fill", items: [ { el: { @@ -86,7 +87,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }, onSearch: function (obj, callback) { var keyword = obj.keyword; - if(o.itemsCreator === BI.emptyFn) { + if (o.itemsCreator === BI.emptyFn) { callback(self._getSearchItems(keyword)); o.allowInsertValue && self.popup.setKeyword(keyword); } else { @@ -99,51 +100,37 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE); } }] - } + }, + width: "fill", }, { el: { - type: "bi.layout", - width: 24 + type: "bi.trigger_icon_button", + cls: "trigger-icon-button", + ref: function (_ref) { + self.triggerBtn = _ref; + }, + width: 24, }, width: 24 } ] }; - - return o.allowEdit ? content : { - type: "bi.absolute", - items: [{ - el: content, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.layout" - }, - left: 0, - right: 24, - top: 0, - bottom: 0 - }] - }; }, - _initData: function() { + _initData: function () { var o = this.options; this.tree = new BI.Tree(); this.nodes = BI.Tree.treeFormat(BI.deepClone(o.items)); this.tree.initTree(this.nodes); }, - _getSearchItems: function(keyword) { + _getSearchItems: function (keyword) { var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); - if(find.find.length > 0 || find.match.length > 0) { + if (find.find.length > 0 || find.match.length > 0) { items.push(node); return true; } @@ -151,7 +138,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { return this._fillTreeStructure4Search(items, "id"); }, - _createJson: function(node, open) { + _createJson: function (node, open) { return { id: node.id, pId: node.pId, @@ -159,10 +146,10 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { value: node.value, isParent: BI.isNotEmptyArray(node.children), open: open - } + }; }, - _getChildren: function(node) { + _getChildren: function (node) { var self = this; node.children = node.children || []; var nodes = []; @@ -179,7 +166,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { var result = []; var queue = []; BI.each(leaves, function (idx, node) { - queue.push({pId: node.pId}); + queue.push({ pId: node.pId }); result.push(node); result = result.concat(self._getChildren(node)); }); @@ -188,7 +175,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id"); if (pNode != null) { pNode.open = true; - queue.push({pId: pNode.pId}); + queue.push({ pId: pNode.pId }); result.push(pNode); } } @@ -260,4 +247,4 @@ BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP"; BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START"; BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; -BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger); \ No newline at end of file +BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger); diff --git a/src/widget/selecttree/nodes/node.first.plus.js b/src/widget/selecttree/nodes/node.first.plus.js index f8f23c2b5..378eac230 100644 --- a/src/widget/selecttree/nodes/node.first.plus.js +++ b/src/widget/selecttree/nodes/node.first.plus.js @@ -24,7 +24,9 @@ BI.SelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { var self = this, o = this.options; this.checkbox = BI.createWidget({ type: "bi.first_tree_node_checkbox", - stopPropagation: true + stopPropagation: true, + iconHeight: o.height, + iconWidth: o.height }); this.text = BI.createWidget({ type: "bi.label", diff --git a/src/widget/selecttree/nodes/node.last.plus.js b/src/widget/selecttree/nodes/node.last.plus.js index 2c4cca80c..f8e764e10 100644 --- a/src/widget/selecttree/nodes/node.last.plus.js +++ b/src/widget/selecttree/nodes/node.last.plus.js @@ -24,7 +24,9 @@ BI.SelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { var self = this, o = this.options; this.checkbox = BI.createWidget({ type: "bi.last_tree_node_checkbox", - stopPropagation: true + stopPropagation: true, + iconHeight: o.height, + iconWidth: o.height }); this.text = BI.createWidget({ type: "bi.label", diff --git a/src/widget/selecttree/nodes/node.mid.plus.js b/src/widget/selecttree/nodes/node.mid.plus.js index 289136242..ddafe5704 100644 --- a/src/widget/selecttree/nodes/node.mid.plus.js +++ b/src/widget/selecttree/nodes/node.mid.plus.js @@ -24,7 +24,9 @@ BI.SelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { var self = this, o = this.options; this.checkbox = BI.createWidget({ type: "bi.mid_tree_node_checkbox", - stopPropagation: true + stopPropagation: true, + iconHeight: o.height, + iconWidth: o.height }); this.text = BI.createWidget({ type: "bi.label", diff --git a/src/widget/selecttree/nodes/node.plus.js b/src/widget/selecttree/nodes/node.plus.js index e0f8e8632..d5cd39c66 100644 --- a/src/widget/selecttree/nodes/node.plus.js +++ b/src/widget/selecttree/nodes/node.plus.js @@ -24,7 +24,9 @@ BI.SelectTreePlusGroupNode = BI.inherit(BI.NodeButton, { var self = this, o = this.options; this.checkbox = BI.createWidget({ type: "bi.tree_node_checkbox", - stopPropagation: true + stopPropagation: true, + iconHeight: o.height, + iconWidth: o.iconWrapperWidth || o.height }); this.text = BI.createWidget({ type: "bi.label", diff --git a/src/widget/selecttree/selecttree.combo.js b/src/widget/selecttree/selecttree.combo.js index 98c542686..c6aca0c62 100644 --- a/src/widget/selecttree/selecttree.combo.js +++ b/src/widget/selecttree/selecttree.combo.js @@ -11,6 +11,7 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, { text: "", items: [], value: "", + allowClear: false, }); }, @@ -25,7 +26,13 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, { text: o.text, height: o.height, items: o.items, - value: o.value + value: o.value, + allowClear: o.allowClear, + warningTitle: o.warningTitle, + }); + + this.trigger.on(BI.SingleTreeTrigger.EVENT_CLEAR, function () { + self._clear(); }); this.popup = BI.createWidget({ @@ -53,12 +60,43 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, { self.setValue(self.popup.getValue()); self.combo.hideView(); }); + + if (BI.isKey(o.value)) { + this._checkError(o.value); + } + }, + + _checkError: function (v) { + if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { + this.trigger.options.tipType = "success"; + this.trigger.element.removeClass("error"); + this.element.removeClass("error"); + } else { + v = BI.isArray(v) ? v : [v]; + var result = BI.find(this.options.items, function (idx, item) { + return BI.contains(v, item.value); + }); + if (BI.isNull(result)) { + this.trigger.setTipType("warning"); + this.element.removeClass("error").addClass("error"); + this.trigger.element.removeClass("error").addClass("error"); + } else { + this.trigger.setTipType("success"); + this.trigger.element.removeClass("error"); + this.element.removeClass("error"); + } + } + }, + + _clear: function () { + this.setValue([]); }, setValue: function (v) { v = BI.isArray(v) ? v : [v]; this.trigger.setValue(v); this.popup.setValue(v); + this._checkError(v); }, getValue: function () { @@ -71,4 +109,4 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, { }); -BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo); \ No newline at end of file +BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo); diff --git a/src/widget/singletree/singletree.combo.js b/src/widget/singletree/singletree.combo.js index ce6d255d4..32d39d338 100644 --- a/src/widget/singletree/singletree.combo.js +++ b/src/widget/singletree/singletree.combo.js @@ -12,6 +12,7 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { text: "", items: [], value: "", + allowClear: false, }); }, @@ -26,9 +27,15 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { text: o.text, height: o.height, items: o.items, - value: o.value + value: o.value, + allowClear: o.allowClear, + warningTitle: o.warningTitle, }, o.trigger)); + this.trigger.on(BI.SingleTreeTrigger.EVENT_CLEAR, function () { + self._clear(); + }); + this.popup = BI.createWidget({ type: "bi.single_level_tree", items: o.items, @@ -58,6 +65,36 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { self.combo.hideView(); self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE); }); + + if (BI.isKey(o.value)) { + this._checkError(o.value); + } + }, + + _checkError: function (v) { + if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { + this.trigger.options.tipType = "success"; + this.trigger.element.removeClass("error"); + this.element.removeClass("error"); + } else { + v = BI.isArray(v) ? v : [v]; + var result = BI.find(this.options.items, function (idx, item) { + return BI.contains(v, item.value); + }); + if (BI.isNull(result)) { + this.trigger.setTipType("warning"); + this.element.removeClass("error").addClass("error"); + this.trigger.element.removeClass("error").addClass("error"); + } else { + this.trigger.setTipType("success"); + this.trigger.element.removeClass("error"); + this.element.removeClass("error"); + } + } + }, + + _clear: function () { + this.setValue([]); }, populate: function (items) { @@ -68,6 +105,7 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { v = BI.isArray(v) ? v : [v]; this.trigger.setValue(v); this.popup.setValue(v); + this._checkError(v); }, getValue: function () { @@ -77,4 +115,4 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { BI.SingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo); \ No newline at end of file +BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo); diff --git a/src/widget/singletree/singletree.trigger.js b/src/widget/singletree/singletree.trigger.js index 91183c033..f4a4ca7df 100644 --- a/src/widget/singletree/singletree.trigger.js +++ b/src/widget/singletree/singletree.trigger.js @@ -11,7 +11,8 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { height: 24, text: "", items: [], - value: "" + value: "", + allowClear: false, }); }, @@ -26,7 +27,18 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { text: o.text, items: o.items, height: o.height, - value: o.value + warningTitle: o.warningTitle, + tipType: o.tipType, + value: o.value, + allowClear: o.allowClear, + listeners: [ + { + eventName: BI.SelectTextTrigger.EVENT_CLEAR, + action: function () { + self.fireEvent(BI.SingleTreeTrigger.EVENT_CLEAR); + } + } + ] }); }, @@ -47,11 +59,16 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { this._checkTitle(); }, + setTipType: function (v) { + this.options.tipType = v; + this.trigger.setTipType(v); + }, + getValue: function () { return this.options.value || []; }, - getTextor: function() { + getTextor: function () { return this.trigger.getTextor(); }, @@ -61,4 +78,5 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { }); +BI.SingleTreeTrigger.EVENT_CLEAR = "EVENT_CLEAR"; BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger); diff --git a/src/widget/year/combo.year.js b/src/widget/year/combo.year.js index 62a498d54..1774ca384 100644 --- a/src/widget/year/combo.year.js +++ b/src/widget/year/combo.year.js @@ -24,7 +24,8 @@ BI.DynamicYearCombo = 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.DynamicYearTrigger.EVENT_KEY_DOWN, function () { if (self.combo.isViewVisible()) { @@ -211,8 +212,11 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, { isStateValid: function () { return this.trigger.isValid(); - } + }, + setWaterMark: function (v) { + this.trigger.setWaterMark(v); + } }); BI.DynamicYearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; diff --git a/src/widget/year/trigger.year.js b/src/widget/year/trigger.year.js index 91b80a431..fe8976b2f 100644 --- a/src/widget/year/trigger.year.js +++ b/src/widget/year/trigger.year.js @@ -10,7 +10,8 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { extraCls: "bi-year-trigger", min: "1900-01-01", // 最小日期 max: "2099-12-31", // 最大日期 - height: 24 + height: 24, + watermark: BI.i18nText("BI-Basic_Unrestricted") }); }, @@ -35,7 +36,7 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { }, hgap: c.hgap, vgap: c.vgap, - watermark: BI.i18nText("BI-Basic_Unrestricted"), + watermark: o.watermark, allowBlank: true, errorText: function (v) { if (BI.isPositiveInteger(v)) { @@ -188,6 +189,10 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { getKey: function () { return this.editor.getValue() | 0; + }, + + setWaterMark: function (v) { + this.editor.setWaterMark(v); } }); BI.DynamicYearTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; diff --git a/typescript/case/colorchooser/colorchooser.simple.ts b/typescript/case/colorchooser/colorchooser.simple.ts index 4ecb0d7c3..274a1f140 100644 --- a/typescript/case/colorchooser/colorchooser.simple.ts +++ b/typescript/case/colorchooser/colorchooser.simple.ts @@ -3,7 +3,8 @@ import { Widget } from '../../core/widget'; export declare class SimpleColorChooser extends Widget { static xtype: string; static EVENT_CHANGE: string; - + static EVENT_AFTER_POPUPVIEW: string; + isViewVisible(): boolean; hideView(): void; diff --git a/typescript/case/colorchooser/colorchooser.ts b/typescript/case/colorchooser/colorchooser.ts new file mode 100644 index 000000000..b58869e37 --- /dev/null +++ b/typescript/case/colorchooser/colorchooser.ts @@ -0,0 +1,13 @@ +import { Widget } from '../../core/widget'; + +export declare class ColorChooser extends Widget { + static xtype: string; + static EVENT_CHANGE: string; + static EVENT_AFTER_POPUPVIEW: string; + + isViewVisible(): boolean; + + hideView(): void; + + showView(): void; +} diff --git a/typescript/index.ts b/typescript/index.ts index 448266b96..fa9a08d19 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -82,6 +82,7 @@ import { MultiSelectCombo } from "./widget/multiselect/multiselect.combo"; import { SearchEditor } from "./widget/editor/editor.search"; import { MultiLayerSingleLevelTree } from "./widget/multilayersingletree/multilayersingletree.leveltree"; import { SimpleColorChooser } from "./case/colorchooser/colorchooser.simple"; +import { ColorChooser } from './case/colorchooser/colorchooser'; import { A } from "./base/a/a"; import { Html } from "./base/single/html/html"; import { Switcher } from "./base/combination/switcher"; @@ -307,6 +308,7 @@ export interface BI extends _func, _i18n, _base, _inject, _var, _web, _utils { SearchEditor: typeof SearchEditor; MultiLayerSingleLevelTree: typeof MultiLayerSingleLevelTree; SimpleColorChooser: typeof SimpleColorChooser; + ColorChooser: typeof ColorChooser; AbstractAllValueChooser: typeof AbstractAllValueChooser; AllValueChooserCombo: typeof AllValueChooserCombo; TextAreaEditor: typeof TextAreaEditor; @@ -496,6 +498,7 @@ export { Text, Pane, MultiLayerSingleLevelTree, + ColorChooser, SimpleColorChooser, AbstractAllValueChooser, AllValueChooserCombo, diff --git a/typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts b/typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts index 1fc9e1519..6146190b8 100644 --- a/typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts +++ b/typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts @@ -21,4 +21,6 @@ export declare class MultiLayerSelectTreeCombo extends Widget { blur(): void; showView(): void; + + setStatus(status: "error" | "warning"): void; } diff --git a/typescript/widget/multilayersingletree/multilayersingletree.combo.ts b/typescript/widget/multilayersingletree/multilayersingletree.combo.ts index fcecc32c4..ebbf5c607 100644 --- a/typescript/widget/multilayersingletree/multilayersingletree.combo.ts +++ b/typescript/widget/multilayersingletree/multilayersingletree.combo.ts @@ -21,4 +21,6 @@ export declare class MultiLayerSingleTreeCombo extends Widget { blur(): void; showView(): void; + + setStatus(status: "error" | "warning"): void; } diff --git a/ui/less/app.less b/ui/less/app.less index d086387ac..27e4631e7 100644 --- a/ui/less/app.less +++ b/ui/less/app.less @@ -1,2 +1,2 @@ -@import "../../src/less/resource/app"; -@import "var"; +@import "../../src/less/resource/app.less"; +@import "var.less"; diff --git a/ui/less/background.less b/ui/less/background.less index 996147127..a6cbde36b 100644 --- a/ui/less/background.less +++ b/ui/less/background.less @@ -1,2 +1,2 @@ -@import "../../src/less/resource/background"; -@import "var"; +@import "../../src/less/resource/background.less"; +@import "var.less"; diff --git a/ui/less/font.less b/ui/less/font.less index c236f82ed..d7399c46e 100644 --- a/ui/less/font.less +++ b/ui/less/font.less @@ -1,2 +1,2 @@ -@import "../../src/less/resource/font"; -@import "var"; +@import "../../src/less/resource/font.less"; +@import "var.less"; diff --git a/ui/less/icon.less b/ui/less/icon.less index 43e3123c5..8aa44a2ae 100644 --- a/ui/less/icon.less +++ b/ui/less/icon.less @@ -1,5 +1,5 @@ -@import "../../src/less/resource/icon"; -@import "var"; +@import "../../src/less/resource/icon.less"; +@import "var.less";