@gtkx/react 0.17.2 → 0.18.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 (194) hide show
  1. package/README.md +7 -7
  2. package/dist/factory.d.ts +0 -1
  3. package/dist/factory.js +21 -8
  4. package/dist/generated/internal.d.ts +4 -51
  5. package/dist/generated/internal.js +626 -412
  6. package/dist/generated/jsx.d.ts +453 -958
  7. package/dist/host-config.d.ts +1 -1
  8. package/dist/host-config.js +18 -23
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +1 -1
  11. package/dist/jsx.d.ts +579 -302
  12. package/dist/jsx.js +37 -179
  13. package/dist/metadata.d.ts +3 -0
  14. package/dist/metadata.js +26 -0
  15. package/dist/node.d.ts +20 -12
  16. package/dist/node.js +72 -17
  17. package/dist/nodes/adjustable.d.ts +3 -16
  18. package/dist/nodes/adjustable.js +5 -22
  19. package/dist/nodes/alert-dialog-response.d.ts +14 -1
  20. package/dist/nodes/alert-dialog-response.js +36 -62
  21. package/dist/nodes/animation.d.ts +37 -1
  22. package/dist/nodes/animation.js +162 -105
  23. package/dist/nodes/application.d.ts +11 -1
  24. package/dist/nodes/application.js +17 -38
  25. package/dist/nodes/calendar.d.ts +13 -0
  26. package/dist/nodes/calendar.js +10 -16
  27. package/dist/nodes/color-dialog-button.d.ts +13 -0
  28. package/dist/nodes/color-dialog-button.js +10 -38
  29. package/dist/nodes/column-view-column.d.ts +13 -11
  30. package/dist/nodes/column-view-column.js +27 -23
  31. package/dist/nodes/column-view.d.ts +31 -0
  32. package/dist/nodes/column-view.js +44 -44
  33. package/dist/nodes/container-slot.d.ts +15 -0
  34. package/dist/nodes/container-slot.js +68 -0
  35. package/dist/nodes/dialog.d.ts +6 -8
  36. package/dist/nodes/dialog.js +12 -13
  37. package/dist/nodes/drawing-area.d.ts +12 -0
  38. package/dist/nodes/drawing-area.js +24 -24
  39. package/dist/nodes/drop-down.d.ts +22 -0
  40. package/dist/nodes/drop-down.js +72 -0
  41. package/dist/nodes/event-controller.d.ts +8 -17
  42. package/dist/nodes/event-controller.js +20 -42
  43. package/dist/nodes/fixed-child.d.ts +18 -1
  44. package/dist/nodes/fixed-child.js +52 -36
  45. package/dist/nodes/font-dialog-button.d.ts +13 -0
  46. package/dist/nodes/font-dialog-button.js +12 -35
  47. package/dist/nodes/grid-child.d.ts +17 -1
  48. package/dist/nodes/grid-child.js +57 -37
  49. package/dist/nodes/grid-view.d.ts +24 -0
  50. package/dist/nodes/grid-view.js +73 -0
  51. package/dist/nodes/internal/base-item-renderer.d.ts +7 -9
  52. package/dist/nodes/internal/base-item-renderer.js +15 -18
  53. package/dist/nodes/internal/grid-item-renderer.d.ts +17 -0
  54. package/dist/nodes/internal/grid-item-renderer.js +59 -0
  55. package/dist/nodes/internal/list-item-renderer.d.ts +14 -9
  56. package/dist/nodes/internal/list-item-renderer.js +96 -35
  57. package/dist/nodes/internal/list-store.d.ts +5 -0
  58. package/dist/nodes/internal/list-store.js +39 -9
  59. package/dist/nodes/internal/predicates.d.ts +4 -19
  60. package/dist/nodes/internal/predicates.js +1 -20
  61. package/dist/nodes/internal/props.d.ts +5 -0
  62. package/dist/nodes/internal/props.js +42 -0
  63. package/dist/nodes/internal/{selection-model.d.ts → selection-model-controller.d.ts} +4 -9
  64. package/dist/nodes/internal/{selection-model.js → selection-model-controller.js} +6 -15
  65. package/dist/nodes/internal/signal-store.js +12 -5
  66. package/dist/nodes/internal/simple-list-store.d.ts +5 -0
  67. package/dist/nodes/internal/simple-list-store.js +42 -13
  68. package/dist/nodes/internal/text-buffer-controller.d.ts +4 -12
  69. package/dist/nodes/internal/text-buffer-controller.js +32 -33
  70. package/dist/nodes/internal/tree-store.d.ts +7 -0
  71. package/dist/nodes/internal/tree-store.js +75 -18
  72. package/dist/nodes/internal/widget.d.ts +7 -0
  73. package/dist/nodes/internal/widget.js +68 -0
  74. package/dist/nodes/level-bar.d.ts +10 -0
  75. package/dist/nodes/level-bar.js +11 -22
  76. package/dist/nodes/list-item.d.ts +17 -9
  77. package/dist/nodes/list-item.js +67 -12
  78. package/dist/nodes/list-view.d.ts +23 -0
  79. package/dist/nodes/list-view.js +27 -31
  80. package/dist/nodes/menu.d.ts +2 -4
  81. package/dist/nodes/menu.js +0 -6
  82. package/dist/nodes/models/grid.d.ts +27 -0
  83. package/dist/nodes/models/grid.js +68 -0
  84. package/dist/nodes/models/list.d.ts +15 -13
  85. package/dist/nodes/models/list.js +48 -26
  86. package/dist/nodes/models/menu.d.ts +15 -16
  87. package/dist/nodes/models/menu.js +63 -93
  88. package/dist/nodes/navigation-page.d.ts +16 -10
  89. package/dist/nodes/navigation-page.js +108 -31
  90. package/dist/nodes/navigation-view.d.ts +15 -0
  91. package/dist/nodes/navigation-view.js +15 -65
  92. package/dist/nodes/notebook-page-tab.d.ts +10 -12
  93. package/dist/nodes/notebook-page-tab.js +24 -27
  94. package/dist/nodes/notebook-page.d.ts +19 -16
  95. package/dist/nodes/notebook-page.js +75 -56
  96. package/dist/nodes/notebook.d.ts +10 -1
  97. package/dist/nodes/notebook.js +10 -22
  98. package/dist/nodes/overlay-child.d.ts +17 -1
  99. package/dist/nodes/overlay-child.js +53 -75
  100. package/dist/nodes/popover-menu.d.ts +15 -0
  101. package/dist/nodes/popover-menu.js +13 -26
  102. package/dist/nodes/scale.d.ts +8 -0
  103. package/dist/nodes/scale.js +2 -11
  104. package/dist/nodes/scrolled-window.d.ts +9 -0
  105. package/dist/nodes/scrolled-window.js +5 -11
  106. package/dist/nodes/search-bar.d.ts +9 -0
  107. package/dist/nodes/search-bar.js +8 -33
  108. package/dist/nodes/shortcut-controller.d.ts +9 -1
  109. package/dist/nodes/shortcut-controller.js +12 -25
  110. package/dist/nodes/shortcut.d.ts +11 -33
  111. package/dist/nodes/shortcut.js +19 -15
  112. package/dist/nodes/slot.d.ts +16 -15
  113. package/dist/nodes/slot.js +63 -57
  114. package/dist/nodes/source-view.d.ts +16 -0
  115. package/dist/nodes/source-view.js +44 -44
  116. package/dist/nodes/stack-page.d.ts +21 -1
  117. package/dist/nodes/stack-page.js +68 -17
  118. package/dist/nodes/stack.d.ts +11 -0
  119. package/dist/nodes/stack.js +8 -26
  120. package/dist/nodes/text-anchor.d.ts +11 -30
  121. package/dist/nodes/text-anchor.js +20 -22
  122. package/dist/nodes/text-content.d.ts +1 -0
  123. package/dist/nodes/text-content.js +1 -1
  124. package/dist/nodes/text-paintable.d.ts +10 -15
  125. package/dist/nodes/text-paintable.js +16 -9
  126. package/dist/nodes/text-segment.d.ts +12 -10
  127. package/dist/nodes/text-segment.js +19 -11
  128. package/dist/nodes/text-tag.d.ts +20 -119
  129. package/dist/nodes/text-tag.js +153 -119
  130. package/dist/nodes/text-view.d.ts +13 -18
  131. package/dist/nodes/text-view.js +17 -17
  132. package/dist/nodes/toggle-group.d.ts +9 -0
  133. package/dist/nodes/toggle-group.js +8 -33
  134. package/dist/nodes/toggle.d.ts +15 -1
  135. package/dist/nodes/toggle.js +34 -52
  136. package/dist/nodes/virtual.d.ts +3 -10
  137. package/dist/nodes/virtual.js +1 -14
  138. package/dist/nodes/web-view.d.ts +9 -0
  139. package/dist/nodes/web-view.js +10 -24
  140. package/dist/nodes/widget.d.ts +17 -13
  141. package/dist/nodes/widget.js +185 -112
  142. package/dist/nodes/window.d.ts +20 -21
  143. package/dist/nodes/window.js +54 -35
  144. package/dist/registry.d.ts +17 -6
  145. package/dist/registry.js +104 -5
  146. package/dist/render.d.ts +1 -10
  147. package/dist/render.js +1 -13
  148. package/package.json +6 -6
  149. package/dist/animation/css-builder.d.ts +0 -3
  150. package/dist/animation/css-builder.js +0 -53
  151. package/dist/animation/types.d.ts +0 -120
  152. package/dist/animation/types.js +0 -1
  153. package/dist/nodes/abstract/positional-child.d.ts +0 -9
  154. package/dist/nodes/abstract/positional-child.js +0 -29
  155. package/dist/nodes/abstract/virtual-container.d.ts +0 -21
  156. package/dist/nodes/abstract/virtual-container.js +0 -68
  157. package/dist/nodes/abstract/virtual-single-child.d.ts +0 -18
  158. package/dist/nodes/abstract/virtual-single-child.js +0 -55
  159. package/dist/nodes/action-row-child.d.ts +0 -1
  160. package/dist/nodes/action-row-child.js +0 -30
  161. package/dist/nodes/autowrapped.d.ts +0 -1
  162. package/dist/nodes/autowrapped.js +0 -115
  163. package/dist/nodes/expander-row-child.d.ts +0 -1
  164. package/dist/nodes/expander-row-child.js +0 -30
  165. package/dist/nodes/grid.d.ts +0 -1
  166. package/dist/nodes/grid.js +0 -41
  167. package/dist/nodes/index.d.ts +0 -56
  168. package/dist/nodes/index.js +0 -56
  169. package/dist/nodes/internal/child-attachment.d.ts +0 -26
  170. package/dist/nodes/internal/child-attachment.js +0 -48
  171. package/dist/nodes/internal/deferred-action.d.ts +0 -9
  172. package/dist/nodes/internal/deferred-action.js +0 -22
  173. package/dist/nodes/internal/text-tag-styles.d.ts +0 -43
  174. package/dist/nodes/internal/text-tag-styles.js +0 -52
  175. package/dist/nodes/internal/tree-list-item-renderer.d.ts +0 -26
  176. package/dist/nodes/internal/tree-list-item-renderer.js +0 -134
  177. package/dist/nodes/internal/utils.d.ts +0 -12
  178. package/dist/nodes/internal/utils.js +0 -92
  179. package/dist/nodes/models/tree-list.d.ts +0 -28
  180. package/dist/nodes/models/tree-list.js +0 -113
  181. package/dist/nodes/pack-child.d.ts +0 -1
  182. package/dist/nodes/pack-child.js +0 -30
  183. package/dist/nodes/simple-list-item.d.ts +0 -9
  184. package/dist/nodes/simple-list-item.js +0 -9
  185. package/dist/nodes/simple-list-view.d.ts +0 -1
  186. package/dist/nodes/simple-list-view.js +0 -74
  187. package/dist/nodes/toolbar-child.d.ts +0 -1
  188. package/dist/nodes/toolbar-child.js +0 -30
  189. package/dist/nodes/tree-list-item.d.ts +0 -22
  190. package/dist/nodes/tree-list-item.js +0 -90
  191. package/dist/nodes/tree-list-view.d.ts +0 -1
  192. package/dist/nodes/tree-list-view.js +0 -77
  193. package/dist/scheduler.d.ts +0 -26
  194. package/dist/scheduler.js +0 -42
