@gtkx/react 0.18.4 → 0.18.6

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.
Files changed (82) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/jsx.d.ts +1 -1
  6. package/dist/jsx.d.ts.map +1 -1
  7. package/dist/nodes/calendar.d.ts +4 -1
  8. package/dist/nodes/calendar.d.ts.map +1 -1
  9. package/dist/nodes/calendar.js +3 -1
  10. package/dist/nodes/calendar.js.map +1 -1
  11. package/dist/nodes/column-view.d.ts +4 -1
  12. package/dist/nodes/column-view.d.ts.map +1 -1
  13. package/dist/nodes/column-view.js +19 -6
  14. package/dist/nodes/column-view.js.map +1 -1
  15. package/dist/nodes/drawing-area.d.ts +4 -1
  16. package/dist/nodes/drawing-area.d.ts.map +1 -1
  17. package/dist/nodes/drawing-area.js +8 -3
  18. package/dist/nodes/drawing-area.js.map +1 -1
  19. package/dist/nodes/drop-down.d.ts +8 -4
  20. package/dist/nodes/drop-down.d.ts.map +1 -1
  21. package/dist/nodes/drop-down.js +18 -6
  22. package/dist/nodes/drop-down.js.map +1 -1
  23. package/dist/nodes/grid-view.d.ts +8 -4
  24. package/dist/nodes/grid-view.d.ts.map +1 -1
  25. package/dist/nodes/grid-view.js +14 -3
  26. package/dist/nodes/grid-view.js.map +1 -1
  27. package/dist/nodes/internal/grid-item-renderer.d.ts +2 -1
  28. package/dist/nodes/internal/grid-item-renderer.d.ts.map +1 -1
  29. package/dist/nodes/internal/list-item-renderer.d.ts +2 -1
  30. package/dist/nodes/internal/list-item-renderer.d.ts.map +1 -1
  31. package/dist/nodes/internal/list-store.d.ts +2 -1
  32. package/dist/nodes/internal/list-store.d.ts.map +1 -1
  33. package/dist/nodes/internal/selection-model-controller.d.ts +1 -1
  34. package/dist/nodes/internal/selection-model-controller.d.ts.map +1 -1
  35. package/dist/nodes/internal/signal-store.d.ts +1 -1
  36. package/dist/nodes/internal/signal-store.d.ts.map +1 -1
  37. package/dist/nodes/internal/tree-store.d.ts +2 -1
  38. package/dist/nodes/internal/tree-store.d.ts.map +1 -1
  39. package/dist/nodes/list-view.d.ts +8 -4
  40. package/dist/nodes/list-view.d.ts.map +1 -1
  41. package/dist/nodes/list-view.js +16 -4
  42. package/dist/nodes/list-view.js.map +1 -1
  43. package/dist/nodes/navigation-view.d.ts +3 -1
  44. package/dist/nodes/navigation-view.d.ts.map +1 -1
  45. package/dist/nodes/navigation-view.js +7 -1
  46. package/dist/nodes/navigation-view.js.map +1 -1
  47. package/dist/nodes/notebook.d.ts +8 -3
  48. package/dist/nodes/notebook.d.ts.map +1 -1
  49. package/dist/nodes/notebook.js +17 -7
  50. package/dist/nodes/notebook.js.map +1 -1
  51. package/dist/nodes/popover-menu.d.ts +3 -1
  52. package/dist/nodes/popover-menu.d.ts.map +1 -1
  53. package/dist/nodes/popover-menu.js +7 -1
  54. package/dist/nodes/popover-menu.js.map +1 -1
  55. package/dist/nodes/text-view.d.ts +2 -1
  56. package/dist/nodes/text-view.d.ts.map +1 -1
  57. package/dist/nodes/text-view.js +2 -0
  58. package/dist/nodes/text-view.js.map +1 -1
  59. package/dist/nodes/window.d.ts +4 -2
  60. package/dist/nodes/window.d.ts.map +1 -1
  61. package/dist/nodes/window.js +5 -1
  62. package/dist/nodes/window.js.map +1 -1
  63. package/package.json +3 -3
  64. package/src/index.ts +1 -0
  65. package/src/jsx.ts +1 -1
  66. package/src/nodes/calendar.ts +6 -2
  67. package/src/nodes/column-view.ts +23 -7
  68. package/src/nodes/drawing-area.ts +19 -8
  69. package/src/nodes/drop-down.ts +26 -10
  70. package/src/nodes/grid-view.ts +20 -7
  71. package/src/nodes/internal/grid-item-renderer.ts +1 -1
  72. package/src/nodes/internal/list-item-renderer.ts +1 -1
  73. package/src/nodes/internal/list-store.ts +1 -1
  74. package/src/nodes/internal/selection-model-controller.ts +1 -1
  75. package/src/nodes/internal/signal-store.ts +1 -1
  76. package/src/nodes/internal/tree-store.ts +1 -1
  77. package/src/nodes/list-view.ts +24 -8
  78. package/src/nodes/navigation-view.ts +10 -2
  79. package/src/nodes/notebook.ts +24 -10
  80. package/src/nodes/popover-menu.ts +10 -2
  81. package/src/nodes/text-view.ts +3 -1
  82. package/src/nodes/window.ts +16 -3
