primevue-mirror/components/lib/inplace/Inplace.vue

54 lines
1.4 KiB
Vue
Raw Normal View History

2022-09-06 12:03:37 +00:00
<template>
2024-04-09 14:11:00 +00:00
<div :class="cx('root')" aria-live="polite" v-bind="ptmi('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')">
2024-04-09 14:11:00 +00:00
<slot name="content" :closeCallback="close" />
2022-09-06 12:03:37 +00:00
</div>
</div>
</template>
<script>
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,
2024-02-11 08:10:29 +00:00
inheritAttrs: false,
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.d_active = true;
2024-04-09 14:11:00 +00:00
this.$emit('open', event);
2022-09-06 12:03:37 +00:00
this.$emit('update:active', true);
},
close(event) {
this.d_active = false;
2024-04-09 14:11:00 +00:00
this.$emit('close', event);
2022-09-06 12:03:37 +00:00
this.$emit('update:active', false);
2024-04-09 14:11:00 +00:00
2022-12-08 11:04:25 +00:00
setTimeout(() => {
this.$refs.display.focus();
}, 0);
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>