Refactor #3965 - For BlockUI
parent
c8a856dc9e
commit
fee8498a7e
|
@ -0,0 +1,66 @@
|
||||||
|
<script>
|
||||||
|
import BaseComponent from 'primevue/basecomponent';
|
||||||
|
import { useStyle } from 'primevue/usestyle';
|
||||||
|
|
||||||
|
const styles = `
|
||||||
|
.p-blockui-container {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-blockui {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-blockui.p-component-overlay {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-blockui-document.p-component-overlay {
|
||||||
|
position: fixed;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const classes = {
|
||||||
|
root: 'p-blockui-container'
|
||||||
|
};
|
||||||
|
|
||||||
|
const { load: loadStyle } = useStyle(styles, { id: 'primevue_divider_style', manual: true });
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'BaseAvatar',
|
||||||
|
extends: BaseComponent,
|
||||||
|
props: {
|
||||||
|
blocked: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
fullScreen: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
baseZIndex: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
autoZIndex: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
css: {
|
||||||
|
classes
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isUnstyled: {
|
||||||
|
immediate: true,
|
||||||
|
handler(newValue) {
|
||||||
|
!newValue && loadStyle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -78,6 +78,11 @@ export interface BlockUIProps {
|
||||||
* @type {BlockUIPassThroughOptions}
|
* @type {BlockUIPassThroughOptions}
|
||||||
*/
|
*/
|
||||||
pt?: BlockUIPassThroughOptions;
|
pt?: BlockUIPassThroughOptions;
|
||||||
|
/**
|
||||||
|
* When enabled, it removes component related styles in the core.
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
unstyled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div ref="container" class="p-blockui-container" :aria-busy="isBlocked" v-bind="ptm('root')">
|
<div ref="container" :class="cx('root')" :aria-busy="isBlocked" v-bind="ptm('root')">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -12,24 +12,6 @@ export default {
|
||||||
name: 'BlockUI',
|
name: 'BlockUI',
|
||||||
extends: BaseComponent,
|
extends: BaseComponent,
|
||||||
emits: ['block', 'unblock'],
|
emits: ['block', 'unblock'],
|
||||||
props: {
|
|
||||||
blocked: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
fullScreen: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
baseZIndex: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
autoZIndex: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mask: null,
|
mask: null,
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -54,13 +36,13 @@ export default {
|
||||||
if (this.fullScreen) {
|
if (this.fullScreen) {
|
||||||
styleClass += ' p-blockui-document';
|
styleClass += ' p-blockui-document';
|
||||||
this.mask = document.createElement('div');
|
this.mask = document.createElement('div');
|
||||||
this.mask.setAttribute('class', styleClass);
|
!this.isUnstyled && this.mask.setAttribute('class', styleClass);
|
||||||
document.body.appendChild(this.mask);
|
document.body.appendChild(this.mask);
|
||||||
DomHandler.addClass(document.body, 'p-overflow-hidden');
|
!this.isUnstyled && DomHandler.addClass(document.body, 'p-overflow-hidden');
|
||||||
document.activeElement.blur();
|
document.activeElement.blur();
|
||||||
} else {
|
} else {
|
||||||
this.mask = document.createElement('div');
|
this.mask = document.createElement('div');
|
||||||
this.mask.setAttribute('class', styleClass);
|
!this.isUnstyled && this.mask.setAttribute('class', styleClass);
|
||||||
this.$refs.container.appendChild(this.mask);
|
this.$refs.container.appendChild(this.mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +54,7 @@ export default {
|
||||||
this.$emit('block');
|
this.$emit('block');
|
||||||
},
|
},
|
||||||
unblock() {
|
unblock() {
|
||||||
DomHandler.addClass(this.mask, 'p-component-overlay-leave');
|
!this.isUnstyled && DomHandler.addClass(this.mask, 'p-component-overlay-leave');
|
||||||
this.mask.addEventListener('animationend', () => {
|
this.mask.addEventListener('animationend', () => {
|
||||||
this.removeMask();
|
this.removeMask();
|
||||||
});
|
});
|
||||||
|
@ -81,8 +63,10 @@ export default {
|
||||||
ZIndexUtils.clear(this.mask);
|
ZIndexUtils.clear(this.mask);
|
||||||
|
|
||||||
if (this.fullScreen) {
|
if (this.fullScreen) {
|
||||||
|
if (!this.isUnstyled) {
|
||||||
document.body.removeChild(this.mask);
|
document.body.removeChild(this.mask);
|
||||||
DomHandler.removeClass(document.body, 'p-overflow-hidden');
|
DomHandler.removeClass(document.body, 'p-overflow-hidden');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$refs.container.removeChild(this.mask);
|
this.$refs.container.removeChild(this.mask);
|
||||||
}
|
}
|
||||||
|
@ -93,25 +77,3 @@ export default {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
|
||||||
.p-blockui-container {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.p-blockui {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.p-blockui.p-component-overlay {
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
.p-blockui-document.p-component-overlay {
|
|
||||||
position: fixed;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
Loading…
Reference in New Issue