bettersight-statement-extra.../frontend/src/stores/uiStore.js

44 lines
1.3 KiB
JavaScript

/**
* Pure view-chrome state, unrelated to the extraction data itself:
* collapse/expand, panel visibility/width, and a layout-change counter
* description boxes watch to know when to re-measure their own height.
*/
import { defineStore } from 'pinia'
export const useUiStore = defineStore('ui', {
state: () => ({
resultExpanded: false,
pdfColHidden: false,
pdfColWidthPct: 40, // matches .pdf-col's own CSS default (flex: 0 0 40%)
restoreBannerVisible: false,
restoreBannerText: '',
/**
* Bumped whenever the transactions column's available width changes
* (the Hide/Show toggle, or a resize-drag ending) - every
* TransactionRow's own description textarea watches this to
* re-measure its height, replacing the old global autoGrowAll()
* call pattern with something each row can react to independently.
*/
layoutVersion: 0,
}),
actions: {
toggleResultExpanded() {
this.resultExpanded = !this.resultExpanded
},
togglePdfCol() {
this.pdfColHidden = !this.pdfColHidden
this.bumpLayout()
},
bumpLayout() {
this.layoutVersion++
},
showRestoreBanner(text) {
this.restoreBannerText = text
this.restoreBannerVisible = true
},
hideRestoreBanner() {
this.restoreBannerVisible = false
},
},
})