import { ref } from 'vue' import { getUpstreamInput } from '@/utils/flow' export function useQuote(nodeId) { const quoteOptions = ref([]) const cascaderRefs = ref([]) const refreshQuoteOptions = () => { quoteOptions.value = getUpstreamInput(nodeId) || [] } // The option tree must exist before Cascader can render a persisted path. refreshQuoteOptions() const handleTypeChange = (property) => { if (!property) return if (property.type === 'input') { property.quote = [] } else { property.input = '' refreshQuoteOptions() } } const cascaderChange = (value, property) => { if (!property) return property.quote = Array.isArray(value) ? [...value] : [] property.quoteType = value?.[1] === 'input' ? 'input' : 'output' } const visibleChange = (visible) => { if (visible) refreshQuoteOptions() } return { quoteOptions, cascaderRefs, handleTypeChange, cascaderChange, visibleChange, refreshQuoteOptions, } }