Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
661 changes: 77 additions & 584 deletions packages/survey-core/src/base-interfaces.ts

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions packages/survey-core/src/interfaces/data-interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { Base } from "../base";
import type { IQuestion } from "../base-interfaces";

export interface ISurveyVariables {
getVariable(name: string): any;
setVariable(name: string, newValue: any): void;
}
export interface ISurveyDataGetEditingObj {
getEditingSurveyElement(): Base;
}
export interface ISurveyData {
getValue(name: string): any;
setValue(name: string, newValue: any, locNotification: boolean | "text", allowNotifyValueChanged?: boolean, questionName?: string): any;
getComment(name: string): string;
setComment(name: string, newValue: string, locNotification: boolean | "text"): any;
getFilteredProperties(): any;
findQuestionByName(name: string): IQuestion;
}
export interface ITextProcessorProp {
text: string;
returnDisplayValue?: boolean;
doEncoding?: boolean;
runAtDesign?: boolean;
replaceUndefinedValues?: boolean;
context?: Base;
}
export interface ITextProcessorResult {
text: string;
hasAllValuesOnLastRun: boolean;
}
export interface ITextProcessor {
processText(text: string, returnDisplayValue: boolean): string;
processTextEx(params: ITextProcessorProp): ITextProcessorResult;
}
129 changes: 129 additions & 0 deletions packages/survey-core/src/interfaces/element-interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import type { HashTable } from "../helpers";
import type { LocalizableString } from "../localizablestring";
import type { AdaptiveActionContainer } from "../actions/adaptive-container";
import type { PanelLayoutColumnModel } from "../panel-layout-column";
import type { ISurveyImpl } from "./survey-interfaces";
import type { ISurveyErrorOwner } from "./validation-interfaces";
import type { IElementUIState } from "./ui-interfaces";

export interface IConditionRunner {
runCondition(properties: HashTable<any>): any;
}
export interface IShortcutText {
shortcutText: string;
}
export interface ISurveyElement extends IShortcutText {
name: string;
isVisible: boolean;
isReadOnly: boolean;
isPage: boolean;
isPanel: boolean;
isQuestion: boolean;
containsErrors: boolean;
parent: IPanel;
skeletonComponentName: string;
setSurveyImpl(value: ISurveyImpl, isLight?: boolean): any;
onSurveyLoad(): any;
onFirstRendering(): any;
getType(): string;
setVisibleIndex(value: number): number;
locStrsChanged(): any;
delete(doDispose?: boolean): void;
toggleState(): void;
stateChangedCallback(): void;
getTitleToolbar(): AdaptiveActionContainer;
isCollapsed: boolean;
isExpanded: boolean;
expand(): void;
collapse(): void;
uiState: IElementUIState;
}
export interface IElement extends IConditionRunner, ISurveyElement {
visible: boolean;
renderWidth: string;
width: string;
minWidth?: string;
maxWidth?: string;
isExpanded: boolean;
isCollapsed: boolean;
rightIndent: number;
startWithNewLine: boolean;
colSpan?: number;
registerPropertyChangedHandlers(propertyNames: Array<string>, handler: any, key: string): void;
registerFunctionOnPropertyValueChanged(name: string, func: any, key: string): void;
unRegisterFunctionOnPropertyValueChanged(name: string, key: string): void;
getPanels(): Array<IPanel>;
getLayoutType(): string;
isLayoutTypeSupported(layoutType: string): boolean;
removeElement(el: IElement): boolean;
onAnyValueChanged(name: string, questionName: string): void;
updateCustomWidgets(): any;
clearIncorrectValues(): any;
clearErrors(): any;
dispose(): void;
needResponsiveWidth(): boolean;
updateRootStyle(): void;
updateElementVisibility(): void;
ensureRowsVisibility(): void;
}

export interface IQuestion extends IElement, ISurveyErrorOwner {
hasTitle: boolean;
isEmpty(): boolean;
onSurveyValueChanged(newValue: any): any;
updateValueFromSurvey(newValue: any, clearData: boolean): void;
updateCommentFromSurvey(newValue: any): any;
supportAutoAdvance(): boolean;
clearUnusedValues(): any;
getDisplayValue(keysAsText: boolean, value: any): any;
getValueName(): string;
clearValue(): any;
clearValueIfInvisible(): any;
isAnswerCorrect(): boolean;
updateValueWithDefaults(): any;
getQuestionFromArray(name: string, index: number): IQuestion;
value: any;
survey: any;
}
export interface IParentElement {
addElement(element: IElement, index: number): any;
removeElement(element: IElement): boolean;
isReadOnly: boolean;
}

