@bpui/popover
Advanced tools
Comparing version 0.0.7 to 0.0.8
/*! | ||
* bpui popover v0.0.7 | ||
* bpui popover v0.0.8 | ||
* Copyright (c) 2020 Copyright bp All Rights Reserved. | ||
* Released under the MIT License. | ||
*/'use strict';function _interopDefault(a){return a&&"object"==typeof a&&"default"in a?a["default"]:a}var bpLibs=_interopDefault(require("@bpui/libs")),bpDialog=_interopDefault(require("@bpui/dialog")),script={components:{widget:bpDialog.bpWidget},props:{visible:Boolean,mask:{default:!1,type:Boolean},maskClose:{default:!0,type:Boolean},pageClass:String|Array,pageStyle:String|Array|Object,direction:{default:"auto",type:String},trigger:{type:String},bind:{}},data(){return{visibleReal:!1,directionData:"auto",offsetTop:0,offsetLeft:0,offsetArrowLeft:null,offsetArrowTop:null,offsetArrowBottom:null,offsetArrowRight:null}},watch:{visible(a,b){this.visibleReal!=a&&(this.visibleReal=a,a!=b&&a&&this._show(this.direction))},visibleReal(a){this.$emit("update:visible",a)},bind(a,b){this._removeEvent(b),this._bindEvent(a)}},beforeMount(){this.visibleReal=this.visible},beforeDestroy(){$("body").off("click",this._hide)},mounted(){$("body").off("click",this._hide).on("click",this._hide),this.$nextTick(()=>{this.$parent.$forceUpdate()})},methods:{show:function(){return this.$refs.widget.show()},hide:function(){return this.$refs.widget.hide()},_removeEvent(a){if(a){let b;b=bpLibs.dom.isVueObject(a)?a.$el:a,$(b).off("mouseover",this._onTrigger),$(b).off("mouseleave",this._onTriggerHide),$(b).off("click",this._onTrigger)}},_bindEvent(a){if(this._removeEvent(a),a){let b;if(b=bpLibs.dom.isVueObject(a)?a.$el:a,"hover"==this.trigger&&(bpLibs.device.browserIsMobile()?$(b).on("click",this._onTrigger):($(b).on("mouseover",this._onTrigger),$(b).on("mouseleave",this._onTriggerHide))),"click"==this.trigger){let a=bpLibs.device.browserIsMobile()?"click":"click";$(b).off(a,this._onTrigger).on(a,this._onTrigger)}}},_onTrigger(){this.visibleReal=!0,this._show(this.direction)},_onTriggerHide(){this.visibleReal=!1},_show:function(a){let b=this.bind;if(!this.bind)return;let c=bpLibs.dom.isVueObject(b)?b.$el:b;let d=bpLibs.dom.getElementOffset(c),e={};e.height=c.clientHeight,e.width=c.clientWidth;let f=bpLibs.dom.getViewPort(),g=bpLibs.dom.getDocumentOffset();this.offsetTop=d.top+g.top,"top"==a?(this.directionData="top",this.offsetTop-=e.height,this.offsetTop-=8):"bottom"==a?(this.directionData="bottom",this.offsetTop+=e.height):"left"==a?(this.directionData="left",this.offsetLeft=d.left+e.width):"right"==a?(this.directionData="right",this.offsetLeft=d.left+e.width):d.top+e.height/2>f.height/2?(this.directionData="top",this.offsetTop-=e.height,this.offsetTop-=8):(this.directionData="bottom",this.offsetTop+=e.height),this.offsetTop+="px";let h="left"==a||"right"==a?parseInt(d.top+e.height/2):parseInt(d.left+e.width/2);const i=10;let j=this.$refs.main;bpLibs.dom.probeDom(200,()=>0<j.clientWidth,()=>{if("left"==a||"right"==a){let b=parseInt(h-j.clientHeight/2);b<i&&(b=i),b+j.clientHeight>f.height-i&&(b=f.height-i-j.clientHeight),this.offsetTop=b+g.top+"px",this.offsetLeft="right"==a?d.left+e.width-6:d.left-j.clientWidth-6,this.offsetLeft+=g.left,this.offsetLeft+="px",this.offsetArrowLeft=null,this.offsetArrowBottom=null,this.offsetArrowTop=h-b-6,10>this.offsetArrowTop?this.offsetArrowTop=10:this.offsetArrowTop>j.clientHeight-22&&(this.offsetArrowTop=j.clientHeight-22),this.offsetArrowTop+="px",this.offsetArrowRight=null}else{let a=parseInt(h-j.clientWidth/2);a<i&&(a=i),a+j.clientWidth>f.width-i&&(a=f.width-i-j.clientWidth),this.offsetLeft=a+"px",this.offsetArrowLeft=h-a-6,10>this.offsetArrowLeft?this.offsetArrowLeft=10:this.offsetArrowLeft>j.clientWidth-22&&(this.offsetArrowLeft=j.clientWidth-22),this.offsetArrowLeft+="px",this.offsetArrowBottom=null,this.offsetArrowTop=null,this.offsetArrowRight=null}})},_hide(){this.hide().then(()=>{})}}};function normalizeComponent(a,b,c,d,e,f,g,h,i,j){"boolean"!=typeof g&&(i=h,h=g,g=!1);const k="function"==typeof c?c.options:c;a&&a.render&&(k.render=a.render,k.staticRenderFns=a.staticRenderFns,k._compiled=!0,e&&(k.functional=!0)),d&&(k._scopeId=d);let l;if(f?(l=function(a){a=a||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,a||"undefined"==typeof __VUE_SSR_CONTEXT__||(a=__VUE_SSR_CONTEXT__),b&&b.call(this,i(a)),a&&a._registeredComponents&&a._registeredComponents.add(f)},k._ssrRegister=l):b&&(l=g?function(a){b.call(this,j(a,this.$root.$options.shadowRoot))}:function(a){b.call(this,h(a))}),l)if(k.functional){const a=k.render;k.render=function(b,c){return l.call(c),a(b,c)}}else{const a=k.beforeCreate;k.beforeCreate=a?[].concat(a,l):[l]}return c}const __vue_script__=script;var __vue_render__=function(){var a=this,b=a.$createElement,c=a._self._c||b;return c("widget",{ref:"widget",staticClass:"bp-popover",attrs:{visible:a.visibleReal,maskClose:a.maskClose,mask:a.mask,pageClass:a.pageClass,pageStyle:a.pageStyle,preventEvent:!1},on:{"update:visible":function(b){a.visibleReal=b}}},[c("div",{ref:"main",staticClass:"bp-popover__main",style:{left:a.offsetLeft,top:a.offsetTop},attrs:{direction:a.directionData}},[a._t("default"),a._v(" "),c("div",{staticClass:"bp-popover__arrow",style:{left:a.offsetArrowLeft,top:a.offsetArrowTop,right:a.offsetArrowRight,bottom:a.offsetArrowBottom}})],2)])},__vue_staticRenderFns__=[];__vue_render__._withStripped=!0;const __vue_inject_styles__=void 0,__vue_scope_id__=void 0,__vue_module_identifier__=void 0,__vue_is_functional_template__=!1,__vue_component__=normalizeComponent({render:__vue_render__,staticRenderFns:__vue_staticRenderFns__},void 0,__vue_script__,__vue_scope_id__,__vue_is_functional_template__,__vue_module_identifier__,!1,void 0,void 0,void 0);var index={bpPopover:__vue_component__};module.exports=index; |
/*! | ||
* bpui popover v0.0.7 | ||
* bpui popover v0.0.8 | ||
* Copyright (c) 2020 Copyright bp All Rights Reserved. | ||
* Released under the MIT License. | ||
*/import bpLibs from"@bpui/libs";import bpDialog from"@bpui/dialog";var script={components:{widget:bpDialog.bpWidget},props:{visible:Boolean,mask:{default:!1,type:Boolean},maskClose:{default:!0,type:Boolean},pageClass:String|Array,pageStyle:String|Array|Object,direction:{default:"auto",type:String},trigger:{type:String},bind:{}},data(){return{visibleReal:!1,directionData:"auto",offsetTop:0,offsetLeft:0,offsetArrowLeft:null,offsetArrowTop:null,offsetArrowBottom:null,offsetArrowRight:null}},watch:{visible(a,b){this.visibleReal!=a&&(this.visibleReal=a,a!=b&&a&&this._show(this.direction))},visibleReal(a){this.$emit("update:visible",a)},bind(a,b){this._removeEvent(b),this._bindEvent(a)}},beforeMount(){this.visibleReal=this.visible},beforeDestroy(){$("body").off("click",this._hide)},mounted(){$("body").off("click",this._hide).on("click",this._hide),this.$nextTick(()=>{this.$parent.$forceUpdate()})},methods:{show:function(){return this.$refs.widget.show()},hide:function(){return this.$refs.widget.hide()},_removeEvent(a){if(a){let b;b=bpLibs.dom.isVueObject(a)?a.$el:a,$(b).off("mouseover",this._onTrigger),$(b).off("mouseleave",this._onTriggerHide),$(b).off("click",this._onTrigger)}},_bindEvent(a){if(this._removeEvent(a),a){let b;if(b=bpLibs.dom.isVueObject(a)?a.$el:a,"hover"==this.trigger&&(bpLibs.device.browserIsMobile()?$(b).on("click",this._onTrigger):($(b).on("mouseover",this._onTrigger),$(b).on("mouseleave",this._onTriggerHide))),"click"==this.trigger){let a=bpLibs.device.browserIsMobile()?"click":"click";$(b).off(a,this._onTrigger).on(a,this._onTrigger)}}},_onTrigger(){this.visibleReal=!0,this._show(this.direction)},_onTriggerHide(){this.visibleReal=!1},_show:function(a){let b=this.bind;if(!this.bind)return;let c=bpLibs.dom.isVueObject(b)?b.$el:b;let d=bpLibs.dom.getElementOffset(c),e={};e.height=c.clientHeight,e.width=c.clientWidth;let f=bpLibs.dom.getViewPort(),g=bpLibs.dom.getDocumentOffset();this.offsetTop=d.top+g.top,"top"==a?(this.directionData="top",this.offsetTop-=e.height,this.offsetTop-=8):"bottom"==a?(this.directionData="bottom",this.offsetTop+=e.height):"left"==a?(this.directionData="left",this.offsetLeft=d.left+e.width):"right"==a?(this.directionData="right",this.offsetLeft=d.left+e.width):d.top+e.height/2>f.height/2?(this.directionData="top",this.offsetTop-=e.height,this.offsetTop-=8):(this.directionData="bottom",this.offsetTop+=e.height),this.offsetTop+="px";let h="left"==a||"right"==a?parseInt(d.top+e.height/2):parseInt(d.left+e.width/2);const i=10;let j=this.$refs.main;bpLibs.dom.probeDom(200,()=>0<j.clientWidth,()=>{if("left"==a||"right"==a){let b=parseInt(h-j.clientHeight/2);b<i&&(b=i),b+j.clientHeight>f.height-i&&(b=f.height-i-j.clientHeight),this.offsetTop=b+g.top+"px",this.offsetLeft="right"==a?d.left+e.width-6:d.left-j.clientWidth-6,this.offsetLeft+=g.left,this.offsetLeft+="px",this.offsetArrowLeft=null,this.offsetArrowBottom=null,this.offsetArrowTop=h-b-6,10>this.offsetArrowTop?this.offsetArrowTop=10:this.offsetArrowTop>j.clientHeight-22&&(this.offsetArrowTop=j.clientHeight-22),this.offsetArrowTop+="px",this.offsetArrowRight=null}else{let a=parseInt(h-j.clientWidth/2);a<i&&(a=i),a+j.clientWidth>f.width-i&&(a=f.width-i-j.clientWidth),this.offsetLeft=a+"px",this.offsetArrowLeft=h-a-6,10>this.offsetArrowLeft?this.offsetArrowLeft=10:this.offsetArrowLeft>j.clientWidth-22&&(this.offsetArrowLeft=j.clientWidth-22),this.offsetArrowLeft+="px",this.offsetArrowBottom=null,this.offsetArrowTop=null,this.offsetArrowRight=null}})},_hide(){this.hide().then(()=>{})}}};function normalizeComponent(a,b,c,d,e,f,g,h,i,j){"boolean"!=typeof g&&(i=h,h=g,g=!1);const k="function"==typeof c?c.options:c;a&&a.render&&(k.render=a.render,k.staticRenderFns=a.staticRenderFns,k._compiled=!0,e&&(k.functional=!0)),d&&(k._scopeId=d);let l;if(f?(l=function(a){a=a||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,a||"undefined"==typeof __VUE_SSR_CONTEXT__||(a=__VUE_SSR_CONTEXT__),b&&b.call(this,i(a)),a&&a._registeredComponents&&a._registeredComponents.add(f)},k._ssrRegister=l):b&&(l=g?function(a){b.call(this,j(a,this.$root.$options.shadowRoot))}:function(a){b.call(this,h(a))}),l)if(k.functional){const a=k.render;k.render=function(b,c){return l.call(c),a(b,c)}}else{const a=k.beforeCreate;k.beforeCreate=a?[].concat(a,l):[l]}return c}const __vue_script__=script;var __vue_render__=function(){var a=this,b=a.$createElement,c=a._self._c||b;return c("widget",{ref:"widget",staticClass:"bp-popover",attrs:{visible:a.visibleReal,maskClose:a.maskClose,mask:a.mask,pageClass:a.pageClass,pageStyle:a.pageStyle,preventEvent:!1},on:{"update:visible":function(b){a.visibleReal=b}}},[c("div",{ref:"main",staticClass:"bp-popover__main",style:{left:a.offsetLeft,top:a.offsetTop},attrs:{direction:a.directionData}},[a._t("default"),a._v(" "),c("div",{staticClass:"bp-popover__arrow",style:{left:a.offsetArrowLeft,top:a.offsetArrowTop,right:a.offsetArrowRight,bottom:a.offsetArrowBottom}})],2)])},__vue_staticRenderFns__=[];__vue_render__._withStripped=!0;const __vue_inject_styles__=void 0,__vue_scope_id__=void 0,__vue_module_identifier__=void 0,__vue_is_functional_template__=!1,__vue_component__=normalizeComponent({render:__vue_render__,staticRenderFns:__vue_staticRenderFns__},void 0,__vue_script__,__vue_scope_id__,__vue_is_functional_template__,__vue_module_identifier__,!1,void 0,void 0,void 0);var index={bpPopover:__vue_component__};export default index; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = global || self, global.bpPopover = factory()); | ||
}(this, (function () { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@bpui/libs'), require('@bpui/dialog')) : | ||
typeof define === 'function' && define.amd ? define(['@bpui/libs', '@bpui/dialog'], factory) : | ||
(global = global || self, global.bpPopover = factory(global.bpLibs, global.bpDialog)); | ||
}(this, (function (bpLibs, bpDialog) { 'use strict'; | ||
var unpkg = "@import '../node_modules/@bpui/libs/style/index';\n@import '../node_modules/@bpui/libs/style/unpkg_class.scss';\n@import '../node_modules/@bpui/component-utils/style/index';\n@import '../node_modules/@bpui/dialog/dist/index.scss';\n\n@import \"./variable\";\n@import \"./popover\";"; | ||
bpLibs = bpLibs && Object.prototype.hasOwnProperty.call(bpLibs, 'default') ? bpLibs['default'] : bpLibs; | ||
bpDialog = bpDialog && Object.prototype.hasOwnProperty.call(bpDialog, 'default') ? bpDialog['default'] : bpDialog; | ||
return unpkg; | ||
// | ||
var script = { | ||
components: { | ||
widget: bpDialog.bpWidget | ||
}, | ||
props: { | ||
visible: Boolean, | ||
mask: { | ||
default: false, | ||
type: Boolean, | ||
}, | ||
maskClose: { | ||
default: true, | ||
type: Boolean, | ||
}, | ||
pageClass: String|Array, | ||
pageStyle: String|Array|Object, | ||
direction: { | ||
default: 'auto', | ||
type: String, | ||
}, | ||
trigger: { | ||
type: String, | ||
}, | ||
bind: { | ||
}, | ||
}, | ||
data() { | ||
return { | ||
visibleReal: false, | ||
directionData: 'auto', | ||
offsetTop: 0, | ||
offsetLeft: 0, | ||
offsetArrowLeft: null, | ||
offsetArrowTop: null, | ||
offsetArrowBottom: null, | ||
offsetArrowRight: null, | ||
}; | ||
}, | ||
watch: { | ||
visible(v, oldV) { | ||
if (this.visibleReal != v) { | ||
this.visibleReal = v; | ||
if (v != oldV && v) { | ||
this._show(this.direction); | ||
// this._show('top'); | ||
// this._show('bottom'); | ||
// this._show('left'); | ||
// this._show('right'); | ||
} | ||
} | ||
}, | ||
visibleReal(v) { | ||
this.$emit('update:visible', v); | ||
}, | ||
bind(v, oldV) { | ||
this._removeEvent(oldV); | ||
this._bindEvent(v); | ||
} | ||
}, | ||
beforeMount() { | ||
this.visibleReal = this.visible; | ||
}, | ||
beforeDestroy() { | ||
$('body').off('click', this._hide); | ||
}, | ||
mounted() { | ||
$('body').off('click', this._hide).on('click', this._hide); | ||
// if (this.trigger) { | ||
// let el = $(this.$el).parent(); | ||
// this._bindEvent(el); | ||
// } | ||
this.$nextTick(()=>{ | ||
this.$parent.$forceUpdate(); | ||
}); | ||
}, | ||
methods: { | ||
/** | ||
* @desc: 显示 | ||
* @return promise. | ||
*/ | ||
show: function () { | ||
return this.$refs.widget.show(); | ||
}, | ||
/** | ||
* @desc: 隐藏. | ||
* @return promise. | ||
*/ | ||
hide: function () { | ||
return this.$refs.widget.hide(); | ||
}, | ||
_removeEvent(v) { | ||
if (v) { | ||
let el; | ||
if (bpLibs.dom.isVueObject(v)) { | ||
el = v.$el; | ||
} | ||
else { | ||
el = v; | ||
} | ||
$(el).off('mouseover', this._onTrigger); | ||
$(el).off('mouseleave', this._onTriggerHide); | ||
$(el).off('click', this._onTrigger); | ||
} | ||
}, | ||
_bindEvent(v) { | ||
this._removeEvent(v); | ||
if (v) { | ||
let el; | ||
if (bpLibs.dom.isVueObject(v)) { | ||
el = v.$el; | ||
} | ||
else { | ||
el = v; | ||
} | ||
if (this.trigger == 'hover') { | ||
if (bpLibs.device.browserIsMobile()) { | ||
$(el).on('click', this._onTrigger); | ||
} | ||
else { | ||
$(el).on('mouseover', this._onTrigger); | ||
$(el).on('mouseleave', this._onTriggerHide); | ||
} | ||
} if (this.trigger == 'click') { | ||
let eventName = bpLibs.device.browserIsMobile()? 'click': 'click'; | ||
$(el).off(eventName, this._onTrigger).on(eventName, this._onTrigger); | ||
} | ||
} | ||
}, | ||
_onTrigger(ev) { | ||
this.visibleReal = true; | ||
this._show(this.direction); | ||
}, | ||
_onTriggerHide(ev) { | ||
this.visibleReal = false; | ||
}, | ||
_show: function(directionData) { | ||
let bind = this.bind; | ||
if (!this.bind) { | ||
return; | ||
} | ||
let el; | ||
if (bpLibs.dom.isVueObject(bind)) { | ||
el = bind.$el; | ||
} | ||
else { | ||
el = bind; | ||
} | ||
let offset = bpLibs.dom.getElementOffset(el); | ||
let port = {}; | ||
port.height = el.clientHeight; | ||
port.width = el.clientWidth; | ||
let viewPort = bpLibs.dom.getViewPort(); | ||
let docOffset = bpLibs.dom.getDocumentOffset(); | ||
this.offsetTop = offset.top + docOffset.top; | ||
// this.offsetLeft = offset.left; | ||
// directionData. | ||
if (directionData == 'top') { | ||
this.directionData = 'top'; | ||
this.offsetTop -= port.height; | ||
this.offsetTop -= 8; | ||
} | ||
else if (directionData == 'bottom') { | ||
this.directionData = 'bottom'; | ||
this.offsetTop += port.height; | ||
} | ||
else if (directionData == 'left') { | ||
this.directionData = 'left'; | ||
this.offsetLeft = offset.left + port.width; | ||
} | ||
else if (directionData == 'right') { | ||
this.directionData = 'right'; | ||
this.offsetLeft = offset.left + port.width; | ||
} | ||
else { | ||
if ((offset.top + port.height / 2) > viewPort.height/2) { | ||
this.directionData = 'top'; | ||
this.offsetTop -= port.height; | ||
this.offsetTop -= 8; | ||
} | ||
else { | ||
this.directionData = 'bottom'; | ||
this.offsetTop += port.height; | ||
} | ||
} | ||
this.offsetTop += 'px'; | ||
// arrow. | ||
let arrowOffset; | ||
if (directionData == 'left' || directionData == 'right') { | ||
arrowOffset = parseInt(offset.top+port.height/2); | ||
} else { | ||
arrowOffset = parseInt(offset.left+port.width/2); | ||
} | ||
const SCREEN_PADDING = 10; | ||
let main = this.$refs.main; | ||
bpLibs.dom.probeDom(200, ()=>{ | ||
return main.clientWidth > 0; | ||
}, ()=>{ | ||
if (directionData == 'left' || directionData == 'right') { | ||
let mainOffset = parseInt(arrowOffset - main.clientHeight/2); | ||
if (mainOffset < SCREEN_PADDING) { | ||
mainOffset = SCREEN_PADDING; | ||
} | ||
if (mainOffset+main.clientHeight > viewPort.height-SCREEN_PADDING) { | ||
mainOffset = viewPort.height-SCREEN_PADDING - main.clientHeight; | ||
} | ||
this.offsetTop = mainOffset + docOffset.top + 'px'; | ||
this.offsetLeft = directionData == 'right'? offset.left+port.width-6: offset.left-main.clientWidth-6; | ||
this.offsetLeft += docOffset.left; | ||
this.offsetLeft += 'px'; | ||
this.offsetArrowLeft = null; | ||
this.offsetArrowBottom = null; | ||
this.offsetArrowTop = arrowOffset - mainOffset - 6; | ||
if (this.offsetArrowTop < 10) { | ||
this.offsetArrowTop = 10; | ||
} | ||
else if (this.offsetArrowTop > main.clientHeight-22) { | ||
this.offsetArrowTop = main.clientHeight-22; | ||
} | ||
this.offsetArrowTop += 'px'; | ||
this.offsetArrowRight = null; | ||
} | ||
else { | ||
let mainOffset = parseInt(arrowOffset - main.clientWidth/2); | ||
if (mainOffset < SCREEN_PADDING) { | ||
mainOffset = SCREEN_PADDING; | ||
} | ||
if (mainOffset+main.clientWidth > viewPort.width-SCREEN_PADDING) { | ||
mainOffset = viewPort.width-SCREEN_PADDING - main.clientWidth; | ||
} | ||
this.offsetLeft = mainOffset + 'px'; | ||
this.offsetArrowLeft = arrowOffset - mainOffset - 6; | ||
if (this.offsetArrowLeft < 10) { | ||
this.offsetArrowLeft = 10; | ||
} | ||
else if (this.offsetArrowLeft > main.clientWidth-22) { | ||
this.offsetArrowLeft = main.clientWidth-22; | ||
} | ||
this.offsetArrowLeft += 'px'; | ||
this.offsetArrowBottom = null; | ||
this.offsetArrowTop = null; | ||
this.offsetArrowRight = null; | ||
} | ||
}); | ||
}, | ||
_hide() { | ||
this.hide().then(res=>{}); | ||
} | ||
}, | ||
}; | ||
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) { | ||
if (typeof shadowMode !== 'boolean') { | ||
createInjectorSSR = createInjector; | ||
createInjector = shadowMode; | ||
shadowMode = false; | ||
} | ||
// Vue.extend constructor export interop. | ||
const options = typeof script === 'function' ? script.options : script; | ||
// render functions | ||
if (template && template.render) { | ||
options.render = template.render; | ||
options.staticRenderFns = template.staticRenderFns; | ||
options._compiled = true; | ||
// functional template | ||
if (isFunctionalTemplate) { | ||
options.functional = true; | ||
} | ||
} | ||
// scopedId | ||
if (scopeId) { | ||
options._scopeId = scopeId; | ||
} | ||
let hook; | ||
if (moduleIdentifier) { | ||
// server build | ||
hook = function (context) { | ||
// 2.3 injection | ||
context = | ||
context || // cached call | ||
(this.$vnode && this.$vnode.ssrContext) || // stateful | ||
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional | ||
// 2.2 with runInNewContext: true | ||
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { | ||
context = __VUE_SSR_CONTEXT__; | ||
} | ||
// inject component styles | ||
if (style) { | ||
style.call(this, createInjectorSSR(context)); | ||
} | ||
// register component module identifier for async chunk inference | ||
if (context && context._registeredComponents) { | ||
context._registeredComponents.add(moduleIdentifier); | ||
} | ||
}; | ||
// used by ssr in case component is cached and beforeCreate | ||
// never gets called | ||
options._ssrRegister = hook; | ||
} | ||
else if (style) { | ||
hook = shadowMode | ||
? function (context) { | ||
style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot)); | ||
} | ||
: function (context) { | ||
style.call(this, createInjector(context)); | ||
}; | ||
} | ||
if (hook) { | ||
if (options.functional) { | ||
// register for functional component in vue file | ||
const originalRender = options.render; | ||
options.render = function renderWithStyleInjection(h, context) { | ||
hook.call(context); | ||
return originalRender(h, context); | ||
}; | ||
} | ||
else { | ||
// inject component registration as beforeCreate hook | ||
const existing = options.beforeCreate; | ||
options.beforeCreate = existing ? [].concat(existing, hook) : [hook]; | ||
} | ||
} | ||
return script; | ||
} | ||
/* script */ | ||
const __vue_script__ = script; | ||
/* template */ | ||
var __vue_render__ = function() { | ||
var _vm = this; | ||
var _h = _vm.$createElement; | ||
var _c = _vm._self._c || _h; | ||
return _c( | ||
"widget", | ||
{ | ||
ref: "widget", | ||
staticClass: "bp-popover", | ||
attrs: { | ||
visible: _vm.visibleReal, | ||
maskClose: _vm.maskClose, | ||
mask: _vm.mask, | ||
pageClass: _vm.pageClass, | ||
pageStyle: _vm.pageStyle, | ||
preventEvent: false | ||
}, | ||
on: { | ||
"update:visible": function($event) { | ||
_vm.visibleReal = $event; | ||
} | ||
} | ||
}, | ||
[ | ||
_c( | ||
"div", | ||
{ | ||
ref: "main", | ||
staticClass: "bp-popover__main", | ||
style: { | ||
left: _vm.offsetLeft, | ||
top: _vm.offsetTop | ||
}, | ||
attrs: { direction: _vm.directionData } | ||
}, | ||
[ | ||
_vm._t("default"), | ||
_vm._v(" "), | ||
_c("div", { | ||
staticClass: "bp-popover__arrow", | ||
style: { | ||
left: _vm.offsetArrowLeft, | ||
top: _vm.offsetArrowTop, | ||
right: _vm.offsetArrowRight, | ||
bottom: _vm.offsetArrowBottom | ||
} | ||
}) | ||
], | ||
2 | ||
) | ||
] | ||
) | ||
}; | ||
var __vue_staticRenderFns__ = []; | ||
__vue_render__._withStripped = true; | ||
/* style */ | ||
const __vue_inject_styles__ = undefined; | ||
/* scoped */ | ||
const __vue_scope_id__ = undefined; | ||
/* module identifier */ | ||
const __vue_module_identifier__ = undefined; | ||
/* functional template */ | ||
const __vue_is_functional_template__ = false; | ||
/* style inject */ | ||
/* style inject SSR */ | ||
/* style inject shadow dom */ | ||
const __vue_component__ = normalizeComponent( | ||
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, | ||
__vue_inject_styles__, | ||
__vue_script__, | ||
__vue_scope_id__, | ||
__vue_is_functional_template__, | ||
__vue_module_identifier__, | ||
false, | ||
undefined, | ||
undefined, | ||
undefined | ||
); | ||
var index = { | ||
bpPopover: __vue_component__, | ||
}; | ||
return index; | ||
}))); | ||
//# sourceMappingURL=index.js.map |
/*! | ||
* bpui popover v0.0.7 | ||
* bpui popover v0.0.8 | ||
* Copyright (c) 2020 Copyright bp All Rights Reserved. | ||
* Released under the MIT License. | ||
*/(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b(require("@bpui/libs"),require("@bpui/dialog")):"function"==typeof define&&define.amd?define(["@bpui/libs","@bpui/dialog"],b):(a=a||self,a.bpPopover=b(a.bpLibs,a.bpDialog))})(this,function(a,b){'use strict';a=a&&Object.prototype.hasOwnProperty.call(a,"default")?a["default"]:a,b=b&&Object.prototype.hasOwnProperty.call(b,"default")?b["default"]:b;var c={components:{widget:b.bpWidget},props:{visible:Boolean,mask:{default:!1,type:Boolean},maskClose:{default:!0,type:Boolean},pageClass:String|Array,pageStyle:String|Array|Object,direction:{default:"auto",type:String},trigger:{type:String},bind:{}},data(){return{visibleReal:!1,directionData:"auto",offsetTop:0,offsetLeft:0,offsetArrowLeft:null,offsetArrowTop:null,offsetArrowBottom:null,offsetArrowRight:null}},watch:{visible(a,b){this.visibleReal!=a&&(this.visibleReal=a,a!=b&&a&&this._show(this.direction))},visibleReal(a){this.$emit("update:visible",a)},bind(a,b){this._removeEvent(b),this._bindEvent(a)}},beforeMount(){this.visibleReal=this.visible},beforeDestroy(){$("body").off("click",this._hide)},mounted(){$("body").off("click",this._hide).on("click",this._hide),this.$nextTick(()=>{this.$parent.$forceUpdate()})},methods:{show:function(){return this.$refs.widget.show()},hide:function(){return this.$refs.widget.hide()},_removeEvent(b){if(b){let c;c=a.dom.isVueObject(b)?b.$el:b,$(c).off("mouseover",this._onTrigger),$(c).off("mouseleave",this._onTriggerHide),$(c).off("click",this._onTrigger)}},_bindEvent(b){if(this._removeEvent(b),b){let c;if(c=a.dom.isVueObject(b)?b.$el:b,"hover"==this.trigger&&(a.device.browserIsMobile()?$(c).on("click",this._onTrigger):($(c).on("mouseover",this._onTrigger),$(c).on("mouseleave",this._onTriggerHide))),"click"==this.trigger){let b=a.device.browserIsMobile()?"click":"click";$(c).off(b,this._onTrigger).on(b,this._onTrigger)}}},_onTrigger(){this.visibleReal=!0,this._show(this.direction)},_onTriggerHide(){this.visibleReal=!1},_show:function(b){let c=this.bind;if(!this.bind)return;let d=a.dom.isVueObject(c)?c.$el:c;let e=a.dom.getElementOffset(d),f={};f.height=d.clientHeight,f.width=d.clientWidth;let g=a.dom.getViewPort(),h=a.dom.getDocumentOffset();this.offsetTop=e.top+h.top,"top"==b?(this.directionData="top",this.offsetTop-=f.height,this.offsetTop-=8):"bottom"==b?(this.directionData="bottom",this.offsetTop+=f.height):"left"==b?(this.directionData="left",this.offsetLeft=e.left+f.width):"right"==b?(this.directionData="right",this.offsetLeft=e.left+f.width):e.top+f.height/2>g.height/2?(this.directionData="top",this.offsetTop-=f.height,this.offsetTop-=8):(this.directionData="bottom",this.offsetTop+=f.height),this.offsetTop+="px";let i="left"==b||"right"==b?parseInt(e.top+f.height/2):parseInt(e.left+f.width/2);const j=10;let k=this.$refs.main;a.dom.probeDom(200,()=>0<k.clientWidth,()=>{if("left"==b||"right"==b){let a=parseInt(i-k.clientHeight/2);a<j&&(a=j),a+k.clientHeight>g.height-j&&(a=g.height-j-k.clientHeight),this.offsetTop=a+h.top+"px",this.offsetLeft="right"==b?e.left+f.width-6:e.left-k.clientWidth-6,this.offsetLeft+=h.left,this.offsetLeft+="px",this.offsetArrowLeft=null,this.offsetArrowBottom=null,this.offsetArrowTop=i-a-6,10>this.offsetArrowTop?this.offsetArrowTop=10:this.offsetArrowTop>k.clientHeight-22&&(this.offsetArrowTop=k.clientHeight-22),this.offsetArrowTop+="px",this.offsetArrowRight=null}else{let a=parseInt(i-k.clientWidth/2);a<j&&(a=j),a+k.clientWidth>g.width-j&&(a=g.width-j-k.clientWidth),this.offsetLeft=a+"px",this.offsetArrowLeft=i-a-6,10>this.offsetArrowLeft?this.offsetArrowLeft=10:this.offsetArrowLeft>k.clientWidth-22&&(this.offsetArrowLeft=k.clientWidth-22),this.offsetArrowLeft+="px",this.offsetArrowBottom=null,this.offsetArrowTop=null,this.offsetArrowRight=null}})},_hide(){this.hide().then(()=>{})}}};var d=function(){var a=this,b=a.$createElement,c=a._self._c||b;return c("widget",{ref:"widget",staticClass:"bp-popover",attrs:{visible:a.visibleReal,maskClose:a.maskClose,mask:a.mask,pageClass:a.pageClass,pageStyle:a.pageStyle,preventEvent:!1},on:{"update:visible":function(b){a.visibleReal=b}}},[c("div",{ref:"main",staticClass:"bp-popover__main",style:{left:a.offsetLeft,top:a.offsetTop},attrs:{direction:a.directionData}},[a._t("default"),a._v(" "),c("div",{staticClass:"bp-popover__arrow",style:{left:a.offsetArrowLeft,top:a.offsetArrowTop,right:a.offsetArrowRight,bottom:a.offsetArrowBottom}})],2)])};d._withStripped=!0;const e=function(a,b,c,d,e,f,g,h,i,j){"boolean"!=typeof g&&(i=h,h=g,g=!1);const k="function"==typeof c?c.options:c;a&&a.render&&(k.render=a.render,k.staticRenderFns=a.staticRenderFns,k._compiled=!0,e&&(k.functional=!0)),d&&(k._scopeId=d);let l;if(f?(l=function(a){a=a||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,a||"undefined"==typeof __VUE_SSR_CONTEXT__||(a=__VUE_SSR_CONTEXT__),b&&b.call(this,i(a)),a&&a._registeredComponents&&a._registeredComponents.add(f)},k._ssrRegister=l):b&&(l=g?function(a){b.call(this,j(a,this.$root.$options.shadowRoot))}:function(a){b.call(this,h(a))}),l)if(k.functional){const a=k.render;k.render=function(b,c){return l.call(c),a(b,c)}}else{const a=k.beforeCreate;k.beforeCreate=a?[].concat(a,l):[l]}return c}({render:d,staticRenderFns:[]},void 0,c,void 0,!1,void 0,!1,void 0,void 0,void 0);return{bpPopover:e}}); |
{ | ||
"description": "popover", | ||
"dependencies": { | ||
"@bpui/dialog": "^0.1.3", | ||
"@bpui/libs": "^0.1.1" | ||
"@bpui/dialog": "^0.1.5", | ||
"@bpui/libs": "^0.2.2" | ||
}, | ||
@@ -23,4 +23,4 @@ "directories": {}, | ||
}, | ||
"main": "dist/index.common.min.js", | ||
"module": "dist/index.esm.min.js", | ||
"main": "dist/index.common.js", | ||
"module": "dist/index.esm.js", | ||
"unpkg": "dist/index.min.js", | ||
@@ -36,6 +36,6 @@ "types": "types/index.d.ts", | ||
"scripts": { | ||
"prepare": "node ../../scripts/bundle.js" | ||
"prepare": "node ../../scripts/bundle.js && rm -rf dist/style.js*" | ||
}, | ||
"name": "@bpui/popover", | ||
"version": "0.0.7" | ||
"version": "0.0.8" | ||
} |
@@ -14,3 +14,3 @@ # Introduce | ||
/* scss */ | ||
import '@bpui/libs/style/class.scss'; | ||
import '@bpui/libs/style'; | ||
import '@bpui/component-utils/style'; | ||
@@ -21,3 +21,3 @@ import '@bpui/dialog/style'; | ||
/* css */ | ||
<link href="~@bpui/popover/dist/index.css" rel="stylesheet" type="text/css"/> | ||
<link href="~@bpui/popover/dist/style.css" rel="stylesheet" type="text/css"/> | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
179735
20
2619
1
- Removed@bpui/libs@0.1.1(transitive)
- Removed@types/hammerjs@2.0.46(transitive)
- Removedbignumber.js@4.1.0(transitive)
- Removedcharenc@0.0.2(transitive)
- Removedcrypt@0.0.2(transitive)
- Removedfebs-browser@0.8.96(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedmd5@2.3.0(transitive)
- Removedsha1@1.1.1(transitive)
Updated@bpui/dialog@^0.1.5
Updated@bpui/libs@^0.2.2