/** @module Survey Builder Configuration Panel Controls */ import { ColorScale } from '../color-scales'; import { SerializedQDSIcon } from '../icons'; import { Leaves } from '../nested-types'; /** * Representation of a non-generic section */ export interface AdditionalSectionConfig
= any> { /** * Text which appears above the control */ label: string; /** * A list of controls contained within the configuration panel section */ controls: Control
[];
/**
* An object for configuring logic for the control to conditionally appear.
*/
condition?: Conditions;
/**
* A boolean which declares whether the configuration panel section is expanded or collapsed by default
*/
isExpandedByDefault?: boolean;
/**
* The name of the section
*/
name?: string;
/**
* The tooltip popover text of the section
*/
tooltipText?: string;
}
export interface SingleValueBehaviorControl > extends ControlWithOptions , SingleValueBehaviorControl > extends ControlWithOptions , SingleValueBehaviorControl > extends ControlWithOptions , SingleValueBehaviorControl > extends BaseControl , SingleValueBehaviorControl [];
}
/**
* A numeric text field with a minus (-) and plus (+) button on either side, which can be used to decrement or increment the value.
*/
export interface StepperControl > extends BaseControl , SingleValueBehaviorControl > extends BaseControl {
/**
* This value indicates the type of control in use
*/
type: 'button';
/**
* A configuration object for defining the button's behavior
*/
behavior: NamedActionBehaviorControl;
}
/**
* A button which fires a callback function when pressed.
* It also displays an icon to the left of the button text.
*/
export interface TextIconButtonControl > extends BaseControl {
/**
* This value indicates the type of control in use
*/
type: 'textIconButton';
/**
* A QDS icon serialized to a string. Icons can be found at https://designsystem.qualtrics.com/icon
*/
icon: SerializedQDSIcon;
/**
* A configuration object for defining the button's behavior
*/
behavior: NamedActionBehaviorControl;
}
/**
* An informative element that just shows text and optionally an icon.
*/
export interface TextIconInfo > extends BaseControl {
/**
* This value indicates the type of control in use
*/
type: 'textIconInfo';
/**
* Informative plain text to be shown
*/
label: string;
/**
* Optional: A QDS icon serialized to a string. Icons can be found at https://designsystem.qualtrics.com/icon
*/
icon?: SerializedQDSIcon;
}
/**
* A text field control
*/
export interface TextFieldControl > extends BaseControl , SingleValueBehaviorControlWithValidation > extends BaseControl , SingleValueBehaviorControl > extends BaseControl {
/**
* This value indicates the type of control in use
*/
type: 'numberRange';
labels: {
/**
* The label for the left number field
*/
left: string;
/**
* The label for the right number field
*/
right: string;
};
/**
* A configuration object for defining the number range control's behavior
*/
behavior: {
/**
* A callback function to be fired when the user interacts with the control
*/
action?: (leftVal: number, rightVal: number) => Promise > extends BaseControl , SingleValueBehaviorControl > extends BaseControl {
/**
* This value indicates the type of control in use
*/
type: 'colorScheme';
/**
* A configuration object for defining the color scheme control's behavior
*/
behavior: {
/**
* A callback function to be fired when the user interacts with the control
*/
action: (newScale: ColorScale) => Promise > extends BaseControl , SingleValueBehaviorControl > {
/**
* Text which appears above the control
*/
label?: string;
/**
* A string representing the json path where the property will be stored inside question.QuestionTypePluginProperties.AdditionalProperties.
* The json path is represented by concatenating the keys together with the period "." character. For this reason, object keys with a period may misbehave.
*
* If your control overrides the action and getPropertyValue behaviors for this control, you will simply need to make this string something unique.
*/
property: K;
/**
* An object for configuring logic for the control to conditionally appear.
*/
condition?: Conditions;
/**
* An object for configuring logic for the control to conditionally be disabled.
*/
disableControl?: {
/**
* A callback function which returns `true` if the control should be disabled
*/
isDisabled: CustomConditionFunction;
/**
* A unique identifier string
*/
property: string;
};
/**
* Descriptor for the size, formatting, and indentation of the control and its labels.
* L1 elements may contain L2 elements. L2 elements may contain L3 elements. L3 elements may contain L4 elements.
*/
elementType: 'l1' | 'l2' | 'l3' | 'l4';
}
/**
* A control for choosing a secure credential to use within your question
* Note: the property value of this control will be stored as a key in the QuestionTypePluginProperties.Credentials object rather than in QuestionTypePluginProperties.AdditionalProperties.
*/
interface AuthenticationControl > extends BaseControl {
type: 'authentication';
}
export type CustomConditionFunction = () => Promise = any> = DropdownControl | MultiDropdownControl | RadioControl | StepperControl | ButtonControl | TextIconButtonControl | TextIconInfo | ToggleControl | TextFieldControl | CheckBoxControl | NumberRangeControl | TextSizeControl | ColorSchemeControl | PipedTextControl | AuthenticationControl ;
/**
* An array of all supported control types. Used for control sanitization.
* Must manually append new controls to this list since TS does not
* currently support instantiating an array from a union type.
* Source: https://stackoverflow.com/a/45486495
*/
export declare const supportedControlTypes: readonly ["button", "checkBox", "colorScheme", "dropdown", "numberRange", "pipedText", "radio", "stepper", "textField", "textIconButton", "textIconInfo", "textSize", "toggle", "authentication"];
export interface ControlWithOptions > extends BaseControl {
options: Option[];
}
/**
* Representation of a single option for a control.
*/
export interface Option {
/**
* Text which appears for the option
*/
label: string;
/**
* The value associated with the option
*/
value: string;
/**
* An object for configuring logic for the option to conditionally appear.
*/
condition?: Conditions;
}
/**
* This object can be configured to declare the conditions under which a component should appear.
* The only supported mechanism right now is a callback function.
*/
export interface Conditions {
custom: CustomConditionFunction;
}
export {};
//# sourceMappingURL=config-panel-controls.d.ts.map