/** * "Live result" for calculator funnels (Funnelforms Pro): when visitors see the result (while they * answer, or blurred with a teaser until the contact step) and lines that show the text of the * range a result lies in. */ import React, { useState } from 'react'; import type { FormDocument, ResultField, ResultLine } from '@funnelforms/form-schema'; import { revealedLater, revealOnEndPages } from '../reveal'; import type { Edit } from './Answers'; import { useBuilder, useEnv } from './context'; import { __, sprintf } from './i18n'; import { put, TextProp } from './texts'; import { Button, Notice, Select, Toggle } from './ui'; export function ResultReveal( { field, edit }: { field: ResultField; edit: Edit } ) { const { ctx, lang, readOnly, store } = useEnv(); const doc = useBuilder( ( st ) => st.doc ); const [ added, setAdded ] = useState( null ); const p = field.props; const locked = 'contact' === p.reveal; const props = ( recipe: ( props: ResultField[ 'props' ] ) => void, key?: string ): void => edit( ( f ) => recipe( ( f as ResultField ).props ), key ); return ( <>