@gtkx/react 0.8.0 → 0.9.0
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/dist/{container-interfaces.d.ts → containers.d.ts} +10 -37
- package/dist/containers.js +1 -0
- package/dist/factory.d.ts +1 -1
- package/dist/factory.js +3 -3
- package/dist/{reconciler/host-config.d.ts → host-config.d.ts} +2 -2
- package/dist/{reconciler/host-config.js → host-config.js} +2 -2
- package/dist/node.d.ts +5 -6
- package/dist/node.js +54 -72
- package/dist/nodes/about-dialog.d.ts +2 -3
- package/dist/nodes/about-dialog.js +6 -4
- package/dist/nodes/column-view.d.ts +6 -7
- package/dist/nodes/column-view.js +29 -32
- package/dist/nodes/grid.d.ts +4 -1
- package/dist/nodes/grid.js +39 -1
- package/dist/nodes/header-bar.d.ts +15 -14
- package/dist/nodes/header-bar.js +79 -39
- package/dist/nodes/indexed-child-container.d.ts +1 -1
- package/dist/nodes/list-view.d.ts +1 -2
- package/dist/nodes/list-view.js +2 -2
- package/dist/nodes/menu.d.ts +27 -11
- package/dist/nodes/menu.js +59 -32
- package/dist/nodes/notebook.d.ts +4 -1
- package/dist/nodes/notebook.js +45 -1
- package/dist/nodes/overlay.d.ts +1 -1
- package/dist/nodes/paged-stack.d.ts +7 -3
- package/dist/nodes/paged-stack.js +47 -2
- package/dist/nodes/root.d.ts +1 -1
- package/dist/nodes/root.js +2 -2
- package/dist/nodes/selectable-list.d.ts +7 -3
- package/dist/nodes/selectable-list.js +34 -2
- package/dist/nodes/slot.d.ts +3 -4
- package/dist/nodes/slot.js +11 -10
- package/dist/nodes/stack-page-props.d.ts +1 -1
- package/dist/nodes/stack.d.ts +1 -1
- package/dist/nodes/stack.js +1 -1
- package/dist/nodes/string-list-container.d.ts +4 -11
- package/dist/nodes/string-list-container.js +32 -4
- package/dist/nodes/string-list-item.d.ts +10 -6
- package/dist/nodes/string-list-item.js +19 -17
- package/dist/nodes/toggle-button.d.ts +0 -3
- package/dist/nodes/toggle-button.js +0 -28
- package/dist/nodes/toolbar-view.d.ts +2 -3
- package/dist/nodes/toolbar-view.js +10 -9
- package/dist/nodes/view-stack.d.ts +1 -1
- package/dist/nodes/virtual-item.d.ts +9 -5
- package/dist/nodes/virtual-item.js +16 -20
- package/dist/nodes/virtual-slot.d.ts +4 -4
- package/dist/nodes/virtual-slot.js +12 -26
- package/dist/nodes/window.d.ts +2 -1
- package/dist/nodes/window.js +7 -3
- package/dist/predicates.d.ts +9 -18
- package/dist/predicates.js +31 -18
- package/dist/reconciler.d.ts +1 -1
- package/dist/reconciler.js +1 -1
- package/package.json +4 -4
- package/dist/container-interfaces.js +0 -26
package/dist/nodes/slot.d.ts
CHANGED
|
@@ -4,11 +4,10 @@ export declare class SlotNode extends Node<never> {
|
|
|
4
4
|
protected isVirtual(): boolean;
|
|
5
5
|
private child;
|
|
6
6
|
private slotName;
|
|
7
|
-
private parentNode;
|
|
8
7
|
constructor(type: string);
|
|
9
8
|
private updateParentSlot;
|
|
10
9
|
appendChild(child: Node): void;
|
|
11
|
-
removeChild(
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
removeChild(child: Node): void;
|
|
11
|
+
mount(): void;
|
|
12
|
+
unmount(): void;
|
|
14
13
|
}
|
package/dist/nodes/slot.js
CHANGED
|
@@ -14,7 +14,6 @@ export class SlotNode extends Node {
|
|
|
14
14
|
}
|
|
15
15
|
child = null;
|
|
16
16
|
slotName;
|
|
17
|
-
parentNode = null;
|
|
18
17
|
constructor(type) {
|
|
19
18
|
super(type);
|
|
20
19
|
const dotIndex = type.indexOf(".");
|
|
@@ -24,9 +23,9 @@ export class SlotNode extends Node {
|
|
|
24
23
|
this.slotName = type.substring(dotIndex + 1);
|
|
25
24
|
}
|
|
26
25
|
updateParentSlot() {
|
|
27
|
-
if (!this.
|
|
26
|
+
if (!this.parent)
|
|
28
27
|
return;
|
|
29
|
-
const parentWidget = this.
|
|
28
|
+
const parentWidget = this.parent.getWidget();
|
|
30
29
|
const childWidget = this.child?.getWidget();
|
|
31
30
|
if (!parentWidget)
|
|
32
31
|
return;
|
|
@@ -37,22 +36,24 @@ export class SlotNode extends Node {
|
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
appendChild(child) {
|
|
39
|
+
child.parent = this;
|
|
40
40
|
if (child.getWidget()) {
|
|
41
41
|
this.child = child;
|
|
42
42
|
this.updateParentSlot();
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
removeChild(
|
|
45
|
+
removeChild(child) {
|
|
46
|
+
child.unmount();
|
|
46
47
|
this.child = null;
|
|
47
48
|
this.updateParentSlot();
|
|
49
|
+
child.parent = null;
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
this.parentNode = parent;
|
|
51
|
+
mount() {
|
|
51
52
|
this.updateParentSlot();
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
if (this.
|
|
55
|
-
const parentWidget = this.
|
|
54
|
+
unmount() {
|
|
55
|
+
if (this.parent) {
|
|
56
|
+
const parentWidget = this.parent.getWidget();
|
|
56
57
|
if (parentWidget) {
|
|
57
58
|
const setterName = `set${this.slotName}`;
|
|
58
59
|
const setter = parentWidget[setterName];
|
|
@@ -61,6 +62,6 @@ export class SlotNode extends Node {
|
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
+
super.unmount();
|
|
65
66
|
}
|
|
66
67
|
}
|
package/dist/nodes/stack.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import {
|
|
2
|
+
import type { StackPageContainer, StackPageProps } from "../containers.js";
|
|
3
3
|
import type { Props } from "../factory.js";
|
|
4
4
|
import type { Node } from "../node.js";
|
|
5
5
|
import { PagedStackNode } from "./paged-stack.js";
|
package/dist/nodes/stack.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isStackPageContainer } from "../
|
|
1
|
+
import { isStackPageContainer } from "../predicates.js";
|
|
2
2
|
import { PagedStackNode } from "./paged-stack.js";
|
|
3
3
|
import { applyStackPageProps } from "./stack-page-props.js";
|
|
4
4
|
import { VirtualSlotNode } from "./virtual-slot.js";
|
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import * as Gio from "@gtkx/ffi/gio";
|
|
2
2
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
+
import type { StringListContainer } from "../containers.js";
|
|
3
4
|
import type { Props } from "../factory.js";
|
|
4
5
|
import type { Node } from "../node.js";
|
|
5
6
|
import { Node as NodeClass } from "../node.js";
|
|
6
7
|
import { StringListStore } from "./string-list-store.js";
|
|
7
|
-
export type StringListItem = {
|
|
8
|
-
id: string;
|
|
9
|
-
label: string;
|
|
10
|
-
};
|
|
11
|
-
type StringListContainer = {
|
|
12
|
-
addStringListItem(id: string, label: string): void;
|
|
13
|
-
insertStringListItemBefore(id: string, label: string, beforeId: string): void;
|
|
14
|
-
removeStringListItem(id: string): void;
|
|
15
|
-
updateStringListItem(oldId: string, newId: string, newLabel: string): void;
|
|
16
|
-
};
|
|
17
|
-
export declare const isStringListContainer: (node: Node) => node is Node & StringListContainer;
|
|
18
8
|
type StringListContainerState = {
|
|
19
9
|
store: StringListStore;
|
|
20
10
|
onSelectionChanged?: (id: string) => void;
|
|
@@ -28,6 +18,9 @@ type StringListWidget = Gtk.Widget & {
|
|
|
28
18
|
};
|
|
29
19
|
export declare abstract class StringListContainerNode<T extends StringListWidget> extends NodeClass<T, StringListContainerState> implements StringListContainer {
|
|
30
20
|
static consumedPropNames: string[];
|
|
21
|
+
appendChild(child: Node): void;
|
|
22
|
+
insertBefore(child: Node, before: Node): void;
|
|
23
|
+
removeChild(child: Node): void;
|
|
31
24
|
initialize(props: Props): void;
|
|
32
25
|
private connectSelectionHandler;
|
|
33
26
|
addStringListItem(id: string, label: string): void;
|
|
@@ -2,14 +2,42 @@ import { getInterface } 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";
|
|
5
|
+
import { StringListItemNode } from "./string-list-item.js";
|
|
5
6
|
import { StringListStore } from "./string-list-store.js";
|
|
6
|
-
export const isStringListContainer = (node) => "addStringListItem" in node &&
|
|
7
|
-
"insertStringListItemBefore" in node &&
|
|
8
|
-
"removeStringListItem" in node &&
|
|
9
|
-
"updateStringListItem" in node;
|
|
10
7
|
const SELECTION_SIGNAL = "notify::selected";
|
|
11
8
|
export class StringListContainerNode extends NodeClass {
|
|
12
9
|
static consumedPropNames = ["onSelectionChanged", "selectedId"];
|
|
10
|
+
appendChild(child) {
|
|
11
|
+
if (child instanceof StringListItemNode) {
|
|
12
|
+
child.parent = this;
|
|
13
|
+
child.addToContainer(this);
|
|
14
|
+
child.setParentContainer(this);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
super.appendChild(child);
|
|
18
|
+
}
|
|
19
|
+
insertBefore(child, before) {
|
|
20
|
+
if (child instanceof StringListItemNode) {
|
|
21
|
+
child.parent = this;
|
|
22
|
+
if (before instanceof StringListItemNode) {
|
|
23
|
+
child.insertBeforeInContainer(this, before.getId());
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
child.addToContainer(this);
|
|
27
|
+
}
|
|
28
|
+
child.setParentContainer(this);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
super.insertBefore(child, before);
|
|
32
|
+
}
|
|
33
|
+
removeChild(child) {
|
|
34
|
+
if (child instanceof StringListItemNode) {
|
|
35
|
+
child.unmount();
|
|
36
|
+
child.parent = null;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
super.removeChild(child);
|
|
40
|
+
}
|
|
13
41
|
initialize(props) {
|
|
14
42
|
const store = new StringListStore();
|
|
15
43
|
const onSelectionChanged = props.onSelectionChanged;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import type { StringListContainer, StringListItem } from "../containers.js";
|
|
1
2
|
import type { Props } from "../factory.js";
|
|
2
|
-
import { Node } from "../node.js";
|
|
3
|
-
import {
|
|
4
|
-
export declare abstract class StringListItemNode extends
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import { Node as NodeClass } from "../node.js";
|
|
5
|
+
export declare abstract class StringListItemNode extends NodeClass<never> {
|
|
5
6
|
static consumedPropNames: string[];
|
|
6
7
|
protected isVirtual(): boolean;
|
|
7
8
|
private id;
|
|
8
9
|
private label;
|
|
10
|
+
private parentContainer;
|
|
9
11
|
initialize(props: Props): void;
|
|
12
|
+
getId(): string;
|
|
10
13
|
getStringListItem(): StringListItem;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
setParentContainer(container: Node & StringListContainer): void;
|
|
15
|
+
addToContainer(container: StringListContainer): void;
|
|
16
|
+
insertBeforeInContainer(container: StringListContainer, beforeId: string): void;
|
|
17
|
+
unmount(): void;
|
|
14
18
|
updateProps(oldProps: Props, newProps: Props): void;
|
|
15
19
|
}
|
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
import { Node } from "../node.js";
|
|
2
|
-
import { isStringListContainer } from "
|
|
3
|
-
export class StringListItemNode extends
|
|
1
|
+
import { Node as NodeClass } from "../node.js";
|
|
2
|
+
import { isStringListContainer } from "../predicates.js";
|
|
3
|
+
export class StringListItemNode extends NodeClass {
|
|
4
4
|
static consumedPropNames = ["id", "label"];
|
|
5
5
|
isVirtual() {
|
|
6
6
|
return true;
|
|
7
7
|
}
|
|
8
8
|
id = "";
|
|
9
9
|
label = "";
|
|
10
|
+
parentContainer = null;
|
|
10
11
|
initialize(props) {
|
|
11
12
|
this.id = props.id;
|
|
12
13
|
this.label = props.label;
|
|
13
14
|
super.initialize(props);
|
|
14
15
|
}
|
|
16
|
+
getId() {
|
|
17
|
+
return this.id;
|
|
18
|
+
}
|
|
15
19
|
getStringListItem() {
|
|
16
20
|
return { id: this.id, label: this.label };
|
|
17
21
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
parent.addStringListItem(this.id, this.label);
|
|
21
|
-
}
|
|
22
|
+
setParentContainer(container) {
|
|
23
|
+
this.parentContainer = container;
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.attachToParent(parent);
|
|
29
|
-
}
|
|
25
|
+
addToContainer(container) {
|
|
26
|
+
container.addStringListItem(this.id, this.label);
|
|
27
|
+
}
|
|
28
|
+
insertBeforeInContainer(container, beforeId) {
|
|
29
|
+
container.insertStringListItemBefore(this.id, this.label, beforeId);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
31
|
+
unmount() {
|
|
32
|
+
if (this.parentContainer) {
|
|
33
|
+
this.parentContainer.removeStringListItem(this.id);
|
|
34
34
|
}
|
|
35
|
+
this.parentContainer = null;
|
|
36
|
+
super.unmount();
|
|
35
37
|
}
|
|
36
38
|
updateProps(oldProps, newProps) {
|
|
37
39
|
const oldId = oldProps.id;
|
|
@@ -16,9 +16,6 @@ export declare class ToggleButtonNode extends Node<Gtk.ToggleButton, ToggleButto
|
|
|
16
16
|
static consumedPropNames: string[];
|
|
17
17
|
static matches(type: string): boolean;
|
|
18
18
|
initialize(props: Props): void;
|
|
19
|
-
attachToParent(parent: Node): void;
|
|
20
|
-
attachToParentBefore(parent: Node, before: Node): void;
|
|
21
|
-
detachFromParent(parent: Node): void;
|
|
22
19
|
updateProps(_oldProps: Props, newProps: Props): void;
|
|
23
20
|
protected connectSignal(widget: Gtk.Widget, eventName: string, handler: (...args: unknown[]) => unknown): void;
|
|
24
21
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isChildContainer } from "../container-interfaces.js";
|
|
2
1
|
import { Node } from "../node.js";
|
|
3
2
|
/**
|
|
4
3
|
* Specialized node for GtkToggleButton that prevents signal feedback loops.
|
|
@@ -17,33 +16,6 @@ export class ToggleButtonNode extends Node {
|
|
|
17
16
|
this.state = { lastPropsActive: undefined };
|
|
18
17
|
super.initialize(props);
|
|
19
18
|
}
|
|
20
|
-
attachToParent(parent) {
|
|
21
|
-
if (isChildContainer(parent)) {
|
|
22
|
-
parent.attachChild(this.widget);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
super.attachToParent(parent);
|
|
26
|
-
}
|
|
27
|
-
attachToParentBefore(parent, before) {
|
|
28
|
-
if (isChildContainer(parent)) {
|
|
29
|
-
const beforeWidget = before.getWidget();
|
|
30
|
-
if (beforeWidget) {
|
|
31
|
-
parent.insertChildBefore(this.widget, beforeWidget);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
parent.attachChild(this.widget);
|
|
35
|
-
}
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
super.attachToParentBefore(parent, before);
|
|
39
|
-
}
|
|
40
|
-
detachFromParent(parent) {
|
|
41
|
-
if (isChildContainer(parent)) {
|
|
42
|
-
parent.detachChild(this.widget);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
super.detachFromParent(parent);
|
|
46
|
-
}
|
|
47
19
|
updateProps(_oldProps, newProps) {
|
|
48
20
|
const widget = this.getWidget();
|
|
49
21
|
if (!widget) {
|
|
@@ -7,13 +7,12 @@ export declare class ToolbarViewSlotNode extends Node<never> {
|
|
|
7
7
|
static matches(type: string): boolean;
|
|
8
8
|
protected isVirtual(): boolean;
|
|
9
9
|
private slotType;
|
|
10
|
-
private parentNode;
|
|
11
10
|
private children;
|
|
12
11
|
constructor(type: string);
|
|
13
12
|
appendChild(child: Node): void;
|
|
14
13
|
removeChild(child: Node): void;
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
mount(): void;
|
|
15
|
+
unmount(): void;
|
|
17
16
|
private addBarToParent;
|
|
18
17
|
private removeBarFromParent;
|
|
19
18
|
}
|
|
@@ -14,7 +14,6 @@ export class ToolbarViewSlotNode extends Node {
|
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
16
|
slotType;
|
|
17
|
-
parentNode = null;
|
|
18
17
|
children = [];
|
|
19
18
|
constructor(type) {
|
|
20
19
|
super(type);
|
|
@@ -25,26 +24,28 @@ export class ToolbarViewSlotNode extends Node {
|
|
|
25
24
|
this.slotType = slot;
|
|
26
25
|
}
|
|
27
26
|
appendChild(child) {
|
|
27
|
+
child.parent = this;
|
|
28
28
|
const childWidget = child.getWidget();
|
|
29
29
|
if (!childWidget)
|
|
30
30
|
return;
|
|
31
31
|
this.children.push(child);
|
|
32
|
-
if (this.
|
|
32
|
+
if (this.parent) {
|
|
33
33
|
this.addBarToParent(childWidget);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
removeChild(child) {
|
|
37
|
+
child.unmount();
|
|
37
38
|
const index = this.children.indexOf(child);
|
|
38
39
|
if (index !== -1) {
|
|
39
40
|
this.children.splice(index, 1);
|
|
40
41
|
}
|
|
41
42
|
const childWidget = child.getWidget();
|
|
42
|
-
if (this.
|
|
43
|
+
if (this.parent && childWidget) {
|
|
43
44
|
this.removeBarFromParent(childWidget);
|
|
44
45
|
}
|
|
46
|
+
child.parent = null;
|
|
45
47
|
}
|
|
46
|
-
|
|
47
|
-
this.parentNode = parent;
|
|
48
|
+
mount() {
|
|
48
49
|
for (const child of this.children) {
|
|
49
50
|
const childWidget = child.getWidget();
|
|
50
51
|
if (childWidget) {
|
|
@@ -52,17 +53,17 @@ export class ToolbarViewSlotNode extends Node {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
unmount() {
|
|
56
57
|
for (const child of this.children) {
|
|
57
58
|
const childWidget = child.getWidget();
|
|
58
59
|
if (childWidget) {
|
|
59
60
|
this.removeBarFromParent(childWidget);
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
+
super.unmount();
|
|
63
64
|
}
|
|
64
65
|
addBarToParent(childWidget) {
|
|
65
|
-
const parentWidget = this.
|
|
66
|
+
const parentWidget = this.parent?.getWidget();
|
|
66
67
|
if (!parentWidget)
|
|
67
68
|
return;
|
|
68
69
|
if (this.slotType === "Top") {
|
|
@@ -73,7 +74,7 @@ export class ToolbarViewSlotNode extends Node {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
removeBarFromParent(childWidget) {
|
|
76
|
-
const parentWidget = this.
|
|
77
|
+
const parentWidget = this.parent?.getWidget();
|
|
77
78
|
if (!parentWidget)
|
|
78
79
|
return;
|
|
79
80
|
parentWidget.remove(childWidget);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Adw from "@gtkx/ffi/adw";
|
|
2
2
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
-
import type { StackPageProps } from "../
|
|
3
|
+
import type { StackPageProps } from "../containers.js";
|
|
4
4
|
import { PagedStackNode } from "./paged-stack.js";
|
|
5
5
|
export declare class ViewStackNode extends PagedStackNode<Adw.ViewStack> {
|
|
6
6
|
static matches(type: string): boolean;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
import type { ItemContainer } from "../containers.js";
|
|
1
2
|
import type { Props } from "../factory.js";
|
|
2
|
-
import { Node } from "../node.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import { Node as NodeClass } from "../node.js";
|
|
3
5
|
/**
|
|
4
6
|
* Base class for virtual item nodes used in list-based containers.
|
|
5
7
|
* Virtual nodes don't create GTK widgets directly but represent items
|
|
6
8
|
* in list models (ListView, GridView, ColumnView).
|
|
7
9
|
*/
|
|
8
|
-
export declare abstract class VirtualItemNode extends
|
|
10
|
+
export declare abstract class VirtualItemNode extends NodeClass<never> {
|
|
9
11
|
static consumedPropNames: string[];
|
|
10
12
|
protected isVirtual(): boolean;
|
|
11
13
|
private id;
|
|
12
14
|
private item;
|
|
15
|
+
private parentContainer;
|
|
13
16
|
initialize(props: Props): void;
|
|
14
17
|
getId(): string;
|
|
15
18
|
getItem(): unknown;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
setParentContainer(container: Node & ItemContainer<unknown>): void;
|
|
20
|
+
addToContainer(container: ItemContainer<unknown>): void;
|
|
21
|
+
insertBeforeInContainer(container: ItemContainer<unknown>, beforeId: string): void;
|
|
22
|
+
unmount(): void;
|
|
19
23
|
updateProps(oldProps: Props, newProps: Props): void;
|
|
20
24
|
}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
const hasGetId = (node) => {
|
|
4
|
-
return typeof node.getId === "function";
|
|
5
|
-
};
|
|
1
|
+
import { Node as NodeClass } from "../node.js";
|
|
2
|
+
import { isItemContainer } from "../predicates.js";
|
|
6
3
|
/**
|
|
7
4
|
* Base class for virtual item nodes used in list-based containers.
|
|
8
5
|
* Virtual nodes don't create GTK widgets directly but represent items
|
|
9
6
|
* in list models (ListView, GridView, ColumnView).
|
|
10
7
|
*/
|
|
11
|
-
export class VirtualItemNode extends
|
|
8
|
+
export class VirtualItemNode extends NodeClass {
|
|
12
9
|
static consumedPropNames = ["id", "item"];
|
|
13
10
|
isVirtual() {
|
|
14
11
|
return true;
|
|
15
12
|
}
|
|
16
13
|
id = "";
|
|
17
14
|
item;
|
|
15
|
+
parentContainer = null;
|
|
18
16
|
initialize(props) {
|
|
19
17
|
this.id = props.id;
|
|
20
18
|
this.item = props.item;
|
|
@@ -26,23 +24,21 @@ export class VirtualItemNode extends Node {
|
|
|
26
24
|
getItem() {
|
|
27
25
|
return this.item;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
parent.addItem(this.id, this.item);
|
|
32
|
-
}
|
|
27
|
+
setParentContainer(container) {
|
|
28
|
+
this.parentContainer = container;
|
|
33
29
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.attachToParent(parent);
|
|
40
|
-
}
|
|
30
|
+
addToContainer(container) {
|
|
31
|
+
container.addItem(this.id, this.item);
|
|
32
|
+
}
|
|
33
|
+
insertBeforeInContainer(container, beforeId) {
|
|
34
|
+
container.insertItemBefore(this.id, this.item, beforeId);
|
|
41
35
|
}
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
|
|
36
|
+
unmount() {
|
|
37
|
+
if (this.parentContainer) {
|
|
38
|
+
this.parentContainer.removeItem(this.id);
|
|
45
39
|
}
|
|
40
|
+
this.parentContainer = null;
|
|
41
|
+
super.unmount();
|
|
46
42
|
}
|
|
47
43
|
updateProps(oldProps, newProps) {
|
|
48
44
|
const newId = newProps.id;
|
|
@@ -16,10 +16,10 @@ export declare abstract class VirtualSlotNode<TContainer, TProps> extends Node<n
|
|
|
16
16
|
protected abstract extractSlotProps(props: Props): TProps;
|
|
17
17
|
initialize(props: Props): void;
|
|
18
18
|
getChildWidget(): Gtk.Widget | null;
|
|
19
|
+
getSlotProps(): TProps;
|
|
20
|
+
setParentContainer(container: Node & TContainer): void;
|
|
21
|
+
getBeforeWidget(before: Node): Gtk.Widget | null;
|
|
19
22
|
appendChild(child: Node): void;
|
|
20
|
-
|
|
21
|
-
attachToParentBefore(parent: Node, before: Node): void;
|
|
22
|
-
protected getBeforeWidget(before: Node): Gtk.Widget | null;
|
|
23
|
-
detachFromParent(parent: Node): void;
|
|
23
|
+
unmount(): void;
|
|
24
24
|
protected updateSlotPropsIfChanged(oldProps: Props, newProps: Props, propKeys: string[]): boolean;
|
|
25
25
|
}
|
|
@@ -22,29 +22,11 @@ export class VirtualSlotNode extends Node {
|
|
|
22
22
|
getChildWidget() {
|
|
23
23
|
return this.childWidget;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (childWidget) {
|
|
28
|
-
this.childWidget = childWidget;
|
|
29
|
-
}
|
|
25
|
+
getSlotProps() {
|
|
26
|
+
return this.slotProps;
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.parentContainer = parent;
|
|
34
|
-
this.addToContainer(parent, this.childWidget, this.slotProps);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
attachToParentBefore(parent, before) {
|
|
38
|
-
if (this.isValidContainer(parent) && this.childWidget) {
|
|
39
|
-
this.parentContainer = parent;
|
|
40
|
-
const beforeWidget = this.getBeforeWidget(before);
|
|
41
|
-
if (beforeWidget) {
|
|
42
|
-
this.insertBeforeInContainer(parent, this.childWidget, this.slotProps, beforeWidget);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
this.addToContainer(parent, this.childWidget, this.slotProps);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
28
|
+
setParentContainer(container) {
|
|
29
|
+
this.parentContainer = container;
|
|
48
30
|
}
|
|
49
31
|
getBeforeWidget(before) {
|
|
50
32
|
if (before instanceof VirtualSlotNode) {
|
|
@@ -52,12 +34,16 @@ export class VirtualSlotNode extends Node {
|
|
|
52
34
|
}
|
|
53
35
|
return before.getWidget() ?? null;
|
|
54
36
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.
|
|
37
|
+
appendChild(child) {
|
|
38
|
+
const childWidget = child.getWidget();
|
|
39
|
+
if (childWidget) {
|
|
40
|
+
this.childWidget = childWidget;
|
|
59
41
|
}
|
|
60
42
|
}
|
|
43
|
+
unmount() {
|
|
44
|
+
this.parentContainer = null;
|
|
45
|
+
super.unmount();
|
|
46
|
+
}
|
|
61
47
|
updateSlotPropsIfChanged(oldProps, newProps, propKeys) {
|
|
62
48
|
const changed = propKeys.some((key) => oldProps[key] !== newProps[key]);
|
|
63
49
|
if (changed) {
|
package/dist/nodes/window.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import { Node } from "../node.js";
|
|
|
4
4
|
export declare class WindowNode extends Node<Gtk.Window> {
|
|
5
5
|
static consumedPropNames: string[];
|
|
6
6
|
static matches(type: string): boolean;
|
|
7
|
+
protected isStandalone(): boolean;
|
|
7
8
|
protected createWidget(type: string, _props: Props): Gtk.Window;
|
|
8
|
-
detachFromParent(_parent: Node): void;
|
|
9
9
|
mount(): void;
|
|
10
|
+
unmount(): void;
|
|
10
11
|
updateProps(oldProps: Props, newProps: Props): void;
|
|
11
12
|
}
|
package/dist/nodes/window.js
CHANGED
|
@@ -8,6 +8,9 @@ export class WindowNode extends Node {
|
|
|
8
8
|
static matches(type) {
|
|
9
9
|
return WINDOW_TYPES.has(normalizeWidgetType(type));
|
|
10
10
|
}
|
|
11
|
+
isStandalone() {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
11
14
|
createWidget(type, _props) {
|
|
12
15
|
const widgetType = normalizeWidgetType(type);
|
|
13
16
|
if (widgetType === "ApplicationWindow") {
|
|
@@ -21,12 +24,13 @@ export class WindowNode extends Node {
|
|
|
21
24
|
}
|
|
22
25
|
return new Gtk.Window();
|
|
23
26
|
}
|
|
24
|
-
detachFromParent(_parent) {
|
|
25
|
-
this.widget.destroy();
|
|
26
|
-
}
|
|
27
27
|
mount() {
|
|
28
28
|
this.widget.present();
|
|
29
29
|
}
|
|
30
|
+
unmount() {
|
|
31
|
+
this.widget.destroy();
|
|
32
|
+
super.unmount();
|
|
33
|
+
}
|
|
30
34
|
updateProps(oldProps, newProps) {
|
|
31
35
|
const widthChanged = oldProps.defaultWidth !== newProps.defaultWidth;
|
|
32
36
|
const heightChanged = oldProps.defaultHeight !== newProps.defaultHeight;
|
package/dist/predicates.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { ChildContainer, GridContainer, ItemContainer, PackContainer, PageContainer, StackPageContainer, StringListContainer } from "./containers.js";
|
|
3
|
+
import type { Node } from "./node.js";
|
|
2
4
|
interface Appendable extends Gtk.Widget {
|
|
3
5
|
append(child: unknown): void;
|
|
4
6
|
}
|
|
@@ -11,28 +13,17 @@ interface SingleChild extends Gtk.Widget {
|
|
|
11
13
|
interface Removable extends Gtk.Widget {
|
|
12
14
|
remove(child: unknown): void;
|
|
13
15
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Type guard that checks if a GTK widget supports appending children via an append method.
|
|
16
|
-
*/
|
|
17
16
|
export declare const isAppendable: (widget: Gtk.Widget) => widget is Appendable;
|
|
18
|
-
/**
|
|
19
|
-
* Type guard that checks if a GTK widget supports adding children via an add method.
|
|
20
|
-
*/
|
|
21
17
|
export declare const isAddable: (widget: Gtk.Widget) => widget is Addable;
|
|
22
|
-
/**
|
|
23
|
-
* Type guard that checks if a GTK widget supports a single child via setChild method.
|
|
24
|
-
*/
|
|
25
18
|
export declare const isSingleChild: (widget: Gtk.Widget) => widget is SingleChild;
|
|
26
|
-
/**
|
|
27
|
-
* Type guard that checks if a GTK widget supports removing children via a remove method.
|
|
28
|
-
*/
|
|
29
19
|
export declare const isRemovable: (widget: Gtk.Widget) => widget is Removable;
|
|
30
|
-
/**
|
|
31
|
-
* Type guard that checks if a GTK widget is a FlowBoxChild.
|
|
32
|
-
*/
|
|
33
20
|
export declare const isFlowBoxChild: (widget: Gtk.Widget) => widget is Gtk.FlowBoxChild;
|
|
34
|
-
/**
|
|
35
|
-
* Type guard that checks if a GTK widget is a ListBoxRow.
|
|
36
|
-
*/
|
|
37
21
|
export declare const isListBoxRow: (widget: Gtk.Widget) => widget is Gtk.ListBoxRow;
|
|
22
|
+
export declare const isChildContainer: (node: Node) => node is Node & ChildContainer;
|
|
23
|
+
export declare const isPageContainer: (node: Node) => node is Node & PageContainer;
|
|
24
|
+
export declare const isStackPageContainer: (node: Node) => node is Node & StackPageContainer;
|
|
25
|
+
export declare const isGridContainer: (node: Node) => node is Node & GridContainer;
|
|
26
|
+
export declare const isItemContainer: (node: Node) => node is Node & ItemContainer<unknown>;
|
|
27
|
+
export declare const isPackContainer: (node: Node) => node is Node & PackContainer;
|
|
28
|
+
export declare const isStringListContainer: (node: Node) => node is Node & StringListContainer;
|
|
38
29
|
export {};
|