swing-ui 1.0.5 → 1.0.6
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/README.md +2 -2
- package/SwingUI.js +4 -3
- package/classes/Arc.js +2 -2
- package/classes/Table.js +11 -9
- package/classes/UIComponent.js +4 -7
- package/icon.png +0 -0
- package/jar/gui-11.jar +0 -0
- package/package.json +1 -1
- package/typedefs.js +3 -3
- package/types/SwingUI.d.ts +8 -0
- package/types/classes/Table.d.ts +9 -9
- package/types/classes/UIComponent.d.ts +7 -9
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ If you've shipped a desktop app in JS before, you've probably lived one of these
|
|
|
67
67
|
npm install swing-ui
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
> Install it locally in each project — not with `-g
|
|
70
|
+
> Install it locally in each project — not with `-g` option.
|
|
71
71
|
|
|
72
72
|
```js
|
|
73
73
|
import "swing-ui";
|
|
@@ -117,7 +117,7 @@ That's just a taste. Tables, trees, tabs, menus, system tray icons, custom drawi
|
|
|
117
117
|
- Financial software with graphical graphs and charts
|
|
118
118
|
- and much more...
|
|
119
119
|
|
|
120
|
-
Anywhere you want a real desktop app without the weight of a browser runtime, and without leaving JavaScript to get it. With thousands
|
|
120
|
+
Anywhere you want a real desktop app without the weight of a browser runtime, and without leaving JavaScript to get it. With thousands of JavaScript modules now almost anything is possible in JavaScript.
|
|
121
121
|
|
|
122
122
|
---
|
|
123
123
|
|
package/SwingUI.js
CHANGED
|
@@ -1162,13 +1162,13 @@ export class SwingUI
|
|
|
1162
1162
|
* data[DataType.HTML] = "<b>HTML Content</b>";
|
|
1163
1163
|
* ui.clipboard(data);
|
|
1164
1164
|
*/
|
|
1165
|
-
clipboard()
|
|
1165
|
+
clipboard(...args)
|
|
1166
1166
|
{
|
|
1167
|
-
if(
|
|
1167
|
+
if(args.length > 0)
|
|
1168
1168
|
{
|
|
1169
1169
|
this.sendToGUI({
|
|
1170
1170
|
system: "clipboard",
|
|
1171
|
-
value: (typeof
|
|
1171
|
+
value: (typeof args[0] === "string") ? {Text: args[0]} : args[0]
|
|
1172
1172
|
});
|
|
1173
1173
|
return this;
|
|
1174
1174
|
}
|
|
@@ -1250,6 +1250,7 @@ export class SwingUI
|
|
|
1250
1250
|
*
|
|
1251
1251
|
* @param {boolean} enabled - `true` to enable double-buffering (default), `false` to disable.
|
|
1252
1252
|
* @return {SwingUI|boolean} When setting a value, an instance of this `ui` object is returned, otherwise a current value is returned.
|
|
1253
|
+
* @since 1.0.5
|
|
1253
1254
|
*/
|
|
1254
1255
|
doubleBuffer(...args)
|
|
1255
1256
|
{
|
package/classes/Arc.js
CHANGED
|
@@ -96,7 +96,7 @@ export class Arc extends Shape
|
|
|
96
96
|
}
|
|
97
97
|
else
|
|
98
98
|
{
|
|
99
|
-
return {width: this.
|
|
99
|
+
return {width: this._size.width, height: this._size.height};
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -182,4 +182,4 @@ export class Arc extends Shape
|
|
|
182
182
|
|
|
183
183
|
return obj;
|
|
184
184
|
}
|
|
185
|
-
}
|
|
185
|
+
}
|
package/classes/Table.js
CHANGED
|
@@ -707,15 +707,16 @@ export class Table extends ScrollableComponent
|
|
|
707
707
|
/**
|
|
708
708
|
* Sets or gets a row and a column of selected cell.
|
|
709
709
|
*
|
|
710
|
-
* @param {number} [
|
|
710
|
+
* @param {number|TableCell} [row_or_cell] - Row or a TableCell object. (Original order is used, sorting is disregarded.)
|
|
711
711
|
* @param {number} [column] - Column of a cell (required if row is specified). (Original order is used, column reordering is disregarded.)
|
|
712
|
-
* @return {
|
|
712
|
+
* @return {TableCell|Table} When both `row` and `cell` are passed, an instance of `this` Table is returned, otherwise a currently selected `TableCell` object is returned, or NULL if there is no selection.
|
|
713
713
|
*/
|
|
714
714
|
selectedCell(...args)
|
|
715
715
|
{
|
|
716
|
-
if(args.length >
|
|
716
|
+
if(args.length > 0)
|
|
717
717
|
{
|
|
718
|
-
|
|
718
|
+
const cell = (typeof args[0] === "object") ? args[0] : {row: parseInt(args[0]), col: parseInt(args[1])};
|
|
719
|
+
return this.property("selectedCell", [cell]);
|
|
719
720
|
}
|
|
720
721
|
else
|
|
721
722
|
{
|
|
@@ -729,10 +730,10 @@ export class Table extends ScrollableComponent
|
|
|
729
730
|
* Pass `null` as a first argument to stop editing currently edited cell. Do it before reading data from the Table to make sure the cell editor commits it's new value to the Table's data.
|
|
730
731
|
* When called with no arguments, returns the cell currently being edited, or `null` if no cell is being edited.
|
|
731
732
|
*
|
|
732
|
-
* @param {number} [
|
|
733
|
+
* @param {number|TableCell} [row_or_cell] - Row index of the cell or a TableCell object to edit, or `null` to stop editing currently edited cell (if any).
|
|
733
734
|
* @param {number} [column] - Column index of the cell to edit.
|
|
734
735
|
* @param {boolean} [new_order=false] - Specified if row and column should be interpreted as new index as displayed (after row sorting and column reordering) or not.
|
|
735
|
-
* @return {
|
|
736
|
+
* @return {TableCell|null|Table} When row and cell is specified, an instance of `this` Table is returned, otherwise a currently edited cell is retuned of `null` if no cell is being edited.
|
|
736
737
|
* @example <h2>Stop editing before reading Table data</h2>
|
|
737
738
|
* if(table.editingCell() != null) table.editingCell(null); // stop editing a cell to commit its changes
|
|
738
739
|
* const _rows = table.rows(); // read new data
|
|
@@ -743,7 +744,8 @@ export class Table extends ScrollableComponent
|
|
|
743
744
|
|
|
744
745
|
if(args.length > 0)
|
|
745
746
|
{
|
|
746
|
-
|
|
747
|
+
const cell = args[0] == null ? null : (typeof args[0] === "object") ? args[0] : {row: parseInt(args[0]), col: parseInt(args[1])};
|
|
748
|
+
ui.sendToGUI({control:this.id, set: "editingCell", value: cell, data: {new_order: (args[2] === true)}});
|
|
747
749
|
return this;
|
|
748
750
|
}
|
|
749
751
|
else
|
|
@@ -873,11 +875,11 @@ export class Table extends ScrollableComponent
|
|
|
873
875
|
}
|
|
874
876
|
|
|
875
877
|
/**
|
|
876
|
-
* Gets a
|
|
878
|
+
* Gets a TableCell {row,column} located at specified X and Y coordinates relative to the Table's top-left corner.
|
|
877
879
|
*
|
|
878
880
|
* @param {number} x - X
|
|
879
881
|
* @param {number} y - Y
|
|
880
|
-
* @return {
|
|
882
|
+
* @return {TableCell|null} Returns the cell at specified location, or `null` if the coordinates are outside any cell.
|
|
881
883
|
*/
|
|
882
884
|
cellAt(x, y)
|
|
883
885
|
{
|
package/classes/UIComponent.js
CHANGED
|
@@ -267,7 +267,7 @@ class UIComponent
|
|
|
267
267
|
* Gets a previous sibling component. If this component wasn't added to any container component, then `null` is returned.
|
|
268
268
|
* @readonly
|
|
269
269
|
* @type {UIComponent|null}
|
|
270
|
-
* @since 1.0.
|
|
270
|
+
* @since 1.0.2
|
|
271
271
|
*/
|
|
272
272
|
get previousSibling()
|
|
273
273
|
{
|
|
@@ -281,7 +281,7 @@ class UIComponent
|
|
|
281
281
|
* Gets a next sibling component. If this component wasn't added to any container component, then `null` is returned.
|
|
282
282
|
* @readonly
|
|
283
283
|
* @type {UIComponent|null}
|
|
284
|
-
* @since 1.0.
|
|
284
|
+
* @since 1.0.2
|
|
285
285
|
*/
|
|
286
286
|
get nextSibling()
|
|
287
287
|
{
|
|
@@ -294,7 +294,7 @@ class UIComponent
|
|
|
294
294
|
* Gets an array of sibling components.
|
|
295
295
|
* @readonly
|
|
296
296
|
* @type {UIComponent[]}
|
|
297
|
-
* @since 1.0.
|
|
297
|
+
* @since 1.0.2
|
|
298
298
|
*/
|
|
299
299
|
get siblings()
|
|
300
300
|
{
|
|
@@ -445,7 +445,7 @@ class UIComponent
|
|
|
445
445
|
|
|
446
446
|
/**
|
|
447
447
|
* Checks if this component is inside specified ancestor component (at any level, not just direct child).
|
|
448
|
-
* @param {
|
|
448
|
+
* @param {Object} ancestor - Ancestor component to test against
|
|
449
449
|
* @return {boolean}
|
|
450
450
|
* @see ComponentContainer#contains
|
|
451
451
|
*/
|
|
@@ -662,7 +662,6 @@ class UIComponent
|
|
|
662
662
|
/**
|
|
663
663
|
* @internal
|
|
664
664
|
* @ignore
|
|
665
|
-
* @private
|
|
666
665
|
* @param {string} property
|
|
667
666
|
* @param {any} value
|
|
668
667
|
* @return {any}
|
|
@@ -697,7 +696,6 @@ class UIComponent
|
|
|
697
696
|
* @return {Function[]|this} If only the `name` argument is provided, returns an array of registered callback functions. Otherwise, returns `this` component.
|
|
698
697
|
* @internal
|
|
699
698
|
* @ignore
|
|
700
|
-
* @private
|
|
701
699
|
* @example
|
|
702
700
|
* const _callbacks_array = button.event("onAction"); // gets an array of previously registered handler functions
|
|
703
701
|
* button.event("onAction", _callbacks_array[0], true); // unregisters callback function, same as button.onAction(_callbacks_array[0], true);
|
|
@@ -1175,7 +1173,6 @@ class UIComponent
|
|
|
1175
1173
|
if(this === menu || typeof menu !== "object" || !(menu instanceof globalThis.ContextMenu)) // can't use !(menu instanceof ContextMenu) because ContextMenu imports this class, thus would create circular import.
|
|
1176
1174
|
{
|
|
1177
1175
|
throw new Error(ui._msg[10]);
|
|
1178
|
-
return this;
|
|
1179
1176
|
}
|
|
1180
1177
|
|
|
1181
1178
|
if(this.#context_menu != null) this.contextMenu(null); // remove existing menu before setting a new one
|
package/icon.png
CHANGED
|
Binary file
|
package/jar/gui-11.jar
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/typedefs.js
CHANGED
|
@@ -695,13 +695,13 @@
|
|
|
695
695
|
/**
|
|
696
696
|
* Table cell coordinates containing column and row property.
|
|
697
697
|
*
|
|
698
|
-
* @typedef {Object}
|
|
698
|
+
* @typedef {Object} TableCell
|
|
699
699
|
* @property {number} column - a column index of the cell
|
|
700
700
|
* @property {number} row - a row index of the cell
|
|
701
701
|
*
|
|
702
702
|
* @see Table#cellAt
|
|
703
|
-
* @see Table#
|
|
704
|
-
* @see Table#
|
|
703
|
+
* @see Table#selectedCell
|
|
704
|
+
* @see Table#editingCell
|
|
705
705
|
*
|
|
706
706
|
*/
|
|
707
707
|
|
package/types/SwingUI.d.ts
CHANGED
|
@@ -295,6 +295,14 @@ export class SwingUI {
|
|
|
295
295
|
* );
|
|
296
296
|
*/
|
|
297
297
|
ui(...args: any[]): string | SwingUI;
|
|
298
|
+
/**
|
|
299
|
+
* Sets/get whether double-buffering should be used in rendering GUI in Java. Disabling may help to fix some graphical issues in Linux if flickering happens on component repaint.
|
|
300
|
+
*
|
|
301
|
+
* @param {boolean} enabled - `true` to enable double-buffering (default), `false` to disable.
|
|
302
|
+
* @return {SwingUI|boolean} When setting a value, an instance of this `ui` object is returned, otherwise a current value is returned.
|
|
303
|
+
* @since 1.0.5
|
|
304
|
+
*/
|
|
305
|
+
doubleBuffer(...args: any[]): SwingUI | boolean;
|
|
298
306
|
/**
|
|
299
307
|
* Shows a message dialog window like alert() in web browser.
|
|
300
308
|
*
|
package/types/classes/Table.d.ts
CHANGED
|
@@ -466,26 +466,26 @@ export class Table extends ScrollableComponent {
|
|
|
466
466
|
/**
|
|
467
467
|
* Sets or gets a row and a column of selected cell.
|
|
468
468
|
*
|
|
469
|
-
* @param {number} [
|
|
469
|
+
* @param {number|TableCell} [row_or_cell] - Row or a TableCell object. (Original order is used, sorting is disregarded.)
|
|
470
470
|
* @param {number} [column] - Column of a cell (required if row is specified). (Original order is used, column reordering is disregarded.)
|
|
471
|
-
* @return {
|
|
471
|
+
* @return {TableCell|Table} When both `row` and `cell` are passed, an instance of `this` Table is returned, otherwise a currently selected `TableCell` object is returned, or NULL if there is no selection.
|
|
472
472
|
*/
|
|
473
|
-
selectedCell(...args: any[]):
|
|
473
|
+
selectedCell(...args: any[]): TableCell | Table;
|
|
474
474
|
/**
|
|
475
475
|
* Gets or sets the cell currently being edited.
|
|
476
476
|
* When `row` and `column` are provided and are valid, the specified cell enters edit mode.
|
|
477
477
|
* Pass `null` as a first argument to stop editing currently edited cell. Do it before reading data from the Table to make sure the cell editor commits it's new value to the Table's data.
|
|
478
478
|
* When called with no arguments, returns the cell currently being edited, or `null` if no cell is being edited.
|
|
479
479
|
*
|
|
480
|
-
* @param {number} [
|
|
480
|
+
* @param {number|TableCell} [row_or_cell] - Row index of the cell or a TableCell object to edit, or `null` to stop editing currently edited cell (if any).
|
|
481
481
|
* @param {number} [column] - Column index of the cell to edit.
|
|
482
482
|
* @param {boolean} [new_order=false] - Specified if row and column should be interpreted as new index as displayed (after row sorting and column reordering) or not.
|
|
483
|
-
* @return {
|
|
483
|
+
* @return {TableCell|null|Table} When row and cell is specified, an instance of `this` Table is returned, otherwise a currently edited cell is retuned of `null` if no cell is being edited.
|
|
484
484
|
* @example <h2>Stop editing before reading Table data</h2>
|
|
485
485
|
* if(table.editingCell() != null) table.editingCell(null); // stop editing a cell to commit its changes
|
|
486
486
|
* const _rows = table.rows(); // read new data
|
|
487
487
|
*/
|
|
488
|
-
editingCell(...args: any[]):
|
|
488
|
+
editingCell(...args: any[]): TableCell | null | Table;
|
|
489
489
|
/**
|
|
490
490
|
* Sets or gets whether sorting can be toggled to unsorted state.
|
|
491
491
|
*
|
|
@@ -573,13 +573,13 @@ export class Table extends ScrollableComponent {
|
|
|
573
573
|
height: number;
|
|
574
574
|
};
|
|
575
575
|
/**
|
|
576
|
-
* Gets a
|
|
576
|
+
* Gets a TableCell {row,column} located at specified X and Y coordinates relative to the Table's top-left corner.
|
|
577
577
|
*
|
|
578
578
|
* @param {number} x - X
|
|
579
579
|
* @param {number} y - Y
|
|
580
|
-
* @return {
|
|
580
|
+
* @return {TableCell|null} Returns the cell at specified location, or `null` if the coordinates are outside any cell.
|
|
581
581
|
*/
|
|
582
|
-
cellAt(x: number, y: number):
|
|
582
|
+
cellAt(x: number, y: number): TableCell | null;
|
|
583
583
|
/**
|
|
584
584
|
* Sets or gets how many quick mouse clicks on editable cells are required to change the cell to editing mode.
|
|
585
585
|
*
|
|
@@ -98,21 +98,21 @@ export class UIComponent {
|
|
|
98
98
|
* Gets a previous sibling component. If this component wasn't added to any container component, then `null` is returned.
|
|
99
99
|
* @readonly
|
|
100
100
|
* @type {UIComponent|null}
|
|
101
|
-
* @since 1.0.
|
|
101
|
+
* @since 1.0.2
|
|
102
102
|
*/
|
|
103
103
|
readonly get previousSibling(): UIComponent | null;
|
|
104
104
|
/**
|
|
105
105
|
* Gets a next sibling component. If this component wasn't added to any container component, then `null` is returned.
|
|
106
106
|
* @readonly
|
|
107
107
|
* @type {UIComponent|null}
|
|
108
|
-
* @since 1.0.
|
|
108
|
+
* @since 1.0.2
|
|
109
109
|
*/
|
|
110
110
|
readonly get nextSibling(): UIComponent | null;
|
|
111
111
|
/**
|
|
112
112
|
* Gets an array of sibling components.
|
|
113
113
|
* @readonly
|
|
114
114
|
* @type {UIComponent[]}
|
|
115
|
-
* @since 1.0.
|
|
115
|
+
* @since 1.0.2
|
|
116
116
|
*/
|
|
117
117
|
readonly get siblings(): UIComponent[];
|
|
118
118
|
/**
|
|
@@ -176,11 +176,11 @@ export class UIComponent {
|
|
|
176
176
|
verifyComponent(): this;
|
|
177
177
|
/**
|
|
178
178
|
* Checks if this component is inside specified ancestor component (at any level, not just direct child).
|
|
179
|
-
* @param {
|
|
179
|
+
* @param {Object} ancestor - Ancestor component to test against
|
|
180
180
|
* @return {boolean}
|
|
181
181
|
* @see ComponentContainer#contains
|
|
182
182
|
*/
|
|
183
|
-
insideOf(ancestor:
|
|
183
|
+
insideOf(ancestor: Object): boolean;
|
|
184
184
|
/**
|
|
185
185
|
* Sets or gets component's visibility.
|
|
186
186
|
* NOTE: Window and InternalWindow components visibility is set to `false` by default. Use .visible(true) or .show() to make it visible.
|
|
@@ -257,12 +257,11 @@ export class UIComponent {
|
|
|
257
257
|
/**
|
|
258
258
|
* @internal
|
|
259
259
|
* @ignore
|
|
260
|
-
* @private
|
|
261
260
|
* @param {string} property
|
|
262
261
|
* @param {any} value
|
|
263
262
|
* @return {any}
|
|
264
263
|
*/
|
|
265
|
-
|
|
264
|
+
property(property: string, ...args: any[]): any;
|
|
266
265
|
/**
|
|
267
266
|
* Registers, unregisters, and gets an event handler callback function for a specified events.
|
|
268
267
|
*
|
|
@@ -276,13 +275,12 @@ export class UIComponent {
|
|
|
276
275
|
* @return {Function[]|this} If only the `name` argument is provided, returns an array of registered callback functions. Otherwise, returns `this` component.
|
|
277
276
|
* @internal
|
|
278
277
|
* @ignore
|
|
279
|
-
* @private
|
|
280
278
|
* @example
|
|
281
279
|
* const _callbacks_array = button.event("onAction"); // gets an array of previously registered handler functions
|
|
282
280
|
* button.event("onAction", _callbacks_array[0], true); // unregisters callback function, same as button.onAction(_callbacks_array[0], true);
|
|
283
281
|
* button.event("onAction", e => {console.debug(e);}); // registers new event handler function, same as button.onAction(e => {console.debug(e);});
|
|
284
282
|
*/
|
|
285
|
-
|
|
283
|
+
event(name: string, callback?: (arg0: Object) => any | null, remove?: boolean): Function[] | this;
|
|
286
284
|
/**
|
|
287
285
|
* Sets or gets the background color of the component. <br />
|
|
288
286
|
* <br />
|