@@ -3,22 +3,31 @@ import type { GtkColumnViewProps } from "../jsx.js";
3
3
  import type { Node } from "../node.js";
4
4
  import type { Container } from "../types.js";
5
5
  import { ColumnViewColumnNode } from "./column-view-column.js";
6
+ import { ContainerSlotNode } from "./container-slot.js";
7
+ import { EventControllerNode } from "./event-controller.js";
6
8
  import { filterProps, hasChanged } from "./internal/props.js";
7
9
  import { ListItemNode } from "./list-item.js";
8
10
  import { ListModel, type ListModelProps } from "./models/list.js";
11
+ import { SlotNode } from "./slot.js";
9
12
  import { WidgetNode } from "./widget.js";
10
13
 
11
14
  const OWN_PROPS = ["sortColumn", "sortOrder", "onSortChanged", "estimatedRowHeight"] as const;
12
15
 
13
16
  type ColumnViewProps = Pick<GtkColumnViewProps, (typeof OWN_PROPS)[number]> & ListModelProps;
14
- type ColumnViewChild = ListItemNode | ColumnViewColumnNode;
17
+ type ColumnViewChild = ListItemNode | ColumnViewColumnNode | EventControllerNode | SlotNode | ContainerSlotNode;
15
18
 
16
19
  export class ColumnViewNode extends WidgetNode<Gtk.ColumnView, ColumnViewProps, ColumnViewChild> {
17
20
  private handleSortChange: (() => void) | null = null;
18
21
  private list: ListModel;
19
22
 
20
23
  public override isValidChild(child: Node): boolean {
21
- return child instanceof ListItemNode || child instanceof ColumnViewColumnNode;
24
+ return (
25
+ child instanceof ListItemNode ||
26
+ child instanceof ColumnViewColumnNode ||
27
+ child instanceof EventControllerNode ||
28
+ child instanceof SlotNode ||
29
+ child instanceof ContainerSlotNode
30
+ );
22
31
  }
23
32
  private columnNodes = new Set<ColumnViewColumnNode>();
24
33
  private estimatedRowHeight: number | null = null;
@@ -43,6 +52,8 @@ export class ColumnViewNode extends WidgetNode<Gtk.ColumnView, ColumnViewProps,
43
52
  return;
44
53
  }
45
54
 
55
+ if (!(child instanceof ColumnViewColumnNode)) return;
56
+
46
57
  const existingColumn = this.findColumnInView(child.getColumn());
47
58
 
48
59
  if (existingColumn) {
@@ -65,6 +76,8 @@ export class ColumnViewNode extends WidgetNode<Gtk.ColumnView, ColumnViewProps,
65
76
  return;
66
77
  }
67
78
 
79
+ if (!(child instanceof ColumnViewColumnNode)) return;
80
+
68
81
  const existingColumn = this.findColumnInView(child.getColumn());
69
82
 
70
83
  if (existingColumn) {
@@ -91,14 +104,17 @@ export class ColumnViewNode extends WidgetNode<Gtk.ColumnView, ColumnViewProps,
91
104
  return;
92
105
  }
93
106
 
94
- const existingColumn = this.findColumnInView(child.getColumn());
107
+ if (child instanceof ColumnViewColumnNode) {
108
+ const existingColumn = this.findColumnInView(child.getColumn());
95
109
 
96
- if (existingColumn) {
97
- this.container.removeColumn(existingColumn);
110
+ if (existingColumn) {
111
+ this.container.removeColumn(existingColumn);
112
+ }
113
+
114
+ child.setStore(null);
115
+ this.columnNodes.delete(child);
98
116
  }
99
117
 
100
- child.setStore(null);
101
- this.columnNodes.delete(child);
102
118
  super.removeChild(child);
103
119
  }
104
120
 
