// Type definitions for Tabris.js 3.8.0 /// // General helper types export interface Constructor {new(...args: any[]): T; } type Omit = Pick>; type ReadOnlyWidgetKeys = T extends {readonly bounds: any} ? Extract : never; type MethodKeysOf = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T]; // Tabris.js Helper Types type JSXDefaultChildren = Flatten; export type Properties< T extends {set?: any}, U = Omit // prevent self-reference issues > = Partial | ReadOnlyWidgetKeys>> & {cid?: never, data?: any}; // prevent empty object type as possible result, would allow any object type ListenersKeysOf = { [K in keyof T]: T[K] extends Listeners ? K : never }[keyof T]; export type UnpackListeners = T extends Listeners ? Listener : T; export type EventOfListeners> = T extends Listeners ? U : never; type ListenersMap = { [Key in ListenersKeysOf]?: UnpackListeners}; export type JSXShorthands = T extends {layoutData?: LayoutDataValue} ? {center?: true, stretch?: true, stretchX?: true, stretchY?: true} : {}; export type JSXCandidate = {set: any; jsxAttributes: any}; // JSX.Element? export type JSXAttributes< T extends JSXCandidate, U = Omit // prevent self-reference issues > = Properties & ListenersMap & JSXShorthands; /** * The attributes object for the given widget type, includes all properties, * events, children and shorthands. To be passed to a JSX element or new-less * widget constructor call. * * The optional second parameter is the type of the "data" property. */ export type Attributes = T['jsxAttributes'] & {data?: TData}; export type JSXCompositeAttributes = JSXAttributes & {apply?: RuleSet, children?: JSXChildren}; type ExtendedEvent = EventObject & EventData; export type Listener = (ev: ExtendedEvent) => any; type ListenersTriggerParam = Omit>; type MinimalEventObject = {target: T}; type TargetType = E extends MinimalEventObject ? Target : object; export interface Listeners { // tslint:disable-next-line:callable-types (listener: Listener>): TargetType; } export type JSXChildren = T|WidgetCollection|Array>|{cid?: never}|undefined; export type SFC = (attributes: object|null, children: any[]) => T; type Flatten = T|Array|undefined; export type Factory< OriginalConstructor extends Constructor & {prototype: Instance}, Instance extends JSXCandidate = InstanceType, Selector extends Function = (...args: any[]) => Widget > = { /** * Creates an instance of this type. * * The given attributes object may include properties, * event listener and children, if supported. * * The second parameter should be given if this is the * return value of a functional component. In this case the * component itself (factory function) must be given to make it * a valid selector for the widget selector API such as * "$()" or the composite "find()" method. */ (attributes?: Attributes, selector?: Selector): Instance }; export type CallableConstructor< OriginalConstructor extends Constructor & {prototype: Instance}, Instance extends JSXCandidate = InstanceType, Selector extends Function = (...args: any[]) => Widget > = { /** This constructor can be called as a factory, without "new". Doing so allows passing an attributes object which may include (in addition to the properties) children, event listeners and layout shorthands. */ new (...args: ConstructorParameters): Instance, /** * Creates an instance of this type. * * The given attributes object may include properties, * event listener and children, if supported. * * The second parameter should be given if this is the * return value of a functional component. In this case the * component itself (factory function) must be given to make it * a valid selector for the widget selector API such as * "$()" or the composite "find()" method. */ (attributes?: Attributes, selector?: Selector): Instance, prototype: Instance }; export as namespace tabris; export type BaseConstructor = Function & { prototype: T }; /** * A plain object with following properties: * * **src**: *string* * File system path, relative path or URL. The [data URI](https://en.wikipedia.org/wiki/Data_URI_scheme) scheme is also supported. Relative paths are resolved relative to 'package.json'. On Android the name of a bundled [drawable resource](https://developer.android.com/guide/topics/resources/drawable-resource.html) can be provided with the url scheme `android-drawable`, e.g. `android-drawable://ic_info_black`. * * **width**: *number | 'auto' (optional)* * Image width in dip, extracted from the image file when missing or `'auto'`. * * **height**: *number | 'auto' (optional)* * Image height in dip, extracted from the image file when missing or `'auto'`. * * **scale**: *number | 'auto' (optional)* * Image scale factor, the image will be scaled down by this factor. The scale will be inferred from the image file name if it follows the pattern "@\x", e.g. `"image@2x.jpg"`. The pattern is ignored if `scale`, `width` or `height` are set to a number or if `scale` is set to `"auto"`. */ export type ImageSource = string | ImageBitmap | Blob; export type ImageLikeObject = {src: ImageSource, scale?: number | "auto", width?: number | "auto", height?: number | "auto"}; /** * Images can be specified as strings or Image/ImageLikeObject. * * An **Image** instance can be created using the **Image** constructor or using **Image.from**. * * The string shorthand `"image.jpg"` equals `{src: "image.jpg"}`. * * The scale can be part of the file name in the pattern of "@\x", e.g. `"image@2x.jpg"`. The pattern is ignored if `scale`, `width` or `height` are set to a number or if `scale` is set to `"auto"`. */ export type ImageValue = ImageLikeObject | Image | ImageSource | null; export type ColorArray = [number, number, number, number]|[number, number, number]; export type ColorLikeObject = {red: number, green: number, blue: number, alpha?: number}; /** * Colors can be specified as strings, arrays or Color/Color-like objects. * * A **Color** instance can be created with the **Color** constructor or using **Color.from**. * * A **Color**-like object is a plain object with "red", "green", "blue" and optional "alpha" properties. * Example: **{red: 0, green: 127, blue: 255, alpha: 120}** * * A color array has consist of 3 or 4 numbers between (and including) 0 and 255, * i.e. **[red, green, blue, alpha]**. If omitted, alpha is 255. * * As a string the following formats can be used: * - **"#xxxxxx"** * - **"#xxx"** * - **"#xxxxxxxx"** * - **"#xxxx"** * - **"rgb(r, g, b)"** with **r**, **g** and **b** being numbers in the range 0..255. * - **"rgba(r, g, b, a)"** with **a** being a number in the range 0..1. * - a color name from the CSS3 specification. * - **"transparent"** sets a fully transparent color. This is a shortcut for **"rgba(0, 0, 0, 0)"**. * - **"initial"** resets the color to its (platform-dependent) default. * * Setting a ColorValue property to null also resets it to the default color. * * Type guards for `ColorValue` are available as **Color.isColorValue** and **Color.isValidColorValue** */ export type ColorValue = ColorLikeObject | ColorArray | string | 'initial' | null; export type FontWeight = 'black' | 'bold' | 'medium' | 'thin' | 'light' | 'normal'; export type FontStyle = 'italic' | 'normal'; export type FontLikeObject = {size: number, family?: string[], weight?: FontWeight, style?: FontStyle}; /** * Fonts can be specified as strings or Font/Font-like objects. * * A **Font** instance can be created with the **Font** constructor or using **Font.from**. * * A **Font**-like object is a plain object with "size" and optional "family", "weight" and "style" properties. * Example: **{size: 16, family: ['serif'], weight: 'bold', style: 'italic'}** * * Generic font families supported across all platforms are **"serif"**, **"sans-serif"**, **"condensed"** and **"monospace"**. * Supported font weights are **"light"**, **"thin"**, **"normal"**, **"medium"**, **"bold"** and **"black"**. * * As a string, the shorthand syntax known from CSS is used: **"[font-style] [font-weight] font-size [font-family[, font-family]*]"**. The font family may be omitted, in this case the default system font will be used. The value **"initial"** represents the platform default. */ export type FontValue = FontLikeObject|string|'initial'|null; export interface PercentLikeObject { percent: number; } export type PercentString = string; /** * * Percents can be specified as strings or Percent/Percent-like objects. * * A **Percent** instance can be created with the **Percent** constructor or using **Percent.from**. * * A **Percent**-like object is a plain object with a *percent* property with a number between and including 0 and 100. * * A percent string contains a number between and including 0 and 100 and and ends with `%`. * */ export type PercentValue = PercentString | PercentLikeObject; /** * Defines how the widget should be arranged. When setting the layout of a widget using **LayoutData**, all currently set layout attributes not in the new LayoutData object will be implicitly reset to null (i.e. "not specified"). */ export type LayoutDataValue = LayoutDataLikeObject|'center'|'stretch'|'stretchX'|'stretchY'; export interface LayoutDataLikeObject { left?: 'auto' | ConstraintValue; right?: 'auto' | ConstraintValue; top?: 'auto' | ConstraintValue; bottom?: 'auto' | ConstraintValue; centerX?: 'auto' | Offset | true; centerY?: 'auto' | Offset | true; baseline?: 'auto' | SiblingReferenceValue |true; width?: 'auto' | Dimension; height?: 'auto' | Dimension; } export interface LayoutDataProperties { left?: 'auto' | Constraint; right?: 'auto' | Constraint; top?: 'auto' | Constraint; bottom?: 'auto' | Constraint; centerX?: 'auto' | Offset; centerY?: 'auto' | Offset; baseline?: 'auto' | SiblingReference; width?: 'auto' | Dimension; height?: 'auto' | Dimension; } export type LinearGradientLikeObject = { colorStops: Array, direction?: number | 'left' | 'top' | 'right' | 'bottom' } /** * Linear gradients can be specified as strings or [LinearGradient](./LinearGradient.html) or * `LinearGradient`-like objects. * * An `LinearGradient` instance can be created using the `LinearGradient` constructor or using * `LinearGradient.from`. * * A `LinearGradient`-like object is a plain object with "colorStops" and optional "direction" * properties. * "colorStops" is an array containing atleast one `ColorValue` or `[ColorValue, PercentValue]`. * "direction" is a number in degrees or one of "left", "top", "right" and "bottom". * * As string, following CSS subset can be used: * * ::= [ % ] * ::= linear-gradient( [ deg | to ( left | top | right | bottom ), ] { , } ) */ export type LinearGradientValue = LinearGradientLikeObject | string | 'initial' | null; /** * A Widget's bounds */ export interface Bounds { /** * the horizontal offset from the parent's left edge in dip */ left: number; /** * the vertical offset from the parent's top edge in dip */ top: number; /** * the width of the widget in dip */ width: number; /** * the height of the widget in dip */ height: number; } export interface Transformation { /** * Clock-wise rotation in radians. Defaults to \`0\`. */ rotation?: number; /** * Horizontal scale factor. Defaults to \`1\`. */ scaleX?: number; /** * Vertical scale factor. Defaults to \`1\`. */ scaleY?: number; /** * Horizontal translation (shift) in dip. Defaults to \`0\`. */ translationX?: number; /** * Vertical translation (shift) in dip. Defaults to \`0\`. */ translationY?: number; /** * Z-axis translation (shift) in dip. Defaults to \`0\`. Android 5.0+ only. */ translationZ?: number; } export type SelectorString = string; export type SiblingSelectorString = string; /** * An expression or a predicate function to select a set of widgets. */ export type Selector< Candidate extends Widget = Widget, Result extends Candidate = Candidate > = SelectorString | SelectorFunction | Constructor | SFC; export type SelectorFunction = (widget: Candidate, index: number, collection: WidgetCollection) => boolean; /** * A positive float, or 0, representing device independent pixels. */ export type Dimension = number; /** * A positive or negative float, or 0, representing device independent pixels. */ export type Offset = number; export type PrevString = 'prev()'; type NextString = 'next()'; export type SiblingReferenceSymbol = typeof LayoutData.next | typeof LayoutData.prev export type SiblingReference = Widget | SiblingReferenceSymbol | SiblingSelectorString; export type SiblingReferenceValue = Widget | SiblingReferenceSymbol | SiblingSelectorString; export type ConstraintArray = [SiblingReferenceValue | PercentValue, Offset]; export type ConstraintArrayValue = [SiblingReference | PercentValue, Offset]; export type ConstraintLikeObject = { reference: SiblingReferenceValue | PercentValue; offset?: Offset; }|{ reference?: SiblingReferenceValue | PercentValue; offset: Offset; }; /** * Distance to a parent's or sibling's opposing edge in one of these formats: * - **offset** the distance from the parent's opposing edge in device independent pixels * - **percentage** the distance from the parent's opposing edge in percent of the parent's width * - **Widget** attach this edge to the given siblings's opposing edge * - **"selector"** * - **"prev()"** Same as above, but as space-separated string list instead of array * - **"selector offset"** * - **"prev() offset"** * - **[Widget, offset]** the distance from the given widget's opposing edge in pixel * - **"Widget, offset"**Same as above, but as space-separated string list instead of array. * - **[percentage, offset]** the distance from the parent's opposing edge in percent of the parent's width plus a fixed offset in pixels * - **"percentage offset"** Same as above, but as space-separated string list instead of array * - **[selector, offset]** * - **["prev()", offset]** */ export type ConstraintValue = Constraint | ConstraintArrayValue | ConstraintLikeObject | Offset | PercentValue | SiblingReferenceValue | true; export interface AnimationOptions { /** * Time until the animation starts in ms, defaults to 0. */ delay?: number; /** * Duration of the animation in ms. */ duration?: number; /** * Easing function applied to the animation. */ easing?: "linear"|"ease-in"|"ease-out"|"ease-in-out"; /** * Number of times to repeat the animation, defaults to 0. */ repeat?: number; /** * If true, alternates the direction of the animation on every repeat. */ reverse?: boolean; /** * no effect, but will be given in animation events. */ name?: string; } /** * Represents dimensions on four edges of a box, as used for padding. */ export type BoxDimensions = number | string | [number, number?, number?, number?] | { /** * The left part, in dip. */ left?: number; /** * The right part, in dip. */ right?: number; /** * The top part, in dip. */ top?: number; /** * The bottom part, in dip. */ bottom?: number; } export interface PropertyChangedEvent extends EventObject{ readonly value: U originalEvent?: PropertyChangedEvent | null; } export class JsxProcessor { public readonly jsxFactory: Symbol; public readonly jsxType: Symbol; createElement(type: {prototype: JSX.ElementClass, new(): object}|string, attributes: object, ...children: Array): JSX.ElementClass | string; createIntrinsicElement(type: string, attributes: object): JSX.ElementClass | string; createCustomComponent(type: {prototype: JSX.ElementClass, new(): object}, attributes: object): JSX.ElementClass | string; createFunctionalComponent(type: ((param: object) => any), attributes: object): JSX.ElementClass | string; createNativeObject(Type: {prototype: JSX.ElementClass, new(): NativeObject}, attributes: object): NativeObject; } export function asFactory< OriginalConstructor extends Constructor & {prototype: Instance}, Instance extends JSXCandidate = InstanceType > (constructor: OriginalConstructor): CallableConstructor; export type ModuleLoader = ( module: Module, exports: object, require: (fn: string) => object, __filename: string, __dirname: string ) => void; export type ResourceData, RawType = any> = Record>; export type ColorResourceData = Record>; export type FontResourceData = Record>; export type TextResourceData = Record>; export type RuleSetObject = ({[selectorOrAttribute: string]: any}) & {prototype?: never}; export type RuleSetStatic = RuleSetObject | Array; export type RuleSetCallback = ((widget: Target) => RuleSetStatic) | null; export type RuleSet = RuleSetStatic | RuleSetCallback | null; export type ApplyAttributes> = ApplyAttributesTypedSetter | ApplyAttributesUntypedSetter | ApplyAttributesRuleSet; export type ApplyAttributesTypedSetter> = { target: WidgetConstructor, selector?: string, children?: Attributes, attr?: Attributes }; export type ApplyAttributesUntypedSetter = { target?: never, selector?: string, children?: Attributes, attr?: Attributes }; export type ApplyAttributesRuleSet = { children?: RuleSet }; export namespace widgets { export class ObservableData { constructor(properties?: Record); [Symbol.observable](): Observable>; } } export type ObservableData = widgets.ObservableData; export type ObservableDataConstructor = typeof widgets.ObservableData; export interface ObservableDataFactory extends ObservableDataConstructor { (properties?: T): ObservableData & T; } export const ObservableData: ObservableDataFactory; declare var ImageDataConstructor: typeof ImageData; declare var StorageConstructor: typeof Storage; declare var WebSocketConstructor: typeof WebSocket; declare var XMLHttpRequestConstructor: typeof XMLHttpRequest; declare var CryptoConstructor: typeof Crypto; declare var cryptoObject: Crypto; declare var workerConstructor: typeof Worker; declare var RequestConstructor: typeof Request; declare var ResponseConstructor: typeof Response; declare var HeadersConstructor: typeof Headers; declare var fetchFunction: typeof fetch; declare var $Function: typeof $; export { ImageDataConstructor as ImageData, StorageConstructor as Storage, WebSocketConstructor as WebSocket, XMLHttpRequestConstructor as XMLHttpRequest, CryptoConstructor as Crypto, cryptoObject as crypto, RequestConstructor as Request, ResponseConstructor as Response, HeadersConstructor as Headers, fetchFunction as fetch, $Function as $, Setter as Set }; type ResourcesConstructorOptions = { data: ResourceRawData, config?: ResourceConfig, base?: ResourceBaseData, validator?: (value: any) => value is RawType, converter?: (raw: RawType) => ResourceType, type?: Constructor }; type ResourceBuildOptions = { validator: (value: any) => value is ResourceType, type?: Constructor } | { validator?: (value: any) => value is ResourceType, type: Constructor }; type ResourceBuildConvertOptions = { validator?: (value: any) => value is RawType, converter: (raw: RawType) => ResourceType, type?: Constructor }; type ResourceBuilderConstructorOptions = { validator?: (value: any) => value is RawType, converter?: (raw: RawType) => ResourceType, type?: Constructor }; type ResourceRawData = NeverResources & Selectable & Partial>; type ResourceDataWithConfig = NeverResources & Selectable & ResourceInlineConfig; type ResourceConfig = { scaleFactor?: ScaleFactor, fallbackLanguage?: string }; type ResourceInlineConfig = { $schema?: string, $scaleFactor?: ScaleFactor, $fallbackLanguage?: string }; type ScaleFactor = 'nearest' | 'higher' | 'lower'; type Selectable = T | {[key: string]: Selectable} | undefined | {inherit: boolean} | {ref: string}; type ResourceBaseData = NeverResources & {readonly [resourceName: string]: ResourceType | undefined}; type NamedResources = { [T in Exclude]: ResourceType }; type ReservedResourceKeys = keyof ResourceInlineConfig | keyof NeverResources | 'toString' | 'valueOf' | symbol | number; // TypeScript does now allow reg-ex checks, // so these only catch the "worst" cases type NeverResources = { _?: never, '#'?: never, '!'?: never, '*'?: never, '@'?: never, ' '?: never, 'on'?: never }; // This type needs to be less strict than FontLikeObject to satisfy tsc when using FontResources.from with JSON type FontResourceValue = {size: number, family?: string[], weight?: string, style?: string} | string; export type TeardownLogic = Function | {unsubscribe: Function} | void; export type SubscriptionHandler = ( this: Observable, subscriber: Subscriber ) => TeardownLogic; export interface Observer { next: NextCb; error: ErrorCb; complete: CompleteCb; } export type NextCb = ((value: T) => void); export type ErrorCb = ((value: any) => void); export type CompleteCb = (() => void); export interface PartialObserver { next?: (value: T) => any; error?: (ex: any) => any complete?: () => any } export interface Subscription { readonly closed: boolean; unsubscribe: () => void; } export interface Subscriber extends Observer { readonly closed: boolean; } declare global { interface SymbolConstructor { readonly observable: symbol; } } // Action export namespace widgets { /** * An executable item that is integrated in the application's navigation menu. Add a *select* listener * to react to action taps. */ export class Action extends Widget { /** * An executable item that is integrated in the application's navigation menu. Add a *select* listener * to react to action taps. * * This constructor can be called as a factory, without "new". Doing so allows passing an attributes * object which may include (in addition to the properties) children, event listeners and layout * shorthands. */ public constructor(properties?: Properties); /** * Appends this widget to the given `NavigationView` instance. * @param parent */ appendTo(parent: NavigationView): this; /** * Inserts this widget directly after the given Action. * @param widget */ insertAfter(widget: Action): this; /** * Inserts this widget directly before the given Action. * @param widget */ insertBefore(widget: Action): this; /** * Returns the `NavigationView` the `Action` is hosted in or `null` if it has no parent. */ parent(): NavigationView; /** * Returns a (possibly empty) collection of all siblings of this widget that match the given selector. * @param selector A selector expression or a predicate function to filter the results. */ siblings(selector?: Selector): WidgetCollection; /** * Icon image for the action. * On iOS the `image` is tinted with the apps default accent color whereas on Android the `image` is * shown as is. When an action is placed into a `NavigationView`, the `NavigationView` property * `actionColor` can be used to adjust the action tint color. */ image: ImageValue; /** * @constant */ readonly jsxAttributes: JSXAttributes & {children?: JSXDefaultChildren}; /** * Actions with 'default' placement will be visible in the toolbar if enough space is available, * otherwise moved to the overflow section. Setting the property to 'overflow' makes the action appear * there exclusively. Lastly, 'navigation' puts the action in the position normally occupied by the * drawer/back button. When 'navigation' is used, only the `Action` image will be shown. If multiple * actions have this value only the first one is displayed. */ placement: 'default' | 'navigation' | 'overflow'; /** * The text to be displayed for the action. * When an action is placed into a `NavigationView`, the `NavigationView` property `actionTextColor` can * be used to adjust the action title color on Android. */ title: string; /** * Fired when the action is invoked. */ onSelect: Listeners>; /** * Fired when the [*image*](#image) property has changed. */ onImageChanged: ChangeListeners; /** * Fired when the [*placement*](#placement) property has changed. */ onPlacementChanged: ChangeListeners; /** * Fired when the [*title*](#title) property has changed. */ onTitleChanged: ChangeListeners; } } export type Action = widgets.Action; export type ActionConstructor = typeof widgets.Action; export interface ActionFactory extends Factory, ActionConstructor {} export const Action: ActionFactory; // ActionSheet export interface ActionSheetCloseEvent extends EventObject { readonly action: ActionSheetItem | null; readonly index: number | null; } export interface ActionSheetSelectEvent extends EventObject { readonly action: ActionSheetItem; readonly index: number; } /** * A pop up dialog that offers a selection. Is automatically disposed when closed. */ export class ActionSheet extends Popup { /** * A pop up dialog that offers a selection. Is automatically disposed when closed. * * This constructor can be called as a factory, without "new". Doing so allows passing an attributes * object which may include (in addition to the properties) children, event listeners and layout * shorthands. */ public constructor(properties?: Properties); /** * Makes the given action sheet visible. Meant to be used with inline-JSX. In TypeScript it also casts * the given JSX element from `any` to an actual ActionSheet. * @param actionSheet The action sheet to open */ static open(actionSheet: ActionSheet): ActionSheet; /** * An array of objects describing the actions to be displayed. The entries may be instances of * `ActionSheetItem` *or plain objects* with some or all of the same properties. */ actions: Array<{title: string, image?: ImageValue, style?: 'default'|'cancel'|'destructive'}>; /** * @constant */ readonly jsxAttributes: JSXAttributes & {children?: Flatten}; /** * A descriptive message for the available actions. */ message: string; /** * The title of the action sheet. */ title: string; /** * Fired when the action sheet was closed. */ onClose: Listeners>; /** * Fired when an action was selected. Note: on iOS, tapping outside of an ActionSheet will also fire a * `select` event. Its parameter will be an index of a button with type `cancel`. This happens despite * the fact that no button has been pressed. */ onSelect: Listeners>; /** * Fired when the [*actions*](#actions) property has changed. */ onActionsChanged: ChangeListeners; /** * Fired when the [*message*](#message) property has changed. */ onMessageChanged: ChangeListeners; /** * Fired when the [*title*](#title) property has changed. */ onTitleChanged: ChangeListeners; } // ActionSheetItem /** * Describes an entry in an [`ActionSheet`](./ActionSheet.md). */ export class ActionSheetItem { /** * Describes an entry in an [`ActionSheet`](./ActionSheet.md). */ public constructor(properties?: {title: string, image?: ImageValue, style?: 'default'|'cancel'|'destructive'}); readonly [JSX.jsxFactory]: JSX.JsxFactory; /** * An image to be displayed for this item in the `ActionSheet` * @constant */ image: ImageValue; /** * @constant */ readonly jsxAttributes: {title?: string, image?: ImageValue, style?: 'default'|'cancel'|'destructive', children?: JSXDefaultChildren}; /** * The style of presentation for this item in the `ActionSheet`. With the style `cancel` or * `destructive` are displayed in a special way. * Note: On iPad, an action with style `cancel` will not be shown in the ActionSheet as per [Apple's * design * approach](https://developer.apple.com/documentation/uikit/windows_and_screens/getting_the_user_s_attention_with_alerts_and_action_sheets). * If such button is added tapping outside of ActionSheet is equivalent to pressing the `cancel` action * on iPad. In case of tapping outside an appropriate event will be sent by the native side as if such * button was pressed * @constant */ style: 'default' | 'cancel' | 'destructive'; /** * The text to be displayed for this item in the `ActionSheet`. * @constant */ title: string; } // ActivityIndicator export namespace widgets { /** * A widget representing a spinning indicator for indeterminate loading / processing time. */ export class ActivityIndicator extends Widget { /** * A widget representing a spinning indicator for indeterminate loading / processing time. * * This constructor can be called as a factory, without "new". Doing so allows passing an attributes * object which may include (in addition to the properties) children, event listeners and layout * shorthands. */ public constructor(properties?: Properties); /** * @constant */ readonly jsxAttributes: JSXAttributes & {children?: JSXDefaultChildren}; /** * The color of the indicator. */ tintColor: ColorValue; /** * Fired when the [*tintColor*](#tintColor) property has changed. */ onTintColorChanged: ChangeListeners; } } export type ActivityIndicator = widgets.ActivityIndicator; export type ActivityIndicatorConstructor = typeof widgets.ActivityIndicator; export interface ActivityIndicatorFactory extends Factory, ActivityIndicatorConstructor {} export const ActivityIndicator: ActivityIndicatorFactory; // AlertDialog export interface AlertDialogCloseEvent extends EventObject { readonly button: 'ok' | 'cancel' | 'neutral' | null; readonly texts: string[]; } /** * An `AlertDialog` represents a native dialog pop-up showing a message and up to three buttons. Is * automatically disposed when closed. */ export class AlertDialog extends Popup { /** * An `AlertDialog` represents a native dialog pop-up showing a message and up to three buttons. Is * automatically disposed when closed. * * This constructor can be called as a factory, without "new". Doing so allows passing an attributes * object which may include (in addition to the properties) children, event listeners and layout * shorthands. */ public constructor(properties?: Properties>); /** * Makes the given alert dialog visible. Meant to be used with inline-JSX. In TypeScript it also casts * the given JSX element from `any` to an actual AlertDialog. * @param alertDialog The alert dialog to open */ static open(alertDialog: AlertDialog): AlertDialog; /** * Creates and opens an alert dialog with one 'OK' button and the given message. * @param message The message to display */ static open(message: string): AlertDialog; /** * An object with the texts of the buttons to display. There are up to three buttons: `ok`, `cancel` and * `neutral`. If no text is given for a button it will not be displayed. Example: `{ok: 'Yes', cancel: * 'No'}` shows 'Yes' and 'No', but no 'neutral' button. */ buttons: {ok?: string, cancel?: string, neutral?: string}; /** * @constant */ readonly jsxAttributes: JSXAttributes & {children?: Flatten, textInputs?: never}; /** * The message to display inside the dialog. */ message: string; /** * A composite that may contain `TextInput` widgets to be displayed alongside the `title` and `message`. * The text values inserted by the user can be read in the dialogs `close` event via its `texts` * property. Eg.: `dialog.on('close', (e) => e.texts[0])` * In an AlertDialog JSX element the TextInput widgets may be given as child elements. * @constant */ readonly textInputs: ContentView; /** * The title of the dialog. */ title: string; /** * Fired when the dialog was closed for any reason. */ onClose: Listeners>; /** * Fired when the dialog was closed by pressing the 'cancel' button. */ onCloseCancel: Listeners>; /** * Fired when the dialog was closed by pressing the 'neutral' button. */ onCloseNeutral: Listeners>; /** * Fired when the dialog was closed by pressing the 'ok' button. */ onCloseOk: Listeners>; /** * Fired when the [*buttons*](#buttons) property has changed. */ onButtonsChanged: ChangeListeners; /** * Fired when the [*message*](#message) property has changed. */ onMessageChanged: ChangeListeners; /** * Fired when the [*title*](#title) property has changed. */ onTitleChanged: ChangeListeners; } // Button export namespace widgets { /** * A push button. Can contain a text or an image. */ export class Button extends Widget { /** * A push button. Can contain a text or an image. * * This constructor can be called as a factory, without "new". Doing so allows passing an attributes * object which may include (in addition to the properties) children, event listeners and layout * shorthands. */ public constructor(properties?: Properties