@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,90 +0,0 @@
1
- import { registerNodeClass } from "../registry.js";
2
- import { VirtualNode } from "./virtual.js";
3
- export const createTreeItemData = (props) => ({
4
- value: props.value,
5
- indentForDepth: props.indentForDepth,
6
- indentForIcon: props.indentForIcon,
7
- hideExpander: props.hideExpander,
8
- });
9
- export class TreeListItemNode extends VirtualNode {
10
- static priority = 1;
11
- store = null;
12
- parentItemId = null;
13
- childNodes = [];
14
- static matches(type) {
15
- return type === "TreeListItem";
16
- }
17
- setStore(store) {
18
- this.store = store;
19
- for (const child of this.childNodes) {
20
- child.setStore(store);
21
- }
22
- }
23
- getChildNodes() {
24
- return this.childNodes;
25
- }
26
- setParentItemId(parentId) {
27
- this.parentItemId = parentId;
28
- }
29
- getParentItemId() {
30
- return this.parentItemId;
31
- }
32
- appendChild(child) {
33
- if (!(child instanceof TreeListItemNode)) {
34
- return;
35
- }
36
- child.setStore(this.store);
37
- child.setParentItemId(this.props.id ?? null);
38
- this.childNodes.push(child);
39
- if (this.store && child.props.id !== undefined) {
40
- this.store.addItem(child.props.id, createTreeItemData(child.props), this.props.id);
41
- }
42
- }
43
- insertBefore(child, before) {
44
- if (!(child instanceof TreeListItemNode) || !(before instanceof TreeListItemNode)) {
45
- return;
46
- }
47
- child.setStore(this.store);
48
- child.setParentItemId(this.props.id ?? null);
49
- const beforeIndex = this.childNodes.indexOf(before);
50
- if (beforeIndex === -1) {
51
- this.childNodes.push(child);
52
- }
53
- else {
54
- this.childNodes.splice(beforeIndex, 0, child);
55
- }
56
- if (this.store && child.props.id !== undefined && before.props.id !== undefined) {
57
- this.store.insertItemBefore(child.props.id, before.props.id, createTreeItemData(child.props), this.props.id);
58
- }
59
- }
60
- removeChild(child) {
61
- if (!(child instanceof TreeListItemNode)) {
62
- return;
63
- }
64
- const index = this.childNodes.indexOf(child);
65
- if (index !== -1) {
66
- this.childNodes.splice(index, 1);
67
- }
68
- if (this.store && child.props.id !== undefined) {
69
- this.store.removeItem(child.props.id, this.props.id);
70
- }
71
- child.setStore(null);
72
- child.setParentItemId(null);
73
- }
74
- updateProps(oldProps, newProps) {
75
- super.updateProps(oldProps, newProps);
76
- if (!this.store) {
77
- return;
78
- }
79
- const propsChanged = !oldProps ||
80
- oldProps.id !== newProps.id ||
81
- oldProps.value !== newProps.value ||
82
- oldProps.indentForDepth !== newProps.indentForDepth ||
83
- oldProps.indentForIcon !== newProps.indentForIcon ||
84
- oldProps.hideExpander !== newProps.hideExpander;
85
- if (propsChanged && newProps.id !== undefined) {
86
- this.store.updateItem(newProps.id, createTreeItemData(newProps));
87
- }
88
- }
89
- }
90
- registerNodeClass(TreeListItemNode);
@@ -1 +0,0 @@
1
- export {};
@@ -1,77 +0,0 @@
1
- import { isObjectEqual } from "@gtkx/ffi";
2
- import * as Gtk from "@gtkx/ffi/gtk";
3
- import { registerNodeClass } from "../registry.js";
4
- import { TreeListItemRenderer } from "./internal/tree-list-item-renderer.js";
5
- import { filterProps } from "./internal/utils.js";
6
- import { TreeList } from "./models/tree-list.js";
7
- import { TreeListItemNode } from "./tree-list-item.js";
8
- import { WidgetNode } from "./widget.js";
9
- const RENDERER_PROP_NAMES = ["renderItem", "estimatedItemHeight"];
10
- const PROP_NAMES = [...RENDERER_PROP_NAMES, "autoexpand", "selectionMode", "selected", "onSelectionChanged"];
11
- class TreeListViewNode extends WidgetNode {
12
- static priority = 1;
13
- itemRenderer;
14
- treeList;
15
- static matches(type) {
16
- return type === "TreeListView";
17
- }
18
- static createContainer() {
19
- return new Gtk.ListView();
20
- }
21
- constructor(typeName, props, container, rootContainer) {
22
- const listView = container ?? new Gtk.ListView();
23
- super(typeName, props, listView, rootContainer);
24
- this.treeList = new TreeList({
25
- autoexpand: props.autoexpand,
26
- selectionMode: props.selectionMode,
27
- selected: props.selected,
28
- onSelectionChanged: props.onSelectionChanged,
29
- }, rootContainer);
30
- this.itemRenderer = new TreeListItemRenderer(this.signalStore);
31
- this.itemRenderer.setStore(this.treeList.getStore());
32
- this.treeList.getStore().setOnItemUpdated((id) => this.itemRenderer.rebindItem(id));
33
- this.container.setFactory(this.itemRenderer.getFactory());
34
- }
35
- mount() {
36
- super.mount();
37
- this.container.setModel(this.treeList.getSelectionModel());
38
- }
39
- unmount() {
40
- this.itemRenderer.dispose();
41
- super.unmount();
42
- }
43
- appendChild(child) {
44
- if (!(child instanceof TreeListItemNode)) {
45
- throw new Error(`Cannot append '${child.typeName}' to 'TreeListView': expected x.TreeListItem`);
46
- }
47
- this.treeList.appendChild(child);
48
- }
49
- insertBefore(child, before) {
50
- if (!(child instanceof TreeListItemNode) || !(before instanceof TreeListItemNode)) {
51
- throw new Error(`Cannot insert '${child.typeName}' into 'TreeListView': expected x.TreeListItem`);
52
- }
53
- this.treeList.insertBefore(child, before);
54
- }
55
- removeChild(child) {
56
- if (!(child instanceof TreeListItemNode)) {
57
- throw new Error(`Cannot remove '${child.typeName}' from 'TreeListView': expected x.TreeListItem`);
58
- }
59
- this.treeList.removeChild(child);
60
- }
61
- updateProps(oldProps, newProps) {
62
- if (!oldProps || oldProps.renderItem !== newProps.renderItem) {
63
- this.itemRenderer.setRenderFn(newProps.renderItem ?? null);
64
- }
65
- if (!oldProps || oldProps.estimatedItemHeight !== newProps.estimatedItemHeight) {
66
- this.itemRenderer.setEstimatedItemHeight(newProps.estimatedItemHeight ?? null);
67
- }
68
- const previousModel = this.treeList.getSelectionModel();
69
- this.treeList.updateProps(oldProps ? filterProps(oldProps, RENDERER_PROP_NAMES) : null, filterProps(newProps, RENDERER_PROP_NAMES));
70
- const currentModel = this.treeList.getSelectionModel();
71
- if (!isObjectEqual(previousModel, currentModel)) {
72
- this.container.setModel(currentModel);
73
- }
74
- super.updateProps(oldProps ? filterProps(oldProps, PROP_NAMES) : null, filterProps(newProps, PROP_NAMES));
75
- }
76
- }
77
- registerNodeClass(TreeListViewNode);
@@ -1,26 +0,0 @@
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
- */
12
- export declare enum CommitPriority {
13
- /** Runs first. Used for widget removals to unparent before reparenting. */
14
- HIGH = 0,
15
- /** Runs after HIGH priority. Used for widget additions. */
16
- NORMAL = 1,
17
- /** Runs after NORMAL. Used for model sync operations that need all data to be added first. */
18
- LOW = 2
19
- }
20
- /**
21
- * Schedule a callback to run after commit with the specified priority.
22
- * HIGH priority callbacks run before NORMAL priority callbacks.
23
- */
24
- export declare const scheduleAfterCommit: (callback: Callback, priority?: CommitPriority) => void;
25
- export declare const flushAfterCommit: () => void;
26
- export {};
package/dist/scheduler.js DELETED
@@ -1,42 +0,0 @@
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
- */
11
- export var CommitPriority;
12
- (function (CommitPriority) {
13
- /** Runs first. Used for widget removals to unparent before reparenting. */
14
- CommitPriority[CommitPriority["HIGH"] = 0] = "HIGH";
15
- /** Runs after HIGH priority. Used for widget additions. */
16
- CommitPriority[CommitPriority["NORMAL"] = 1] = "NORMAL";
17
- /** Runs after NORMAL. Used for model sync operations that need all data to be added first. */
18
- CommitPriority[CommitPriority["LOW"] = 2] = "LOW";
19
- })(CommitPriority || (CommitPriority = {}));
20
- const queues = {
21
- [CommitPriority.HIGH]: [],
22
- [CommitPriority.NORMAL]: [],
23
- [CommitPriority.LOW]: [],
24
- };
25
- const priorities = [CommitPriority.HIGH, CommitPriority.NORMAL, CommitPriority.LOW];
26
- /**
27
- * Schedule a callback to run after commit with the specified priority.
28
- * HIGH priority callbacks run before NORMAL priority callbacks.
29
- */
30
- export const scheduleAfterCommit = (callback, priority = CommitPriority.NORMAL) => {
31
- queues[priority].push(callback);
32
- };
33
- export const flushAfterCommit = () => {
34
- for (const priority of priorities) {
35
- const queue = queues[priority];
36
- while (queue.length > 0) {
37
- const callback = queue.shift();
38
- if (callback)
39
- callback();
40
- }
41
- }
42
- };