@@ -1,19 +1,28 @@
1
1
  import type * as Gtk from "@gtkx/ffi/gtk";
2
2
  import type { GtkDrawingAreaProps } from "../jsx.js";
3
3
  import type { Node } from "../node.js";
4
+ import { ContainerSlotNode } from "./container-slot.js";
4
5
  import { EventControllerNode } from "./event-controller.js";
5
6
  import { filterProps, hasChanged } from "./internal/props.js";
7
+ import { SlotNode } from "./slot.js";
6
8
  import { WidgetNode } from "./widget.js";
7
9
 
8
10
  const OWN_PROPS = ["onDraw"] as const;
9
11
 
10
- type DrawFunc = (self: Gtk.DrawingArea, cr: import("@gtkx/ffi/cairo").Context, width: number, height: number) => void;
12
+ type DrawFunc = (cr: import("@gtkx/ffi/cairo").Context, width: number, height: number, self: Gtk.DrawingArea) => void;
11
13
  type DrawingAreaProps = Pick<GtkDrawingAreaProps, (typeof OWN_PROPS)[number]>;
12
- type PendingDrawFunc = { container: Gtk.DrawingArea; fn: DrawFunc };
13
14
 
14
- const pendingDrawFuncs: PendingDrawFunc[] = [];
15
+ type PendingDrawFuncEntry = { container: Gtk.DrawingArea; fn: DrawFunc };
15
16
 
