@gtkx/react 0.18.3 → 0.18.5
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.
- package/dist/generated/jsx.d.ts +10 -30
- package/dist/generated/jsx.d.ts.map +1 -1
- package/dist/generated/jsx.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/nodes/calendar.d.ts +4 -1
- package/dist/nodes/calendar.d.ts.map +1 -1
- package/dist/nodes/calendar.js +3 -1
- package/dist/nodes/calendar.js.map +1 -1
- package/dist/nodes/column-view.d.ts +4 -1
- package/dist/nodes/column-view.d.ts.map +1 -1
- package/dist/nodes/column-view.js +19 -6
- package/dist/nodes/column-view.js.map +1 -1
- package/dist/nodes/drawing-area.d.ts +4 -1
- package/dist/nodes/drawing-area.d.ts.map +1 -1
- package/dist/nodes/drawing-area.js +3 -1
- package/dist/nodes/drawing-area.js.map +1 -1
- package/dist/nodes/drop-down.d.ts +8 -4
- package/dist/nodes/drop-down.d.ts.map +1 -1
- package/dist/nodes/drop-down.js +18 -6
- package/dist/nodes/drop-down.js.map +1 -1
- package/dist/nodes/grid-view.d.ts +8 -4
- package/dist/nodes/grid-view.d.ts.map +1 -1
- package/dist/nodes/grid-view.js +14 -3
- package/dist/nodes/grid-view.js.map +1 -1
- package/dist/nodes/internal/grid-item-renderer.d.ts +2 -1
- package/dist/nodes/internal/grid-item-renderer.d.ts.map +1 -1
- package/dist/nodes/internal/list-item-renderer.d.ts +2 -1
- package/dist/nodes/internal/list-item-renderer.d.ts.map +1 -1
- package/dist/nodes/internal/list-store.d.ts +2 -1
- package/dist/nodes/internal/list-store.d.ts.map +1 -1
- package/dist/nodes/internal/selection-model-controller.d.ts +1 -1
- package/dist/nodes/internal/selection-model-controller.d.ts.map +1 -1
- package/dist/nodes/internal/signal-store.d.ts +1 -1
- package/dist/nodes/internal/signal-store.d.ts.map +1 -1
- package/dist/nodes/internal/tree-store.d.ts +2 -1
- package/dist/nodes/internal/tree-store.d.ts.map +1 -1
- package/dist/nodes/list-view.d.ts +8 -4
- package/dist/nodes/list-view.d.ts.map +1 -1
- package/dist/nodes/list-view.js +16 -4
- package/dist/nodes/list-view.js.map +1 -1
- package/dist/nodes/navigation-view.d.ts +3 -1
- package/dist/nodes/navigation-view.d.ts.map +1 -1
- package/dist/nodes/navigation-view.js +7 -1
- package/dist/nodes/navigation-view.js.map +1 -1
- package/dist/nodes/notebook.d.ts +8 -3
- package/dist/nodes/notebook.d.ts.map +1 -1
- package/dist/nodes/notebook.js +17 -7
- package/dist/nodes/notebook.js.map +1 -1
- package/dist/nodes/popover-menu.d.ts +3 -1
- package/dist/nodes/popover-menu.d.ts.map +1 -1
- package/dist/nodes/popover-menu.js +7 -1
- package/dist/nodes/popover-menu.js.map +1 -1
- package/dist/nodes/text-view.d.ts +2 -1
- package/dist/nodes/text-view.d.ts.map +1 -1
- package/dist/nodes/text-view.js +2 -0
- package/dist/nodes/text-view.js.map +1 -1
- package/dist/nodes/window.d.ts +4 -2
- package/dist/nodes/window.d.ts.map +1 -1
- package/dist/nodes/window.js +5 -1
- package/dist/nodes/window.js.map +1 -1
- package/package.json +3 -3
- package/src/generated/jsx.ts +10 -30
- package/src/index.ts +1 -0
- package/src/nodes/calendar.ts +6 -2
- package/src/nodes/column-view.ts +23 -7
- package/src/nodes/drawing-area.ts +6 -2
- package/src/nodes/drop-down.ts +26 -10
- package/src/nodes/grid-view.ts +20 -7
- package/src/nodes/internal/grid-item-renderer.ts +1 -1
- package/src/nodes/internal/list-item-renderer.ts +1 -1
- package/src/nodes/internal/list-store.ts +1 -1
- package/src/nodes/internal/selection-model-controller.ts +1 -1
- package/src/nodes/internal/signal-store.ts +1 -1
- package/src/nodes/internal/tree-store.ts +1 -1
- package/src/nodes/list-view.ts +24 -8
- package/src/nodes/navigation-view.ts +10 -2
- package/src/nodes/notebook.ts +24 -10
- package/src/nodes/popover-menu.ts +10 -2
- package/src/nodes/text-view.ts +3 -1
- package/src/nodes/window.ts +16 -3
package/src/generated/jsx.ts
CHANGED
|
@@ -10195,71 +10195,51 @@ export interface GtkShortcutControllerProps extends EventControllerBaseProps {
|
|
|
10195
10195
|
*/
|
|
10196
10196
|
export type WidgetSlotNames = {
|
|
10197
10197
|
AdwWindow: "content";
|
|
10198
|
-
GtkWindow: "
|
|
10198
|
+
GtkWindow: "defaultWidget" | "focusWidget" | "titlebar" | "transientFor";
|
|
10199
10199
|
AdwActionRow: "activatableWidget";
|
|
10200
10200
|
AdwAlertDialog: "extraChild";
|
|
10201
10201
|
AdwApplicationWindow: "content";
|
|
10202
|
-
GtkAspectFrame: "child";
|
|
10203
|
-
AdwBin: "child";
|
|
10204
10202
|
AdwBottomSheet: "bottomBar" | "content" | "sheet";
|
|
10205
|
-
AdwBreakpointBin: "child";
|
|
10206
|
-
GtkButton: "child";
|
|
10207
10203
|
AdwCarouselIndicatorDots: "carousel";
|
|
10208
10204
|
AdwCarouselIndicatorLines: "carousel";
|
|
10209
10205
|
GtkCenterBox: "centerWidget" | "endWidget" | "startWidget";
|
|
10210
|
-
GtkCheckButton: "
|
|
10211
|
-
AdwClamp: "child";
|
|
10212
|
-
AdwClampScrollable: "child";
|
|
10213
|
-
GtkComboBox: "child";
|
|
10206
|
+
GtkCheckButton: "group";
|
|
10214
10207
|
GtkSourceCompletionCell: "widget";
|
|
10215
|
-
AdwDialog: "
|
|
10216
|
-
|
|
10217
|
-
GtkExpander: "child" | "labelWidget";
|
|
10208
|
+
AdwDialog: "defaultWidget" | "focusWidget";
|
|
10209
|
+
GtkExpander: "labelWidget";
|
|
10218
10210
|
AdwFlap: "content" | "flap" | "separator";
|
|
10219
|
-
|
|
10220
|
-
GtkFrame: "child" | "labelWidget";
|
|
10221
|
-
GtkGraphicsOffload: "child";
|
|
10211
|
+
GtkFrame: "labelWidget";
|
|
10222
10212
|
GtkSourceGutter: "view";
|
|
10223
10213
|
AdwHeaderBar: "titleWidget";
|
|
10224
10214
|
GtkHeaderBar: "titleWidget";
|
|
10225
10215
|
AdwInlineViewSwitcher: "stack";
|
|
10226
10216
|
GtkLabel: "mnemonicWidget";
|
|
10227
10217
|
AdwLeaflet: "visibleChild";
|
|
10228
|
-
GtkListBoxRow: "child";
|
|
10229
10218
|
GtkSourceMap: "view";
|
|
10230
|
-
GtkMenuButton: "
|
|
10219
|
+
GtkMenuButton: "popover";
|
|
10231
10220
|
AdwMessageDialog: "extraChild";
|
|
10232
|
-
AdwNavigationPage: "child";
|
|
10233
10221
|
AdwNavigationSplitView: "content" | "sidebar";
|
|
10234
|
-
GtkOverlay: "child";
|
|
10235
10222
|
AdwOverlaySplitView: "content" | "sidebar";
|
|
10236
10223
|
GtkPaned: "endChild" | "startChild";
|
|
10237
|
-
GtkPopover: "
|
|
10224
|
+
GtkPopover: "defaultWidget";
|
|
10238
10225
|
AdwPreferencesDialog: "visiblePage";
|
|
10239
10226
|
AdwPreferencesGroup: "headerSuffix";
|
|
10240
10227
|
AdwPreferencesPage: "banner";
|
|
10241
10228
|
AdwPreferencesWindow: "visiblePage";
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
GtkSearchBar: "child" | "keyCaptureWidget";
|
|
10245
|
-
AdwSplitButton: "child" | "popover";
|
|
10229
|
+
GtkSearchBar: "keyCaptureWidget";
|
|
10230
|
+
AdwSplitButton: "popover";
|
|
10246
10231
|
GtkStackSidebar: "stack";
|
|
10247
10232
|
GtkStackSwitcher: "stack";
|
|
10248
|
-
AdwStatusPage: "child";
|
|
10249
10233
|
AdwTabBar: "endActionWidget" | "startActionWidget" | "view";
|
|
10250
10234
|
AdwTabButton: "view";
|
|
10251
|
-
AdwTabOverview: "
|
|
10235
|
+
AdwTabOverview: "view";
|
|
10252
10236
|
VteTerminal: "contextMenu";
|
|
10253
|
-
AdwToastOverlay: "child";
|
|
10254
10237
|
GtkToggleButton: "group";
|
|
10255
10238
|
AdwToolbarView: "content";
|
|
10256
|
-
GtkTreeExpander: "child";
|
|
10257
|
-
GtkViewport: "child";
|
|
10258
10239
|
AdwViewSwitcher: "stack";
|
|
10259
10240
|
AdwViewSwitcherBar: "stack";
|
|
10260
10241
|
AdwViewSwitcherTitle: "stack";
|
|
10261
10242
|
WebKitWebView: "relatedView";
|
|
10262
|
-
GtkWindowHandle: "child";
|
|
10263
10243
|
};
|
|
10264
10244
|
|
|
10265
10245
|
/**
|
package/src/index.ts
CHANGED
package/src/nodes/calendar.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { GtkCalendarProps } from "../jsx.js";
|
|
3
3
|
import type { Node } from "../node.js";
|
|
4
|
+
import { ContainerSlotNode } from "./container-slot.js";
|
|
4
5
|
import { EventControllerNode } from "./event-controller.js";
|
|
5
6
|
import { filterProps, primitiveArrayEqual } from "./internal/props.js";
|
|
7
|
+
import { SlotNode } from "./slot.js";
|
|
6
8
|
import { WidgetNode } from "./widget.js";
|
|
7
9
|
|
|
8
10
|
const OWN_PROPS = ["markedDays"] as const;
|
|
9
11
|
|
|
10
12
|
type CalendarProps = Pick<GtkCalendarProps, (typeof OWN_PROPS)[number]>;
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
type CalendarChild = EventControllerNode | SlotNode | ContainerSlotNode;
|
|
15
|
+
|
|
16
|
+
export class CalendarNode extends WidgetNode<Gtk.Calendar, CalendarProps, CalendarChild> {
|
|
13
17
|
public override isValidChild(child: Node): boolean {
|
|
14
|
-
return child instanceof EventControllerNode;
|
|
18
|
+
return child instanceof EventControllerNode || child instanceof SlotNode || child instanceof ContainerSlotNode;
|
|
15
19
|
}
|
|
16
20
|
private appliedMarks: number[] = [];
|
|
17
21
|
|
package/src/nodes/column-view.ts
CHANGED
|
@@ -3,22 +3,31 @@ import type { GtkColumnViewProps } from "../jsx.js";
|
|
|
3
3
|
import type { Node } from "../node.js";
|
|
4
4
|
import type { Container } from "../types.js";
|
|
5
5
|
import { ColumnViewColumnNode } from "./column-view-column.js";
|
|
6
|
+
import { ContainerSlotNode } from "./container-slot.js";
|
|
7
|
+
import { EventControllerNode } from "./event-controller.js";
|
|
6
8
|
import { filterProps, hasChanged } from "./internal/props.js";
|
|
7
9
|
import { ListItemNode } from "./list-item.js";
|
|
8
10
|
import { ListModel, type ListModelProps } from "./models/list.js";
|
|
11
|
+
import { SlotNode } from "./slot.js";
|
|
9
12
|
import { WidgetNode } from "./widget.js";
|
|
10
13
|
|
|
11
14
|
const OWN_PROPS = ["sortColumn", "sortOrder", "onSortChanged", "estimatedRowHeight"] as const;
|
|
12
15
|
|
|
13
16
|
type ColumnViewProps = Pick<GtkColumnViewProps, (typeof OWN_PROPS)[number]> & ListModelProps;
|
|
14
|
-
type ColumnViewChild = ListItemNode | ColumnViewColumnNode;
|
|
17
|
+
type ColumnViewChild = ListItemNode | ColumnViewColumnNode | EventControllerNode | SlotNode | ContainerSlotNode;
|
|
15
18
|
|
|
16
19
|
export class ColumnViewNode extends WidgetNode<Gtk.ColumnView, ColumnViewProps, ColumnViewChild> {
|
|
17
20
|
private handleSortChange: (() => void) | null = null;
|
|
18
21
|
private list: ListModel;
|
|
19
22
|
|
|
20
23
|
public override isValidChild(child: Node): boolean {
|
|
21
|
-
return
|
|
24
|
+
return (
|
|
25
|
+
child instanceof ListItemNode ||
|
|
26
|
+
child instanceof ColumnViewColumnNode ||
|
|
27
|
+
child instanceof EventControllerNode ||
|
|
28
|
+
child instanceof SlotNode ||
|
|
29
|
+
child instanceof ContainerSlotNode
|
|
30
|
+
);
|
|
22
31
|
}
|
|
23
32
|
private columnNodes = new Set<ColumnViewColumnNode>();
|
|
24
33
|
private estimatedRowHeight: number | null = null;
|
|
@@ -43,6 +52,8 @@ export class ColumnViewNode extends WidgetNode<Gtk.ColumnView, ColumnViewProps,
|
|
|
43
52
|
return;
|
|
44
53
|
}
|
|
45
54
|
|
|
55
|
+
if (!(child instanceof ColumnViewColumnNode)) return;
|
|
56
|
+
|
|
46
57
|
const existingColumn = this.findColumnInView(child.getColumn());
|
|
47
58
|
|
|
48
59
|
if (existingColumn) {
|
|
@@ -65,6 +76,8 @@ export class ColumnViewNode extends WidgetNode<Gtk.ColumnView, ColumnViewProps,
|
|
|
65
76
|
return;
|
|
66
77
|
}
|
|
67
78
|
|
|
79
|
+
if (!(child instanceof ColumnViewColumnNode)) return;
|
|
80
|
+
|
|
68
81
|
const existingColumn = this.findColumnInView(child.getColumn());
|
|
69
82
|
|
|
70
83
|
if (existingColumn) {
|
|
@@ -91,14 +104,17 @@ export class ColumnViewNode extends WidgetNode<Gtk.ColumnView, ColumnViewProps,
|
|
|
91
104
|
return;
|
|
92
105
|
}
|
|
93
106
|
|
|
94
|
-
|
|
107
|
+
if (child instanceof ColumnViewColumnNode) {
|
|
108
|
+
const existingColumn = this.findColumnInView(child.getColumn());
|
|
95
109
|
|
|
96
|
-
|
|
97
|
-
|
|
110
|
+
if (existingColumn) {
|
|
111
|
+
this.container.removeColumn(existingColumn);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
child.setStore(null);
|
|
115
|
+
this.columnNodes.delete(child);
|
|
98
116
|
}
|
|
99
117
|
|
|
100
|
-
child.setStore(null);
|
|
101
|
-
this.columnNodes.delete(child);
|
|
102
118
|
super.removeChild(child);
|
|
103
119
|
}
|
|
104
120
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { GtkDrawingAreaProps } from "../jsx.js";
|
|
3
3
|
import type { Node } from "../node.js";
|
|
4
|
+
import { ContainerSlotNode } from "./container-slot.js";
|
|
4
5
|
import { EventControllerNode } from "./event-controller.js";
|
|
5
6
|
import { filterProps, hasChanged } from "./internal/props.js";
|
|
7
|
+
import { SlotNode } from "./slot.js";
|
|
6
8
|
import { WidgetNode } from "./widget.js";
|
|
7
9
|
|
|
8
10
|
const OWN_PROPS = ["onDraw"] as const;
|
|
@@ -29,9 +31,11 @@ function flushPendingDrawFuncs(): void {
|
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
type DrawingAreaChild = EventControllerNode | SlotNode | ContainerSlotNode;
|
|
35
|
+
|
|
36
|
+
export class DrawingAreaNode extends WidgetNode<Gtk.DrawingArea, DrawingAreaProps, DrawingAreaChild> {
|
|
33
37
|
public override isValidChild(child: Node): boolean {
|
|
34
|
-
return child instanceof EventControllerNode;
|
|
38
|
+
return child instanceof EventControllerNode || child instanceof SlotNode || child instanceof ContainerSlotNode;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
public override commitUpdate(oldProps: DrawingAreaProps | null, newProps: DrawingAreaProps): void {
|
package/src/nodes/drop-down.ts
CHANGED
|
@@ -2,21 +2,31 @@ import type { AdwComboRowProps, GtkDropDownProps } from "../jsx.js";
|
|
|
2
2
|
import type { Node } from "../node.js";
|
|
3
3
|
import type { DropDownWidget } from "../registry.js";
|
|
4
4
|
import type { Container } from "../types.js";
|
|
5
|
+
import { ContainerSlotNode } from "./container-slot.js";
|
|
6
|
+
import { EventControllerNode } from "./event-controller.js";
|
|
5
7
|
import { filterProps, hasChanged } from "./internal/props.js";
|
|
6
8
|
import { SimpleListStore } from "./internal/simple-list-store.js";
|
|
7
9
|
import { ListItemNode } from "./list-item.js";
|
|
10
|
+
import { SlotNode } from "./slot.js";
|
|
8
11
|
import { WidgetNode } from "./widget.js";
|
|
9
12
|
|
|
10
13
|
const OWN_PROPS = ["selectedId", "onSelectionChanged"] as const;
|
|
11
14
|
|
|
12
15
|
type DropDownProps = Pick<GtkDropDownProps | AdwComboRowProps, (typeof OWN_PROPS)[number]>;
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
type DropDownChild = ListItemNode | EventControllerNode | SlotNode | ContainerSlotNode;
|
|
18
|
+
|
|
19
|
+
export class DropDownNode extends WidgetNode<DropDownWidget, DropDownProps, DropDownChild> {
|
|
15
20
|
private store = new SimpleListStore();
|
|
16
21
|
private initialSelectedId: string | null | undefined;
|
|
17
22
|
|
|
18
23
|
public override isValidChild(child: Node): boolean {
|
|
19
|
-
return
|
|
24
|
+
return (
|
|
25
|
+
child instanceof ListItemNode ||
|
|
26
|
+
child instanceof EventControllerNode ||
|
|
27
|
+
child instanceof SlotNode ||
|
|
28
|
+
child instanceof ContainerSlotNode
|
|
29
|
+
);
|
|
20
30
|
}
|
|
21
31
|
|
|
22
32
|
constructor(typeName: string, props: DropDownProps, container: DropDownWidget, rootContainer: Container) {
|
|
@@ -42,20 +52,26 @@ export class DropDownNode extends WidgetNode<DropDownWidget, DropDownProps, List
|
|
|
42
52
|
}
|
|
43
53
|
}
|
|
44
54
|
|
|
45
|
-
public override appendChild(child:
|
|
55
|
+
public override appendChild(child: DropDownChild): void {
|
|
46
56
|
super.appendChild(child);
|
|
47
|
-
child
|
|
48
|
-
|
|
57
|
+
if (child instanceof ListItemNode) {
|
|
58
|
+
child.setStore(this.store);
|
|
59
|
+
this.store.addItem(child.props.id, child.props.value as string);
|
|
60
|
+
}
|
|
49
61
|
}
|
|
50
62
|
|
|
51
|
-
public override insertBefore(child:
|
|
63
|
+
public override insertBefore(child: DropDownChild, before: DropDownChild): void {
|
|
52
64
|
super.insertBefore(child, before);
|
|
53
|
-
child
|
|
54
|
-
|
|
65
|
+
if (child instanceof ListItemNode && before instanceof ListItemNode) {
|
|
66
|
+
child.setStore(this.store);
|
|
67
|
+
this.store.insertItemBefore(child.props.id, before.props.id, child.props.value as string);
|
|
68
|
+
}
|
|
55
69
|
}
|
|
56
70
|
|
|
57
|
-
public override removeChild(child:
|
|
58
|
-
|
|
71
|
+
public override removeChild(child: DropDownChild): void {
|
|
72
|
+
if (child instanceof ListItemNode) {
|
|
73
|
+
this.store.removeItem(child.props.id);
|
|
74
|
+
}
|
|
59
75
|
super.removeChild(child);
|
|
60
76
|
}
|
|
61
77
|
|
package/src/nodes/grid-view.ts
CHANGED
|
@@ -2,17 +2,22 @@ import type * as Gtk from "@gtkx/ffi/gtk";
|
|
|
2
2
|
import type { GtkGridViewProps } from "../jsx.js";
|
|
3
3
|
import type { Node } from "../node.js";
|
|
4
4
|
import type { Container } from "../types.js";
|
|
5
|
+
import { ContainerSlotNode } from "./container-slot.js";
|
|
6
|
+
import { EventControllerNode } from "./event-controller.js";
|
|
5
7
|
import { GridItemRenderer } from "./internal/grid-item-renderer.js";
|
|
6
8
|
import { filterProps, hasChanged } from "./internal/props.js";
|
|
7
9
|
import { ListItemNode } from "./list-item.js";
|
|
8
10
|
import { GridModel, type GridModelProps } from "./models/grid.js";
|
|
11
|
+
import { SlotNode } from "./slot.js";
|
|
9
12
|
import { WidgetNode } from "./widget.js";
|
|
10
13
|
|
|
11
14
|
const OWN_PROPS = ["renderItem", "estimatedItemHeight"] as const;
|
|
12
15
|
|
|
13
16
|
type GridViewProps = Pick<GtkGridViewProps, (typeof OWN_PROPS)[number]> & GridModelProps;
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
type GridViewChild = ListItemNode | EventControllerNode | SlotNode | ContainerSlotNode;
|
|
19
|
+
|
|
20
|
+
export class GridViewNode extends WidgetNode<Gtk.GridView, GridViewProps, GridViewChild> {
|
|
16
21
|
private itemRenderer: GridItemRenderer;
|
|
17
22
|
private grid: GridModel;
|
|
18
23
|
|
|
@@ -33,6 +38,8 @@ export class GridViewNode extends WidgetNode<Gtk.GridView, GridViewProps, ListIt
|
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
public override isValidChild(child: Node): boolean {
|
|
41
|
+
if (child instanceof EventControllerNode || child instanceof SlotNode || child instanceof ContainerSlotNode)
|
|
42
|
+
return true;
|
|
36
43
|
if (!(child instanceof ListItemNode)) return false;
|
|
37
44
|
if (child.getChildNodes().length > 0) {
|
|
38
45
|
throw new Error("GtkGridView does not support nested ListItems. Use GtkListView for tree lists.");
|
|
@@ -40,18 +47,24 @@ export class GridViewNode extends WidgetNode<Gtk.GridView, GridViewProps, ListIt
|
|
|
40
47
|
return true;
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
public override appendChild(child:
|
|
50
|
+
public override appendChild(child: GridViewChild): void {
|
|
44
51
|
super.appendChild(child);
|
|
45
|
-
|
|
52
|
+
if (child instanceof ListItemNode) {
|
|
53
|
+
this.grid.appendChild(child);
|
|
54
|
+
}
|
|
46
55
|
}
|
|
47
56
|
|
|
48
|
-
public override insertBefore(child:
|
|
57
|
+
public override insertBefore(child: GridViewChild, before: GridViewChild): void {
|
|
49
58
|
super.insertBefore(child, before);
|
|
50
|
-
|
|
59
|
+
if (child instanceof ListItemNode && before instanceof ListItemNode) {
|
|
60
|
+
this.grid.insertBefore(child, before);
|
|
61
|
+
}
|
|
51
62
|
}
|
|
52
63
|
|
|
53
|
-
public override removeChild(child:
|
|
54
|
-
|
|
64
|
+
public override removeChild(child: GridViewChild): void {
|
|
65
|
+
if (child instanceof ListItemNode) {
|
|
66
|
+
this.grid.removeChild(child);
|
|
67
|
+
}
|
|
55
68
|
super.removeChild(child);
|
|
56
69
|
}
|
|
57
70
|
|
|
@@ -5,7 +5,7 @@ import { reconciler } from "../../reconciler.js";
|
|
|
5
5
|
import { BaseItemRenderer } from "./base-item-renderer.js";
|
|
6
6
|
import type { ListStore } from "./list-store.js";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
type GridRenderItemFn<T> = (item: T | null) => ReactNode;
|
|
9
9
|
|
|
10
10
|
export class GridItemRenderer extends BaseItemRenderer<ListStore> {
|
|
11
11
|
private renderFn: GridRenderItemFn<unknown> | null = () => null;
|
|
@@ -5,7 +5,7 @@ import { reconciler } from "../../reconciler.js";
|
|
|
5
5
|
import { BaseItemRenderer } from "./base-item-renderer.js";
|
|
6
6
|
import type { TreeStore } from "./tree-store.js";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
type RenderItemFn<T> = (item: T | null, row: Gtk.TreeListRow | null) => ReactNode;
|
|
9
9
|
|
|
10
10
|
type PendingBind = {
|
|
11
11
|
treeListRow: Gtk.TreeListRow;
|
|
@@ -5,7 +5,7 @@ import type { SignalStore } from "./signal-store.js";
|
|
|
5
5
|
|
|
6
6
|
type SelectionModel = Gtk.NoSelection | Gtk.SingleSelection | Gtk.MultiSelection;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
type SelectionModelConfig = Pick<GtkListViewProps, "selectionMode" | "selected" | "onSelectionChanged"> & {
|
|
9
9
|
owner: object;
|
|
10
10
|
signalStore: SignalStore;
|
|
11
11
|
};
|
package/src/nodes/list-view.ts
CHANGED
|
@@ -2,10 +2,13 @@ import type * as Gtk from "@gtkx/ffi/gtk";
|
|
|
2
2
|
import type { GtkListViewProps } from "../jsx.js";
|
|
3
3
|
import type { Node } from "../node.js";
|
|
4
4
|
import type { Container } from "../types.js";
|
|
5
|
+
import { ContainerSlotNode } from "./container-slot.js";
|
|
6
|
+
import { EventControllerNode } from "./event-controller.js";
|
|
5
7
|
import { ListItemRenderer } from "./internal/list-item-renderer.js";
|
|
6
8
|
import { filterProps, hasChanged } from "./internal/props.js";
|
|
7
9
|
import { ListItemNode } from "./list-item.js";
|
|
8
10
|
import { ListModel, type ListModelProps } from "./models/list.js";
|
|
11
|
+
import { SlotNode } from "./slot.js";
|
|
9
12
|
import { WidgetNode } from "./widget.js";
|
|
10
13
|
|
|
11
14
|
const RENDERER_PROPS = ["renderItem", "estimatedItemHeight"] as const;
|
|
@@ -13,12 +16,19 @@ const OWN_PROPS = [...RENDERER_PROPS, "autoexpand", "selectionMode", "selected",
|
|
|
13
16
|
|
|
14
17
|
type ListViewProps = Pick<GtkListViewProps, (typeof RENDERER_PROPS)[number]> & ListModelProps;
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
type ListViewChild = ListItemNode | EventControllerNode | SlotNode | ContainerSlotNode;
|
|
20
|
+
|
|
21
|
+
export class ListViewNode extends WidgetNode<Gtk.ListView, ListViewProps, ListViewChild> {
|
|
17
22
|
private itemRenderer: ListItemRenderer;
|
|
18
23
|
private list: ListModel;
|
|
19
24
|
|
|
20
25
|
public override isValidChild(child: Node): boolean {
|
|
21
|
-
return
|
|
26
|
+
return (
|
|
27
|
+
child instanceof ListItemNode ||
|
|
28
|
+
child instanceof EventControllerNode ||
|
|
29
|
+
child instanceof SlotNode ||
|
|
30
|
+
child instanceof ContainerSlotNode
|
|
31
|
+
);
|
|
22
32
|
}
|
|
23
33
|
|
|
24
34
|
constructor(typeName: string, props: ListViewProps, container: Gtk.ListView, rootContainer: Container) {
|
|
@@ -38,18 +48,24 @@ export class ListViewNode extends WidgetNode<Gtk.ListView, ListViewProps, ListIt
|
|
|
38
48
|
this.container.setFactory(this.itemRenderer.getFactory());
|
|
39
49
|
}
|
|
40
50
|
|
|
41
|
-
public override appendChild(child:
|
|
51
|
+
public override appendChild(child: ListViewChild): void {
|
|
42
52
|
super.appendChild(child);
|
|
43
|
-
|
|
53
|
+
if (child instanceof ListItemNode) {
|
|
54
|
+
this.list.appendChild(child);
|
|
55
|
+
}
|
|
44
56
|
}
|
|
45
57
|
|
|
46
|
-
public override insertBefore(child:
|
|
58
|
+
public override insertBefore(child: ListViewChild, before: ListViewChild): void {
|
|
47
59
|
super.insertBefore(child, before);
|
|
48
|
-
|
|
60
|
+
if (child instanceof ListItemNode && before instanceof ListItemNode) {
|
|
61
|
+
this.list.insertBefore(child, before);
|
|
62
|
+
}
|
|
49
63
|
}
|
|
50
64
|
|
|
51
|
-
public override removeChild(child:
|
|
52
|
-
|
|
65
|
+
public override removeChild(child: ListViewChild): void {
|
|
66
|
+
if (child instanceof ListItemNode) {
|
|
67
|
+
this.list.removeChild(child);
|
|
68
|
+
}
|
|
53
69
|
super.removeChild(child);
|
|
54
70
|
}
|
|
55
71
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as Adw from "@gtkx/ffi/adw";
|
|
2
2
|
import type { AdwNavigationViewProps } from "../jsx.js";
|
|
3
3
|
import type { Node } from "../node.js";
|
|
4
|
+
import { ContainerSlotNode } from "./container-slot.js";
|
|
5
|
+
import { EventControllerNode } from "./event-controller.js";
|
|
4
6
|
import { filterProps, hasChanged, primitiveArrayEqual } from "./internal/props.js";
|
|
5
7
|
import { NavigationPageNode } from "./navigation-page.js";
|
|
6
8
|
import { SlotNode } from "./slot.js";
|
|
@@ -9,11 +11,17 @@ import { WidgetNode } from "./widget.js";
|
|
|
9
11
|
const OWN_PROPS = ["history", "onHistoryChanged"] as const;
|
|
10
12
|
|
|
11
13
|
type NavigationViewProps = Pick<AdwNavigationViewProps, (typeof OWN_PROPS)[number]>;
|
|
12
|
-
type NavigationViewChild = NavigationPageNode | SlotNode | WidgetNode;
|
|
14
|
+
type NavigationViewChild = NavigationPageNode | SlotNode | ContainerSlotNode | EventControllerNode | WidgetNode;
|
|
13
15
|
|
|
14
16
|
export class NavigationViewNode extends WidgetNode<Adw.NavigationView, NavigationViewProps, NavigationViewChild> {
|
|
15
17
|
public override isValidChild(child: Node): boolean {
|
|
16
|
-
return
|
|
18
|
+
return (
|
|
19
|
+
child instanceof NavigationPageNode ||
|
|
20
|
+
child instanceof SlotNode ||
|
|
21
|
+
child instanceof EventControllerNode ||
|
|
22
|
+
child instanceof ContainerSlotNode ||
|
|
23
|
+
child instanceof WidgetNode
|
|
24
|
+
);
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
public override commitUpdate(oldProps: NavigationViewProps | null, newProps: NavigationViewProps): void {
|
package/src/nodes/notebook.ts
CHANGED
|
@@ -1,28 +1,42 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { Node } from "../node.js";
|
|
3
3
|
import type { Props } from "../types.js";
|
|
4
|
+
import { ContainerSlotNode } from "./container-slot.js";
|
|
5
|
+
import { EventControllerNode } from "./event-controller.js";
|
|
4
6
|
import { NotebookPageNode } from "./notebook-page.js";
|
|
7
|
+
import { SlotNode } from "./slot.js";
|
|
5
8
|
import { WidgetNode } from "./widget.js";
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
type NotebookChild = NotebookPageNode | EventControllerNode | SlotNode | ContainerSlotNode;
|
|
11
|
+
|
|
12
|
+
export class NotebookNode extends WidgetNode<Gtk.Notebook, Props, NotebookChild> {
|
|
8
13
|
public override isValidChild(child: Node): boolean {
|
|
9
|
-
return
|
|
14
|
+
return (
|
|
15
|
+
child instanceof NotebookPageNode ||
|
|
16
|
+
child instanceof EventControllerNode ||
|
|
17
|
+
child instanceof SlotNode ||
|
|
18
|
+
child instanceof ContainerSlotNode
|
|
19
|
+
);
|
|
10
20
|
}
|
|
11
21
|
|
|
12
|
-
public override insertBefore(child:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
public override insertBefore(child: NotebookChild, before: NotebookChild): void {
|
|
23
|
+
if (child instanceof NotebookPageNode && before instanceof NotebookPageNode) {
|
|
24
|
+
const isMove = this.children.includes(child);
|
|
25
|
+
const beforePosition = this.container.pageNum(before.getChildWidget());
|
|
26
|
+
child.setPosition(beforePosition);
|
|
16
27
|
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
if (isMove) {
|
|
29
|
+
this.container.reorderChild(child.getChildWidget(), beforePosition);
|
|
30
|
+
}
|
|
19
31
|
}
|
|
20
32
|
|
|
21
33
|
super.insertBefore(child, before);
|
|
22
34
|
}
|
|
23
35
|
|
|
24
|
-
public override removeChild(child:
|
|
25
|
-
child
|
|
36
|
+
public override removeChild(child: NotebookChild): void {
|
|
37
|
+
if (child instanceof NotebookPageNode) {
|
|
38
|
+
child.setPosition(null);
|
|
39
|
+
}
|
|
26
40
|
super.removeChild(child);
|
|
27
41
|
}
|
|
28
42
|
}
|
|
@@ -3,18 +3,26 @@ import * as Gtk from "@gtkx/ffi/gtk";
|
|
|
3
3
|
import type { Node } from "../node.js";
|
|
4
4
|
import type { PopoverMenuWidget } from "../registry.js";
|
|
5
5
|
import type { Container, Props } from "../types.js";
|
|
6
|
+
import { ContainerSlotNode } from "./container-slot.js";
|
|
7
|
+
import { EventControllerNode } from "./event-controller.js";
|
|
6
8
|
import { MenuNode } from "./menu.js";
|
|
7
9
|
import { MenuModel } from "./models/menu.js";
|
|
8
10
|
import { SlotNode } from "./slot.js";
|
|
9
11
|
import { WidgetNode } from "./widget.js";
|
|
10
12
|
|
|
11
|
-
type PopoverMenuChild = MenuNode | SlotNode | WidgetNode;
|
|
13
|
+
type PopoverMenuChild = MenuNode | SlotNode | ContainerSlotNode | EventControllerNode | WidgetNode;
|
|
12
14
|
|
|
13
15
|
export class PopoverMenuNode extends WidgetNode<PopoverMenuWidget, Props, PopoverMenuChild> {
|
|
14
16
|
private menu: MenuModel;
|
|
15
17
|
|
|
16
18
|
public override isValidChild(child: Node): boolean {
|
|
17
|
-
return
|
|
19
|
+
return (
|
|
20
|
+
child instanceof MenuNode ||
|
|
21
|
+
child instanceof SlotNode ||
|
|
22
|
+
child instanceof EventControllerNode ||
|
|
23
|
+
child instanceof ContainerSlotNode ||
|
|
24
|
+
child instanceof WidgetNode
|
|
25
|
+
);
|
|
18
26
|
}
|
|
19
27
|
|
|
20
28
|
constructor(typeName: string, props: Props, container: PopoverMenuWidget, rootContainer: Container) {
|
package/src/nodes/text-view.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { GtkTextViewProps } from "../jsx.js";
|
|
3
3
|
import type { Node } from "../node.js";
|
|
4
|
+
import { ContainerSlotNode } from "./container-slot.js";
|
|
4
5
|
import { EventControllerNode } from "./event-controller.js";
|
|
5
6
|
import { filterProps } from "./internal/props.js";
|
|
6
7
|
import { TextBufferController } from "./internal/text-buffer-controller.js";
|
|
@@ -22,7 +23,7 @@ const OWN_PROPS = [
|
|
|
22
23
|
] as const;
|
|
23
24
|
|
|
24
25
|
type TextViewProps = Pick<GtkTextViewProps, (typeof OWN_PROPS)[number]>;
|
|
25
|
-
type TextViewChild = TextContentChild | SlotNode | EventControllerNode | WidgetNode;
|
|
26
|
+
type TextViewChild = TextContentChild | SlotNode | ContainerSlotNode | EventControllerNode | WidgetNode;
|
|
26
27
|
|
|
27
28
|
export class TextViewNode extends WidgetNode<Gtk.TextView, TextViewProps, TextViewChild> implements TextContentParent {
|
|
28
29
|
protected bufferController: TextBufferController | null = null;
|
|
@@ -34,6 +35,7 @@ export class TextViewNode extends WidgetNode<Gtk.TextView, TextViewProps, TextVi
|
|
|
34
35
|
child instanceof TextAnchorNode ||
|
|
35
36
|
child instanceof TextPaintableNode ||
|
|
36
37
|
child instanceof SlotNode ||
|
|
38
|
+
child instanceof ContainerSlotNode ||
|
|
37
39
|
child instanceof EventControllerNode ||
|
|
38
40
|
child instanceof WidgetNode
|
|
39
41
|
);
|
package/src/nodes/window.ts
CHANGED
|
@@ -4,7 +4,9 @@ import type { GtkAboutDialogProps, GtkWindowProps } from "../jsx.js";
|
|
|
4
4
|
import type { Node } from "../node.js";
|
|
5
5
|
import type { Container, Props } from "../types.js";
|
|
6
6
|
import { AnimationNode } from "./animation.js";
|
|
7
|
+
import { ContainerSlotNode } from "./container-slot.js";
|
|
7
8
|
import type { DialogNode } from "./dialog.js";
|
|
9
|
+
import { EventControllerNode } from "./event-controller.js";
|
|
8
10
|
import { filterProps, hasChanged } from "./internal/props.js";
|
|
9
11
|
import { MenuNode } from "./menu.js";
|
|
10
12
|
import { MenuModel } from "./models/menu.js";
|
|
@@ -18,9 +20,18 @@ const isOrExtendsClass = (target: object, cls: abstract new (...args: any[]) =>
|
|
|
18
20
|
|
|
19
21
|
const OWN_PROPS = ["onClose"] as const;
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
type WindowProps = Pick<GtkWindowProps, "onClose"> & Pick<GtkAboutDialogProps, "creditSections">;
|
|
22
24
|
|
|
23
|
-
type WindowChild =
|
|
25
|
+
type WindowChild =
|
|
26
|
+
| WindowNode
|
|
27
|
+
| DialogNode
|
|
28
|
+
| MenuNode
|
|
29
|
+
| SlotNode
|
|
30
|
+
| ContainerSlotNode
|
|
31
|
+
| AnimationNode
|
|
32
|
+
| NavigationPageNode
|
|
33
|
+
| EventControllerNode
|
|
34
|
+
| WidgetNode;
|
|
24
35
|
|
|
25
36
|
export class WindowNode extends WidgetNode<Gtk.Window, WindowProps, WindowChild> {
|
|
26
37
|
private menu: MenuModel;
|
|
@@ -73,7 +84,9 @@ export class WindowNode extends WidgetNode<Gtk.Window, WindowProps, WindowChild>
|
|
|
73
84
|
child instanceof MenuNode ||
|
|
74
85
|
child instanceof SlotNode ||
|
|
75
86
|
child instanceof AnimationNode ||
|
|
76
|
-
child instanceof NavigationPageNode
|
|
87
|
+
child instanceof NavigationPageNode ||
|
|
88
|
+
child instanceof EventControllerNode ||
|
|
89
|
+
child instanceof ContainerSlotNode
|
|
77
90
|
);
|
|
78
91
|
}
|
|
79
92
|
|