@gtkx/react 0.17.3 → 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 (193) hide show
  1. package/dist/factory.d.ts +0 -1
  2. package/dist/factory.js +21 -8
  3. package/dist/generated/internal.d.ts +4 -51
  4. package/dist/generated/internal.js +626 -412
  5. package/dist/generated/jsx.d.ts +453 -958
  6. package/dist/host-config.d.ts +1 -1
  7. package/dist/host-config.js +18 -23
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/jsx.d.ts +579 -302
  11. package/dist/jsx.js +37 -179
  12. package/dist/metadata.d.ts +3 -0
  13. package/dist/metadata.js +26 -0
  14. package/dist/node.d.ts +20 -12
  15. package/dist/node.js +72 -17
  16. package/dist/nodes/adjustable.d.ts +3 -16
  17. package/dist/nodes/adjustable.js +5 -22
  18. package/dist/nodes/alert-dialog-response.d.ts +14 -1
  19. package/dist/nodes/alert-dialog-response.js +36 -62
  20. package/dist/nodes/animation.d.ts +37 -1
  21. package/dist/nodes/animation.js +162 -105
  22. package/dist/nodes/application.d.ts +11 -1
  23. package/dist/nodes/application.js +17 -38
  24. package/dist/nodes/calendar.d.ts +13 -0
  25. package/dist/nodes/calendar.js +10 -16
  26. package/dist/nodes/color-dialog-button.d.ts +13 -0
  27. package/dist/nodes/color-dialog-button.js +10 -38
  28. package/dist/nodes/column-view-column.d.ts +13 -11
  29. package/dist/nodes/column-view-column.js +27 -23
  30. package/dist/nodes/column-view.d.ts +31 -0
  31. package/dist/nodes/column-view.js +44 -44
  32. package/dist/nodes/container-slot.d.ts +15 -0
  33. package/dist/nodes/container-slot.js +68 -0
  34. package/dist/nodes/dialog.d.ts +6 -8
  35. package/dist/nodes/dialog.js +12 -13
  36. package/dist/nodes/drawing-area.d.ts +12 -0
  37. package/dist/nodes/drawing-area.js +24 -24
  38. package/dist/nodes/drop-down.d.ts +22 -0
  39. package/dist/nodes/drop-down.js +72 -0
  40. package/dist/nodes/event-controller.d.ts +8 -17
  41. package/dist/nodes/event-controller.js +20 -42
  42. package/dist/nodes/fixed-child.d.ts +18 -1
  43. package/dist/nodes/fixed-child.js +52 -36
  44. package/dist/nodes/font-dialog-button.d.ts +13 -0
  45. package/dist/nodes/font-dialog-button.js +12 -35
  46. package/dist/nodes/grid-child.d.ts +17 -1
  47. package/dist/nodes/grid-child.js +57 -37
  48. package/dist/nodes/grid-view.d.ts +24 -0
  49. package/dist/nodes/grid-view.js +73 -0
  50. package/dist/nodes/internal/base-item-renderer.d.ts +7 -9
  51. package/dist/nodes/internal/base-item-renderer.js +15 -18
  52. package/dist/nodes/internal/grid-item-renderer.d.ts +17 -0
  53. package/dist/nodes/internal/grid-item-renderer.js +59 -0
  54. package/dist/nodes/internal/list-item-renderer.d.ts +14 -9
  55. package/dist/nodes/internal/list-item-renderer.js +96 -35
  56. package/dist/nodes/internal/list-store.d.ts +5 -0
  57. package/dist/nodes/internal/list-store.js +39 -9
  58. package/dist/nodes/internal/predicates.d.ts +4 -19
  59. package/dist/nodes/internal/predicates.js +1 -20
  60. package/dist/nodes/internal/props.d.ts +5 -0
  61. package/dist/nodes/internal/props.js +42 -0
  62. package/dist/nodes/internal/{selection-model.d.ts → selection-model-controller.d.ts} +4 -9
  63. package/dist/nodes/internal/{selection-model.js → selection-model-controller.js} +6 -15
  64. package/dist/nodes/internal/signal-store.js +12 -5
  65. package/dist/nodes/internal/simple-list-store.d.ts +5 -0
  66. package/dist/nodes/internal/simple-list-store.js +42 -13
  67. package/dist/nodes/internal/text-buffer-controller.d.ts +4 -12
  68. package/dist/nodes/internal/text-buffer-controller.js +32 -33
  69. package/dist/nodes/internal/tree-store.d.ts +7 -0
  70. package/dist/nodes/internal/tree-store.js +75 -18
  71. package/dist/nodes/internal/widget.d.ts +7 -0
  72. package/dist/nodes/internal/widget.js +68 -0
  73. package/dist/nodes/level-bar.d.ts +10 -0
  74. package/dist/nodes/level-bar.js +11 -22
  75. package/dist/nodes/list-item.d.ts +17 -9
  76. package/dist/nodes/list-item.js +67 -12
  77. package/dist/nodes/list-view.d.ts +23 -0
  78. package/dist/nodes/list-view.js +27 -31
  79. package/dist/nodes/menu.d.ts +2 -4
  80. package/dist/nodes/menu.js +0 -6
  81. package/dist/nodes/models/grid.d.ts +27 -0
  82. package/dist/nodes/models/grid.js +68 -0
  83. package/dist/nodes/models/list.d.ts +15 -13
  84. package/dist/nodes/models/list.js +48 -26
  85. package/dist/nodes/models/menu.d.ts +15 -16
  86. package/dist/nodes/models/menu.js +63 -93
  87. package/dist/nodes/navigation-page.d.ts +16 -10
  88. package/dist/nodes/navigation-page.js +108 -31
  89. package/dist/nodes/navigation-view.d.ts +15 -0
  90. package/dist/nodes/navigation-view.js +15 -65
  91. package/dist/nodes/notebook-page-tab.d.ts +10 -12
  92. package/dist/nodes/notebook-page-tab.js +24 -27
  93. package/dist/nodes/notebook-page.d.ts +19 -16
  94. package/dist/nodes/notebook-page.js +75 -56
  95. package/dist/nodes/notebook.d.ts +10 -1
  96. package/dist/nodes/notebook.js +10 -22
  97. package/dist/nodes/overlay-child.d.ts +17 -1
  98. package/dist/nodes/overlay-child.js +53 -75
  99. package/dist/nodes/popover-menu.d.ts +15 -0
  100. package/dist/nodes/popover-menu.js +13 -26
  101. package/dist/nodes/scale.d.ts +8 -0
  102. package/dist/nodes/scale.js +2 -11
  103. package/dist/nodes/scrolled-window.d.ts +9 -0
  104. package/dist/nodes/scrolled-window.js +5 -11
  105. package/dist/nodes/search-bar.d.ts +9 -0
  106. package/dist/nodes/search-bar.js +8 -33
  107. package/dist/nodes/shortcut-controller.d.ts +9 -1
  108. package/dist/nodes/shortcut-controller.js +12 -25
  109. package/dist/nodes/shortcut.d.ts +11 -33
  110. package/dist/nodes/shortcut.js +19 -15
  111. package/dist/nodes/slot.d.ts +16 -15
  112. package/dist/nodes/slot.js +63 -57
  113. package/dist/nodes/source-view.d.ts +16 -0
  114. package/dist/nodes/source-view.js +44 -44
  115. package/dist/nodes/stack-page.d.ts +21 -1
  116. package/dist/nodes/stack-page.js +68 -17
  117. package/dist/nodes/stack.d.ts +11 -0
  118. package/dist/nodes/stack.js +8 -26
  119. package/dist/nodes/text-anchor.d.ts +11 -30
  120. package/dist/nodes/text-anchor.js +20 -22
  121. package/dist/nodes/text-content.d.ts +1 -0
  122. package/dist/nodes/text-content.js +1 -1
  123. package/dist/nodes/text-paintable.d.ts +10 -15
  124. package/dist/nodes/text-paintable.js +16 -9
  125. package/dist/nodes/text-segment.d.ts +12 -10
  126. package/dist/nodes/text-segment.js +19 -11
  127. package/dist/nodes/text-tag.d.ts +20 -119
  128. package/dist/nodes/text-tag.js +153 -119
  129. package/dist/nodes/text-view.d.ts +13 -18
  130. package/dist/nodes/text-view.js +17 -17
  131. package/dist/nodes/toggle-group.d.ts +9 -0
  132. package/dist/nodes/toggle-group.js +8 -33
  133. package/dist/nodes/toggle.d.ts +15 -1
  134. package/dist/nodes/toggle.js +34 -52
  135. package/dist/nodes/virtual.d.ts +3 -10
  136. package/dist/nodes/virtual.js +1 -14
  137. package/dist/nodes/web-view.d.ts +9 -0
  138. package/dist/nodes/web-view.js +10 -24
  139. package/dist/nodes/widget.d.ts +17 -13
  140. package/dist/nodes/widget.js +185 -112
  141. package/dist/nodes/window.d.ts +20 -21
  142. package/dist/nodes/window.js +54 -35
  143. package/dist/registry.d.ts +17 -6
  144. package/dist/registry.js +104 -5
  145. package/dist/render.d.ts +0 -9
  146. package/dist/render.js +0 -11
  147. package/package.json +3 -3
  148. package/dist/animation/css-builder.d.ts +0 -3
  149. package/dist/animation/css-builder.js +0 -53
  150. package/dist/animation/types.d.ts +0 -120
  151. package/dist/animation/types.js +0 -1
  152. package/dist/nodes/abstract/positional-child.d.ts +0 -9
  153. package/dist/nodes/abstract/positional-child.js +0 -29
  154. package/dist/nodes/abstract/virtual-container.d.ts +0 -21
  155. package/dist/nodes/abstract/virtual-container.js +0 -68
  156. package/dist/nodes/abstract/virtual-single-child.d.ts +0 -18
  157. package/dist/nodes/abstract/virtual-single-child.js +0 -55
  158. package/dist/nodes/action-row-child.d.ts +0 -1
  159. package/dist/nodes/action-row-child.js +0 -30
  160. package/dist/nodes/autowrapped.d.ts +0 -1
  161. package/dist/nodes/autowrapped.js +0 -115
  162. package/dist/nodes/expander-row-child.d.ts +0 -1
  163. package/dist/nodes/expander-row-child.js +0 -30
  164. package/dist/nodes/grid.d.ts +0 -1
  165. package/dist/nodes/grid.js +0 -41
  166. package/dist/nodes/index.d.ts +0 -56
  167. package/dist/nodes/index.js +0 -56
  168. package/dist/nodes/internal/child-attachment.d.ts +0 -26
  169. package/dist/nodes/internal/child-attachment.js +0 -48
  170. package/dist/nodes/internal/deferred-action.d.ts +0 -9
  171. package/dist/nodes/internal/deferred-action.js +0 -22
  172. package/dist/nodes/internal/text-tag-styles.d.ts +0 -43
  173. package/dist/nodes/internal/text-tag-styles.js +0 -52
  174. package/dist/nodes/internal/tree-list-item-renderer.d.ts +0 -26
  175. package/dist/nodes/internal/tree-list-item-renderer.js +0 -134
  176. package/dist/nodes/internal/utils.d.ts +0 -12
  177. package/dist/nodes/internal/utils.js +0 -92
  178. package/dist/nodes/models/tree-list.d.ts +0 -28
  179. package/dist/nodes/models/tree-list.js +0 -113
  180. package/dist/nodes/pack-child.d.ts +0 -1
  181. package/dist/nodes/pack-child.js +0 -30
  182. package/dist/nodes/simple-list-item.d.ts +0 -9
  183. package/dist/nodes/simple-list-item.js +0 -9
  184. package/dist/nodes/simple-list-view.d.ts +0 -1
  185. package/dist/nodes/simple-list-view.js +0 -74
  186. package/dist/nodes/toolbar-child.d.ts +0 -1
  187. package/dist/nodes/toolbar-child.js +0 -30
  188. package/dist/nodes/tree-list-item.d.ts +0 -22
  189. package/dist/nodes/tree-list-item.js +0 -90
  190. package/dist/nodes/tree-list-view.d.ts +0 -1
  191. package/dist/nodes/tree-list-view.js +0 -77
  192. package/dist/scheduler.d.ts +0 -26
  193. package/dist/scheduler.js +0 -42
