@gtkx/react 0.13.2 → 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.
@@ -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
- private addPage;
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
- if (!this.page) {
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
- this.page.setTag(newProps.id);
16
+ child.setTag(newProps.id);
21
17
  }
22
18
  if (newProps.title !== undefined && (!oldProps || oldProps.title !== newProps.title)) {
23
- this.page.setTitle(newProps.title);
19
+ child.setTitle(newProps.title);
24
20
  }
25
21
  if (newProps.canPop !== undefined && (!oldProps || oldProps.canPop !== newProps.canPop)) {
26
- this.page.setCanPop(newProps.canPop);
22
+ child.setCanPop(newProps.canPop);
27
23
  }
28
24
  }
29
- addPage() {
30
- const child = this.getChild();
31
- const parent = this.getParent();
25
+ onChildChange(oldChild) {
26
+ const navigationView = this.getParent();
32
27
  const title = this.props.title ?? "";
33
- const page = this.props.id
34
- ? Adw.NavigationPage.newWithTag(child, title, this.props.id)
35
- : new Adw.NavigationPage(child, title);
36
- parent.add(page);
37
- this.page = page;
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
- const pageChild = this.page.getChild();
46
- if (pageChild && isObjectEqual(pageChild, oldChild)) {
47
- parent.remove(this.page);
48
- this.page = undefined;
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
- onChildChange(oldChild) {
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.2",
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/ffi": "0.13.2",
41
- "@gtkx/gir": "0.13.2"
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"