@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.
Files changed (182) hide show
  1. package/README.md +55 -67
  2. package/dist/errors.d.ts +3 -3
  3. package/dist/errors.js +8 -8
  4. package/dist/factory.d.ts +3 -5
  5. package/dist/factory.js +18 -71
  6. package/dist/fiber-root.d.ts +1 -1
  7. package/dist/fiber-root.js +1 -2
  8. package/dist/generated/internal.d.ts +3 -6
  9. package/dist/generated/internal.js +10386 -13577
  10. package/dist/generated/jsx.d.ts +914 -808
  11. package/dist/generated/jsx.js +123 -358
  12. package/dist/generated/registry.d.ts +4 -0
  13. package/dist/generated/registry.js +13 -0
  14. package/dist/host-config.d.ts +7 -4
  15. package/dist/host-config.js +53 -18
  16. package/dist/index.d.ts +2 -22
  17. package/dist/index.js +2 -40
  18. package/dist/jsx.d.ts +719 -0
  19. package/dist/jsx.js +392 -0
  20. package/dist/node.d.ts +15 -32
  21. package/dist/node.js +20 -240
  22. package/dist/nodes/action-row-child.d.ts +21 -0
  23. package/dist/nodes/action-row-child.js +69 -0
  24. package/dist/nodes/action-row.js +33 -0
  25. package/dist/nodes/application.d.ts +1 -0
  26. package/dist/nodes/application.js +38 -0
  27. package/dist/nodes/autowrapped.d.ts +1 -0
  28. package/dist/nodes/autowrapped.js +109 -0
  29. package/dist/nodes/column-view-column.d.ts +16 -0
  30. package/dist/nodes/column-view-column.js +54 -0
  31. package/dist/nodes/column-view.d.ts +0 -59
  32. package/dist/nodes/column-view.js +107 -226
  33. package/dist/nodes/fixed-child.d.ts +1 -0
  34. package/dist/nodes/fixed-child.js +45 -0
  35. package/dist/nodes/grid-child.d.ts +1 -0
  36. package/dist/nodes/grid-child.js +54 -0
  37. package/dist/nodes/index.d.ts +34 -0
  38. package/dist/nodes/index.js +34 -0
  39. package/dist/nodes/internal/list-item-renderer.d.ts +18 -0
  40. package/dist/nodes/internal/list-item-renderer.js +67 -0
  41. package/dist/nodes/internal/list-store.d.ts +16 -0
  42. package/dist/nodes/internal/list-store.js +69 -0
  43. package/dist/nodes/internal/predicates.d.ts +26 -0
  44. package/dist/nodes/internal/predicates.js +36 -0
  45. package/dist/nodes/internal/signal-store.d.ts +9 -0
  46. package/dist/nodes/internal/signal-store.js +54 -0
  47. package/dist/nodes/internal/simple-list-store.d.ts +14 -0
  48. package/dist/nodes/internal/simple-list-store.js +60 -0
  49. package/dist/nodes/internal/tree-list-item-renderer.d.ts +18 -0
  50. package/dist/nodes/internal/tree-list-item-renderer.js +90 -0
  51. package/dist/nodes/internal/tree-store.d.ts +28 -0
  52. package/dist/nodes/internal/tree-store.js +153 -0
  53. package/dist/nodes/internal/utils.d.ts +3 -0
  54. package/dist/nodes/internal/utils.js +20 -0
  55. package/dist/nodes/list-item.d.ts +12 -0
  56. package/dist/nodes/list-item.js +24 -0
  57. package/dist/nodes/list-view.d.ts +0 -22
  58. package/dist/nodes/list-view.js +45 -38
  59. package/dist/nodes/menu.d.ts +6 -106
  60. package/dist/nodes/menu.js +16 -268
  61. package/dist/nodes/models/list.d.ts +24 -0
  62. package/dist/nodes/models/list.js +102 -0
  63. package/dist/nodes/models/menu.d.ts +45 -0
  64. package/dist/nodes/models/menu.js +265 -0
  65. package/dist/nodes/models/tree-list.d.ts +28 -0
  66. package/dist/nodes/models/tree-list.js +141 -0
  67. package/dist/nodes/navigation-page.d.ts +21 -0
  68. package/dist/nodes/navigation-page.js +95 -0
  69. package/dist/nodes/navigation-view.d.ts +1 -0
  70. package/dist/nodes/navigation-view.js +29 -0
  71. package/dist/nodes/notebook-page-tab.d.ts +15 -0
  72. package/dist/nodes/notebook-page-tab.js +42 -0
  73. package/dist/nodes/notebook-page.d.ts +23 -0
  74. package/dist/nodes/notebook-page.js +106 -0
  75. package/dist/nodes/notebook.d.ts +0 -32
  76. package/dist/nodes/notebook.js +20 -113
  77. package/dist/nodes/overlay-child.d.ts +1 -0
  78. package/dist/nodes/overlay-child.js +30 -0
  79. package/dist/nodes/pack-child.d.ts +21 -0
  80. package/dist/nodes/pack-child.js +68 -0
  81. package/dist/nodes/pack.d.ts +1 -0
  82. package/dist/nodes/pack.js +33 -0
  83. package/dist/nodes/popover-menu.d.ts +1 -0
  84. package/dist/nodes/popover-menu.js +58 -0
  85. package/dist/nodes/simple-list-item.d.ts +9 -0
  86. package/dist/nodes/simple-list-item.js +9 -0
  87. package/dist/nodes/simple-list-view.d.ts +1 -0
  88. package/dist/nodes/simple-list-view.js +75 -0
  89. package/dist/nodes/slot.d.ts +18 -10
  90. package/dist/nodes/slot.js +83 -51
  91. package/dist/nodes/stack-page.d.ts +1 -0
  92. package/dist/nodes/stack-page.js +80 -0
  93. package/dist/nodes/stack.d.ts +1 -22
  94. package/dist/nodes/stack.js +21 -60
  95. package/dist/nodes/toast-overlay.d.ts +1 -0
  96. package/dist/nodes/toast-overlay.js +35 -0
  97. package/dist/nodes/toast.d.ts +17 -0
  98. package/dist/nodes/toast.js +77 -0
  99. package/dist/nodes/toolbar-child.d.ts +9 -0
  100. package/dist/nodes/toolbar-child.js +33 -0
  101. package/dist/nodes/toolbar.d.ts +1 -0
  102. package/dist/nodes/toolbar.js +42 -0
  103. package/dist/nodes/tree-list-item.d.ts +20 -0
  104. package/dist/nodes/tree-list-item.js +102 -0
  105. package/dist/nodes/tree-list-view.d.ts +1 -0
  106. package/dist/nodes/tree-list-view.js +57 -0
  107. package/dist/nodes/virtual.d.ts +13 -0
  108. package/dist/nodes/virtual.js +21 -0
  109. package/dist/nodes/widget.d.ts +17 -3
  110. package/dist/nodes/widget.js +258 -2
  111. package/dist/nodes/window.d.ts +1 -12
  112. package/dist/nodes/window.js +66 -27
  113. package/dist/portal.d.ts +18 -13
  114. package/dist/portal.js +17 -14
  115. package/dist/reconciler.d.ts +0 -4
  116. package/dist/reconciler.js +1 -9
  117. package/dist/registry.d.ts +8 -0
  118. package/dist/registry.js +5 -0
  119. package/dist/render.d.ts +108 -12
  120. package/dist/render.js +140 -16
  121. package/dist/scheduler.d.ts +4 -0
  122. package/dist/scheduler.js +10 -0
  123. package/dist/types.d.ts +3 -136
  124. package/package.json +6 -6
  125. package/dist/batch.d.ts +0 -5
  126. package/dist/batch.js +0 -31
  127. package/dist/codegen/jsx-generator.d.ts +0 -56
  128. package/dist/codegen/jsx-generator.js +0 -959
  129. package/dist/containers.d.ts +0 -58
  130. package/dist/nodes/about-dialog.d.ts +0 -8
  131. package/dist/nodes/about-dialog.js +0 -16
  132. package/dist/nodes/action-bar.d.ts +0 -5
  133. package/dist/nodes/action-bar.js +0 -6
  134. package/dist/nodes/combo-row.d.ts +0 -5
  135. package/dist/nodes/combo-row.js +0 -6
  136. package/dist/nodes/drop-down.d.ts +0 -9
  137. package/dist/nodes/drop-down.js +0 -12
  138. package/dist/nodes/flow-box.d.ts +0 -10
  139. package/dist/nodes/flow-box.js +0 -41
  140. package/dist/nodes/grid.d.ts +0 -30
  141. package/dist/nodes/grid.js +0 -84
  142. package/dist/nodes/header-bar.d.ts +0 -43
  143. package/dist/nodes/header-bar.js +0 -116
  144. package/dist/nodes/indexed-child-container.d.ts +0 -16
  145. package/dist/nodes/indexed-child-container.js +0 -22
  146. package/dist/nodes/list-box.d.ts +0 -10
  147. package/dist/nodes/list-box.js +0 -48
  148. package/dist/nodes/list-item-factory.d.ts +0 -19
  149. package/dist/nodes/list-item-factory.js +0 -58
  150. package/dist/nodes/overlay.d.ts +0 -11
  151. package/dist/nodes/overlay.js +0 -50
  152. package/dist/nodes/paged-stack.d.ts +0 -31
  153. package/dist/nodes/paged-stack.js +0 -95
  154. package/dist/nodes/root.d.ts +0 -8
  155. package/dist/nodes/root.js +0 -13
  156. package/dist/nodes/selectable-list.d.ts +0 -45
  157. package/dist/nodes/selectable-list.js +0 -260
  158. package/dist/nodes/stack-page-props.d.ts +0 -11
  159. package/dist/nodes/stack-page-props.js +0 -23
  160. package/dist/nodes/string-list-container.d.ts +0 -34
  161. package/dist/nodes/string-list-container.js +0 -118
  162. package/dist/nodes/string-list-item.d.ts +0 -19
  163. package/dist/nodes/string-list-item.js +0 -50
  164. package/dist/nodes/string-list-store.d.ts +0 -13
  165. package/dist/nodes/string-list-store.js +0 -44
  166. package/dist/nodes/text-view.d.ts +0 -8
  167. package/dist/nodes/text-view.js +0 -16
  168. package/dist/nodes/toggle-button.d.ts +0 -14
  169. package/dist/nodes/toggle-button.js +0 -39
  170. package/dist/nodes/toolbar-view.d.ts +0 -14
  171. package/dist/nodes/toolbar-view.js +0 -78
  172. package/dist/nodes/view-stack.d.ts +0 -9
  173. package/dist/nodes/view-stack.js +0 -28
  174. package/dist/nodes/virtual-item.d.ts +0 -19
  175. package/dist/nodes/virtual-item.js +0 -48
  176. package/dist/nodes/virtual-slot.d.ts +0 -25
  177. package/dist/nodes/virtual-slot.js +0 -57
  178. package/dist/predicates.d.ts +0 -29
  179. package/dist/predicates.js +0 -37
  180. package/dist/props.d.ts +0 -7
  181. package/dist/props.js +0 -12
  182. /package/dist/{containers.js → nodes/action-row.d.ts} +0 -0
