2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2024-01-30 14:35:32 +00:00
|
|
|
<div v-focustrap :class="cx('root')" aria-live="polite" v-bind="ptm('root')">
|
2023-05-24 09:52:20 +00:00
|
|
|
<div v-if="!d_active" ref="display" :class="cx('display')" :tabindex="$attrs.tabindex || '0'" role="button" @click="open" @keydown.enter="open" v-bind="{ ...displayProps, ...ptm('display') }">
|
2022-09-06 12:03:37 +00:00
|
|
|
<slot name="display"></slot>
|
|
|
|
</div>
|
2023-05-24 09:52:20 +00:00
|
|
|
<div v-else :class="cx('content')" v-bind="ptm('content')">
|
2022-09-06 12:03:37 +00:00
|
|
|
<slot name="content"></slot>
|
2023-06-05 08:10:25 +00:00
|
|
|
<IPButton v-if="closable" :aria-label="closeAriaLabel" @click="close" :unstyled="unstyled" :pt="ptm('closeButton')" v-bind="closeButtonProps">
|
2023-04-13 10:32:32 +00:00
|
|
|
<template #icon>
|
|
|
|
<slot name="closeicon">
|
2023-09-06 07:13:22 +00:00
|
|
|
<component :is="closeIcon ? 'span' : 'TimesIcon'" :class="closeIcon" v-bind="ptm('closeButton')['icon']" data-pc-section="closebuttonicon"></component>
|
2023-04-13 10:32:32 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
|
|
|
</IPButton>
|
2022-09-06 12:03:37 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Button from 'primevue/button';
|
2023-03-17 08:47:12 +00:00
|
|
|
import FocusTrap from 'primevue/focustrap';
|
2023-04-18 12:53:43 +00:00
|
|
|
import TimesIcon from 'primevue/icons/times';
|
2023-05-25 14:42:26 +00:00
|
|
|
import BaseInplace from './BaseInplace.vue';
|
2023-04-14 10:05:52 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
export default {
|
|
|
|
name: 'Inplace',
|
2023-05-24 09:52:20 +00:00
|
|
|
extends: BaseInplace,
|
2022-09-06 12:03:37 +00:00
|
|
|
emits: ['open', 'close', 'update:active'],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
d_active: this.active
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
active(newValue) {
|
|
|
|
this.d_active = newValue;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
open(event) {
|
|
|
|
if (this.disabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$emit('open', event);
|
|
|
|
this.d_active = true;
|
|
|
|
this.$emit('update:active', true);
|
|
|
|
},
|
|
|
|
close(event) {
|
|
|
|
this.$emit('close', event);
|
|
|
|
this.d_active = false;
|
|
|
|
this.$emit('update:active', false);
|
2022-12-08 11:04:25 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
this.$refs.display.focus();
|
|
|
|
}, 0);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2022-12-08 11:04:25 +00:00
|
|
|
closeAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.close : undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
2023-04-13 10:32:32 +00:00
|
|
|
IPButton: Button,
|
|
|
|
TimesIcon
|
2023-03-17 08:47:12 +00:00
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
focustrap: FocusTrap
|
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>
|