@divkitframework/jsonbuilder
Version:
DivKit TypeScript JSON Builder
1,555 lines (1,493 loc) • 465 kB
TypeScript
declare type Div = DivImage | DivGifImage | DivText | DivSeparator | DivContainer | DivGrid | DivGallery | DivPager | DivTabs | DivState | DivCustom | DivIndicator | DivSlider | DivSwitch | DivInput | DivSelect | DivVideo | TemplateBlock;
declare const expr: unique symbol;
interface DivExpression {
[expr]: string;
}
declare class SafeDivExpression implements DivExpression {
[expr]: string;
constructor(expression: string);
toJSON(): string;
toString(): string;
}
/**
* Root structure.
*/
interface IDivData {
/**
* User functions.
*
* Platforms: ios, web
*/
functions?: NonEmptyArray<IDivFunction>;
/**
* Logging ID.
*/
log_id: string;
/**
* A set of visual element states. Each element can have a few states with a different layout.
* The states are displayed strictly one by one and switched using [action](div-action.md).
*/
states: NonEmptyArray<IDivDataState>;
/**
* List of timers.
*/
timers?: NonEmptyArray<IDivTimer>;
/**
* Events that trigger transition animations.
*
* @deprecated
*
* Platforms: android, ios
*/
transition_animation_selector?: DivTransitionSelector | DivExpression;
/**
* Triggers for changing variables.
*/
variable_triggers?: NonEmptyArray<IDivTrigger>;
/**
* Declaration of variables that can be used in an element.
*/
variables?: NonEmptyArray<DivVariable>;
}
interface IDivDataState {
/**
* Contents.
*/
div: Div;
/**
* State ID.
*/
state_id: number;
}
interface ITemplates {
[type: string]: Div;
}
declare type Type<U, V extends string = string> = U | TemplatePropertyReference<V, U>;
declare class TemplatePropertyReference<V extends string = string, U = {}> {
templatePropertyName: V;
private _value?;
constructor(name: V);
}
declare function reference<V extends string = string, U = {}>(name: V): TemplatePropertyReference<V, U>;
declare class TemplateBlock<T extends string = any, U = object> {
readonly type: T;
readonly _props?: U;
constructor(type: T, props?: U);
getProps(): object;
}
declare function template<T extends string = any, U = object>(type: T, props?: U): TemplateBlock<T, U>;
declare function escapeCard(obj: unknown): unknown;
declare function divCard(templates: ITemplates, card: IDivData): {
templates: ITemplates;
card: IDivData;
};
declare type NonEmptyArray<T> = T[];
declare type Exact<TBase, TExt extends TBase> = TExt extends unknown ? Exactly<TBase, TExt> : never;
declare type Exactly<TBase, TExt extends TBase> = {
[K in keyof TExt]: K extends keyof TBase ? TExt[K] : never;
};
declare type IntBoolean = 1 | 0 | true | false;
/**
* DFS for a js object with callback on each leaf
* @param tree js object
* @param nodeAction callback for each leaf
*/
declare function treeWalkDFS(tree: unknown, nodeAction: (x: unknown, path: string[]) => void): void;
declare function copyTemplates<T extends ITemplates>(templates: T): T;
declare class ArrayValue<T extends ArrayValueProps = ArrayValueProps> {
readonly _props?: Exact<ArrayValueProps, T>;
readonly type = "array";
value: Type<unknown[] | DivExpression>;
constructor(props: Exact<ArrayValueProps, T>);
}
interface ArrayValueProps {
value: Type<unknown[] | DivExpression>;
}
/**
* An arbitrary array in JSON format.
*/
declare class ArrayVariable<T extends ArrayVariableProps = ArrayVariableProps> {
readonly _props?: Exact<ArrayVariableProps, T>;
readonly type = "array";
/**
* Variable name.
*/
name: Type<string>;
/**
* Value. Supports expressions for variable initialization.
*/
value: Type<unknown[] | DivExpression>;
constructor(props: Exact<ArrayVariableProps, T>);
}
interface ArrayVariableProps {
/**
* Variable name.
*/
name: Type<string>;
/**
* Value. Supports expressions for variable initialization.
*/
value: Type<unknown[] | DivExpression>;
}
declare class BooleanValue<T extends BooleanValueProps = BooleanValueProps> {
readonly _props?: Exact<BooleanValueProps, T>;
readonly type = "boolean";
value: Type<boolean | DivExpression>;
constructor(props: Exact<BooleanValueProps, T>);
}
interface BooleanValueProps {
value: Type<boolean | DivExpression>;
}
/**
* A Boolean variable in binary format.
*/
declare class BooleanVariable<T extends BooleanVariableProps = BooleanVariableProps> {
readonly _props?: Exact<BooleanVariableProps, T>;
readonly type = "boolean";
/**
* Variable name.
*/
name: Type<string>;
/**
* Value. Supports expressions for variable initialization.
*/
value: Type<IntBoolean | DivExpression>;
constructor(props: Exact<BooleanVariableProps, T>);
}
interface BooleanVariableProps {
/**
* Variable name.
*/
name: Type<string>;
/**
* Value. Supports expressions for variable initialization.
*/
value: Type<IntBoolean | DivExpression>;
}
declare class ColorValue<T extends ColorValueProps = ColorValueProps> {
readonly _props?: Exact<ColorValueProps, T>;
readonly type = "color";
value: Type<string | DivExpression>;
constructor(props: Exact<ColorValueProps, T>);
}
interface ColorValueProps {
value: Type<string | DivExpression>;
}
/**
* Variable — HEX color as a string.
*/
declare class ColorVariable<T extends ColorVariableProps = ColorVariableProps> {
readonly _props?: Exact<ColorVariableProps, T>;
readonly type = "color";
/**
* Variable name.
*/
name: Type<string>;
/**
* Value. Supports expressions for variable initialization.
*/
value: Type<string | DivExpression>;
constructor(props: Exact<ColorVariableProps, T>);
}
interface ColorVariableProps {
/**
* Variable name.
*/
name: Type<string>;
/**
* Value. Supports expressions for variable initialization.
*/
value: Type<string | DivExpression>;
}
declare class ContentText<T extends ContentTextProps = ContentTextProps> {
readonly _props?: Exact<ContentTextProps, T>;
readonly type = "text";
value: Type<string | DivExpression>;
constructor(props: Exact<ContentTextProps, T>);
}
interface ContentTextProps {
value: Type<string | DivExpression>;
}
declare class ContentUrl<T extends ContentUrlProps = ContentUrlProps> {
readonly _props?: Exact<ContentUrlProps, T>;
readonly type = "url";
value: Type<string | DivExpression>;
constructor(props: Exact<ContentUrlProps, T>);
}
interface ContentUrlProps {
value: Type<string | DivExpression>;
}
declare class DictValue<T extends DictValueProps = DictValueProps> {
readonly _props?: Exact<DictValueProps, T>;
readonly type = "dict";
value: Type<{} | DivExpression>;
constructor(props: Exact<DictValueProps, T>);
}
interface DictValueProps {
value: Type<{} | DivExpression>;
}
/**
* An arbitrary object in JSON format.
*/
declare class DictVariable<T extends DictVariableProps = DictVariableProps> {
readonly _props?: Exact<DictVariableProps, T>;
readonly type = "dict";
/**
* Variable name.
*/
name: Type<string>;
/**
* Value. Supports expressions for variable initialization.
*/
value: Type<{} | DivExpression>;
constructor(props: Exact<DictVariableProps, T>);
}
interface DictVariableProps {
/**
* Variable name.
*/
name: Type<string>;
/**
* Value. Supports expressions for variable initialization.
*/
value: Type<{} | DivExpression>;
}
/**
* Sets margins without regard to screen properties.
*/
interface IDivAbsoluteEdgeInsets {
/**
* Bottom margin.
*/
bottom?: Type<number | DivExpression>;
/**
* Left margin.
*/
left?: Type<number | DivExpression>;
/**
* Right margin.
*/
right?: Type<number | DivExpression>;
/**
* Top margin.
*/
top?: Type<number | DivExpression>;
}
/**
* Accessibility settings.
*/
interface IDivAccessibility {
/**
* Element description. It is used as the main description for screen reading applications.
*/
description?: Type<string | DivExpression>;
/**
* A tooltip of what will happen during interaction. If Speak Hints is enabled in the VoiceOver
* settings on iOS, a tooltip is played after `description`.
*
* Platforms: android, ios, web
*/
hint?: Type<string | DivExpression>;
/**
* Shows the current status of the checkbox or toggle: `true` means it's selected, `false` means
* it isn't selected.
*
* Platforms: ios, web
*/
is_checked?: Type<IntBoolean | DivExpression>;
/**
* The way the accessibility tree is organized. In the `merge` mode the accessibility service
* perceives an element together with a subtree as a whole. In the `exclude` mode an element
* together with a subtree isn't available for accessibility.
*
* Platforms: android, ios, web
*/
mode?: Type<DivAccessibilityMode | DivExpression>;
/**
* Mutes the screen reader sound after interacting with the element.
*
* Platforms: ios
*/
mute_after_action?: Type<IntBoolean | DivExpression>;
/**
* Description of the current state of an element. For example, in the description you can
* specify a selected date for a date selection element and an on/off state for a switch.
*
* Platforms: android, ios, web
*/
state_description?: Type<string | DivExpression>;
/**
* Element role. Used to correctly identify an element by the accessibility service. For example,
* the `list` element is used to group list elements into one element.
*
* Platforms: android, ios, web
*/
type?: Type<DivAccessibilityType>;
}
declare type DivAccessibilityMode = 'default' | 'merge' | 'exclude';
declare type DivAccessibilityType = 'none' | 'button' | 'image' | 'text' | 'edit_text' | 'header' | 'tab_bar' | 'list' | 'select' | 'checkbox' | 'radio' | 'auto';
/**
* It defines an action when clicking on an element.
*/
interface IDivAction {
/**
* Callbacks that are called after data loading.
*/
download_callbacks?: Type<IDivDownloadCallbacks>;
/**
* The parameter disables the action. Disabled actions stop listening to their associated event
* (clicks, changes in visibility, and so on).
*/
is_enabled?: Type<IntBoolean | DivExpression>;
/**
* Logging ID.
*/
log_id: Type<string | DivExpression>;
/**
* URL for logging.
*/
log_url?: Type<string | DivExpression>;
/**
* Context menu.
*/
menu_items?: Type<NonEmptyArray<IDivActionMenuItem>>;
/**
* Additional parameters, passed to the host application.
*/
payload?: Type<{}>;
/**
* Referer URL for logging.
*
* Platforms: android, ios
*/
referer?: Type<string | DivExpression>;
/**
* The ID of the element within which the specified action will be performed.
*
* Platforms: android, ios, web
*/
scope_id?: Type<string>;
/**
* The tab in which the URL must be opened.
*
* Platforms: web
*/
target?: Type<DivActionTarget | DivExpression>;
typed?: Type<DivActionTyped>;
/**
* URL. Possible values: `url` or `div-action://`.
*/
url?: Type<string | DivExpression>;
}
declare type DivActionTarget = '_self' | '_blank';
interface IDivActionMenuItem {
/**
* One action when clicking on a menu item. Not used if the `actions` parameter is set.
*/
action?: Type<IDivAction>;
/**
* Multiple actions when clicking on a menu item.
*/
actions?: Type<NonEmptyArray<IDivAction>>;
/**
* Menu item title.
*/
text: Type<string | DivExpression>;
}
/**
* Launches the specified animator.
*/
declare class DivActionAnimatorStart<T extends DivActionAnimatorStartProps = DivActionAnimatorStartProps> {
readonly _props?: Exact<DivActionAnimatorStartProps, T>;
readonly type = "animator_start";
/**
* ID of the animator launched.
*/
animator_id: Type<string>;
/**
* Animation direction. Determines whether the animation should be played forward, backward, or
* alternate between forward and backward.
*/
direction?: Type<DivAnimationDirection | DivExpression>;
/**
* Animation duration in milliseconds.
*/
duration?: Type<number | DivExpression>;
/**
* Overrides the value that will be set after the animation finishes.
*/
end_value?: Type<DivTypedValue>;
/**
* Animated value interpolation function.
*/
interpolator?: Type<DivAnimationInterpolator | DivExpression>;
/**
* Number of times the animation will repeat before stopping. A value of `0` enables infinite
* looping.
*/
repeat_count?: Type<DivCount>;
/**
* Delay before the animation is launched in milliseconds.
*/
start_delay?: Type<number | DivExpression>;
/**
* Overrides the value that will be set before the animation begins.
*/
start_value?: Type<DivTypedValue>;
constructor(props: Exact<DivActionAnimatorStartProps, T>);
}
interface DivActionAnimatorStartProps {
/**
* ID of the animator launched.
*/
animator_id: Type<string>;
/**
* Animation direction. Determines whether the animation should be played forward, backward, or
* alternate between forward and backward.
*/
direction?: Type<DivAnimationDirection | DivExpression>;
/**
* Animation duration in milliseconds.
*/
duration?: Type<number | DivExpression>;
/**
* Overrides the value that will be set after the animation finishes.
*/
end_value?: Type<DivTypedValue>;
/**
* Animated value interpolation function.
*/
interpolator?: Type<DivAnimationInterpolator | DivExpression>;
/**
* Number of times the animation will repeat before stopping. A value of `0` enables infinite
* looping.
*/
repeat_count?: Type<DivCount>;
/**
* Delay before the animation is launched in milliseconds.
*/
start_delay?: Type<number | DivExpression>;
/**
* Overrides the value that will be set before the animation begins.
*/
start_value?: Type<DivTypedValue>;
}
/**
* Stops the specified animator.
*/
declare class DivActionAnimatorStop<T extends DivActionAnimatorStopProps = DivActionAnimatorStopProps> {
readonly _props?: Exact<DivActionAnimatorStopProps, T>;
readonly type = "animator_stop";
/**
* ID of the animator to be stopped.
*/
animator_id: Type<string>;
constructor(props: Exact<DivActionAnimatorStopProps, T>);
}
interface DivActionAnimatorStopProps {
/**
* ID of the animator to be stopped.
*/
animator_id: Type<string>;
}
/**
* Adds a value to the array
*/
declare class DivActionArrayInsertValue<T extends DivActionArrayInsertValueProps = DivActionArrayInsertValueProps> {
readonly _props?: Exact<DivActionArrayInsertValueProps, T>;
readonly type = "array_insert_value";
index?: Type<number | DivExpression>;
value: Type<DivTypedValue>;
variable_name: Type<string | DivExpression>;
constructor(props: Exact<DivActionArrayInsertValueProps, T>);
}
interface DivActionArrayInsertValueProps {
index?: Type<number | DivExpression>;
value: Type<DivTypedValue>;
variable_name: Type<string | DivExpression>;
}
/**
* Deletes a value from the array
*/
declare class DivActionArrayRemoveValue<T extends DivActionArrayRemoveValueProps = DivActionArrayRemoveValueProps> {
readonly _props?: Exact<DivActionArrayRemoveValueProps, T>;
readonly type = "array_remove_value";
index: Type<number | DivExpression>;
variable_name: Type<string | DivExpression>;
constructor(props: Exact<DivActionArrayRemoveValueProps, T>);
}
interface DivActionArrayRemoveValueProps {
index: Type<number | DivExpression>;
variable_name: Type<string | DivExpression>;
}
/**
* Sets the value in the array by index.
*/
declare class DivActionArraySetValue<T extends DivActionArraySetValueProps = DivActionArraySetValueProps> {
readonly _props?: Exact<DivActionArraySetValueProps, T>;
readonly type = "array_set_value";
index: Type<number | DivExpression>;
value: Type<DivTypedValue>;
variable_name: Type<string | DivExpression>;
constructor(props: Exact<DivActionArraySetValueProps, T>);
}
interface DivActionArraySetValueProps {
index: Type<number | DivExpression>;
value: Type<DivTypedValue>;
variable_name: Type<string | DivExpression>;
}
/**
* Removes focus from an element.
*/
declare class DivActionClearFocus<T extends DivActionClearFocusProps = DivActionClearFocusProps> {
readonly _props?: Exact<DivActionClearFocusProps, T>;
readonly type = "clear_focus";
constructor(props?: Exact<DivActionClearFocusProps, T>);
}
interface DivActionClearFocusProps {
}
/**
* Copies data to the clipboard.
*/
declare class DivActionCopyToClipboard<T extends DivActionCopyToClipboardProps = DivActionCopyToClipboardProps> {
readonly _props?: Exact<DivActionCopyToClipboardProps, T>;
readonly type = "copy_to_clipboard";
content: Type<DivActionCopyToClipboardContent>;
constructor(props: Exact<DivActionCopyToClipboardProps, T>);
}
interface DivActionCopyToClipboardProps {
content: Type<DivActionCopyToClipboardContent>;
}
declare type DivActionCopyToClipboardContent = ContentText | ContentUrl;
/**
* Sets the value in the dictionary by the specified key. Deletes the key if the value is not
* set.
*/
declare class DivActionDictSetValue<T extends DivActionDictSetValueProps = DivActionDictSetValueProps> {
readonly _props?: Exact<DivActionDictSetValueProps, T>;
readonly type = "dict_set_value";
key: Type<string | DivExpression>;
value?: Type<DivTypedValue>;
variable_name: Type<string | DivExpression>;
constructor(props: Exact<DivActionDictSetValueProps, T>);
}
interface DivActionDictSetValueProps {
key: Type<string | DivExpression>;
value?: Type<DivTypedValue>;
variable_name: Type<string | DivExpression>;
}
/**
* Loads additional data in `div-patch` format and updates the current element.
*/
declare class DivActionDownload<T extends DivActionDownloadProps = DivActionDownloadProps> {
readonly _props?: Exact<DivActionDownloadProps, T>;
readonly type = "download";
/**
* Actions in case of unsuccessful loading if the host reported it or the waiting time expired.
*/
on_fail_actions?: Type<NonEmptyArray<IDivAction>>;
/**
* Actions in case of successful loading.
*/
on_success_actions?: Type<NonEmptyArray<IDivAction>>;
/**
* Link for receiving changes.
*/
url: Type<string | DivExpression>;
constructor(props: Exact<DivActionDownloadProps, T>);
}
interface DivActionDownloadProps {
/**
* Actions in case of unsuccessful loading if the host reported it or the waiting time expired.
*/
on_fail_actions?: Type<NonEmptyArray<IDivAction>>;
/**
* Actions in case of successful loading.
*/
on_success_actions?: Type<NonEmptyArray<IDivAction>>;
/**
* Link for receiving changes.
*/
url: Type<string | DivExpression>;
}
/**
* Requests focus for an element. May require a user action on the web.
*/
declare class DivActionFocusElement<T extends DivActionFocusElementProps = DivActionFocusElementProps> {
readonly _props?: Exact<DivActionFocusElementProps, T>;
readonly type = "focus_element";
element_id: Type<string | DivExpression>;
constructor(props: Exact<DivActionFocusElementProps, T>);
}
interface DivActionFocusElementProps {
element_id: Type<string | DivExpression>;
}
/**
* Hides the tooltip.
*/
declare class DivActionHideTooltip<T extends DivActionHideTooltipProps = DivActionHideTooltipProps> {
readonly _props?: Exact<DivActionHideTooltipProps, T>;
readonly type = "hide_tooltip";
/**
* Tooltip ID.
*/
id: Type<string | DivExpression>;
constructor(props: Exact<DivActionHideTooltipProps, T>);
}
interface DivActionHideTooltipProps {
/**
* Tooltip ID.
*/
id: Type<string | DivExpression>;
}
/**
* Scrolls the container by `item_count` or `offset` starting from the current position. If both
* values are specified, the action will be combined. For scrolling back, use negative values.
*/
declare class DivActionScrollBy<T extends DivActionScrollByProps = DivActionScrollByProps> {
readonly _props?: Exact<DivActionScrollByProps, T>;
readonly type = "scroll_by";
/**
* Enables scrolling animation.
*/
animated?: Type<boolean | DivExpression>;
/**
* ID of the element where the action should be performed.
*/
id: Type<string | DivExpression>;
/**
* Number of container elements to scroll through. For scrolling back, use negative values.
*/
item_count?: Type<number | DivExpression>;
/**
* Scrolling distance measured in `dp` from the current position. For scrolling back, use
* negative values. Only applies in `gallery`.
*/
offset?: Type<number | DivExpression>;
/**
* Defines navigation behavior at boundary elements:`clamp`: Stop navigation at the boundary
* element (default)`ring`: Navigate to the start or end, depending on the current element.
*/
overflow?: Type<DivActionScrollByOverflow | DivExpression>;
constructor(props: Exact<DivActionScrollByProps, T>);
}
interface DivActionScrollByProps {
/**
* Enables scrolling animation.
*/
animated?: Type<boolean | DivExpression>;
/**
* ID of the element where the action should be performed.
*/
id: Type<string | DivExpression>;
/**
* Number of container elements to scroll through. For scrolling back, use negative values.
*/
item_count?: Type<number | DivExpression>;
/**
* Scrolling distance measured in `dp` from the current position. For scrolling back, use
* negative values. Only applies in `gallery`.
*/
offset?: Type<number | DivExpression>;
/**
* Defines navigation behavior at boundary elements:`clamp`: Stop navigation at the boundary
* element (default)`ring`: Navigate to the start or end, depending on the current element.
*/
overflow?: Type<DivActionScrollByOverflow | DivExpression>;
}
declare type DivActionScrollByOverflow = 'clamp' | 'ring';
declare type DivActionScrollDestination = OffsetDestination | IndexDestination | StartDestination | EndDestination;
/**
* Scrolls to a position or switches to the container element specified by the `destination`
* parameter.
*/
declare class DivActionScrollTo<T extends DivActionScrollToProps = DivActionScrollToProps> {
readonly _props?: Exact<DivActionScrollToProps, T>;
readonly type = "scroll_to";
/**
* Enables scrolling animation.
*/
animated?: Type<boolean | DivExpression>;
/**
* Defines the scrolling end position:`index`: Scroll to the element with the index provided in
* `value``offset`: Scroll to the position specified in `value` and measured in `dp` from the
* start of the container. Applies only in `gallery`;`start`: Scroll to the container
* start;`end`: Scroll to the container end.
*/
destination: Type<DivActionScrollDestination>;
/**
* ID of the element where the action should be performed.
*/
id: Type<string | DivExpression>;
constructor(props: Exact<DivActionScrollToProps, T>);
}
interface DivActionScrollToProps {
/**
* Enables scrolling animation.
*/
animated?: Type<boolean | DivExpression>;
/**
* Defines the scrolling end position:`index`: Scroll to the element with the index provided in
* `value``offset`: Scroll to the position specified in `value` and measured in `dp` from the
* start of the container. Applies only in `gallery`;`start`: Scroll to the container
* start;`end`: Scroll to the container end.
*/
destination: Type<DivActionScrollDestination>;
/**
* ID of the element where the action should be performed.
*/
id: Type<string | DivExpression>;
}
/**
* Applies a new appearance to the content in `div-state'.
*/
declare class DivActionSetState<T extends DivActionSetStateProps = DivActionSetStateProps> {
readonly _props?: Exact<DivActionSetStateProps, T>;
readonly type = "set_state";
/**
* The path of the state inside `state` that needs to be activated. Set in the format
* `div_data_state_id/id/state_id'. Can be hierarchical:
* `div_data_state_id/id_1/state_id_1/../id_n/state_id_n`. Consists of:`div_data_state_id` — the
* numeric value of the `state_id` of the `state` object in `data`'id` — the `id` value of the
* `state` object`state_id` — the `state_id` value of the `state` object in `state`
*/
state_id: Type<string | DivExpression>;
/**
* Indicates a state change:`true` — the change is temporary and will switch to the original one
* (default value) when the element is recreated`false` — the change is permanent
*
* Platforms: android, ios
*/
temporary?: Type<boolean | DivExpression>;
constructor(props: Exact<DivActionSetStateProps, T>);
}
interface DivActionSetStateProps {
/**
* The path of the state inside `state` that needs to be activated. Set in the format
* `div_data_state_id/id/state_id'. Can be hierarchical:
* `div_data_state_id/id_1/state_id_1/../id_n/state_id_n`. Consists of:`div_data_state_id` — the
* numeric value of the `state_id` of the `state` object in `data`'id` — the `id` value of the
* `state` object`state_id` — the `state_id` value of the `state` object in `state`
*/
state_id: Type<string | DivExpression>;
/**
* Indicates a state change:`true` — the change is temporary and will switch to the original one
* (default value) when the element is recreated`false` — the change is permanent
*
* Platforms: android, ios
*/
temporary?: Type<boolean | DivExpression>;
}
/**
* Temporarily saves the variable in storage.
*/
declare class DivActionSetStoredValue<T extends DivActionSetStoredValueProps = DivActionSetStoredValueProps> {
readonly _props?: Exact<DivActionSetStoredValueProps, T>;
readonly type = "set_stored_value";
/**
* Duration of storage in seconds.
*/
lifetime: Type<number | DivExpression>;
/**
* Name of the saved variable.
*/
name: Type<string | DivExpression>;
/**
* Saved value.
*/
value: Type<DivTypedValue>;
constructor(props: Exact<DivActionSetStoredValueProps, T>);
}
interface DivActionSetStoredValueProps {
/**
* Duration of storage in seconds.
*/
lifetime: Type<number | DivExpression>;
/**
* Name of the saved variable.
*/
name: Type<string | DivExpression>;
/**
* Saved value.
*/
value: Type<DivTypedValue>;
}
/**
* Assigns a value to the variable
*/
declare class DivActionSetVariable<T extends DivActionSetVariableProps = DivActionSetVariableProps> {
readonly _props?: Exact<DivActionSetVariableProps, T>;
readonly type = "set_variable";
value: Type<DivTypedValue>;
variable_name: Type<string | DivExpression>;
constructor(props: Exact<DivActionSetVariableProps, T>);
}
interface DivActionSetVariableProps {
value: Type<DivTypedValue>;
variable_name: Type<string | DivExpression>;
}
/**
* Shows the tooltip.
*/
declare class DivActionShowTooltip<T extends DivActionShowTooltipProps = DivActionShowTooltipProps> {
readonly _props?: Exact<DivActionShowTooltipProps, T>;
readonly type = "show_tooltip";
/**
* Tooltip ID.
*/
id: Type<string | DivExpression>;
/**
* Sets whether the tooltip can be shown again after it’s closed.
*/
multiple?: Type<boolean | DivExpression>;
constructor(props: Exact<DivActionShowTooltipProps, T>);
}
interface DivActionShowTooltipProps {
/**
* Tooltip ID.
*/
id: Type<string | DivExpression>;
/**
* Sets whether the tooltip can be shown again after it’s closed.
*/
multiple?: Type<boolean | DivExpression>;
}
/**
* Sends variables from the container by link. Data sending configuration can be defined by the
* host app. By default, variables are sent as JSON in the request body using the POST method.
*/
declare class DivActionSubmit<T extends DivActionSubmitProps = DivActionSubmitProps> {
readonly _props?: Exact<DivActionSubmitProps, T>;
readonly type = "submit";
/**
* ID of the container with the variables to be sent.
*/
container_id: Type<string | DivExpression>;
/**
* Actions when sending data is unsuccessful.
*/
on_fail_actions?: Type<NonEmptyArray<IDivAction>>;
/**
* Actions when sending data is successful.
*/
on_success_actions?: Type<NonEmptyArray<IDivAction>>;
/**
* HTTP request parameters for configuring the sending of data.
*/
request: Type<IDivActionSubmitRequest>;
constructor(props: Exact<DivActionSubmitProps, T>);
}
interface DivActionSubmitProps {
/**
* ID of the container with the variables to be sent.
*/
container_id: Type<string | DivExpression>;
/**
* Actions when sending data is unsuccessful.
*/
on_fail_actions?: Type<NonEmptyArray<IDivAction>>;
/**
* Actions when sending data is successful.
*/
on_success_actions?: Type<NonEmptyArray<IDivAction>>;
/**
* HTTP request parameters for configuring the sending of data.
*/
request: Type<IDivActionSubmitRequest>;
}
/**
* HTTP request parameters for configuring the sending of data.
*/
interface IDivActionSubmitRequest {
/**
* HTTP request headers. Please note that DivKit does not clean duplicate headers, which can lead
* to errors in request processing. Keep this in mind when assembling actions with complex
* JSON-builders.
*/
headers?: Type<NonEmptyArray<IRequestHeader>>;
/**
* HTTP request method.
*/
method?: Type<RequestMethod | DivExpression>;
/**
* Link for sending data from the container.
*/
url: Type<string | DivExpression>;
}
declare type RequestMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head' | 'options';
interface IRequestHeader {
name: Type<string | DivExpression>;
value: Type<string | DivExpression>;
}
/**
* Controls the timer.
*/
declare class DivActionTimer<T extends DivActionTimerProps = DivActionTimerProps> {
readonly _props?: Exact<DivActionTimerProps, T>;
readonly type = "timer";
/**
* Timer actions:`start` — starts the timer from a stopped state`stop`— stops the timer and
* performs the `onEnd` action`pause` — pauses the timer, saves the current time`resume` —
* restarts the timer after a pause`cancel` — interrupts the timer, resets the time`reset` —
* cancels the timer, then starts it again
*/
action: Type<DivActionTimerAction | DivExpression>;
/**
* Timer ID.
*/
id: Type<string | DivExpression>;
constructor(props: Exact<DivActionTimerProps, T>);
}
interface DivActionTimerProps {
/**
* Timer actions:`start` — starts the timer from a stopped state`stop`— stops the timer and
* performs the `onEnd` action`pause` — pauses the timer, saves the current time`resume` —
* restarts the timer after a pause`cancel` — interrupts the timer, resets the time`reset` —
* cancels the timer, then starts it again
*/
action: Type<DivActionTimerAction | DivExpression>;
/**
* Timer ID.
*/
id: Type<string | DivExpression>;
}
declare type DivActionTimerAction = 'start' | 'stop' | 'pause' | 'resume' | 'cancel' | 'reset';
declare type DivActionTyped = DivActionAnimatorStart | DivActionAnimatorStop | DivActionArrayInsertValue | DivActionArrayRemoveValue | DivActionArraySetValue | DivActionClearFocus | DivActionCopyToClipboard | DivActionDictSetValue | DivActionDownload | DivActionFocusElement | DivActionHideTooltip | DivActionScrollBy | DivActionScrollTo | DivActionSetState | DivActionSetStoredValue | DivActionSetVariable | DivActionShowTooltip | DivActionSubmit | DivActionTimer | DivActionUpdateStructure | DivActionVideo;
/**
* Set values in a variable of type array or dictionary with different nesting.
*/
declare class DivActionUpdateStructure<T extends DivActionUpdateStructureProps = DivActionUpdateStructureProps> {
readonly _props?: Exact<DivActionUpdateStructureProps, T>;
readonly type = "update_structure";
/**
* Path within an array/dictionary where a value needs to be set. Path format: Each path element
* is separated by a '/' symbol.Path elements can be of two types: an index of an element in an
* array, starting from 0 or dictionary keys in the form of arbitrary strings.The path is read
* from left to right, each element determines the transition to the next level of
* nesting.Example path: `key/0/inner_key/1`.
*/
path: Type<string | DivExpression>;
/**
* Value set into dictionary/array.
*/
value: Type<DivTypedValue>;
/**
* Variable name of array or dictionary type.
*/
variable_name: Type<string | DivExpression>;
constructor(props: Exact<DivActionUpdateStructureProps, T>);
}
interface DivActionUpdateStructureProps {
/**
* Path within an array/dictionary where a value needs to be set. Path format: Each path element
* is separated by a '/' symbol.Path elements can be of two types: an index of an element in an
* array, starting from 0 or dictionary keys in the form of arbitrary strings.The path is read
* from left to right, each element determines the transition to the next level of
* nesting.Example path: `key/0/inner_key/1`.
*/
path: Type<string | DivExpression>;
/**
* Value set into dictionary/array.
*/
value: Type<DivTypedValue>;
/**
* Variable name of array or dictionary type.
*/
variable_name: Type<string | DivExpression>;
}
/**
* Manages video playback.
*/
declare class DivActionVideo<T extends DivActionVideoProps = DivActionVideoProps> {
readonly _props?: Exact<DivActionVideoProps, T>;
readonly type = "video";
/**
* Defines the action for the video: `start` — starts playing the video if the video is ready to
* be played, or schedules playback`pause' — stops the video playback
*/
action: Type<DivActionVideoAction | DivExpression>;
/**
* Video ID.
*/
id: Type<string | DivExpression>;
constructor(props: Exact<DivActionVideoProps, T>);
}
interface DivActionVideoProps {
/**
* Defines the action for the video: `start` — starts playing the video if the video is ready to
* be played, or schedules playback`pause' — stops the video playback
*/
action: Type<DivActionVideoAction | DivExpression>;
/**
* Video ID.
*/
id: Type<string | DivExpression>;
}
declare type DivActionVideoAction = 'start' | 'pause';
declare type DivAlignmentHorizontal = 'left' | 'center' | 'right' | 'start' | 'end';
declare type DivAlignmentVertical = 'top' | 'center' | 'bottom' | 'baseline';
/**
* Element animation parameters.
*/
interface IDivAnimation {
/**
* Animation duration in milliseconds.
*/
duration?: Type<number | DivExpression>;
/**
* Final value of an animation.
*/
end_value?: Type<number | DivExpression>;
/**
* Animation speed nature. When the value is set to `spring` — animation of damping fluctuations
* cut to 0.7 with the `damping=1` parameter. Other options correspond to the Bezier
* curve:`linear` — cubic-bezier(0, 0, 1, 1);`ease` — cubic-bezier(0.25, 0.1, 0.25, 1);`ease_in`
* — cubic-bezier(0.42, 0, 1, 1);`ease_out` — cubic-bezier(0, 0, 0.58, 1);`ease_in_out` —
* cubic-bezier(0.42, 0, 0.58, 1).
*/
interpolator?: Type<DivAnimationInterpolator | DivExpression>;
/**
* Animation elements.
*/
items?: Type<NonEmptyArray<IDivAnimation>>;
/**
* Animation type.
*/
name: Type<DivAnimationName | DivExpression>;
/**
* Number of animation repetitions.
*/
repeat?: Type<DivCount>;
/**
* Delay in milliseconds before animation starts.
*/
start_delay?: Type<number | DivExpression>;
/**
* Starting value of an animation.
*/
start_value?: Type<number | DivExpression>;
}
declare type DivAnimationName = 'fade' | 'translate' | 'scale' | 'native' | 'set' | 'no_animation';
declare type DivAnimationDirection = 'normal' | 'reverse' | 'alternate' | 'alternate_reverse';
declare type DivAnimationInterpolator = 'linear' | 'ease' | 'ease_in' | 'ease_out' | 'ease_in_out' | 'spring';
declare type DivAnimator = DivColorAnimator | DivNumberAnimator;
interface IDivAnimatorBase {
/**
* Actions performed when the animation is canceled. For example, when a command with the
* 'animator_stop' type is received.
*/
cancel_actions?: Type<NonEmptyArray<IDivAction>>;
/**
* Animation direction. Determines whether the animation should be played forward, backward, or
* alternate between forward and backward.
*/
direction?: Type<DivAnimationDirection | DivExpression>;
/**
* Animation duration in milliseconds.
*/
duration: Type<number | DivExpression>;
/**
* Actions when the animation is completed.
*/
end_actions?: Type<NonEmptyArray<IDivAction>>;
/**
* Animator ID.
*/
id: Type<string>;
/**
* Animated value interpolation function.
*/
interpolator?: Type<DivAnimationInterpolator | DivExpression>;
/**
* Number of times the animation will repeat before stopping. A value of `0` enables infinite
* looping.
*/
repeat_count?: Type<DivCount>;
/**
* Delay before the animation is launched in milliseconds.
*/
start_delay?: Type<number | DivExpression>;
/**
* Name of the variable being animated.
*/
variable_name: Type<string>;
}
/**
* A set of animations to be applied simultaneously.
*/
declare class DivAppearanceSetTransition<T extends DivAppearanceSetTransitionProps = DivAppearanceSetTransitionProps> {
readonly _props?: Exact<DivAppearanceSetTransitionProps, T>;
readonly type = "set";
/**
* An array of animations.
*/
items: Type<NonEmptyArray<DivAppearanceTransition>>;
constructor(props: Exact<DivAppearanceSetTransitionProps, T>);
}
interface DivAppearanceSetTransitionProps {
/**
* An array of animations.
*/
items: Type<NonEmptyArray<DivAppearanceTransition>>;
}
declare type DivAppearanceTransition = DivAppearanceSetTransition | DivFadeTransition | DivScaleTransition | DivSlideTransition;
/**
* Fixed aspect ratio. The element's height is calculated based on the width, ignoring the
* `height` value.
*/
interface IDivAspect {
/**
* `height = width / ratio`.
*/
ratio: Type<number | DivExpression>;
}
declare type DivBackground = DivLinearGradient | DivRadialGradient | DivImageBackground | DivSolidBackground | DivNinePatchBackground;
interface IDivBase {
/**
* Accessibility settings.
*
* Platforms: android, ios, web
*/
accessibility?: Type<IDivAccessibility>;
/**
* Horizontal alignment of an element inside the parent element.
*/
alignment_horizontal?: Type<DivAlignmentHorizontal | DivExpression>;
/**
* Vertical alignment of an element inside the parent element.
*/
alignment_vertical?: Type<DivAlignmentVertical | DivExpression>;
/**
* Sets transparency of the entire element: `0` — completely transparent, `1` — opaque.
*/
alpha?: Type<number | DivExpression>;
/**
* Declaration of animators that change variable values over time.
*
* Platforms: android, ios, web
*/
animators?: Type<NonEmptyArray<DivAnimator>>;
/**
* Element background. It can contain multiple layers.
*/
background?: Type<NonEmptyArray<DivBackground>>;
/**
* Element stroke.
*/
border?: Type<IDivBorder>;
/**
* Merges cells in a column of the [grid](div-grid.md) element.
*
* Platforms: android, ios, web
*/
column_span?: Type<number | DivExpression>;
/**
* Actions when an element disappears from the screen.
*
* Platforms: android, ios, web
*/
disappear_actions?: Type<NonEmptyArray<IDivDisappearAction>>;
/**
* Extensions for additional processing of an element. The list of extensions is given in
* [DivExtension](../../extensions).
*
* Platforms: android, ios, web
*/
extensions?: Type<NonEmptyArray<IDivExtension>>;
/**
* Parameters when focusing on an element or losing focus.
*/
focus?: Type<IDivFocus>;
/**
* User functions.
*
* Platforms: android, ios, web
*/
functions?: Type<NonEmptyArray<IDivFunction>>;
/**
* Element height. For Android: if there is text in this or in a child element, specify height in
* `sp` to scale the element together with the text. To learn more about units of size
* measurement, see [Layout inside the card](../../layout).
*/
height?: Type<DivSize>;
/**
* Element ID. It must be unique within the root element. It is used as `accessibilityIdentifier`
* on iOS.
*/
id?: Type<string>;
/**
* Provides data on the actual size of the element. The size is calculated without taking into
* account the margins of the element itself.
*
* Platforms: android, ios, web
*/
layout_provider?: Type<IDivLayoutProvider>;
/**
* External margins from the element stroke.
*/
margins?: Type<IDivEdgeInsets>;
/**
* Internal margins from the element stroke.
*/
paddings?: Type<IDivEdgeInsets>;
/**
* ID for the div object structure. Used to optimize block reuse. See [block
* reuse](../../reuse/reuse.md).
*
* Platforms: android, ios
*/
reuse_id?: Type<string | DivExpression>;
/**
* Merges cells in a string of the [grid](div-grid.md) element.
*
* Platforms: android, ios, web
*/
row_span?: Type<number | DivExpression>;
/**
* List of [actions](div-action.md) to be executed when selecting an element in
* [pager](div-pager.md).
*
* Platforms: android, ios, web
*/
selected_actions?: Type<NonEmptyArray<IDivAction>>;
/**
* Tooltips linked to an element. A tooltip can be shown by `div-action://show_tooltip?id=`,
* hidden by `div-action://hide_tooltip?id=` where `id` — tooltip id.
*
* Platforms: android, ios, web
*/
tooltips?: Type<NonEmptyArray<IDivTooltip>>;
/**
* Applies the passed transformation to the element. Content that doesn't fit into the original
* view area is cut off.
*
* Platforms: android, ios, web
*/
transform?: Type<IDivTransform>;
/**
* Change animation. It is played when the position or size of an element changes in the new
* layout.
*
* Platforms: android, ios, web
*/
transition_change?: Type<DivChangeTransition>;
/**
* Appearance animation. It is played when an element with a new ID appears. To learn more about
* the concept of transitions, see [Animated
* transitions](../../interaction#animation/transition-animation).
*
* Platforms: android, ios, web
*/
transition_in?: Type<DivAppearanceTransition>;
/**
* Disappearance animation. It is played when an element disappears in the new layout.
*
* Platforms: android, ios, web
*/
transition_out?: Type<DivAppearanceTransition>;
/**
* Animation starting triggers. Default value: `[state_change, visibility_change]`.
*
* Platforms: android, ios, web
*/
transition_triggers?: Type<NonEmptyArray<DivTransitionTrigger>>;
/**
* Triggers for changing variables within an element.
*
* Platforms: android, ios, web
*/
variable_triggers?: Type<NonEmptyArray<IDivTrigger>>;
/**
* Declaration of variables that can be used within an element. Variables declared in this array
* can only be used within the element and its child elements.
*
* Platforms: ios, web, android
*/
variables?: Type<NonEmptyArray<DivVariable>>;
/**
* Element visibility.
*/
visibility?: Type<DivVisibility | DivExpression>;
/**
* Tracking visibility of a single element. Not used if the `visibility_actions` parameter is
* set.
*/
visibility_action?: Type<IDivVisibilityAction>;
/**
* Actions when an element appears on the screen.
*/
visibility_actions?: Type<NonEmptyArray<IDivVisibilityAction>>;
/**
* Element width.
*/
width?: Type<DivSize>;
}
declare type DivBlendMode = 'source_in' | 'source_atop' | 'darken' | 'lighten' | 'multiply' | 'screen';
/**
* Gaussian image blur.
*/
declare class DivBlur<T extends DivBlurProps = DivBlurProps> {
readonly _props?: Exact<DivBlurProps, T>;
readonly type = "blur";
/**
* Blur radius. Defines how many pixels blend into each other. Specified in: `dp`.
*/
radius: Type<number | DivExpression>;
constructor(props: Exact<DivBlurProps, T>);
}
interface DivBlurProps {
/**
* Blur radius. Defines how many pixels blend into each other. Specified in: `dp`.
*/
radius: Type<number | DivExpression>;
}
/**
* Stroke around the element.
*/
interface IDivBorder {
/**
* One radius of element and stroke corner rounding. Has a lower priority than `corners_radius`.
*/
corner_radius?: Type<number | DivExpression>;
/**
* Multiple radii of element and stroke corner rounding.
*/
corners_radius?: Type<IDivCornersRadius>;
/**
* Adding shadow.
*/
has_shadow?: Type<IntBoolean | DivExpression>;
/**
* Parameters of the shadow applied to the element stroke.
*/
shadow?: Type<IDivShadow>;
/**
* Stroke style.
*/
stroke?: Type<IDivStroke>;
}
/**
* Element position and size change animation.
*/
declare class DivChangeBoundsTransition<T extends DivChangeBoundsTransitionProps = DivChangeBoundsTransitionProps> {
readonly _props?: Exact<DivChangeBoundsTransitionProps, T>;
readonly type = "change_bounds";
/**
* Animation duration in milliseconds.
*/
duration?: Type<number | DivExpression>;
/**
* Transition speed nature.
*/
interpolator?: Type<DivAnimationInterpolator | DivExpression>;
/**
* Delay in milliseconds before animation starts.
*/
start_delay?: Type<number | DivExpression>;
constructor(props?: Exact<DivChangeBoundsTransitionProps, T>);
}
interface DivChangeBoundsTransitionProps {
/**
* Animation duration in milliseconds.
*/
duration?: Type<number | DivExpression>;
/**
* Transition speed nature.
*/
interpolator?: Type<DivAnimationInterpolator | DivExpression>;
/**
* Delay in milliseconds before animation starts.
*/
start_delay?: Type<number | DivExpression>;
}
/**
* Animations.
*/
declare class DivChangeSetTransition<T extends DivChangeSetTransitionProps = DivChangeSetTransitionProps> {
readonly _props?: Exact<DivChangeSetTransitionProps, T>;
readonly type = "set";
/**
* List of animations.
*/
items: Type<NonEmptyArray<DivChangeTransition>>;
constructor(props: Exact<DivChangeSetTransitionProps, T>);
}
interface DivChangeSetTransitionProps {
/**
* List of animations.
*/
items: Type<NonEmptyArray<DivChangeTransition>>;
}
declare type DivChangeTransition = DivChangeSetTransition | DivChangeBoundsTransition;
/**
* Circle.
*/
declare class DivCircleShape<T extends DivCircleShapeProps = DivCircleShapeProps> {
readonly _props?: Exact<DivCircleShapeProps, T>;
readonly type = "circle";
/**
* Fill color.
*/
background_color?: Type<string | DivExpression>;
/**
* Radius.
*/
radius?: Type<DivFixedSize>;
/**
* Stroke style.
*/
stroke?: Type<IDivStroke>;
constructor(props?: Exact<DivCircleShapeProps, T>);
}
interface DivCircleShapeProps {
/**
* Fill color.
*/
background_color?: Type<string | DivExpression>;
/**
* Radius.
*/
radius?: Type<DivFixedSize>;
/**
* Stroke style.
*/
stroke?: Type<IDivStroke>;
}
/**
* Cloud-style text background. Rows have a rectangular background in the specified color with
* rounded corners.
*/
declare class DivCloudBackground<T extends DivCloudBackgroundProps = DivCloudBackgroundProps> {
readonly _props?: Exact<DivCloudBackgroundProps, T>;
readonly type = "cloud";
/**
* Fill color.
*/
color: Type<string | DivExpression>;
/**
* Corner rounding radius.
*/
corner_radius: Type<number | DivExpression>;
/**
* Margins between the row border and background border.
*/
paddings?: Type<IDivEdgeInsets>;
constructor(props: Exact<DivCloudBackgroundProps, T>);
}
interface DivCloudBackgroundProps {
/**
* Fill color.
*/
color: Type<string | DivExpression>;
/**
* Corner rounding radius.
*/
corner_radius: Type<number | DivExpression>;
/**
* Margins between the row border and background border.
*/
paddings?: Type<IDivEdgeInsets>;
}
interface IDivCollectionItemBuilder {
/**
* Data that will be used to crea