UNPKG

3 kBTypeScriptView Raw
1import { View, AddChildFromBuilder, AddArrayFromBuilder } from '../core/view';
2import { ViewBase } from '../core/view-base';
3import { Property, CoercibleProperty, CssProperty } from '../core/properties';
4import { EventData } from '../../data/observable';
5import { Color } from '../../color';
6import { Style } from '../styling/style';
7
8/**
9 * Represents a SegmentedBar item.
10 */
11export class SegmentedBarItem extends ViewBase {
12 /**
13 * Gets or sets the title of the SegmentedBarItem.
14 */
15 public title: string;
16}
17
18/**
19 * Defines the data for the SegmentedBar.selectedIndexChanged event.
20 */
21export interface SelectedIndexChangedEventData extends EventData {
22 /**
23 * The old selected index.
24 */
25 oldIndex: number;
26
27 /**
28 * The new selected index.
29 */
30 newIndex: number;
31}
32
33/**
34 * Represents a UI SegmentedBar component.
35 */
36export class SegmentedBar extends View implements AddChildFromBuilder, AddArrayFromBuilder {
37 /**
38 * Gets or sets the selected index of the SegmentedBar component.
39 */
40 selectedIndex: number;
41
42 /**
43 * Gets or sets the selected background color of the SegmentedBar component.
44 */
45 selectedBackgroundColor: Color;
46
47 /**
48 * Gets or sets the selected text color of the SegmentedBar component.
49 */
50 selectedTextColor: Color;
51
52 /**
53 * Gets or sets the items of the SegmentedBar.
54 */
55 items: Array<SegmentedBarItem>;
56
57 /**
58 * String value used when hooking to the selectedIndexChanged event.
59 */
60 public static selectedIndexChangedEvent: string;
61
62 /**
63 * Adds a listener for the specified event name.
64 *
65 * @param eventName The name of the event.
66 * @param callback The event listener to add. Will be called when an event of
67 * the given name is raised.
68 * @param thisArg An optional parameter which, when set, will be bound as the
69 * `this` context when the callback is called. Falsy values will be not be
70 * bound.
71 */
72 on(eventName: string, callback: (data: EventData) => void, thisArg?: any): void;
73
74 /**
75 * Raised when the selected index changes.
76 */
77 on(event: 'selectedIndexChanged', callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any): void;
78
79 /**
80 * Called for every child element declared in xml.
81 * @param name - Name of the element.
82 * @param value - Value of the element.
83 */
84 public _addChildFromBuilder(name: string, value: any): void;
85 public _addArrayFromBuilder(name: string, value: Array<any>): void;
86}
87
88/**
89 * Gets or sets the selected index dependency property of the SegmentedBar.
90 */
91export const selectedIndexProperty: CoercibleProperty<SegmentedBar, number>;
92
93/**
94 * Gets or sets the selected background color property of the SegmentedBar.
95 */
96export const selectedBackgroundColorProperty: CssProperty<Style, Color>;
97
98/**
99 * Gets or sets the items dependency property of the SegmentedBar.
100 */
101export const itemsProperty: Property<SegmentedBar, SegmentedBarItem[]>;
102
103/**
104 * Gets or sets the selected text color property of the SegmentedBar.
105 */
106export const selectedTextColorProperty: CssProperty<Style, Color>;