export interface IPanel extends ISurveyElement, IParentElement {
getChildrenLayoutType(): string;
getQuestionTitleLocation(): string;
getQuestionTitleWidth(): string;
getQuestionStartIndex(): string;
getQuestionErrorLocation(): string;
getColumsForElement(el: IElement): Array<PanelLayoutColumnModel>;
updateColumns(): void;
parent: IPanel;
elementWidthChanged(el: IElement): any;
indexOf(el: IElement): number;
elements: Array<IElement>;
ensureRowsVisibility(): void;
validateContainerOnly(): void;
}
export interface IPage extends IPanel, IConditionRunner {
isStartPage: boolean;
}
export interface ITitleOwner {
name: string;
no: string;
requiredMark: string;
cssTitleNumber: string;
cssRequiredMark?: string;
isRequireTextOnStart: boolean;
isRequireTextBeforeTitle: boolean;
isRequireTextAfterTitle: boolean;
locTitle: LocalizableString;
locRenderedTitle: LocalizableString;
}
export interface IProgressInfo {
questionCount: number;
answeredQuestionCount: number;
requiredQuestionCount: number;
requiredAnsweredQuestionCount: number;
}
55 changes: 55 additions & 0 deletions packages/survey-core/src/interfaces/serialization-interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { Base } from "../base";
import type { LocalizableString } from "../localizablestring";

export interface IValueItemCustomPropValues {
propertyName: string;
values: Array<any>;
}

export interface IFindElement {
element: Base;
str: LocalizableString;
}

export interface IPlainDataOptions {
includeEmpty?: boolean;
includeQuestionTypes?: boolean;
includeValues?: boolean;
calculations?: Array<{
propertyName: string,
}>;
}
export interface ILoadFromJSONOptions {
validatePropertyValues?: boolean;
}
/**
* An interface with configuration options that control how a `SurveyModel` instance is serialized by the [`toJSON()`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#toJSON) method.
*/
export interface ISaveToJSONOptions {
/**
* Specifies whether the exported JSON schema should include properties whose values are equal to their defaults.
*
* Default value: `false`
*/
storeDefaults?: boolean;
version?: string;
/**
* Specifies how locale-specific strings are handled during JSON export.
*
* Possible values:
*
* - `true` (default)\
* Export the full JSON schema, including all locale strings. Use the [`locales`](#locales) array to restrict the output to specific locales.
* - `false`\
* Export the JSON schema without any textual content.
* - `"stringsOnly"`\
* Export a JSON schema that contains only locale strings and the minimal set of properties required to identify survey elements. Use the [`locales`](#locales) array to restrict the output to specific locales. To apply a locale-strings-only schema to a survey model, call the [`mergeLocalizationJSON(json, locales)`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#mergeLocalizationJSON) method.
*
* > As an alternative to calling `toJSON()` with `"stringsOnly"`, you can call the [`getLocalizationJSON(locales)`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#getLocalizationJSON) method, which is syntactic sugar.
*/
storeLocaleStrings?: boolean | "stringsOnly";
/**
* Specifies the locales to include in the exported JSON schema. Applies only when [`storeLocaleStrings`](#storeLocaleStrings) is `true` or `"stringsOnly"`.
*/
locales?: Array<string>;
}
140 changes: 140 additions & 0 deletions packages/survey-core/src/interfaces/survey-callbacks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import type { Base } from "../base";
import type { SurveyError } from "../survey-error";
import type { CreateCustomChoiceItemEvent } from "../survey-events-api";
import type {
IElement,
IPage,
IPanel,
IQuestion,
ISurveyElement,
IValueItemCustomPropValues,
} from "../base-interfaces";

