11<script setup>
2- import { ref , onMounted , onBeforeUnmount } from " vue" ;
2+ import { ref , onMounted , onBeforeUnmount , computed } from " vue" ;
33import vClickOutside from ' ../directives/vClickOutside' ;
44import BaseIcon from " ./BaseIcon.vue" ;
55
@@ -113,10 +113,18 @@ const props = defineProps({
113113 offsetX: {
114114 type: Number ,
115115 default: 0
116+ },
117+ hasAnnotator: {
118+ type: Boolean ,
119+ default: false ,
120+ },
121+ isAnnotation: {
122+ type: Boolean ,
123+ default: false ,
116124 }
117125});
118126
119- const emit = defineEmits ([' generatePdf' , ' generateCsv' , ' generateImage' , ' toggleTable' , ' toggleLabels' , ' toggleSort' , ' toggleFullscreen' , ' toggleStack' , ' toggleTooltip' , ' toggleAnimation' ]);
127+ const emit = defineEmits ([' generatePdf' , ' generateCsv' , ' generateImage' , ' toggleTable' , ' toggleLabels' , ' toggleSort' , ' toggleFullscreen' , ' toggleStack' , ' toggleTooltip' , ' toggleAnimation' , ' toggleAnnotator ' ]);
120128
121129function generatePdf () {
122130 emit (' generatePdf' );
@@ -172,6 +180,19 @@ function toggleAnimation() {
172180 emit (' toggleAnimation' );
173181}
174182
183+ const isAnnotator = computed ({
184+ get : () => {
185+ return props .isAnnotation ;
186+ },
187+ set : (bool ) => {
188+ return bool
189+ }
190+ })
191+ function toggleAnnotator () {
192+ isAnnotator .value = ! isAnnotator .value ;
193+ emit (' toggleAnnotator' )
194+ }
195+
175196function toggleSort () {
176197 emit (' toggleSort' )
177198}
@@ -206,11 +227,11 @@ function toggleFullscreen(state) {
206227}
207228
208229function fullscreenchanged (_event ) {
209- if (document .fullscreenElement ) {
210- isFullscreen .value = true ;
211- } else {
212- isFullscreen .value = false ;
213- }
230+ if (document .fullscreenElement ) {
231+ isFullscreen .value = true ;
232+ } else {
233+ isFullscreen .value = false ;
234+ }
214235}
215236
216237onMounted (() => {
@@ -234,6 +255,7 @@ const isInfo = ref({
234255 stack: false ,
235256 fullscreen: false ,
236257 animation: false ,
258+ annotator: false ,
237259})
238260
239261 </script >
@@ -376,6 +398,19 @@ const isInfo = ref({
376398 </div >
377399 </button >
378400
401+ <button tabindex =" 0" v-if =" hasAnnotator" data-cy =" user-options-anim" class =" vue-ui-user-options-button" @mouseenter =" isInfo.annotator = true" @mouseout =" isInfo.annotator = false" @click =" toggleAnnotator" >
402+ <template v-if =" $slots .optionAnnotator " >
403+ <slot name =" optionAnnotator" v-bind =" { toggleAnnotator, isAnnotator }" />
404+ </template >
405+ <template v-else >
406+ <BaseIcon v-if =" isAnnotator" name =" annotatorDisabled" :stroke =" color" style =" pointer-events : none ;" />
407+ <BaseIcon v-if =" !isAnnotator" name =" annotator" :stroke =" color" style =" pointer-events : none ;" />
408+ </template >
409+ <div dir =" auto" v-if =" isDesktop && titles.annotator && !$slots.optionAnnotator" :class =" {'button-info-left': position === 'left', 'button-info-right' : position === 'right', 'button-info-right-visible': position === 'right' && isInfo.annotator, 'button-info-left-visible': position === 'left' && isInfo.annotator }" :style =" { background: backgroundColor, color: color }" >
410+ {{ titles.annotator }}
411+ </div >
412+ </button >
413+
379414 </div >
380415 </div >
381416</template >
0 commit comments