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,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Tabs UI component is a set of linked panels where only one panel is visible at a time, and users can switch between them by clicking tab headers. It’s commonly used to organize related content into separate views. This helps save space and makes navigation more intuitive.
|
|
3
|
+
* Extends ComponentContainer, which extends UIComponent.
|
|
4
|
+
* @class
|
|
5
|
+
* @global
|
|
6
|
+
* @see ComponentContainer
|
|
7
|
+
* @example
|
|
8
|
+
* // Usage example
|
|
9
|
+
*
|
|
10
|
+
* // create new Tabs component
|
|
11
|
+
* this.tabs = new Tabs().addTo(this).position(15, 15, 15, 15).anchor("top right bottom left");
|
|
12
|
+
*
|
|
13
|
+
* // One way to add a Panel to Tabs
|
|
14
|
+
* this.loginPanel = new Panel().background(null);
|
|
15
|
+
* this.tabs.add(this.loginPanel, {text: "Sign In", enabled: true, tooltip: "Log in to your account", icon: "images/user.png"});
|
|
16
|
+
*
|
|
17
|
+
* // second way to add same panel and options
|
|
18
|
+
* this.loginPanel = new Panel("Sign In").background(null).icon("images/user.png").addTo(this.tabs);
|
|
19
|
+
* this.tabs.tooltipAt(0, "Log in to your account");
|
|
20
|
+
*
|
|
21
|
+
* // third way to add same panel and options
|
|
22
|
+
* this.loginPanel = new Panel().background(null);
|
|
23
|
+
* this.tabs.add(this.loginPanel).textAt(0, "Sign In").iconAt(0, "images/user.png").tooltipAt(0, "Log in to your account").enabledAt(0, true);
|
|
24
|
+
*/
|
|
25
|
+
export class Tabs extends ComponentContainer {
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new Tabs component.
|
|
28
|
+
*/
|
|
29
|
+
constructor();
|
|
30
|
+
/**
|
|
31
|
+
* Adds a new tab with provided component as the main component of that tab. If options are passed, they will be used for tab text, icon, tooltip, etc.
|
|
32
|
+
*
|
|
33
|
+
* @param {object} component - A component that is allowed to be added to Tabs:
|
|
34
|
+
* @param {string|object|undefined} [options=undefined] - Text of the new tab or an object containing one or more options {text:string, icon: string, tooltip: string, enabled: boolean, index: number}.
|
|
35
|
+
* @param {number|undefined} [index=undefined] - Index at which to insert the new tab. Default is last tab.
|
|
36
|
+
* @returns {Tabs} Returns `this` Tabs component for method chaining.
|
|
37
|
+
* @example
|
|
38
|
+
* // Setting multiple tab options
|
|
39
|
+
* tabs.add(panel, {text:"Tab Name",icon:"icons/user.png",enabled:true,tooltip:"Create new user"});
|
|
40
|
+
*
|
|
41
|
+
* // Setting tab name only (as a string)
|
|
42
|
+
* tabs.add(panel, "Tab Name");
|
|
43
|
+
*
|
|
44
|
+
* // Setting insert index
|
|
45
|
+
* tabs.add(panel, "Tab Name", 2);
|
|
46
|
+
*/
|
|
47
|
+
add(component: object, options?: string | object | undefined, index?: number | undefined): Tabs;
|
|
48
|
+
/**
|
|
49
|
+
* Sets or gets a selected tab index.
|
|
50
|
+
*
|
|
51
|
+
* @param {number} [index] - Index of the tab to select. Out of bounds integer will not select anything)
|
|
52
|
+
* @returns {number|Tabs} When setting an index, `this` Tabs component is returned; otherwise currently selected tab index is returned.
|
|
53
|
+
*/
|
|
54
|
+
selected(...args: any[]): number | Tabs;
|
|
55
|
+
/**
|
|
56
|
+
* Gets information about selected Tab.
|
|
57
|
+
* Returned object format is: {index:number, text:string, tooltip:string, enables:boolean, component: object}.
|
|
58
|
+
*
|
|
59
|
+
* @type {object|null}
|
|
60
|
+
* @readonly
|
|
61
|
+
*/
|
|
62
|
+
readonly get selectedItem(): object | null;
|
|
63
|
+
/**
|
|
64
|
+
* Gets an array of objects about each tab.
|
|
65
|
+
* Each object format is: {text:string, tooltip:string, enables:boolean, selected:boolean, component: object}.
|
|
66
|
+
*
|
|
67
|
+
* @type {object[]}
|
|
68
|
+
* @readonly
|
|
69
|
+
*/
|
|
70
|
+
readonly get items(): object[];
|
|
71
|
+
/**
|
|
72
|
+
* Sets or gets whether the tab at specified index is enabled. Setting it to `false` makes it disabled.
|
|
73
|
+
*
|
|
74
|
+
* @param {number} i - Index of the tab
|
|
75
|
+
* @param {boolean} [enabled] - Set to `true` to enabled the tab, `false` to disable.
|
|
76
|
+
* @return {boolean|Tabs} When setting `enabled` argument, `this` Tabs component object is returned; otherwise current `enabled` state is returned.
|
|
77
|
+
*/
|
|
78
|
+
enabledAt(i: number, ...args: any[]): boolean | Tabs;
|
|
79
|
+
/**
|
|
80
|
+
* Sets or gets the text of the tab at specified index.
|
|
81
|
+
*
|
|
82
|
+
* @param {number} i - Index of the tab
|
|
83
|
+
* @param {string} [text] - New text for the tab
|
|
84
|
+
* @return {string|Tabs} When setting `text` argument, `this` Tabs component object is returned; otherwise current text is returned.
|
|
85
|
+
*/
|
|
86
|
+
textAt(i: number, ...args: any[]): string | Tabs;
|
|
87
|
+
/**
|
|
88
|
+
* Sets or gets the tooltip text for the tab at specified index.
|
|
89
|
+
*
|
|
90
|
+
* @param {number} i - Index of the tab
|
|
91
|
+
* @param {string} [tooltip] - New tooltip text for the tab
|
|
92
|
+
* @return {string|Tabs} When setting `tooltip` argument, `this` Tabs component object is returned; otherwise current tooltip text is returned.
|
|
93
|
+
*/
|
|
94
|
+
tooltipAt(i: number, ...args: any[]): string | Tabs;
|
|
95
|
+
/**
|
|
96
|
+
* Sets or gets the icon for the tab at specified index.
|
|
97
|
+
*
|
|
98
|
+
* @param {number} i - Index of the tab
|
|
99
|
+
* @param {string|null} [icon] - Icon's path (URL, relative or absolute path) or base64 encoded image. Set `null` to remove current icon.
|
|
100
|
+
* @return {string|null|Tabs} When setting `icon` argument, `this` Tabs component object is returned; otherwise current icon is returned as base64 encoded string or `null` if the icon was not set.
|
|
101
|
+
*/
|
|
102
|
+
iconAt(i: number, ...args: any[]): string | null | Tabs;
|
|
103
|
+
/**
|
|
104
|
+
* Position of tabs: left, right, top, or bottom. Default is top.
|
|
105
|
+
*
|
|
106
|
+
* @param {string} [position] - "top", "bottom", "left", or "right.
|
|
107
|
+
* @return {string|Tabs} If setting value, `this` Tabs component object is returned; otherwise current value is returned.
|
|
108
|
+
*/
|
|
109
|
+
tabPosition(...args: any[]): string | Tabs;
|
|
110
|
+
/**
|
|
111
|
+
* Sets or gets whether tabs on left or right side should be displayed vertically to take less space. Has no affect when tabs are at the top or bottom. Default is false.
|
|
112
|
+
*
|
|
113
|
+
* @param {boolean} [vertical] - `true` for vertical, `false` for horizontal menu-like tab list (default).
|
|
114
|
+
* @return {boolean|Tabs} If setting value, `this` Tabs component object is returned; otherwise current value is returned.
|
|
115
|
+
*/
|
|
116
|
+
sideTabsVertical(...args: any[]): boolean | Tabs;
|
|
117
|
+
}
|
|
118
|
+
import { ComponentContainer } from "./ComponentContainer.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextArea is a multi-line text field with multiple text-wrapping modes.
|
|
3
|
+
* TextArea extends TextComponent and ScrollableComponent classes, which extend UIComponent class.
|
|
4
|
+
* @class
|
|
5
|
+
* @global
|
|
6
|
+
* @see TextComponent
|
|
7
|
+
* @see ScrollableComponent
|
|
8
|
+
*/
|
|
9
|
+
export class TextArea extends TextComponent {
|
|
10
|
+
/**
|
|
11
|
+
* Sets or Gets the text value of the text area.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} [text=undefined] - Text value to replace existing text.
|
|
14
|
+
* @param {TextAction} [action=TextAction.Set] - Specific action to perform with text. One of: TextAction.Set, TextAction.Prepend, TextAction.Append, TextAction.Insert, TextAction.ReplaceSelection.
|
|
15
|
+
* @param {number} [insert_position=undefined)] - Position where to insert text. Applies only if `action` argument is TextAction.Insert.
|
|
16
|
+
* @return {string|TextArea} When setting text, `this` TextArea component is returned; otherwise current text is returned.
|
|
17
|
+
* @example
|
|
18
|
+
* const txt = textarea.text(); // gets text value
|
|
19
|
+
* textarea.text("New Text"); // sets new text value
|
|
20
|
+
* textarea.text("Appended Text", TextAction.Append); // Appends new text to the end of current text
|
|
21
|
+
* textarea.text("Inserted Text", TextAction.Insert); // Inserts at current caret position
|
|
22
|
+
* textarea.text("Inserted Text", TextAction.Insert, textarea.caretPosition() - 50); // Inserts at specified position
|
|
23
|
+
* textarea.text("New Text", TextAction.ReplaceSelection); // Replaces selected text or inserts at current cursor position if no text is selected
|
|
24
|
+
*/
|
|
25
|
+
text(text?: string, action?: TextAction, i?: undefined, ...args: any[]): string | TextArea;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
* @ignore
|
|
29
|
+
*/
|
|
30
|
+
rows(...args: any[]): any;
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
* @ignore
|
|
34
|
+
*/
|
|
35
|
+
columns(...args: any[]): any;
|
|
36
|
+
/**
|
|
37
|
+
* Sets or gets line wrapping mode. Line wrapping helps to display long lines without having to scroll horizontally.
|
|
38
|
+
*
|
|
39
|
+
* @param {LineWrap} [value] - One of: LineWrap.Word, LineWrap.Character, LineWrap.None (default).
|
|
40
|
+
* @return {LineWrap|TextArea} When setting a value, `this` TextArea component is returned; otherwise a current line wrapping value is returned.
|
|
41
|
+
* @see LineWrap
|
|
42
|
+
*/
|
|
43
|
+
lineWrap(...args: any[]): LineWrap | TextArea;
|
|
44
|
+
}
|
|
45
|
+
import { TextComponent } from "./TextComponent.js";
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextComponent is not a standalone component. TextComponent extends {@link UIComponent} and serves a purpose to implement text editor related methods and properties.
|
|
3
|
+
*
|
|
4
|
+
* TextComponent is extended by {@link TextField}, {@link PasswordField}, {@link TextArea}, {@link DocumentEditor}, {@link Spinner} and {@link ComboBox}.
|
|
5
|
+
* @class
|
|
6
|
+
* @global
|
|
7
|
+
*/
|
|
8
|
+
export class TextComponent extends UIComponent {
|
|
9
|
+
/**
|
|
10
|
+
* TextComponent constructor.
|
|
11
|
+
* @internal
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
constructor(...args: any[]);
|
|
15
|
+
/**
|
|
16
|
+
* Sets or gets whether component's text can be edited by user typing. Applies to components such as TextField, TextArea, DocumentEditor, ComboBox, Password, Spinner, Tree (to edit list item).
|
|
17
|
+
*
|
|
18
|
+
* @param {boolean} [editable] - enables or disables editing
|
|
19
|
+
* @return {Object|boolean} If arguments is passed, returns `this` component instance, otherwise returns `boolean` value.
|
|
20
|
+
*/
|
|
21
|
+
editable(...args: any[]): Object | boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Gets a boolean indicating if undo operation can be performed on the text. Only applies to components where text can be types (excluding Table cell editor).
|
|
24
|
+
* @readonly
|
|
25
|
+
* @type {boolean}
|
|
26
|
+
*/
|
|
27
|
+
readonly get canUndo(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Gets a boolean indicating if redo operation can be performed on the text. Only applies to components where text can be types (excluding Table cell editor).
|
|
30
|
+
* @readonly
|
|
31
|
+
* @type boolean
|
|
32
|
+
*/
|
|
33
|
+
readonly get canRedo(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Attempts to perform undo operation and returns boolean specifying if undo operations can be performed on the text again. Only applies to components where text can be types (excluding Table cell editor).
|
|
36
|
+
* @return boolean
|
|
37
|
+
*/
|
|
38
|
+
undo(): any;
|
|
39
|
+
/**
|
|
40
|
+
* Attempts to perform redo operation and returns boolean specifying if redo operations can be performed on the text again. Only applies to components where text can be types (excluding Table cell editor).
|
|
41
|
+
* @return boolean
|
|
42
|
+
*/
|
|
43
|
+
redo(): any;
|
|
44
|
+
/**
|
|
45
|
+
* Sets or gets the maximum amount of last edits that can be undone.
|
|
46
|
+
* @param {number} [limit] - Value 0 disabled undo/redo operation. Default is 100.
|
|
47
|
+
* @return {this|number} Returns `this` component if argument is provided, otherwise returns `number` value.
|
|
48
|
+
*/
|
|
49
|
+
undoLimit(...args: any[]): this | number;
|
|
50
|
+
/**
|
|
51
|
+
* Sets or gets whether GUI should handle key combinations CTRL+Z and CTRL+Y to perform undo and redo actions for text editing components. If disabled, undo and redo can still be performed by calling undo() and redo() methods.
|
|
52
|
+
* @param {boolean} enable - Enables/disables undo/redo performed by keyboard keys. Default is `true`.
|
|
53
|
+
* @return {this|boolean} Returns `this` component if argument is provided, otherwise returns `boolean` value.
|
|
54
|
+
*/
|
|
55
|
+
undoEnabled(...args: any[]): this | boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Copies selected text to clipboard and removes it from text. Applies only to some text editing components, such as TextArea.
|
|
58
|
+
*
|
|
59
|
+
* @return {this} Returns `this` component
|
|
60
|
+
*/
|
|
61
|
+
cutSelection(): this;
|
|
62
|
+
/**
|
|
63
|
+
* Copies selected text to clipboard. Applies only to some text editing components, such as TextArea.
|
|
64
|
+
*
|
|
65
|
+
* @return {this} Returns `this` component
|
|
66
|
+
*/
|
|
67
|
+
copySelection(): this;
|
|
68
|
+
/**
|
|
69
|
+
* Inserts clipboard text into component's text as current caret position. Applies only to some text editing components, such as TextArea.
|
|
70
|
+
*
|
|
71
|
+
* @return {this} Returns `this` component
|
|
72
|
+
*/
|
|
73
|
+
paste(): this;
|
|
74
|
+
/**
|
|
75
|
+
* Removes selected text. Applies only to some text editing components, such as TextArea, Password, DocumentEditor, etc.
|
|
76
|
+
*
|
|
77
|
+
* @return {this} Returns `this` component instance for method chaining.
|
|
78
|
+
*/
|
|
79
|
+
deleteSelection(): this;
|
|
80
|
+
/**
|
|
81
|
+
* Selects/deselects all text of the component. Applies only to some text editing components, such as TextArea.
|
|
82
|
+
*
|
|
83
|
+
* @param {boolean} [selected=true] - `true` to select all, `false` to deselect all.
|
|
84
|
+
* @return {this} Returns `this` component
|
|
85
|
+
*/
|
|
86
|
+
selectAll(selected?: boolean): this;
|
|
87
|
+
/**
|
|
88
|
+
* Selects text at specified position and length or gets current selection as an object {start:number, length:number, text:string}.
|
|
89
|
+
*
|
|
90
|
+
* @param {number} [start] - Beginning position of text to be selected.
|
|
91
|
+
* @param {number} [end] - End position of text to be selected. If `start` argument is provided but `end` is omitted, `end` will be same as `start`, simply placing cursor at the `start` position.
|
|
92
|
+
* @return {{start:number, end:number, text:string}|this} If arguments are provided, `this` TextField component is returned; otherwise current selection is returned as object {start:number, end:number, text:string}.
|
|
93
|
+
* @example
|
|
94
|
+
* // Setting selection
|
|
95
|
+
* textfield.selection(10, 30);
|
|
96
|
+
* @example
|
|
97
|
+
* // getting selection
|
|
98
|
+
* let s = textfield.selection();
|
|
99
|
+
* console.log(`Selected from ${s.start} to ${s.end}: ${s.text}`);
|
|
100
|
+
*/
|
|
101
|
+
selection(...args: any[]): {
|
|
102
|
+
start: number;
|
|
103
|
+
end: number;
|
|
104
|
+
text: string;
|
|
105
|
+
} | this;
|
|
106
|
+
/**
|
|
107
|
+
* Set or gets a position of caret in text editing components. Used in some text editing components only.
|
|
108
|
+
*
|
|
109
|
+
* @param {number} [position] - The zero-based caret position to set. If omitted, returns current caret position.
|
|
110
|
+
* @return {this|number} If argument is provided, returns an instance of `this` component, otherwise a current caret position.
|
|
111
|
+
*/
|
|
112
|
+
caretPosition(...args: any[]): this | number;
|
|
113
|
+
/**
|
|
114
|
+
* Gets, registers or unregisters an event handler function for caret position changes and text selection changes in text editing components.
|
|
115
|
+
*
|
|
116
|
+
* @param {function(CaretEvent): any} [callback=undefined] - The event handler function that receives a {@link CaretEvent} object. Pass `null` to unregister all handler functions.
|
|
117
|
+
* @param {boolean} [remove=false] - Set to `true` to unregister the event handler.
|
|
118
|
+
* @returns {this|function[]} An array of handler functions if no arguments are passed, otherwise `this` component for method chaining.
|
|
119
|
+
* @see CaretEvent
|
|
120
|
+
* @example
|
|
121
|
+
* // Example event object:
|
|
122
|
+
* const e = {
|
|
123
|
+
* target: object, // The component that triggered the event.
|
|
124
|
+
* type: string, // `change`.
|
|
125
|
+
* position: number, // New caret position
|
|
126
|
+
* selectionStart: number, // Start position of selected text
|
|
127
|
+
* selectionEnd: number, // End position of selected text
|
|
128
|
+
* line: number, // Line of text where caret is now. Present only in some components, such as DocumentEditor.
|
|
129
|
+
* column: number, // Position of caret from the beginning of the line where caret is now. Present only in multi-line text editing components, such as DocumentEditor.
|
|
130
|
+
* styles: object // Text formatting information of the text segment where caret is now. Present only for DocumentEditor component when HTML is enabled.
|
|
131
|
+
* path: string[], // HTML tag hierarchy. Present only for DocumentEditor component when HTML is enabled.
|
|
132
|
+
* };
|
|
133
|
+
*/
|
|
134
|
+
onCaretEvents(...args: any[]): this | Function[];
|
|
135
|
+
}
|
|
136
|
+
import { UIComponent } from "./UIComponent.js";
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextField component is the most popular text input component used for name, address, email, and many other data types. It can be formatted to define a specific input format. It can also use a regular expression to only accept specified characters or predefined input text format.
|
|
3
|
+
*
|
|
4
|
+
* @class
|
|
5
|
+
* @global
|
|
6
|
+
* @see TextComponent
|
|
7
|
+
*/
|
|
8
|
+
export class TextField extends TextComponent {
|
|
9
|
+
/**
|
|
10
|
+
* Sets or gets a text mask formatter with a specified mask string and a placeholder character.
|
|
11
|
+
*
|
|
12
|
+
* A mask string defines the allowed characters at each position.
|
|
13
|
+
* Each special character in the mask has a meaning:
|
|
14
|
+
*
|
|
15
|
+
* - `#` — A digit (0–9).
|
|
16
|
+
* - `U` — An uppercase letter (A–Z).
|
|
17
|
+
* - `L` — A lowercase letter (a–z).
|
|
18
|
+
* - `A` — Any letter (A–Z or a–z).
|
|
19
|
+
* - `?` — Any letter (case-insensitive).
|
|
20
|
+
* - `*` — Any character (letter or digit).
|
|
21
|
+
* - `H` — A hexadecimal character (0–9, A–F, a–f).
|
|
22
|
+
* - `.` , `,` , `:` , `-` , `/` — These are treated as **literal** characters and appear in the formatted text.
|
|
23
|
+
* - `'` (single quote) — Escape character. Place before a literal mask character if you don’t want it treated specially.
|
|
24
|
+
* Example: `"'#'###"` means literal `#` followed by three digits.
|
|
25
|
+
*
|
|
26
|
+
* Example masks:
|
|
27
|
+
* - `"###-##-####"` → U.S. Social Security number (digits with dashes).
|
|
28
|
+
* - `"(###) ###-####"` → U.S. phone number.
|
|
29
|
+
* - `"UUU-####"` → Three uppercase letters, dash, and four digits.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} [mask] - Text mask string. Set to empty string or `null` to clear the mask.
|
|
32
|
+
* @param {string} [placeholder="_"] - A character to use for empty characters in the mask. Default is "_" character.
|
|
33
|
+
* @return {{mask:string, placeholder:string}|TextField} When setting a mask, returns `this` TextField component for chaining. When called without arguments, returns the current mask information object.
|
|
34
|
+
* @example
|
|
35
|
+
* // U.S. Phone number mask
|
|
36
|
+
* textfield.mask("(###) ###-####", "_");
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* // Date input (MM/DD/YYYY)
|
|
40
|
+
* textfield.mask("##/##/####", "_");
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Time input (HH:MM)
|
|
44
|
+
* textfield.mask("##:##", "_");
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Product code input
|
|
48
|
+
* textfield.mask("AAAA-####", "_");
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // Get current mask settings
|
|
52
|
+
* const info = textfield.mask();
|
|
53
|
+
* console.log(info.mask, info.placeholder);
|
|
54
|
+
*/
|
|
55
|
+
mask(...args: any[]): {
|
|
56
|
+
mask: string;
|
|
57
|
+
placeholder: string;
|
|
58
|
+
} | TextField;
|
|
59
|
+
/**
|
|
60
|
+
* Sets or gets a text input filter regular expression that filters the input of text to allow only text that matches filter.
|
|
61
|
+
*
|
|
62
|
+
* The filter must match the **entire text** of the field, not just a single character.
|
|
63
|
+
*
|
|
64
|
+
* NOTE: When setting text to TextField that doesn't match this filter, the text will not be set and previous text will remain in the text field.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} [regex_filter] - Regular expression filter string. Set to empty string to remove existing filter.
|
|
67
|
+
* @return {string|TextField} When setting a filter, `this` TextField component is returned. When called without arguments, returns the current filter string.
|
|
68
|
+
* @example
|
|
69
|
+
* // Allow only digits
|
|
70
|
+
* textfield.filter("^\\d*$");
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // Allow U.S. phone numbers in format 123-456-7890
|
|
74
|
+
* textfield.filter("^\\d{3}-\\d{3}-\\d{4}$");
|
|
75
|
+
*
|
|
76
|
+
* // Allow only characters valid for email address
|
|
77
|
+
* textfield.filter([A-Za-z0-9\.\_\%\+\-\@]);
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* // Allow basic email addresses (accepts partial email)
|
|
81
|
+
* textfield.filter("^[a-zA-Z0-9.\\_\\%\\+\\-]+(@([a-zA-Z0-9-]*(\\.[a-zA-Z0-9-]*)*(\\.[a-zA-Z]*)?))?$");
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* // Allow basic email addresses (email cannot be typed one character at at time, only pasted in full)
|
|
85
|
+
* textfield.filter("^[A-Za-z0-9\\.\\_\\%\\+\\-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$");
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* // Remove filter
|
|
89
|
+
* textfield.filter("");
|
|
90
|
+
*
|
|
91
|
+
*/
|
|
92
|
+
filter(...args: any[]): string | TextField;
|
|
93
|
+
}
|
|
94
|
+
import { TextComponent } from "./TextComponent.js";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextShape is used to draw text as a shape. It can also have a {@link Stroke}, background, and everything like other shapes have.
|
|
3
|
+
*
|
|
4
|
+
* In Text shape you can also specify font parameters, like name, size, underlines, italic, bold, strikethrough and more. Check out {@link FontFamily} enum for generic font family names that can be used for cross-platform compatibility.
|
|
5
|
+
*
|
|
6
|
+
* @class
|
|
7
|
+
* @global
|
|
8
|
+
* @see Shape
|
|
9
|
+
*/
|
|
10
|
+
export class TextShape extends Shape {
|
|
11
|
+
/**
|
|
12
|
+
* Constructor of Text shape. Color, Gradient, or background image are specified in "background" argument, because it's a Shape.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} text - Text to be drawn as shape
|
|
15
|
+
* @param {Font} [font=undefined] - Font object, such as {size: 13, name: "sans-serif", ...}.
|
|
16
|
+
* @param {Stroke} [stroke=null] - Stroke object.
|
|
17
|
+
* @param {string} [background="#000000"] - Background string, CSS style. See {@link Shape#background} for details.
|
|
18
|
+
* @param {number} [opacity=1] - Opacity of the shape. Valid value is a decimal between 0 - 1.
|
|
19
|
+
* @param {number} [x=0] - X position of top-left corner of text
|
|
20
|
+
* @param {number} [y=0] - Y position of top-left corner of text
|
|
21
|
+
* @see Font
|
|
22
|
+
* //@param {number} [width] - Width of the text bounding box. null means all in one line. No wrapping.
|
|
23
|
+
* //@param {number} [height] - Height of the text bounding box. null means auto-detect, without limit.
|
|
24
|
+
*/
|
|
25
|
+
constructor(text: string, font?: Font, stroke?: Stroke, background?: string, opacity?: number, x?: number, y?: number);
|
|
26
|
+
_text: string;
|
|
27
|
+
_font: {
|
|
28
|
+
size: number;
|
|
29
|
+
name: any;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Sets new text to the shape. this will recreate the graphics of the shape for the new text.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} text - New text for the shape.
|
|
35
|
+
* @return {string|TextShape} If called without parameters, current text value is returned; otherwise this `Text` shape object is returned.
|
|
36
|
+
*/
|
|
37
|
+
text(...args: any[]): string | TextShape;
|
|
38
|
+
/**
|
|
39
|
+
* Gets or sets the font used for the `Text` shape. See the example for font object format.
|
|
40
|
+
*
|
|
41
|
+
* @param {Font} [font] - Font object.
|
|
42
|
+
* @return {TextShape|Font}
|
|
43
|
+
* @see Font
|
|
44
|
+
* @example
|
|
45
|
+
* textShape.font({name: "sans-serif", size: 14, italic: true}); // Sets new font.
|
|
46
|
+
* const font = textShape.font(); // gets component's font
|
|
47
|
+
*
|
|
48
|
+
* // Full list of supported font properties:
|
|
49
|
+
* const font = {
|
|
50
|
+
* name: string, // Font name or family name from {@link FontFamily} (e.g., "sans-serif")
|
|
51
|
+
* size: number, // Font size in pixels
|
|
52
|
+
* bold: boolean, // Whether the text is bold
|
|
53
|
+
* italic: boolean, // Whether the text is italic
|
|
54
|
+
* underlined: boolean, // Whether the text is underlined
|
|
55
|
+
* strikethrough: boolean, // Whether the text has a strikethrough
|
|
56
|
+
* direction: string, // Text direction: "ltr" or "rtl"
|
|
57
|
+
* kerning: boolean, // Enable or disable kerning
|
|
58
|
+
* ligatures: boolean, // Enable or disable font ligatures
|
|
59
|
+
* tracking: number // Letter spacing adjustment: -1, 0 (default), or 1
|
|
60
|
+
* };
|
|
61
|
+
* @see Font
|
|
62
|
+
* @see FontFamily
|
|
63
|
+
*/
|
|
64
|
+
font(...args: any[]): TextShape | Font;
|
|
65
|
+
/**
|
|
66
|
+
* Returns a JSON object that contains this shape properties. It may be converted back to this shape.
|
|
67
|
+
*
|
|
68
|
+
* @param {string} [include="all"] - Specified what to include. "all" is default. Valid values are: "all", "stroke", "background", "points", "basic".
|
|
69
|
+
* @return {object} Returns an object containing this shape's properties.
|
|
70
|
+
*/
|
|
71
|
+
toObject(what?: string): object;
|
|
72
|
+
}
|
|
73
|
+
import { Shape } from "./Shape.js";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToggleButton UI component that is similar to a `Button` component, but can be selected.
|
|
3
|
+
* @class
|
|
4
|
+
* @global
|
|
5
|
+
*/
|
|
6
|
+
export class ToggleButton extends UIComponent {
|
|
7
|
+
/**
|
|
8
|
+
* ToggleButton constructor.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} [text] - Button text
|
|
11
|
+
* @example
|
|
12
|
+
* this.button1 = new ToggleButton().text("Click Me");
|
|
13
|
+
* this.button2 = new ToggleButton("Click Me");
|
|
14
|
+
*/
|
|
15
|
+
constructor(...args: any[]);
|
|
16
|
+
/**
|
|
17
|
+
* Sets/Gets selection state of the toggle button.
|
|
18
|
+
*
|
|
19
|
+
* @param {boolean} [selected] - `true` to select, `false` to deselect the toggle button.
|
|
20
|
+
* @return {boolean|ToggleButton} If called without arguments, returns `boolean` value, otherwise returns `this` ToggleButton instance.
|
|
21
|
+
*/
|
|
22
|
+
selected(...args: any[]): boolean | ToggleButton;
|
|
23
|
+
/**
|
|
24
|
+
* Sets/Gets whether the toggle button can be selected by the user.
|
|
25
|
+
*
|
|
26
|
+
* @param {boolean} [selectable] - `true` to allow selection, `false` to prevent the toggle button from being selected.
|
|
27
|
+
* @return {boolean|ToggleButton} If called without arguments, returns `boolean` value, otherwise returns `this` ToggleButton instance.
|
|
28
|
+
* @see ToggleButton#selected
|
|
29
|
+
*/
|
|
30
|
+
selectable(...args: any[]): boolean | ToggleButton;
|
|
31
|
+
/**
|
|
32
|
+
* Sets or gets a value of this component.
|
|
33
|
+
* @param {*} [value] - Value to be held by this component
|
|
34
|
+
* @return {ToggleButton|*} If setting a value, then an instance of `this` component is returned, otherwise current value is returned.
|
|
35
|
+
*/
|
|
36
|
+
value(...args: any[]): ToggleButton | any;
|
|
37
|
+
/**
|
|
38
|
+
* Gets or sets the selected value within this ToggleButton group.
|
|
39
|
+
*
|
|
40
|
+
* If a value is provided, selects a ToggleButton within the group that matches the given value (including this one).
|
|
41
|
+
*
|
|
42
|
+
* @param {number|string} [value] - Value to select within the group.
|
|
43
|
+
* @return {ToggleButton|number|string|null} If value is provided, an instance of `this` object is returned. If no argument is provided, a value of the currently selected radio button in the group is returned, or `null`, if no button is selected or selected button doesn't have a value.
|
|
44
|
+
*/
|
|
45
|
+
selectedValue(...args: any[]): ToggleButton | number | string | null;
|
|
46
|
+
/**
|
|
47
|
+
* Adds this ToggleButton to the group of another ToggleButton while abandoning current group, or removes it from its current group and creates its own when you pass `null`.
|
|
48
|
+
*
|
|
49
|
+
* - Call without parameters to get an Array of all components in its group.
|
|
50
|
+
* - Pass another ToggleButton to join its group.
|
|
51
|
+
* - Pass `null` to leave the current group (if any) and create its own group.
|
|
52
|
+
*
|
|
53
|
+
* @param {ToggleButton|null} [component] - A ToggleButton to join, or `null` to leave the current group. Omit to get the grouped ToggleButton components.
|
|
54
|
+
* @returns {ToggleButton|ToggleButton[]} This ToggleButton, for chaining when called with parameter, otherwise an Array of all ToggleButton components in its group.
|
|
55
|
+
*/
|
|
56
|
+
group(...args: any[]): ToggleButton | ToggleButton[];
|
|
57
|
+
/**
|
|
58
|
+
* Deselect all RadioButton elements grouped with this element.
|
|
59
|
+
*
|
|
60
|
+
* @return {RadioButton} Returns `this` component.
|
|
61
|
+
*/
|
|
62
|
+
clearSelection(): RadioButton;
|
|
63
|
+
/**
|
|
64
|
+
* Sets or gets an action command. This command is specified in event object for onAction(e => {alert(e.command);}) event handler.
|
|
65
|
+
* Default value of action command for a Button is it's initial text.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} [command] (Optional)
|
|
68
|
+
* @return {string|Button} If called without arguments, returns `number` value, otherwise returns `this` Button instance.
|
|
69
|
+
* @example
|
|
70
|
+
* const button = new Button("Activate").addTo(window).center();
|
|
71
|
+
* button.command("Activate Motor 1");
|
|
72
|
+
* button.onAction(e => {
|
|
73
|
+
* alert(e.command); // shows a dialog window with a message "Activate Motor 1" when button is clicked.
|
|
74
|
+
* });
|
|
75
|
+
*/
|
|
76
|
+
command(...args: any[]): string | Button;
|
|
77
|
+
/**
|
|
78
|
+
* Returns current size of an icon, or `null` when no icon has been set or icon failed to load.
|
|
79
|
+
* @readonly
|
|
80
|
+
* @type {Size|null}
|
|
81
|
+
*/
|
|
82
|
+
readonly get iconSize(): Size | null;
|
|
83
|
+
}
|
|
84
|
+
import { UIComponent } from "./UIComponent.js";
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A toolbar component that is usually used at the top of window and can hold {@link Label}, {@link Button}, {@link TextField}, {@link ComboBox}, and a {@link Separator} to display useful tools for a user.
|
|
3
|
+
*
|
|
4
|
+
* Toolbar can be draggable and can be detached and displayed in a separate dedicated window. It can also be in horizontal (default) and vertical orientation.
|
|
5
|
+
*
|
|
6
|
+
* ToolBar extends ComponentContainer, which extends UIComponent.
|
|
7
|
+
*
|
|
8
|
+
* @class
|
|
9
|
+
* @global
|
|
10
|
+
*/
|
|
11
|
+
export class ToolBar extends ComponentContainer {
|
|
12
|
+
/**
|
|
13
|
+
* Create an instance of ToolBar component object.
|
|
14
|
+
*/
|
|
15
|
+
constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Sets of gets whether the ToolBar can be detached from the Window it was added to.
|
|
18
|
+
*
|
|
19
|
+
* @param {boolean} [detachable] - `true` to enable detaching, `false` to disable.
|
|
20
|
+
* @return {boolean|ToolBar} If no parameters were passed, current value is returned, otherwise `this` Toolbar component is returned for method chaining.
|
|
21
|
+
*/
|
|
22
|
+
detachable(...args: any[]): boolean | ToolBar;
|
|
23
|
+
/**
|
|
24
|
+
* Sets or gets boolean whether the toolbar is attached to main Window. Has no affect if not attached to a Window yet.
|
|
25
|
+
*
|
|
26
|
+
* @param {boolean} [attached] - `true` to attach, `false` to detach from Window component the ToolBar is added to.
|
|
27
|
+
* @param {{x:number, y:number}} [floating_position] - Position on screen where toolbar should float {x:number, y:number}.
|
|
28
|
+
* @return {boolean|ToolBar} If no parameters were passed, current state is returned; otherwise `this` Toolbar component is returned for method chaining.
|
|
29
|
+
*/
|
|
30
|
+
attached(...args: any[]): boolean | ToolBar;
|
|
31
|
+
/**
|
|
32
|
+
* Sets or gets vertical or horizontal orientation of the ToolBar.
|
|
33
|
+
*
|
|
34
|
+
* @param {Orientation} [orientation] - One of these values: Orientation.Horizontal (default) or Orientation.Vertical
|
|
35
|
+
* @return {Orientation|ToolBar} If no parameters were passed, current orientation is returned; otherwise `this` Toolbar component is returned for method chaining.
|
|
36
|
+
* @see Orientation
|
|
37
|
+
*/
|
|
38
|
+
orientation(...args: any[]): Orientation | ToolBar;
|
|
39
|
+
/**
|
|
40
|
+
* Sets or gets a padding size between edge of the component and items inside it, and spacing between items.
|
|
41
|
+
*
|
|
42
|
+
* @param {number} padding - Padding size in pixels.
|
|
43
|
+
* @return {number|ToolBar} If no parameters were passed, current padding is returned; otherwise `this` Toolbar component is returned for method chaining.
|
|
44
|
+
*/
|
|
45
|
+
padding(...args: any[]): number | ToolBar;
|
|
46
|
+
/**
|
|
47
|
+
* Set or get alignment of components within toolbar.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} [alignment] - "leading|trailing|left|center|right"
|
|
50
|
+
* @return {string|ToolBar} If no parameters were passed, current alignment is returned; otherwise `this` Toolbar component is returned for method chaining.
|
|
51
|
+
*/
|
|
52
|
+
alignment(...args: any[]): string | ToolBar;
|
|
53
|
+
/**
|
|
54
|
+
* Add an invisible spacer of specified width and height.
|
|
55
|
+
*
|
|
56
|
+
* @param {number} width - Width of the spacer block
|
|
57
|
+
* @param {number} height - Height of the spacer block
|
|
58
|
+
* @return {ToolBar} Returns `this` ToolBar component for method chaining.
|
|
59
|
+
*/
|
|
60
|
+
addSpacer(width: number, height: number): ToolBar;
|
|
61
|
+
/**
|
|
62
|
+
* Gets, registers or unregisters a docking event handler function. This event handler is called when the ToolBar gets attached/detached.
|
|
63
|
+
*
|
|
64
|
+
* @param {function(Object): any} [callback] - The event handler function. Receives an event object.
|
|
65
|
+
* @param {boolean} [remove=false] - Set to `true` to unregister the event handler.
|
|
66
|
+
* @returns {ToolBar|function[]} An array of handler functions if no arguments are passed, otherwise `this` component for method chaining.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Event object format:
|
|
70
|
+
* const e = {
|
|
71
|
+
* target: object, // The ToolBar component that triggered the event.
|
|
72
|
+
* type: string, // "attached", "detached".
|
|
73
|
+
* interactive: boolean // Only when type is "update". `true` when update was made by the user interacting with the GUI. `false` when update was made programmatically.
|
|
74
|
+
* orientation: Orientation // current orientation
|
|
75
|
+
* location: string // "top", "bottom", "left", "right". Only when `e.interactive` is `true`.
|
|
76
|
+
* mouseX: number // Mouse X position relative to Window's content area. Only when `e.interactive` is `true`.
|
|
77
|
+
* mouseY: number // Mouse Y position relative to Window's content area. Only when `e.interactive` is `true`.
|
|
78
|
+
* };
|
|
79
|
+
*/
|
|
80
|
+
onDockEvents(callback?: (arg0: Object) => any, ...args: any[]): ToolBar | Function[];
|
|
81
|
+
}
|
|
82
|
+
import { ComponentContainer } from "./ComponentContainer.js";
|