/**
* Callbacks for element lifecycle events (question/panel/page add, remove, rename, visibility).
*/
export interface ISurveyElementLifecycle {
questionCreated(question: IQuestion): any;
questionAdded(
question: IQuestion,
index: number,
parentPanel: any,
rootPanel: any
): any;
panelAdded(
panel: IElement,
index: number,
parentPanel: any,
rootPanel: any
): any;
questionRemoved(question: IQuestion): any;
panelRemoved(panel: IElement): any;
questionRenamed(
question: IQuestion,
oldName: string,
oldValueName: string
): any;
pageVisibilityChanged(page: IPage, newValue: boolean): any;
panelVisibilityChanged(panel: IPanel, newValue: boolean): any;
questionVisibilityChanged(question: IQuestion, newValue: boolean, resetIndexes: boolean): any;
elementContentVisibilityChanged(element: ISurveyElement): void;
}
/**
* Callbacks for file upload, download, removal, and file chooser operations.
*/
export interface ISurveyFileCallbacks {
uploadFiles(
question: IQuestion,
name: string,
files: File[],
uploadingCallback: (data: any | Array<any>, errors?: any | Array<any>) => any,
sourceType?: string
): any;
downloadFile(
question: IQuestion,
name: string,
content: string,
callback: (status: string, data: any) => any
): any;
clearFiles(
question: IQuestion,
name: string,
value: any,
fileName: string,
clearCallback: (status: string, data: any) => any
): any;
chooseFiles(input: HTMLInputElement, callback: (files: File[]) => void, context?: { element: Base, item?: any, elementType?: string, propertyName?: string }): void;
}
/**
* Callbacks for matrix question events (row/cell add, remove, validate, render).
*/
export interface ISurveyMatrixCallbacks {
matrixRowAdded(question: IQuestion, row: any): any;
matrixColumnAdded(question: IQuestion, column: any): void;
matrixBeforeRowAdded(options: {
question: IQuestion,
canAddRow: boolean,
}): any;
matrixRowRemoved(question: IQuestion, rowIndex: number, row: any): any;
matrixRowRemoving(question: IQuestion, rowIndex: number, row: any): boolean;
matrixAllowRemoveRow(question: IQuestion, rowIndex: number, row: any): boolean;
matrixDetailPanelVisibleChanged(question: IQuestion, rowIndex: number, row: any, visible: boolean): void;
matrixCellCreating(question: IQuestion, options: any): any;
matrixCellCreated(question: IQuestion, options: any): any;
matrixAfterCellRender(options: any): any;
matrixCellValueChanged(question: IQuestion, options: any): any;
matrixCellValueChanging(question: IQuestion, options: any): any;
matrixCellValidate(question: IQuestion, options: any): SurveyError;
matrixDragHandleArea: string;
}
/**
* Callbacks for dynamic panel events (add, remove, tab title, index change).
*/
export interface ISurveyDynamicPanelCallbacks {
dynamicPanelAdded(question: IQuestion, panelIndex: number, panel: IPanel, updateIndexes: boolean): void;
dynamicPanelRemoved(question: IQuestion, panelIndex: number, panel: IPanel, updateIndexes: boolean): void;
dynamicPanelRemoving(question: IQuestion, panelIndex: number, panel: IPanel): boolean;
dynamicPanelGetTabTitle(question: IQuestion, options: any): any;
dynamicPanelCurrentIndexChanged(question: IQuestion, options: any): void;
}
/**
* Callbacks and settings for choice/select-based questions (choice visibility, display values,
* server-populated choices, custom items).
*/
export interface ISurveyChoiceCallbacks {
storeOthersAsComment: boolean;
/**
* @deprecated Use `clearDisabledChoices` instead.
*/
clearValueOnDisableItems: boolean;
clearDisabledChoices: boolean;
canChangeChoiceItemsVisibility(): boolean;
getChoiceItemVisibility(question: IQuestion, item: any, val: boolean): boolean;
loadQuestionChoices(options: { question: IQuestion, filter: string, skip: number, take: number, setItems: (items: Array<any>, totalCount: number) => void }): void;
getChoiceDisplayValue(options: { question: IQuestion, values: Array<any>, setItems: (displayValues: Array<string>, ...customValues: Array<IValueItemCustomPropValues>) => void }): void;
updateChoicesFromServer(
question: IQuestion,
choices: Array<any>,
serverResult: any
): Array<any>;
loadedChoicesFromServer(question: IQuestion): void;
createCustomChoiceItem(options: CreateCustomChoiceItemEvent);
}
/**
* Callbacks for CSS class updates on questions, panels, pages, and choice items.
*/
export interface ISurveyCssCallbacks {
updateQuestionCssClasses(question: IQuestion, cssClasses: any): any;
updatePanelCssClasses(panel: IPanel, cssClasses: any): any;
updatePageCssClasses(panel: IPanel, cssClasses: any): any;
updateChoiceItemCss(question: IQuestion, options: any): any;
}
/**
* Callbacks fired after rendering questions, panels, and pages.
*/
export interface ISurveyAfterRenderCallbacks {
afterRenderQuestion(question: IQuestion, htmlElement: HTMLElement): any;
afterRenderQuestionInput(question: IQuestion, htmlElement: HTMLElement): any;
afterRenderPanel(panel: IElement, htmlElement: HTMLElement): any;
afterRenderPage(htmlElement: HTMLElement): any;
}
Loading
Loading