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.
Files changed (116) hide show
  1. package/LICENSE +5 -4
  2. package/README.md +144 -7
  3. package/SwingUI.js +2611 -0
  4. package/classes/Arc.js +185 -0
  5. package/classes/Button.js +55 -0
  6. package/classes/CheckBox.js +33 -0
  7. package/classes/CheckBoxMenuItem.js +24 -0
  8. package/classes/ComboBox.js +329 -0
  9. package/classes/ComponentContainer.js +828 -0
  10. package/classes/ContextMenu.js +141 -0
  11. package/classes/DocumentEditor.js +168 -0
  12. package/classes/Ellipse.js +76 -0
  13. package/classes/InternalWindow.js +397 -0
  14. package/classes/InternalWindowContainer.js +93 -0
  15. package/classes/Label.js +52 -0
  16. package/classes/Line.js +105 -0
  17. package/classes/List.js +452 -0
  18. package/classes/MediaPlayer.js +504 -0
  19. package/classes/Menu.js +74 -0
  20. package/classes/MenuBar.js +56 -0
  21. package/classes/MenuItem.js +92 -0
  22. package/classes/Panel.js +50 -0
  23. package/classes/PasswordField.js +47 -0
  24. package/classes/Polygon.js +236 -0
  25. package/classes/Polyline.js +240 -0
  26. package/classes/ProgressBar.js +62 -0
  27. package/classes/RadioButton.js +110 -0
  28. package/classes/RadioButtonMenuItem.js +106 -0
  29. package/classes/Rectangle.js +199 -0
  30. package/classes/ScrollPane.js +53 -0
  31. package/classes/ScrollableComponent.js +141 -0
  32. package/classes/Separator.js +24 -0
  33. package/classes/Shape.js +584 -0
  34. package/classes/ShapeContainer.js +231 -0
  35. package/classes/Slider.js +172 -0
  36. package/classes/Spinner.js +172 -0
  37. package/classes/SplitView.js +82 -0
  38. package/classes/Stroke.js +115 -0
  39. package/classes/Table.js +982 -0
  40. package/classes/Tabs.js +228 -0
  41. package/classes/TextArea.js +125 -0
  42. package/classes/TextComponent.js +207 -0
  43. package/classes/TextField.js +128 -0
  44. package/classes/TextShape.js +123 -0
  45. package/classes/ToggleButton.js +147 -0
  46. package/classes/ToolBar.js +120 -0
  47. package/classes/TrayIcon.js +54 -0
  48. package/classes/Tree.js +569 -0
  49. package/classes/UIComponent.js +2154 -0
  50. package/classes/Window.js +609 -0
  51. package/enums.js +298 -0
  52. package/fonts.conf +32 -0
  53. package/functions.js +254 -0
  54. package/icon.png +0 -0
  55. package/index.js +109 -4
  56. package/jar/gui-11.jar +0 -0
  57. package/jar/lib/flatlaf.jar +0 -0
  58. package/jar/lib/jna.jar +0 -0
  59. package/package.json +58 -33
  60. package/typedefs.js +973 -0
  61. package/types/SwingUI.d.ts +727 -0
  62. package/types/classes/Arc.d.ts +111 -0
  63. package/types/classes/Button.d.ts +38 -0
  64. package/types/classes/CheckBox.d.ts +22 -0
  65. package/types/classes/CheckBoxMenuItem.d.ts +18 -0
  66. package/types/classes/ComboBox.d.ts +172 -0
  67. package/types/classes/ComponentContainer.d.ts +131 -0
  68. package/types/classes/ContextMenu.d.ts +74 -0
  69. package/types/classes/DocumentEditor.d.ts +95 -0
  70. package/types/classes/Ellipse.d.ts +34 -0
  71. package/types/classes/InternalWindow.d.ts +163 -0
  72. package/types/classes/InternalWindowContainer.d.ts +36 -0
  73. package/types/classes/Label.d.ts +33 -0
  74. package/types/classes/Line.d.ts +48 -0
  75. package/types/classes/List.d.ts +223 -0
  76. package/types/classes/MediaPlayer.d.ts +381 -0
  77. package/types/classes/Menu.d.ts +43 -0
  78. package/types/classes/MenuBar.d.ts +26 -0
  79. package/types/classes/MenuItem.d.ts +57 -0
  80. package/types/classes/Panel.d.ts +28 -0
  81. package/types/classes/PasswordField.d.ts +22 -0
  82. package/types/classes/Polygon.d.ts +93 -0
  83. package/types/classes/Polyline.d.ts +96 -0
  84. package/types/classes/ProgressBar.d.ts +36 -0
  85. package/types/classes/RadioButton.d.ts +70 -0
  86. package/types/classes/RadioButtonMenuItem.d.ts +71 -0
  87. package/types/classes/Rectangle.d.ts +82 -0
  88. package/types/classes/ScrollPane.d.ts +23 -0
  89. package/types/classes/ScrollableComponent.d.ts +81 -0
  90. package/types/classes/Separator.d.ts +14 -0
  91. package/types/classes/Shape.d.ts +223 -0
  92. package/types/classes/ShapeContainer.d.ts +92 -0
  93. package/types/classes/Slider.d.ts +107 -0
  94. package/types/classes/Spinner.d.ts +129 -0
  95. package/types/classes/SplitView.d.ts +47 -0
  96. package/types/classes/Stroke.d.ts +99 -0
  97. package/types/classes/Table.d.ts +652 -0
  98. package/types/classes/Tabs.d.ts +118 -0
  99. package/types/classes/TextArea.d.ts +45 -0
  100. package/types/classes/TextComponent.d.ts +136 -0
  101. package/types/classes/TextField.d.ts +94 -0
  102. package/types/classes/TextShape.d.ts +73 -0
  103. package/types/classes/ToggleButton.d.ts +84 -0
  104. package/types/classes/ToolBar.d.ts +82 -0
  105. package/types/classes/TrayIcon.d.ts +43 -0
  106. package/types/classes/Tree.d.ts +354 -0
  107. package/types/classes/UIComponent.d.ts +966 -0
  108. package/types/classes/Window.d.ts +334 -0
  109. package/types/enums.d.ts +437 -0
  110. package/types/functions.d.ts +109 -0
  111. package/types/index.d.ts +188 -0
  112. package/types/typedefs.d.ts +1626 -0
  113. package/ui-process-manager.js +317 -0
  114. package/video-devices-linux.sh +72 -0
  115. package/video-devices-mac.sh +33 -0
  116. package/CHANGES.md +0 -3