package/dist/factory.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type { Node } from "./node.js";
2
2
  import type { Container, ContainerClass, Props } from "./types.js";
3
- import "./nodes/index.js";
4
3
  export declare const resolveContainerClass: (type: string) => ContainerClass | null;
5
4
  export declare const createNode: (typeName: string, props: Props, existingContainer: Container | undefined, rootContainer: Container) => Node;
package/dist/factory.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { NAMESPACE_REGISTRY } from "./generated/registry.js";
2
- import { NODE_CLASSES } from "./registry.js";
3
- import "./nodes/index.js";
2
+ import { NODE_REGISTRY } from "./registry.js";
4
3
  export const resolveContainerClass = (type) => {
5
4
  for (const [prefix, namespace] of NAMESPACE_REGISTRY) {
6
5
  if (type.startsWith(prefix)) {
@@ -10,14 +9,28 @@ export const resolveContainerClass = (type) => {
10
9
  }
11
10
  return null;
12
11
  };
12
+ const matchesSingleKey = (key, typeName, target) => {
13
+ if (typeof key === "string") {
14
+ return key === typeName;
15
+ }
16
+ return !!target && (target instanceof key || target === key || Object.prototype.isPrototypeOf.call(key, target));
17
+ };
18
+ const matchesKey = (key, typeName, target) => {
19
+ if (typeof key === "string" || typeof key === "function") {
20
+ return matchesSingleKey(key, typeName, target);
21
+ }
22
+ return key.some((k) => matchesSingleKey(k, typeName, target));
23
+ };
13
24
  export const createNode = (typeName, props, existingContainer, rootContainer) => {
14
25
  const containerClass = resolveContainerClass(typeName);
15
- for (const NodeClass of NODE_CLASSES) {
16
- if (NodeClass.matches(typeName, existingContainer ?? containerClass)) {
17
- const container = existingContainer ??
18
- (containerClass && NodeClass.createContainer(props, containerClass, rootContainer));
19
- return new NodeClass(typeName, props, container, rootContainer);
20
- }
26
+ for (const [key, NodeClass] of NODE_REGISTRY) {
27
+ if (!matchesKey(key, typeName, existingContainer ?? containerClass))
28
+ continue;
29
+ return instantiateNode(NodeClass, typeName, props, existingContainer, containerClass, rootContainer);
21
30
  }
22
31
  throw new Error(`Unable to find node class for type '${typeName}'`);
23
32
  };
33
+ const instantiateNode = (NodeClass, typeName, props, existingContainer, containerClass, rootContainer) => {
34
+ const container = existingContainer ?? (containerClass && NodeClass.createContainer(props, containerClass, rootContainer));
35
+ return new NodeClass(typeName, props, container, rootContainer);
36
+ };
@@ -1,57 +1,10 @@
1
1
  /**
2
2
  * Internal metadata for the reconciler.
3
- * This is the SINGLE SOURCE OF TRUTH for widget classification.
3
+ * Runtime prop/signal resolution and constructor parameters.
4
4
  * Not part of the public API.
5
5
  */
6
- import * as Adw from "@gtkx/ffi/adw";
7
- import * as Gtk from "@gtkx/ffi/gtk";
8
- /** List widgets that require renderItem prop. */
9
- export declare const LIST_WIDGET_CLASSES: readonly [typeof Gtk.GridView, typeof Gtk.ListView];
10
- /** Dropdown widgets with special item handling. */
11
- export declare const DROP_DOWN_CLASSES: readonly [typeof Adw.ComboRow, typeof Gtk.DropDown];
12
- /** Column view widgets with column-based layout. */
13
- export declare const COLUMN_VIEW_CLASSES: readonly [typeof Gtk.ColumnView];
14
- /** Widgets that auto-wrap children (ListBox wraps in ListBoxRow, FlowBox wraps in FlowBoxChild). */
15
- export declare const AUTOWRAP_CLASSES: readonly [typeof Gtk.FlowBox, typeof Gtk.ListBox];
16
- /** Stack widgets that show one child at a time. */
17
- export declare const STACK_CLASSES: readonly [typeof Gtk.Stack, typeof Adw.ViewStack];
18
- /** Notebook widgets with tabbed interface. */
19
- export declare const NOTEBOOK_CLASSES: readonly [typeof Gtk.Notebook];
20
- /** Widgets that support popover menu children. */
21
- export declare const POPOVER_MENU_CLASSES: readonly [typeof Gtk.MenuButton, typeof Gtk.PopoverMenu, typeof Gtk.PopoverMenuBar];
22
- /** Methods that define the packable interface (pack start/end positioning). */
23
- export declare const PACK_INTERFACE_METHODS: string[];
24
- /** Methods that define the prefix/suffix interface (Adwaita action rows). */
25
- export declare const PREFIX_SUFFIX_INTERFACE_METHODS: string[];
26
- /** Methods that define the adjustable interface (widgets with GtkAdjustment). */
27
- export declare const ADJUSTABLE_INTERFACE_METHODS: string[];
28
- /** Constructor parameters for each widget type, derived from GIR analysis. */
6
+ /** Constructor parameters for each widget and controller type, derived from GIR analysis. */
29
7
  export declare const CONSTRUCTOR_PROPS: Record<string, string[]>;
30
8
  export declare const PROPS: Record<string, Record<string, [string | null, string]>>;
31
- /** Signal names for widgets and controllers, derived from CodegenMeta. */
32
- export declare const SIGNALS: Record<string, Set<string>>;
33
- /** Map from JSX element name to controller class. */
34
- export declare const CONTROLLER_CLASSES: {
35
- GtkDragSource: typeof Gtk.DragSource;
36
- GtkDropControllerMotion: typeof Gtk.DropControllerMotion;
37
- GtkDropTarget: typeof Gtk.DropTarget;
38
- GtkDropTargetAsync: typeof Gtk.DropTargetAsync;
39
- GtkEventControllerFocus: typeof Gtk.EventControllerFocus;
40
- GtkEventControllerKey: typeof Gtk.EventControllerKey;
41
- GtkEventControllerLegacy: typeof Gtk.EventControllerLegacy;
42
- GtkEventControllerMotion: typeof Gtk.EventControllerMotion;
43
- GtkEventControllerScroll: typeof Gtk.EventControllerScroll;
44
- GtkGestureClick: typeof Gtk.GestureClick;
45
- GtkGestureDrag: typeof Gtk.GestureDrag;
46
- GtkGestureLongPress: typeof Gtk.GestureLongPress;
47
- GtkGesturePan: typeof Gtk.GesturePan;
48
- GtkGestureRotate: typeof Gtk.GestureRotate;
49
- GtkGestureSingle: typeof Gtk.GestureSingle;
50
- GtkGestureStylus: typeof Gtk.GestureStylus;
51
- GtkGestureSwipe: typeof Gtk.GestureSwipe;
52
- GtkGestureZoom: typeof Gtk.GestureZoom;
53
- GtkPadController: typeof Gtk.PadController;
54
- GtkShortcutController: typeof Gtk.ShortcutController;
55
- };
56
- /** Constructor props for controllers that require them. */
57
- export declare const CONTROLLER_CONSTRUCTOR_PROPS: Record<string, string[]>;
9
+ /** Signal handler prop name to GTK signal name mapping for widgets and controllers. */
10
+ export declare const SIGNALS: Record<string, Record<string, string>>;