@gtkx/react 0.9.1 → 0.9.2
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 +4 -14
- package/dist/batch.d.ts +0 -15
- package/dist/batch.js +0 -15
- package/dist/codegen/jsx-generator.d.ts +1 -25
- package/dist/codegen/jsx-generator.js +13 -51
- package/dist/factory.d.ts +0 -7
- package/dist/factory.js +0 -4
- package/dist/fiber-root.d.ts +0 -5
- package/dist/fiber-root.js +0 -5
- package/dist/generated/jsx.d.ts +1947 -1928
- package/dist/generated/jsx.js +1308 -1300
- package/dist/node.d.ts +0 -4
- package/dist/node.js +0 -4
- package/dist/nodes/menu.js +8 -8
- package/dist/nodes/paged-stack.d.ts +0 -12
- package/dist/nodes/paged-stack.js +0 -4
- package/dist/nodes/selectable-list.js +3 -3
- package/dist/nodes/string-list-container.js +2 -2
- package/dist/nodes/toggle-button.d.ts +0 -8
- package/dist/nodes/toggle-button.js +0 -8
- package/dist/nodes/toolbar-view.d.ts +0 -4
- package/dist/nodes/toolbar-view.js +0 -4
- package/dist/nodes/virtual-item.d.ts +0 -5
- package/dist/nodes/virtual-item.js +0 -5
- package/dist/nodes/widget.d.ts +0 -5
- package/dist/nodes/widget.js +0 -5
- package/dist/nodes/window.js +3 -3
- package/package.json +4 -4
package/dist/node.d.ts
CHANGED
|
@@ -15,10 +15,6 @@ export declare abstract class Node<T extends Gtk.Widget | undefined = Gtk.Widget
|
|
|
15
15
|
protected isVirtual(): boolean;
|
|
16
16
|
protected isStandalone(): boolean;
|
|
17
17
|
constructor(type: string, widget?: Gtk.Widget);
|
|
18
|
-
/**
|
|
19
|
-
* Initializes the node with props. Called by the reconciler after construction.
|
|
20
|
-
* Subclasses can override to perform custom initialization.
|
|
21
|
-
*/
|
|
22
18
|
initialize(props: Props): void;
|
|
23
19
|
protected createWidget(type: string, props: Props): T;
|
|
24
20
|
getWidget(): T;
|
package/dist/node.js
CHANGED
|
@@ -62,10 +62,6 @@ export class Node {
|
|
|
62
62
|
this.widget = widget;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Initializes the node with props. Called by the reconciler after construction.
|
|
67
|
-
* Subclasses can override to perform custom initialization.
|
|
68
|
-
*/
|
|
69
65
|
initialize(props) {
|
|
70
66
|
if (!this.widget && !this.isVirtual()) {
|
|
71
67
|
this.widget = this.createWidget(this.nodeType, props);
|
package/dist/nodes/menu.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getApplication, getNativeObject } from "@gtkx/ffi";
|
|
2
2
|
import * as Gio from "@gtkx/ffi/gio";
|
|
3
3
|
import * as GObject from "@gtkx/ffi/gobject";
|
|
4
4
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
@@ -116,14 +116,14 @@ export class ApplicationMenuNode extends MenuContainerNode {
|
|
|
116
116
|
if (!(this.parent instanceof RootNode)) {
|
|
117
117
|
throw new Error("ApplicationMenu must be a direct child of a fragment at the root level");
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
getApplication().setMenubar(this.menu);
|
|
120
120
|
}
|
|
121
121
|
unmount() {
|
|
122
|
-
|
|
122
|
+
getApplication().setMenubar(undefined);
|
|
123
123
|
super.unmount();
|
|
124
124
|
}
|
|
125
125
|
onMenuRebuilt() {
|
|
126
|
-
|
|
126
|
+
getApplication().setMenubar(this.menu);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
export class MenuItemNode extends NodeClass {
|
|
@@ -198,8 +198,8 @@ export class MenuItemNode extends NodeClass {
|
|
|
198
198
|
this.actionName = generateActionName();
|
|
199
199
|
this.action = new Gio.SimpleAction(this.actionName);
|
|
200
200
|
this.signalHandlerId = this.action.connect("activate", () => this.invokeCurrentCallback());
|
|
201
|
-
const app =
|
|
202
|
-
const action =
|
|
201
|
+
const app = getApplication();
|
|
202
|
+
const action = getNativeObject(this.action.id, Gio.Action);
|
|
203
203
|
if (!action) {
|
|
204
204
|
throw new Error("Failed to get Gio.Action interface from SimpleAction");
|
|
205
205
|
}
|
|
@@ -211,7 +211,7 @@ export class MenuItemNode extends NodeClass {
|
|
|
211
211
|
}
|
|
212
212
|
cleanupAction() {
|
|
213
213
|
if (this.actionName) {
|
|
214
|
-
const app =
|
|
214
|
+
const app = getApplication();
|
|
215
215
|
app.removeAction(this.actionName);
|
|
216
216
|
if (this.currentAccels) {
|
|
217
217
|
app.setAccelsForAction(`app.${this.actionName}`, []);
|
|
@@ -228,7 +228,7 @@ export class MenuItemNode extends NodeClass {
|
|
|
228
228
|
updateAccels(accels) {
|
|
229
229
|
if (!this.actionName)
|
|
230
230
|
return;
|
|
231
|
-
const app =
|
|
231
|
+
const app = getApplication();
|
|
232
232
|
const accelArray = accels ? (Array.isArray(accels) ? accels : [accels]) : [];
|
|
233
233
|
app.setAccelsForAction(`app.${this.actionName}`, accelArray);
|
|
234
234
|
}
|
|
@@ -10,22 +10,10 @@ type StackWidget = Gtk.Widget & {
|
|
|
10
10
|
remove(child: Gtk.Widget): void;
|
|
11
11
|
getPage(child: Gtk.Widget): StackPageLike;
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
14
|
-
* Abstract node for paged stack widgets (Gtk.Stack, Adw.ViewStack).
|
|
15
|
-
* Handles visible child deferral and common page operations.
|
|
16
|
-
*/
|
|
17
13
|
export declare abstract class PagedStackNode<T extends StackWidget> extends NodeClass<T> implements StackPageContainer, ChildContainer {
|
|
18
14
|
static consumedPropNames: string[];
|
|
19
15
|
private pendingVisibleChildName;
|
|
20
|
-
/**
|
|
21
|
-
* Add a page to the stack widget. Must be implemented by subclasses
|
|
22
|
-
* due to API differences between Gtk.Stack and Adw.ViewStack.
|
|
23
|
-
*/
|
|
24
16
|
abstract addStackPage(child: Gtk.Widget, props: StackPageProps): void;
|
|
25
|
-
/**
|
|
26
|
-
* Add a child directly to the stack widget (without page props).
|
|
27
|
-
* Must be implemented by subclasses due to API differences.
|
|
28
|
-
*/
|
|
29
17
|
protected abstract addChildToWidget(child: Gtk.Widget): void;
|
|
30
18
|
protected applyPendingVisibleChild(): void;
|
|
31
19
|
insertStackPageBefore(child: Gtk.Widget, props: StackPageProps, _beforeChild: Gtk.Widget): void;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { Node as NodeClass } from "../node.js";
|
|
2
2
|
import { StackPageNode } from "./stack.js";
|
|
3
3
|
import { applyStackPageProps } from "./stack-page-props.js";
|
|
4
|
-
/**
|
|
5
|
-
* Abstract node for paged stack widgets (Gtk.Stack, Adw.ViewStack).
|
|
6
|
-
* Handles visible child deferral and common page operations.
|
|
7
|
-
*/
|
|
8
4
|
export class PagedStackNode extends NodeClass {
|
|
9
5
|
static consumedPropNames = ["visibleChildName"];
|
|
10
6
|
pendingVisibleChildName = null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getNativeObject } from "@gtkx/ffi";
|
|
2
2
|
import * as Gio from "@gtkx/ffi/gio";
|
|
3
3
|
import * as GObject from "@gtkx/ffi/gobject";
|
|
4
4
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
@@ -41,7 +41,7 @@ export class SelectableListNode extends NodeClass {
|
|
|
41
41
|
initializeSelectionState(props) {
|
|
42
42
|
const selectionMode = props.selectionMode ?? Gtk.SelectionMode.SINGLE;
|
|
43
43
|
const stringList = new Gtk.StringList([]);
|
|
44
|
-
const listModel =
|
|
44
|
+
const listModel = getNativeObject(stringList.id, Gio.ListModel) ?? undefined;
|
|
45
45
|
const selectionModel = selectionMode === Gtk.SelectionMode.MULTIPLE
|
|
46
46
|
? new Gtk.MultiSelection(listModel)
|
|
47
47
|
: new Gtk.SingleSelection(listModel);
|
|
@@ -100,7 +100,7 @@ export class SelectableListNode extends NodeClass {
|
|
|
100
100
|
const currentSelection = this.getSelectedIds();
|
|
101
101
|
const hadHandler = this.state.selectionHandlerId !== null;
|
|
102
102
|
this.disconnectSelectionHandler();
|
|
103
|
-
const listModel =
|
|
103
|
+
const listModel = getNativeObject(this.state.stringList.id, Gio.ListModel) ?? undefined;
|
|
104
104
|
const newSelectionModel = newSelectionMode === Gtk.SelectionMode.MULTIPLE
|
|
105
105
|
? new Gtk.MultiSelection(listModel)
|
|
106
106
|
: new Gtk.SingleSelection(listModel);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getNativeObject } from "@gtkx/ffi";
|
|
2
2
|
import * as Gio from "@gtkx/ffi/gio";
|
|
3
3
|
import { Node as NodeClass } from "../node.js";
|
|
4
4
|
import { getCallbackChange } from "../props.js";
|
|
@@ -44,7 +44,7 @@ export class StringListContainerNode extends NodeClass {
|
|
|
44
44
|
const initialSelection = props.selectedId;
|
|
45
45
|
this.state = { store, onSelectionChanged, initialSelection, hasAppliedInitialSelection: false };
|
|
46
46
|
super.initialize(props);
|
|
47
|
-
this.widget.setModel(
|
|
47
|
+
this.widget.setModel(getNativeObject(store.getModel().id, Gio.ListModel) ?? undefined);
|
|
48
48
|
}
|
|
49
49
|
connectSelectionHandler() {
|
|
50
50
|
const handler = () => {
|
|
@@ -4,14 +4,6 @@ import { Node } from "../node.js";
|
|
|
4
4
|
type ToggleButtonState = {
|
|
5
5
|
lastPropsActive: boolean | undefined;
|
|
6
6
|
};
|
|
7
|
-
/**
|
|
8
|
-
* Specialized node for GtkToggleButton that prevents signal feedback loops.
|
|
9
|
-
*
|
|
10
|
-
* When multiple ToggleButtons share the same state (controlled components),
|
|
11
|
-
* React syncing the `active` prop via setActive() triggers the `toggled` signal.
|
|
12
|
-
* This node guards against that by tracking the expected active state and
|
|
13
|
-
* suppressing callbacks when the signal was caused by a programmatic update.
|
|
14
|
-
*/
|
|
15
7
|
export declare class ToggleButtonNode extends Node<Gtk.ToggleButton, ToggleButtonState> {
|
|
16
8
|
static consumedPropNames: string[];
|
|
17
9
|
static matches(type: string): boolean;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { Node } from "../node.js";
|
|
2
|
-
/**
|
|
3
|
-
* Specialized node for GtkToggleButton that prevents signal feedback loops.
|
|
4
|
-
*
|
|
5
|
-
* When multiple ToggleButtons share the same state (controlled components),
|
|
6
|
-
* React syncing the `active` prop via setActive() triggers the `toggled` signal.
|
|
7
|
-
* This node guards against that by tracking the expected active state and
|
|
8
|
-
* suppressing callbacks when the signal was caused by a programmatic update.
|
|
9
|
-
*/
|
|
10
2
|
export class ToggleButtonNode extends Node {
|
|
11
3
|
static consumedPropNames = ["active"];
|
|
12
4
|
static matches(type) {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { Node } from "../node.js";
|
|
2
|
-
/**
|
|
3
|
-
* Virtual node for AdwToolbarView Top and Bottom slots.
|
|
4
|
-
* These slots use addTopBar/addBottomBar instead of setChild.
|
|
5
|
-
*/
|
|
6
2
|
export declare class ToolbarViewSlotNode extends Node<never> {
|
|
7
3
|
static matches(type: string): boolean;
|
|
8
4
|
protected isVirtual(): boolean;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { Node } from "../node.js";
|
|
2
|
-
/**
|
|
3
|
-
* Virtual node for AdwToolbarView Top and Bottom slots.
|
|
4
|
-
* These slots use addTopBar/addBottomBar instead of setChild.
|
|
5
|
-
*/
|
|
6
2
|
export class ToolbarViewSlotNode extends Node {
|
|
7
3
|
static matches(type) {
|
|
8
4
|
if (!type.startsWith("AdwToolbarView."))
|
|
@@ -2,11 +2,6 @@ import type { ItemContainer } from "../containers.js";
|
|
|
2
2
|
import type { Props } from "../factory.js";
|
|
3
3
|
import type { Node } from "../node.js";
|
|
4
4
|
import { Node as NodeClass } from "../node.js";
|
|
5
|
-
/**
|
|
6
|
-
* Base class for virtual item nodes used in list-based containers.
|
|
7
|
-
* Virtual nodes don't create GTK widgets directly but represent items
|
|
8
|
-
* in list models (ListView, GridView, ColumnView).
|
|
9
|
-
*/
|
|
10
5
|
export declare abstract class VirtualItemNode extends NodeClass<never> {
|
|
11
6
|
static consumedPropNames: string[];
|
|
12
7
|
protected isVirtual(): boolean;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { Node as NodeClass } from "../node.js";
|
|
2
2
|
import { isItemContainer } from "../predicates.js";
|
|
3
|
-
/**
|
|
4
|
-
* Base class for virtual item nodes used in list-based containers.
|
|
5
|
-
* Virtual nodes don't create GTK widgets directly but represent items
|
|
6
|
-
* in list models (ListView, GridView, ColumnView).
|
|
7
|
-
*/
|
|
8
3
|
export class VirtualItemNode extends NodeClass {
|
|
9
4
|
static consumedPropNames = ["id", "item"];
|
|
10
5
|
isVirtual() {
|
package/dist/nodes/widget.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import { Node } from "../node.js";
|
|
3
|
-
/**
|
|
4
|
-
* Catch-all node for standard GTK widgets that don't need special handling.
|
|
5
|
-
* Specialized widgets (Window, AboutDialog, ActionBar, FlowBox, ListBox, etc.)
|
|
6
|
-
* are handled by their own dedicated Node classes.
|
|
7
|
-
*/
|
|
8
3
|
export declare class WidgetNode extends Node<Gtk.Widget> {
|
|
9
4
|
static matches(_type: string): boolean;
|
|
10
5
|
}
|
package/dist/nodes/widget.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { Node } from "../node.js";
|
|
2
|
-
/**
|
|
3
|
-
* Catch-all node for standard GTK widgets that don't need special handling.
|
|
4
|
-
* Specialized widgets (Window, AboutDialog, ActionBar, FlowBox, ListBox, etc.)
|
|
5
|
-
* are handled by their own dedicated Node classes.
|
|
6
|
-
*/
|
|
7
2
|
export class WidgetNode extends Node {
|
|
8
3
|
static matches(_type) {
|
|
9
4
|
return true;
|
package/dist/nodes/window.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getApplication } from "@gtkx/ffi";
|
|
2
2
|
import * as Adw from "@gtkx/ffi/adw";
|
|
3
3
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
4
4
|
import { Node, normalizeWidgetType } from "../node.js";
|
|
@@ -14,10 +14,10 @@ export class WindowNode extends Node {
|
|
|
14
14
|
createWidget(type, _props) {
|
|
15
15
|
const widgetType = normalizeWidgetType(type);
|
|
16
16
|
if (widgetType === "ApplicationWindow") {
|
|
17
|
-
return new Gtk.ApplicationWindow(
|
|
17
|
+
return new Gtk.ApplicationWindow(getApplication());
|
|
18
18
|
}
|
|
19
19
|
if (widgetType === "AdwApplicationWindow") {
|
|
20
|
-
return new Adw.ApplicationWindow(
|
|
20
|
+
return new Adw.ApplicationWindow(getApplication());
|
|
21
21
|
}
|
|
22
22
|
if (widgetType === "AdwWindow") {
|
|
23
23
|
return new Adw.Window();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/react",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Build GTK4 desktop applications with React and TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtk",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"react-reconciler": "^0.33.0",
|
|
39
|
-
"@gtkx/ffi": "0.9.
|
|
39
|
+
"@gtkx/ffi": "0.9.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@gtkx/gir": "0.9.
|
|
43
|
-
"@gtkx/native": "0.9.
|
|
42
|
+
"@gtkx/gir": "0.9.2",
|
|
43
|
+
"@gtkx/native": "0.9.2"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": "^19"
|