2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2024-02-10 00:19:47 +00:00
|
|
|
<div :class="cx('root')" v-bind="ptmi('root')">
|
2023-05-19 11:14:50 +00:00
|
|
|
<div :class="cx('header')" v-bind="ptm('header')">
|
2024-02-02 15:47:37 +00:00
|
|
|
<slot :id="id + '_header'" name="header" :class="cx('title')">
|
|
|
|
<span v-if="header" :id="id + '_header'" :class="cx('title')" v-bind="ptm('title')">{{ header }}</span>
|
2022-09-06 12:03:37 +00:00
|
|
|
</slot>
|
2024-04-30 14:09:06 +00:00
|
|
|
<div :class="cx('headerActions')" v-bind="ptm('headerActions')">
|
2022-09-06 12:03:37 +00:00
|
|
|
<slot name="icons"></slot>
|
2024-04-15 08:08:42 +00:00
|
|
|
<Button
|
2022-09-14 11:26:01 +00:00
|
|
|
v-if="toggleable"
|
2024-02-02 15:47:37 +00:00
|
|
|
:id="id + '_header'"
|
2024-04-30 14:09:06 +00:00
|
|
|
:class="cx('toggleButton')"
|
2022-12-08 11:04:25 +00:00
|
|
|
:aria-label="buttonAriaLabel"
|
2024-02-02 15:47:37 +00:00
|
|
|
:aria-controls="id + '_content'"
|
2022-09-14 11:26:01 +00:00
|
|
|
:aria-expanded="!d_collapsed"
|
2024-04-15 08:08:42 +00:00
|
|
|
:unstyled="unstyled"
|
2022-09-14 11:26:01 +00:00
|
|
|
@click="toggle"
|
|
|
|
@keydown="onKeyDown"
|
2024-04-15 08:08:42 +00:00
|
|
|
v-bind="toggleButtonProps"
|
2024-04-30 14:09:06 +00:00
|
|
|
:pt="ptm('toggleButton')"
|
2022-09-14 11:26:01 +00:00
|
|
|
>
|
2024-04-15 08:08:42 +00:00
|
|
|
<template #icon="slotProps">
|
2024-04-30 14:09:06 +00:00
|
|
|
<!--TODO: togglericon deprecated since v4.0-->
|
2024-05-06 10:52:41 +00:00
|
|
|
<slot :name="$slots.toggleicon ? 'toggleicon' : 'togglericon'" :collapsed="d_collapsed">
|
2024-04-30 14:09:06 +00:00
|
|
|
<component :is="d_collapsed ? 'PlusIcon' : 'MinusIcon'" :class="slotProps.class" v-bind="ptm('toggleButton')['icon']" />
|
2024-04-15 08:08:42 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
|
|
|
</Button>
|
2022-09-06 12:03:37 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-08-02 11:04:59 +00:00
|
|
|
<transition name="p-toggleable-content" v-bind="ptm('transition')">
|
2024-04-30 14:09:06 +00:00
|
|
|
<div v-show="!d_collapsed" :id="id + '_content'" :class="cx('contentContainer')" role="region" :aria-labelledby="id + '_header'" v-bind="ptm('contentContainer')">
|
2023-05-19 11:14:50 +00:00
|
|
|
<div :class="cx('content')" v-bind="ptm('content')">
|
2022-09-06 12:03:37 +00:00
|
|
|
<slot></slot>
|
|
|
|
</div>
|
2023-05-19 11:14:50 +00:00
|
|
|
<div v-if="$slots.footer" :class="cx('footer')" v-bind="ptm('footer')">
|
2023-03-31 13:42:19 +00:00
|
|
|
<slot name="footer"></slot>
|
|
|
|
</div>
|
2022-09-06 12:03:37 +00:00
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2024-04-15 08:08:42 +00:00
|
|
|
import Button from 'primevue/button';
|
2023-04-18 12:53:43 +00:00
|
|
|
import MinusIcon from 'primevue/icons/minus';
|
|
|
|
import PlusIcon from 'primevue/icons/plus';
|
2022-09-06 12:03:37 +00:00
|
|
|
import Ripple from 'primevue/ripple';
|
2022-12-08 11:04:25 +00:00
|
|
|
import { UniqueComponentId } from 'primevue/utils';
|
2023-05-19 12:16:12 +00:00
|
|
|
import BasePanel from './BasePanel.vue';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Panel',
|
2023-05-19 10:33:07 +00:00
|
|
|
extends: BasePanel,
|
2024-02-10 00:19:47 +00:00
|
|
|
inheritAttrs: false,
|
2022-09-06 12:03:37 +00:00
|
|
|
emits: ['update:collapsed', 'toggle'],
|
|
|
|
data() {
|
|
|
|
return {
|
2024-02-02 15:47:37 +00:00
|
|
|
id: this.$attrs.id,
|
2022-09-06 12:03:37 +00:00
|
|
|
d_collapsed: this.collapsed
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
watch: {
|
2024-04-16 09:35:02 +00:00
|
|
|
'$attrs.id': function (newValue) {
|
|
|
|
this.id = newValue || UniqueComponentId();
|
2024-02-02 15:47:37 +00:00
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
collapsed(newValue) {
|
|
|
|
this.d_collapsed = newValue;
|
|
|
|
}
|
|
|
|
},
|
2024-04-16 09:35:02 +00:00
|
|
|
mounted() {
|
|
|
|
this.id = this.id || UniqueComponentId();
|
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
methods: {
|
|
|
|
toggle(event) {
|
|
|
|
this.d_collapsed = !this.d_collapsed;
|
|
|
|
this.$emit('update:collapsed', this.d_collapsed);
|
|
|
|
this.$emit('toggle', {
|
|
|
|
originalEvent: event,
|
|
|
|
value: this.d_collapsed
|
|
|
|
});
|
2022-09-14 11:26:01 +00:00
|
|
|
},
|
|
|
|
onKeyDown(event) {
|
2023-12-20 10:45:43 +00:00
|
|
|
if (event.code === 'Enter' || event.code === 'NumpadEnter' || event.code === 'Space') {
|
2022-09-14 11:26:01 +00:00
|
|
|
this.toggle(event);
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2022-12-08 11:04:25 +00:00
|
|
|
buttonAriaLabel() {
|
2023-11-30 20:08:56 +00:00
|
|
|
return this.toggleButtonProps && this.toggleButtonProps.ariaLabel ? this.toggleButtonProps.ariaLabel : this.header;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
2023-04-03 08:27:41 +00:00
|
|
|
components: {
|
|
|
|
PlusIcon,
|
2024-04-15 08:08:42 +00:00
|
|
|
MinusIcon,
|
|
|
|
Button
|
2023-04-03 08:27:41 +00:00
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
directives: {
|
2022-09-14 11:26:01 +00:00
|
|
|
ripple: Ripple
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|