@@ -1,25 +1,25 @@
1
1
  import * as Adw from "@gtkx/ffi/adw";
2
2
  import * as Gtk from "@gtkx/ffi/gtk";
3
- import { registerNodeClass } from "../registry.js";
4
- import { DialogNode } from "./dialog.js";
5
- import { filterProps, hasChanged, matchesAnyClass } from "./internal/utils.js";
3
+ import { AnimationNode } from "./animation.js";
4
+ import { filterProps, hasChanged } from "./internal/props.js";
5
+ import { MenuNode } from "./menu.js";
6
6
  import { MenuModel } from "./models/menu.js";
7
+ import { NavigationPageNode } from "./navigation-page.js";
8
+ import { SlotNode } from "./slot.js";
7
9
  import { WidgetNode } from "./widget.js";
8
- const OWN_PROPS = ["defaultWidth", "defaultHeight", "onClose"];
10
+ // biome-ignore lint/suspicious/noExplicitAny: Required for matching GTK class constructors with varying signatures
11
+ const isOrExtendsClass = (target, cls) => target === cls || Object.prototype.isPrototypeOf.call(cls, target);
12
+ const OWN_PROPS = ["onClose"];
9
13
  export class WindowNode extends WidgetNode {
10
- static priority = 1;
11
14
  menu;
12
- static matches(_type, containerOrClass) {
13
- return matchesAnyClass([Gtk.Window], containerOrClass);
14
- }
15
15
  static createContainer(props, containerClass, rootContainer) {
16
16
  const WindowClass = containerClass;
17
- if (matchesAnyClass([Gtk.ApplicationWindow], WindowClass) ||
18
- matchesAnyClass([Adw.ApplicationWindow], WindowClass)) {
17
+ if (isOrExtendsClass(WindowClass, Gtk.ApplicationWindow) ||
18
+ isOrExtendsClass(WindowClass, Adw.ApplicationWindow)) {
19
19
  if (!(rootContainer instanceof Gtk.Application)) {
20
20
  throw new Error("Expected ApplicationWindow to be created within Application");
21
21
  }
22
- if (matchesAnyClass([Adw.ApplicationWindow], WindowClass)) {
22
+ if (isOrExtendsClass(WindowClass, Adw.ApplicationWindow)) {
23
23
  return new Adw.ApplicationWindow(rootContainer);
24
24
  }
25
25
  return new Gtk.ApplicationWindow(rootContainer);
@@ -37,52 +37,72 @@ export class WindowNode extends WidgetNode {
37
37
  }
38
38
  }
39
39
  }
40
+ shouldAttachToParent() {
41
+ return false;
42
+ }
43
+ isValidChild(child) {
44
+ return (child instanceof WidgetNode ||
45
+ child instanceof MenuNode ||
46
+ child instanceof SlotNode ||
47
+ child instanceof AnimationNode ||
48
+ child instanceof NavigationPageNode);
49
+ }
40
50
  appendChild(child) {
41
- if (child.container instanceof Gtk.Window) {
51
+ if (child instanceof WindowNode) {
42
52
  child.container.setTransientFor(this.container);
53
+ super.appendChild(child);
43
54
  return;
44
55
  }
45
- if (child instanceof DialogNode) {
46
- child.parent = this.container;
56
+ if (child instanceof MenuNode) {
57
+ this.menu.appendChild(child);
47
58
  return;
48
59
  }
49
- this.menu.appendChild(child);
50
60
  super.appendChild(child);
51
61
  }
52
62
  removeChild(child) {
53
- if (child.container instanceof Gtk.Window) {
63
+ if (child instanceof WindowNode) {
54
64
  child.container.setTransientFor(null);
65
+ super.removeChild(child);
55
66
  return;
56
67
  }
57
- if (child instanceof DialogNode) {
58
- child.parent = null;
68
+ if (child instanceof MenuNode) {
69
+ this.menu.removeChild(child);
59
70
  return;
60
71
  }
61
- this.menu.removeChild(child);
62
72
  super.removeChild(child);
63
73
  }
64
74
  insertBefore(child, before) {
65
- this.menu.insertBefore(child, before);
66
- this.appendChild(child);
75
+ if (child instanceof MenuNode) {
76
+ if (before instanceof MenuNode) {
77
+ this.menu.insertBefore(child, before);
78
+ }
79
+ else {
80
+ this.menu.appendChild(child);
81
+ }
82
+ return;
83
+ }
84
+ if (child instanceof WindowNode) {
85
+ child.container.setTransientFor(this.container);
86
+ }
87
+ super.insertBefore(child, before);
88
+ }
89
+ finalizeInitialChildren(props) {
90
+ this.commitUpdate(null, props);
91
+ return true;
92
+ }
93
+ commitUpdate(oldProps, newProps) {
94
+ super.commitUpdate(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
95
+ this.applyOwnProps(oldProps, newProps);
67
96
  }
68
- mount() {
97
+ commitMount() {
69
98
  this.container.present();
70
- super.mount();
71
99
  }
72
- unmount() {
100
+ detachDeletedInstance() {
101
+ this.container.setVisible(false);
73
102
  this.container.destroy();
74
- super.unmount();
75
- }
76
- updateProps(oldProps, newProps) {
77
- super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
78
- this.applyOwnProps(oldProps, newProps);
103
+ super.detachDeletedInstance();
79
104
  }
80
105
  applyOwnProps(oldProps, newProps) {
81
- if (hasChanged(oldProps, newProps, "defaultWidth") || hasChanged(oldProps, newProps, "defaultHeight")) {
82
- const width = newProps.defaultWidth ?? -1;
83
- const height = newProps.defaultHeight ?? -1;
84
- this.container.setDefaultSize(width, height);
85
- }
86
106
  if (hasChanged(oldProps, newProps, "onClose")) {
87
107
  const userHandler = newProps.onClose;
88
108
  const wrappedHandler = userHandler
@@ -95,4 +115,3 @@ export class WindowNode extends WidgetNode {
95
115
  }
96
116
  }
97
117
  }
98
- registerNodeClass(WindowNode);
@@ -1,8 +1,19 @@
1
+ import * as Adw from "@gtkx/ffi/adw";
2
+ import * as Gtk from "@gtkx/ffi/gtk";
1
3
  import type { Node } from "./node.js";
2
- import type { Container, Props } from "./types.js";
3
- type NodeClass<T = unknown, P = Props> = {
4
- new (typeName: string, props: P, container: T, rootContainer: Container): Node<T, P>;
5
- } & Omit<typeof Node, "prototype">;
6
- export declare const NODE_CLASSES: NodeClass[];
7
- export declare const registerNodeClass: <T, P>(nodeClass: NodeClass<T, P>) => void;
4
+ export declare const AdjustableWidgets: readonly [typeof Gtk.SpinButton, typeof Gtk.ScaleButton, typeof Gtk.Range];
5
+ export type AdjustableWidget = InstanceType<(typeof AdjustableWidgets)[number]>;
6
+ export declare const StackWidgets: readonly [typeof Gtk.Stack, typeof Adw.ViewStack];
7
+ export type StackWidget = InstanceType<(typeof StackWidgets)[number]>;
8
+ export declare const DropDownWidgets: readonly [typeof Gtk.DropDown, typeof Adw.ComboRow];
9
+ export type DropDownWidget = InstanceType<(typeof DropDownWidgets)[number]>;
10
+ export declare const PopoverMenuWidgets: readonly [typeof Gtk.PopoverMenu, typeof Gtk.PopoverMenuBar, typeof Gtk.MenuButton];
11
+ export type PopoverMenuWidget = InstanceType<(typeof PopoverMenuWidgets)[number]>;
12
+ export type NodeClass = (new (...args: any[]) => Node) & {
13
+ createContainer(...args: any[]): unknown;
14
+ };
15
+ type ClassKey = new (...args: any[]) => any;
16
+ type RegistryKey = string | ClassKey | readonly (string | ClassKey)[];
17
+ type NodeRegistryEntry = [RegistryKey, NodeClass];
18
+ export declare const NODE_REGISTRY: NodeRegistryEntry[];
8
19
  export {};
package/dist/registry.js CHANGED
@@ -1,5 +1,104 @@
1
- export const NODE_CLASSES = [];
2
- export const registerNodeClass = (nodeClass) => {
3
- NODE_CLASSES.push(nodeClass);
4
- NODE_CLASSES.sort((a, b) => a.priority - b.priority);
5
- };
1
+ import * as Adw from "@gtkx/ffi/adw";
2
+ import * as Gtk from "@gtkx/ffi/gtk";
3
+ import * as GtkSource from "@gtkx/ffi/gtksource";
4
+ import * as WebKit from "@gtkx/ffi/webkit";
5
+ import { AdjustableNode } from "./nodes/adjustable.js";
6
+ import { AlertDialogResponseNode } from "./nodes/alert-dialog-response.js";
7
+ import { AnimationNode } from "./nodes/animation.js";
8
+ import { ApplicationNode } from "./nodes/application.js";
9
+ import { CalendarNode } from "./nodes/calendar.js";
10
+ import { ColorDialogButtonNode } from "./nodes/color-dialog-button.js";
11
+ import { ColumnViewNode } from "./nodes/column-view.js";
12
+ import { ColumnViewColumnNode } from "./nodes/column-view-column.js";
13
+ import { ContainerSlotNode } from "./nodes/container-slot.js";
14
+ import { DialogNode } from "./nodes/dialog.js";
15
+ import { DrawingAreaNode } from "./nodes/drawing-area.js";
16
+ import { DropDownNode } from "./nodes/drop-down.js";
17
+ import { EventControllerNode } from "./nodes/event-controller.js";
18
+ import { FixedChildNode } from "./nodes/fixed-child.js";
19
+ import { FontDialogButtonNode } from "./nodes/font-dialog-button.js";
20
+ import { GridChildNode } from "./nodes/grid-child.js";
21
+ import { GridViewNode } from "./nodes/grid-view.js";
22
+ import { LevelBarNode } from "./nodes/level-bar.js";
23
+ import { ListItemNode } from "./nodes/list-item.js";
24
+ import { ListViewNode } from "./nodes/list-view.js";
25
+ import { MenuNode } from "./nodes/menu.js";
26
+ import { NavigationPageNode } from "./nodes/navigation-page.js";
27
+ import { NavigationViewNode } from "./nodes/navigation-view.js";
28
+ import { NotebookNode } from "./nodes/notebook.js";
29
+ import { NotebookPageNode } from "./nodes/notebook-page.js";
30
+ import { NotebookPageTabNode } from "./nodes/notebook-page-tab.js";
31
+ import { OverlayChildNode } from "./nodes/overlay-child.js";
32
+ import { PopoverMenuNode } from "./nodes/popover-menu.js";
33
+ import { ScaleNode } from "./nodes/scale.js";
34
+ import { ScrolledWindowNode } from "./nodes/scrolled-window.js";
35
+ import { SearchBarNode } from "./nodes/search-bar.js";
36
+ import { ShortcutNode } from "./nodes/shortcut.js";
37
+ import { ShortcutControllerNode } from "./nodes/shortcut-controller.js";
38
+ import { SlotNode } from "./nodes/slot.js";
39
+ import { SourceViewNode } from "./nodes/source-view.js";
40
+ import { StackNode } from "./nodes/stack.js";
41
+ import { StackPageNode } from "./nodes/stack-page.js";
42
+ import { TextAnchorNode } from "./nodes/text-anchor.js";
43
+ import { TextPaintableNode } from "./nodes/text-paintable.js";
44
+ import { TextSegmentNode } from "./nodes/text-segment.js";
45
+ import { TextTagNode } from "./nodes/text-tag.js";
46
+ import { TextViewNode } from "./nodes/text-view.js";
47
+ import { ToggleNode } from "./nodes/toggle.js";
48
+ import { ToggleGroupNode } from "./nodes/toggle-group.js";
49
+ import { WebViewNode } from "./nodes/web-view.js";
50
+ import { WidgetNode } from "./nodes/widget.js";
51
+ import { WindowNode } from "./nodes/window.js";
52
+ export const AdjustableWidgets = [Gtk.SpinButton, Gtk.ScaleButton, Gtk.Range];
53
+ export const StackWidgets = [Gtk.Stack, Adw.ViewStack];
54
+ export const DropDownWidgets = [Gtk.DropDown, Adw.ComboRow];
55
+ export const PopoverMenuWidgets = [Gtk.PopoverMenu, Gtk.PopoverMenuBar, Gtk.MenuButton];
56
+ export const NODE_REGISTRY = [
57
+ ["ContainerSlot", ContainerSlotNode],
58
+ ["AlertDialogResponse", AlertDialogResponseNode],
59
+ ["Animation", AnimationNode],
60
+ ["ColumnViewColumn", ColumnViewColumnNode],
61
+ ["FixedChild", FixedChildNode],
62
+ ["GridChild", GridChildNode],
63
+ ["ListItem", ListItemNode],
64
+ [["MenuItem", "MenuSection", "MenuSubmenu"], MenuNode],
65
+ ["NavigationPage", NavigationPageNode],
66
+ ["NotebookPage", NotebookPageNode],
67
+ ["NotebookPageTab", NotebookPageTabNode],
68
+ ["OverlayChild", OverlayChildNode],
69
+ ["Shortcut", ShortcutNode],
70
+ ["Slot", SlotNode],
71
+ ["StackPage", StackPageNode],
72
+ ["TextAnchor", TextAnchorNode],
73
+ ["TextPaintable", TextPaintableNode],
74
+ ["TextSegment", TextSegmentNode],
75
+ ["TextTag", TextTagNode],
76
+ ["Toggle", ToggleNode],
77
+ [Gtk.Application, ApplicationNode],
78
+ [Gtk.ShortcutController, ShortcutControllerNode],
79
+ [Gtk.EventController, EventControllerNode],
80
+ [GtkSource.View, SourceViewNode],
81
+ [Gtk.TextView, TextViewNode],
82
+ [WebKit.WebView, WebViewNode],
83
+ [Adw.Dialog, DialogNode],
84
+ [Gtk.Window, WindowNode],
85
+ [Gtk.Scale, ScaleNode],
86
+ [Gtk.LevelBar, LevelBarNode],
87
+ [Gtk.ScrolledWindow, ScrolledWindowNode],
88
+ [Gtk.Calendar, CalendarNode],
89
+ [Gtk.ColorDialogButton, ColorDialogButtonNode],
90
+ [Gtk.FontDialogButton, FontDialogButtonNode],
91
+ [Gtk.DrawingArea, DrawingAreaNode],
92
+ [Gtk.SearchBar, SearchBarNode],
93
+ [Adw.NavigationView, NavigationViewNode],
94
+ [Adw.ToggleGroup, ToggleGroupNode],
95
+ [Gtk.Notebook, NotebookNode],
96
+ [StackWidgets, StackNode],
97
+ [Gtk.ColumnView, ColumnViewNode],
98
+ [Gtk.ListView, ListViewNode],
99
+ [Gtk.GridView, GridViewNode],
100
+ [DropDownWidgets, DropDownNode],
101
+ [PopoverMenuWidgets, PopoverMenuNode],
102
+ [AdjustableWidgets, AdjustableNode],
103
+ [Gtk.Widget, WidgetNode],
104
+ ];
package/dist/render.d.ts CHANGED
@@ -35,15 +35,6 @@ export declare const ApplicationContext: React.Context<Gtk.Application | null>;
35
35
  * @see {@link ApplicationContext} for the underlying context
36
36
  */
37
37
  export declare const useApplication: () => Gtk.Application;
38
- /**
39
- * Returns the current GTK Application instance.
40
- *
41
- * Returns null if no application has been rendered yet.
42
- * Used by tools that need access to the running application.
43
- *
44
- * @returns The current GTK Application or null
45
- */
46
- export declare const getApplication: () => Gtk.Application | null;
47
38
  /**
48
39
  * Sets the hot reloading state.
49
40
  *
@@ -122,4 +113,4 @@ export declare const update: (element: ReactNode) => Promise<void>;
122
113
  *
123
114
  * @see {@link render} for starting the application
124
115
  */
125
- export declare const quit: () => boolean;
116
+ export declare const quit: () => void;
package/dist/render.js CHANGED
@@ -47,17 +47,6 @@ export const useApplication = () => {
47
47
  let container = null;
48
48
  let app = null;
49
49
  let isHotReloading = false;
50
- /**
51
- * Returns the current GTK Application instance.
52
- *
53
- * Returns null if no application has been rendered yet.
54
- * Used by tools that need access to the running application.
55
- *
56
- * @returns The current GTK Application or null
57
- */
58
- export const getApplication = () => {
59
- return app;
60
- };
61
50
  /**
62
51
  * Sets the hot reloading state.
63
52
  *
@@ -159,12 +148,11 @@ export const update = (element) => {
159
148
  */
160
149
  export const quit = () => {
161
150
  if (isHotReloading) {
162
- return true;
151
+ return;
163
152
  }
164
153
  reconciler.getInstance().updateContainer(null, container, null, () => {
165
154
  setTimeout(() => {
166
155
  stop();
167
156
  }, 0);
168
157
  });
169
- return true;
170
158
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/react",
3
- "version": "0.17.2",
3
+ "version": "0.18.0",
4
4
  "description": "Build GTK4 desktop applications with React and TypeScript",
5
5
  "keywords": [
6
6
  "gtkx",
@@ -13,13 +13,13 @@
13
13
  "gui",
14
14
  "native"
15
15
  ],
16
- "homepage": "https://eugeniodepalo.github.io/gtkx",
16
+ "homepage": "https://gtkx.dev",
17
17
  "bugs": {
18
- "url": "https://github.com/eugeniodepalo/gtkx/issues"
18
+ "url": "https://github.com/gtkx-org/gtkx/issues"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "https://github.com/eugeniodepalo/gtkx.git",
22
+ "url": "https://github.com/gtkx-org/gtkx.git",
23
23
  "directory": "packages/react"
24
24
  },
25
25
  "license": "MPL-2.0",
@@ -37,8 +37,8 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "react-reconciler": "^0.33.0",
40
- "@gtkx/ffi": "0.17.2",
41
- "@gtkx/gir": "0.17.2"
40
+ "@gtkx/ffi": "0.18.0",
41
+ "@gtkx/gir": "0.18.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/react-reconciler": "^0.33.0"
@@ -1,3 +0,0 @@
1
- import type { AnimatableProperties } from "./types.js";
2
- export declare const interpolate: (from: AnimatableProperties, to: AnimatableProperties, progress: number) => AnimatableProperties;
3
- export declare const buildCss: (className: string, props: AnimatableProperties) => string;
@@ -1,53 +0,0 @@
1
- const getDefaultValue = (property) => {
2
- switch (property) {
3
- case "opacity":
4
- case "scale":
5
- case "scaleX":
6
- case "scaleY":
7
- return 1;
8
- default:
9
- return 0;
10
- }
11
- };
12
- export const interpolate = (from, to, progress) => {
13
- const result = {};
14
- const allKeys = new Set([...Object.keys(from), ...Object.keys(to)]);
15
- for (const key of allKeys) {
16
- const fromVal = from[key] ?? getDefaultValue(key);
17
- const toVal = to[key] ?? getDefaultValue(key);
18
- result[key] = fromVal + (toVal - fromVal) * progress;
19
- }
20
- return result;
21
- };
22
- export const buildCss = (className, props) => {
23
- const parts = [];
24
- const transforms = [];
25
- if (props.opacity !== undefined) {
26
- parts.push(`opacity: ${props.opacity}`);
27
- }
28
- if (props.translateX !== undefined || props.translateY !== undefined) {
29
- transforms.push(`translate(${props.translateX ?? 0}px, ${props.translateY ?? 0}px)`);
30
- }
31
- if (props.scale !== undefined) {
32
- transforms.push(`scale(${props.scale})`);
33
- }
34
- else if (props.scaleX !== undefined || props.scaleY !== undefined) {
35
- transforms.push(`scale(${props.scaleX ?? 1}, ${props.scaleY ?? 1})`);
36
- }
37
- if (props.rotate !== undefined) {
38
- transforms.push(`rotate(${props.rotate}deg)`);
39
- }
40
- if (props.skewX !== undefined) {
41
- transforms.push(`skewX(${props.skewX}deg)`);
42
- }
43
- if (props.skewY !== undefined) {
44
- transforms.push(`skewY(${props.skewY}deg)`);
45
- }
46
- if (transforms.length > 0) {
47
- parts.push(`transform: ${transforms.join(" ")}`);
48
- }
49
- if (parts.length === 0) {
50
- return "";
51
- }
52
- return `.${className} { ${parts.join("; ")}; }`;
53
- };
@@ -1,120 +0,0 @@
1
- import type { Easing } from "@gtkx/ffi/adw";
2
- import type { ReactNode } from "react";
3
- /**
4
- * The type of animation to use.
5
- *
6
- * - `"timed"`: Duration-based animation with easing curves (uses {@link Adw.TimedAnimation})
7
- * - `"spring"`: Physics-based spring animation (uses {@link Adw.SpringAnimation})
8
- */
9
- export type AnimationMode = "timed" | "spring";
10
- /**
11
- * A numeric value that can be animated.
12
- */
13
- export type AnimatableValue = number;
14
- /**
15
- * CSS properties that can be animated on a widget.
16
- *
17
- * All transforms are applied via GTK CSS and rendered through the widget's style context.
18
- */
19
- export type AnimatableProperties = {
20
- /** Opacity from 0 (fully transparent) to 1 (fully opaque) */
21
- opacity?: AnimatableValue;
22
- /** Horizontal translation in pixels (positive moves right) */
23
- translateX?: AnimatableValue;
24
- /** Vertical translation in pixels (positive moves down) */
25
- translateY?: AnimatableValue;
26
- /** Uniform scale factor (1 = original size, 2 = double size) */
27
- scale?: AnimatableValue;
28
- /** Horizontal scale factor */
29
- scaleX?: AnimatableValue;
30
- /** Vertical scale factor */
31
- scaleY?: AnimatableValue;
32
- /** Rotation angle in degrees (positive rotates clockwise) */
33
- rotate?: AnimatableValue;
34
- /** Horizontal skew angle in degrees */
35
- skewX?: AnimatableValue;
36
- /** Vertical skew angle in degrees */
37
- skewY?: AnimatableValue;
38
- };
39
- /**
40
- * Transition configuration for timed (duration-based) animations.
41
- *
42
- * @see {@link https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TimedAnimation.html Adw.TimedAnimation}
43
- */
44
- export type TimedTransition = {
45
- /** Animation duration in milliseconds (default: 300) */
46
- duration?: number;
47
- /** Easing function for the animation curve (default: EASE_OUT_CUBIC) */
48
- easing?: Easing;
49
- /** Delay before starting the animation in milliseconds */
50
- delay?: number;
51
- /** Number of times to repeat the animation (0 = no repeat, -1 = infinite) */
52
- repeat?: number;
53
- /** Whether to play the animation in reverse */
54
- reverse?: boolean;
55
- /** Whether to alternate direction on each repeat */
56
- alternate?: boolean;
57
- };
58
- /**
59
- * Transition configuration for spring (physics-based) animations.
60
- *
61
- * Spring animations simulate a mass attached to a spring, providing natural-feeling motion.
62
- * The animation settles when the spring reaches equilibrium.
63
- *
64
- * @see {@link https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.SpringAnimation.html Adw.SpringAnimation}
65
- */
66
- export type SpringTransition = {
67
- /** Damping ratio controlling oscillation decay (default: 1, critically damped) */
68
- damping?: number;
69
- /** Spring stiffness in N/m affecting animation speed (default: 100) */
70
- stiffness?: number;
71
- /** Virtual mass in kg affecting momentum (default: 1) */
72
- mass?: number;
73
- /** Initial velocity to apply at animation start */
74
- initialVelocity?: number;
75
- /** Whether to clamp the animation value to prevent overshooting */
76
- clamp?: boolean;
77
- /** Delay before starting the animation in milliseconds */
78
- delay?: number;
79
- };
80
- /**
81
- * Props for the Animation component.
82
- *
83
- * Provides a declarative API for animating widget properties using either
84
- * timed (duration-based) or spring (physics-based) animations.
85
- *
86
- * @typeParam M - The animation mode, either `"timed"` or `"spring"`
87
- *
88
- * @example
89
- * ```tsx
90
- * <x.Animation
91
- * mode="spring"
92
- * initial={{ opacity: 0, translateY: -20 }}
93
- * animate={{ opacity: 1, translateY: 0 }}
94
- * exit={{ opacity: 0, translateY: 20 }}
95
- * animateOnMount
96
- * >
97
- * <GtkLabel label="Animated content" />
98
- * </x.Animation>
99
- * ```
100
- */
101
- export type AnimationProps<M extends AnimationMode = AnimationMode> = {
102
- /** Animation type: `"timed"` for duration-based or `"spring"` for physics-based */
103
- mode: M;
104
- /** Initial property values before animation starts, or `false` to skip initial state */
105
- initial?: AnimatableProperties | false;
106
- /** Target property values to animate towards */
107
- animate?: AnimatableProperties;
108
- /** Property values to animate to when the component unmounts */
109
- exit?: AnimatableProperties;
110
- /** Transition configuration (type depends on mode) */
111
- transition?: M extends "timed" ? TimedTransition : SpringTransition;
112
- /** Whether to animate from `initial` to `animate` when first mounted (default: false) */
113
- animateOnMount?: boolean;
114
- /** Callback fired when an animation begins */
115
- onAnimationStart?: () => void;
116
- /** Callback fired when an animation completes */
117
- onAnimationComplete?: () => void;
118
- /** The child widget to animate (must be a single GTK widget) */
119
- children?: ReactNode;
120
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import type { Props } from "../../types.js";
3
- import { VirtualSingleChildNode } from "./virtual-single-child.js";
4
- export declare abstract class PositionalChildNode<P extends Props = Props> extends VirtualSingleChildNode<P> {
5
- protected abstract attachToParent(parent: Gtk.Widget, child: Gtk.Widget): void;
6
- protected abstract detachFromParent(parent: Gtk.Widget, child: Gtk.Widget): void;
7
- unmount(): void;
8
- protected onChildChange(oldChild: Gtk.Widget | null): void;
9
- }
@@ -1,29 +0,0 @@
1
- import { isObjectEqual } from "@gtkx/ffi";
2
- import { VirtualSingleChildNode } from "./virtual-single-child.js";
3
- export class PositionalChildNode extends VirtualSingleChildNode {
4
- unmount() {
5
- if (this.parent && this.child) {
6
- const parent = this.parent;
7
- const oldChild = this.child;
8
- this.child = null;
9
- const parentOfOld = oldChild.getParent();
10
- if (parentOfOld && isObjectEqual(parentOfOld, parent)) {
11
- this.detachFromParent(parent, oldChild);
12
- }
13
- }
14
- this.parent = null;
15
- super.unmount();
16
- }
17
- onChildChange(oldChild) {
18
- const parent = this.getParent();
19
- if (oldChild) {
20
- const parentOfOld = oldChild.getParent();
21
- if (parentOfOld && isObjectEqual(parentOfOld, parent)) {
22
- this.detachFromParent(parent, oldChild);
23
- }
24
- }
25
- if (this.child) {
26
- this.attachToParent(parent, this.child);
27
- }
28
- }
29
- }
@@ -1,21 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import type { Node } from "../../node.js";
3
- import type { Attachable } from "../internal/predicates.js";
4
- import { VirtualNode } from "../virtual.js";
5
- type ChildParentWidget = Gtk.Widget & {
6
- remove(child: Gtk.Widget): void;
7
- };
8
- export declare abstract class VirtualContainerNode<P extends ChildParentWidget = ChildParentWidget> extends VirtualNode implements Attachable {
9
- protected parent: P | null;
10
- setParent(newParent: P | null): void;
11
- protected getParent(): P;
12
- protected abstract attachChild(parent: P, widget: Gtk.Widget): void;
13
- canBeChildOf(parent: Node): boolean;
14
- attachTo(parent: Node): void;
15
- detachFrom(_parent: Node): void;
16
- unmount(): void;
17
- appendChild(child: Node): void;
18
- insertBefore(child: Node, _before: Node): void;
19
- removeChild(child: Node): void;
20
- }
21
- export {};