@gtkx/react 0.12.1 → 0.13.1

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 (81) hide show
  1. package/README.md +1 -1
  2. package/dist/generated/internal.js +2 -0
  3. package/dist/generated/jsx.d.ts +32 -18
  4. package/dist/host-config.js +3 -3
  5. package/dist/jsx.d.ts +524 -366
  6. package/dist/jsx.js +401 -353
  7. package/dist/nodes/action-row-child.d.ts +4 -11
  8. package/dist/nodes/action-row-child.js +10 -66
  9. package/dist/nodes/action-row.js +21 -4
  10. package/dist/nodes/application.js +22 -3
  11. package/dist/nodes/autowrapped.js +13 -3
  12. package/dist/nodes/calendar-mark.d.ts +15 -0
  13. package/dist/nodes/calendar-mark.js +29 -0
  14. package/dist/nodes/calendar.d.ts +1 -0
  15. package/dist/nodes/calendar.js +70 -0
  16. package/dist/nodes/column-view-column.d.ts +1 -0
  17. package/dist/nodes/column-view-column.js +4 -0
  18. package/dist/nodes/column-view.js +24 -7
  19. package/dist/nodes/expander-row-child.d.ts +15 -0
  20. package/dist/nodes/expander-row-child.js +20 -0
  21. package/dist/nodes/expander-row.d.ts +1 -0
  22. package/dist/nodes/expander-row.js +54 -0
  23. package/dist/nodes/fixed-child.js +10 -8
  24. package/dist/nodes/grid-child.js +10 -8
  25. package/dist/nodes/index.d.ts +12 -0
  26. package/dist/nodes/index.js +12 -0
  27. package/dist/nodes/internal/list-item-renderer.d.ts +3 -0
  28. package/dist/nodes/internal/list-item-renderer.js +25 -9
  29. package/dist/nodes/internal/list-store.js +2 -2
  30. package/dist/nodes/internal/tree-list-item-renderer.d.ts +8 -0
  31. package/dist/nodes/internal/tree-list-item-renderer.js +68 -24
  32. package/dist/nodes/internal/tree-store.js +3 -4
  33. package/dist/nodes/level-bar-offset.d.ts +13 -0
  34. package/dist/nodes/level-bar-offset.js +35 -0
  35. package/dist/nodes/level-bar.d.ts +1 -0
  36. package/dist/nodes/level-bar.js +82 -0
  37. package/dist/nodes/list-view.js +14 -7
  38. package/dist/nodes/menu.js +4 -4
  39. package/dist/nodes/models/list.d.ts +2 -1
  40. package/dist/nodes/models/list.js +21 -12
  41. package/dist/nodes/models/menu.d.ts +1 -0
  42. package/dist/nodes/models/menu.js +24 -17
  43. package/dist/nodes/models/tree-list.d.ts +2 -1
  44. package/dist/nodes/models/tree-list.js +43 -24
  45. package/dist/nodes/navigation-page.d.ts +16 -0
  46. package/dist/nodes/navigation-page.js +58 -0
  47. package/dist/nodes/navigation-view.d.ts +1 -0
  48. package/dist/nodes/navigation-view.js +105 -0
  49. package/dist/nodes/notebook-page-tab.js +1 -1
  50. package/dist/nodes/notebook-page.js +3 -2
  51. package/dist/nodes/notebook.js +3 -3
  52. package/dist/nodes/overlay-child.js +29 -14
  53. package/dist/nodes/pack-child.d.ts +4 -11
  54. package/dist/nodes/pack-child.js +10 -66
  55. package/dist/nodes/pack.js +21 -4
  56. package/dist/nodes/popover-menu.js +15 -12
  57. package/dist/nodes/scale-mark.d.ts +17 -0
  58. package/dist/nodes/scale-mark.js +38 -0
  59. package/dist/nodes/scale.d.ts +1 -0
  60. package/dist/nodes/scale.js +70 -0
  61. package/dist/nodes/simple-list-view.js +3 -3
  62. package/dist/nodes/slot.js +2 -2
  63. package/dist/nodes/stack-page.js +7 -7
  64. package/dist/nodes/stack.js +5 -5
  65. package/dist/nodes/toggle-group.d.ts +1 -0
  66. package/dist/nodes/toggle-group.js +48 -0
  67. package/dist/nodes/toggle.d.ts +15 -0
  68. package/dist/nodes/toggle.js +70 -0
  69. package/dist/nodes/toolbar-child.js +18 -16
  70. package/dist/nodes/tree-list-view.js +16 -7
  71. package/dist/nodes/virtual-child.d.ts +18 -0
  72. package/dist/nodes/virtual-child.js +62 -0
  73. package/dist/nodes/widget.js +22 -8
  74. package/dist/nodes/window.d.ts +22 -0
  75. package/dist/nodes/window.js +11 -2
  76. package/dist/render.d.ts +3 -5
  77. package/dist/render.js +3 -5
  78. package/dist/scheduler.d.ts +13 -1
  79. package/dist/scheduler.js +26 -6
  80. package/dist/types.d.ts +25 -0
  81. package/package.json +3 -3