@@ -1,58 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- export type ChildContainer = {
3
- attachChild(child: Gtk.Widget): void;
4
- insertChildBefore(child: Gtk.Widget, before: Gtk.Widget): void;
5
- detachChild(child: Gtk.Widget): void;
6
- };
7
- export type PageContainer = {
8
- addPage(child: Gtk.Widget, label: string): void;
9
- insertPageBefore(child: Gtk.Widget, label: string, beforeChild: Gtk.Widget): void;
10
- removePage(child: Gtk.Widget): void;
11
- updatePageLabel(child: Gtk.Widget, label: string): void;
12
- };
13
- export type StackPageProps = {
14
- name?: string;
15
- title?: string;
16
- iconName?: string;
17
- needsAttention?: boolean;
18
- visible?: boolean;
19
- useUnderline?: boolean;
20
- badgeNumber?: number;
21
- };
22
- export type StackPageContainer = {
23
- addStackPage(child: Gtk.Widget, props: StackPageProps): void;
24
- insertStackPageBefore(child: Gtk.Widget, props: StackPageProps, beforeChild: Gtk.Widget): void;
25
- removeStackPage(child: Gtk.Widget): void;
26
- updateStackPageProps(child: Gtk.Widget, props: StackPageProps): void;
27
- };
28
- export type GridContainer = {
29
- attachToGrid(child: Gtk.Widget, column: number, row: number, colSpan: number, rowSpan: number): void;
30
- removeFromGrid(child: Gtk.Widget): void;
31
- };
32
- export type ItemContainer<T> = {
33
- addItem(id: string, item: T): void;
34
- insertItemBefore(id: string, item: T, beforeId: string): void;
35
- removeItem(id: string): void;
36
- updateItem(id: string, item: T): void;
37
- };
38
- export type ColumnContainer = {
39
- addColumn(column: unknown): void;
40
- insertColumnBefore(column: unknown, beforeColumn: unknown): void;
41
- removeColumn(column: unknown): void;
42
- getItems(): unknown[];
43
- };
44
- export type PackContainer = {
45
- packStart(child: Gtk.Widget): void;
46
- packEnd(child: Gtk.Widget): void;
47
- removeFromPack(child: Gtk.Widget): void;
48
- };
49
- export type StringListItem = {
50
- id: string;
51
- label: string;
52
- };
53
- export type StringListContainer = {
54
- addStringListItem(id: string, label: string): void;
55
- insertStringListItemBefore(id: string, label: string, beforeId: string): void;
56
- removeStringListItem(id: string): void;
57
- updateStringListItem(oldId: string, newId: string, newLabel: string): void;
58
- };
@@ -1,8 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import { Node } from "../node.js";
3
- export declare class AboutDialogNode extends Node<Gtk.AboutDialog> {
4
- static matches(type: string): boolean;
5
- protected isStandalone(): boolean;
6
- mount(): void;
7
- unmount(): void;
8
- }
@@ -1,16 +0,0 @@
1
- import { Node } from "../node.js";
2
- export class AboutDialogNode extends Node {
3
- static matches(type) {
4
- return type === "AboutDialog";
5
- }
6
- isStandalone() {
7
- return true;
8
- }
9
- mount() {
10
- this.widget.present();
11
- }
12
- unmount() {
13
- this.widget.destroy();
14
- super.unmount();
15
- }
16
- }
@@ -1,5 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import { PackContainerNode } from "./header-bar.js";
3
- export declare class ActionBarNode extends PackContainerNode<Gtk.ActionBar> {
4
- static matches(type: string): boolean;
5
- }
@@ -1,6 +0,0 @@
1
- import { PackContainerNode } from "./header-bar.js";
2
- export class ActionBarNode extends PackContainerNode {
3
- static matches(type) {
4
- return type === "ActionBar" || type === "ActionBar.Root";
5
- }
6
- }
@@ -1,5 +0,0 @@
1
- import type * as Adw from "@gtkx/ffi/adw";
2
- import { StringListContainerNode } from "./string-list-container.js";
3
- export declare class ComboRowNode extends StringListContainerNode<Adw.ComboRow> {
4
- static matches(type: string): boolean;
5
- }
@@ -1,6 +0,0 @@
1
- import { StringListContainerNode } from "./string-list-container.js";
2
- export class ComboRowNode extends StringListContainerNode {
3
- static matches(type) {
4
- return type === "AdwComboRow.Root";
5
- }
6
- }
@@ -1,9 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import { StringListContainerNode } from "./string-list-container.js";
3
- import { StringListItemNode } from "./string-list-item.js";
4
- export declare class DropDownNode extends StringListContainerNode<Gtk.DropDown> {
5
- static matches(type: string): boolean;
6
- }
7
- export declare class DropDownItemNode extends StringListItemNode {
8
- static matches(type: string): boolean;
9
- }
@@ -1,12 +0,0 @@
1
- import { StringListContainerNode } from "./string-list-container.js";
2
- import { StringListItemNode } from "./string-list-item.js";
3
- export class DropDownNode extends StringListContainerNode {
4
- static matches(type) {
5
- return type === "DropDown.Root";
6
- }
7
- }
8
- export class DropDownItemNode extends StringListItemNode {
9
- static matches(type) {
10
- return type === "DropDown.Item" || type === "AdwComboRow.Item";
11
- }
12
- }
@@ -1,10 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import { IndexedChildContainerNode } from "./indexed-child-container.js";
3
- export declare class FlowBoxNode extends IndexedChildContainerNode<Gtk.FlowBox> {
4
- static matches(type: string): boolean;
5
- protected getInsertionIndex(before: Gtk.Widget): number;
6
- private unparentFromChild;
7
- attachChild(child: Gtk.Widget): void;
8
- insertChildBefore(child: Gtk.Widget, before: Gtk.Widget): void;
9
- detachChild(child: Gtk.Widget): void;
10
- }
@@ -1,41 +0,0 @@
1
- import { beginBatch, endBatch } from "@gtkx/ffi";
2
- import { isFlowBoxChild } from "../predicates.js";
3
- import { IndexedChildContainerNode } from "./indexed-child-container.js";
4
- export class FlowBoxNode extends IndexedChildContainerNode {
5
- static matches(type) {
6
- return type === "FlowBox";
7
- }
8
- getInsertionIndex(before) {
9
- const beforeParent = before.getParent();
10
- if (beforeParent && isFlowBoxChild(beforeParent)) {
11
- return beforeParent.getIndex();
12
- }
13
- return -1;
14
- }
15
- unparentFromChild(child) {
16
- const parent = child.getParent();
17
- if (parent && isFlowBoxChild(parent)) {
18
- beginBatch();
19
- parent.setChild(undefined);
20
- this.widget.remove(parent);
21
- endBatch();
22
- }
23
- }
24
- attachChild(child) {
25
- this.unparentFromChild(child);
26
- this.widget.append(child);
27
- }
28
- insertChildBefore(child, before) {
29
- this.unparentFromChild(child);
30
- const index = this.getInsertionIndex(before);
31
- if (index >= 0) {
32
- this.widget.insert(child, index);
33
- }
34
- else {
35
- this.widget.append(child);
36
- }
37
- }
38
- detachChild(child) {
39
- this.unparentFromChild(child);
40
- }
41
- }
@@ -1,30 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import type { GridContainer } from "../containers.js";
3
- import type { Props } from "../factory.js";
4
- import { Node } from "../node.js";
5
- import { VirtualSlotNode } from "./virtual-slot.js";
6
- export declare class GridNode extends Node<Gtk.Grid> implements GridContainer {
7
- static matches(type: string): boolean;
8
- attachToGrid(child: Gtk.Widget, column: number, row: number, colSpan: number, rowSpan: number): void;
9
- removeFromGrid(child: Gtk.Widget): void;
10
- appendChild(child: Node): void;
11
- insertBefore(child: Node, before: Node): void;
12
- removeChild(child: Node): void;
13
- }
14
- type GridChildProps = {
15
- column: number;
16
- row: number;
17
- columnSpan: number;
18
- rowSpan: number;
19
- };
20
- export declare class GridChildNode extends VirtualSlotNode<GridContainer, GridChildProps> {
21
- static matches(type: string): boolean;
22
- protected isValidContainer(parent: Node): parent is Node & GridContainer;
23
- protected extractSlotProps(props: Props): GridChildProps;
24
- protected addToContainer(container: GridContainer, child: Gtk.Widget, props: GridChildProps): void;
25
- protected insertBeforeInContainer(container: GridContainer, child: Gtk.Widget, props: GridChildProps, _before: Gtk.Widget): void;
26
- protected removeFromContainer(container: GridContainer, child: Gtk.Widget): void;
27
- protected updateInContainer(container: GridContainer, child: Gtk.Widget, props: GridChildProps): void;
28
- updateProps(oldProps: Props, newProps: Props): void;
29
- }
30
- export {};
@@ -1,84 +0,0 @@
1
- import { Node } from "../node.js";
2
- import { isGridContainer } from "../predicates.js";
3
- import { VirtualSlotNode } from "./virtual-slot.js";
4
- export class GridNode extends Node {
5
- static matches(type) {
6
- return type === "Grid.Root";
7
- }
8
- attachToGrid(child, column, row, colSpan, rowSpan) {
9
- this.widget.attach(child, column, row, colSpan, rowSpan);
10
- }
11
- removeFromGrid(child) {
12
- this.widget.remove(child);
13
- }
14
- appendChild(child) {
15
- if (child instanceof GridChildNode) {
16
- child.parent = this;
17
- const childWidget = child.getChildWidget();
18
- const props = child.getSlotProps();
19
- if (childWidget) {
20
- this.attachToGrid(childWidget, props.column, props.row, props.columnSpan, props.rowSpan);
21
- child.setParentContainer(this);
22
- }
23
- return;
24
- }
25
- super.appendChild(child);
26
- }
27
- insertBefore(child, before) {
28
- if (child instanceof GridChildNode) {
29
- child.parent = this;
30
- const childWidget = child.getChildWidget();
31
- const props = child.getSlotProps();
32
- if (childWidget) {
33
- this.attachToGrid(childWidget, props.column, props.row, props.columnSpan, props.rowSpan);
34
- child.setParentContainer(this);
35
- }
36
- return;
37
- }
38
- super.insertBefore(child, before);
39
- }
40
- removeChild(child) {
41
- if (child instanceof GridChildNode) {
42
- const childWidget = child.getChildWidget();
43
- if (childWidget) {
44
- this.removeFromGrid(childWidget);
45
- }
46
- child.unmount();
47
- child.parent = null;
48
- return;
49
- }
50
- super.removeChild(child);
51
- }
52
- }
53
- export class GridChildNode extends VirtualSlotNode {
54
- static matches(type) {
55
- return type === "Grid.Child";
56
- }
57
- isValidContainer(parent) {
58
- return isGridContainer(parent);
59
- }
60
- extractSlotProps(props) {
61
- return {
62
- column: props.column ?? 0,
63
- row: props.row ?? 0,
64
- columnSpan: props.columnSpan ?? 1,
65
- rowSpan: props.rowSpan ?? 1,
66
- };
67
- }
68
- addToContainer(container, child, props) {
69
- container.attachToGrid(child, props.column, props.row, props.columnSpan, props.rowSpan);
70
- }
71
- insertBeforeInContainer(container, child, props, _before) {
72
- this.addToContainer(container, child, props);
73
- }
74
- removeFromContainer(container, child) {
75
- container.removeFromGrid(child);
76
- }
77
- updateInContainer(container, child, props) {
78
- container.removeFromGrid(child);
79
- container.attachToGrid(child, props.column, props.row, props.columnSpan, props.rowSpan);
80
- }
81
- updateProps(oldProps, newProps) {
82
- this.updateSlotPropsIfChanged(oldProps, newProps, ["column", "row", "columnSpan", "rowSpan"]);
83
- }
84
- }
@@ -1,43 +0,0 @@
1
- import type * as Adw from "@gtkx/ffi/adw";
2
- import type * as Gtk from "@gtkx/ffi/gtk";
3
- import type { PackContainer } from "../containers.js";
4
- import type { Props } from "../factory.js";
5
- import { Node } from "../node.js";
6
- import { VirtualSlotNode } from "./virtual-slot.js";
7
- type HeaderBarWidget = Gtk.HeaderBar | Adw.HeaderBar | Gtk.ActionBar;
8
- type PackPosition = "start" | "end";
9
- type PackSlotProps = {
10
- position: PackPosition;
11
- };
12
- declare abstract class PackSlotNode extends VirtualSlotNode<PackContainer, PackSlotProps> {
13
- protected abstract readonly position: PackPosition;
14
- protected isValidContainer(parent: Node): parent is Node & PackContainer;
15
- protected extractSlotProps(_props: Props): PackSlotProps;
16
- protected addToContainer(container: PackContainer, child: Gtk.Widget, props: PackSlotProps): void;
17
- protected insertBeforeInContainer(container: PackContainer, child: Gtk.Widget, props: PackSlotProps, _before: Gtk.Widget): void;
18
- protected removeFromContainer(container: PackContainer, child: Gtk.Widget): void;
19
- protected updateInContainer(): void;
20
- }
21
- export declare class PackStartNode extends PackSlotNode {
22
- protected readonly position: PackPosition;
23
- static matches(type: string): boolean;
24
- }
25
- export declare class PackEndNode extends PackSlotNode {
26
- protected readonly position: PackPosition;
27
- static matches(type: string): boolean;
28
- }
29
- export declare class PackContainerNode<T extends HeaderBarWidget> extends Node<T> implements PackContainer {
30
- packStart(child: Gtk.Widget): void;
31
- packEnd(child: Gtk.Widget): void;
32
- removeFromPack(child: Gtk.Widget): void;
33
- appendChild(child: Node): void;
34
- insertBefore(child: Node, before: Node): void;
35
- removeChild(child: Node): void;
36
- }
37
- export declare class AdwHeaderBarNode extends PackContainerNode<Adw.HeaderBar> {
38
- static matches(type: string): boolean;
39
- }
40
- export declare class HeaderBarNode extends PackContainerNode<Gtk.HeaderBar> {
41
- static matches(type: string): boolean;
42
- }
43
- export {};
@@ -1,116 +0,0 @@
1
- import { Node } from "../node.js";
2
- import { isPackContainer } from "../predicates.js";
3
- import { VirtualSlotNode } from "./virtual-slot.js";
4
- class PackSlotNode extends VirtualSlotNode {
5
- isValidContainer(parent) {
6
- return isPackContainer(parent);
7
- }
8
- extractSlotProps(_props) {
9
- return { position: this.position };
10
- }
11
- addToContainer(container, child, props) {
12
- if (props.position === "start") {
13
- container.packStart(child);
14
- }
15
- else {
16
- container.packEnd(child);
17
- }
18
- }
19
- insertBeforeInContainer(container, child, props, _before) {
20
- this.addToContainer(container, child, props);
21
- }
22
- removeFromContainer(container, child) {
23
- container.removeFromPack(child);
24
- }
25
- updateInContainer() { }
26
- }
27
- export class PackStartNode extends PackSlotNode {
28
- position = "start";
29
- static matches(type) {
30
- return type === "HeaderBar.Start" || type === "AdwHeaderBar.Start" || type === "ActionBar.Start";
31
- }
32
- }
33
- export class PackEndNode extends PackSlotNode {
34
- position = "end";
35
- static matches(type) {
36
- return type === "HeaderBar.End" || type === "AdwHeaderBar.End" || type === "ActionBar.End";
37
- }
38
- }
39
- export class PackContainerNode extends Node {
40
- packStart(child) {
41
- this.widget.packStart(child);
42
- }
43
- packEnd(child) {
44
- this.widget.packEnd(child);
45
- }
46
- removeFromPack(child) {
47
- this.widget.remove(child);
48
- }
49
- appendChild(child) {
50
- if (child instanceof PackSlotNode) {
51
- child.parent = this;
52
- const childWidget = child.getChildWidget();
53
- const props = child.getSlotProps();
54
- if (childWidget) {
55
- if (props.position === "start") {
56
- this.packStart(childWidget);
57
- }
58
- else {
59
- this.packEnd(childWidget);
60
- }
61
- child.setParentContainer(this);
62
- }
63
- return;
64
- }
65
- child.parent = this;
66
- const childWidget = child.getWidget();
67
- if (childWidget) {
68
- this.packStart(childWidget);
69
- }
70
- }
71
- insertBefore(child, before) {
72
- if (child instanceof PackSlotNode) {
73
- child.parent = this;
74
- const childWidget = child.getChildWidget();
75
- const props = child.getSlotProps();
76
- if (childWidget) {
77
- if (props.position === "start") {
78
- this.packStart(childWidget);
79
- }
80
- else {
81
- this.packEnd(childWidget);
82
- }
83
- child.setParentContainer(this);
84
- }
85
- return;
86
- }
87
- super.insertBefore(child, before);
88
- }
89
- removeChild(child) {
90
- if (child instanceof PackSlotNode) {
91
- const childWidget = child.getChildWidget();
92
- if (childWidget) {
93
- this.removeFromPack(childWidget);
94
- }
95
- child.unmount();
96
- child.parent = null;
97
- return;
98
- }
99
- child.unmount();
100
- const childWidget = child.getWidget();
101
- if (childWidget) {
102
- this.removeFromPack(childWidget);
103
- }
104
- child.parent = null;
105
- }
106
- }
107
- export class AdwHeaderBarNode extends PackContainerNode {
108
- static matches(type) {
109
- return type === "AdwHeaderBar" || type === "AdwHeaderBar.Root";
110
- }
111
- }
112
- export class HeaderBarNode extends PackContainerNode {
113
- static matches(type) {
114
- return type === "HeaderBar" || type === "HeaderBar.Root";
115
- }
116
- }
@@ -1,16 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import type { ChildContainer } from "../containers.js";
3
- import { Node } from "../node.js";
4
- type IndexedWidget = Gtk.Widget & {
5
- append(child: Gtk.Widget): void;
6
- insert(child: Gtk.Widget, position: number): void;
7
- remove(child: Gtk.Widget): void;
8
- };
9
- export declare abstract class IndexedChildContainerNode<T extends IndexedWidget> extends Node<T> implements ChildContainer {
10
- protected abstract getInsertionIndex(before: Gtk.Widget): number;
11
- protected getWidgetToRemove(child: Gtk.Widget): Gtk.Widget;
12
- attachChild(child: Gtk.Widget): void;
13
- insertChildBefore(child: Gtk.Widget, before: Gtk.Widget): void;
14
- detachChild(child: Gtk.Widget): void;
15
- }
16
- export {};
@@ -1,22 +0,0 @@
1
- import { Node } from "../node.js";
2
- export class IndexedChildContainerNode extends Node {
3
- getWidgetToRemove(child) {
4
- return child;
5
- }
6
- attachChild(child) {
7
- this.widget.append(child);
8
- }
9
- insertChildBefore(child, before) {
10
- const index = this.getInsertionIndex(before);
11
- if (index >= 0) {
12
- this.widget.insert(child, index);
13
- }
14
- else {
15
- this.widget.append(child);
16
- }
17
- }
18
- detachChild(child) {
19
- const toRemove = this.getWidgetToRemove(child);
20
- this.widget.remove(toRemove);
21
- }
22
- }
@@ -1,10 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import { IndexedChildContainerNode } from "./indexed-child-container.js";
3
- export declare class ListBoxNode extends IndexedChildContainerNode<Gtk.ListBox> {
4
- static matches(type: string): boolean;
5
- protected getInsertionIndex(before: Gtk.Widget): number;
6
- private unparentFromRow;
7
- attachChild(child: Gtk.Widget): void;
8
- insertChildBefore(child: Gtk.Widget, before: Gtk.Widget): void;
9
- detachChild(child: Gtk.Widget): void;
10
- }
@@ -1,48 +0,0 @@
1
- import { beginBatch, endBatch } from "@gtkx/ffi";
2
- import { isListBoxRow } from "../predicates.js";
3
- import { IndexedChildContainerNode } from "./indexed-child-container.js";
4
- export class ListBoxNode extends IndexedChildContainerNode {
5
- static matches(type) {
6
- return type === "ListBox";
7
- }
8
- getInsertionIndex(before) {
9
- const beforeParent = before.getParent();
10
- if (beforeParent && isListBoxRow(beforeParent)) {
11
- return beforeParent.getIndex();
12
- }
13
- return -1;
14
- }
15
- unparentFromRow(child) {
16
- const parent = child.getParent();
17
- if (parent && isListBoxRow(parent)) {
18
- beginBatch();
19
- parent.setChild(undefined);
20
- this.widget.remove(parent);
21
- endBatch();
22
- }
23
- }
24
- attachChild(child) {
25
- this.unparentFromRow(child);
26
- this.widget.append(child);
27
- }
28
- insertChildBefore(child, before) {
29
- this.unparentFromRow(child);
30
- const index = this.getInsertionIndex(before);
31
- if (index >= 0) {
32
- this.widget.insert(child, index);
33
- }
34
- else {
35
- this.widget.append(child);
36
- }
37
- }
38
- detachChild(child) {
39
- if (isListBoxRow(child)) {
40
- beginBatch();
41
- child.setChild(undefined);
42
- this.widget.remove(child);
43
- endBatch();
44
- return;
45
- }
46
- this.unparentFromRow(child);
47
- }
48
- }
@@ -1,19 +0,0 @@
1
- import * as Gtk from "@gtkx/ffi/gtk";
2
- import type Reconciler from "react-reconciler";
3
- import type { RenderItemFn } from "../types.js";
4
- export type ListItemInfo = {
5
- box: Gtk.Box;
6
- fiberRoot: Reconciler.FiberRoot;
7
- };
8
- type ListItemFactoryConfig = {
9
- factory: Gtk.SignalListItemFactory;
10
- listItemCache: Map<number, ListItemInfo>;
11
- getRenderFn: () => RenderItemFn<unknown>;
12
- getItemAtPosition: (position: number) => unknown;
13
- };
14
- export type ListItemFactoryHandlers = {
15
- handlerIds: number[];
16
- disconnect: () => void;
17
- };
18
- export declare function connectListItemFactorySignals(config: ListItemFactoryConfig): ListItemFactoryHandlers;
19
- export {};
@@ -1,58 +0,0 @@
1
- import { getObjectId } from "@gtkx/ffi";
2
- import * as GObject from "@gtkx/ffi/gobject";
3
- import * as Gtk from "@gtkx/ffi/gtk";
4
- import { createFiberRoot } from "../fiber-root.js";
5
- import { reconciler } from "../reconciler.js";
6
- export function connectListItemFactorySignals(config) {
7
- const { factory, listItemCache, getRenderFn, getItemAtPosition } = config;
8
- const handlerIds = [];
9
- const setupId = factory.connect("setup", (_self, listItemObj) => {
10
- const listItem = listItemObj;
11
- const id = getObjectId(listItemObj.id);
12
- const box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
13
- listItem.setChild(box);
14
- const fiberRoot = createFiberRoot(box);
15
- listItemCache.set(id, { box, fiberRoot });
16
- const element = getRenderFn()(null);
17
- reconciler.getInstance().updateContainer(element, fiberRoot, null, () => { });
18
- });
19
- handlerIds.push(setupId);
20
- const bindId = factory.connect("bind", (_self, listItemObj) => {
21
- const listItem = listItemObj;
22
- const id = getObjectId(listItemObj.id);
23
- const info = listItemCache.get(id);
24
- if (!info)
25
- return;
26
- const position = listItem.getPosition();
27
- const item = getItemAtPosition(position);
28
- const element = getRenderFn()(item ?? null);
29
- reconciler.getInstance().updateContainer(element, info.fiberRoot, null, () => { });
30
- });
31
- handlerIds.push(bindId);
32
- const unbindId = factory.connect("unbind", (_self, listItemObj) => {
33
- const id = getObjectId(listItemObj.id);
34
- const info = listItemCache.get(id);
35
- if (!info)
36
- return;
37
- reconciler.getInstance().updateContainer(null, info.fiberRoot, null, () => { });
38
- });
39
- handlerIds.push(unbindId);
40
- const teardownId = factory.connect("teardown", (_self, listItemObj) => {
41
- const id = getObjectId(listItemObj.id);
42
- const info = listItemCache.get(id);
43
- if (info) {
44
- reconciler.getInstance().updateContainer(null, info.fiberRoot, null, () => { });
45
- queueMicrotask(() => listItemCache.delete(id));
46
- }
47
- });
48
- handlerIds.push(teardownId);
49
- return {
50
- handlerIds,
51
- disconnect: () => {
52
- for (const handlerId of handlerIds) {
53
- GObject.signalHandlerDisconnect(factory, handlerId);
54
- }
55
- handlerIds.length = 0;
56
- },
57
- };
58
- }
@@ -1,11 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import type { ChildContainer } from "../containers.js";
3
- import { Node } from "../node.js";
4
- export declare class OverlayNode extends Node<Gtk.Overlay> implements ChildContainer {
5
- static matches(type: string): boolean;
6
- private mainChild;
7
- private overlayChildren;
8
- attachChild(childWidget: Gtk.Widget): void;
9
- insertChildBefore(childWidget: Gtk.Widget, beforeWidget: Gtk.Widget): void;
10
- detachChild(childWidget: Gtk.Widget): void;
11
- }