import { IFrameCloseEvent, IFrameNotShownEvent } from './common'; import { ComponentDefinition } from './component-definition'; const Dropdown = 'Dropdown' as const; const FacesRatingBar = 'FacesRatingBar' as const; const TextInput = 'TextInput' as const; const SegmentedToggle = 'SegmentedToggle' as const; /** * @deprecated use ComponentDefinition */ export type ComponentType = | typeof Dropdown | typeof FacesRatingBar | typeof TextInput | typeof SegmentedToggle; export interface IBaseComponentStructure { // we need to define each row with ID, will be used for BI data questionId: string; type: TType; label: string; placeholder?: string; // NOTE: we decided there are no any validation which means there are no any required field // required: boolean; } export interface ITextInputComponentStructure extends IBaseComponentStructure {} export interface IDropdownComponentStructure extends IBaseComponentStructure { options: { id: string; displayName: string; }[]; } export interface ISegmentedToggleComponentStructure extends IBaseComponentStructure { buttons: { id: 'negative' | 'positive'; displayName: string; }[]; } export interface IFacesRatingBarComponentStructure extends IBaseComponentStructure { tooltips?: [string, string, string, string, string]; } export type IStructure = { TextInput: ITextInputComponentStructure; Dropdown: IDropdownComponentStructure; SegmentedToggle: ISegmentedToggleComponentStructure; FacesRatingBar: IFacesRatingBarComponentStructure; }[TType]; type Prettify = { [K in keyof T]: T[K]; } & {}; type JSONPrimitive = string | number | boolean | null; type JSONValue = JSONPrimitive | JSONObject | JSONArray; type JSONArray = JSONValue[]; interface JSONObject { [prop: string]: JSONValue; } /** * @deprecated use ComponentDefinition */ export type Component = | ITextInputComponentStructure | IDropdownComponentStructure | ISegmentedToggleComponentStructure | IFacesRatingBarComponentStructure; export interface IFeedbackFormStructure { id: string; title: string; components: ComponentDefinition[]; } export type IframePosition = 'center' | 'bottom-right'; export interface IFeedbackFormMetadata { uuid: string; language?: string; debug?: boolean; formVariantId?: string; origin?: string; appDefId?: string; editorType?: string; esi?: string; msid?: string; customFields?: JSONObject; position?: IframePosition; } interface FeedbackLoopOptionsBase extends Omit, IFeedbackFormMetadata { formSetId: string; title?: string; components?: ComponentDefinition[]; } /** * All available options for integrations */ export type FeedbackLoopOptions = Prettify; /** * Helper type for defining options for Public facing APIs */ export type RequestFeedbackLoopOptions = Prettify< Pick< FeedbackLoopOptions, | 'formSetId' | 'formVariantId' | 'origin' | 'title' | 'components' | 'debug' | 'customFields' > >; /** * Helper type for public facing `requestFeedbackLoop` integrations */ export type RequestFeedbackLoop< TOptions extends {} = RequestFeedbackLoopOptions, > = (options: TOptions) => OpenFeedbackFormReturn; /** * Public facing interface */ export type OpenFeedbackFormReturn = Promise< IFrameCloseEvent | IFrameNotShownEvent >;