swing-ui 1.0.1 → 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/README.md CHANGED
@@ -77,7 +77,7 @@ class HelloApp extends Window {
77
77
  super("swing-ui Demo");
78
78
  this.innerSize(360, 160).position(200, 200).closeOperation(Window.CloseOperation.Exit);
79
79
 
80
- new Label("What's your name?").position(20, 20).addTo(this);
80
+ new Label("What's your name?").position(20, 20).size(300, 25).addTo(this);
81
81
  const name = new TextField("type name here").size(300, 28).position(20, 45).addTo(this);
82
82
 
83
83
  new Button("Greet me").position(20, 85).addTo(this)
@@ -803,7 +803,7 @@ export class ComponentContainer extends UIComponent
803
803
  {
804
804
  try
805
805
  {
806
- component[event](new Function('e', func.substring(11).trim()).bind(this));
806
+ component[event](new Function('e', func.substring(11).trim()).bind(component));
807
807
  }catch(ex)
808
808
  {
809
809
  component[event]((...args) =>
@@ -251,9 +251,9 @@ class UIComponent
251
251
  }
252
252
 
253
253
  /**
254
- * Gets a parent Object. If this component wasn't added to any container component, then `null` is returned.
254
+ * Gets a parent container component. If this component wasn't added to any container component, then `null` is returned.
255
255
  * @readonly
256
- * @type {Object|undefined}
256
+ * @type {UIComponent|null}
257
257
  */
258
258
  get parent()
259
259
  {
@@ -263,6 +263,47 @@ class UIComponent
263
263
  return UIComponent.get(this.parent_id);
264
264
  }
265
265
 
266
+ /**
267
+ * Gets a previous sibling component. If this component wasn't added to any container component, then `null` is returned.
268
+ * @readonly
269
+ * @type {UIComponent|null}
270
+ * @since 1.0.2
271
+ */
272
+ get previousSibling()
273
+ {
274
+ if(this.parent == null) return null;
275
+ let i = this.parent.childIndex(this);
276
+ if(i === 0) return null;
277
+ return this.parent.child(i - 1);
278
+ }
279
+
280
+ /**
281
+ * Gets a next sibling component. If this component wasn't added to any container component, then `null` is returned.
282
+ * @readonly
283
+ * @type {UIComponent|null}
284
+ * @since 1.0.2
285
+ */
286
+ get nextSibling()
287
+ {
288
+ if(this.parent == null) return null;
289
+ let i = this.parent.childIndex(this);
290
+ return this.parent.child(i + 1);
291
+ }
292
+
293
+ /**
294
+ * Gets an array of sibling components.
295
+ * @readonly
296
+ * @type {UIComponent[]}
297
+ * @since 1.0.2
298
+ */
299
+ get siblings()
300
+ {
301
+ if(this.parent == null) return [];
302
+ const _siblings = this.parent.children;
303
+ _siblings.splice(_siblings.indexOf(this), 1);
304
+ return _siblings;
305
+ }
306
+
266
307
  /**
267
308
  * Gets a Window component containing this component. Returns `null` if no Window contain this component.
268
309
  * @readonly
package/enums.js CHANGED
@@ -160,7 +160,7 @@ export const SelectionMode = Object.freeze({Single: 0, Range: 1, Multiple: 2});
160
160
  * textarea.font({name: FontFamily.SansSerif});
161
161
  *
162
162
  * @example <h2>Setting Text shape font:</h2>
163
- * let text = new Text("Hello World", {name: FontFamily.Fantasy, size: 30});
163
+ * let text = new TextShape("Hello World", {name: FontFamily.Fantasy, size: 30});
164
164
  */
165
165
  export const FontFamily = Object.freeze({Serif: "serif", SansSerif: "sans-serif", Monospaced: "monospace", Cursive: "cursive", System: "system-ui", Fantasy: "fantasy"});
166
166
 
package/icon.png CHANGED
Binary file
package/jar/gui-11.jar CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "swing-ui",
3
- "version": "1.0.1",
4
- "description": "Graphic User Interface for JavaScript",
3
+ "version": "1.0.3",
4
+ "description": "Cross-platform Graphic User Interface for Node.js, Bun and Deno 2+",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "docs": "jsdoc -c docs-files/jsdoc.json",
@@ -89,11 +89,32 @@ export class UIComponent {
89
89
  */
90
90
  readonly get id(): number;
91
91
  /**
92
- * Gets a parent Object. If this component wasn't added to any container component, then `null` is returned.
92
+ * Gets a parent container component. If this component wasn't added to any container component, then `null` is returned.
93
93
  * @readonly
94
- * @type {Object|undefined}
94
+ * @type {UIComponent|null}
95
95
  */
96
- readonly get parent(): Object | undefined;
96
+ readonly get parent(): UIComponent | null;
97
+ /**
98
+ * Gets a previous sibling component. If this component wasn't added to any container component, then `null` is returned.
99
+ * @readonly
100
+ * @type {UIComponent|null}
101
+ * @since 1.0.2
102
+ */
103
+ readonly get previousSibling(): UIComponent | null;
104
+ /**
105
+ * Gets a next sibling component. If this component wasn't added to any container component, then `null` is returned.
106
+ * @readonly
107
+ * @type {UIComponent|null}
108
+ * @since 1.0.2
109
+ */
110
+ readonly get nextSibling(): UIComponent | null;
111
+ /**
112
+ * Gets an array of sibling components.
113
+ * @readonly
114
+ * @type {UIComponent[]}
115
+ * @since 1.0.2
116
+ */
117
+ readonly get siblings(): UIComponent[];
97
118
  /**
98
119
  * Gets a Window component containing this component. Returns `null` if no Window contain this component.
99
120
  * @readonly
package/types/enums.d.ts CHANGED
@@ -225,7 +225,7 @@ export type FontFamily = string;
225
225
  * textarea.font({name: FontFamily.SansSerif});
226
226
  *
227
227
  * @example <h2>Setting Text shape font:</h2>
228
- * let text = new Text("Hello World", {name: FontFamily.Fantasy, size: 30});
228
+ * let text = new TextShape("Hello World", {name: FontFamily.Fantasy, size: 30});
229
229
  */
230
230
  export const FontFamily: Readonly<{
231
231
  Serif: "serif";