UNPKG

survey-creator-core

Version:

A framework-independent core package of the SurveyJS Survey Creator component. With Survey Creator, you can visually design complex, interactive JSON forms and surveys in a drag-and-drop interface.

311 lines (310 loc) 17.5 kB
import { Base, JsonObjectProperty, PanelModel, PanelModelBase, Question, SurveyModel, MatrixDynamicRowModel, PageModel } from "survey-core"; import { ISurveyCreatorOptions } from "../creator-settings"; import { ISurveyPropertyGridDefinition } from "../question-editor/definition"; import { QuestionFileEditorModel } from "../custom-questions/question-file"; export interface IPropertyEditorSetup { editSurvey: SurveyModel; apply(): boolean; } export declare function setSurveyJSONForPropertyGrid(json: any, updateOnTyping?: boolean, titleLocationLeft?: boolean): void; export declare abstract class PropertyEditorSetupValue implements IPropertyEditorSetup { protected options: ISurveyCreatorOptions; private editSurveyValue; constructor(options?: ISurveyCreatorOptions, doSetup?: boolean); protected setupSurvey(): void; get editSurvey(): SurveyModel; hasErrors(): boolean; protected createSurvey(): SurveyModel; protected abstract getSurveyJSON(): any; protected abstract getSurveyCreationReason(): string; abstract apply(): boolean; dispose(): void; } export interface IPropertyGridEditor { fit(prop: JsonObjectProperty, context?: string): boolean; isDefault?: () => boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions, propGridDefinition?: ISurveyPropertyGridDefinition): any; showModalPropertyEditor?: (editor: IPropertyGridEditor, property: JsonObjectProperty, question: Question, options: ISurveyCreatorOptions) => void; onCreated?: (obj: Base, question: Question, prop: JsonObjectProperty, options: ISurveyCreatorOptions, propGridDefinition?: ISurveyPropertyGridDefinition) => void; onSetup?: (obj: Base, question: Question, prop: JsonObjectProperty, options: ISurveyCreatorOptions) => void; validateValue?: (obj: Base, question: Question, prop: JsonObjectProperty, val: any) => string; onAfterRenderQuestion?: (obj: Base, prop: JsonObjectProperty, evtOptions: any) => void; createPropertyEditorSetup?: (obj: Base, prop: JsonObjectProperty, question: Question, options: ISurveyCreatorOptions) => IPropertyEditorSetup; isPropertyEditorSetupEnabled?: (obj: Base, prop: JsonObjectProperty, question: Question, options: ISurveyCreatorOptions) => boolean; canClearPropertyValue?: (obj: Base, prop: JsonObjectProperty, question: Question, options: ISurveyCreatorOptions) => boolean; clearPropertyValue?: (obj: Base, prop: JsonObjectProperty, question: Question, options: ISurveyCreatorOptions) => void; onValueChanged?: (obj: Base, prop: JsonObjectProperty, question: Question) => void; onValueChanging?: (obj: Base, prop: JsonObjectProperty, question: Question, options: any) => void; onMasterValueChanged?: (obj: Base, prop: JsonObjectProperty, question: Question) => void; onAddIntoPropertyValue?: (obj: Base, prop: JsonObjectProperty, question: Question, options: ISurveyCreatorOptions) => void; onMatrixCellCreated?: (obj: Base, options: any) => void; onMatrixCellValidate?: (obj: Base, options: any) => void; onMatrixCellValueChanged?: (obj: Base, options: any) => void; onMatrixAllowRemoveRow?: (obj: Base, row: any) => boolean; onGetQuestionTitleActions?: (obj: Base, options: any, creator: ISurveyCreatorOptions) => void; onUpdateQuestionCssClasses?: (obj: Base, options: any) => void; } export declare var PropertyGridEditorCollection: { editors: IPropertyGridEditor[]; fitHash: {}; clearHash(): void; register(editor: IPropertyGridEditor): void; getEditor(prop: JsonObjectProperty, context?: string): IPropertyGridEditor; isEditorFit(prop: JsonObjectProperty, asDefault?: boolean): IPropertyGridEditor; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions, context?: string, propGridDefinition?: ISurveyPropertyGridDefinition): any; onCreated(obj: Base, question: Question, prop: JsonObjectProperty, options: ISurveyCreatorOptions, propGridDefinition?: ISurveyPropertyGridDefinition): any; onSetup(obj: Base, question: Question, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; validateValue(obj: Base, question: Question, prop: JsonObjectProperty, value: any): string; onAfterRenderQuestion(obj: Base, prop: JsonObjectProperty, evtOptions: any): void; onMatrixCellCreated(obj: Base, prop: JsonObjectProperty, options: any): void; onMatrixCellValidate(obj: Base, prop: JsonObjectProperty, options: any): void; onMatrixCellValueChanged(obj: Base, prop: JsonObjectProperty, options: any): void; onMatrixAllowRemoveRow(obj: Base, prop: JsonObjectProperty, row: MatrixDynamicRowModel): boolean; onGetMatrixRowAction(obj: Base, prop: JsonObjectProperty, options: any, setObjFunc: (obj: Base) => void): void; onUpdateQuestionCssClasses(obj: Base, prop: JsonObjectProperty, options: any): void; onGetQuestionTitleActions(obj: Base, prop: JsonObjectProperty, options: any, creator: ISurveyCreatorOptions): void; onValueChanged(obj: Base, prop: JsonObjectProperty, question: Question): void; onValueChanging(obj: Base, prop: JsonObjectProperty, question: Question, options: any): void; onMasterValueChanged(obj: Base, prop: JsonObjectProperty, question: Question): void; }; export declare class PropertyGridTitleActionsCreator { obj: Base; private options; constructor(obj: Base, options: ISurveyCreatorOptions); onGetQuestionTitleActions(options: any): void; onValueChanged(obj: any, property: JsonObjectProperty, question: Question): void; private createClearValueAction; private createEditorSetupAction; private createPropertyHelpAction; private getHelpActionIconName; } export declare class PropertyJSONGenerator { obj: Base; private options; private parentObj; private parentProperty; private propertyGridDefinition; static isPropertyReadOnly(prop: JsonObjectProperty, options: ISurveyCreatorOptions, obj: Base, parentObj: Base, parentProperty: JsonObjectProperty): boolean; static getClassNameProperty(obj: Base): string; constructor(obj: Base, options?: ISurveyCreatorOptions, parentObj?: Base, parentProperty?: JsonObjectProperty, propertyGridDefinition?: ISurveyPropertyGridDefinition); toJSON(isNested?: boolean, context?: string): any; createColumnsJSON(className: string, names: Array<string>): any; setupObjPanel(panel: PanelModelBase, isNestedObj?: boolean, context?: string): void; setupPages(survey: SurveyModel): void; convertPanelsToPages(json: any): any; private onQuestionsCreated; private getVisibilityOnEvent; private isPropertyReadOnly; private createOverridingQuestion; private getClasPropName; private createJSON; private createPanelProps; private updateQuestionJSONOnSameLine; private createPanelJSON; private createQuestionJSON; private getColumnPropertyJSON; private getPanelTitle; private getQuestionTitle; private isQuestionTitleHidden; } export declare class PropertyGridModel { private surveyValue; private objValue; private optionsValue; private titleActionsCreator; private classNameProperty; private classNameValue; private propertyGridDefinition; currentlySelectedProperty: string; currentlySelectedPanel: PanelModel; currentlySelectedPage: PageModel; onSetNewObjectCallback: () => void; onNewSurveyCreatedCallback: () => void; changedFromActionCallback: (obj: Base, propertyName: string) => void; readonly placeholderPageName = "p1--empty-pg-placeholder-page"; refresh(): void; constructor(obj?: Base, options?: ISurveyCreatorOptions, propertyGridDefinition?: ISurveyPropertyGridDefinition); get obj(): Base; set obj(value: Base); setPropertyGridDefinition(val: ISurveyPropertyGridDefinition): void; selectProperty(propertyName: string, focus?: boolean): void; private setObjFromAction; private setObj; private clearSurveyValue; private createSurveyValue; private onCreateSurvey; private updateCurrentSurveyWithNewDefinition; private updateElementsInPanel; get options(): ISurveyCreatorOptions; set options(val: ISurveyCreatorOptions); get survey(): SurveyModel; showOneCategoryInPropertyGrid: boolean; validate(): boolean; activateCategory(name: string): void; collapseCategory(name: string): void; expandCategory(name: string): void; collapseAllCategories(): void; expandAllCategories(): void; expandCategoryIfNeeded(): void; private getPropertyGridExpandedCategory; private collapseOtherPanels; private collapseAllCategoriesExcept; surveyInstanceCreatedArea: string; protected createSurvey(json: any, callback?: (survey: SurveyModel) => void): SurveyModel; protected getSurveyJSON(): any; private validateQuestionValue; private getErrorTextOnValidate; private onValidateQuestion; private onValueChanging; private isPropNameInValid; private onValueChanged; private changeDependedProperties; private updateDependedPropertiesEditor; private updateDependedPropertiesEditors; private onAfterRenderQuestion; private isCellCreating; private onMatrixCellCreated; private onMatrixCellValueChanging; private onMatrixCellValidate; private onGetMatrixRowAction; private onUpdateQuestionCssClasses; private onGetQuestionTitleActions; private onMatrixCellValueChanged; private getMatrixAllowRemoveRow; private getMatrixOnRowRemoving; private getMatrixAllowEditRow; private calculateMatrixAllowOperations; private onMatrixAllowRemoveRow; private onMatrixRowAdded; } export declare abstract class PropertyGridEditor implements IPropertyGridEditor { constructor(); abstract fit(prop: JsonObjectProperty): boolean; abstract getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions, propGridDefinition?: ISurveyPropertyGridDefinition): any; showModalPropertyEditor(editor: IPropertyGridEditor, property: JsonObjectProperty, question: Question, options: ISurveyCreatorOptions, onClose?: (reason: "apply" | "cancel") => void): void; protected onModalPropertyEditorShown(editor: IPropertyGridEditor, property: JsonObjectProperty, question: Question, options: ISurveyCreatorOptions): void; protected onModalPropertyEditorClosed(editor: IPropertyGridEditor, property: JsonObjectProperty, question: Question, options: ISurveyCreatorOptions, reason: "apply" | "cancel"): void; isSupportGrouping(): boolean; private hasPreviousElementForGrouping; onUpdateQuestionCssClasses(obj: Base, options: any): void; } export declare class PropertyGridEditorBoolean extends PropertyGridEditor { fit(prop: JsonObjectProperty, context?: string): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; isSupportGrouping(): boolean; } export declare class PropertyGridEditorSwitchToggle extends PropertyGridEditor { fit(prop: JsonObjectProperty, context?: string): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; } export declare class PropertyGridEditorUndefinedBoolean extends PropertyGridEditor { fit(prop: JsonObjectProperty, context?: string): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; onCreated(obj: Base, question: Question, prop: JsonObjectProperty, options: ISurveyCreatorOptions, propGridDefinition?: ISurveyPropertyGridDefinition): void; onSetup(obj: Base, question: Question, prop: JsonObjectProperty, options: ISurveyCreatorOptions): void; } export declare abstract class PropertyGridEditorStringBase extends PropertyGridEditor { protected updateMaxLength(prop: JsonObjectProperty, json: any): any; protected updateType(prop: JsonObjectProperty, obj: Base, json: any): any; onCreated(obj: Base, question: Question, prop: JsonObjectProperty, options: ISurveyCreatorOptions): void; } export declare class PropertyGridEditorString extends PropertyGridEditorStringBase { fit(prop: JsonObjectProperty): boolean; isDefault(): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; validateValue(obj: Base, question: Question, prop: JsonObjectProperty, val: any): string; } export declare class PropertyGridEditorDateTime extends PropertyGridEditor { fit(prop: JsonObjectProperty): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; } export declare class PropertyGridLinkEditor extends PropertyGridEditor { fit(prop: JsonObjectProperty): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; onCreated(obj: Base, question: QuestionFileEditorModel, prop: JsonObjectProperty, options: ISurveyCreatorOptions): void; validateValue(obj: Base, question: Question, prop: JsonObjectProperty, val: any): string; } export declare class PropertyGridEditorColor extends PropertyGridEditor { fit(prop: JsonObjectProperty): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; onCreated(obj: Base, question: Question, prop: JsonObjectProperty): void; } export declare class PropertyGridEditorColorWithAlpha extends PropertyGridEditor { fit(prop: JsonObjectProperty): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; onCreated(obj: Base, question: Question, prop: JsonObjectProperty): void; } export declare class PropertyGridEditorNumber extends PropertyGridEditor { fit(prop: JsonObjectProperty): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; onValueChanging(obj: Base, prop: JsonObjectProperty, question: Question, options: any): void; } export declare class PropertyGridEditorSpinEdit extends PropertyGridEditor { fit(prop: JsonObjectProperty): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; } export declare class PropertyGridEditorImageSize extends PropertyGridEditorString { fit(prop: JsonObjectProperty): boolean; isDefault(): boolean; onCreated(obj: Base, question: Question, prop: JsonObjectProperty, options: ISurveyCreatorOptions): void; } export declare class PropertyGridEditorText extends PropertyGridEditorStringBase { fit(prop: JsonObjectProperty): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; } export declare class PropertyGridEditorHtml extends PropertyGridEditorStringBase { fit(prop: JsonObjectProperty): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; } export declare class PropertyGridEditorStringArray extends PropertyGridEditor { fit(prop: JsonObjectProperty): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; onCreated(obj: Base, question: Question, prop: JsonObjectProperty): void; } export declare class PropertyGridEditorDropdown extends PropertyGridEditor { fit(prop: JsonObjectProperty): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; private getChoices; private updateObjBasedOnEmptyValueItem; protected get canRenderAsButtonGroup(): boolean; protected renderAsButtonGroup(prop: JsonObjectProperty, choices: Array<any>): boolean; onCreated(obj: Base, question: Question, prop: JsonObjectProperty): void; onMasterValueChanged(obj: Base, prop: JsonObjectProperty, question: Question): void; private setChoicesCore; private isLocaleProp; private getLocalizedText; private choicesFromPropChoices; private getJsonItem; private setChoices; private getEmptyJsonItemValue; } export declare class PropertyGridEditorSet extends PropertyGridEditorDropdown { fit(prop: JsonObjectProperty): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; } export declare class PropertyGridEditorPage extends PropertyGridEditorDropdown { fit(prop: JsonObjectProperty): boolean; protected get canRenderAsButtonGroup(): boolean; onCreated(obj: Base, question: Question, prop: JsonObjectProperty): void; } export declare class PropertyGridEditorQuestion extends PropertyGridEditor { fit(prop: JsonObjectProperty): boolean; getJSON(obj: Base, prop: JsonObjectProperty, options: ISurveyCreatorOptions): any; private getChoices; protected getQuestions(survey: SurveyModel, obj: Base): Array<Question>; protected getItemValue(question: Question): any; } export declare class PropertyGridEditorQuestionSelectBase extends PropertyGridEditorQuestion { fit(prop: JsonObjectProperty): boolean; protected isQuestionFit(question: Question): boolean; protected getQuestions(survey: SurveyModel, obj: Base): Array<Question>; } export declare class PropertyGridEditorQuestionCarryForward extends PropertyGridEditorQuestionSelectBase { fit(prop: JsonObjectProperty): boolean; protected isQuestionFit(question: Question): boolean; } export declare class PropertyGridEditorQuestionValue extends PropertyGridEditorQuestion { fit(prop: JsonObjectProperty): boolean; protected getItemValue(question: Question): any; protected getQuestions(survey: SurveyModel, obj: Base): Array<Question>; }