import { useState } from 'react'; import { Viewer, DocumentGate } from '@embedpdf/react/runtime'; import type { OpenInput } from '@embedpdf/react/runtime'; import { Stage, stagePlugin } from '@embedpdf/react/stage'; import { RenderLayer, renderPlugin } from '@embedpdf/react/render'; import { interactionPlugin } from '@embedpdf/react/interaction'; import { FormLayer, formPlugin, toFieldRef, useForm } from '@embedpdf/react/form'; import type { FormCapability } from '@embedpdf/react/form'; import { cloudEngine } from '@cloudpdf/engine'; import './fill.css'; const engine = cloudEngine(); const plugins = [stagePlugin(), renderPlugin(), interactionPlugin(), formPlugin()]; const forms: OpenInput = { kind: 'grant', grant: 'shr_eBRW5E3MpolzD8G36Alp30EF' }; /** One field of each kind, with `setValue()` in the shape each one takes. */ async function fillIn(form: FormCapability) { await form.setValue(toFieldRef('name'), { value: 'Ada Lovelace' }); // text await form.setValue(toFieldRef('updates'), { checked: true }); // checkbox await form.setValue(toFieldRef('plan'), { value: 'yearly' }); // radio group: a button's value await form.setValue(toFieldRef('framework'), { value: 'React' }); // dropdown: an option's value return form.setValue(toFieldRef('topics'), { selectedValues: ['Forms', 'Signatures'] }); // list } function FillToolbar() { const form = useForm(); const [result, setResult] = useState(''); return (