@@ -0,0 +1,34 @@
1
+ /**
2
+ * `Ellipse` shape can draw an oval (when height and width are different) or a circle (when height and width are same).
3
+ *
4
+ * Ellipse extends the {@link Shape} class.
5
+ * @class
6
+ * @global
7
+ * @see Shape
8
+ */
9
+ export class Ellipse extends Shape {
10
+ /**
11
+ * Creates an instance of Arc shape.
12
+ *
13
+ * @param {Stroke} [stroke=undefined] - A border of the shape.
14
+ * @param {string} [background=undefined] - Color, gradient, or image background, similar to CSS. Use an empty string to remove the background.
15
+ * @param {number} [opacity=1] - Opacity of the shape (0 to 1).
16
+ * @param {number} [x=0] - Horizontal position from the left edge.
17
+ * @param {number} [y=0] - Vertical position from the top edge.
18
+ * @param {number} [width=100] - Width of the ellipse (horizontal diameter).
19
+ * @param {number} [height=undefined] - Height of the ellipse (vertical diameter). If omitted, height will be same as width.
20
+ */
21
+ constructor(stroke?: Stroke, background?: string, opacity?: number, x?: number, y?: number, width?: number, height?: number);
22
+ _size: {
23
+ width: number;
24
+ height: number;
25
+ };
26
+ /**
27
+ * Returns a JSON object that contains this shape properties. It may be converted back to this shape.
28
+ *
29
+ * @param {string} [include="all"] - Specified what to include. "all" is default. Valid values are: "all", "stroke", "background", "points", "basic".
30
+ * @return {object} Returns an object containing this shape's properties.
31
+ */
32
+ toObject(include?: string): object;
33
+ }
34
+ import { Shape } from "./Shape.js";
@@ -0,0 +1,163 @@
1
+ /**
2
+ * InternalWindow UI component. Extends ComponentContainer, which extends UIComponent class.
3
+ * Internal window is a Window like component, but it can only be added to InternalWindowContainer for window-in-window experience.
4
+ * By default, InternalWindow is not visible. Use .visible(true) or .show() to make it visible.
5
+ *
6
+ * For more methods for this component check UIComponent class.
7
+ * @class
8
+ * @global
9
+ */
10
+ export class InternalWindow extends ComponentContainer {
11
+ /**
12
+ * Sets or gets the operation to perform when the InternalWindow's close button is clicked by a user or a close() method is called on this InternalWindow.
13
+ *
14
+ * Default value is `Window.CloseOperation.Dispose`.
15
+ *
16
+ * @param {Window.CloseOperation} [operation] - One of Window.CloseOperation enum values. (default is `Dispose`)
17
+ * @return {InternalWindow|Window.CloseOperation} Returns `this` component if argument is provided, otherwise returns value.
18
+ */
19
+ closeOperation(...args: any[]): InternalWindow | Window.CloseOperation;
20
+ /**
21
+ * Gets, registers or unregisters an event handler for when the state of the Window changes between normal, minimized, maximized.
22
+ *
23
+ * @param {function(Object): any} [callback] - The event handler function. Receives an event object.
24
+ * @param {boolean} [remove=false] - Set to `true` to unregister the event handler.
25
+ * @returns {this}
26
+ *
27
+ * @example
28
+ * // Example event object:
29
+ * const e = {
30
+ * target: InternalWindow, // The component that triggered the event.
31
+ * type: string, // `change`
32
+ * fromState: Window.State, // Previous state
33
+ * toState: Window.State, // New state
34
+ * interactive: boolean // Indicates if the state was changed by user's interaction with window
35
+ * };
36
+ */
37
+ onStateChange(callback?: (arg0: Object) => any, ...args: any[]): this;
38
+ /**
39
+ * Gets, registers or unregisters an event handler for window events, such as activate, deactivate, close, etc.
40
+ *
41
+ * @param {function(Object): any} [callback] - The event handler function. Receives an event object.
42
+ * @param {boolean} [remove=false] - Set to `true` to unregister the event handler.
43
+ * @returns {this}
44
+ *
45
+ * @example
46
+ * // Example event object:
47
+ * const e = {
48
+ * target: InternalWindow, // The component that triggered the event.
49
+ * type: string, // `activate`, `deactivate`, `minimize`, `restore`, `closing`, `close`, `show`
50
+ * interactive: boolean // Indicates if triggered by user's interaction with window
51
+ * };
52
+ */
53
+ onWindowEvents(callback?: (arg0: Object) => any, ...args: any[]): this;
54
+ /**
55
+ * Performs previously specified close operation on this InternalWindow.
56
+ * To specify what operation should be performed use closeOperation(Window.CloseOperation.[Nothing|Exit|Hide|Dispose])
57
+ *
58
+ * @return {InternalWindow} Returns this window component
59
+ */
60
+ close(): InternalWindow;
61
+ /**
62
+ * Sets or get a window state. Use one of these enum values: Window.State.[Normal|Minimized|Maximized]
63
+ *
64
+ * @param {Window.State} [state] - Setting new window state
65
+ * @returns {Window.State|Window} Returns `this` Window if argument is provided, otherwise returns current state.
66
+ * @example
67
+ * window.state(Window.State.Maximized);
68
+ * if(window.state() === Window.State.Maximized) console.log("It works!");
69
+ */
70
+ state(...args: any[]): Window.State | Window;
71
+ /**
72
+ * Sets or gets whether minimize button in window title bar should be visible.
73
+ * @param {boolean} [value] - `true` to show (default), `false` - to hide.
74
+ * @return {InternalWindow|boolean} Returns `this` component instance if argument is set, otherwise returns current value.
75
+ */
76
+ minimizable(...args: any[]): InternalWindow | boolean;
77
+ /**
78
+ * Sets or gets whether maximize button in window title bar should be visible.
79
+ * @param {boolean} [value] - `true` to show (default), `false` - to hide.
80
+ * @return {InternalWindow|boolean} Returns `this` component instance if argument is set, otherwise returns current value.
81
+ */
82
+ maximizable(...args: any[]): InternalWindow | boolean;
83
+ /**
84
+ * Sets or gets whether close button in window title bar should be visible.
85
+ * @param {boolean} [value] - `true` to show (default), `false` - to hide.
86
+ * @return {InternalWindow|boolean} Returns `this` component instance if argument is set, otherwise returns current value.
87
+ */
88
+ closable(...args: any[]): InternalWindow | boolean;
89
+ /**
90
+ * Sets or gets the ability to resize the window in GUI. Programmatically it can still be resized even when this is disabled.
91
+ * @param {boolean} [value] - `true` to enable (default), `false` - to disable.
92
+ * @return {InternalWindow|boolean} Returns `this` component instance if argument is set, otherwise returns current value.
93
+ */
94
+ resizable(...args: any[]): InternalWindow | boolean;
95
+ /**
96
+ * Sets or gets the ability to move the window in GUI by dragging title bar or resizing. Programmatically it can still be moved and resized even when this is disabled.
97
+ * This may not be supported in Linux and some other systems.
98
+ *
99
+ * @param {boolean} [value] - `true` to enable (default), `false` - to disable.
100
+ * @return {InternalWindow|boolean} Returns `this` component instance if argument is set, otherwise returns current value.
101
+ */
102
+ movable(...args: any[]): InternalWindow | boolean;
103
+ /**
104
+ * Sets or gets whether the InternalWindow should be above other internal windows in default layer. It puts the InternalWindow component in a higher layer. More than one InternalWindow can be in the top layer.
105
+ *
106
+ * @param {boolean} [value] - `true` to set enable, `false` to disable (default).
107
+ * @return {InternalWindow|boolean} Returns `this` component instance if argument is set, otherwise returns current value.
108
+ */
109
+ alwaysOnTop(...args: any[]): InternalWindow | boolean;
110
+ /**
111
+ * Make this window be selected (activated) or not.
112
+ *
113
+ * @param {boolean} [selected] - `true` to activate, `false` to deactivate.
114
+ * @return {InternalWindow|boolean} Returns `this` component instance if argument is set, otherwise returns current value.
115
+ */
116
+ selected(...args: any[]): InternalWindow | boolean;
117
+ /**
118
+ * Sets or gets a size of content container of this Window (doesn't include the size of the window borders like size() function does).
119
+ *
120
+ * @param {number|Size} [width_or_size] - Width integer or a Size object as a sole parameter.
121
+ * @param {number} [height] - Integer height value (required if the first argument is a numeric width).
122
+ * @return {InternalWindow|Size} Returns `this` InternalWindow component if called with parameters, otherwise returns the inner size.
123
+ * @see Size
124
+ */
125
+ innerSize(...args: any[]): InternalWindow | Size;
126
+ /**
127
+ * Indicates the minimum size the content container of the InternalWindow it can be resized to. It overrides previously set minSize() value.
128
+ *
129
+ * @param {number|Size} width_or_size - Width, or a Size formatted object as a sole parameter.
130
+ * @param {number} height - Height of the component.
131
+ * @returns {Size|InternalWindow|null} If called without parameters, current minimum inner Size is returned or `null` if it wasn't previously set; otherwise returns `this` component instance for chaining.
132
+ * @see InternalWindow#maxInnerSize
133
+ * @see UIComponent#minSize
134
+ * @see Size
135
+ */
136
+ minInnerSize(...args: any[]): Size | InternalWindow | null;
137
+ /**
138
+ * Indicates the maximum size the content container of the InternalWindow it can be resized to. It overrides previously set maxSize() value.
139
+ *
140
+ * @param {number|Size} width_or_size - Width, or a Size formatted object as a sole parameter.
141
+ * @param {number} height - Height of the component.
142
+ * @returns {Size|InternalWindow|null} If called without parameters, current maximum inner Size is returned or `null` if it wasn't previously set; otherwise returns `this` component instance for chaining.
143
+ * @see InternalWindow#minInnerSize
144
+ * @see UIComponent#maxSize
145
+ * @see Size
146
+ */
147
+ maxInnerSize(...args: any[]): Size | InternalWindow | null;
148
+ /**
149
+ * Gets the offset (in pixels) from each edge of the window to the content container.
150
+ * @type {Object}
151
+ * @example
152
+ * // Returned offset object format:
153
+ * {
154
+ * top: number,
155
+ * right: number,
156
+ * bottom: number,
157
+ * left: number
158
+ * }
159
+ */
160
+ get innerOffset(): Object;
161
+ #private;
162
+ }
163
+ import { ComponentContainer } from "./ComponentContainer.js";
@@ -0,0 +1,36 @@
1
+ /**
2
+ * InternalWindowContainer UI component, extends ScrollableComponent class.
3
+ * Internal window container is a component designed to contain InternalWindow components.
4
+ *
5
+ * For more methods for this component check {@link ComponentContainer}, {@link ScrollableComponent} and {@link UIComponent} classes.
6
+ * @class
7
+ * @global
8
+ */
9
+ export class InternalWindowContainer extends ComponentContainer {
10
+ /**
11
+ * Sets or gets currently selected InternalWindow component.
12
+ *
13
+ * @window [InternalWindow] [window] - InternalWindow component that should become selected.
14
+ * @return {InternalWindowContainer|InternalWindow|null} - If setting, returns `this` component instance. If getting, returns selected InternalWindow or `null` (if there are no windows added yet).
15
+ */
16
+ selectedWindow(...args: any[]): InternalWindowContainer | InternalWindow | null;
17
+ /**
18
+ * Sets or gets an index of a selected InternalWindow component.
19
+ *
20
+ * @param {number} [index] - Index of an item to select.
21
+ * @returns {number|InternalWindowContainer} If index is specified, then `this` component instance is returned, otherwise currently selected InternalWindow index is returned.
22
+ * @see InternalWindow
23
+ * @see InternalWindowContainer#selectedWindow
24
+ */
25
+ selectedIndex(...args: any[]): number | InternalWindowContainer;
26
+ /**
27
+ * Prevents internal windows from being moved outside of visible area of window container. Otherwise windows can be move beyond the boundaries and scroll bars would appear to scroll to those windows.
28
+ * This may not work on some systems yet.
29
+ *
30
+ * @param {boolean} [enforce] - To enable border enforcement set `true`, to disable set `false.
31
+ * @return {InternalWindowContainer|boolean} If setting, returns `this` component instance, otherwise returns `boolean` value.
32
+ */
33
+ enforceBoundaries(...args: any[]): InternalWindowContainer | boolean;
34
+ }
35
+ import { ComponentContainer } from "./ComponentContainer.js";
36
+ import { InternalWindow } from "./InternalWindow.js";
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Label UI component, extends UIComponent class.
3
+ * Label can be used to display plain text, HTML content, and image as an icon.
4
+ *
5
+ * For more methods for this component check UIComponent class.
6
+ * @class
7
+ * @global
8
+ */
9
+ export class Label extends UIComponent {
10
+ /**
11
+ * Label constructor.
12
+ * @param {string} [text] - Initial text to display in the label.
13
+ * @example <h2>Few ways to create and use Label:</h2>
14
+ * // Setting text in constructor
15
+ * const label1 = new Label("New label text");
16
+ *
17
+ * // Setting text after instantiation
18
+ * const label2 = new Label().text("Second label text");
19
+ *
20
+ * // setting an image icon
21
+ * const label2 = new Label().icon("images/icon.png");
22
+ *
23
+ * // setting HTML content to be rendered in the label component
24
+ * const label2 = new Label("<html><body><h1>Label Header</h1><p>New paragraph</p></body></html>");
25
+ */
26
+ constructor(...args: any[]);
27
+ /**
28
+ * Returns current size of an icon, or `undefined` when no icon has been set or icon failed to load.
29
+ * @type {Object|undefined}
30
+ */
31
+ get iconSize(): Object | undefined;
32
+ }
33
+ import { UIComponent } from "./UIComponent.js";
@@ -0,0 +1,48 @@
1
+ /**
2
+ * A `Line` shape that extends the {@link Shape} class.
3
+ *
4
+ * Line is a geometric line that doesn't have an area to be filled. For the line to be visible you specify the stroke size to be more that 0.
5
+ *
6
+ * Line points are relative to the position of the `Line` shape. If you daw multiple lines that are related to each other, make sure to set same position for each of the lines.
7
+ * @class
8
+ * @global
9
+ * @see Shape
10
+ */
11
+ export class Line extends Shape {
12
+ /**
13
+ * Creates an instance of a Line shape.
14
+ *
15
+ * @param {Stroke} stroke - A border of the shape.
16
+ * @param {number} opacity - Opacity of the shape (0 to 1).
17
+ * @param {number} [x] - Horizontal position from the left edge.
18
+ * @param {number} [y] - Vertical position from the top edge.
19
+ * @param {number} [point1] - An object with X and Y coordinates {x: number, y: number}.
20
+ * @param {number} [point2] - An object with X and Y coordinates {x: number, y: number}.
21
+ */
22
+ constructor(stroke: Stroke, opacity?: number, x?: number, y?: number, point1?: number, point2?: number);
23
+ _points: any[];
24
+ /**
25
+ * Sets or gets the first point of the line.
26
+ *
27
+ * @param {number|{x:number, y:number}} x - X coordinate of the point, or an object with X and Y coordinates {x: number, y: number}.
28
+ * @param {number} [y] - Y coordinate of the point (required only if `x` parameter is a number).
29
+ * @returns {Line|Point} If called without parameters, returns current point; otherwise returns this Line shape for chaining.
30
+ */
31
+ point1(...args: any[]): Line | Point;
32
+ /**
33
+ * Sets or gets the second point of the line.
34
+ *
35
+ * @param {number|{x:number, y:number}} x - X coordinate of the point, or an object with X and Y coordinates {x: number, y: number}.
36
+ * @param {number} [y] - Y coordinate of the point (required only if `x` parameter is a number).
37
+ * @return {Line|Point} If called without parameters, returns current point; otherwise returns this Line shape for chaining.
38
+ */
39
+ point2(...args: any[]): Line | Point;
40
+ /**
41
+ * Returns a JSON object that contains this shape properties. It may be converted back to this shape.
42
+ *
43
+ * @param {string} [include="all"] - Specified what to include. "all" is default. Valid values are: "all", "stroke", "background", "points", "basic".
44
+ * @return {object} Returns an object containing this shape's properties.
45
+ */
46
+ toObject(include?: string): object;
47
+ }
48
+ import { Shape } from "./Shape.js";
@@ -0,0 +1,223 @@
1
+ /**
2
+ * List UI component, extends ScrollableComponent class, which extends UIComponent class.
3
+ * List can be a list of text items, icons, or icons and text. List direction can be vertical, horizontal with wrapping, and vertical with wrapping.
4
+ * Check example below to become familiar with how the item Object is formatted.
5
+ *
6
+ * For more methods for this component check UIComponent class.
7
+ * @class
8
+ * @global
9
+ * @see ScrollableComponent
10
+ * @see ListItem
11
+ * @example
12
+ *
13
+ * // Item Object format (All fields other than "text" are optional):
14
+ * {
15
+ * text: string, // Item text (Required)
16
+ * [id]: string|number, // Value that can be used by software logic to identify this item
17
+ * [value]: string|number, // Additional value to be stored in the item for later use.
18
+ * [icon]: string, // Absolute or relative path to icon image, base64 encoded image string, or `null` to remove icon.
19
+ * [color]: string, // Item text color as a 6 character hex encoded color string (e.g. #665500)
20
+ * [background]: string, // Item background color as a 6 character hex encoded color string (e.g. #665500)
21
+ * [tooltip]: string, // Tooltip text to show when pointer hover the item. (in List and Tree components only)
22
+ * [font]: font object // Object{name: string, size: number, bold: boolean, ...}. See complete list of font properties in example of font() method.
23
+ * }
24
+ */
25
+ export class List extends ScrollableComponent {
26
+ /**
27
+ * Layouts that can be used to display list items.
28
+ * @readonly
29
+ * @enum {number}
30
+ * @property {number} Vertical - Items are arranged in a single vertical column.
31
+ * @property {number} VerticalWrap - Items flow vertically and wrap into additional columns if needed.
32
+ * @property {number} HorizontalWrap - Items flow horizontally and wrap into additional rows if needed.
33
+ * @example
34
+ * list.layout(List.Layout.VerticalWrap);
35
+ */
36
+ static readonly Layout: Readonly<{
37
+ Vertical: 0;
38
+ VerticalWrap: 1;
39
+ HorizontalWrap: 2;
40
+ }>;
41
+ /**
42
+ * Adds a list item at the end of the list, or inserts the item at specified index.
43
+ *
44
+ * @param {string|number|ListItem} item - List item as a string, number, or ListItem formatted object.
45
+ * @param {number} index - Integer position at which to add the item.
46
+ * @returns {number} Returns an index at which the item was inserted, or -1 if item was not inserted for some reason.
47
+ * @see ListItem
48
+ * @example
49
+ * const i = combo1.add({text: "New Item", ...more optional properties}); // Adding item as object
50
+ * const i = combo1.add("New Item"); // Adding item as string
51
+ * const i = combo1.add(45); // Adding item as number
52
+ */
53
+ add(item: string | number | ListItem, index?: number): number;
54
+ /**
55
+ * If index argument is specified, N amount of items starting form specified index will be removed.
56
+ * If called without parameters, this component will be removed from it's parent. See examples below.
57
+ *
58
+ * @param {number} [index=undefined] - Index of the item to remove. If not provided, the component will be removed from its parent.
59
+ * @param {number} [deleteCount=1] - Amount of items to remove
60
+ * @returns {List} Returns `this` ComboBox instance.
61
+ * @example
62
+ * list.remove(); // removes the component from it's parent container
63
+ * list.remove(4); // removes list item at index 4
64
+ * list.remove(4, 3); // removes 3 items starting at index 4
65
+ */
66
+ remove(...args: any[]): List;
67
+ /**
68
+ * Gets the amount of items in the list.
69
+ * @readonly
70
+ * @type {number}
71
+ */
72
+ readonly get length(): number;
73
+ /**
74
+ * Gets, sets or updates an item at a specified index. Check usage examples below.
75
+ *
76
+ * @param {number} index - Index of the list item
77
+ * @param {ListItem} [item] - Item object. See object format in the example of ComboBox.add() documentation.
78
+ * @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`.
79
+ * @returns {List|ListItem} If item argument is passed, then `this` List instance is returned, otherwise item at specified index is returned. If index is out of range, `undefined` is returned.
80
+ * @see ListItem
81
+ * @example
82
+ * const item = list.item(3); // gets the item at index 3
83
+ * list.item(3, {text: "New text", value:"new value"}); // replaces item at index 3
84
+ * list.item(3, {background: "#FF7777"}, true); // changes item's background color at index 3
85
+ */
86
+ item(i: any, ...args: any[]): List | ListItem;
87
+ /**
88
+ * Sets selected indexes of elements in the list or returns an array of selected indexes.
89
+ *
90
+ * @param {number[]|number|null} [indices] - Array of indexes to be selected, one index number, `null` or -1 to deselect all items
91
+ * @returns {List|Array} When setting, `this` component instance is returned, otherwise an array indexes of selected items is returned.
92
+ */
93
+ selection(...args: any[]): List | any[];
94
+ /**
95
+ * Gets an Array of selected items. Returns selected items as an Array of objects, or empty Array if no item is selected.
96
+ *
97
+ * @readonly
98
+ * @type {ListItem[]}
99
+ */
100
+ readonly get selectedItems(): ListItem[];
101
+ /**
102
+ * Sets or gets an index of a selected item. Can be used to make one item at certain index to be selected.
103
+ * To select more than one item make sure to enable multi-selection by selectionMode(SelectionMode.Multiple), and then use selection() method instead.
104
+ *
105
+ * @param {number} [index] - Index of an item to select.
106
+ * @returns {List|number} If index is specified, then `this` component instance is returned, otherwise currently selected index is returned.
107
+ */
108
+ selectedIndex(...args: any[]): List | number;
109
+ /**
110
+ * Sets or returns a selection mode, which defines how list items can be selected (only one item, multiple items together as a range, or any combination of items).
111
+ *
112
+ * @param {SelectionMode} mode - One of: SelectionMode.Single, SelectionMode.Multiple, SelectionMode.Range. See {@link SelectionMode}.
113
+ * @returns {SelectionMode|List}
114
+ * @see SelectionMode
115
+ */
116
+ selectionMode(...args: any[]): SelectionMode | List;
117
+ /**
118
+ * Selects/Deselects all items in the List
119
+ *
120
+ * @param {boolean} [selected=true] - `true` to select all items, `false` to deselect.
121
+ * @return {List} Returns an instance of `this` List for method chaining.
122
+ */
123
+ selectAll(selected?: boolean): List;
124
+ /**
125
+ * Sets or gets items of the list.
126
+ * @arg {Array.<(object|string|number)>} [items] - Array of items as objects or strings
127
+ * @returns {List|object[]} If items are passed, returns an instance of `this` List, otherwise returns an Object Array of items.
128
+ * @example
129
+ * list.items([{value:1, text:"Label 1", ...}, [{value:2, text:"Label 2", ...}); // Sets items by an array of objects
130
+ * list.items(["Label 1", "Label 2", ...]); // Sets items by an array of strings
131
+ * list.items(["Label 1", {value:1, text:"Label 1", ...}, 45); // Sets items as an array of strings, objects and numbers
132
+ */
133
+ items(...args: any[]): List | object[];
134
+ /**
135
+ * Removes all items from the list.
136
+ * @returns {List} Returns an instance of ths List.
137
+ */
138
+ clear(): List;
139
+ /**
140
+ * Sets or get layout of the list (Vertical, Horizontal Wrap, or Vertical Wrap).
141
+ * Default is Vertical.
142
+ *
143
+ * @param {List.Layout} [layout] - List.Layout.[Vertical|HorizontalWrap|VerticalWrap]
144
+ * @return {List.Layout|List} Returns `this` component instance if argument is provided, otherwise returns the current layout.
145
+ */
146
+ layout(...args: any[]): Readonly<{
147
+ Vertical: 0;
148
+ VerticalWrap: 1;
149
+ HorizontalWrap: 2;
150
+ }> | List;
151
+ /**
152
+ * Sets the size of each item in the list.
153
+ *
154
+ * @param {number|object} [width_or_both] - Width of items as a number, same width and height as a number, or size Object to set both width and height (see examples below).
155
+ * @param {number} [height] - Height of items.
156
+ * @return {object|List} Returns `this` component instance if at least one argument is provided, otherwise returns the current item size.
157
+ * @example
158
+ * itemSize(null) - Resets item size to default (auto size).
159
+ * itemSize(100) - Both width and height are set to 100px.
160
+ * itemSize(100, 150) - width 100, height 150
161
+ * itemSize({width:100, height:150})
162
+ * itemSize() - retrieves size and returns {width:number, height:number} or NULL if it was not previously set.
163
+ */
164
+ itemSize(...args: any[]): object | List;
165
+ /**
166
+ * Sets or gets an alignment of item's label and icon within a list item.
167
+ *
168
+ * @param {string} [alignment] - One or combination of alignment describing strings: top, bottom, left, right, and center. Maximum one horizontal and maximum one vertical alignment is allowed.
169
+ * @return {string|List} Returns `this` component instance if at least one argument is provided, otherwise returns the current layout.
170
+ * @example
171
+ * list.alignment("top left"); // positions label at the top left corner of list item
172
+ * list.alignment("bottom"); // positions label at the bottom-center of list item
173
+ * list.alignment("top center"); // positions label at the top-center of list item
174
+ * list.alignment("center"); // positions label at the center vertically and horizontally
175
+ */
176
+ alignment(...args: any[]): string | List;
177
+ /**
178
+ * Gets or sets a padding for each item in the list. See example below.
179
+ *
180
+ * @param {number|string} [padding] - Number for same padding on all sides, string to specify padding for each side "top right bottom left"
181
+ * @return {string|List} Returns `this` component instance if at least one argument is provided, otherwise returns current padding.
182
+ * @example
183
+ * list.itemPadding(3); // defines same padding for top, right, bottom and left.
184
+ * list.itemPadding("5 0 5 3"); // defines padding for each side separately, top=5, right=0, bottom=5 and left=3.
185
+ * const padding = list.itemPadding(); // gets the padding object
186
+ */
187
+ itemPadding(...args: any[]): string | List;
188
+ /**
189
+ * Sets or gets whether to allow selecting list items with a click of a right mouse button.
190
+ * @param {boolean} [enable] - Boolean value that enables or disables right-click item selection.
191
+ * @return {boolean|List} Returns `this` component instance if at least one argument is provided, otherwise returns current value.
192
+ */
193
+ rightClickSelect(...args: any[]): boolean | List;
194
+ /**
195
+ * Finds items whose text matches the string argument. If item is {text: "First Item", value: "item1"}, it should be found by passing value "First Item".
196
+ *
197
+ * @param {string} value - Search by this text
198
+ * @return {ListItem[]} Returns an array of found items. Each found item will have an `index` property fo convenience.
199
+ */
200
+ findByText(value: string): ListItem[];
201
+ /**
202
+ * Finds first item whose value matches the argument. If item is {text: "First Item", value: "item1", id: 1}, it should be found by passing value "item1".
203
+ *
204
+ * @param {string|number} value - Search by this text or number
205
+ * @return {ListItem[]} Returns an array of found items. Each found item will have an `index` property fo convenience.
206
+ */
207
+ findByValue(value: string | number): ListItem[];
208
+ /**
209
+ * Finds first item whose ID matches the argument. If item is {text: "First Item", value: "item1", id: 1}, it should be found by passing value 1.
210
+ *
211
+ * @param {string|number} value - Search by this text or number
212
+ * @return {ListItem[]} Returns an array of found items. Each found item will have an `index` property fo convenience.
213
+ */
214
+ findByID(value: string | number): ListItem[];
215
+ /**
216
+ * 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 List component.
217
+ *
218
+ * @param {number} index - Index of a list item to make visible.
219
+ * @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.
220
+ */
221
+ scrollToIndex(index?: number, position?: number): any;
222
+ }
223
+ import { ScrollableComponent } from "./ScrollableComponent.js";