import { Ref , ComputedRef , ref , computed } from "vue" ; export class PreviewableValue { private isPreview : Ref < boolean > ; private storeValue : ComputedRef < number | undefined > ; private previewValue : Ref < number | undefined > ; currentValue : ComputedRef < number | undefined > ; constructor ( storeFunc ) { this . isPreview = ref ( false ) ; this . storeValue = computed ( storeFunc ) ; this . previewValue = ref ( undefined ) ; this . currentValue = computed ( ( ) => this . isPreview . value ? this . previewValue . value : this . storeValue . value ) ; } setPreviewValue ( newValue ) { this . previewValue . value = newValue ; } startPreview ( ) { this . isPreview . value = true ; this . setPreviewValue ( this . storeValue . value ?? 0.0 ) ; } stopPreview ( ) { this . isPreview . value = false ; } }