swing-ui 0.1.25 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +5 -4
- package/README.md +144 -7
- package/SwingUI.js +2611 -0
- package/classes/Arc.js +185 -0
- package/classes/Button.js +55 -0
- package/classes/CheckBox.js +33 -0
- package/classes/CheckBoxMenuItem.js +24 -0
- package/classes/ComboBox.js +329 -0
- package/classes/ComponentContainer.js +828 -0
- package/classes/ContextMenu.js +141 -0
- package/classes/DocumentEditor.js +168 -0
- package/classes/Ellipse.js +76 -0
- package/classes/InternalWindow.js +397 -0
- package/classes/InternalWindowContainer.js +93 -0
- package/classes/Label.js +52 -0
- package/classes/Line.js +105 -0
- package/classes/List.js +452 -0
- package/classes/MediaPlayer.js +504 -0
- package/classes/Menu.js +74 -0
- package/classes/MenuBar.js +56 -0
- package/classes/MenuItem.js +92 -0
- package/classes/Panel.js +50 -0
- package/classes/PasswordField.js +47 -0
- package/classes/Polygon.js +236 -0
- package/classes/Polyline.js +240 -0
- package/classes/ProgressBar.js +62 -0
- package/classes/RadioButton.js +110 -0
- package/classes/RadioButtonMenuItem.js +106 -0
- package/classes/Rectangle.js +199 -0
- package/classes/ScrollPane.js +53 -0
- package/classes/ScrollableComponent.js +141 -0
- package/classes/Separator.js +24 -0
- package/classes/Shape.js +584 -0
- package/classes/ShapeContainer.js +231 -0
- package/classes/Slider.js +172 -0
- package/classes/Spinner.js +172 -0
- package/classes/SplitView.js +82 -0
- package/classes/Stroke.js +115 -0
- package/classes/Table.js +982 -0
- package/classes/Tabs.js +228 -0
- package/classes/TextArea.js +125 -0
- package/classes/TextComponent.js +207 -0
- package/classes/TextField.js +128 -0
- package/classes/TextShape.js +123 -0
- package/classes/ToggleButton.js +147 -0
- package/classes/ToolBar.js +120 -0
- package/classes/TrayIcon.js +54 -0
- package/classes/Tree.js +569 -0
- package/classes/UIComponent.js +2154 -0
- package/classes/Window.js +609 -0
- package/enums.js +298 -0
- package/fonts.conf +32 -0
- package/functions.js +254 -0
- package/icon.png +0 -0
- package/index.js +109 -4
- package/jar/gui-11.jar +0 -0
- package/jar/lib/flatlaf.jar +0 -0
- package/jar/lib/jna.jar +0 -0
- package/package.json +58 -33
- package/typedefs.js +973 -0
- package/types/SwingUI.d.ts +727 -0
- package/types/classes/Arc.d.ts +111 -0
- package/types/classes/Button.d.ts +38 -0
- package/types/classes/CheckBox.d.ts +22 -0
- package/types/classes/CheckBoxMenuItem.d.ts +18 -0
- package/types/classes/ComboBox.d.ts +172 -0
- package/types/classes/ComponentContainer.d.ts +131 -0
- package/types/classes/ContextMenu.d.ts +74 -0
- package/types/classes/DocumentEditor.d.ts +95 -0
- package/types/classes/Ellipse.d.ts +34 -0
- package/types/classes/InternalWindow.d.ts +163 -0
- package/types/classes/InternalWindowContainer.d.ts +36 -0
- package/types/classes/Label.d.ts +33 -0
- package/types/classes/Line.d.ts +48 -0
- package/types/classes/List.d.ts +223 -0
- package/types/classes/MediaPlayer.d.ts +381 -0
- package/types/classes/Menu.d.ts +43 -0
- package/types/classes/MenuBar.d.ts +26 -0
- package/types/classes/MenuItem.d.ts +57 -0
- package/types/classes/Panel.d.ts +28 -0
- package/types/classes/PasswordField.d.ts +22 -0
- package/types/classes/Polygon.d.ts +93 -0
- package/types/classes/Polyline.d.ts +96 -0
- package/types/classes/ProgressBar.d.ts +36 -0
- package/types/classes/RadioButton.d.ts +70 -0
- package/types/classes/RadioButtonMenuItem.d.ts +71 -0
- package/types/classes/Rectangle.d.ts +82 -0
- package/types/classes/ScrollPane.d.ts +23 -0
- package/types/classes/ScrollableComponent.d.ts +81 -0
- package/types/classes/Separator.d.ts +14 -0
- package/types/classes/Shape.d.ts +223 -0
- package/types/classes/ShapeContainer.d.ts +92 -0
- package/types/classes/Slider.d.ts +107 -0
- package/types/classes/Spinner.d.ts +129 -0
- package/types/classes/SplitView.d.ts +47 -0
- package/types/classes/Stroke.d.ts +99 -0
- package/types/classes/Table.d.ts +652 -0
- package/types/classes/Tabs.d.ts +118 -0
- package/types/classes/TextArea.d.ts +45 -0
- package/types/classes/TextComponent.d.ts +136 -0
- package/types/classes/TextField.d.ts +94 -0
- package/types/classes/TextShape.d.ts +73 -0
- package/types/classes/ToggleButton.d.ts +84 -0
- package/types/classes/ToolBar.d.ts +82 -0
- package/types/classes/TrayIcon.d.ts +43 -0
- package/types/classes/Tree.d.ts +354 -0
- package/types/classes/UIComponent.d.ts +966 -0
- package/types/classes/Window.d.ts +334 -0
- package/types/enums.d.ts +437 -0
- package/types/functions.d.ts +109 -0
- package/types/index.d.ts +188 -0
- package/types/typedefs.d.ts +1626 -0
- package/ui-process-manager.js +317 -0
- package/video-devices-linux.sh +72 -0
- package/video-devices-mac.sh +33 -0
- package/CHANGES.md +0 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TrayIcon is a system icon usually displayed in a tray of icons for applications running or capable of running in the background.
|
|
3
|
+
*
|
|
4
|
+
* TrayIcon component is able to show system notification messages, have context menu and show tooltip text on mouse hover.
|
|
5
|
+
*
|
|
6
|
+
* @class
|
|
7
|
+
* @global
|
|
8
|
+
* @example <h2>Create new TrayIcon:</h2>
|
|
9
|
+
* const icon = new TrayIcon("/path/to/icon.png").tooltip("New App Icon").contextMenu(existing_context_menu).show();
|
|
10
|
+
*
|
|
11
|
+
* @example <h2>Set an event handler:</h2>
|
|
12
|
+
* icon.onMouseEvents(e => {
|
|
13
|
+
* console.log(`${e.clicks} ${e.type}`);
|
|
14
|
+
* })
|
|
15
|
+
* .onAction(e => {
|
|
16
|
+
* console.log("System tray icon action was performed.");
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* @example <h2>Show system message:</h2>
|
|
20
|
+
* icon.showNotification(`Warning Sample`, `This is a sample message`, MessageIcon.Warning);
|
|
21
|
+
*
|
|
22
|
+
* @example <h2>hide and show the icon:</h2>
|
|
23
|
+
* icon.hide(); // or icon.visible(false);
|
|
24
|
+
*
|
|
25
|
+
* icons.show(); // or icon.visible(true);
|
|
26
|
+
*/
|
|
27
|
+
export class TrayIcon extends UIComponent {
|
|
28
|
+
/**
|
|
29
|
+
* Slider TrayIcon. Creates an instance of TrayIcon UI component.
|
|
30
|
+
* @param {string} icon - Icon image (relative/absolute path or base64 encoded image string).
|
|
31
|
+
*/
|
|
32
|
+
constructor(icon: string);
|
|
33
|
+
/**
|
|
34
|
+
* Displays system notification.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} title - Title of the notification message
|
|
37
|
+
* @param {string} message - The message body
|
|
38
|
+
* @param {MessageIcon} [icon=MessageIcon.Info] - One of the values: MessageIcon.Info, MessageIcon.Warning, MessageIcon.Info, or `null` to not show any icon.
|
|
39
|
+
* @return {TrayIcon} Returns `this` TrayIcon component for method chaining.
|
|
40
|
+
*/
|
|
41
|
+
showNotification(title: string, message: string, icon?: MessageIcon): TrayIcon;
|
|
42
|
+
}
|
|
43
|
+
import { UIComponent } from "./UIComponent.js";
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Tree component shows a list items but in a child/parent structure.
|
|
3
|
+
*
|
|
4
|
+
* Like in a {@link List} component the items can hold custom `id` and `value` data in addition to `text`, `icon`, `tooltip`, `font` object, `background`, and `color`.
|
|
5
|
+
*
|
|
6
|
+
* The Tree component can be customized the way it's displayed by methods {@link Tree#showRoot}, {@link Tree#showRootHandle}, {@link Tree#showIcons}, and {@link Tree#expanded}.
|
|
7
|
+
*
|
|
8
|
+
* Items are identified by their unique index path, which is an array of each index, starting from root element [0]. Example index of an item can be [0, 3, 2] where first element is an index of root element (always [0]), and child's index, and then its child.
|
|
9
|
+
*
|
|
10
|
+
* Items can be easily added using {@link Tree#add}, removed using {@link Tree#remove}, updated and retrieved using {@link Tree#item}, and moved from one parent to another using {@link Tree#moveItem}.
|
|
11
|
+
*
|
|
12
|
+
* All other Tree methods not on this page are inherited from {@link ScrollableComponent} and {@link UIComponent}.
|
|
13
|
+
*
|
|
14
|
+
* @class
|
|
15
|
+
* @global
|
|
16
|
+
* @see ListItem
|
|
17
|
+
* @see ScrollableComponent
|
|
18
|
+
* @example
|
|
19
|
+
* // Format of tree item object (Only "text" is requited, other fields are optional)
|
|
20
|
+
* {
|
|
21
|
+
* text: string, // Item text (Required)
|
|
22
|
+
* [id]: string|number, // Value that can be used by software logic to identify this item
|
|
23
|
+
* [value]: string|number, // Additional value to be stored in the item for later use.
|
|
24
|
+
* [icon]: string, // Absolute or relative path to icon image, base64 encoded image string, or `null` to remove icon.
|
|
25
|
+
* [color]: string, // Item text color as a 6 character hex encoded color string (e.g. #665500)
|
|
26
|
+
* [background]: string, // Item background color as a 6 character hex encoded color string (e.g. #665500)
|
|
27
|
+
* [tooltip]: string, // Tooltip text to show when pointer hover the item. (in List and Tree components only)
|
|
28
|
+
* [font]: Font object // Object{name: string, size: number, bold: boolean, ...}. See complete list of font properties in example of font() method.
|
|
29
|
+
* [editable]: boolean // Specifies if the node item text can be edited by the user.
|
|
30
|
+
* [children]:object[] // An array of children (when adding or recursively retrieving).
|
|
31
|
+
* }
|
|
32
|
+
*/
|
|
33
|
+
export class Tree extends ScrollableComponent {
|
|
34
|
+
/**
|
|
35
|
+
* Sets or gets visibility of a root node of the tree.
|
|
36
|
+
*
|
|
37
|
+
* @param {boolean} [show] - `true` to show, `false` to hide.
|
|
38
|
+
* @return {boolean|Tree} If no arguments are passed, current value is returned; otherwise `this` Tree component is returned for method chaining.
|
|
39
|
+
*/
|
|
40
|
+
showRoot(...args: any[]): boolean | Tree;
|
|
41
|
+
/**
|
|
42
|
+
* Sets or gets visibility of a root node handle (the one that's used to expand/collapse the node to show/hide child nodes).
|
|
43
|
+
*
|
|
44
|
+
* @param {boolean} [show] - `true` to show, `false` to hide.
|
|
45
|
+
* @return {boolean|Tree} If no arguments are passed, current value is returned; otherwise `this` Tree component is returned for method chaining.
|
|
46
|
+
*/
|
|
47
|
+
showRootHandle(...args: any[]): boolean | Tree;
|
|
48
|
+
/**
|
|
49
|
+
* Shows or hides all icons in the tree.
|
|
50
|
+
*
|
|
51
|
+
* @param {boolean} [show] - `true` to show, `false` to hide.
|
|
52
|
+
* @return {boolean|Tree} If no arguments are passed, current value is returned; otherwise `this` Tree component is returned for method chaining.
|
|
53
|
+
*/
|
|
54
|
+
showIcons(...args: any[]): boolean | Tree;
|
|
55
|
+
/**
|
|
56
|
+
* Add an item or array of items to a tree node. To add item to root node use [0] for `index` argument.
|
|
57
|
+
*
|
|
58
|
+
* @param {object|object[]} items - One item object or an array of item objects.
|
|
59
|
+
* @param {number[]} index - Index of the item to insert the passed items to. To add to the root use [0].
|
|
60
|
+
* @param {number|undefined} [insertAt=undefined] - Indicates at what position to inserted the items. Value -1 means the end of list.
|
|
61
|
+
* @return {number} Returns an integer at which first passed item was inserted, or -1 if specified parent item index is invalid or no items were inserted.
|
|
62
|
+
*/
|
|
63
|
+
add(items: object | object[], index: number[], insertAt?: number | undefined): number;
|
|
64
|
+
/**
|
|
65
|
+
* Removes item at specified index argument or removes this Tree component from its parent if no argument is passed.
|
|
66
|
+
*
|
|
67
|
+
* @param {number[]} [index] - Index if the item to remove. Omit this argument to remove this Tree from its parent.
|
|
68
|
+
* @return {Tree} Returns `this` Tree component for method chaining.
|
|
69
|
+
*/
|
|
70
|
+
remove(...args: any[]): Tree;
|
|
71
|
+
/**
|
|
72
|
+
* Updates or gets an item at specified index.
|
|
73
|
+
*
|
|
74
|
+
* @param {number[]} index - Index of the item to get or update.
|
|
75
|
+
* @param {object} [item] - Item object. Omit this argument to get the item instead of updating it.
|
|
76
|
+
* @param {boolean} [update=false] - `true` to update specified item properties with provided item properties, `false` to replace the item with new one. Default is `false`.
|
|
77
|
+
* @return [object|undefined|Tree] If `item` argument is passed, `this` Tree component is returned; otherwise an item at specified index is returned, or `null` if passed `index` is invalid.
|
|
78
|
+
* @example
|
|
79
|
+
* // update an item at index [0,3,5]
|
|
80
|
+
* tree.item([0,3,5], {text:"New item text"});
|
|
81
|
+
*
|
|
82
|
+
* // get an item at index [0,3,5]
|
|
83
|
+
* let item = tree.item([0,3,5]);
|
|
84
|
+
* console.log(item?.text); // checks if item is not undefined
|
|
85
|
+
*/
|
|
86
|
+
item(index: number[], ...args: any[]): any;
|
|
87
|
+
/**
|
|
88
|
+
* Sets or gets a list of items for a node at specified index. Setting the list of items will replace current items at specified index before adding new ones. To simply remove existing items pass an empty array as a second parameter.
|
|
89
|
+
*
|
|
90
|
+
* @param {number[]} [index=[0]] - Index of target item. Default is [0] tree root node
|
|
91
|
+
* @param {boolean|object[]} [items_or_recursive=false] - To set items, pass an array of items, or empty array to simply remove all items. When getting items you can specify a `boolean` whether to get all children items recursively or not. Default is `false`.
|
|
92
|
+
* @return {object[]|undefined|Tree} If setting items then `this` Tree component is returned. If getting items then Array of items is returned, or `undefined` if index doesn't point to an item in the Tree.
|
|
93
|
+
* @example <h2> Set items at the root node:</h2>
|
|
94
|
+
* tree.items([0], [
|
|
95
|
+
* { text: "Videos", id: 1, icon: "icons/folder-videos.png" },
|
|
96
|
+
* { text: "Photos", id: 2, icon: "icons/folder-images.png" }
|
|
97
|
+
* ]);
|
|
98
|
+
*
|
|
99
|
+
* @example <h2>Set items at a child node:</h2>
|
|
100
|
+
* tree.items([0,0], [
|
|
101
|
+
* { text: "Video 1", id: "a1", value: "video1.mp4" },
|
|
102
|
+
* { text: "Video 2", id: "a2", value: "video2.mp4", tooltip: "Second video" }
|
|
103
|
+
* ]);
|
|
104
|
+
*
|
|
105
|
+
* @example <h2>Get direct children of a node:</h2>
|
|
106
|
+
* const rootItems = tree.items([0]);
|
|
107
|
+
* console.log(rootItems); // → [ {text: "Videos", id: 1, ...}, {text: "Photos", id: 2, ...} ]
|
|
108
|
+
*
|
|
109
|
+
* @example <h2>Get items recursively from a node:</h2>
|
|
110
|
+
* const deepItems = tree.items([0,0], true);
|
|
111
|
+
* console.log(deepItems); // → [ {text: "Video 1", id: "a1", ...}, {text: "Video 2", id: "a2", ...} ]
|
|
112
|
+
*
|
|
113
|
+
* @example <h2>Get from a non-existing index:</h2>
|
|
114
|
+
* const nothing = tree.items([9]);
|
|
115
|
+
* console.log(nothing); // → undefined
|
|
116
|
+
*/
|
|
117
|
+
items(index?: number[], items_or_recursive?: boolean | object[]): object[] | undefined | Tree;
|
|
118
|
+
/**
|
|
119
|
+
* Sets or gets the expand state of a specified item that has children. Items without children cannot be expanded. When setting `expanded` argument and `index` doesn't point to an item then just nothing will happen.
|
|
120
|
+
*
|
|
121
|
+
* @param {number[]} index - Index path of the item in question
|
|
122
|
+
* @param {boolean} [expanded] - Pass `true` or `false` to set the expand state, or omit to get current state.
|
|
123
|
+
* @param {boolean} [recursive=false] - Whether the specified `expand` state should be applied to all children items recursively. Default is `false`.
|
|
124
|
+
* @return {boolean|undefined|Tree} If `expanded` argument is passed, then `this` Tree component is returned; otherwise current expand state is returned, or `undefined` if specified index in not valid.
|
|
125
|
+
* @example <h2>Expand root node:</h2>
|
|
126
|
+
* tree.expended([0], true);
|
|
127
|
+
*
|
|
128
|
+
* @example <h2>Collapse item at specified index:</h2>
|
|
129
|
+
* tree.expended([0, 2], false);
|
|
130
|
+
*
|
|
131
|
+
* @example <h2>Check if item at specified index is expanded:</h2>
|
|
132
|
+
* let expanded = tree.expended([0, 2]);
|
|
133
|
+
*/
|
|
134
|
+
expanded(...args: any[]): boolean | undefined | Tree;
|
|
135
|
+
/**
|
|
136
|
+
* Expands all items or a specified item and all if its children. If argument is not supplied, root default.
|
|
137
|
+
*
|
|
138
|
+
* @param {number[]} [index=[0]] - Index of an item to expand with all children items. If omitted, all items will be expended.
|
|
139
|
+
* @return {Tree} Returns `this` Tree component for method chaining.
|
|
140
|
+
*/
|
|
141
|
+
expandAll(index?: number[]): Tree;
|
|
142
|
+
/**
|
|
143
|
+
* Collapses all items or a specified item and all if its children. If argument is not supplied, root is default.
|
|
144
|
+
*
|
|
145
|
+
* @param {number[]} [index=[0]] - Index of an item to collapse with all children items. If omitted, all items will be collapsed.
|
|
146
|
+
* @return {Tree} Returns `this` Tree component for method chaining.
|
|
147
|
+
*/
|
|
148
|
+
collapseAll(index?: number[]): Tree;
|
|
149
|
+
/**
|
|
150
|
+
* Sets or gets a selection mode of the tree items, which defines how items can be selected (only one item, a multiple items as a range, or any combination of items).
|
|
151
|
+
*
|
|
152
|
+
* @param {SelectionMode} [mode] - One of: SelectionMode.Single, SelectionMode.Multiple, SelectionMode.Range. See {@link SelectionMode}
|
|
153
|
+
* @return {SelectionMode|Tree} If no arguments are supplied, current selection mode is returned; otherwise `this` Tree component is returned.
|
|
154
|
+
* @see SelectionMode
|
|
155
|
+
* @example <h2>Setting a selection mode:</h2>
|
|
156
|
+
* tree.selectionMode(SelectionMode.Single);
|
|
157
|
+
*/
|
|
158
|
+
selectionMode(...args: any[]): SelectionMode | Tree;
|
|
159
|
+
/**
|
|
160
|
+
* Gets or sets the selected items in the tree. When setting selection, items that were previously selected but are not in the `indexes` argument will get deselected.
|
|
161
|
+
*
|
|
162
|
+
* - To **get** the current selection, call without arguments.
|
|
163
|
+
* - To **set** the selection, pass an array of index paths (array of arrays of index integers).
|
|
164
|
+
*
|
|
165
|
+
* @param {number[][]} [indexes] - An array of index paths to select. (array of arrays)
|
|
166
|
+
* @return {number[][]|Tree} Returns the current selection when called without arguments, or `this` Tree instance when setting.
|
|
167
|
+
*/
|
|
168
|
+
selection(...args: any[]): number[][] | Tree;
|
|
169
|
+
/**
|
|
170
|
+
* Sets or get a whether item or items at specified index or array o indexes are selected. This adds or removes items to/from current selection instead of replacing current selection like selection() method does. If "selected" argument is supplied, it will select or deselect specified items.
|
|
171
|
+
*
|
|
172
|
+
* @param {number[]|number[][]} index - Index path of one item as array, or multiple items as array of arrays. When getting selection status, only first item is used.
|
|
173
|
+
* @param {boolean} [selected] - If supplied, it will indicate if specified items should be selected or not.
|
|
174
|
+
* @return {boolean|Tree} If `selected` arguments is passed, `this` Tree component is returned; otherwise a selection status of first specified item is returned, or `undefined` if index doesn't point to an item.
|
|
175
|
+
* @example <h2>Add one item to current selection:</h2>
|
|
176
|
+
* tree.selected([0,2], true);
|
|
177
|
+
*
|
|
178
|
+
* @example <h2>Add two items to current selection:</h2>
|
|
179
|
+
* tree.selected([[0,3], [0,4]], true);
|
|
180
|
+
*
|
|
181
|
+
* @example <h2>Deselect one item:</h2>
|
|
182
|
+
* tree.selected([0,3], false);
|
|
183
|
+
*
|
|
184
|
+
* @example <h2>Check if one item is selected:</h2>
|
|
185
|
+
* let selected = tree.selected([0,4]); // -> true
|
|
186
|
+
*/
|
|
187
|
+
selected(index: number[] | number[][], ...args: any[]): boolean | Tree;
|
|
188
|
+
/**
|
|
189
|
+
* Selects/Deselects all items in the Tree
|
|
190
|
+
*
|
|
191
|
+
* @param {boolean} [selected=true] - `true` to select all items, `false` to deselect all items.
|
|
192
|
+
* @return {Tree} Returns an instance of `this` Tree for method chaining.
|
|
193
|
+
*/
|
|
194
|
+
selectAll(selected?: boolean): Tree;
|
|
195
|
+
/**
|
|
196
|
+
* Starts editing a specified item, stops editing all items when `null` is passed, or returns an item currently being edited with its `index` property.
|
|
197
|
+
*
|
|
198
|
+
* If no parameters are passed, it returns currently editing item's index or `null` if no item is being edited at the moment.
|
|
199
|
+
*
|
|
200
|
+
* Editing state is when a user can type a new text into the item. Only one item can be editing at a time.
|
|
201
|
+
*
|
|
202
|
+
* @param {number[]|null} [index] - Index of the item to start editing. Pass `null` to stop editing currently editing item (if any).
|
|
203
|
+
* @return {ListItem|null|Tree} If `index` argument is passed, `this` Tree component is returned. When no arguments are provided, returns an item being edited at the moment (if any), or `null` if no item is being edited.
|
|
204
|
+
* @example <h2>Starting to edit a specified item:</h2>
|
|
205
|
+
* tree.editing([0, 2]);
|
|
206
|
+
*
|
|
207
|
+
* @example <h2>Stop editing all items:</h2>
|
|
208
|
+
* tree.editing(null);
|
|
209
|
+
*
|
|
210
|
+
* @example <h2>Check which item is editing now:</h2>
|
|
211
|
+
* let editedItem = tree.editing(); // -> ListItem or false.
|
|
212
|
+
* console.log(editedItem.index); // prints the index of the item
|
|
213
|
+
*/
|
|
214
|
+
editing(...args: any[]): ListItem | null | Tree;
|
|
215
|
+
/**
|
|
216
|
+
* Gets or sets currently focused item in the Tree. Focus is different from selection. Focus can be controlled by focus traversing keys, such as Tab keyboard key, and focused item is not always an item being selected. Multiple items may be selected at a time, but only one item can retain focus at a time.
|
|
217
|
+
*
|
|
218
|
+
* @param {number[]} [index] - Index of one item (array of numbers).
|
|
219
|
+
* @return {ListItem|null|Tree} When no parameters are passed, returns currently focused item with index property, or `null` when no item is focused. When `index` is provided, `this` Tree component is returned.
|
|
220
|
+
*/
|
|
221
|
+
focusedItem(...args: any[]): ListItem | null | Tree;
|
|
222
|
+
/**
|
|
223
|
+
* Sets custom icons to be used for open node, closed node, and leaf node.
|
|
224
|
+
*
|
|
225
|
+
* Example of icons object: {closed:"icons/closed.png", open:"icons/open.png", leaf:"icons/leaf.png"}. Each element is optional.
|
|
226
|
+
*
|
|
227
|
+
* Note: all properties of this object are optional.
|
|
228
|
+
*
|
|
229
|
+
* @param {{closed:string, open:string, leaf: string}} [icons] - An object of icons to set. Each icon is optional. When some icons are omitted, default ones will be used.
|
|
230
|
+
* @return {Tree|object} If setting icons, Returns `this` Tree component for method chaining; otherwise returns currently set icons.
|
|
231
|
+
* @example
|
|
232
|
+
* tree.icons({
|
|
233
|
+
* closed:"icons/closed.png",
|
|
234
|
+
* open:"icons/open.png",
|
|
235
|
+
* leaf:"icons/leaf.png"
|
|
236
|
+
* });
|
|
237
|
+
*/
|
|
238
|
+
icons(icons?: {
|
|
239
|
+
closed: string;
|
|
240
|
+
open: string;
|
|
241
|
+
leaf: string;
|
|
242
|
+
}): Tree | object;
|
|
243
|
+
/**
|
|
244
|
+
* Returns the amount of child nodes under the node specified by index argument.
|
|
245
|
+
*
|
|
246
|
+
* @param {number[]} [index] - Index path of an item in question. Default is the root item.
|
|
247
|
+
* @return {number|undefined} Returns a number of child items the specified item has, or `undefined` if the index doesn't point to an item.
|
|
248
|
+
*/
|
|
249
|
+
childCount(index?: number[]): number | undefined;
|
|
250
|
+
/**
|
|
251
|
+
* Finds items whose `text` property matches the argument. Returns an array of found items.
|
|
252
|
+
*
|
|
253
|
+
* @param {string} text - Text to match when finding items.
|
|
254
|
+
* @return {ListItem[]} Returns an array of found items. Each found item will have an `index` property fo convenience.
|
|
255
|
+
*/
|
|
256
|
+
findByText(text: string): ListItem[];
|
|
257
|
+
/**
|
|
258
|
+
* Finds items whose `id` property matches the argument. Returns an array of found items.
|
|
259
|
+
*
|
|
260
|
+
* @param {string|number} id - Value of item's `id` property to match when finding items.
|
|
261
|
+
* @return {ListItem[]} Returns an array of found items. Each found item will have an `index` property fo convenience.
|
|
262
|
+
*/
|
|
263
|
+
findByID(id: string | number): ListItem[];
|
|
264
|
+
/**
|
|
265
|
+
* Finds items whose `value` property matches the argument. Returns an array of found items.
|
|
266
|
+
*
|
|
267
|
+
* @param {string|number} value - Value of item's `value` property to match when finding items.
|
|
268
|
+
* @return {ListItem[]} Returns an array of found items. Each found item will have an `index` property fo convenience.
|
|
269
|
+
*/
|
|
270
|
+
findByValue(value: string | number): ListItem[];
|
|
271
|
+
/**
|
|
272
|
+
* Moves one or more items from one location (index path) to another within the same Tree component. Items will be inserted in the order they are in the provided `indexes` array.
|
|
273
|
+
*
|
|
274
|
+
* @param {number[][]} indexes - Array of index arrays of items you want to move.
|
|
275
|
+
* @param {number[]} toIndex - Index of a new parent for specified items.
|
|
276
|
+
* @param {number} [insertAt] - Index position at which to insert the item(s) into parent (apply applies only if the parent item already has some items).
|
|
277
|
+
* @return {Tree} Returns `this` Tree component for method chaining.
|
|
278
|
+
*/
|
|
279
|
+
moveItems(indexes: number[][], toIndex: number[], ...args: any[]): Tree;
|
|
280
|
+
/**
|
|
281
|
+
* Moves one item from one location (index path) to another within the same Tree component.
|
|
282
|
+
*
|
|
283
|
+
* @param {number[]} index -Index path of the item you want to move.
|
|
284
|
+
* @param {number[]} toIndex - Index of a new parent for specified item.
|
|
285
|
+
* @param {number} [insertAt] - Index position at which to insert the item into parent (apply applies only if the parent item already has some items).
|
|
286
|
+
* @return {Tree} Returns `this` Tree component for method chaining.
|
|
287
|
+
*/
|
|
288
|
+
moveItem(itemIndexArray: any, toIndexArray: any, insertAt?: number): Tree;
|
|
289
|
+
/**
|
|
290
|
+
* Gets or sets how many consecutive clicks are required to start editing an item's text. The `Tree` component is not editable by default, therefore editing should be enabled by {@link UIComponent#editable} method for these clicks have effect. See example below.
|
|
291
|
+
*
|
|
292
|
+
* @param {number} [clicks] - Amount of rapid clicks required (1 or 2). Default is 2. If omitted, the current value is returned.
|
|
293
|
+
* @return {number|Tree} When called without parameters, current value is returned; otherwise returns `this` Tree component for method chaining.
|
|
294
|
+
* @example <h2>Enables editing, then sets 1 click to start editing:</h2>
|
|
295
|
+
* tree.editable(true).clicksToEdit(1);
|
|
296
|
+
* @see Tree#editable
|
|
297
|
+
*/
|
|
298
|
+
clicksToEdit(...args: any[]): number | Tree;
|
|
299
|
+
/**
|
|
300
|
+
* Sets or gets whether Tree nodes' text can be edited by user.
|
|
301
|
+
*
|
|
302
|
+
* @param {boolean} [editable] - enables or disables editing
|
|
303
|
+
* @return {Object|boolean} If arguments is passed, returns `this` component instance, otherwise returns `boolean` value.
|
|
304
|
+
* @see Tree#clicksToEdit
|
|
305
|
+
*/
|
|
306
|
+
editable(...args: any[]): Object | boolean;
|
|
307
|
+
/**
|
|
308
|
+
* Removes all children items of item at specified index. If no index path is specified, [0] root is cleared.
|
|
309
|
+
*
|
|
310
|
+
* @param {number[]} [index] - Index path of the item to clear. If omitted, the root node will be cleared.
|
|
311
|
+
* @return {Tree} Returns `this` Tree component for method chaining.
|
|
312
|
+
*/
|
|
313
|
+
clear(...args: any[]): Tree;
|
|
314
|
+
/**
|
|
315
|
+
* Scrolls the scroll bars to make sure the item at specified index is visible. If position is specified, the item will be placed at the specified position between the top and bottom of the Tree component.
|
|
316
|
+
*
|
|
317
|
+
* @param {number[]} index - Index of a tree item to make visible.
|
|
318
|
+
* @param {number} [position] - A decimal number between 0 and 1 indicating vertical position in percentages (0% - 100% of the height of the component). If omitted, the item will only become visible, but not at a specific location.
|
|
319
|
+
* @returns {Tree} Returns `this` Tree object for chaining.
|
|
320
|
+
*/
|
|
321
|
+
scrollToIndex(index?: number[], position?: number): Tree;
|
|
322
|
+
/**
|
|
323
|
+
* Sets or gets a height of each row. If returned value is 0 or less, then height is determined automatically.
|
|
324
|
+
*
|
|
325
|
+
* @param {number} [height] - New row height
|
|
326
|
+
* @returns {number|Tree} If called without arguments, a current row height is returned, otherwise `this` Tree object is returned for chaining.
|
|
327
|
+
*/
|
|
328
|
+
rowHeight(...args: any[]): number | Tree;
|
|
329
|
+
/**
|
|
330
|
+
* Gets, registers or unregisters an event handler function for events triggered by adding, removing, updating items and when the Tree structure is changed.
|
|
331
|
+
*
|
|
332
|
+
* @param {function(Object): any} [callback] - The event handler function. Receives an event object.
|
|
333
|
+
* @param {boolean} [remove=false] - Set to `true` to unregister the event handler.
|
|
334
|
+
* @returns {function[]|Tree} When called without parameters, an array of handler functions is returned, otherwise `this` Tree component is returned for method chaining.
|
|
335
|
+
*
|
|
336
|
+
* @example <h2>Event object format:</h2>
|
|
337
|
+
* Object {
|
|
338
|
+
* target: Tree, // The component that triggered the event
|
|
339
|
+
* type: string, // "add", "update", "remove", or "restructure".
|
|
340
|
+
* items: object[], // Items effected by the action that triggered the event
|
|
341
|
+
* interactive: boolean // Only when type is "update". Indicates if the update was made by the user interacting with the item in GUI. `false` when updated programmatically.
|
|
342
|
+
* }
|
|
343
|
+
*
|
|
344
|
+
* @example <h2>Registering an event handler:</h2>
|
|
345
|
+
* tree.onItemsEvents(e=>{alert(e.type);}); // shows the event type in a new message dialog window
|
|
346
|
+
*
|
|
347
|
+
* @example <h2>Unregistering all registered event handlers:</h2>
|
|
348
|
+
* let _handlers = tree.onItemsEvents(); // gets all handlers
|
|
349
|
+
*
|
|
350
|
+
* for(let handler of _handlers) tree.onItemsEvents(handler, false); // unregisters each handler
|
|
351
|
+
*/
|
|
352
|
+
onItemsEvents(callback?: (arg0: Object) => any, ...args: any[]): Function[] | Tree;
|
|
353
|
+
}
|
|
354
|
+
import { ScrollableComponent } from "./ScrollableComponent.js";
|