import { AttachmentAnswer } from '@esheet/core'; import { default as default_2 } from 'react'; import { FieldComponentProps } from '@esheet/core'; import { FieldDefinition } from '@esheet/core'; import { FieldTypeMeta } from '@esheet/core'; import { FieldWidth } from '@esheet/core'; import { FileInput } from '@esheet/core'; import { FileStore } from '@esheet/core'; import { FormStore } from '@esheet/core'; import { JSX } from 'react'; import { LucideProps } from 'lucide-react'; import { OptionsSource } from '@esheet/core'; import { ReactNode } from 'react'; import { ResponseReference } from '@esheet/core'; import { ResponseReferenceNavigate } from '@esheet/core'; import { ResponseReferenceResolver } from '@esheet/core'; import { SelectedOption } from '@esheet/core'; import { StoreApi } from 'zustand/vanilla'; import { UIState } from '@esheet/core'; import { UIStore } from '@esheet/core'; export declare const ArrowDownIcon: default_2.MemoExoticComponent<({ className }: IconProps) => default_2.JSX.Element>; export declare const ArrowUpIcon: default_2.MemoExoticComponent<({ className }: IconProps) => default_2.JSX.Element>; /** Form extension namespace for per-field arrays of retained autocomplete items. */ export declare const AUTOCOMPLETE_HISTORY_NAMESPACE = "@esheet/fields/autocomplete"; export declare const AutocompleteField: default_2.NamedExoticComponent; /** * Definition props for the `autocomplete` custom field type. * * The field searches a remote endpoint as the user types and stores the * chosen item as `{ selected: { id, value } }`, like a dropdown. */ export declare interface AutocompleteFieldDefinition { /** Field id, assigned by the builder like every field definition. */ id: string; question?: string; /** * Host-registered provider to source options from (see * `registerOptionsProvider` in `@esheet/core`). Takes precedence over * `dataSourceUrl`; the host owns fetching, auth and caching. */ optionsSource?: OptionsSource; /** * Remote endpoint template. `{query}` is replaced with the URL-encoded * search text, e.g. * `https://en.wikipedia.org/w/api.php?action=opensearch&search={query}&limit=8&format=json&origin=*` */ dataSourceUrl?: string; /** For JSON object-array responses: key holding the display label. Default `label`. */ labelKey?: string; /** For JSON object-array responses: key holding the stored id. Defaults to `labelKey`. */ valueKey?: string; /** * Dot-path to the results array inside an enveloped response, e.g. * `results` for `{ results: [...] }` or `data.items` for `{ data: { items: [...] } }`. * Leave empty when the response is the array itself. */ resultsPath?: string; /** * For JSON object-array responses: extra keys copied from the selected * object into `response.attributes`, e.g. `['city', 'state', 'zip']` when * picking an address. Values are stringified. */ captureKeys?: string[]; /** Input placeholder text. */ answerPlaceholder?: string; /** Minimum query length before searching. Default 2. */ minQueryLength?: number; /** * Keep what the user typed as a plain `answer` when nothing is picked, so * the field doubles as a text input for names the source does not know. * A pick replaces it with `selected`. */ allowFreeText?: boolean; /** * Only accept picks from the list: typed text just searches and is never * stored, and on blur without a pick the input reverts to the stored * selection (or clears). With no `selected`, a required field fails * submission as usual. Takes precedence over `allowFreeText`. */ requireSelection?: boolean; /** * Sibling fields to fill from the picked option's attributes: * `{ : }`, e.g. `{ mrn: mrn, dateOfBirth: dob }`. * Each named field gets `{ answer }`; attributes the option lacks clear * the target so a stale value from an earlier pick does not linger. */ fillFields?: Record; } export declare const BooleanField: default_2.NamedExoticComponent; declare type CheckboxSize = keyof typeof SIZES_2; export declare const CheckField: default_2.NamedExoticComponent; export declare const ClipboardIcon: default_2.ForwardRefExoticComponent & default_2.RefAttributes>; export declare function createFileStoreProvider(store: FileStore): FieldProvider; export declare function createResponseReferenceProvider(resolver: ResponseReferenceResolver, onNavigate?: ResponseReferenceNavigate): FieldProvider; /** * Themed checkbox with custom square + checkmark SVG. */ export declare const CustomCheckbox: default_2.NamedExoticComponent; export declare const CustomCheckboxButton: default_2.NamedExoticComponent; declare interface CustomCheckboxButtonProps { id: string; name?: string; value: string; checked: boolean; children: ReactNode; onChange?: (checked: boolean) => void; disabled?: boolean; className?: string; } declare interface CustomCheckboxProps { id: string; name?: string; checked: boolean; onChange?: (checked: boolean) => void; disabled?: boolean; className?: string; size?: CheckboxSize; /** If true, only renders a hidden input (for button-style label UIs). */ hidden?: boolean; } export declare function CustomDropdown(props: CustomDropdownProps): JSX.Element; declare type CustomDropdownProps = SingleSelectProps | MultiSelectProps; /** * Themed radio button with deselect support. * * Click a selected radio again to deselect — uses `onUnselect` callback. */ export declare const CustomRadio: default_2.NamedExoticComponent; export declare const CustomRadioButton: default_2.NamedExoticComponent; declare interface CustomRadioButtonProps { id: string; name: string; value: string; checked: boolean; children: ReactNode; onSelect?: (value: string) => void; onUnselect?: (value: string) => void; disabled?: boolean; className?: string; } declare interface CustomRadioProps { id: string; name: string; value: string; checked: boolean; onSelect?: (value: string) => void; onUnselect?: (value: string) => void; disabled?: boolean; className?: string; size?: RadioSize; /** If true, only renders a hidden input (for button-style label UIs). */ hidden?: boolean; } export declare const DiagramField: default_2.NamedExoticComponent; export declare const DisplayField: default_2.NamedExoticComponent; /** * The persisted drawing payload. * `baseWidth` / `baseHeight` record the design dimensions used when the drawing * was created — they are stored for reference but strokes are always replayed * from their normalized coordinates, so resizing never distorts geometry. */ export declare interface DrawingData { strokes: Stroke[]; baseWidth: number; baseHeight: number; } export declare const DrawingPad: default_2.NamedExoticComponent; /** Configuration knobs for a `DrawingPad` instance. */ export declare interface DrawingPadConfig { /** * Logical design width in CSS pixels. * Together with `baseHeight`, this establishes the aspect ratio. * The canvas will fill its container width while preserving this ratio. * Default: 600 */ baseWidth?: number; /** Default: 300 */ baseHeight?: number; /** Initial pen colour. Default: '#000000' */ strokeColor?: string; /** Initial pen size in logical pixels. Default: 2 */ strokeWidth?: number; /** Eraser square half-size. Default: 20 */ eraserWidth?: number; /** Show the eraser tool button. Default: false */ hasEraser?: boolean; /** Canvas fill colour used as background. Default: '#ffffff' */ backgroundColor?: string; } /** The value emitted by the `onChange` callback after every stroke. */ export declare interface DrawingPadPayload { /** JSON-stringified `DrawingData`. Empty string when the canvas is cleared. */ strokes: string; /** Base64 PNG export of the composite display canvas. Empty string when cleared. */ image: string; } declare interface DrawingPadProps { config?: DrawingPadConfig; colorInputId?: string; /** Optional background image (base64 data-URL or remote URL) drawn beneath user strokes. */ backgroundImage?: string; /** Text shown centred on an empty canvas. */ placeholder?: string; /** * JSON-stringified `DrawingData` to pre-load. * Changing this prop replaces the current drawing. */ existingData?: string; onChange?: (payload: DrawingPadPayload) => void; disabled?: boolean; } export declare const DropdownField: default_2.NamedExoticComponent; declare interface DropdownOption { readonly id: string; value: string; } /** * Reusable modal used for import and validation feedback. */ export declare function FeedbackModal({ open, title, message, details, issues, issuesTitle, issuesHint, content, variant, confirmLabel, cancelLabel, showCancel, onConfirm, onClose, }: FeedbackModalProps): JSX.Element | null; export declare interface FeedbackModalProps { open: boolean; title: string; message: string; details?: string; issues?: string[]; issuesTitle?: string; issuesHint?: string; content?: ReactNode; variant?: FeedbackModalVariant; confirmLabel?: string; cancelLabel?: string; showCancel?: boolean; onConfirm?: () => void; onClose: () => void; } export declare type FeedbackModalVariant = 'info' | 'success' | 'warning' | 'error'; declare type FieldComponent = default_2.ComponentType; export declare const FieldGrid: default_2.ForwardRefExoticComponent>; export declare function FieldGridItem({ children, fieldType, width, inheritedWidth, }: FieldGridItemProps): default_2.ReactElement<{ style?: default_2.CSSProperties; }, string | default_2.JSXElementConstructor>; export declare interface FieldGridItemProps { children: default_2.ReactElement<{ style?: default_2.CSSProperties; }>; fieldType: string; width?: FieldWidth; inheritedWidth?: FieldWidth; } export declare interface FieldGridProps extends default_2.ComponentPropsWithoutRef<'div'> { enabled?: boolean; stackedClassName?: string; } declare type FieldPropertyEditor = default_2.ComponentType; export declare interface FieldPropertyEditorProps { readonly fieldId: string; readonly instanceId: string; readonly def: Omit; readonly onUpdate: (patch: Partial>) => void; } export declare type FieldProvider = (children: default_2.ReactNode) => default_2.ReactNode; export declare function FieldProviderStack({ providers, children, }: FieldProviderStackProps): default_2.JSX.Element; export declare interface FieldProviderStackProps { providers?: readonly FieldProvider[]; children: default_2.ReactNode; } export declare const FileField: default_2.NamedExoticComponent; /** Match a file against an `accept` string (MIME types, wildcards, extensions). */ export declare const fileMatchesAccept: (file: File, accept?: string) => boolean; export declare interface FileMetadata { readonly contentType: string; readonly title: string; readonly size: number; } export declare function FileStoreProvider({ store, children, }: FileStoreProviderProps): default_2.JSX.Element; export declare interface FileStoreProviderProps { readonly store: FileStore; readonly children: default_2.ReactNode; } export declare const fileToInput: (file: File) => FileInput; export declare const FolderIcon: default_2.ForwardRefExoticComponent & default_2.RefAttributes>; /** Human-readable file size (e.g. `1.5 MB`). */ export declare const formatFileSize: (bytes: number) => string; export declare const FormStoreContext: default_2.Context; /** Look up the component for a field type. Returns undefined if none registered. */ export declare function getFieldComponent(key: string): FieldComponent | undefined; /** Look up the Edit-mode property editor registered for a field type. */ export declare function getFieldPropertyEditor(key: string): FieldPropertyEditor | undefined; /** Normalize metadata shared by inline attachments and external file stores. */ export declare const getFileMetadata: (file: File) => FileMetadata; /** Returns the field type keys that have a registered React component. */ export declare function getRegisteredComponentKeys(): string[]; declare interface Host { resolver: ResponseReferenceResolver; onNavigate?: ResponseReferenceNavigate; } export declare const HtmlField: default_2.NamedExoticComponent; declare type IconProps = { className?: string; }; export declare const ImageField: default_2.NamedExoticComponent; export declare const InfoIcon: default_2.ForwardRefExoticComponent & default_2.RefAttributes>; export declare const LongTextField: default_2.NamedExoticComponent; export declare const MinusIcon: default_2.ForwardRefExoticComponent & default_2.RefAttributes>; export declare const MultiMatrixField: default_2.NamedExoticComponent; export declare const MultiSelectDropdownField: default_2.NamedExoticComponent; declare interface MultiSelectProps { options: readonly DropdownOption[]; value: string[]; onChange: (selectedIds: string[]) => void; placeholder?: string; showClearOption?: boolean; maxHeight?: string; isMulti: true; disabled?: boolean; } export declare const MultiTextField: default_2.NamedExoticComponent; /** A single normalized point (0..1 fraction of the canvas design dimensions). */ export declare interface NormalizedPoint { x: number; y: number; } export declare const OpenChoiceField: default_2.NamedExoticComponent; /** * PageNavigator — wraps a page's content and renders configurable page navigation. * * Used in both the renderer and the builder's preview mode so both surfaces * share identical navigation UX. * * Layout: optional page tabs above content and [← Previous] [currentIdx + 1 / total] [Next →] below. * The Next button is replaced with "Last page" text on the final page. * The Previous button is disabled (not hidden) on the first page. * When blockedCount > 0, clicking Next shows an inline error instead of advancing. */ export declare function PageNavigator({ children, currentIdx, total, onPrev, onNext, pageTitles, onPageChange, topNavigation, bottomNavigation, validateNavigation, blockedCount, }: PageNavigatorProps): default_2.JSX.Element; export declare interface PageNavigatorProps { children: default_2.ReactNode; currentIdx: number; total: number; onPrev: () => void; onNext: () => void; /** Optional labels for the top page tabs. */ pageTitles?: readonly string[]; /** Called when a top page tab requests a specific page. */ onPageChange?: (pageIdx: number) => void; /** Show page tabs above the content. */ topNavigation?: boolean; /** Show Previous / Next controls below the content. */ bottomNavigation?: boolean; /** Block forward page changes while required fields are unanswered. */ validateNavigation?: boolean; /** Number of unfilled hard-required fields on the current page. Blocks Next when > 0. */ blockedCount?: number; } /** * Normalizes a remote response into selectable options. Supports: * 1. OpenSearch arrays (`[query, titles[], descriptions[], urls[]]`, e.g. Wikipedia) * 2. Arrays of strings * 3. Arrays of objects (using `labelKey` / `valueKey`; the raw object is * retained for attribute capture) * * Enveloped responses (`{ results: [...] }`) are unwrapped first via `resultsPath`. */ export declare function parseAutocompleteItems(data: unknown, labelKey?: string, valueKey?: string, resultsPath?: string): ParsedAutocompleteItem[]; /** An option plus the raw source object it came from (for attribute capture). */ declare interface ParsedAutocompleteItem extends SelectedOption { /** The raw response object this option was parsed from, when available. */ raw?: Record; /** Secondary text a provider attached, shown beside the value. */ description?: string; /** Attributes a provider attached directly (no `captureKeys` needed). */ attributes?: Record; } export declare const PencilIcon: default_2.ForwardRefExoticComponent & default_2.RefAttributes>; export declare const PlusIcon: default_2.ForwardRefExoticComponent & default_2.RefAttributes>; export declare const RadioField: default_2.NamedExoticComponent; declare type RadioSize = keyof typeof SIZES; export declare const RankingField: default_2.NamedExoticComponent; export declare const RatingField: default_2.NamedExoticComponent; /** Read a File into the AttachmentAnswer shape (dataUrl-based). */ export declare const readFileAsAttachment: (file: File) => Promise; /** * Registers the `autocomplete` custom field type: a type-ahead question that * searches a remote endpoint and stores the chosen item like a dropdown. * * @example * ```tsx * import { registerAutocompleteFieldType } from '@esheet/fields'; * registerAutocompleteFieldType(); * ``` */ export declare function registerAutocompleteFieldType(): void; /** * Register one or more custom field types with both core metadata AND a React component. * * Works with both @esheet/builder (canvas) and @esheet/renderer (fill-out mode). * * @example * ```tsx * import { registerCustomFieldTypes } from '@esheet/fields'; * * registerCustomFieldTypes({ * vitals: { label: 'Vitals', category: 'rich', answerType: 'object', hasOptions: false, hasMatrix: false, defaultProps: {}, component: VitalsField }, * }); * ``` */ export declare function registerCustomFieldTypes(entries: Record): void; /** Register React components for field types. */ export declare function registerFieldComponents(components: Record): void; export declare function registerResponseReferenceFieldType(): void; export declare function removeUnreferencedFiles(store: FileStore | undefined, before: readonly AttachmentAnswer[], after: readonly AttachmentAnswer[]): void; /** Render a block of markdown-lite content (headings, bullets, paragraphs). */ export declare function renderMarkdownContent(content: string): default_2.ReactNode; /** Render one line of inline markdown (no block structure). */ export declare function renderMarkdownInline(text: string): default_2.ReactNode[]; /** Reference assignment is host-owned; following it remains possible in read-only forms. */ export declare function ResponseReferenceField({ response, isPreview, }: FieldComponentProps): default_2.JSX.Element; /** The host supplies safe display metadata; this component never loads answers. */ export declare function ResponseReferenceLink({ reference, resolver: resolverProp, onNavigate: navigateProp, className, }: ResponseReferenceLinkProps): default_2.JSX.Element; export declare interface ResponseReferenceLinkProps { reference: ResponseReference; resolver?: ResponseReferenceResolver; onNavigate?: ResponseReferenceNavigate; className?: string; } export declare function ResponseReferenceProvider({ resolver, onNavigate, children, }: ResponseReferenceProviderProps): default_2.JSX.Element; export declare interface ResponseReferenceProviderProps extends Host { children: default_2.ReactNode; } /** * SectionField - Renders section header and empty state. * Canvas manages rendering nested children. */ export declare const SectionField: default_2.NamedExoticComponent; declare type SectionFieldProps = FieldComponentProps & { nestedChildren?: default_2.ReactNode; }; export declare const SignatureField: default_2.NamedExoticComponent; export declare const SingleMatrixField: default_2.NamedExoticComponent; declare interface SingleSelectProps { options: readonly DropdownOption[]; value: string | null; onChange: (selectedId: string | null) => void; placeholder?: string; showClearOption?: boolean; maxHeight?: string; isMulti?: false; disabled?: boolean; } declare const SIZES: { readonly sm: { readonly outer: 20; readonly inner: 10; }; readonly md: { readonly outer: 24; readonly inner: 12; }; readonly lg: { readonly outer: 36; readonly inner: 18; }; }; declare const SIZES_2: { readonly sm: { readonly outer: 20; readonly inner: 12; }; readonly md: { readonly outer: 24; readonly inner: 16; }; readonly lg: { readonly outer: 36; readonly inner: 24; }; }; export declare const SliderField: default_2.NamedExoticComponent; export declare function storeFiles(store: FileStore, files: readonly FileInput[]): Promise; /** One stroke captured during a drawing session. */ export declare interface Stroke { tool: 'pen' | 'eraser'; color: string; size: number; /** All points stored as normalized coordinates so the drawing scales losslessly. */ points: NormalizedPoint[]; } export declare const TextField: default_2.NamedExoticComponent; export declare interface TouchModeConfig { /** Touch mode setting: true = always on, false = always off, 'auto' = media query based */ mode?: boolean | 'auto'; /** Called when touch mode changes */ onChange?: (enabled: boolean) => void; } export declare interface TouchModeState { /** Whether touch mode is currently enabled */ isTouchEnabled: boolean; /** Whether user has manually overridden auto mode */ isManualOverride: boolean; /** Toggle touch mode on/off. Only works when mode is 'auto' or undefined. */ setTouchMode: (enabled: boolean) => void; /** Reset to auto-detection mode (clears manual override). Only works when mode='auto'. */ resetTouchMode: () => void; } export declare const TrashIcon: default_2.MemoExoticComponent<({ className }: IconProps) => default_2.JSX.Element>; export declare const UIContext: default_2.Context< StoreApi | null>; export declare const UpDownArrowIcon: default_2.MemoExoticComponent<({ className }: IconProps) => default_2.JSX.Element>; export declare function useFieldGridLayout(): boolean; export declare function useFileStore(): FileStore | undefined; /** Hook to access the FormStore from context. */ export declare function useFormStore(): FormStore; /** * Hook to manage touch mode state with auto-detection support. * * @param config - Configuration object * @returns Touch mode state and control methods * * @example * ```tsx * const { isTouchEnabled, setTouchMode, resetTouchMode } = useTouchMode({ * mode: 'auto', * onChange: (enabled) => console.log('Touch mode:', enabled), * }); * ``` */ export declare function useTouchMode(config?: TouchModeConfig): TouchModeState; /** Hook to access the UIStore from context. */ export declare function useUI(): UIStore; /** The Wikipedia opensearch endpoint used as the friendly default data source. */ export declare const WIKIPEDIA_OPENSEARCH_URL = "https://en.wikipedia.org/w/api.php?action=opensearch&search={query}&limit=8&format=json&origin=*"; /** * Reusable, field-style panel for displaying one or more Zod validation issues. */ export declare function ZodIssuesPanel({ title, issues, hint, className, variant, }: ZodIssuesPanelProps): JSX.Element | null; export declare interface ZodIssuesPanelProps { title?: string; issues: readonly string[]; hint?: string; className?: string; variant?: ZodIssuesPanelVariant; } export declare type ZodIssuesPanelVariant = 'error' | 'warning' | 'info' | 'success'; export { }