import 'rollup-plugin-inject-process-env'; import React, { FC } from "react"; import { FormField, FormStep, FormStepIFrame, FormSteps } from "stentor-models"; import { ExternalWidgetConfig } from "../../utils/useExternalWidget"; import "./costguide-overrides.scss"; /** * Local extension of FormStep for the external booking-widget handoff step, * mirroring stentor-models@1.75.0's FormStepExternalWidget. See the note on * FormStepWithUnloadWarning above for why this is redeclared locally. */ export interface FormStepExternalWidget extends FormStep { externalWidget: ExternalWidgetConfig; } export declare function isFormStepIframe(step: FormSteps): step is FormStepIFrame; export declare function isFormStepExternalWidget(step: FormSteps): step is FormStepExternalWidget; export interface StepData { current?: { [key: string]: unknown; }; } type Groupable = T & { mandatoryGroup?: string; }; interface GroupableFieldStep extends FormStep { fields: Groupable[]; } export interface FormStepDisplayProps { /** * Step data */ readonly formStep: FormSteps | GroupableFieldStep; /** * Open a DATETIME field on the soonest day that has times, rather than on * "Select a date to see the available times." For a preview that lands * straight on that step; off by default. */ readonly preselectFirstAvailableDate?: boolean; /** * When the user hits the next button. * * If submit is true, then the form should be submitted. * May return a Promise when a FORM_NEXT server callback is in flight. */ onNextStep: ((submit?: boolean) => Promise | void) | undefined; /** * When the user hits the previous button */ onPrevStep: (() => void) | undefined; /** * Data from the step */ onData: (data: StepData) => void; /** * Data from the step but split up into key, value pairs. * * For example, {"name": "John Smith"} */ onDataWithLabels: (data: object) => void; getData: () => object; /** * Returns the data needed for the form * * @returns */ getDataWithLabels: () => object; /** * Is the form loading */ loading: boolean; /** * Current step index (0-indexed) */ currentStepIndex?: number; /** * Total number of steps in the form */ totalSteps?: number; /** * Callback to track next_step event */ onTrackNextStep?: (stepName: string, stepIndex: number, stepData: Record, isLastStep: boolean) => void; /** * Optional ref to sync current step data for tracking purposes. * This allows parent components to access live form data before step completion. */ currentStepDataRef?: React.MutableRefObject>; /** * Whether this step is the one currently visible. Every step's FormStepDisplay * is mounted at once (FormDisplay toggles visibility via CSS), so this is what * gates the external-widget mount sequence to only run once the step actually * becomes active, rather than for every handoff step on the form's first render. */ isActive?: boolean; /** * True while this step's partner-widget config is still missing the values that only the * FORM_SUBMIT response carries. Injecting before they land hands the partner a config with no * zipCode, name or trade, and one that reads its global at load never sees the real one. */ externalWidgetConfigPending?: boolean; /** * Fired when a booking-widget handoff step's anchor gains content within * its render timeout. */ onTrackHandoffRendered?: (stepName: string, provider: string) => void; /** * Fired when a booking-widget handoff step's render timeout elapses with * an empty anchor. */ onTrackHandoffNoRender?: (stepName: string, provider: string) => void; /** * Fired when the partner script invokes the configured success callback. */ onTrackHandoffScheduled?: (stepName: string, provider: string, payload?: unknown) => void; /** * Fired when a booking-widget handoff step's script fails to load or is rejected. */ onTrackHandoffError?: (stepName: string, provider: string) => void; /** * Fired when a booking-widget handoff step fails to render (timeout or script * error) and `externalWidget.fallbackStep` is set, so the parent can navigate * there. Not fired when fallbackStep is unset -- an inline fallback message is * rendered in place instead. */ onExternalWidgetFallback?: (fallbackStep: string) => void; /** * Message shown when this step's FORM_SUBMIT dispatch failed, so the user knows * their submission did not land and can retry rather than assuming it worked * (issue #1373). Undefined when the step has no failed submit. */ submitError?: string; /** * Suppresses this step's own title/subtitle block. Set when a partner frame is * around the step, since the frame's intro block renders them instead -- and * placement is the frame's decision (it can sit outside the frame entirely). */ hideIntro?: boolean; } export declare const FormStepDisplay: FC; export default FormStepDisplay;