16
- function ensurePendingBatch(): PendingDrawFunc[] {
17
+ const pendingDrawFuncs: PendingDrawFuncEntry[] = [];
18
+
19
+ function wrapDrawFunc(
20
+ fn: DrawFunc,
21
+ ): (self: Gtk.DrawingArea, cr: import("@gtkx/ffi/cairo").Context, width: number, height: number) => void {
22
+ return (self, cr, width, height) => fn(cr, width, height, self);
23
+ }
24
+
25
+ function ensurePendingBatch(): PendingDrawFuncEntry[] {
17
26
  if (pendingDrawFuncs.length === 0) {
18
27
  queueMicrotask(flushPendingDrawFuncs);
19
28
  }
@@ -25,13 +34,15 @@ function flushPendingDrawFuncs(): void {
25
34
  const batch = pendingDrawFuncs.splice(0);
26
35
 
27
36
  for (const { container, fn } of batch) {
28
- container.setDrawFunc(fn);
37
+ container.setDrawFunc(wrapDrawFunc(fn));
29
38
  }
30
39
  }
31
40
 
32
- export class DrawingAreaNode extends WidgetNode<Gtk.DrawingArea, DrawingAreaProps, EventControllerNode> {
41
+ type DrawingAreaChild = EventControllerNode | SlotNode | ContainerSlotNode;
42
+
43
+ export class DrawingAreaNode extends WidgetNode<Gtk.DrawingArea, DrawingAreaProps, DrawingAreaChild> {
33
44
  public override isValidChild(child: Node): boolean {
34
- return child instanceof EventControllerNode;
45
+ return child instanceof EventControllerNode || child instanceof SlotNode || child instanceof ContainerSlotNode;
35
46
  }
36
47
 
37
48
  public override commitUpdate(oldProps: DrawingAreaProps | null, newProps: DrawingAreaProps): void {
@@ -42,7 +53,7 @@ export class DrawingAreaNode extends WidgetNode<Gtk.DrawingArea, DrawingAreaProp
42
53
  private applyOwnProps(oldProps: DrawingAreaProps | null, newProps: DrawingAreaProps): void {
43
54
  if (hasChanged(oldProps, newProps, "onDraw")) {
44
55
  if (this.container.getAllocatedWidth() > 0) {
45
- this.container.setDrawFunc(newProps.onDraw);
56
+ this.container.setDrawFunc(newProps.onDraw ? wrapDrawFunc(newProps.onDraw) : null);
46
57
  } else if (newProps.onDraw) {
47
58
  ensurePendingBatch().push({ container: this.container, fn: newProps.onDraw });
48
59
  }
@@ -2,21 +2,31 @@ import type { AdwComboRowProps, GtkDropDownProps } from "../jsx.js";
2
2
  import type { Node } from "../node.js";
3
3
  import type { DropDownWidget } from "../registry.js";
4
4
  import type { Container } from "../types.js";
5
+ import { ContainerSlotNode } from "./container-slot.js";
6
+ import { EventControllerNode } from "./event-controller.js";
5
7
  import { filterProps, hasChanged } from "./internal/props.js";
6
8
  import { SimpleListStore } from "./internal/simple-list-store.js";
7
9
  import { ListItemNode } from "./list-item.js";
10
+ import { SlotNode } from "./slot.js";
8
11
  import { WidgetNode } from "./widget.js";
9
12
 
10
13
  const OWN_PROPS = ["selectedId", "onSelectionChanged"] as const;
11
14
 
12
15
  type DropDownProps = Pick<GtkDropDownProps | AdwComboRowProps, (typeof OWN_PROPS)[number]>;
13
16
 
14
- export class DropDownNode extends WidgetNode<DropDownWidget, DropDownProps, ListItemNode> {
17
+ type DropDownChild = ListItemNode | EventControllerNode | SlotNode | ContainerSlotNode;
18
+
19
+ export class DropDownNode extends WidgetNode<DropDownWidget, DropDownProps, DropDownChild> {
15
20
  private store = new SimpleListStore();
16
21
  private initialSelectedId: string | null | undefined;
17
22
 
18
23
  public override isValidChild(child: Node): boolean {
19
- return child instanceof ListItemNode;
24
+ return (
25
+ child instanceof ListItemNode ||
26
+ child instanceof EventControllerNode ||
27
+ child instanceof SlotNode ||
28
+ child instanceof ContainerSlotNode
29
+ );
20
30
  }
21
31
 
22
32
  constructor(typeName: string, props: DropDownProps, container: DropDownWidget, rootContainer: Container) {
@@ -42,20 +52,26 @@ export class DropDownNode extends WidgetNode<DropDownWidget, DropDownProps, List
42
52
  }
43
53
  }
44
54
 
45
- public override appendChild(child: ListItemNode): void {
55
+ public override appendChild(child: DropDownChild): void {
46
56
  super.appendChild(child);
47
- child.setStore(this.store);
48
- this.store.addItem(child.props.id, child.props.value as string);
57
+ if (child instanceof ListItemNode) {
58
+ child.setStore(this.store);
59
+ this.store.addItem(child.props.id, child.props.value as string);
60
+ }
49
61
  }
50
62
 
51
- public override insertBefore(child: ListItemNode, before: ListItemNode): void {
63
+ public override insertBefore(child: DropDownChild, before: DropDownChild): void {
52
64
  super.insertBefore(child, before);
53
- child.setStore(this.store);
54
- this.store.insertItemBefore(child.props.id, before.props.id, child.props.value as string);
65
+ if (child instanceof ListItemNode && before instanceof ListItemNode) {
66
+ child.setStore(this.store);
67
+ this.store.insertItemBefore(child.props.id, before.props.id, child.props.value as string);
68
+ }
55
69
  }
56
70
 
57
- public override removeChild(child: ListItemNode): void {
58
- this.store.removeItem(child.props.id);
71
+ public override removeChild(child: DropDownChild): void {
72
+ if (child instanceof ListItemNode) {
73
+ this.store.removeItem(child.props.id);
74
+ }
59
75
  super.removeChild(child);
60
76
  }
61
77
 
@@ -2,17 +2,22 @@ import type * as Gtk from "@gtkx/ffi/gtk";
2
2
  import type { GtkGridViewProps } from "../jsx.js";
3
3
  import type { Node } from "../node.js";
4
4
  import type { Container } from "../types.js";
5
+ import { ContainerSlotNode } from "./container-slot.js";
6
+ import { EventControllerNode } from "./event-controller.js";
5
7
  import { GridItemRenderer } from "./internal/grid-item-renderer.js";
6
8
  import { filterProps, hasChanged } from "./internal/props.js";
7
9
  import { ListItemNode } from "./list-item.js";
8
10
  import { GridModel, type GridModelProps } from "./models/grid.js";
11
+ import { SlotNode } from "./slot.js";
9
12
  import { WidgetNode } from "./widget.js";
10
13
 
11
14
  const OWN_PROPS = ["renderItem", "estimatedItemHeight"] as const;
12
15
 
13
16
  type GridViewProps = Pick<GtkGridViewProps, (typeof OWN_PROPS)[number]> & GridModelProps;
14
17
 
15
- export class GridViewNode extends WidgetNode<Gtk.GridView, GridViewProps, ListItemNode> {
18
+ type GridViewChild = ListItemNode | EventControllerNode | SlotNode | ContainerSlotNode;
19
+
20
+ export class GridViewNode extends WidgetNode<Gtk.GridView, GridViewProps, GridViewChild> {
16
21
  private itemRenderer: GridItemRenderer;
17
22
  private grid: GridModel;
18
23
 
@@ -33,6 +38,8 @@ export class GridViewNode extends WidgetNode<Gtk.GridView, GridViewProps, ListIt
33
38
  }
34
39
 
35
40
  public override isValidChild(child: Node): boolean {
41
+ if (child instanceof EventControllerNode || child instanceof SlotNode || child instanceof ContainerSlotNode)
42
+ return true;
36
43
  if (!(child instanceof ListItemNode)) return false;
37
44
  if (child.getChildNodes().length > 0) {
38
45
  throw new Error("GtkGridView does not support nested ListItems. Use GtkListView for tree lists.");
@@ -40,18 +47,24 @@ export class GridViewNode extends WidgetNode<Gtk.GridView, GridViewProps, ListIt
40
47
  return true;
41
48
  }
42
49
 
43
- public override appendChild(child: ListItemNode): void {
50
+ public override appendChild(child: GridViewChild): void {
44
51
  super.appendChild(child);
45
- this.grid.appendChild(child);
52
+ if (child instanceof ListItemNode) {
53
+ this.grid.appendChild(child);
54
+ }
46
55
  }
47
56
 
48
- public override insertBefore(child: ListItemNode, before: ListItemNode): void {
57
+ public override insertBefore(child: GridViewChild, before: GridViewChild): void {
49
58
  super.insertBefore(child, before);
50
- this.grid.insertBefore(child, before);
59
+ if (child instanceof ListItemNode && before instanceof ListItemNode) {
60
+ this.grid.insertBefore(child, before);
61
+ }
51
62
  }
52
63
 
53
- public override removeChild(child: ListItemNode): void {
54
- this.grid.removeChild(child);
64
+ public override removeChild(child: GridViewChild): void {
65
+ if (child instanceof ListItemNode) {
66
+ this.grid.removeChild(child);
67
+ }
55
68
  super.removeChild(child);
56
69
  }
57
70
 
@@ -5,7 +5,7 @@ import { reconciler } from "../../reconciler.js";
5
5
  import { BaseItemRenderer } from "./base-item-renderer.js";
6
6
  import type { ListStore } from "./list-store.js";
7
7
 
8
- export type GridRenderItemFn<T> = (item: T | null) => ReactNode;
8
+ type GridRenderItemFn<T> = (item: T | null) => ReactNode;
9
9
 
10
10
  export class GridItemRenderer extends BaseItemRenderer<ListStore> {
11
11
  private renderFn: GridRenderItemFn<unknown> | null = () => null;
@@ -5,7 +5,7 @@ import { reconciler } from "../../reconciler.js";
5
5
  import { BaseItemRenderer } from "./base-item-renderer.js";
6
6
  import type { TreeStore } from "./tree-store.js";
7
7
 
8
- export type RenderItemFn<T> = (item: T | null, row: Gtk.TreeListRow | null) => ReactNode;
8
+ type RenderItemFn<T> = (item: T | null, row: Gtk.TreeListRow | null) => ReactNode;
9
9
 
10
10
  type PendingBind = {
11
11
  treeListRow: Gtk.TreeListRow;
@@ -1,6 +1,6 @@
1
1
  import * as Gtk from "@gtkx/ffi/gtk";
2
2
 
3
- export type ItemUpdatedCallback = (id: string) => void;
3
+ type ItemUpdatedCallback = (id: string) => void;
4
4
 
5
5
  export class ListStore {
6
6
  private model = new Gtk.StringList();
@@ -5,7 +5,7 @@ import type { SignalStore } from "./signal-store.js";
5
5
 
6
6
  type SelectionModel = Gtk.NoSelection | Gtk.SingleSelection | Gtk.MultiSelection;
7
7
 
8
- export type SelectionModelConfig = Pick<GtkListViewProps, "selectionMode" | "selected" | "onSelectionChanged"> & {
8
+ type SelectionModelConfig = Pick<GtkListViewProps, "selectionMode" | "selected" | "onSelectionChanged"> & {
9
9
  owner: object;
10
10
  signalStore: SignalStore;
11
11
  };
@@ -25,7 +25,7 @@ type HandlerEntry = { obj: GObject.Object; handlerId: number };
25
25
 
26
26
  type SignalKey = `${string}:${string}`;
27
27
 
28
- export interface SignalOptions {
28
+ interface SignalOptions {
29
29
  blockable?: boolean;
30
30
  }
31
31
 
@@ -1,6 +1,6 @@
1
1
  import * as Gtk from "@gtkx/ffi/gtk";
2
2
 
3
- export type TreeItemUpdatedCallback = (id: string) => void;
3
+ type TreeItemUpdatedCallback = (id: string) => void;
4
4
 
5
5
  export type TreeItemData<T = unknown> = {
6
6
  value: T;
@@ -2,10 +2,13 @@ import type * as Gtk from "@gtkx/ffi/gtk";
2
2
  import type { GtkListViewProps } from "../jsx.js";
3
3
  import type { Node } from "../node.js";
4
4
  import type { Container } from "../types.js";
5
+ import { ContainerSlotNode } from "./container-slot.js";
6
+ import { EventControllerNode } from "./event-controller.js";
5
7
  import { ListItemRenderer } from "./internal/list-item-renderer.js";
6
8
  import { filterProps, hasChanged } from "./internal/props.js";
7
9
  import { ListItemNode } from "./list-item.js";
8
10
  import { ListModel, type ListModelProps } from "./models/list.js";
11
+ import { SlotNode } from "./slot.js";
9
12
  import { WidgetNode } from "./widget.js";
10
13
 
11
14
  const RENDERER_PROPS = ["renderItem", "estimatedItemHeight"] as const;
@@ -13,12 +16,19 @@ const OWN_PROPS = [...RENDERER_PROPS, "autoexpand", "selectionMode", "selected",
13
16
 
14
17
  type ListViewProps = Pick<GtkListViewProps, (typeof RENDERER_PROPS)[number]> & ListModelProps;
15
18
 
16
- export class ListViewNode extends WidgetNode<Gtk.ListView, ListViewProps, ListItemNode> {
19
+ type ListViewChild = ListItemNode | EventControllerNode | SlotNode | ContainerSlotNode;
20
+
21
+ export class ListViewNode extends WidgetNode<Gtk.ListView, ListViewProps, ListViewChild> {
17
22
  private itemRenderer: ListItemRenderer;
18
23
  private list: ListModel;
19
24
 
20
25
  public override isValidChild(child: Node): boolean {
21
- return child instanceof ListItemNode;
26
+ return (
27
+ child instanceof ListItemNode ||
28
+ child instanceof EventControllerNode ||
29
+ child instanceof SlotNode ||
30
+ child instanceof ContainerSlotNode
31
+ );
22
32
  }
23
33
 
24
34
  constructor(typeName: string, props: ListViewProps, container: Gtk.ListView, rootContainer: Container) {
@@ -38,18 +48,24 @@ export class ListViewNode extends WidgetNode<Gtk.ListView, ListViewProps, ListIt
38
48
  this.container.setFactory(this.itemRenderer.getFactory());
39
49
  }
40
50
 
41
- public override appendChild(child: ListItemNode): void {
51
+ public override appendChild(child: ListViewChild): void {
42
52
  super.appendChild(child);
43
- this.list.appendChild(child);
53
+ if (child instanceof ListItemNode) {
54
+ this.list.appendChild(child);
55
+ }
44
56
  }
45
57
 
46
- public override insertBefore(child: ListItemNode, before: ListItemNode): void {
58
+ public override insertBefore(child: ListViewChild, before: ListViewChild): void {
47
59
  super.insertBefore(child, before);
48
- this.list.insertBefore(child, before);
60
+ if (child instanceof ListItemNode && before instanceof ListItemNode) {
61
+ this.list.insertBefore(child, before);
62
+ }
49
63
  }
50
64
 
51
- public override removeChild(child: ListItemNode): void {
52
- this.list.removeChild(child);
65
+ public override removeChild(child: ListViewChild): void {
66
+ if (child instanceof ListItemNode) {
67
+ this.list.removeChild(child);
68
+ }
53
69
  super.removeChild(child);
54
70
  }
55
71
 
@@ -1,6 +1,8 @@
1
1
  import * as Adw from "@gtkx/ffi/adw";
2
2
  import type { AdwNavigationViewProps } from "../jsx.js";
3
3
  import type { Node } from "../node.js";
4
+ import { ContainerSlotNode } from "./container-slot.js";
5
+ import { EventControllerNode } from "./event-controller.js";
4
6
  import { filterProps, hasChanged, primitiveArrayEqual } from "./internal/props.js";
5
7
  import { NavigationPageNode } from "./navigation-page.js";
6
8
  import { SlotNode } from "./slot.js";
@@ -9,11 +11,17 @@ import { WidgetNode } from "./widget.js";
9
11
  const OWN_PROPS = ["history", "onHistoryChanged"] as const;
10
12
 
11
13
  type NavigationViewProps = Pick<AdwNavigationViewProps, (typeof OWN_PROPS)[number]>;
12
- type NavigationViewChild = NavigationPageNode | SlotNode | WidgetNode;
14
+ type NavigationViewChild = NavigationPageNode | SlotNode | ContainerSlotNode | EventControllerNode | WidgetNode;
13
15
 
14
16
  export class NavigationViewNode extends WidgetNode<Adw.NavigationView, NavigationViewProps, NavigationViewChild> {
15
17
  public override isValidChild(child: Node): boolean {
16
- return child instanceof NavigationPageNode || child instanceof SlotNode || child instanceof WidgetNode;
18
+ return (
19
+ child instanceof NavigationPageNode ||
20
+ child instanceof SlotNode ||
21
+ child instanceof EventControllerNode ||
22
+ child instanceof ContainerSlotNode ||
23
+ child instanceof WidgetNode
24
+ );
17
25
  }
18
26
 
19
27
  public override commitUpdate(oldProps: NavigationViewProps | null, newProps: NavigationViewProps): void {
@@ -1,28 +1,42 @@
1
1
  import type * as Gtk from "@gtkx/ffi/gtk";
2
2
  import type { Node } from "../node.js";
3
3
  import type { Props } from "../types.js";
4
+ import { ContainerSlotNode } from "./container-slot.js";
5
+ import { EventControllerNode } from "./event-controller.js";
4
6
  import { NotebookPageNode } from "./notebook-page.js";
7
+ import { SlotNode } from "./slot.js";
5
8
  import { WidgetNode } from "./widget.js";
6
9
 
7
- export class NotebookNode extends WidgetNode<Gtk.Notebook, Props, NotebookPageNode> {
10
+ type NotebookChild = NotebookPageNode | EventControllerNode | SlotNode | ContainerSlotNode;
11
+
12
+ export class NotebookNode extends WidgetNode<Gtk.Notebook, Props, NotebookChild> {
8
13
  public override isValidChild(child: Node): boolean {
9
- return child instanceof NotebookPageNode;
14
+ return (
15
+ child instanceof NotebookPageNode ||
16
+ child instanceof EventControllerNode ||
17
+ child instanceof SlotNode ||
18
+ child instanceof ContainerSlotNode
19
+ );
10
20
  }
11
21
 
12
- public override insertBefore(child: NotebookPageNode, before: NotebookPageNode): void {
13
- const isMove = this.children.includes(child);
14
- const beforePosition = this.container.pageNum(before.getChildWidget());
15
- child.setPosition(beforePosition);
22
+ public override insertBefore(child: NotebookChild, before: NotebookChild): void {
23
+ if (child instanceof NotebookPageNode && before instanceof NotebookPageNode) {
24
+ const isMove = this.children.includes(child);
25
+ const beforePosition = this.container.pageNum(before.getChildWidget());
26
+ child.setPosition(beforePosition);
16
27
 
17
- if (isMove) {
18
- this.container.reorderChild(child.getChildWidget(), beforePosition);
28
+ if (isMove) {
29
+ this.container.reorderChild(child.getChildWidget(), beforePosition);
30
+ }
19
31
  }
20
32
 
21
33
  super.insertBefore(child, before);
22
34
  }
23
35
 
24
- public override removeChild(child: NotebookPageNode): void {
25
- child.setPosition(null);
36
+ public override removeChild(child: NotebookChild): void {
37
+ if (child instanceof NotebookPageNode) {
38
+ child.setPosition(null);
39
+ }
26
40
  super.removeChild(child);
27
41
  }
28
42
  }
@@ -3,18 +3,26 @@ import * as Gtk from "@gtkx/ffi/gtk";
3
3
  import type { Node } from "../node.js";
4
4
  import type { PopoverMenuWidget } from "../registry.js";
5
5
  import type { Container, Props } from "../types.js";
6
+ import { ContainerSlotNode } from "./container-slot.js";
7
+ import { EventControllerNode } from "./event-controller.js";
6
8
  import { MenuNode } from "./menu.js";
7
9
  import { MenuModel } from "./models/menu.js";
8
10
  import { SlotNode } from "./slot.js";
9
11
  import { WidgetNode } from "./widget.js";
10
12
 
11
- type PopoverMenuChild = MenuNode | SlotNode | WidgetNode;
13
+ type PopoverMenuChild = MenuNode | SlotNode | ContainerSlotNode | EventControllerNode | WidgetNode;
12
14
 
13
15
  export class PopoverMenuNode extends WidgetNode<PopoverMenuWidget, Props, PopoverMenuChild> {
14
16
  private menu: MenuModel;
15
17
 
16
18
  public override isValidChild(child: Node): boolean {
17
- return child instanceof MenuNode || child instanceof SlotNode || child instanceof WidgetNode;
19
+ return (
20
+ child instanceof MenuNode ||
21
+ child instanceof SlotNode ||
22
+ child instanceof EventControllerNode ||
23
+ child instanceof ContainerSlotNode ||
24
+ child instanceof WidgetNode
25
+ );
18
26
  }
19
27
 
20
28
  constructor(typeName: string, props: Props, container: PopoverMenuWidget, rootContainer: Container) {
@@ -1,6 +1,7 @@
1
1
  import * as Gtk from "@gtkx/ffi/gtk";
2
2
  import type { GtkTextViewProps } from "../jsx.js";
3
3
  import type { Node } from "../node.js";
4
+ import { ContainerSlotNode } from "./container-slot.js";
4
5
  import { EventControllerNode } from "./event-controller.js";
5
6
  import { filterProps } from "./internal/props.js";
6
7
  import { TextBufferController } from "./internal/text-buffer-controller.js";
@@ -22,7 +23,7 @@ const OWN_PROPS = [
22
23
  ] as const;
23
24
 
24
25
  type TextViewProps = Pick<GtkTextViewProps, (typeof OWN_PROPS)[number]>;
25
- type TextViewChild = TextContentChild | SlotNode | EventControllerNode | WidgetNode;
26
+ type TextViewChild = TextContentChild | SlotNode | ContainerSlotNode | EventControllerNode | WidgetNode;
26
27
 
27
28
  export class TextViewNode extends WidgetNode<Gtk.TextView, TextViewProps, TextViewChild> implements TextContentParent {
28
29
  protected bufferController: TextBufferController | null = null;
@@ -34,6 +35,7 @@ export class TextViewNode extends WidgetNode<Gtk.TextView, TextViewProps, TextVi
34
35
  child instanceof TextAnchorNode ||
35
36
  child instanceof TextPaintableNode ||
36
37
  child instanceof SlotNode ||
38
+ child instanceof ContainerSlotNode ||
37
39
  child instanceof EventControllerNode ||
38
40
  child instanceof WidgetNode
39
41
  );
@@ -4,7 +4,9 @@ import type { GtkAboutDialogProps, GtkWindowProps } from "../jsx.js";
4
4
  import type { Node } from "../node.js";
5
5
  import type { Container, Props } from "../types.js";
6
6
  import { AnimationNode } from "./animation.js";
7
+ import { ContainerSlotNode } from "./container-slot.js";
7
8
  import type { DialogNode } from "./dialog.js";
9
+ import { EventControllerNode } from "./event-controller.js";
8
10
  import { filterProps, hasChanged } from "./internal/props.js";
9
11
  import { MenuNode } from "./menu.js";
10
12
  import { MenuModel } from "./models/menu.js";
@@ -18,9 +20,18 @@ const isOrExtendsClass = (target: object, cls: abstract new (...args: any[]) =>
18
20
 
19
21
  const OWN_PROPS = ["onClose"] as const;
20
22
 
21
- export type WindowProps = Pick<GtkWindowProps, "onClose"> & Pick<GtkAboutDialogProps, "creditSections">;
23
+ type WindowProps = Pick<GtkWindowProps, "onClose"> & Pick<GtkAboutDialogProps, "creditSections">;
22
24
 
23
- type WindowChild = WindowNode | DialogNode | MenuNode | SlotNode | AnimationNode | NavigationPageNode | WidgetNode;
25
+ type WindowChild =
26
+ | WindowNode
27
+ | DialogNode
28
+ | MenuNode
29
+ | SlotNode
30
+ | ContainerSlotNode
31
+ | AnimationNode
32
+ | NavigationPageNode
33
+ | EventControllerNode
34
+ | WidgetNode;
24
35
 
25
36
  export class WindowNode extends WidgetNode<Gtk.Window, WindowProps, WindowChild> {
26
37
  private menu: MenuModel;
@@ -73,7 +84,9 @@ export class WindowNode extends WidgetNode<Gtk.Window, WindowProps, WindowChild>
73
84
  child instanceof MenuNode ||
74
85
  child instanceof SlotNode ||
75
86
  child instanceof AnimationNode ||
76
- child instanceof NavigationPageNode
87
+ child instanceof NavigationPageNode ||
88
+ child instanceof EventControllerNode ||
89
+ child instanceof ContainerSlotNode
77
90
  );
78
91
  }
79
92