diff --git a/package.json b/package.json index fbbb2e06a..49f9670d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20211116211231", + "version": "2.0.20211119174324", "description": "fineui", "main": "dist/fineui.min.js", "types": "dist/lib/index.d.ts", diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index 622ede324..9f392411a 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -30,7 +30,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { }); this.behaviors = behaviors; this.populate(o.items); - if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){ + if (BI.isKey(o.value) || BI.isNotEmptyArray(o.value)) { this.setValue(o.value); } }, @@ -77,11 +77,12 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { _packageBtns: function (btns) { var o = this.options; - for (var i = o.layouts.length - 1; i > 0; i--) { + var layouts = BI.isArray(o.layouts) ? o.layouts : [o.layouts]; + for (var i = layouts.length - 1; i > 0; i--) { btns = BI.map(btns, function (k, it) { - return BI.extend({}, o.layouts[i], { + return BI.extend({}, layouts[i], { items: [ - BI.extend({}, o.layouts[i].el, { + BI.extend({}, layouts[i].el, { el: it }) ] @@ -108,7 +109,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { }, _packageLayout: function (items) { - var o = this.options, layout = BI.deepClone(o.layouts[0]); + var o = this.options, layout = BI.deepClone(BI.isArray(o.layouts) ? o.layouts[0] : o.layouts); var lay = BI.formatEL(layout).el; while (lay && lay.items && !BI.isEmpty(lay.items)) { @@ -121,7 +122,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { // 如果是一个简单的layout _isSimpleLayout: function () { var o = this.options; - return o.layouts.length === 1 && !BI.isArray(o.items[0]); + return BI.isArray(o.layouts) ? (o.layouts.length === 1 && !BI.isArray(o.items[0])) : true; }, doBehavior: function () { diff --git a/src/base/layer/layer.drawer.js b/src/base/layer/layer.drawer.js index 6b93a4324..e62c272dc 100644 --- a/src/base/layer/layer.drawer.js +++ b/src/base/layer/layer.drawer.js @@ -4,8 +4,14 @@ * @extends BI.Widget */ BI.Drawer = BI.inherit(BI.Widget, { + SIZE: { + SMALL: "small", + NORMAL: "normal", + BIG: "big" + }, props: { baseCls: "bi-drawer bi-card", + size: "normal", placement: "right", // top/bottom/left/right header: null, headerHeight: 40, @@ -74,10 +80,37 @@ BI.Drawer = BI.inherit(BI.Widget, { bgap: o.bodyBgap }]; - return { + return BI.extend({ type: "bi.vtape", items: items - }; + }, this._getSuitableSize()); + }, + + _getSuitableSize: function () { + var o = this.options; + var size = 0; + switch (o.size) { + case "big": + size = 736; + break; + case "small": + size = 200; + break; + case "normal": + default: + size = 378; + break; + } + if (o.placement === "top" || o.placement === "bottom") { + return { + height: o.height || size + }; + } + if (o.placement === "left" || o.placement === "right") { + return { + width: o.width || size + }; + } }, mounted: function () { @@ -117,25 +150,26 @@ BI.Drawer = BI.inherit(BI.Widget, { show: function (callback) { var self = this, o = this.options; requestAnimationFrame(function () { + var size = self._getSuitableSize(); switch (o.placement) { case "right": self.element.css({ - transform: "translateX(-" + self.getWidth() + "px)" + transform: "translateX(-" + size.width + "px)" }); break; case "left": self.element.css({ - transform: "translateX(" + self.getWidth() + "px)" + transform: "translateX(" + size.width + "px)" }); break; case "top": self.element.css({ - transform: "translateY(" + self.getHeight() + "px)" + transform: "translateY(" + size.height + "px)" }); break; case "bottom": self.element.css({ - transform: "translateY(-" + self.getHeight() + "px)" + transform: "translateY(-" + size.height + "px)" }); break; } @@ -160,7 +194,7 @@ BI.Drawer = BI.inherit(BI.Widget, { }); break; } - setTimeout(callback, 300) + setTimeout(callback, 300); }); }, diff --git a/src/core/6.inject.js b/src/core/6.inject.js index ed4d1165b..c9f77055b 100644 --- a/src/core/6.inject.js +++ b/src/core/6.inject.js @@ -39,6 +39,9 @@ _global.console && console.error("constant: [" + xtype + "]已经注册过了"); } constantInjection[xtype] = cls; + return function () { + return BI.Constants.getConstant(xtype); + } }; var modelInjection = {}; @@ -47,6 +50,9 @@ _global.console && console.error("model: [" + xtype + "] 已经注册过了"); } modelInjection[xtype] = cls; + return function (xtype, config) { + return BI.Models.getModel(xtype, config); + }; }; var storeInjection = {}; @@ -55,6 +61,9 @@ _global.console && console.error("store: [" + xtype + "] 已经注册过了"); } storeInjection[xtype] = cls; + return function (xtype, config) { + return BI.Stores.getStore(xtype, config); + } }; var serviceInjection = {}; @@ -63,6 +72,9 @@ _global.console && console.error("service: [" + xtype + "] 已经注册过了"); } serviceInjection[xtype] = cls; + return function (xtype, config) { + return BI.Services.getService(xtype, config); + } }; var providerInjection = {}; @@ -71,6 +83,9 @@ _global.console && console.error("provider: [" + xtype + "] 已经注册过了"); } providerInjection[xtype] = cls; + return function (xtype, config) { + return BI.Providers.getProvider(xtype, config); + } }; var configFunctions = {}; @@ -294,7 +309,7 @@ _global.console && console.error("constant: [" + type + "] 未定义"); } runConfigFunction(type); - return constantInjection[type]; + return BI.isFunction(constantInjection[type]) ? constantInjection[type]() : constantInjection[type]; } }; diff --git a/src/core/controller/controller.drawer.js b/src/core/controller/controller.drawer.js index 1b7bae664..68fdadbc8 100644 --- a/src/core/controller/controller.drawer.js +++ b/src/core/controller/controller.drawer.js @@ -18,7 +18,6 @@ BI.DrawerController = BI.inherit(BI.Controller, { this.floatLayer = {}; this.floatContainer = {}; this.floatOpened = {}; - this.zindex = BI.zIndex_popover; this.zindexMap = {}; }, @@ -41,17 +40,18 @@ BI.DrawerController = BI.inherit(BI.Controller, { if (!this.floatOpened[name]) { this.floatOpened[name] = true; var container = this.floatContainer[name]; - container.element.css("zIndex", this.zindex++); + var zIndex = BI.Popovers._getZIndex(); + container.element.css("zIndex", zIndex); this.modal && container.element.__hasZIndexMask__(this.zindexMap[name]) && container.element.__releaseZIndexMask__(this.zindexMap[name]); - this.zindexMap[name] = this.zindex; + this.zindexMap[name] = zIndex; if (this.modal) { - var mask = container.element.__buildZIndexMask__(this.zindex++); + var mask = container.element.__buildZIndexMask__(BI.Popovers._getZIndex()); mask.click(function () { mask.destroy(); self.get(name).close(); }); } - this.get(name).setZindex(this.zindex++); + this.get(name).setZindex(BI.Popovers._getZIndex()); this.floatContainer[name].visible(); var popover = this.get(name); popover.show && popover.show(); diff --git a/src/core/controller/controller.popover.js b/src/core/controller/controller.popover.js index fbe7e29d9..83f1e8d5c 100644 --- a/src/core/controller/controller.popover.js +++ b/src/core/controller/controller.popover.js @@ -48,7 +48,8 @@ BI.PopoverController = BI.inherit(BI.Controller, { this.floatContainer[name].visible(); var popover = this.get(name); popover.show && popover.show(); - var W = BI.Widget._renderEngine.createElement(this.options.render).width(), H = BI.Widget._renderEngine.createElement(this.options.render).height(); + var W = BI.Widget._renderEngine.createElement(this.options.render).width(), + H = BI.Widget._renderEngine.createElement(this.options.render).height(); var w = popover.element.width(), h = popover.element.height(); var left = (W - w) / 2, top = (H - h) / 2; if (left < 0) { @@ -163,5 +164,9 @@ BI.PopoverController = BI.inherit(BI.Controller, { this.floatOpened = {}; this.zindexMap = {}; return this; + }, + + _getZIndex: function () { + return this.zindex++; } }); diff --git a/src/less/base/view/drawer.less b/src/less/base/view/drawer.less index f364457e3..80a8ca1be 100644 --- a/src/less/base/view/drawer.less +++ b/src/less/base/view/drawer.less @@ -1,6 +1,6 @@ @import "../../index"; .bi-drawer { - .box-shadow(-6px 0 16px -8px #00000014, -9px 0 28px #0000000d, -12px 0 48px 16px #00000008); - .transition(transform .3s cubic-bezier(.23, 1, .32, 1), box-shadow .3s cubic-bezier(.23, 1, .32, 1)); + .box-shadows(-6px 0 16px -8px #00000014, -9px 0 28px #0000000d, -12px 0 48px 16px #00000008); + .transitions(transform .3s cubic-bezier(.23, 1, .32, 1), box-shadow .3s cubic-bezier(.23, 1, .32, 1)); } diff --git a/src/less/visual.less b/src/less/visual.less index cebb0eb61..9a1bda2b7 100644 --- a/src/less/visual.less +++ b/src/less/visual.less @@ -53,6 +53,13 @@ transition: @transition; } +.transitions(@transition1, @transition2) { + -webkit-transition: @transition1, @transition2; + -moz-transition: @transition1, @transition2; + -o-transition: @transition1, @transition2; + transition: @transition1, @transition2; +} + .rotate(@rotate) { -webkit-transform: rotate(@rotate); -moz-transform: rotate(@rotate); diff --git a/typescript/base/combination/combo.ts b/typescript/base/combination/combo.ts index ee80cfeea..38191df7a 100644 --- a/typescript/base/combination/combo.ts +++ b/typescript/base/combination/combo.ts @@ -22,6 +22,7 @@ export declare class Combo extends Widget { container?: any; // popupview放置的容器,默认为this.element isDefaultInit?: boolean; destroyWhenHide?: boolean; + hideWhenBlur?: boolean; hideWhenAnotherComboOpen?: boolean; isNeedAdjustHeight?: boolean; // 是否需要高度调整 isNeedAdjustWidth?: boolean; diff --git a/typescript/core/inject.ts b/typescript/core/inject.ts index 3852fe442..5754277c0 100644 --- a/typescript/core/inject.ts +++ b/typescript/core/inject.ts @@ -1,9 +1,9 @@ -type _module = (xtype: string, cls: any) => void; -type _constant = (xtype: string, cls: any) => void; -type _model = (xtype: string, cls: any) => void; -type _store = (xtype: string, cls: any) => void; -type _service = (xtype: string, cls: any) => void; -type _provider = (xtype: string, cls: any) => void; +type _module = (xtype: string, cls: any) => void | Function; +type _constant = (xtype: string, cls: any) => void | Function; +type _model = (xtype: string, cls: any) => void | Function; +type _store = (xtype: string, cls: any) => void | Function; +type _service = (xtype: string, cls: any) => void | Function; +type _provider = (xtype: string, cls: any) => void | Function; interface _modules { getModule: (type: string) => any; diff --git a/typescript/core/wrapper/layout/fill/fill.horizontal.ts b/typescript/core/wrapper/layout/fill/fill.horizontal.ts new file mode 100644 index 000000000..378f402ad --- /dev/null +++ b/typescript/core/wrapper/layout/fill/fill.horizontal.ts @@ -0,0 +1,5 @@ +import { Layout } from "../../layout"; + +export declare class HorizontalFillLayout extends Layout { + static xtype: string; +} diff --git a/typescript/core/wrapper/layout/fill/fill.vertical.ts b/typescript/core/wrapper/layout/fill/fill.vertical.ts new file mode 100644 index 000000000..809b34c36 --- /dev/null +++ b/typescript/core/wrapper/layout/fill/fill.vertical.ts @@ -0,0 +1,5 @@ +import { Layout } from "../../layout"; + +export declare class VerticalFillLayout extends Layout { + static xtype: string; +} diff --git a/typescript/index.ts b/typescript/index.ts index 6e6131a7d..27dc12099 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -44,6 +44,8 @@ import { _inject } from "./core/inject"; import { Layout } from "./core/wrapper/layout"; import { AbsoluteLayout } from "./core/wrapper/layout/layout.absolute"; import { HTapeLayout, VTapeLayout } from "./core/wrapper/layout/layout.tape"; +import {HorizontalFillLayout} from "./core/wrapper/layout/fill/fill.horizontal"; +import {VerticalFillLayout} from "./core/wrapper/layout/fill/fill.vertical"; import { VerticalLayout } from "./core/wrapper/layout/layout.vertical"; import { DefaultLayout } from "./core/wrapper/layout/layout.default"; import { DownListCombo } from "./widget/downlist/combo.downlist"; @@ -243,6 +245,8 @@ export interface BI extends _func, _i18n, _base, _inject, _var, _web, _utils { DownListCombo: typeof DownListCombo; Iframe: typeof Iframe; AbsoluteLayout: typeof AbsoluteLayout; + HorizontalFillLayout: typeof HorizontalFillLayout; + VerticalFillLayout: typeof VerticalFillLayout; VerticalLayout: typeof VerticalLayout; DefaultLayout: typeof DefaultLayout; Input: typeof Input; @@ -389,6 +393,8 @@ export { HorizontalAdaptLayout, FloatLeftLayout, FloatRightLayout, + HorizontalFillLayout, + VerticalFillLayout, VerticalLayout, AbsoluteLayout, DefaultLayout,