package/README.md CHANGED
@@ -49,7 +49,7 @@ const App = () => {
49
49
  title="Counter"
50
50
  defaultWidth={300}
51
51
  defaultHeight={200}
52
- onCloseRequest={quit}
52
+ onClose={quit}
53
53
  >
54
54
  <GtkBox
55
55
  orientation={Gtk.Orientation.VERTICAL}
@@ -691,11 +691,13 @@ export const PROPS = {
691
691
  vscrollPolicy: ["getVscrollPolicy", "setVscrollPolicy"],
692
692
  },
693
693
  GtkImage: {
694
+ file: [null, "setFromFile"],
694
695
  gicon: ["getGicon", "setFromGicon"],
695
696
  iconName: ["getIconName", "setFromIconName"],
696
697
  iconSize: ["getIconSize", "setIconSize"],
697
698
  paintable: ["getPaintable", "setFromPaintable"],
698
699
  pixelSize: ["getPixelSize", "setPixelSize"],
700
+ resource: [null, "setFromResource"],
699
701
  },
700
702
  GtkInfoBar: {
701
703
  messageType: ["getMessageType", "setMessageType"],
@@ -1,4 +1,5 @@
1
1
  import type { ReactNode, Ref } from "react";
2
+ import type { EventControllerProps } from "../types.js";
2
3
  import type * as Adw from "@gtkx/ffi/adw";
3
4
  import type * as GLib from "@gtkx/ffi/glib";
4
5
  import type * as GObject from "@gtkx/ffi/gobject";
@@ -13,7 +14,7 @@ import type * as WebKit from "@gtkx/ffi/webkit";
13
14
  import type * as cairo from "@gtkx/ffi/cairo";
14
15
  /** Property names that can be passed to the onNotify callback for Widget. */
15
16
  export type WidgetNotifyProps = "accessible-role" | "can-focus" | "can-target" | "css-classes" | "css-name" | "cursor" | "focus-on-click" | "focusable" | "halign" | "has-tooltip" | "height-request" | "hexpand" | "hexpand-set" | "layout-manager" | "limit-events" | "margin-bottom" | "margin-end" | "margin-start" | "margin-top" | "name" | "opacity" | "overflow" | "receives-default" | "sensitive" | "tooltip-markup" | "tooltip-text" | "valign" | "vexpand" | "vexpand-set" | "visible" | "width-request";
16
- export interface WidgetProps {
17
+ export type WidgetProps = EventControllerProps & {
17
18
  /**
18
19
  * Whether the widget or any of its descendents can accept
19
20
  * the input focus.
@@ -294,7 +295,7 @@ export interface WidgetProps {
294
295
  * or the widget has been unmapped (that is, it is going to be hidden).
295
296
  */
296
297
  onUnrealize?: (self: Gtk.Widget) => void | null;
297
- }
298
+ };
298
299
  /** Props for the {@link AdwWindow} widget. */
299
300
  export type AdwWindowProps = Omit<GtkWindowProps, "onNotify"> & {
300
301
  /**
@@ -321,6 +322,8 @@ export type AdwWindowProps = Omit<GtkWindowProps, "onNotify"> & {
321
322
  dialogs?: Gio.ListModel | null;
322
323
  /** The currently visible dialog */
323
324
  visibleDialog?: Adw.Dialog | null;
325
+ /** Called when the window close button is clicked. Control window visibility using React state. */
326
+ onClose?: (() => void) | null;
324
327
  children?: ReactNode;
325
328
  /**
326
329
  * Called when any property on this widget changes.
@@ -332,6 +335,18 @@ export type AdwWindowProps = Omit<GtkWindowProps, "onNotify"> & {
332
335
  };
333
336
  /** Props for the {@link GtkWindow} widget. */
334
337
  export type GtkWindowProps = WidgetProps & {
338
+ /**
339
+ * The `GtkApplication` associated with the window.
340
+ *
341
+ * The application will be kept alive for at least as long as it
342
+ * has any windows associated with it (see g_application_hold()
343
+ * for a way to keep it alive without windows).
344
+ *
345
+ * Normally, the connection between the application and the window
346
+ * will remain until the window is destroyed, but you can explicitly
347
+ * remove it by setting the this property to `NULL`.
348
+ */
349
+ application?: Gtk.Application | null;
335
350
  /** The child widget. */
336
351
  child?: Gtk.Widget | null;
337
352
  /** Whether the window should have a frame (also known as *decorations*). */
@@ -446,8 +461,6 @@ export type GtkWindowProps = WidgetProps & {
446
461
  * The default binding for this signal is `␣`.
447
462
  */
448
463
  onActivateFocus?: (self: Gtk.Window) => void | null;
449
- /** Emitted when the user clicks on the close button of the window. */
450
- onCloseRequest?: (self: Gtk.Window) => boolean | null;
451
464
  /**
452
465
  * Emitted when the user enables or disables interactive debugging.
453
466
  *
@@ -467,6 +480,8 @@ export type GtkWindowProps = WidgetProps & {
467
480
  * are associated with the window changes.
468
481
  */
469
482
  onKeysChanged?: (self: Gtk.Window) => void | null;
483
+ /** Called when the window close button is clicked. Control window visibility using React state. */
484
+ onClose?: (() => void) | null;
470
485
  children?: ReactNode;
471
486
  /**
472
487
  * Called when any property on this widget changes.
@@ -2036,6 +2051,7 @@ export type GtkCalendarProps = WidgetProps & {
2036
2051
  onPrevMonth?: (self: Gtk.Calendar) => void | null;
2037
2052
  /** Emitted when user switches to the previous year. */
2038
2053
  onPrevYear?: (self: Gtk.Calendar) => void | null;
2054
+ children?: ReactNode;
2039
2055
  /**
2040
2056
  * Called when any property on this widget changes.
2041
2057
  * @param self - The widget that emitted the notification
@@ -2664,6 +2680,8 @@ export type GtkColumnViewProps = WidgetProps & {
2664
2680
  sortOrder?: import("@gtkx/ffi/gtk").SortType | null;
2665
2681
  /** Called when a column header is clicked to change sort */
2666
2682
  onSortChange?: ((column: string | null, order: import("@gtkx/ffi/gtk").SortType) => void) | null;
2683
+ /** Estimated row height in pixels for proper virtualization before content loads */
2684
+ estimatedRowHeight?: number | null;
2667
2685
  children?: ReactNode;
2668
2686
  /**
2669
2687
  * Called when any property on this widget changes.
@@ -5644,6 +5662,7 @@ export type GtkLevelBarProps = WidgetProps & {
5644
5662
  * the value of offset "x" changes.
5645
5663
  */
5646
5664
  onOffsetChanged?: (self: Gtk.LevelBar, name: string) => void | null;
5665
+ children?: ReactNode;
5647
5666
  /**
5648
5667
  * Called when any property on this widget changes.
5649
5668
  * @param self - The widget that emitted the notification
@@ -6346,6 +6365,10 @@ export type AdwNavigationViewProps = WidgetProps & {
6346
6365
  * See {@link NavigationViewreplace}.
6347
6366
  */
6348
6367
  onReplaced?: (self: Adw.NavigationView) => void | null;
6368
+ /** Array of page IDs representing the navigation stack. The last ID is the visible page. */
6369
+ history?: string[] | null;
6370
+ /** Called when the navigation history changes due to user interaction (back button, swipe gesture). */
6371
+ onHistoryChanged?: ((history: string[]) => void) | null;
6349
6372
  children?: ReactNode;
6350
6373
  /**
6351
6374
  * Called when any property on this widget changes.
@@ -7215,6 +7238,7 @@ export type GtkScaleProps = Omit<GtkRangeProps, "onNotify"> & {
7215
7238
  hasOrigin?: boolean | null;
7216
7239
  /** The position in which the current value is displayed. */
7217
7240
  valuePos?: Gtk.PositionType | null;
7241
+ children?: ReactNode;
7218
7242
  /**
7219
7243
  * Called when any property on this widget changes.
7220
7244
  * @param self - The widget that emitted the notification
@@ -8388,10 +8412,8 @@ export type GtkStackProps = WidgetProps & {
8388
8412
  transitionType?: Gtk.StackTransitionType | null;
8389
8413
  /** %TRUE if the stack allocates the same height for all children. */
8390
8414
  vhomogeneous?: boolean | null;
8391
- /** The widget currently visible in the stack. */
8392
- visibleChild?: Gtk.Widget | null;
8393
- /** The name of the widget currently visible in the stack. */
8394
- visibleChildName?: string | null;
8415
+ /** ID of the visible page in the stack. */
8416
+ page?: string | null;
8395
8417
  children?: ReactNode;
8396
8418
  /**
8397
8419
  * Called when any property on this widget changes.
@@ -10451,14 +10473,8 @@ export type AdwViewStackProps = WidgetProps & {
10451
10473
  * visible.
10452
10474
  */
10453
10475
  vhomogeneous?: boolean | null;
10454
- /** The widget currently visible in the stack. */
10455
- visibleChild?: Gtk.Widget | null;
10456
- /**
10457
- * The name of the widget currently visible in the stack.
10458
- *
10459
- * See {@link AdwViewStack.visible-child}.
10460
- */
10461
- visibleChildName?: string | null;
10476
+ /** ID of the visible page in the stack. */
10477
+ page?: string | null;
10462
10478
  children?: ReactNode;
10463
10479
  /**
10464
10480
  * Called when any property on this widget changes.
@@ -11427,7 +11443,6 @@ export type WidgetSlotNames = {
11427
11443
  GtkScrolledWindow: "child";
11428
11444
  GtkSearchBar: "child" | "keyCaptureWidget";
11429
11445
  AdwSplitButton: "child" | "popover";
11430
- GtkStack: "visibleChild";
11431
11446
  GtkStackSidebar: "stack";
11432
11447
  GtkStackSwitcher: "stack";
11433
11448
  AdwStatusPage: "child";
@@ -11440,7 +11455,6 @@ export type WidgetSlotNames = {
11440
11455
  AdwToolbarView: "content";
11441
11456
  GtkTreeExpander: "child";
11442
11457
  GtkViewport: "child";
11443
- AdwViewStack: "visibleChild";
11444
11458
  AdwViewSwitcher: "stack";
11445
11459
  AdwViewSwitcherBar: "stack";
11446
11460
  AdwViewSwitcherTitle: "stack";
@@ -1,4 +1,4 @@
1
- import { beginBatch, endBatch, getNativeId } from "@gtkx/ffi";
1
+ import { batch, beginBatch, endBatch, getNativeId } from "@gtkx/ffi";
2
2
  import React from "react";
3
3
  import { createNode } from "./factory.js";
4
4
  import { signalStore } from "./nodes/internal/signal-store.js";
@@ -71,14 +71,14 @@ export function createHostConfig() {
71
71
  parent.insertBefore(child, beforeChild);
72
72
  },
73
73
  prepareForCommit: () => {
74
- signalStore.blockAll();
75
74
  beginBatch();
76
75
  return null;
77
76
  },
78
77
  resetAfterCommit: () => {
78
+ batch(() => signalStore.blockAll());
79
79
  endBatch();
80
- signalStore.unblockAll();
81
80
  flushAfterCommit();
81
+ signalStore.unblockAll();
82
82
  },
83
83
  commitTextUpdate: (textInstance, oldText, newText) => {
84
84
  textInstance.updateProps({ label: oldText }, { label: newText });