@gtkx/react 0.9.4 → 0.10.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/README.md +55 -67
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +8 -8
- package/dist/factory.d.ts +3 -5
- package/dist/factory.js +18 -71
- package/dist/fiber-root.d.ts +1 -1
- package/dist/fiber-root.js +1 -2
- package/dist/generated/internal.d.ts +3 -6
- package/dist/generated/internal.js +10386 -13577
- package/dist/generated/jsx.d.ts +914 -808
- package/dist/generated/jsx.js +123 -358
- package/dist/generated/registry.d.ts +4 -0
- package/dist/generated/registry.js +13 -0
- package/dist/host-config.d.ts +7 -4
- package/dist/host-config.js +53 -18
- package/dist/index.d.ts +2 -22
- package/dist/index.js +2 -40
- package/dist/jsx.d.ts +719 -0
- package/dist/jsx.js +392 -0
- package/dist/node.d.ts +15 -32
- package/dist/node.js +20 -240
- package/dist/nodes/action-row-child.d.ts +21 -0
- package/dist/nodes/action-row-child.js +69 -0
- package/dist/nodes/action-row.js +33 -0
- package/dist/nodes/application.d.ts +1 -0
- package/dist/nodes/application.js +38 -0
- package/dist/nodes/autowrapped.d.ts +1 -0
- package/dist/nodes/autowrapped.js +109 -0
- package/dist/nodes/column-view-column.d.ts +16 -0
- package/dist/nodes/column-view-column.js +54 -0
- package/dist/nodes/column-view.d.ts +0 -59
- package/dist/nodes/column-view.js +107 -226
- package/dist/nodes/fixed-child.d.ts +1 -0
- package/dist/nodes/fixed-child.js +45 -0
- package/dist/nodes/grid-child.d.ts +1 -0
- package/dist/nodes/grid-child.js +54 -0
- package/dist/nodes/index.d.ts +34 -0
- package/dist/nodes/index.js +34 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +18 -0
- package/dist/nodes/internal/list-item-renderer.js +67 -0
- package/dist/nodes/internal/list-store.d.ts +16 -0
- package/dist/nodes/internal/list-store.js +69 -0
- package/dist/nodes/internal/predicates.d.ts +26 -0
- package/dist/nodes/internal/predicates.js +36 -0
- package/dist/nodes/internal/signal-store.d.ts +9 -0
- package/dist/nodes/internal/signal-store.js +54 -0
- package/dist/nodes/internal/simple-list-store.d.ts +14 -0
- package/dist/nodes/internal/simple-list-store.js +60 -0
- package/dist/nodes/internal/tree-list-item-renderer.d.ts +18 -0
- package/dist/nodes/internal/tree-list-item-renderer.js +90 -0
- package/dist/nodes/internal/tree-store.d.ts +28 -0
- package/dist/nodes/internal/tree-store.js +153 -0
- package/dist/nodes/internal/utils.d.ts +3 -0
- package/dist/nodes/internal/utils.js +20 -0
- package/dist/nodes/list-item.d.ts +12 -0
- package/dist/nodes/list-item.js +24 -0
- package/dist/nodes/list-view.d.ts +0 -22
- package/dist/nodes/list-view.js +45 -38
- package/dist/nodes/menu.d.ts +6 -106
- package/dist/nodes/menu.js +16 -268
- package/dist/nodes/models/list.d.ts +24 -0
- package/dist/nodes/models/list.js +102 -0
- package/dist/nodes/models/menu.d.ts +45 -0
- package/dist/nodes/models/menu.js +265 -0
- package/dist/nodes/models/tree-list.d.ts +28 -0
- package/dist/nodes/models/tree-list.js +141 -0
- package/dist/nodes/navigation-page.d.ts +21 -0
- package/dist/nodes/navigation-page.js +95 -0
- package/dist/nodes/navigation-view.d.ts +1 -0
- package/dist/nodes/navigation-view.js +29 -0
- package/dist/nodes/notebook-page-tab.d.ts +15 -0
- package/dist/nodes/notebook-page-tab.js +42 -0
- package/dist/nodes/notebook-page.d.ts +23 -0
- package/dist/nodes/notebook-page.js +106 -0
- package/dist/nodes/notebook.d.ts +0 -32
- package/dist/nodes/notebook.js +20 -113
- package/dist/nodes/overlay-child.d.ts +1 -0
- package/dist/nodes/overlay-child.js +30 -0
- package/dist/nodes/pack-child.d.ts +21 -0
- package/dist/nodes/pack-child.js +68 -0
- package/dist/nodes/pack.d.ts +1 -0
- package/dist/nodes/pack.js +33 -0
- package/dist/nodes/popover-menu.d.ts +1 -0
- package/dist/nodes/popover-menu.js +58 -0
- package/dist/nodes/simple-list-item.d.ts +9 -0
- package/dist/nodes/simple-list-item.js +9 -0
- package/dist/nodes/simple-list-view.d.ts +1 -0
- package/dist/nodes/simple-list-view.js +75 -0
- package/dist/nodes/slot.d.ts +18 -10
- package/dist/nodes/slot.js +83 -51
- package/dist/nodes/stack-page.d.ts +1 -0
- package/dist/nodes/stack-page.js +80 -0
- package/dist/nodes/stack.d.ts +1 -22
- package/dist/nodes/stack.js +21 -60
- package/dist/nodes/toast-overlay.d.ts +1 -0
- package/dist/nodes/toast-overlay.js +35 -0
- package/dist/nodes/toast.d.ts +17 -0
- package/dist/nodes/toast.js +77 -0
- package/dist/nodes/toolbar-child.d.ts +9 -0
- package/dist/nodes/toolbar-child.js +33 -0
- package/dist/nodes/toolbar.d.ts +1 -0
- package/dist/nodes/toolbar.js +42 -0
- package/dist/nodes/tree-list-item.d.ts +20 -0
- package/dist/nodes/tree-list-item.js +102 -0
- package/dist/nodes/tree-list-view.d.ts +1 -0
- package/dist/nodes/tree-list-view.js +57 -0
- package/dist/nodes/virtual.d.ts +13 -0
- package/dist/nodes/virtual.js +21 -0
- package/dist/nodes/widget.d.ts +17 -3
- package/dist/nodes/widget.js +258 -2
- package/dist/nodes/window.d.ts +1 -12
- package/dist/nodes/window.js +66 -27
- package/dist/portal.d.ts +18 -13
- package/dist/portal.js +17 -14
- package/dist/reconciler.d.ts +0 -4
- package/dist/reconciler.js +1 -9
- package/dist/registry.d.ts +8 -0
- package/dist/registry.js +5 -0
- package/dist/render.d.ts +108 -12
- package/dist/render.js +140 -16
- package/dist/scheduler.d.ts +4 -0
- package/dist/scheduler.js +10 -0
- package/dist/types.d.ts +3 -136
- package/package.json +6 -6
- package/dist/batch.d.ts +0 -5
- package/dist/batch.js +0 -31
- package/dist/codegen/jsx-generator.d.ts +0 -56
- package/dist/codegen/jsx-generator.js +0 -959
- package/dist/containers.d.ts +0 -58
- package/dist/nodes/about-dialog.d.ts +0 -8
- package/dist/nodes/about-dialog.js +0 -16
- package/dist/nodes/action-bar.d.ts +0 -5
- package/dist/nodes/action-bar.js +0 -6
- package/dist/nodes/combo-row.d.ts +0 -5
- package/dist/nodes/combo-row.js +0 -6
- package/dist/nodes/drop-down.d.ts +0 -9
- package/dist/nodes/drop-down.js +0 -12
- package/dist/nodes/flow-box.d.ts +0 -10
- package/dist/nodes/flow-box.js +0 -41
- package/dist/nodes/grid.d.ts +0 -30
- package/dist/nodes/grid.js +0 -84
- package/dist/nodes/header-bar.d.ts +0 -43
- package/dist/nodes/header-bar.js +0 -116
- package/dist/nodes/indexed-child-container.d.ts +0 -16
- package/dist/nodes/indexed-child-container.js +0 -22
- package/dist/nodes/list-box.d.ts +0 -10
- package/dist/nodes/list-box.js +0 -48
- package/dist/nodes/list-item-factory.d.ts +0 -19
- package/dist/nodes/list-item-factory.js +0 -58
- package/dist/nodes/overlay.d.ts +0 -11
- package/dist/nodes/overlay.js +0 -50
- package/dist/nodes/paged-stack.d.ts +0 -31
- package/dist/nodes/paged-stack.js +0 -95
- package/dist/nodes/root.d.ts +0 -8
- package/dist/nodes/root.js +0 -13
- package/dist/nodes/selectable-list.d.ts +0 -45
- package/dist/nodes/selectable-list.js +0 -260
- package/dist/nodes/stack-page-props.d.ts +0 -11
- package/dist/nodes/stack-page-props.js +0 -23
- package/dist/nodes/string-list-container.d.ts +0 -34
- package/dist/nodes/string-list-container.js +0 -118
- package/dist/nodes/string-list-item.d.ts +0 -19
- package/dist/nodes/string-list-item.js +0 -50
- package/dist/nodes/string-list-store.d.ts +0 -13
- package/dist/nodes/string-list-store.js +0 -44
- package/dist/nodes/text-view.d.ts +0 -8
- package/dist/nodes/text-view.js +0 -16
- package/dist/nodes/toggle-button.d.ts +0 -14
- package/dist/nodes/toggle-button.js +0 -39
- package/dist/nodes/toolbar-view.d.ts +0 -14
- package/dist/nodes/toolbar-view.js +0 -78
- package/dist/nodes/view-stack.d.ts +0 -9
- package/dist/nodes/view-stack.js +0 -28
- package/dist/nodes/virtual-item.d.ts +0 -19
- package/dist/nodes/virtual-item.js +0 -48
- package/dist/nodes/virtual-slot.d.ts +0 -25
- package/dist/nodes/virtual-slot.js +0 -57
- package/dist/predicates.d.ts +0 -29
- package/dist/predicates.js +0 -37
- package/dist/props.d.ts +0 -7
- package/dist/props.js +0 -12
- /package/dist/{containers.js → nodes/action-row.d.ts} +0 -0
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { getNativeObject } from "@gtkx/ffi";
|
|
2
|
-
import * as Gio from "@gtkx/ffi/gio";
|
|
3
|
-
import { Node as NodeClass } from "../node.js";
|
|
4
|
-
import { getCallbackChange } from "../props.js";
|
|
5
|
-
import { StringListItemNode } from "./string-list-item.js";
|
|
6
|
-
import { StringListStore } from "./string-list-store.js";
|
|
7
|
-
const SELECTION_SIGNAL = "notify::selected";
|
|
8
|
-
export class StringListContainerNode extends NodeClass {
|
|
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
|
-
}
|
|
41
|
-
initialize(props) {
|
|
42
|
-
const store = new StringListStore();
|
|
43
|
-
const onSelectionChanged = props.onSelectionChanged;
|
|
44
|
-
const initialSelection = props.selectedId;
|
|
45
|
-
this.state = { store, onSelectionChanged, initialSelection, hasAppliedInitialSelection: false };
|
|
46
|
-
super.initialize(props);
|
|
47
|
-
this.widget.setModel(getNativeObject(store.getModel().id, Gio.ListModel) ?? undefined);
|
|
48
|
-
}
|
|
49
|
-
connectSelectionHandler() {
|
|
50
|
-
const handler = () => {
|
|
51
|
-
const index = this.widget.getSelected();
|
|
52
|
-
const id = this.state.store.getIdAtIndex(index);
|
|
53
|
-
if (id !== undefined) {
|
|
54
|
-
this.state.onSelectionChanged?.(id);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
this.connectSignal(this.widget, SELECTION_SIGNAL, handler);
|
|
58
|
-
}
|
|
59
|
-
addStringListItem(id, label) {
|
|
60
|
-
this.state.store.append(id, label);
|
|
61
|
-
this.scheduleInitialSelectionIfNeeded();
|
|
62
|
-
}
|
|
63
|
-
scheduleInitialSelectionIfNeeded() {
|
|
64
|
-
if (!this.state.hasAppliedInitialSelection) {
|
|
65
|
-
this.state.hasAppliedInitialSelection = true;
|
|
66
|
-
queueMicrotask(() => this.applyInitialSelection());
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
applyInitialSelection() {
|
|
70
|
-
if (this.state.initialSelection !== undefined) {
|
|
71
|
-
const index = this.state.store.getIndexForId(this.state.initialSelection);
|
|
72
|
-
if (index !== -1) {
|
|
73
|
-
this.widget.setSelected(index);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (this.state.onSelectionChanged) {
|
|
77
|
-
this.connectSelectionHandler();
|
|
78
|
-
const currentIndex = this.widget.getSelected();
|
|
79
|
-
const id = this.state.store.getIdAtIndex(currentIndex);
|
|
80
|
-
if (id !== undefined) {
|
|
81
|
-
this.state.onSelectionChanged(id);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
insertStringListItemBefore(id, label, beforeId) {
|
|
86
|
-
this.state.store.insertBefore(id, label, beforeId);
|
|
87
|
-
}
|
|
88
|
-
removeStringListItem(id) {
|
|
89
|
-
this.state.store.remove(id);
|
|
90
|
-
}
|
|
91
|
-
updateStringListItem(oldId, newId, newLabel) {
|
|
92
|
-
this.state.store.update(oldId, newId, newLabel);
|
|
93
|
-
}
|
|
94
|
-
updateProps(oldProps, newProps) {
|
|
95
|
-
const oldCallback = oldProps.onSelectionChanged;
|
|
96
|
-
const newCallback = newProps.onSelectionChanged;
|
|
97
|
-
const change = getCallbackChange(oldCallback, newCallback);
|
|
98
|
-
if (change.action !== "none") {
|
|
99
|
-
this.state.onSelectionChanged = change.callback;
|
|
100
|
-
if (change.action === "disconnect") {
|
|
101
|
-
this.disconnectSignal(SELECTION_SIGNAL);
|
|
102
|
-
}
|
|
103
|
-
else if (change.action === "connect") {
|
|
104
|
-
this.connectSelectionHandler();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const oldSelected = oldProps.selectedId;
|
|
108
|
-
const newSelected = newProps.selectedId;
|
|
109
|
-
if (oldSelected !== newSelected && newSelected !== undefined) {
|
|
110
|
-
this.state.initialSelection = newSelected;
|
|
111
|
-
const index = this.state.store.getIndexForId(newSelected);
|
|
112
|
-
if (index !== -1) {
|
|
113
|
-
this.widget.setSelected(index);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
super.updateProps(oldProps, newProps);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { StringListContainer, StringListItem } from "../containers.js";
|
|
2
|
-
import type { Props } from "../factory.js";
|
|
3
|
-
import type { Node } from "../node.js";
|
|
4
|
-
import { Node as NodeClass } from "../node.js";
|
|
5
|
-
export declare abstract class StringListItemNode extends NodeClass<never> {
|
|
6
|
-
static consumedPropNames: string[];
|
|
7
|
-
protected isVirtual(): boolean;
|
|
8
|
-
private id;
|
|
9
|
-
private label;
|
|
10
|
-
private parentContainer;
|
|
11
|
-
initialize(props: Props): void;
|
|
12
|
-
getId(): string;
|
|
13
|
-
getStringListItem(): StringListItem;
|
|
14
|
-
setParentContainer(container: Node & StringListContainer): void;
|
|
15
|
-
addToContainer(container: StringListContainer): void;
|
|
16
|
-
insertBeforeInContainer(container: StringListContainer, beforeId: string): void;
|
|
17
|
-
unmount(): void;
|
|
18
|
-
updateProps(oldProps: Props, newProps: Props): void;
|
|
19
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Node as NodeClass } from "../node.js";
|
|
2
|
-
import { isStringListContainer } from "../predicates.js";
|
|
3
|
-
export class StringListItemNode extends NodeClass {
|
|
4
|
-
static consumedPropNames = ["id", "label"];
|
|
5
|
-
isVirtual() {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
id = "";
|
|
9
|
-
label = "";
|
|
10
|
-
parentContainer = null;
|
|
11
|
-
initialize(props) {
|
|
12
|
-
this.id = props.id;
|
|
13
|
-
this.label = props.label;
|
|
14
|
-
super.initialize(props);
|
|
15
|
-
}
|
|
16
|
-
getId() {
|
|
17
|
-
return this.id;
|
|
18
|
-
}
|
|
19
|
-
getStringListItem() {
|
|
20
|
-
return { id: this.id, label: this.label };
|
|
21
|
-
}
|
|
22
|
-
setParentContainer(container) {
|
|
23
|
-
this.parentContainer = container;
|
|
24
|
-
}
|
|
25
|
-
addToContainer(container) {
|
|
26
|
-
container.addStringListItem(this.id, this.label);
|
|
27
|
-
}
|
|
28
|
-
insertBeforeInContainer(container, beforeId) {
|
|
29
|
-
container.insertStringListItemBefore(this.id, this.label, beforeId);
|
|
30
|
-
}
|
|
31
|
-
unmount() {
|
|
32
|
-
if (this.parentContainer) {
|
|
33
|
-
this.parentContainer.removeStringListItem(this.id);
|
|
34
|
-
}
|
|
35
|
-
this.parentContainer = null;
|
|
36
|
-
super.unmount();
|
|
37
|
-
}
|
|
38
|
-
updateProps(oldProps, newProps) {
|
|
39
|
-
const oldId = oldProps.id;
|
|
40
|
-
const newId = newProps.id;
|
|
41
|
-
const oldLabel = oldProps.label;
|
|
42
|
-
const newLabel = newProps.label;
|
|
43
|
-
if ((oldId !== newId || oldLabel !== newLabel) && this.parent && isStringListContainer(this.parent)) {
|
|
44
|
-
this.parent.updateStringListItem(this.id, newId, newLabel);
|
|
45
|
-
this.id = newId;
|
|
46
|
-
this.label = newLabel;
|
|
47
|
-
}
|
|
48
|
-
super.updateProps(oldProps, newProps);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
export declare class StringListStore {
|
|
3
|
-
private stringList;
|
|
4
|
-
private ids;
|
|
5
|
-
constructor();
|
|
6
|
-
getModel(): Gtk.StringList;
|
|
7
|
-
append(id: string, label: string): void;
|
|
8
|
-
insertBefore(id: string, label: string, beforeId: string): void;
|
|
9
|
-
remove(id: string): void;
|
|
10
|
-
update(oldId: string, newId: string, newLabel: string): void;
|
|
11
|
-
getIdAtIndex(index: number): string | undefined;
|
|
12
|
-
getIndexForId(id: string): number;
|
|
13
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
export class StringListStore {
|
|
3
|
-
stringList;
|
|
4
|
-
ids = [];
|
|
5
|
-
constructor() {
|
|
6
|
-
this.stringList = new Gtk.StringList([]);
|
|
7
|
-
}
|
|
8
|
-
getModel() {
|
|
9
|
-
return this.stringList;
|
|
10
|
-
}
|
|
11
|
-
append(id, label) {
|
|
12
|
-
this.stringList.append(label);
|
|
13
|
-
this.ids.push(id);
|
|
14
|
-
}
|
|
15
|
-
insertBefore(id, label, beforeId) {
|
|
16
|
-
const beforeIndex = this.ids.indexOf(beforeId);
|
|
17
|
-
if (beforeIndex === -1) {
|
|
18
|
-
this.append(id, label);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
this.stringList.splice(beforeIndex, 0, [label]);
|
|
22
|
-
this.ids.splice(beforeIndex, 0, id);
|
|
23
|
-
}
|
|
24
|
-
remove(id) {
|
|
25
|
-
const index = this.ids.indexOf(id);
|
|
26
|
-
if (index !== -1) {
|
|
27
|
-
this.stringList.remove(index);
|
|
28
|
-
this.ids.splice(index, 1);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
update(oldId, newId, newLabel) {
|
|
32
|
-
const index = this.ids.indexOf(oldId);
|
|
33
|
-
if (index !== -1) {
|
|
34
|
-
this.stringList.splice(index, 1, [newLabel]);
|
|
35
|
-
this.ids[index] = newId;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
getIdAtIndex(index) {
|
|
39
|
-
return this.ids[index];
|
|
40
|
-
}
|
|
41
|
-
getIndexForId(id) {
|
|
42
|
-
return this.ids.indexOf(id);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import type { Props } from "../factory.js";
|
|
3
|
-
import { Node } from "../node.js";
|
|
4
|
-
export declare class TextViewNode extends Node<Gtk.TextView> {
|
|
5
|
-
static consumedPropNames: string[];
|
|
6
|
-
static matches(type: string): boolean;
|
|
7
|
-
updateProps(oldProps: Props, newProps: Props): void;
|
|
8
|
-
}
|
package/dist/nodes/text-view.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Node } from "../node.js";
|
|
2
|
-
export class TextViewNode extends Node {
|
|
3
|
-
static consumedPropNames = ["buffer"];
|
|
4
|
-
static matches(type) {
|
|
5
|
-
return type === "TextView";
|
|
6
|
-
}
|
|
7
|
-
updateProps(oldProps, newProps) {
|
|
8
|
-
if (oldProps.buffer !== newProps.buffer) {
|
|
9
|
-
const buffer = newProps.buffer;
|
|
10
|
-
if (buffer) {
|
|
11
|
-
this.widget.setBuffer(buffer);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
super.updateProps(oldProps, newProps);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import type { Props } from "../factory.js";
|
|
3
|
-
import { Node } from "../node.js";
|
|
4
|
-
type ToggleButtonState = {
|
|
5
|
-
lastPropsActive: boolean | undefined;
|
|
6
|
-
};
|
|
7
|
-
export declare class ToggleButtonNode extends Node<Gtk.ToggleButton, ToggleButtonState> {
|
|
8
|
-
static consumedPropNames: string[];
|
|
9
|
-
static matches(type: string): boolean;
|
|
10
|
-
initialize(props: Props): void;
|
|
11
|
-
updateProps(_oldProps: Props, newProps: Props): void;
|
|
12
|
-
protected connectSignal(widget: Gtk.Widget, eventName: string, handler: (...args: unknown[]) => unknown): void;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Node } from "../node.js";
|
|
2
|
-
export class ToggleButtonNode extends Node {
|
|
3
|
-
static consumedPropNames = ["active"];
|
|
4
|
-
static matches(type) {
|
|
5
|
-
return type === "ToggleButton.Root";
|
|
6
|
-
}
|
|
7
|
-
initialize(props) {
|
|
8
|
-
this.state = { lastPropsActive: undefined };
|
|
9
|
-
super.initialize(props);
|
|
10
|
-
}
|
|
11
|
-
updateProps(_oldProps, newProps) {
|
|
12
|
-
const widget = this.getWidget();
|
|
13
|
-
if (!widget) {
|
|
14
|
-
super.updateProps(_oldProps, newProps);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const newActive = newProps.active;
|
|
18
|
-
if (typeof newActive === "boolean") {
|
|
19
|
-
this.state.lastPropsActive = newActive;
|
|
20
|
-
if (widget.getActive() !== newActive) {
|
|
21
|
-
widget.setActive(newActive);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
super.updateProps(_oldProps, newProps);
|
|
25
|
-
}
|
|
26
|
-
connectSignal(widget, eventName, handler) {
|
|
27
|
-
if (eventName === "toggled") {
|
|
28
|
-
const wrappedHandler = (...args) => {
|
|
29
|
-
if (this.widget?.getActive() === this.state.lastPropsActive) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
return handler(...args);
|
|
33
|
-
};
|
|
34
|
-
super.connectSignal(widget, eventName, wrappedHandler);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
super.connectSignal(widget, eventName, handler);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Node } from "../node.js";
|
|
2
|
-
export declare class ToolbarViewSlotNode extends Node<never> {
|
|
3
|
-
static matches(type: string): boolean;
|
|
4
|
-
protected isVirtual(): boolean;
|
|
5
|
-
private slotType;
|
|
6
|
-
private children;
|
|
7
|
-
constructor(type: string);
|
|
8
|
-
appendChild(child: Node): void;
|
|
9
|
-
removeChild(child: Node): void;
|
|
10
|
-
mount(): void;
|
|
11
|
-
unmount(): void;
|
|
12
|
-
private addBarToParent;
|
|
13
|
-
private removeBarFromParent;
|
|
14
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Node } from "../node.js";
|
|
2
|
-
export class ToolbarViewSlotNode extends Node {
|
|
3
|
-
static matches(type) {
|
|
4
|
-
if (!type.startsWith("AdwToolbarView."))
|
|
5
|
-
return false;
|
|
6
|
-
const slot = type.split(".")[1];
|
|
7
|
-
return slot === "Top" || slot === "Bottom";
|
|
8
|
-
}
|
|
9
|
-
isVirtual() {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
slotType;
|
|
13
|
-
children = [];
|
|
14
|
-
constructor(type) {
|
|
15
|
-
super(type);
|
|
16
|
-
const slot = type.split(".")[1];
|
|
17
|
-
if (slot !== "Top" && slot !== "Bottom") {
|
|
18
|
-
throw new Error(`Invalid toolbar view slot type: ${type}`);
|
|
19
|
-
}
|
|
20
|
-
this.slotType = slot;
|
|
21
|
-
}
|
|
22
|
-
appendChild(child) {
|
|
23
|
-
child.parent = this;
|
|
24
|
-
const childWidget = child.getWidget();
|
|
25
|
-
if (!childWidget)
|
|
26
|
-
return;
|
|
27
|
-
this.children.push(child);
|
|
28
|
-
if (this.parent) {
|
|
29
|
-
this.addBarToParent(childWidget);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
removeChild(child) {
|
|
33
|
-
child.unmount();
|
|
34
|
-
const index = this.children.indexOf(child);
|
|
35
|
-
if (index !== -1) {
|
|
36
|
-
this.children.splice(index, 1);
|
|
37
|
-
}
|
|
38
|
-
const childWidget = child.getWidget();
|
|
39
|
-
if (this.parent && childWidget) {
|
|
40
|
-
this.removeBarFromParent(childWidget);
|
|
41
|
-
}
|
|
42
|
-
child.parent = null;
|
|
43
|
-
}
|
|
44
|
-
mount() {
|
|
45
|
-
for (const child of this.children) {
|
|
46
|
-
const childWidget = child.getWidget();
|
|
47
|
-
if (childWidget) {
|
|
48
|
-
this.addBarToParent(childWidget);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
unmount() {
|
|
53
|
-
for (const child of this.children) {
|
|
54
|
-
const childWidget = child.getWidget();
|
|
55
|
-
if (childWidget) {
|
|
56
|
-
this.removeBarFromParent(childWidget);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
super.unmount();
|
|
60
|
-
}
|
|
61
|
-
addBarToParent(childWidget) {
|
|
62
|
-
const parentWidget = this.parent?.getWidget();
|
|
63
|
-
if (!parentWidget)
|
|
64
|
-
return;
|
|
65
|
-
if (this.slotType === "Top") {
|
|
66
|
-
parentWidget.addTopBar(childWidget);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
parentWidget.addBottomBar(childWidget);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
removeBarFromParent(childWidget) {
|
|
73
|
-
const parentWidget = this.parent?.getWidget();
|
|
74
|
-
if (!parentWidget)
|
|
75
|
-
return;
|
|
76
|
-
parentWidget.remove(childWidget);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type * as Adw from "@gtkx/ffi/adw";
|
|
2
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
-
import type { StackPageProps } from "../containers.js";
|
|
4
|
-
import { PagedStackNode } from "./paged-stack.js";
|
|
5
|
-
export declare class ViewStackNode extends PagedStackNode<Adw.ViewStack> {
|
|
6
|
-
static matches(type: string): boolean;
|
|
7
|
-
addStackPage(child: Gtk.Widget, props: StackPageProps): void;
|
|
8
|
-
protected addChildToWidget(child: Gtk.Widget): void;
|
|
9
|
-
}
|
package/dist/nodes/view-stack.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { PagedStackNode } from "./paged-stack.js";
|
|
2
|
-
import { applyStackPageProps } from "./stack-page-props.js";
|
|
3
|
-
export class ViewStackNode extends PagedStackNode {
|
|
4
|
-
static matches(type) {
|
|
5
|
-
return type === "AdwViewStack" || type === "AdwViewStack.Root";
|
|
6
|
-
}
|
|
7
|
-
addStackPage(child, props) {
|
|
8
|
-
const { name, title, iconName } = props;
|
|
9
|
-
let page;
|
|
10
|
-
if (title !== undefined && iconName !== undefined) {
|
|
11
|
-
page = this.widget.addTitledWithIcon(child, title, iconName, name);
|
|
12
|
-
}
|
|
13
|
-
else if (title !== undefined) {
|
|
14
|
-
page = this.widget.addTitled(child, title, name);
|
|
15
|
-
}
|
|
16
|
-
else if (name !== undefined) {
|
|
17
|
-
page = this.widget.addNamed(child, name);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
page = this.widget.add(child);
|
|
21
|
-
}
|
|
22
|
-
applyStackPageProps(page, props);
|
|
23
|
-
this.applyPendingVisibleChild();
|
|
24
|
-
}
|
|
25
|
-
addChildToWidget(child) {
|
|
26
|
-
this.widget.add(child);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ItemContainer } from "../containers.js";
|
|
2
|
-
import type { Props } from "../factory.js";
|
|
3
|
-
import type { Node } from "../node.js";
|
|
4
|
-
import { Node as NodeClass } from "../node.js";
|
|
5
|
-
export declare abstract class VirtualItemNode extends NodeClass<never> {
|
|
6
|
-
static consumedPropNames: string[];
|
|
7
|
-
protected isVirtual(): boolean;
|
|
8
|
-
private id;
|
|
9
|
-
private item;
|
|
10
|
-
private parentContainer;
|
|
11
|
-
initialize(props: Props): void;
|
|
12
|
-
getId(): string;
|
|
13
|
-
getItem(): unknown;
|
|
14
|
-
setParentContainer(container: Node & ItemContainer<unknown>): void;
|
|
15
|
-
addToContainer(container: ItemContainer<unknown>): void;
|
|
16
|
-
insertBeforeInContainer(container: ItemContainer<unknown>, beforeId: string): void;
|
|
17
|
-
unmount(): void;
|
|
18
|
-
updateProps(oldProps: Props, newProps: Props): void;
|
|
19
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Node as NodeClass } from "../node.js";
|
|
2
|
-
import { isItemContainer } from "../predicates.js";
|
|
3
|
-
export class VirtualItemNode extends NodeClass {
|
|
4
|
-
static consumedPropNames = ["id", "item"];
|
|
5
|
-
isVirtual() {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
id = "";
|
|
9
|
-
item;
|
|
10
|
-
parentContainer = null;
|
|
11
|
-
initialize(props) {
|
|
12
|
-
this.id = props.id;
|
|
13
|
-
this.item = props.item;
|
|
14
|
-
super.initialize(props);
|
|
15
|
-
}
|
|
16
|
-
getId() {
|
|
17
|
-
return this.id;
|
|
18
|
-
}
|
|
19
|
-
getItem() {
|
|
20
|
-
return this.item;
|
|
21
|
-
}
|
|
22
|
-
setParentContainer(container) {
|
|
23
|
-
this.parentContainer = container;
|
|
24
|
-
}
|
|
25
|
-
addToContainer(container) {
|
|
26
|
-
container.addItem(this.id, this.item);
|
|
27
|
-
}
|
|
28
|
-
insertBeforeInContainer(container, beforeId) {
|
|
29
|
-
container.insertItemBefore(this.id, this.item, beforeId);
|
|
30
|
-
}
|
|
31
|
-
unmount() {
|
|
32
|
-
if (this.parentContainer) {
|
|
33
|
-
this.parentContainer.removeItem(this.id);
|
|
34
|
-
}
|
|
35
|
-
this.parentContainer = null;
|
|
36
|
-
super.unmount();
|
|
37
|
-
}
|
|
38
|
-
updateProps(oldProps, newProps) {
|
|
39
|
-
const newId = newProps.id;
|
|
40
|
-
const newItem = newProps.item;
|
|
41
|
-
if ((oldProps.id !== newId || oldProps.item !== newItem) && this.parent && isItemContainer(this.parent)) {
|
|
42
|
-
this.parent.updateItem(newId, newItem);
|
|
43
|
-
this.id = newId;
|
|
44
|
-
this.item = newItem;
|
|
45
|
-
}
|
|
46
|
-
super.updateProps(oldProps, newProps);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import type { Props } from "../factory.js";
|
|
3
|
-
import { Node } from "../node.js";
|
|
4
|
-
export declare abstract class VirtualSlotNode<TContainer, TProps> extends Node<never> {
|
|
5
|
-
protected isVirtual(): boolean;
|
|
6
|
-
protected childWidget: Gtk.Widget | null;
|
|
7
|
-
protected parentContainer: (Node & TContainer) | null;
|
|
8
|
-
private _slotProps;
|
|
9
|
-
protected get slotProps(): TProps;
|
|
10
|
-
protected set slotProps(value: TProps);
|
|
11
|
-
protected abstract isValidContainer(parent: Node): parent is Node & TContainer;
|
|
12
|
-
protected abstract addToContainer(container: TContainer, child: Gtk.Widget, props: TProps): void;
|
|
13
|
-
protected abstract insertBeforeInContainer(container: TContainer, child: Gtk.Widget, props: TProps, before: Gtk.Widget): void;
|
|
14
|
-
protected abstract removeFromContainer(container: TContainer, child: Gtk.Widget): void;
|
|
15
|
-
protected abstract updateInContainer(container: TContainer, child: Gtk.Widget, props: TProps): void;
|
|
16
|
-
protected abstract extractSlotProps(props: Props): TProps;
|
|
17
|
-
initialize(props: Props): void;
|
|
18
|
-
getChildWidget(): Gtk.Widget | null;
|
|
19
|
-
getSlotProps(): TProps;
|
|
20
|
-
setParentContainer(container: Node & TContainer): void;
|
|
21
|
-
getBeforeWidget(before: Node): Gtk.Widget | null;
|
|
22
|
-
appendChild(child: Node): void;
|
|
23
|
-
unmount(): void;
|
|
24
|
-
protected updateSlotPropsIfChanged(oldProps: Props, newProps: Props, propKeys: string[]): boolean;
|
|
25
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Node } from "../node.js";
|
|
2
|
-
export class VirtualSlotNode extends Node {
|
|
3
|
-
isVirtual() {
|
|
4
|
-
return true;
|
|
5
|
-
}
|
|
6
|
-
childWidget = null;
|
|
7
|
-
parentContainer = null;
|
|
8
|
-
_slotProps;
|
|
9
|
-
get slotProps() {
|
|
10
|
-
if (this._slotProps === undefined) {
|
|
11
|
-
throw new Error("slotProps accessed before initialization");
|
|
12
|
-
}
|
|
13
|
-
return this._slotProps;
|
|
14
|
-
}
|
|
15
|
-
set slotProps(value) {
|
|
16
|
-
this._slotProps = value;
|
|
17
|
-
}
|
|
18
|
-
initialize(props) {
|
|
19
|
-
this.slotProps = this.extractSlotProps(props);
|
|
20
|
-
super.initialize(props);
|
|
21
|
-
}
|
|
22
|
-
getChildWidget() {
|
|
23
|
-
return this.childWidget;
|
|
24
|
-
}
|
|
25
|
-
getSlotProps() {
|
|
26
|
-
return this.slotProps;
|
|
27
|
-
}
|
|
28
|
-
setParentContainer(container) {
|
|
29
|
-
this.parentContainer = container;
|
|
30
|
-
}
|
|
31
|
-
getBeforeWidget(before) {
|
|
32
|
-
if (before instanceof VirtualSlotNode) {
|
|
33
|
-
return before.getChildWidget();
|
|
34
|
-
}
|
|
35
|
-
return before.getWidget() ?? null;
|
|
36
|
-
}
|
|
37
|
-
appendChild(child) {
|
|
38
|
-
const childWidget = child.getWidget();
|
|
39
|
-
if (childWidget) {
|
|
40
|
-
this.childWidget = childWidget;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
unmount() {
|
|
44
|
-
this.parentContainer = null;
|
|
45
|
-
super.unmount();
|
|
46
|
-
}
|
|
47
|
-
updateSlotPropsIfChanged(oldProps, newProps, propKeys) {
|
|
48
|
-
const changed = propKeys.some((key) => oldProps[key] !== newProps[key]);
|
|
49
|
-
if (changed) {
|
|
50
|
-
this.slotProps = this.extractSlotProps(newProps);
|
|
51
|
-
if (this.parentContainer && this.childWidget) {
|
|
52
|
-
this.updateInContainer(this.parentContainer, this.childWidget, this.slotProps);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return changed;
|
|
56
|
-
}
|
|
57
|
-
}
|
package/dist/predicates.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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";
|
|
4
|
-
interface Appendable extends Gtk.Widget {
|
|
5
|
-
append(child: unknown): void;
|
|
6
|
-
}
|
|
7
|
-
interface Addable extends Gtk.Widget {
|
|
8
|
-
add(child: unknown): void;
|
|
9
|
-
}
|
|
10
|
-
interface SingleChild extends Gtk.Widget {
|
|
11
|
-
setChild(child: unknown): void;
|
|
12
|
-
}
|
|
13
|
-
interface Removable extends Gtk.Widget {
|
|
14
|
-
remove(child: unknown): void;
|
|
15
|
-
}
|
|
16
|
-
export declare const isAppendable: (widget: Gtk.Widget) => widget is Appendable;
|
|
17
|
-
export declare const isAddable: (widget: Gtk.Widget) => widget is Addable;
|
|
18
|
-
export declare const isSingleChild: (widget: Gtk.Widget) => widget is SingleChild;
|
|
19
|
-
export declare const isRemovable: (widget: Gtk.Widget) => widget is Removable;
|
|
20
|
-
export declare const isFlowBoxChild: (widget: Gtk.Widget) => widget is Gtk.FlowBoxChild;
|
|
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;
|
|
29
|
-
export {};
|