@gtkx/react 0.1.11 → 0.1.14
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 +6 -5
- package/dist/codegen/jsx-generator.js +13 -11
- package/dist/factory.js +2 -36
- package/dist/generated/jsx.d.ts +239 -239
- package/dist/index.js +2 -3
- package/dist/node.d.ts +17 -7
- package/dist/node.js +126 -1
- package/dist/nodes/dropdown.d.ts +23 -30
- package/dist/nodes/dropdown.js +31 -99
- package/dist/nodes/grid.d.ts +7 -24
- package/dist/nodes/grid.js +19 -72
- package/dist/nodes/list.d.ts +12 -31
- package/dist/nodes/list.js +30 -95
- package/dist/nodes/overlay.d.ts +3 -23
- package/dist/nodes/overlay.js +7 -85
- package/dist/nodes/slot.d.ts +5 -9
- package/dist/nodes/slot.js +13 -14
- package/dist/nodes/widget.d.ts +5 -12
- package/dist/nodes/widget.js +53 -82
- package/dist/portal.d.ts +0 -1
- package/dist/portal.js +0 -1
- package/dist/predicates.d.ts +13 -0
- package/dist/predicates.js +3 -0
- package/dist/reconciler.d.ts +5 -6
- package/dist/reconciler.js +14 -31
- package/dist/types.d.ts +2 -2
- package/package.json +5 -4
- package/dist/nodes/action-bar.d.ts +0 -27
- package/dist/nodes/action-bar.js +0 -88
- package/dist/nodes/dialog.d.ts +0 -19
- package/dist/nodes/dialog.js +0 -87
- package/dist/nodes/notebook.d.ts +0 -25
- package/dist/nodes/notebook.js +0 -88
- package/dist/nodes/text.d.ts +0 -16
- package/dist/nodes/text.js +0 -31
- package/dist/signal-utils.d.ts +0 -4
- package/dist/signal-utils.js +0 -7
- package/dist/widget-capabilities.d.ts +0 -46
- package/dist/widget-capabilities.js +0 -32
package/dist/index.js
CHANGED
|
@@ -3,12 +3,11 @@ export * from "./generated/jsx.js";
|
|
|
3
3
|
export { createPortal } from "./portal.js";
|
|
4
4
|
export { render } from "./render.js";
|
|
5
5
|
import { stop } from "@gtkx/ffi";
|
|
6
|
-
import {
|
|
6
|
+
import { reconciler } from "./reconciler.js";
|
|
7
7
|
import { container } from "./render.js";
|
|
8
8
|
export const quit = () => {
|
|
9
9
|
reconciler.updateContainer(null, container, null, () => {
|
|
10
|
-
disposeAllInstances();
|
|
11
10
|
stop();
|
|
12
11
|
});
|
|
13
|
-
return
|
|
12
|
+
return true;
|
|
14
13
|
};
|
package/dist/node.d.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { Props } from "./factory.js";
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export declare abstract class Node<T extends Gtk.Widget | undefined = Gtk.Widget | undefined> {
|
|
4
|
+
static matches(_type: string): boolean;
|
|
5
|
+
protected signalHandlers: Map<string, number>;
|
|
6
|
+
protected widget: T;
|
|
7
|
+
protected isVirtual(): boolean;
|
|
8
|
+
constructor(type: string, props: Props, currentApp?: unknown);
|
|
9
|
+
protected createWidget(type: string, props: Props, currentApp?: unknown): T;
|
|
10
|
+
getWidget(): T;
|
|
5
11
|
appendChild(child: Node): void;
|
|
6
12
|
removeChild(child: Node): void;
|
|
7
|
-
insertBefore(child: Node,
|
|
8
|
-
updateProps(oldProps: Props, newProps: Props): void;
|
|
9
|
-
mount(): void;
|
|
13
|
+
insertBefore(child: Node, _before: Node): void;
|
|
10
14
|
attachToParent(parent: Node): void;
|
|
11
15
|
detachFromParent(parent: Node): void;
|
|
12
|
-
|
|
16
|
+
protected consumedProps(): Set<string>;
|
|
17
|
+
updateProps(oldProps: Props, newProps: Props): void;
|
|
18
|
+
protected setSignalProperty(widget: Gtk.Widget, key: string, handler: unknown): void;
|
|
19
|
+
protected setSignalHandler(widget: Gtk.Widget, eventName: string, handler: (...args: unknown[]) => unknown): void;
|
|
20
|
+
protected setProperty(widget: Gtk.Widget, key: string, value: unknown): void;
|
|
21
|
+
mount(): void;
|
|
22
|
+
dispose(): void;
|
|
13
23
|
}
|
package/dist/node.js
CHANGED
|
@@ -1 +1,126 @@
|
|
|
1
|
-
|
|
1
|
+
import * as GObject from "@gtkx/ffi/gobject";
|
|
2
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
+
import { CONSTRUCTOR_PARAMS } from "./generated/jsx.js";
|
|
4
|
+
import { isAppendable, isRemovable, isSingleChild } from "./predicates.js";
|
|
5
|
+
const extractConstructorArgs = (type, props) => {
|
|
6
|
+
const params = CONSTRUCTOR_PARAMS[type];
|
|
7
|
+
if (!params)
|
|
8
|
+
return [];
|
|
9
|
+
return params.map((p) => props[p.name]);
|
|
10
|
+
};
|
|
11
|
+
const normalizeType = (type) => (type.endsWith(".Root") ? type.slice(0, -5) : type);
|
|
12
|
+
export class Node {
|
|
13
|
+
static matches(_type) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
signalHandlers = new Map();
|
|
17
|
+
widget;
|
|
18
|
+
isVirtual() {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
constructor(type, props, currentApp) {
|
|
22
|
+
this.widget = (this.isVirtual() ? undefined : this.createWidget(type, props, currentApp));
|
|
23
|
+
this.updateProps({}, props);
|
|
24
|
+
}
|
|
25
|
+
createWidget(type, props, currentApp) {
|
|
26
|
+
const normalizedType = normalizeType(type);
|
|
27
|
+
const WidgetClass = Gtk[normalizedType];
|
|
28
|
+
if (!WidgetClass || typeof WidgetClass !== "function") {
|
|
29
|
+
throw new Error(`Unknown GTK widget type: ${normalizedType}`);
|
|
30
|
+
}
|
|
31
|
+
if (normalizedType === "ApplicationWindow") {
|
|
32
|
+
return new WidgetClass(currentApp);
|
|
33
|
+
}
|
|
34
|
+
const args = extractConstructorArgs(normalizedType, props);
|
|
35
|
+
return new WidgetClass(...args);
|
|
36
|
+
}
|
|
37
|
+
getWidget() {
|
|
38
|
+
return this.widget;
|
|
39
|
+
}
|
|
40
|
+
appendChild(child) {
|
|
41
|
+
child.attachToParent(this);
|
|
42
|
+
}
|
|
43
|
+
removeChild(child) {
|
|
44
|
+
child.detachFromParent(this);
|
|
45
|
+
}
|
|
46
|
+
insertBefore(child, _before) {
|
|
47
|
+
this.appendChild(child);
|
|
48
|
+
}
|
|
49
|
+
attachToParent(parent) {
|
|
50
|
+
const parentWidget = parent.getWidget();
|
|
51
|
+
const widget = this.getWidget();
|
|
52
|
+
if (!parentWidget || !widget)
|
|
53
|
+
return;
|
|
54
|
+
if (isAppendable(parentWidget)) {
|
|
55
|
+
parentWidget.append(widget);
|
|
56
|
+
}
|
|
57
|
+
else if (isSingleChild(parentWidget)) {
|
|
58
|
+
parentWidget.setChild(widget);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
detachFromParent(parent) {
|
|
62
|
+
const parentWidget = parent.getWidget();
|
|
63
|
+
const widget = this.getWidget();
|
|
64
|
+
if (!parentWidget || !widget)
|
|
65
|
+
return;
|
|
66
|
+
if (isRemovable(parentWidget)) {
|
|
67
|
+
parentWidget.remove(widget);
|
|
68
|
+
}
|
|
69
|
+
else if (isSingleChild(parentWidget)) {
|
|
70
|
+
parentWidget.setChild(null);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
consumedProps() {
|
|
74
|
+
return new Set(["children"]);
|
|
75
|
+
}
|
|
76
|
+
updateProps(oldProps, newProps) {
|
|
77
|
+
const widget = this.getWidget();
|
|
78
|
+
if (!widget)
|
|
79
|
+
return;
|
|
80
|
+
const consumed = this.consumedProps();
|
|
81
|
+
const allKeys = new Set([...Object.keys(oldProps), ...Object.keys(newProps)]);
|
|
82
|
+
for (const key of allKeys) {
|
|
83
|
+
if (consumed.has(key))
|
|
84
|
+
continue;
|
|
85
|
+
const oldValue = oldProps[key];
|
|
86
|
+
const newValue = newProps[key];
|
|
87
|
+
if (oldValue === newValue)
|
|
88
|
+
continue;
|
|
89
|
+
if (key.startsWith("on")) {
|
|
90
|
+
this.setSignalProperty(widget, key, newValue);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (newValue === undefined)
|
|
94
|
+
continue;
|
|
95
|
+
this.setProperty(widget, key, newValue);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
setSignalProperty(widget, key, handler) {
|
|
99
|
+
const eventName = key
|
|
100
|
+
.slice(2)
|
|
101
|
+
.replace(/([A-Z])/g, "-$1")
|
|
102
|
+
.toLowerCase()
|
|
103
|
+
.replace(/^-/, "");
|
|
104
|
+
const oldHandlerId = this.signalHandlers.get(eventName);
|
|
105
|
+
if (oldHandlerId !== undefined) {
|
|
106
|
+
GObject.signalHandlerDisconnect(widget, oldHandlerId);
|
|
107
|
+
this.signalHandlers.delete(eventName);
|
|
108
|
+
}
|
|
109
|
+
if (typeof handler === "function") {
|
|
110
|
+
this.setSignalHandler(widget, eventName, handler);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
setSignalHandler(widget, eventName, handler) {
|
|
114
|
+
const handlerId = widget.connect(eventName, handler);
|
|
115
|
+
this.signalHandlers.set(eventName, handlerId);
|
|
116
|
+
}
|
|
117
|
+
setProperty(widget, key, value) {
|
|
118
|
+
const setterName = `set${key.charAt(0).toUpperCase()}${key.slice(1)}`;
|
|
119
|
+
const setter = widget[setterName];
|
|
120
|
+
if (typeof setter === "function") {
|
|
121
|
+
setter.call(widget, value);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
mount() { }
|
|
125
|
+
dispose() { }
|
|
126
|
+
}
|
package/dist/nodes/dropdown.d.ts
CHANGED
|
@@ -1,41 +1,34 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { Props } from "../factory.js";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare class DropDownNode implements Node<DropDownWidget> {
|
|
9
|
-
static needsWidget: boolean;
|
|
10
|
-
static matches(type: string, widget: Gtk.Widget | null): widget is DropDownWidget;
|
|
11
|
-
private widget;
|
|
3
|
+
import { Node } from "../node.js";
|
|
4
|
+
type ItemLabelFn = (item: unknown) => string;
|
|
5
|
+
declare class DropDownStore {
|
|
6
|
+
private stringList;
|
|
7
|
+
private items;
|
|
12
8
|
private labelFn;
|
|
9
|
+
constructor(labelFn: ItemLabelFn);
|
|
10
|
+
getModel(): Gtk.StringList;
|
|
11
|
+
append(item: unknown): void;
|
|
12
|
+
remove(item: unknown): void;
|
|
13
|
+
getItem(index: number): unknown;
|
|
14
|
+
get length(): number;
|
|
15
|
+
}
|
|
16
|
+
export declare class DropDownNode extends Node<Gtk.DropDown> {
|
|
17
|
+
static matches(type: string): boolean;
|
|
18
|
+
private store;
|
|
13
19
|
private onSelectionChanged?;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
getLabelFn(): ItemLabelFn<unknown>;
|
|
18
|
-
appendChild(child: Node): void;
|
|
19
|
-
removeChild(child: Node): void;
|
|
20
|
-
insertBefore(child: Node, _before: Node): void;
|
|
21
|
-
attachToParent(parent: Node): void;
|
|
22
|
-
detachFromParent(parent: Node): void;
|
|
20
|
+
constructor(type: string, props: Props, currentApp?: unknown);
|
|
21
|
+
getStore(): DropDownStore;
|
|
22
|
+
protected consumedProps(): Set<string>;
|
|
23
23
|
updateProps(oldProps: Props, newProps: Props): void;
|
|
24
|
-
mount(): void;
|
|
25
|
-
dispose(): void;
|
|
26
24
|
}
|
|
27
|
-
export declare class DropDownItemNode
|
|
28
|
-
static
|
|
29
|
-
|
|
25
|
+
export declare class DropDownItemNode extends Node<never> {
|
|
26
|
+
static matches(type: string): boolean;
|
|
27
|
+
protected isVirtual(): boolean;
|
|
30
28
|
private item;
|
|
31
|
-
constructor(
|
|
32
|
-
getItem():
|
|
33
|
-
appendChild(_child: Node): void;
|
|
34
|
-
removeChild(_child: Node): void;
|
|
35
|
-
insertBefore(_child: Node, _before: Node): void;
|
|
29
|
+
constructor(type: string, props: Props, _currentApp?: unknown);
|
|
30
|
+
getItem(): unknown;
|
|
36
31
|
attachToParent(parent: Node): void;
|
|
37
32
|
detachFromParent(parent: Node): void;
|
|
38
|
-
updateProps(_oldProps: Props, _newProps: Props): void;
|
|
39
|
-
mount(): void;
|
|
40
33
|
}
|
|
41
34
|
export {};
|
package/dist/nodes/dropdown.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import {
|
|
3
|
-
const isDropDownWidget = (widget) => isModelSettable(widget) && isSelectable(widget) && isConnectable(widget);
|
|
2
|
+
import { Node } from "../node.js";
|
|
4
3
|
class DropDownStore {
|
|
5
4
|
stringList;
|
|
6
5
|
items = [];
|
|
@@ -10,7 +9,7 @@ class DropDownStore {
|
|
|
10
9
|
this.labelFn = labelFn;
|
|
11
10
|
}
|
|
12
11
|
getModel() {
|
|
13
|
-
return this.stringList
|
|
12
|
+
return this.stringList;
|
|
14
13
|
}
|
|
15
14
|
append(item) {
|
|
16
15
|
const label = this.labelFn(item);
|
|
@@ -31,133 +30,66 @@ class DropDownStore {
|
|
|
31
30
|
return this.items.length;
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
dropdownStores.set(widget, store);
|
|
40
|
-
widget.setModel(store.getModel());
|
|
41
|
-
}
|
|
42
|
-
return store;
|
|
43
|
-
};
|
|
44
|
-
export class DropDownNode {
|
|
45
|
-
static needsWidget = true;
|
|
46
|
-
static matches(type, widget) {
|
|
47
|
-
if (type !== "DropDown" && type !== "DropDown.Root")
|
|
48
|
-
return false;
|
|
49
|
-
return widget !== null && isDropDownWidget(widget);
|
|
50
|
-
}
|
|
51
|
-
widget;
|
|
52
|
-
labelFn;
|
|
33
|
+
export class DropDownNode extends Node {
|
|
34
|
+
static matches(type) {
|
|
35
|
+
return type === "DropDown.Root";
|
|
36
|
+
}
|
|
37
|
+
store;
|
|
53
38
|
onSelectionChanged;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
throw new Error("DropDownNode requires a DropDown widget");
|
|
58
|
-
}
|
|
59
|
-
this.widget = widget;
|
|
60
|
-
this.labelFn = props.itemLabel ?? ((item) => String(item));
|
|
39
|
+
constructor(type, props, currentApp) {
|
|
40
|
+
super(type, props, currentApp);
|
|
41
|
+
const labelFn = props.itemLabel ?? ((item) => String(item));
|
|
61
42
|
this.onSelectionChanged = props.onSelectionChanged;
|
|
62
|
-
|
|
43
|
+
this.store = new DropDownStore(labelFn);
|
|
44
|
+
this.widget.setModel(this.store.getModel());
|
|
63
45
|
if (this.onSelectionChanged) {
|
|
64
46
|
const handler = () => {
|
|
65
47
|
const index = this.widget.getSelected();
|
|
66
|
-
const
|
|
67
|
-
const item = store?.getItem(index);
|
|
48
|
+
const item = this.store.getItem(index);
|
|
68
49
|
this.onSelectionChanged?.(item, index);
|
|
69
50
|
};
|
|
70
|
-
|
|
71
|
-
this.signalHandlers.set("notify::selected", handlerId);
|
|
51
|
+
this.setSignalHandler(this.widget, "notify::selected", handler);
|
|
72
52
|
}
|
|
73
53
|
}
|
|
74
|
-
|
|
75
|
-
return this.
|
|
76
|
-
}
|
|
77
|
-
getLabelFn() {
|
|
78
|
-
return this.labelFn;
|
|
79
|
-
}
|
|
80
|
-
appendChild(child) {
|
|
81
|
-
child.attachToParent(this);
|
|
82
|
-
}
|
|
83
|
-
removeChild(child) {
|
|
84
|
-
child.detachFromParent(this);
|
|
85
|
-
}
|
|
86
|
-
insertBefore(child, _before) {
|
|
87
|
-
this.appendChild(child);
|
|
88
|
-
}
|
|
89
|
-
attachToParent(parent) {
|
|
90
|
-
const parentWidget = parent.getWidget?.();
|
|
91
|
-
if (parentWidget) {
|
|
92
|
-
appendChild(parentWidget, this.widget);
|
|
93
|
-
}
|
|
54
|
+
getStore() {
|
|
55
|
+
return this.store;
|
|
94
56
|
}
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
57
|
+
consumedProps() {
|
|
58
|
+
const consumed = super.consumedProps();
|
|
59
|
+
consumed.add("itemLabel");
|
|
60
|
+
consumed.add("onSelectionChanged");
|
|
61
|
+
return consumed;
|
|
100
62
|
}
|
|
101
63
|
updateProps(oldProps, newProps) {
|
|
102
64
|
if (oldProps.onSelectionChanged !== newProps.onSelectionChanged) {
|
|
103
65
|
this.onSelectionChanged = newProps.onSelectionChanged;
|
|
104
66
|
}
|
|
105
|
-
|
|
106
|
-
const allKeys = new Set([...Object.keys(oldProps), ...Object.keys(newProps)]);
|
|
107
|
-
for (const key of allKeys) {
|
|
108
|
-
if (consumedProps.has(key))
|
|
109
|
-
continue;
|
|
110
|
-
const oldValue = oldProps[key];
|
|
111
|
-
const newValue = newProps[key];
|
|
112
|
-
if (oldValue === newValue)
|
|
113
|
-
continue;
|
|
114
|
-
if (key.startsWith("on")) {
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
const setterName = `set${key.charAt(0).toUpperCase()}${key.slice(1)}`;
|
|
118
|
-
const setter = this.widget[setterName];
|
|
119
|
-
if (typeof setter === "function") {
|
|
120
|
-
setter.call(this.widget, newValue);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
mount() { }
|
|
125
|
-
dispose() {
|
|
126
|
-
disconnectSignalHandlers(this.widget, this.signalHandlers);
|
|
67
|
+
super.updateProps(oldProps, newProps);
|
|
127
68
|
}
|
|
128
69
|
}
|
|
129
|
-
export class DropDownItemNode {
|
|
130
|
-
static
|
|
131
|
-
static matches(type, _widget) {
|
|
70
|
+
export class DropDownItemNode extends Node {
|
|
71
|
+
static matches(type) {
|
|
132
72
|
return type === "DropDown.Item";
|
|
133
73
|
}
|
|
74
|
+
isVirtual() {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
134
77
|
item;
|
|
135
|
-
constructor(
|
|
78
|
+
constructor(type, props, _currentApp) {
|
|
79
|
+
super(type, props);
|
|
136
80
|
this.item = props.item;
|
|
137
81
|
}
|
|
138
82
|
getItem() {
|
|
139
83
|
return this.item;
|
|
140
84
|
}
|
|
141
|
-
appendChild(_child) { }
|
|
142
|
-
removeChild(_child) { }
|
|
143
|
-
insertBefore(_child, _before) { }
|
|
144
85
|
attachToParent(parent) {
|
|
145
86
|
if (!(parent instanceof DropDownNode))
|
|
146
87
|
return;
|
|
147
|
-
|
|
148
|
-
const labelFn = parent.getLabelFn() ?? ((item) => String(item));
|
|
149
|
-
const store = getOrCreateStore(widget, labelFn);
|
|
150
|
-
store.append(this.item);
|
|
88
|
+
parent.getStore().append(this.item);
|
|
151
89
|
}
|
|
152
90
|
detachFromParent(parent) {
|
|
153
91
|
if (!(parent instanceof DropDownNode))
|
|
154
92
|
return;
|
|
155
|
-
|
|
156
|
-
const store = dropdownStores.get(widget);
|
|
157
|
-
if (store) {
|
|
158
|
-
store.remove(this.item);
|
|
159
|
-
}
|
|
93
|
+
parent.getStore().remove(this.item);
|
|
160
94
|
}
|
|
161
|
-
updateProps(_oldProps, _newProps) { }
|
|
162
|
-
mount() { }
|
|
163
95
|
}
|
package/dist/nodes/grid.d.ts
CHANGED
|
@@ -1,41 +1,24 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { Props } from "../factory.js";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { Node } from "../node.js";
|
|
4
|
+
export declare class GridNode extends Node<Gtk.Grid> {
|
|
5
|
+
static matches(type: string): boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare class
|
|
8
|
-
static
|
|
9
|
-
|
|
10
|
-
private widget;
|
|
11
|
-
constructor(_type: string, widget: Gtk.Widget, _props: Props);
|
|
12
|
-
getWidget(): GridWidget;
|
|
13
|
-
appendChild(child: Node): void;
|
|
14
|
-
removeChild(child: Node): void;
|
|
15
|
-
insertBefore(child: Node, _before: Node): void;
|
|
16
|
-
attachToParent(parent: Node): void;
|
|
17
|
-
detachFromParent(parent: Node): void;
|
|
18
|
-
updateProps(oldProps: Props, newProps: Props): void;
|
|
19
|
-
mount(): void;
|
|
20
|
-
}
|
|
21
|
-
export declare class GridChildNode implements Node {
|
|
22
|
-
static needsWidget: boolean;
|
|
23
|
-
static matches(type: string, _widget: Gtk.Widget | null): _widget is Gtk.Widget;
|
|
7
|
+
export declare class GridChildNode extends Node<never> {
|
|
8
|
+
static matches(type: string): boolean;
|
|
9
|
+
protected isVirtual(): boolean;
|
|
24
10
|
private column;
|
|
25
11
|
private row;
|
|
26
12
|
private columnSpan;
|
|
27
13
|
private rowSpan;
|
|
28
14
|
private childWidget;
|
|
29
15
|
private parentGrid;
|
|
30
|
-
constructor(
|
|
16
|
+
constructor(type: string, props: Props, _currentApp?: unknown);
|
|
31
17
|
appendChild(child: Node): void;
|
|
32
18
|
removeChild(child: Node): void;
|
|
33
|
-
insertBefore(child: Node, _before: Node): void;
|
|
34
19
|
private attachChildToGrid;
|
|
35
20
|
private detachChildFromGrid;
|
|
36
21
|
attachToParent(parent: Node): void;
|
|
37
22
|
detachFromParent(parent: Node): void;
|
|
38
23
|
updateProps(oldProps: Props, newProps: Props): void;
|
|
39
|
-
mount(): void;
|
|
40
24
|
}
|
|
41
|
-
export {};
|
package/dist/nodes/grid.js
CHANGED
|
@@ -1,84 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
static matches(type, widget) {
|
|
6
|
-
if (type !== "Grid" && type !== "Grid.Root")
|
|
7
|
-
return false;
|
|
8
|
-
return widget !== null && isGridWidget(widget);
|
|
1
|
+
import { Node } from "../node.js";
|
|
2
|
+
export class GridNode extends Node {
|
|
3
|
+
static matches(type) {
|
|
4
|
+
return type === "Grid.Root";
|
|
9
5
|
}
|
|
10
|
-
widget;
|
|
11
|
-
constructor(_type, widget, _props) {
|
|
12
|
-
if (!isGridWidget(widget)) {
|
|
13
|
-
throw new Error("GridNode requires a Grid widget");
|
|
14
|
-
}
|
|
15
|
-
this.widget = widget;
|
|
16
|
-
}
|
|
17
|
-
getWidget() {
|
|
18
|
-
return this.widget;
|
|
19
|
-
}
|
|
20
|
-
appendChild(child) {
|
|
21
|
-
child.attachToParent(this);
|
|
22
|
-
}
|
|
23
|
-
removeChild(child) {
|
|
24
|
-
child.detachFromParent(this);
|
|
25
|
-
}
|
|
26
|
-
insertBefore(child, _before) {
|
|
27
|
-
this.appendChild(child);
|
|
28
|
-
}
|
|
29
|
-
attachToParent(parent) {
|
|
30
|
-
const parentWidget = parent.getWidget?.();
|
|
31
|
-
if (parentWidget) {
|
|
32
|
-
appendChild(parentWidget, this.widget);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
detachFromParent(parent) {
|
|
36
|
-
const parentWidget = parent.getWidget?.();
|
|
37
|
-
if (parentWidget) {
|
|
38
|
-
removeChild(parentWidget, this.widget);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
updateProps(oldProps, newProps) {
|
|
42
|
-
const consumedProps = new Set(["children"]);
|
|
43
|
-
const allKeys = new Set([...Object.keys(oldProps), ...Object.keys(newProps)]);
|
|
44
|
-
for (const key of allKeys) {
|
|
45
|
-
if (consumedProps.has(key))
|
|
46
|
-
continue;
|
|
47
|
-
const oldValue = oldProps[key];
|
|
48
|
-
const newValue = newProps[key];
|
|
49
|
-
if (oldValue === newValue)
|
|
50
|
-
continue;
|
|
51
|
-
if (key.startsWith("on")) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
const setterName = `set${key.charAt(0).toUpperCase()}${key.slice(1)}`;
|
|
55
|
-
const setter = this.widget[setterName];
|
|
56
|
-
if (typeof setter === "function") {
|
|
57
|
-
setter.call(this.widget, newValue);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
mount() { }
|
|
62
6
|
}
|
|
63
|
-
export class GridChildNode {
|
|
64
|
-
static
|
|
65
|
-
static matches(type, _widget) {
|
|
7
|
+
export class GridChildNode extends Node {
|
|
8
|
+
static matches(type) {
|
|
66
9
|
return type === "Grid.Child";
|
|
67
10
|
}
|
|
11
|
+
isVirtual() {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
68
14
|
column;
|
|
69
15
|
row;
|
|
70
16
|
columnSpan;
|
|
71
17
|
rowSpan;
|
|
72
18
|
childWidget = null;
|
|
73
19
|
parentGrid = null;
|
|
74
|
-
constructor(
|
|
20
|
+
constructor(type, props, _currentApp) {
|
|
21
|
+
super(type, props);
|
|
75
22
|
this.column = props.column ?? 0;
|
|
76
23
|
this.row = props.row ?? 0;
|
|
77
24
|
this.columnSpan = props.columnSpan ?? 1;
|
|
78
25
|
this.rowSpan = props.rowSpan ?? 1;
|
|
79
26
|
}
|
|
80
27
|
appendChild(child) {
|
|
81
|
-
const widget = child.getWidget
|
|
28
|
+
const widget = child.getWidget();
|
|
82
29
|
if (widget) {
|
|
83
30
|
this.childWidget = widget;
|
|
84
31
|
if (this.parentGrid) {
|
|
@@ -87,26 +34,27 @@ export class GridChildNode {
|
|
|
87
34
|
}
|
|
88
35
|
}
|
|
89
36
|
removeChild(child) {
|
|
90
|
-
const widget = child.getWidget
|
|
37
|
+
const widget = child.getWidget();
|
|
91
38
|
if (widget && this.childWidget === widget) {
|
|
92
39
|
this.detachChildFromGrid();
|
|
93
40
|
this.childWidget = null;
|
|
94
41
|
}
|
|
95
42
|
}
|
|
96
|
-
insertBefore(child, _before) {
|
|
97
|
-
this.appendChild(child);
|
|
98
|
-
}
|
|
99
43
|
attachChildToGrid() {
|
|
100
44
|
if (!this.parentGrid || !this.childWidget)
|
|
101
45
|
return;
|
|
102
46
|
const grid = this.parentGrid.getWidget();
|
|
103
|
-
grid
|
|
47
|
+
if (!grid)
|
|
48
|
+
return;
|
|
49
|
+
grid.attach(this.childWidget, this.column, this.row, this.columnSpan, this.rowSpan);
|
|
104
50
|
}
|
|
105
51
|
detachChildFromGrid() {
|
|
106
52
|
if (!this.parentGrid || !this.childWidget)
|
|
107
53
|
return;
|
|
108
54
|
const grid = this.parentGrid.getWidget();
|
|
109
|
-
grid
|
|
55
|
+
if (!grid)
|
|
56
|
+
return;
|
|
57
|
+
grid.remove(this.childWidget);
|
|
110
58
|
}
|
|
111
59
|
attachToParent(parent) {
|
|
112
60
|
if (parent instanceof GridNode) {
|
|
@@ -136,5 +84,4 @@ export class GridChildNode {
|
|
|
136
84
|
this.attachChildToGrid();
|
|
137
85
|
}
|
|
138
86
|
}
|
|
139
|
-
mount() { }
|
|
140
87
|
}
|
package/dist/nodes/list.d.ts
CHANGED
|
@@ -1,46 +1,27 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { Props } from "../factory.js";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
setFactory(factory: unknown): void;
|
|
7
|
-
}
|
|
8
|
-
export declare class ListViewNode<T = unknown> implements Node<ListViewWidget> {
|
|
9
|
-
static needsWidget: boolean;
|
|
10
|
-
static matches(type: string, widget: Gtk.Widget | null): widget is ListViewWidget;
|
|
11
|
-
private widget;
|
|
3
|
+
import { Node } from "../node.js";
|
|
4
|
+
export declare class ListViewNode extends Node<Gtk.ListView> {
|
|
5
|
+
static matches(type: string): boolean;
|
|
12
6
|
private stringList;
|
|
13
7
|
private selectionModel;
|
|
14
8
|
private factory;
|
|
15
9
|
private items;
|
|
16
10
|
private renderItem;
|
|
17
|
-
private signalHandlers;
|
|
18
11
|
private factorySignalHandlers;
|
|
19
|
-
constructor(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
insertBefore(child: Node, _before: Node): void;
|
|
24
|
-
attachToParent(parent: Node): void;
|
|
25
|
-
detachFromParent(parent: Node): void;
|
|
26
|
-
addItem(item: T): void;
|
|
27
|
-
removeItem(item: T): void;
|
|
12
|
+
constructor(type: string, props: Props, currentApp?: unknown);
|
|
13
|
+
addItem(item: unknown): void;
|
|
14
|
+
removeItem(item: unknown): void;
|
|
15
|
+
protected consumedProps(): Set<string>;
|
|
28
16
|
updateProps(oldProps: Props, newProps: Props): void;
|
|
29
|
-
mount(): void;
|
|
30
17
|
dispose(): void;
|
|
31
18
|
}
|
|
32
|
-
export declare class ListItemNode
|
|
33
|
-
static
|
|
34
|
-
|
|
19
|
+
export declare class ListItemNode extends Node {
|
|
20
|
+
static matches(type: string): boolean;
|
|
21
|
+
protected isVirtual(): boolean;
|
|
35
22
|
private item;
|
|
36
|
-
constructor(
|
|
37
|
-
getItem():
|
|
38
|
-
appendChild(_child: Node): void;
|
|
39
|
-
removeChild(_child: Node): void;
|
|
40
|
-
insertBefore(_child: Node, _before: Node): void;
|
|
23
|
+
constructor(type: string, props: Props, _currentApp?: unknown);
|
|
24
|
+
getItem(): unknown;
|
|
41
25
|
attachToParent(parent: Node): void;
|
|
42
26
|
detachFromParent(parent: Node): void;
|
|
43
|
-
updateProps(_oldProps: Props, _newProps: Props): void;
|
|
44
|
-
mount(): void;
|
|
45
27
|
}
|
|
46
|
-
export {};
|