Refactor #3965 - For InlineMessage
parent
34d2b65236
commit
0d3816522a
|
@ -0,0 +1,56 @@
|
||||||
|
<script>
|
||||||
|
import BaseComponent from 'primevue/basecomponent';
|
||||||
|
import { useStyle } from 'primevue/usestyle';
|
||||||
|
|
||||||
|
const styles = `
|
||||||
|
.p-inline-message {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-inline-message-icon-only .p-inline-message-text {
|
||||||
|
visibility: hidden;
|
||||||
|
width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-fluid .p-inline-message {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const classes = {
|
||||||
|
root: ({ props, instance }) => ['p-inline-message p-component p-inline-message-' + props.severity, { 'p-inline-message-icon-only': !instance.$slots.default }],
|
||||||
|
icon: ({ props }) => ['p-inline-message-icon', props.icon],
|
||||||
|
text: 'p-inline-message-text'
|
||||||
|
};
|
||||||
|
|
||||||
|
const { load: loadStyle } = useStyle(styles, { id: 'primevue_inlinemessage_style', manual: true });
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'BaseInlineMessage',
|
||||||
|
extends: BaseComponent,
|
||||||
|
props: {
|
||||||
|
severity: {
|
||||||
|
type: String,
|
||||||
|
default: 'error'
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
type: String,
|
||||||
|
default: undefined
|
||||||
|
}
|
||||||
|
},
|
||||||
|
css: {
|
||||||
|
classes
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isUnstyled: {
|
||||||
|
immediate: true,
|
||||||
|
handler(newValue) {
|
||||||
|
!newValue && loadStyle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -76,6 +76,11 @@ export interface InlineMessageProps {
|
||||||
* @type {InlineMessagePassThroughOptions}
|
* @type {InlineMessagePassThroughOptions}
|
||||||
*/
|
*/
|
||||||
pt?: InlineMessagePassThroughOptions;
|
pt?: InlineMessagePassThroughOptions;
|
||||||
|
/**
|
||||||
|
* When enabled, it removes component related styles in the core.
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
unstyled?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Defines valid slots in InlineMessage slots.
|
* Defines valid slots in InlineMessage slots.
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<div aria-live="polite" :class="containerClass" v-bind="ptm('root')">
|
<div aria-live="polite" :class="cx('root')" v-bind="ptm('root')">
|
||||||
<slot name="icon">
|
<slot name="icon">
|
||||||
<component :is="icon ? 'span' : iconComponent" :class="['p-inline-message-icon', icon]" v-bind="ptm('icon')"></component>
|
<component :is="icon ? 'span' : iconComponent" :class="cx('icon')" v-bind="ptm('icon')"></component>
|
||||||
</slot>
|
</slot>
|
||||||
<span class="p-inline-message-text" v-bind="ptm('text')">
|
<span :class="cx('text')" v-bind="ptm('text')">
|
||||||
<slot> </slot>
|
<slot> </slot>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import BaseComponent from 'primevue/basecomponent';
|
import BaseInlineMessage from './BaseInlineMessage.vue';
|
||||||
import CheckIcon from 'primevue/icons/check';
|
import CheckIcon from 'primevue/icons/check';
|
||||||
import ExclamationTriangleIcon from 'primevue/icons/exclamationtriangle';
|
import ExclamationTriangleIcon from 'primevue/icons/exclamationtriangle';
|
||||||
import InfoCircleIcon from 'primevue/icons/infocircle';
|
import InfoCircleIcon from 'primevue/icons/infocircle';
|
||||||
|
@ -18,17 +18,7 @@ import TimesCircleIcon from 'primevue/icons/timescircle';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'InlineMessage',
|
name: 'InlineMessage',
|
||||||
extends: BaseComponent,
|
extends: BaseInlineMessage,
|
||||||
props: {
|
|
||||||
severity: {
|
|
||||||
type: String,
|
|
||||||
default: 'error'
|
|
||||||
},
|
|
||||||
icon: {
|
|
||||||
type: String,
|
|
||||||
default: undefined
|
|
||||||
}
|
|
||||||
},
|
|
||||||
timeout: null,
|
timeout: null,
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -43,9 +33,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
containerClass() {
|
|
||||||
return ['p-inline-message p-component p-inline-message-' + this.severity, { 'p-inline-message-icon-only': !this.$slots.default }];
|
|
||||||
},
|
|
||||||
iconComponent() {
|
iconComponent() {
|
||||||
return {
|
return {
|
||||||
info: InfoCircleIcon,
|
info: InfoCircleIcon,
|
||||||
|
@ -57,21 +44,3 @@ export default {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
|
||||||
.p-inline-message {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
|
|
||||||
.p-inline-message-icon-only .p-inline-message-text {
|
|
||||||
visibility: hidden;
|
|
||||||
width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.p-fluid .p-inline-message {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
Loading…
Reference in New Issue