@gtkx/react 0.15.0 → 0.16.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 (186) hide show
  1. package/README.md +1 -0
  2. package/dist/errors.js +3 -0
  3. package/dist/factory.d.ts +3 -2
  4. package/dist/factory.js +1 -1
  5. package/dist/generated/internal.d.ts +28 -1
  6. package/dist/generated/internal.js +93 -18
  7. package/dist/generated/jsx.d.ts +1489 -1300
  8. package/dist/generated/jsx.js +475 -0
  9. package/dist/host-config.d.ts +3 -1
  10. package/dist/host-config.js +31 -11
  11. package/dist/jsx.d.ts +107 -166
  12. package/dist/jsx.js +58 -69
  13. package/dist/node.d.ts +3 -1
  14. package/dist/node.js +5 -3
  15. package/dist/nodes/abstract/positional-child.d.ts +9 -0
  16. package/dist/nodes/abstract/positional-child.js +29 -0
  17. package/dist/nodes/abstract/positional-parent.d.ts +18 -0
  18. package/dist/nodes/abstract/positional-parent.js +48 -0
  19. package/dist/nodes/abstract/virtual-container.d.ts +17 -0
  20. package/dist/nodes/abstract/virtual-container.js +59 -0
  21. package/dist/nodes/abstract/virtual-single-child.d.ts +18 -0
  22. package/dist/nodes/abstract/virtual-single-child.js +54 -0
  23. package/dist/nodes/action-row-child.d.ts +0 -13
  24. package/dist/nodes/action-row-child.js +14 -12
  25. package/dist/nodes/action-row.d.ts +6 -1
  26. package/dist/nodes/action-row.js +4 -37
  27. package/dist/nodes/adjustable.d.ts +23 -0
  28. package/dist/nodes/adjustable.js +62 -0
  29. package/dist/nodes/alert-dialog-response.d.ts +1 -0
  30. package/dist/nodes/alert-dialog-response.js +86 -0
  31. package/dist/nodes/animation/animation-controller.d.ts +17 -0
  32. package/dist/nodes/animation/animation-controller.js +107 -0
  33. package/dist/nodes/animation/animation-factory.d.ts +15 -0
  34. package/dist/nodes/animation/animation-factory.js +25 -0
  35. package/dist/nodes/animation/animation-node.d.ts +9 -0
  36. package/dist/nodes/animation/animation-node.js +126 -0
  37. package/dist/nodes/animation/animation-style-sheet.d.ts +16 -0
  38. package/dist/nodes/animation/animation-style-sheet.js +74 -0
  39. package/dist/nodes/animation/index.d.ts +4 -0
  40. package/dist/nodes/animation/index.js +1 -0
  41. package/dist/nodes/animation/property-mapper.d.ts +11 -0
  42. package/dist/nodes/animation/property-mapper.js +36 -0
  43. package/dist/nodes/animation/transform-state.d.ts +11 -0
  44. package/dist/nodes/animation/transform-state.js +57 -0
  45. package/dist/nodes/animation/widget-registry.d.ts +5 -0
  46. package/dist/nodes/animation/widget-registry.js +42 -0
  47. package/dist/nodes/application.js +17 -7
  48. package/dist/nodes/autowrapped.js +37 -43
  49. package/dist/nodes/calendar.js +17 -43
  50. package/dist/nodes/color-dialog-button.d.ts +1 -0
  51. package/dist/nodes/color-dialog-button.js +70 -0
  52. package/dist/nodes/column-view-column.d.ts +3 -3
  53. package/dist/nodes/column-view-column.js +1 -1
  54. package/dist/nodes/column-view.js +36 -39
  55. package/dist/nodes/dialog.d.ts +11 -0
  56. package/dist/nodes/dialog.js +20 -0
  57. package/dist/nodes/drawing-area.js +24 -7
  58. package/dist/nodes/event-controller.d.ts +1 -0
  59. package/dist/nodes/event-controller.js +96 -0
  60. package/dist/nodes/expander-row-child.d.ts +0 -14
  61. package/dist/nodes/expander-row-child.js +14 -12
  62. package/dist/nodes/expander-row.d.ts +6 -1
  63. package/dist/nodes/expander-row.js +11 -48
  64. package/dist/nodes/fixed-child.js +48 -36
  65. package/dist/nodes/font-dialog-button.d.ts +1 -0
  66. package/dist/nodes/font-dialog-button.js +90 -0
  67. package/dist/nodes/grid-child.js +39 -45
  68. package/dist/nodes/grid.d.ts +1 -0
  69. package/dist/nodes/grid.js +41 -0
  70. package/dist/nodes/index.d.ts +17 -9
  71. package/dist/nodes/index.js +17 -9
  72. package/dist/nodes/internal/base-item-renderer.d.ts +29 -0
  73. package/dist/nodes/internal/base-item-renderer.js +88 -0
  74. package/dist/nodes/internal/base-store.d.ts +9 -0
  75. package/dist/nodes/internal/base-store.js +20 -0
  76. package/dist/nodes/internal/child-attachment.d.ts +26 -0
  77. package/dist/nodes/internal/child-attachment.js +48 -0
  78. package/dist/nodes/internal/deferred-action.d.ts +8 -0
  79. package/dist/nodes/internal/deferred-action.js +19 -0
  80. package/dist/nodes/internal/list-item-renderer.d.ts +14 -15
  81. package/dist/nodes/internal/list-item-renderer.js +51 -77
  82. package/dist/nodes/internal/list-store.d.ts +7 -6
  83. package/dist/nodes/internal/list-store.js +20 -24
  84. package/dist/nodes/internal/predicates.d.ts +25 -2
  85. package/dist/nodes/internal/predicates.js +53 -41
  86. package/dist/nodes/internal/selection-model.d.ts +30 -0
  87. package/dist/nodes/internal/selection-model.js +91 -0
  88. package/dist/nodes/internal/signal-store.d.ts +5 -4
  89. package/dist/nodes/internal/signal-store.js +30 -28
  90. package/dist/nodes/internal/simple-list-store.js +6 -9
  91. package/dist/nodes/internal/text-buffer-controller.d.ts +43 -0
  92. package/dist/nodes/internal/text-buffer-controller.js +287 -0
  93. package/dist/nodes/internal/text-tag-styles.d.ts +43 -0
  94. package/dist/nodes/internal/text-tag-styles.js +52 -0
  95. package/dist/nodes/internal/tree-list-item-renderer.d.ts +15 -14
  96. package/dist/nodes/internal/tree-list-item-renderer.js +85 -96
  97. package/dist/nodes/internal/tree-store.d.ts +10 -9
  98. package/dist/nodes/internal/tree-store.js +31 -35
  99. package/dist/nodes/internal/utils.d.ts +7 -4
  100. package/dist/nodes/internal/utils.js +50 -5
  101. package/dist/nodes/level-bar.js +19 -54
  102. package/dist/nodes/list-item.d.ts +6 -3
  103. package/dist/nodes/list-item.js +7 -4
  104. package/dist/nodes/list-view.js +15 -11
  105. package/dist/nodes/menu.d.ts +3 -3
  106. package/dist/nodes/menu.js +3 -3
  107. package/dist/nodes/models/list.d.ts +11 -13
  108. package/dist/nodes/models/list.js +16 -73
  109. package/dist/nodes/models/menu.d.ts +8 -7
  110. package/dist/nodes/models/menu.js +43 -50
  111. package/dist/nodes/models/tree-list.d.ts +6 -12
  112. package/dist/nodes/models/tree-list.js +30 -93
  113. package/dist/nodes/navigation-page.d.ts +1 -0
  114. package/dist/nodes/navigation-page.js +27 -32
  115. package/dist/nodes/navigation-view.js +17 -28
  116. package/dist/nodes/notebook-page-tab.d.ts +3 -3
  117. package/dist/nodes/notebook-page-tab.js +11 -14
  118. package/dist/nodes/notebook-page.d.ts +7 -5
  119. package/dist/nodes/notebook-page.js +45 -25
  120. package/dist/nodes/notebook.js +2 -2
  121. package/dist/nodes/overlay-child.js +90 -30
  122. package/dist/nodes/pack-child.d.ts +0 -13
  123. package/dist/nodes/pack-child.js +14 -12
  124. package/dist/nodes/pack.d.ts +6 -1
  125. package/dist/nodes/pack.js +4 -37
  126. package/dist/nodes/popover-menu.js +2 -2
  127. package/dist/nodes/scale.js +15 -45
  128. package/dist/nodes/scrolled-window.js +7 -6
  129. package/dist/nodes/search-bar.d.ts +1 -0
  130. package/dist/nodes/search-bar.js +40 -0
  131. package/dist/nodes/shortcut-controller.d.ts +1 -37
  132. package/dist/nodes/shortcut-controller.js +24 -8
  133. package/dist/nodes/shortcut.d.ts +5 -4
  134. package/dist/nodes/shortcut.js +11 -5
  135. package/dist/nodes/simple-list-view.js +2 -3
  136. package/dist/nodes/slot.d.ts +6 -9
  137. package/dist/nodes/slot.js +27 -42
  138. package/dist/nodes/source-view.js +80 -29
  139. package/dist/nodes/stack-page.js +20 -22
  140. package/dist/nodes/stack.js +19 -5
  141. package/dist/nodes/text-anchor.d.ts +41 -0
  142. package/dist/nodes/text-anchor.js +59 -0
  143. package/dist/nodes/text-content.d.ts +10 -0
  144. package/dist/nodes/text-content.js +1 -0
  145. package/dist/nodes/text-paintable.d.ts +17 -0
  146. package/dist/nodes/text-paintable.js +34 -0
  147. package/dist/nodes/text-segment.d.ts +15 -0
  148. package/dist/nodes/text-segment.js +29 -0
  149. package/dist/nodes/text-tag.d.ts +136 -0
  150. package/dist/nodes/text-tag.js +202 -0
  151. package/dist/nodes/text-view.d.ts +30 -0
  152. package/dist/nodes/text-view.js +49 -21
  153. package/dist/nodes/toggle-group.js +24 -32
  154. package/dist/nodes/toggle.d.ts +1 -15
  155. package/dist/nodes/toggle.js +40 -32
  156. package/dist/nodes/toolbar-child.js +14 -16
  157. package/dist/nodes/tree-list-item.d.ts +7 -5
  158. package/dist/nodes/tree-list-item.js +24 -36
  159. package/dist/nodes/tree-list-view.js +7 -6
  160. package/dist/nodes/virtual.d.ts +1 -1
  161. package/dist/nodes/widget.d.ts +2 -16
  162. package/dist/nodes/widget.js +105 -294
  163. package/dist/nodes/window.d.ts +9 -3
  164. package/dist/nodes/window.js +29 -15
  165. package/dist/registry.d.ts +1 -1
  166. package/dist/render.js +8 -6
  167. package/dist/scheduler.d.ts +11 -1
  168. package/dist/scheduler.js +16 -4
  169. package/dist/types.d.ts +2 -136
  170. package/package.json +3 -3
  171. package/dist/nodes/adjustment.d.ts +0 -48
  172. package/dist/nodes/adjustment.js +0 -70
  173. package/dist/nodes/calendar-mark.d.ts +0 -15
  174. package/dist/nodes/calendar-mark.js +0 -29
  175. package/dist/nodes/internal/constants.d.ts +0 -1
  176. package/dist/nodes/internal/constants.js +0 -24
  177. package/dist/nodes/level-bar-offset.d.ts +0 -13
  178. package/dist/nodes/level-bar-offset.js +0 -35
  179. package/dist/nodes/scale-mark.d.ts +0 -17
  180. package/dist/nodes/scale-mark.js +0 -38
  181. package/dist/nodes/source-buffer.d.ts +0 -73
  182. package/dist/nodes/source-buffer.js +0 -149
  183. package/dist/nodes/text-buffer.d.ts +0 -43
  184. package/dist/nodes/text-buffer.js +0 -81
  185. package/dist/nodes/virtual-child.d.ts +0 -18
  186. package/dist/nodes/virtual-child.js +0 -62
