@gtkx/react 0.13.1 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/nodes/navigation-page.d.ts +1 -6
- package/dist/nodes/navigation-page.js +21 -32
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -83,6 +83,7 @@ Explore complete applications in the [`examples/`](./examples) directory:
|
|
|
83
83
|
- **[gtk-demo](./examples/gtk-demo)** — Full replica of the official GTK demo app
|
|
84
84
|
- **[hello-world](./examples/hello-world)** — Minimal application showing a counter
|
|
85
85
|
- **[todo](./examples/todo)** — Full-featured todo application with Adwaita styling and testing
|
|
86
|
+
- **[x-showcase](./examples/x-showcase)** — Showcase of all x.* virtual components
|
|
86
87
|
- **[deploying](./examples/deploying)** — Example of packaging and distributing a GTKX app
|
|
87
88
|
|
|
88
89
|
## Documentation
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
3
2
|
import type { NavigationPageProps } from "../jsx.js";
|
|
4
3
|
import { SlotNode } from "./slot.js";
|
|
5
4
|
type Props = Partial<NavigationPageProps>;
|
|
6
5
|
export declare class NavigationPageNode extends SlotNode<Props> {
|
|
7
6
|
static priority: number;
|
|
8
|
-
private page?;
|
|
9
7
|
static matches(type: string): boolean;
|
|
10
|
-
getPage(): Adw.NavigationPage | undefined;
|
|
11
8
|
updateProps(oldProps: Props | null, newProps: Props): void;
|
|
12
|
-
|
|
13
|
-
private removePage;
|
|
14
|
-
protected onChildChange(oldChild: Gtk.Widget | null): void;
|
|
9
|
+
protected onChildChange(oldChild: Adw.NavigationPage | null): void;
|
|
15
10
|
}
|
|
16
11
|
export {};
|
|
@@ -1,57 +1,46 @@
|
|
|
1
|
-
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
1
|
import * as Adw from "@gtkx/ffi/adw";
|
|
3
2
|
import { registerNodeClass } from "../registry.js";
|
|
4
3
|
import { SlotNode } from "./slot.js";
|
|
5
4
|
export class NavigationPageNode extends SlotNode {
|
|
6
5
|
static priority = 1;
|
|
7
|
-
page;
|
|
8
6
|
static matches(type) {
|
|
9
7
|
return type === "NavigationPage";
|
|
10
8
|
}
|
|
11
|
-
getPage() {
|
|
12
|
-
return this.page;
|
|
13
|
-
}
|
|
14
9
|
updateProps(oldProps, newProps) {
|
|
15
10
|
super.updateProps(oldProps, newProps);
|
|
16
|
-
|
|
11
|
+
const child = this.child;
|
|
12
|
+
if (!(child instanceof Adw.NavigationPage)) {
|
|
17
13
|
return;
|
|
18
14
|
}
|
|
19
15
|
if (newProps.id !== undefined && (!oldProps || oldProps.id !== newProps.id)) {
|
|
20
|
-
|
|
16
|
+
child.setTag(newProps.id);
|
|
21
17
|
}
|
|
22
18
|
if (newProps.title !== undefined && (!oldProps || oldProps.title !== newProps.title)) {
|
|
23
|
-
|
|
19
|
+
child.setTitle(newProps.title);
|
|
24
20
|
}
|
|
25
21
|
if (newProps.canPop !== undefined && (!oldProps || oldProps.canPop !== newProps.canPop)) {
|
|
26
|
-
|
|
22
|
+
child.setCanPop(newProps.canPop);
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const parent = this.getParent();
|
|
25
|
+
onChildChange(oldChild) {
|
|
26
|
+
const navigationView = this.getParent();
|
|
32
27
|
const title = this.props.title ?? "";
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.updateProps(null, this.props);
|
|
39
|
-
}
|
|
40
|
-
removePage(oldChild) {
|
|
41
|
-
const parent = this.getParent();
|
|
42
|
-
if (!oldChild || !this.page) {
|
|
43
|
-
return;
|
|
28
|
+
if (this.child) {
|
|
29
|
+
this.child = this.props.id
|
|
30
|
+
? Adw.NavigationPage.newWithTag(this.child, title, this.props.id)
|
|
31
|
+
: new Adw.NavigationPage(this.child, title);
|
|
32
|
+
this.updateProps(null, this.props);
|
|
44
33
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
if (navigationView instanceof Adw.NavigationView) {
|
|
35
|
+
if (oldChild instanceof Adw.NavigationPage) {
|
|
36
|
+
navigationView.remove(oldChild);
|
|
37
|
+
}
|
|
38
|
+
if (this.child) {
|
|
39
|
+
navigationView.add(this.child);
|
|
40
|
+
}
|
|
49
41
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.removePage(oldChild);
|
|
53
|
-
if (this.child) {
|
|
54
|
-
this.addPage();
|
|
42
|
+
else {
|
|
43
|
+
super.onChildChange(oldChild);
|
|
55
44
|
}
|
|
56
45
|
}
|
|
57
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/react",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.3",
|
|
4
4
|
"description": "Build GTK4 desktop applications with React and TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"react-reconciler": "^0.33.0",
|
|
40
|
-
"@gtkx/gir": "0.13.
|
|
41
|
-
"@gtkx/ffi": "0.13.
|
|
40
|
+
"@gtkx/gir": "0.13.3",
|
|
41
|
+
"@gtkx/ffi": "0.13.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/react-reconciler": "^0.32.3"
|