package/dist/render.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { discardAllBatches, start, stop } from "@gtkx/ffi";
2
+ import { start, stop } from "@gtkx/ffi";
3
3
  import { createContext, useContext } from "react";
4
4
  import { formatBoundaryError, formatRenderError } from "./errors.js";
5
+ import { getSignalStore } from "./nodes/internal/signal-store.js";
5
6
  import { reconciler } from "./reconciler.js";
6
7
  /**
7
8
  * React Context providing access to the GTK Application instance.
@@ -96,17 +97,18 @@ export const setHotReloading = (value) => {
96
97
  * @see {@link update} for hot-reloading the rendered tree
97
98
  */
98
99
  export const render = (element, appId, flags) => {
99
- app = start(appId, flags);
100
+ const application = start(appId, flags);
101
+ app = application;
100
102
  const instance = reconciler.getInstance();
101
- container = instance.createContainer(app, 1, null, false, null, "", (error) => {
102
- discardAllBatches();
103
+ container = instance.createContainer(application, 1, null, false, null, "", (error) => {
104
+ getSignalStore(application).forceUnblockAll();
103
105
  throw formatRenderError(error);
104
106
  }, (error) => {
105
- discardAllBatches();
107
+ getSignalStore(application).forceUnblockAll();
106
108
  const formattedError = formatBoundaryError(error);
107
109
  console.error(formattedError.toString());
108
110
  }, () => { }, () => { }, null);
109
- instance.updateContainer(_jsx(ApplicationContext.Provider, { value: app, children: element }), container, null, () => { });
111
+ instance.updateContainer(_jsx(ApplicationContext.Provider, { value: application, children: element }), container, null, () => { });
110
112
  };
111
113
  /**
112
114
  * Updates the rendered React element tree.
@@ -1,10 +1,20 @@
1
1
  type Callback = () => void;
2
+ /**
3
+ * Priority levels for scheduling operations after React commit.
4
+ *
5
+ * Priority guidelines:
6
+ * - HIGH: Removals and detachments (must run before additions to avoid conflicts)
7
+ * - NORMAL: Additions and attachments (standard widget operations)
8
+ * - LOW: Sync operations that depend on all additions being complete (e.g., model updates)
9
+ *
10
+ * Within the same priority level, callbacks execute in FIFO order.
11
+ */
2
12
  export declare enum CommitPriority {
3
13
  /** Runs first. Used for widget removals to unparent before reparenting. */
4
14
  HIGH = 0,
5
15
  /** Runs after HIGH priority. Used for widget additions. */
6
16
  NORMAL = 1,
7
- /** Runs last. Used for model sync operations that need all data to be added first. */
17
+ /** Runs after NORMAL. Used for model sync operations that need all data to be added first. */
8
18
  LOW = 2
9
19
  }
10
20
  /**
package/dist/scheduler.js CHANGED
@@ -1,10 +1,20 @@
1
+ /**
2
+ * Priority levels for scheduling operations after React commit.
3
+ *
4
+ * Priority guidelines:
5
+ * - HIGH: Removals and detachments (must run before additions to avoid conflicts)
6
+ * - NORMAL: Additions and attachments (standard widget operations)
7
+ * - LOW: Sync operations that depend on all additions being complete (e.g., model updates)
8
+ *
9
+ * Within the same priority level, callbacks execute in FIFO order.
10
+ */
1
11
  export var CommitPriority;
2
12
  (function (CommitPriority) {
3
13
  /** Runs first. Used for widget removals to unparent before reparenting. */
4
14
  CommitPriority[CommitPriority["HIGH"] = 0] = "HIGH";
5
15
  /** Runs after HIGH priority. Used for widget additions. */
6
16
  CommitPriority[CommitPriority["NORMAL"] = 1] = "NORMAL";
7
- /** Runs last. Used for model sync operations that need all data to be added first. */
17
+ /** Runs after NORMAL. Used for model sync operations that need all data to be added first. */
8
18
  CommitPriority[CommitPriority["LOW"] = 2] = "LOW";
9
19
  })(CommitPriority || (CommitPriority = {}));
10
20
  const queues = {
@@ -22,9 +32,11 @@ export const scheduleAfterCommit = (callback, priority = CommitPriority.NORMAL)
22
32
  };
23
33
  export const flushAfterCommit = () => {
24
34
  for (const priority of priorities) {
25
- const callbacks = queues[priority].splice(0);
26
- for (const callback of callbacks) {
27
- callback();
35
+ const queue = queues[priority];
36
+ while (queue.length > 0) {
37
+ const callback = queue.shift();
38
+ if (callback)
39
+ callback();
28
40
  }
29
41
  }
30
42
  };
package/dist/types.d.ts CHANGED
@@ -1,138 +1,4 @@
1
- import type * as Gdk from "@gtkx/ffi/gdk";
2
- import type * as GObject from "@gtkx/ffi/gobject";
3
1
  import type * as Gtk from "@gtkx/ffi/gtk";
4
- export type Container = Gtk.Widget | Gtk.Application;
2
+ export type Container = Gtk.Widget | Gtk.Application | Gtk.EventController;
5
3
  export type Props = Record<string, unknown>;
6
- export type ContainerClass = typeof Gtk.Widget | typeof Gtk.Application;
7
- /**
8
- * Props for EventController-based event handlers.
9
- *
10
- * These props attach EventControllers to widgets for handling
11
- * pointer motion, clicks, keyboard events, and drag-and-drop.
12
- */
13
- export interface EventControllerProps {
14
- /** Called when the pointer enters the widget */
15
- onEnter?: (x: number, y: number) => void;
16
- /** Called when the pointer leaves the widget */
17
- onLeave?: () => void;
18
- /** Called when the pointer moves over the widget */
19
- onMotion?: (x: number, y: number) => void;
20
- /** Called when a mouse button is pressed */
21
- onPressed?: (nPress: number, x: number, y: number) => void;
22
- /** Called when a mouse button is released */
23
- onReleased?: (nPress: number, x: number, y: number) => void;
24
- /** Called when a key is pressed (for focusable widgets) */
25
- onKeyPressed?: (keyval: number, keycode: number, state: Gdk.ModifierType) => boolean;
26
- /** Called when a key is released */
27
- onKeyReleased?: (keyval: number, keycode: number, state: Gdk.ModifierType) => void;
28
- /** Called when the widget is scrolled */
29
- onScroll?: (dx: number, dy: number) => boolean;
30
- }
31
- /**
32
- * Props for DragSource controller.
33
- *
34
- * Enables dragging content from a widget. Attach a DragSource to make
35
- * a widget draggable.
36
- */
37
- export interface DragSourceProps {
38
- /**
39
- * Called when a drag is about to start. Return a ContentProvider with the data
40
- * to be dragged, or null to cancel the drag.
41
- * @param x - X coordinate where drag started
42
- * @param y - Y coordinate where drag started
43
- */
44
- onDragPrepare?: (x: number, y: number) => Gdk.ContentProvider | null;
45
- /**
46
- * Called when the drag operation begins.
47
- * @param drag - The Gdk.Drag object representing the ongoing drag
48
- */
49
- onDragBegin?: (drag: Gdk.Drag) => void;
50
- /**
51
- * Called when the drag operation ends.
52
- * @param drag - The Gdk.Drag object
53
- * @param deleteData - Whether the data should be deleted (for move operations)
54
- */
55
- onDragEnd?: (drag: Gdk.Drag, deleteData: boolean) => void;
56
- /**
57
- * Called when the drag operation is cancelled.
58
- * @param drag - The Gdk.Drag object
59
- * @param reason - The reason for cancellation
60
- * @returns true if the cancel was handled
61
- */
62
- onDragCancel?: (drag: Gdk.Drag, reason: Gdk.DragCancelReason) => boolean;
63
- /**
64
- * The allowed drag actions (COPY, MOVE, LINK, ASK).
65
- * Defaults to Gdk.DragAction.COPY if not specified.
66
- */
67
- dragActions?: Gdk.DragAction;
68
- }
69
- /**
70
- * Props for DropTarget controller.
71
- *
72
- * Enables dropping content onto a widget. Attach a DropTarget to make
73
- * a widget accept drops.
74
- */
75
- export interface DropTargetProps {
76
- /**
77
- * Called when content is dropped on the widget.
78
- * @param value - The dropped value (use value.getTypeName() to check type, then extract)
79
- * @param x - X coordinate of drop
80
- * @param y - Y coordinate of drop
81
- * @returns true if the drop was accepted
82
- */
83
- onDrop?: (value: GObject.Value, x: number, y: number) => boolean;
84
- /**
85
- * Called when a drag enters the widget bounds.
86
- * @param x - X coordinate
87
- * @param y - Y coordinate
88
- * @returns The preferred action, or 0 to reject
89
- */
90
- onDropEnter?: (x: number, y: number) => Gdk.DragAction;
91
- /**
92
- * Called when a drag leaves the widget bounds.
93
- */
94
- onDropLeave?: () => void;
95
- /**
96
- * Called when a drag moves within the widget bounds.
97
- * @param x - X coordinate
98
- * @param y - Y coordinate
99
- * @returns The preferred action, or 0 to reject
100
- */
101
- onDropMotion?: (x: number, y: number) => Gdk.DragAction;
102
- /**
103
- * The allowed drop actions (COPY, MOVE, LINK, ASK).
104
- * Defaults to Gdk.DragAction.COPY if not specified.
105
- */
106
- dropActions?: Gdk.DragAction;
107
- /**
108
- * Array of GTypes that this drop target accepts.
109
- * Use typeFromName() to get GType values (e.g., typeFromName("gchararray") for strings).
110
- */
111
- dropTypes?: number[];
112
- }
113
- /**
114
- * Props for GestureDrag controller.
115
- *
116
- * Enables tracking drag gestures (mouse/touch drag movements) on a widget.
117
- * Use this for drawing, panning, or any interaction that tracks movement from a start point.
118
- */
119
- export interface GestureDragProps {
120
- /**
121
- * Called when a drag gesture begins.
122
- * @param startX - X coordinate where the drag started
123
- * @param startY - Y coordinate where the drag started
124
- */
125
- onGestureDragBegin?: (startX: number, startY: number) => void;
126
- /**
127
- * Called as the drag gesture continues.
128
- * @param offsetX - Horizontal offset from the start point
129
- * @param offsetY - Vertical offset from the start point
130
- */
131
- onGestureDragUpdate?: (offsetX: number, offsetY: number) => void;
132
- /**
133
- * Called when the drag gesture ends.
134
- * @param offsetX - Final horizontal offset from the start point
135
- * @param offsetY - Final vertical offset from the start point
136
- */
137
- onGestureDragEnd?: (offsetX: number, offsetY: number) => void;
138
- }
4
+ export type ContainerClass = typeof Gtk.Widget | typeof Gtk.Application | typeof Gtk.EventController;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/react",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Build GTK4 desktop applications with React and TypeScript",
5
5
  "keywords": [
6
6
  "gtkx",
@@ -37,8 +37,8 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "react-reconciler": "^0.33.0",
40
- "@gtkx/gir": "0.15.0",
41
- "@gtkx/ffi": "0.15.0"
40
+ "@gtkx/ffi": "0.16.0",
41
+ "@gtkx/gir": "0.16.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/react-reconciler": "^0.32.3"
@@ -1,48 +0,0 @@
1
- import type { AdjustableWidget } from "./internal/predicates.js";
2
- import { VirtualNode } from "./virtual.js";
3
- /**
4
- * Props for the Adjustment virtual element.
5
- *
6
- * Used to declaratively configure the adjustment for adjustable widgets
7
- * such as Scale, Scrollbar, ScaleButton, SpinButton, and ListBox.
8
- *
9
- * @example
10
- * ```tsx
11
- * <GtkScale>
12
- * <x.Adjustment
13
- * value={50}
14
- * lower={0}
15
- * upper={100}
16
- * stepIncrement={1}
17
- * onValueChanged={(v) => console.log("Value:", v)}
18
- * />
19
- * </GtkScale>
20
- * ```
21
- */
22
- export type AdjustmentProps = {
23
- /** The current value */
24
- value?: number;
25
- /** The minimum value */
26
- lower?: number;
27
- /** The maximum value */
28
- upper?: number;
29
- /** The increment for arrow keys */
30
- stepIncrement?: number;
31
- /** The increment for page up/down */
32
- pageIncrement?: number;
33
- /** The page size (usually 0 for scales) */
34
- pageSize?: number;
35
- /** Callback when the value changes */
36
- onValueChanged?: (value: number) => void;
37
- };
38
- export declare class AdjustmentNode extends VirtualNode<AdjustmentProps> {
39
- static priority: number;
40
- private widget?;
41
- private adjustment?;
42
- static matches(type: string): boolean;
43
- setWidget(widget: AdjustableWidget): void;
44
- private setupAdjustment;
45
- private updateSignalHandler;
46
- updateProps(oldProps: AdjustmentProps | null, newProps: AdjustmentProps): void;
47
- unmount(): void;
48
- }
@@ -1,70 +0,0 @@
1
- import * as Gtk from "@gtkx/ffi/gtk";
2
- import { registerNodeClass } from "../registry.js";
3
- import { signalStore } from "./internal/signal-store.js";
4
- import { VirtualNode } from "./virtual.js";
5
- export class AdjustmentNode extends VirtualNode {
6
- static priority = 1;
7
- widget;
8
- adjustment;
9
- static matches(type) {
10
- return type === "Adjustment";
11
- }
12
- setWidget(widget) {
13
- this.widget = widget;
14
- this.setupAdjustment();
15
- }
16
- setupAdjustment() {
17
- if (!this.widget)
18
- return;
19
- const { value = 0, lower = 0, upper = 100, stepIncrement = 1, pageIncrement = 10, pageSize = 0 } = this.props;
20
- this.adjustment = new Gtk.Adjustment(value, lower, upper, stepIncrement, pageIncrement, pageSize);
21
- this.widget.setAdjustment(this.adjustment);
22
- this.updateSignalHandler();
23
- }
24
- updateSignalHandler() {
25
- if (!this.adjustment)
26
- return;
27
- const { onValueChanged } = this.props;
28
- if (onValueChanged) {
29
- const adjustment = this.adjustment;
30
- signalStore.set(this, adjustment, "value-changed", () => onValueChanged(adjustment.getValue()));
31
- }
32
- else {
33
- signalStore.set(this, this.adjustment, "value-changed", null);
34
- }
35
- }
36
- updateProps(oldProps, newProps) {
37
- super.updateProps(oldProps, newProps);
38
- if (!this.adjustment)
39
- return;
40
- if (!oldProps || oldProps.lower !== newProps.lower) {
41
- this.adjustment.setLower(newProps.lower ?? 0);
42
- }
43
- if (!oldProps || oldProps.upper !== newProps.upper) {
44
- this.adjustment.setUpper(newProps.upper ?? 100);
45
- }
46
- if (!oldProps || oldProps.stepIncrement !== newProps.stepIncrement) {
47
- this.adjustment.setStepIncrement(newProps.stepIncrement ?? 1);
48
- }
49
- if (!oldProps || oldProps.pageIncrement !== newProps.pageIncrement) {
50
- this.adjustment.setPageIncrement(newProps.pageIncrement ?? 10);
51
- }
52
- if (!oldProps || oldProps.pageSize !== newProps.pageSize) {
53
- this.adjustment.setPageSize(newProps.pageSize ?? 0);
54
- }
55
- if (!oldProps || oldProps.value !== newProps.value) {
56
- if (newProps.value !== undefined) {
57
- this.adjustment.setValue(newProps.value);
58
- }
59
- }
60
- if (!oldProps || oldProps.onValueChanged !== newProps.onValueChanged) {
61
- this.updateSignalHandler();
62
- }
63
- }
64
- unmount() {
65
- this.adjustment = undefined;
66
- this.widget = undefined;
67
- super.unmount();
68
- }
69
- }
70
- registerNodeClass(AdjustmentNode);
@@ -1,15 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import { VirtualNode } from "./virtual.js";
3
- export type CalendarMarkProps = {
4
- day: number;
5
- };
6
- export declare class CalendarMarkNode extends VirtualNode<CalendarMarkProps> {
7
- static priority: number;
8
- private calendar?;
9
- private onRebuild?;
10
- static matches(type: string): boolean;
11
- setCalendar(calendar: Gtk.Calendar, onRebuild: () => void): void;
12
- addMark(): void;
13
- updateProps(oldProps: CalendarMarkProps | null, newProps: CalendarMarkProps): void;
14
- unmount(): void;
15
- }
@@ -1,29 +0,0 @@
1
- import { registerNodeClass } from "../registry.js";
2
- import { VirtualNode } from "./virtual.js";
3
- export class CalendarMarkNode extends VirtualNode {
4
- static priority = 1;
5
- calendar;
6
- onRebuild;
7
- static matches(type) {
8
- return type === "CalendarMark";
9
- }
10
- setCalendar(calendar, onRebuild) {
11
- this.calendar = calendar;
12
- this.onRebuild = onRebuild;
13
- }
14
- addMark() {
15
- this.calendar?.markDay(this.props.day);
16
- }
17
- updateProps(oldProps, newProps) {
18
- super.updateProps(oldProps, newProps);
19
- if (oldProps && this.calendar && oldProps.day !== newProps.day) {
20
- this.onRebuild?.();
21
- }
22
- }
23
- unmount() {
24
- this.calendar = undefined;
25
- this.onRebuild = undefined;
26
- super.unmount();
27
- }
28
- }
29
- registerNodeClass(CalendarMarkNode);
@@ -1 +0,0 @@
1
- export declare const EVENT_CONTROLLER_PROPS: Set<string>;
@@ -1,24 +0,0 @@
1
- export const EVENT_CONTROLLER_PROPS = new Set([
2
- "onEnter",
3
- "onLeave",
4
- "onMotion",
5
- "onPressed",
6
- "onReleased",
7
- "onKeyPressed",
8
- "onKeyReleased",
9
- "onScroll",
10
- "onDragPrepare",
11
- "onDragBegin",
12
- "onDragEnd",
13
- "onDragCancel",
14
- "dragActions",
15
- "onDrop",
16
- "onDropEnter",
17
- "onDropLeave",
18
- "onDropMotion",
19
- "dropActions",
20
- "dropTypes",
21
- "onGestureDragBegin",
22
- "onGestureDragUpdate",
23
- "onGestureDragEnd",
24
- ]);
@@ -1,13 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import type { LevelBarOffsetProps } from "../jsx.js";
3
- import { VirtualNode } from "./virtual.js";
4
- export declare class LevelBarOffsetNode extends VirtualNode<LevelBarOffsetProps> {
5
- static priority: number;
6
- private levelBar?;
7
- private onRebuild?;
8
- static matches(type: string): boolean;
9
- setLevelBar(levelBar: Gtk.LevelBar, onRebuild: () => void): void;
10
- addOffset(): string | undefined;
11
- updateProps(oldProps: LevelBarOffsetProps | null, newProps: LevelBarOffsetProps): void;
12
- unmount(): void;
13
- }
@@ -1,35 +0,0 @@
1
- import { registerNodeClass } from "../registry.js";
2
- import { VirtualNode } from "./virtual.js";
3
- export class LevelBarOffsetNode extends VirtualNode {
4
- static priority = 1;
5
- levelBar;
6
- onRebuild;
7
- static matches(type) {
8
- return type === "LevelBarOffset";
9
- }
10
- setLevelBar(levelBar, onRebuild) {
11
- this.levelBar = levelBar;
12
- this.onRebuild = onRebuild;
13
- }
14
- addOffset() {
15
- if (!this.levelBar)
16
- return undefined;
17
- this.levelBar.addOffsetValue(this.props.id, this.props.value);
18
- return this.props.id;
19
- }
20
- updateProps(oldProps, newProps) {
21
- super.updateProps(oldProps, newProps);
22
- if (oldProps && this.levelBar) {
23
- const changed = oldProps.id !== newProps.id || oldProps.value !== newProps.value;
24
- if (changed) {
25
- this.onRebuild?.();
26
- }
27
- }
28
- }
29
- unmount() {
30
- this.levelBar = undefined;
31
- this.onRebuild = undefined;
32
- super.unmount();
33
- }
34
- }
35
- registerNodeClass(LevelBarOffsetNode);
@@ -1,17 +0,0 @@
1
- import * as Gtk from "@gtkx/ffi/gtk";
2
- import { VirtualNode } from "./virtual.js";
3
- export type ScaleMarkProps = {
4
- value: number;
5
- position?: Gtk.PositionType;
6
- label?: string | null;
7
- };
8
- export declare class ScaleMarkNode extends VirtualNode<ScaleMarkProps> {
9
- static priority: number;
10
- private scale?;
11
- private onRebuild?;
12
- static matches(type: string): boolean;
13
- setScale(scale: Gtk.Scale, onRebuild: () => void): void;
14
- addMark(): void;
15
- updateProps(oldProps: ScaleMarkProps | null, newProps: ScaleMarkProps): void;
16
- unmount(): void;
17
- }
@@ -1,38 +0,0 @@
1
- import * as Gtk from "@gtkx/ffi/gtk";
2
- import { registerNodeClass } from "../registry.js";
3
- import { VirtualNode } from "./virtual.js";
4
- export class ScaleMarkNode extends VirtualNode {
5
- static priority = 1;
6
- scale;
7
- onRebuild;
8
- static matches(type) {
9
- return type === "ScaleMark";
10
- }
11
- setScale(scale, onRebuild) {
12
- this.scale = scale;
13
- this.onRebuild = onRebuild;
14
- }
15
- addMark() {
16
- if (!this.scale)
17
- return;
18
- const { value, position, label } = this.props;
19
- this.scale.addMark(value, position ?? Gtk.PositionType.BOTTOM, label);
20
- }
21
- updateProps(oldProps, newProps) {
22
- super.updateProps(oldProps, newProps);
23
- if (oldProps && this.scale) {
24
- const changed = oldProps.value !== newProps.value ||
25
- oldProps.position !== newProps.position ||
26
- oldProps.label !== newProps.label;
27
- if (changed) {
28
- this.onRebuild?.();
29
- }
30
- }
31
- }
32
- unmount() {
33
- this.scale = undefined;
34
- this.onRebuild = undefined;
35
- super.unmount();
36
- }
37
- }
38
- registerNodeClass(ScaleMarkNode);
@@ -1,73 +0,0 @@
1
- import * as Gtk from "@gtkx/ffi/gtk";
2
- import * as GtkSource from "@gtkx/ffi/gtksource";
3
- import { VirtualNode } from "./virtual.js";
4
- /**
5
- * Props for the SourceBuffer virtual element.
6
- *
7
- * Used to declaratively configure the text buffer for a GtkSourceView with syntax highlighting,
8
- * bracket matching, and other source code editing features.
9
- *
10
- * @example
11
- * ```tsx
12
- * <GtkSourceView>
13
- * <x.SourceBuffer
14
- * text={sourceCode}
15
- * language="typescript"
16
- * styleScheme="Adwaita-dark"
17
- * highlightSyntax
18
- * highlightMatchingBrackets
19
- * onTextChanged={(text) => console.log("Code:", text)}
20
- * />
21
- * </GtkSourceView>
22
- * ```
23
- */
24
- export type SourceBufferProps = {
25
- /** Text content */
26
- text?: string;
27
- /** Whether to enable undo/redo */
28
- enableUndo?: boolean;
29
- /** Callback when the text content changes */
30
- onTextChanged?: (text: string) => void;
31
- /** Callback when can-undo state changes */
32
- onCanUndoChanged?: (canUndo: boolean) => void;
33
- /** Callback when can-redo state changes */
34
- onCanRedoChanged?: (canRedo: boolean) => void;
35
- /**
36
- * Language for syntax highlighting.
37
- * Can be a language ID string (e.g., "typescript", "python", "rust") or a GtkSource.Language object.
38
- */
39
- language?: string | GtkSource.Language;
40
- /**
41
- * Style scheme for syntax highlighting colors.
42
- * Can be a scheme ID string (e.g., "Adwaita-dark", "classic") or a GtkSource.StyleScheme object.
43
- */
44
- styleScheme?: string | GtkSource.StyleScheme;
45
- /** Whether to enable syntax highlighting. Defaults to true when language is set. */
46
- highlightSyntax?: boolean;
47
- /** Whether to highlight matching brackets when cursor is on a bracket. Defaults to true. */
48
- highlightMatchingBrackets?: boolean;
49
- /**
50
- * Whether the buffer has an implicit trailing newline.
51
- * When true (default), trailing newlines are handled automatically during file load/save.
52
- */
53
- implicitTrailingNewline?: boolean;
54
- /** Callback when the cursor position changes */
55
- onCursorMoved?: () => void;
56
- /** Callback when syntax highlighting is updated for a region */
57
- onHighlightUpdated?: (start: Gtk.TextIter, end: Gtk.TextIter) => void;
58
- };
59
- export declare class SourceBufferNode extends VirtualNode<SourceBufferProps> {
60
- static priority: number;
61
- private sourceView?;
62
- private buffer?;
63
- static matches(type: string): boolean;
64
- setSourceView(sourceView: GtkSource.View): void;
65
- private resolveLanguage;
66
- private resolveStyleScheme;
67
- private setupBuffer;
68
- private applySourceProps;
69
- private getBufferText;
70
- private updateSignalHandlers;
71
- updateProps(oldProps: SourceBufferProps | null, newProps: SourceBufferProps): void;
72
- unmount(): void;
73
- }