@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.
- package/README.md +7 -7
- package/dist/factory.d.ts +0 -1
- package/dist/factory.js +21 -8
- package/dist/generated/internal.d.ts +4 -51
- package/dist/generated/internal.js +626 -412
- package/dist/generated/jsx.d.ts +453 -958
- package/dist/host-config.d.ts +1 -1
- package/dist/host-config.js +18 -23
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/jsx.d.ts +579 -302
- package/dist/jsx.js +37 -179
- package/dist/metadata.d.ts +3 -0
- package/dist/metadata.js +26 -0
- package/dist/node.d.ts +20 -12
- package/dist/node.js +72 -17
- package/dist/nodes/adjustable.d.ts +3 -16
- package/dist/nodes/adjustable.js +5 -22
- package/dist/nodes/alert-dialog-response.d.ts +14 -1
- package/dist/nodes/alert-dialog-response.js +36 -62
- package/dist/nodes/animation.d.ts +37 -1
- package/dist/nodes/animation.js +162 -105
- package/dist/nodes/application.d.ts +11 -1
- package/dist/nodes/application.js +17 -38
- package/dist/nodes/calendar.d.ts +13 -0
- package/dist/nodes/calendar.js +10 -16
- package/dist/nodes/color-dialog-button.d.ts +13 -0
- package/dist/nodes/color-dialog-button.js +10 -38
- package/dist/nodes/column-view-column.d.ts +13 -11
- package/dist/nodes/column-view-column.js +27 -23
- package/dist/nodes/column-view.d.ts +31 -0
- package/dist/nodes/column-view.js +44 -44
- package/dist/nodes/container-slot.d.ts +15 -0
- package/dist/nodes/container-slot.js +68 -0
- package/dist/nodes/dialog.d.ts +6 -8
- package/dist/nodes/dialog.js +12 -13
- package/dist/nodes/drawing-area.d.ts +12 -0
- package/dist/nodes/drawing-area.js +24 -24
- package/dist/nodes/drop-down.d.ts +22 -0
- package/dist/nodes/drop-down.js +72 -0
- package/dist/nodes/event-controller.d.ts +8 -17
- package/dist/nodes/event-controller.js +20 -42
- package/dist/nodes/fixed-child.d.ts +18 -1
- package/dist/nodes/fixed-child.js +52 -36
- package/dist/nodes/font-dialog-button.d.ts +13 -0
- package/dist/nodes/font-dialog-button.js +12 -35
- package/dist/nodes/grid-child.d.ts +17 -1
- package/dist/nodes/grid-child.js +57 -37
- package/dist/nodes/grid-view.d.ts +24 -0
- package/dist/nodes/grid-view.js +73 -0
- package/dist/nodes/internal/base-item-renderer.d.ts +7 -9
- package/dist/nodes/internal/base-item-renderer.js +15 -18
- package/dist/nodes/internal/grid-item-renderer.d.ts +17 -0
- package/dist/nodes/internal/grid-item-renderer.js +59 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +14 -9
- package/dist/nodes/internal/list-item-renderer.js +96 -35
- package/dist/nodes/internal/list-store.d.ts +5 -0
- package/dist/nodes/internal/list-store.js +39 -9
- package/dist/nodes/internal/predicates.d.ts +4 -19
- package/dist/nodes/internal/predicates.js +1 -20
- package/dist/nodes/internal/props.d.ts +5 -0
- package/dist/nodes/internal/props.js +42 -0
- package/dist/nodes/internal/{selection-model.d.ts → selection-model-controller.d.ts} +4 -9
- package/dist/nodes/internal/{selection-model.js → selection-model-controller.js} +6 -15
- package/dist/nodes/internal/signal-store.js +12 -5
- package/dist/nodes/internal/simple-list-store.d.ts +5 -0
- package/dist/nodes/internal/simple-list-store.js +42 -13
- package/dist/nodes/internal/text-buffer-controller.d.ts +4 -12
- package/dist/nodes/internal/text-buffer-controller.js +32 -33
- package/dist/nodes/internal/tree-store.d.ts +7 -0
- package/dist/nodes/internal/tree-store.js +75 -18
- package/dist/nodes/internal/widget.d.ts +7 -0
- package/dist/nodes/internal/widget.js +68 -0
- package/dist/nodes/level-bar.d.ts +10 -0
- package/dist/nodes/level-bar.js +11 -22
- package/dist/nodes/list-item.d.ts +17 -9
- package/dist/nodes/list-item.js +67 -12
- package/dist/nodes/list-view.d.ts +23 -0
- package/dist/nodes/list-view.js +27 -31
- package/dist/nodes/menu.d.ts +2 -4
- package/dist/nodes/menu.js +0 -6
- package/dist/nodes/models/grid.d.ts +27 -0
- package/dist/nodes/models/grid.js +68 -0
- package/dist/nodes/models/list.d.ts +15 -13
- package/dist/nodes/models/list.js +48 -26
- package/dist/nodes/models/menu.d.ts +15 -16
- package/dist/nodes/models/menu.js +63 -93
- package/dist/nodes/navigation-page.d.ts +16 -10
- package/dist/nodes/navigation-page.js +108 -31
- package/dist/nodes/navigation-view.d.ts +15 -0
- package/dist/nodes/navigation-view.js +15 -65
- package/dist/nodes/notebook-page-tab.d.ts +10 -12
- package/dist/nodes/notebook-page-tab.js +24 -27
- package/dist/nodes/notebook-page.d.ts +19 -16
- package/dist/nodes/notebook-page.js +75 -56
- package/dist/nodes/notebook.d.ts +10 -1
- package/dist/nodes/notebook.js +10 -22
- package/dist/nodes/overlay-child.d.ts +17 -1
- package/dist/nodes/overlay-child.js +53 -75
- package/dist/nodes/popover-menu.d.ts +15 -0
- package/dist/nodes/popover-menu.js +13 -26
- package/dist/nodes/scale.d.ts +8 -0
- package/dist/nodes/scale.js +2 -11
- package/dist/nodes/scrolled-window.d.ts +9 -0
- package/dist/nodes/scrolled-window.js +5 -11
- package/dist/nodes/search-bar.d.ts +9 -0
- package/dist/nodes/search-bar.js +8 -33
- package/dist/nodes/shortcut-controller.d.ts +9 -1
- package/dist/nodes/shortcut-controller.js +12 -25
- package/dist/nodes/shortcut.d.ts +11 -33
- package/dist/nodes/shortcut.js +19 -15
- package/dist/nodes/slot.d.ts +16 -15
- package/dist/nodes/slot.js +63 -57
- package/dist/nodes/source-view.d.ts +16 -0
- package/dist/nodes/source-view.js +44 -44
- package/dist/nodes/stack-page.d.ts +21 -1
- package/dist/nodes/stack-page.js +68 -17
- package/dist/nodes/stack.d.ts +11 -0
- package/dist/nodes/stack.js +8 -26
- package/dist/nodes/text-anchor.d.ts +11 -30
- package/dist/nodes/text-anchor.js +20 -22
- package/dist/nodes/text-content.d.ts +1 -0
- package/dist/nodes/text-content.js +1 -1
- package/dist/nodes/text-paintable.d.ts +10 -15
- package/dist/nodes/text-paintable.js +16 -9
- package/dist/nodes/text-segment.d.ts +12 -10
- package/dist/nodes/text-segment.js +19 -11
- package/dist/nodes/text-tag.d.ts +20 -119
- package/dist/nodes/text-tag.js +153 -119
- package/dist/nodes/text-view.d.ts +13 -18
- package/dist/nodes/text-view.js +17 -17
- package/dist/nodes/toggle-group.d.ts +9 -0
- package/dist/nodes/toggle-group.js +8 -33
- package/dist/nodes/toggle.d.ts +15 -1
- package/dist/nodes/toggle.js +34 -52
- package/dist/nodes/virtual.d.ts +3 -10
- package/dist/nodes/virtual.js +1 -14
- package/dist/nodes/web-view.d.ts +9 -0
- package/dist/nodes/web-view.js +10 -24
- package/dist/nodes/widget.d.ts +17 -13
- package/dist/nodes/widget.js +185 -112
- package/dist/nodes/window.d.ts +20 -21
- package/dist/nodes/window.js +54 -35
- package/dist/registry.d.ts +17 -6
- package/dist/registry.js +104 -5
- package/dist/render.d.ts +1 -10
- package/dist/render.js +1 -13
- package/package.json +6 -6
- package/dist/animation/css-builder.d.ts +0 -3
- package/dist/animation/css-builder.js +0 -53
- package/dist/animation/types.d.ts +0 -120
- package/dist/animation/types.js +0 -1
- package/dist/nodes/abstract/positional-child.d.ts +0 -9
- package/dist/nodes/abstract/positional-child.js +0 -29
- package/dist/nodes/abstract/virtual-container.d.ts +0 -21
- package/dist/nodes/abstract/virtual-container.js +0 -68
- package/dist/nodes/abstract/virtual-single-child.d.ts +0 -18
- package/dist/nodes/abstract/virtual-single-child.js +0 -55
- package/dist/nodes/action-row-child.d.ts +0 -1
- package/dist/nodes/action-row-child.js +0 -30
- package/dist/nodes/autowrapped.d.ts +0 -1
- package/dist/nodes/autowrapped.js +0 -115
- package/dist/nodes/expander-row-child.d.ts +0 -1
- package/dist/nodes/expander-row-child.js +0 -30
- package/dist/nodes/grid.d.ts +0 -1
- package/dist/nodes/grid.js +0 -41
- package/dist/nodes/index.d.ts +0 -56
- package/dist/nodes/index.js +0 -56
- package/dist/nodes/internal/child-attachment.d.ts +0 -26
- package/dist/nodes/internal/child-attachment.js +0 -48
- package/dist/nodes/internal/deferred-action.d.ts +0 -9
- package/dist/nodes/internal/deferred-action.js +0 -22
- package/dist/nodes/internal/text-tag-styles.d.ts +0 -43
- package/dist/nodes/internal/text-tag-styles.js +0 -52
- package/dist/nodes/internal/tree-list-item-renderer.d.ts +0 -26
- package/dist/nodes/internal/tree-list-item-renderer.js +0 -134
- package/dist/nodes/internal/utils.d.ts +0 -12
- package/dist/nodes/internal/utils.js +0 -92
- package/dist/nodes/models/tree-list.d.ts +0 -28
- package/dist/nodes/models/tree-list.js +0 -113
- package/dist/nodes/pack-child.d.ts +0 -1
- package/dist/nodes/pack-child.js +0 -30
- package/dist/nodes/simple-list-item.d.ts +0 -9
- package/dist/nodes/simple-list-item.js +0 -9
- package/dist/nodes/simple-list-view.d.ts +0 -1
- package/dist/nodes/simple-list-view.js +0 -74
- package/dist/nodes/toolbar-child.d.ts +0 -1
- package/dist/nodes/toolbar-child.js +0 -30
- package/dist/nodes/tree-list-item.d.ts +0 -22
- package/dist/nodes/tree-list-item.js +0 -90
- package/dist/nodes/tree-list-view.d.ts +0 -1
- package/dist/nodes/tree-list-view.js +0 -77
- package/dist/scheduler.d.ts +0 -26
- package/dist/scheduler.js +0 -42
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
1
|
import * as Gio from "@gtkx/ffi/gio";
|
|
3
|
-
import { CommitPriority, scheduleAfterCommit } from "../../scheduler.js";
|
|
4
2
|
import { VirtualNode } from "../virtual.js";
|
|
5
3
|
export class MenuModel extends VirtualNode {
|
|
6
4
|
actionMap = null;
|
|
7
5
|
actionPrefix;
|
|
8
|
-
parent = null;
|
|
9
6
|
menu;
|
|
10
7
|
type;
|
|
11
8
|
application = null;
|
|
12
9
|
action = null;
|
|
13
|
-
children = [];
|
|
14
10
|
constructor(type, props, rootContainer, actionMap, application) {
|
|
15
11
|
super("", props, undefined, rootContainer);
|
|
16
12
|
this.type = type;
|
|
@@ -19,6 +15,12 @@ export class MenuModel extends VirtualNode {
|
|
|
19
15
|
this.application = application ?? null;
|
|
20
16
|
this.menu = new Gio.Menu();
|
|
21
17
|
}
|
|
18
|
+
isValidChild(child) {
|
|
19
|
+
return child instanceof MenuModel;
|
|
20
|
+
}
|
|
21
|
+
isValidParent(parent) {
|
|
22
|
+
return parent instanceof MenuModel;
|
|
23
|
+
}
|
|
22
24
|
setActionMap(actionMap, prefix) {
|
|
23
25
|
this.actionMap = actionMap;
|
|
24
26
|
this.actionPrefix = prefix;
|
|
@@ -51,11 +53,11 @@ export class MenuModel extends VirtualNode {
|
|
|
51
53
|
}
|
|
52
54
|
return this.props.id;
|
|
53
55
|
}
|
|
54
|
-
|
|
56
|
+
getParentMenu() {
|
|
55
57
|
if (!this.parent) {
|
|
56
58
|
throw new Error("Expected parent menu to be set on MenuNode");
|
|
57
59
|
}
|
|
58
|
-
return this.parent;
|
|
60
|
+
return this.parent.getMenu();
|
|
59
61
|
}
|
|
60
62
|
getActionMap() {
|
|
61
63
|
if (!this.actionMap) {
|
|
@@ -85,28 +87,25 @@ export class MenuModel extends VirtualNode {
|
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
getPosition() {
|
|
88
|
-
return this.findPositionIn(this.
|
|
90
|
+
return this.findPositionIn(this.getParentMenu());
|
|
89
91
|
}
|
|
90
|
-
findPositionIn(
|
|
91
|
-
for (let i = 0; i <
|
|
92
|
+
findPositionIn(parentMenu) {
|
|
93
|
+
for (let i = 0; i < parentMenu.getNItems(); i++) {
|
|
92
94
|
if (this.type === "item") {
|
|
93
|
-
const actionName =
|
|
95
|
+
const actionName = parentMenu.getItemAttributeValue(i, "action")?.getString();
|
|
94
96
|
if (actionName === this.getActionName()) {
|
|
95
97
|
return i;
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
100
|
else {
|
|
99
|
-
const link =
|
|
100
|
-
if (link &&
|
|
101
|
+
const link = parentMenu.getItemLink(i, this.type);
|
|
102
|
+
if (link && link === this.menu) {
|
|
101
103
|
return i;
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
return -1;
|
|
106
108
|
}
|
|
107
|
-
setParent(parent) {
|
|
108
|
-
this.parent = parent;
|
|
109
|
-
}
|
|
110
109
|
getMenu() {
|
|
111
110
|
return this.menu;
|
|
112
111
|
}
|
|
@@ -116,98 +115,71 @@ export class MenuModel extends VirtualNode {
|
|
|
116
115
|
}
|
|
117
116
|
return this.action;
|
|
118
117
|
}
|
|
119
|
-
|
|
118
|
+
removeFromParentMenu() {
|
|
120
119
|
if (!this.parent)
|
|
121
120
|
return;
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
parent.remove(position);
|
|
128
|
-
}
|
|
129
|
-
}, CommitPriority.HIGH);
|
|
121
|
+
const parentMenu = this.parent.getMenu();
|
|
122
|
+
const position = this.findPositionIn(parentMenu);
|
|
123
|
+
if (position >= 0) {
|
|
124
|
+
parentMenu.remove(position);
|
|
125
|
+
}
|
|
130
126
|
}
|
|
131
127
|
insertInParentBefore(before) {
|
|
132
128
|
if (this.type === "item" && this.actionMap) {
|
|
133
129
|
this.createAction();
|
|
134
130
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
case "section":
|
|
144
|
-
parent.insertSection(beforePosition, this.menu, this.props.label);
|
|
145
|
-
break;
|
|
146
|
-
case "submenu":
|
|
147
|
-
parent.insertSubmenu(beforePosition, this.menu, this.props.label);
|
|
148
|
-
break;
|
|
131
|
+
const parentMenu = this.getParentMenu();
|
|
132
|
+
const beforePosition = before.getPosition();
|
|
133
|
+
switch (this.type) {
|
|
134
|
+
case "item": {
|
|
135
|
+
parentMenu.insert(beforePosition, this.props.label, this.getActionName());
|
|
136
|
+
break;
|
|
149
137
|
}
|
|
150
|
-
|
|
138
|
+
case "section":
|
|
139
|
+
parentMenu.insertSection(beforePosition, this.menu, this.props.label);
|
|
140
|
+
break;
|
|
141
|
+
case "submenu":
|
|
142
|
+
parentMenu.insertSubmenu(beforePosition, this.menu, this.props.label);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
151
145
|
}
|
|
152
|
-
|
|
146
|
+
appendToParentMenu() {
|
|
153
147
|
if (this.type === "item" && this.actionMap) {
|
|
154
148
|
this.createAction();
|
|
155
149
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
}, CommitPriority.NORMAL);
|
|
150
|
+
const parentMenu = this.getParentMenu();
|
|
151
|
+
switch (this.type) {
|
|
152
|
+
case "item":
|
|
153
|
+
parentMenu.append(this.props.label, this.getActionName());
|
|
154
|
+
break;
|
|
155
|
+
case "section":
|
|
156
|
+
parentMenu.appendSection(this.menu, this.props.label);
|
|
157
|
+
break;
|
|
158
|
+
case "submenu":
|
|
159
|
+
parentMenu.appendSubmenu(this.menu, this.props.label);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
170
162
|
}
|
|
171
163
|
appendChild(child) {
|
|
172
|
-
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
this.children.push(child);
|
|
164
|
+
super.appendChild(child);
|
|
176
165
|
if (this.actionMap) {
|
|
177
166
|
child.setActionMap(this.actionMap, this.actionPrefix);
|
|
178
167
|
}
|
|
179
|
-
child.
|
|
180
|
-
child.appendToParent();
|
|
168
|
+
child.appendToParentMenu();
|
|
181
169
|
}
|
|
182
170
|
insertBefore(child, before) {
|
|
183
|
-
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
const beforeIndex = this.children.indexOf(before);
|
|
187
|
-
if (beforeIndex >= 0) {
|
|
188
|
-
this.children.splice(beforeIndex, 0, child);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
this.children.push(child);
|
|
192
|
-
}
|
|
171
|
+
super.insertBefore(child, before);
|
|
193
172
|
if (this.actionMap) {
|
|
194
173
|
child.setActionMap(this.actionMap, this.actionPrefix);
|
|
195
174
|
}
|
|
196
|
-
child.setParent(this.menu);
|
|
197
175
|
child.insertInParentBefore(before);
|
|
198
176
|
}
|
|
199
177
|
removeChild(child) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
const index = this.children.indexOf(child);
|
|
204
|
-
if (index >= 0) {
|
|
205
|
-
this.children.splice(index, 1);
|
|
206
|
-
}
|
|
207
|
-
child.removeFromParent();
|
|
178
|
+
child.removeFromParentMenu();
|
|
179
|
+
super.removeChild(child);
|
|
208
180
|
}
|
|
209
|
-
|
|
210
|
-
super.
|
|
181
|
+
commitUpdate(oldProps, newProps) {
|
|
182
|
+
super.commitUpdate(oldProps, newProps);
|
|
211
183
|
if (this.type === "item") {
|
|
212
184
|
this.updateItemProps(oldProps, newProps);
|
|
213
185
|
}
|
|
@@ -223,12 +195,10 @@ export class MenuModel extends VirtualNode {
|
|
|
223
195
|
return;
|
|
224
196
|
}
|
|
225
197
|
if (oldProps.id !== newProps.id || oldProps.label !== newProps.label) {
|
|
226
|
-
const parent = this.parent;
|
|
227
198
|
this.removeAction();
|
|
228
|
-
this.
|
|
229
|
-
this.parent = parent;
|
|
199
|
+
this.removeFromParentMenu();
|
|
230
200
|
this.createAction();
|
|
231
|
-
this.
|
|
201
|
+
this.appendToParentMenu();
|
|
232
202
|
return;
|
|
233
203
|
}
|
|
234
204
|
if (oldProps.onActivate !== newProps.onActivate) {
|
|
@@ -245,22 +215,22 @@ export class MenuModel extends VirtualNode {
|
|
|
245
215
|
return;
|
|
246
216
|
}
|
|
247
217
|
if (!oldProps || oldProps.label !== newProps.label) {
|
|
248
|
-
const
|
|
249
|
-
const position = this.findPositionIn(
|
|
218
|
+
const parentMenu = this.parent.getMenu();
|
|
219
|
+
const position = this.findPositionIn(parentMenu);
|
|
250
220
|
if (position >= 0) {
|
|
251
|
-
|
|
221
|
+
parentMenu.remove(position);
|
|
252
222
|
if (this.type === "section") {
|
|
253
|
-
|
|
223
|
+
parentMenu.insertSection(position, this.menu, this.props.label);
|
|
254
224
|
}
|
|
255
225
|
else if (this.type === "submenu") {
|
|
256
|
-
|
|
226
|
+
parentMenu.insertSubmenu(position, this.menu, this.props.label);
|
|
257
227
|
}
|
|
258
228
|
}
|
|
259
229
|
}
|
|
260
230
|
}
|
|
261
|
-
|
|
231
|
+
detachDeletedInstance() {
|
|
262
232
|
this.removeAction();
|
|
263
|
-
this.
|
|
264
|
-
super.
|
|
233
|
+
this.removeFromParentMenu();
|
|
234
|
+
super.detachDeletedInstance();
|
|
265
235
|
}
|
|
266
236
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import * as Adw from "@gtkx/ffi/adw";
|
|
2
1
|
import type { NavigationPageProps } from "../jsx.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import type { Node } from "../node.js";
|
|
3
|
+
import { VirtualNode } from "./virtual.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
export declare class NavigationPageNode extends VirtualNode<NavigationPageProps, WidgetNode, WidgetNode> {
|
|
6
|
+
private wrappedPage;
|
|
7
|
+
isValidChild(child: Node): boolean;
|
|
8
|
+
isValidParent(parent: Node): boolean;
|
|
9
|
+
setParent(parent: WidgetNode | null): void;
|
|
10
|
+
appendChild(child: WidgetNode): void;
|
|
11
|
+
removeChild(child: WidgetNode): void;
|
|
12
|
+
commitUpdate(oldProps: NavigationPageProps | null, newProps: NavigationPageProps): void;
|
|
13
|
+
detachDeletedInstance(): void;
|
|
14
|
+
private applyOwnProps;
|
|
15
|
+
private onChildChange;
|
|
16
|
+
private applySlotChild;
|
|
17
|
+
private getParentWidget;
|
|
11
18
|
}
|
|
12
|
-
export {};
|
|
@@ -1,51 +1,128 @@
|
|
|
1
1
|
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
-
import {
|
|
3
|
-
import { hasChanged } from "./internal/
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import { toCamelCase } from "@gtkx/gir";
|
|
3
|
+
import { hasChanged } from "./internal/props.js";
|
|
4
|
+
import { getFocusWidget, isDescendantOf, resolvePropertySetter } from "./internal/widget.js";
|
|
5
|
+
import { VirtualNode } from "./virtual.js";
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
export class NavigationPageNode extends VirtualNode {
|
|
8
|
+
wrappedPage = null;
|
|
9
|
+
isValidChild(child) {
|
|
10
|
+
return child instanceof WidgetNode;
|
|
11
|
+
}
|
|
12
|
+
isValidParent(parent) {
|
|
13
|
+
return parent instanceof WidgetNode;
|
|
14
|
+
}
|
|
15
|
+
setParent(parent) {
|
|
16
|
+
if (!parent && this.parent && this.wrappedPage) {
|
|
17
|
+
const parentWidget = this.getParentWidget();
|
|
18
|
+
if (parentWidget instanceof Adw.NavigationView) {
|
|
19
|
+
parentWidget.remove(this.wrappedPage);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.applySlotChild(parentWidget, this.wrappedPage);
|
|
23
|
+
}
|
|
24
|
+
this.wrappedPage = null;
|
|
25
|
+
}
|
|
26
|
+
super.setParent(parent);
|
|
27
|
+
if (parent && this.children[0]) {
|
|
28
|
+
this.onChildChange(null);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
appendChild(child) {
|
|
32
|
+
const oldChildWidget = this.children[0]?.container ?? null;
|
|
33
|
+
super.appendChild(child);
|
|
34
|
+
if (this.parent) {
|
|
35
|
+
this.onChildChange(oldChildWidget);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
removeChild(child) {
|
|
39
|
+
const oldChildWidget = child.container;
|
|
40
|
+
super.removeChild(child);
|
|
41
|
+
if (this.parent && oldChildWidget) {
|
|
42
|
+
this.onChildChange(oldChildWidget);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
commitUpdate(oldProps, newProps) {
|
|
46
|
+
super.commitUpdate(oldProps, newProps);
|
|
12
47
|
this.applyOwnProps(oldProps, newProps);
|
|
13
48
|
}
|
|
49
|
+
detachDeletedInstance() {
|
|
50
|
+
if (this.parent && this.wrappedPage) {
|
|
51
|
+
const parentWidget = this.getParentWidget();
|
|
52
|
+
if (parentWidget instanceof Adw.NavigationView) {
|
|
53
|
+
parentWidget.remove(this.wrappedPage);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.applySlotChild(parentWidget, this.wrappedPage);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
this.wrappedPage = null;
|
|
60
|
+
super.detachDeletedInstance();
|
|
61
|
+
}
|
|
14
62
|
applyOwnProps(oldProps, newProps) {
|
|
15
|
-
|
|
16
|
-
if (!(child instanceof Adw.NavigationPage)) {
|
|
63
|
+
if (!this.wrappedPage) {
|
|
17
64
|
return;
|
|
18
65
|
}
|
|
19
|
-
if (hasChanged(oldProps, newProps, "id")
|
|
20
|
-
|
|
66
|
+
if (hasChanged(oldProps, newProps, "id")) {
|
|
67
|
+
this.wrappedPage.setTag(newProps.id);
|
|
21
68
|
}
|
|
22
|
-
if (hasChanged(oldProps, newProps, "title")
|
|
23
|
-
|
|
69
|
+
if (hasChanged(oldProps, newProps, "title")) {
|
|
70
|
+
this.wrappedPage.setTitle(newProps.title ?? "");
|
|
24
71
|
}
|
|
25
|
-
if (hasChanged(oldProps, newProps, "canPop")
|
|
26
|
-
|
|
72
|
+
if (hasChanged(oldProps, newProps, "canPop")) {
|
|
73
|
+
this.wrappedPage.setCanPop(newProps.canPop ?? true);
|
|
27
74
|
}
|
|
28
75
|
}
|
|
29
76
|
onChildChange(oldChild) {
|
|
30
|
-
const
|
|
77
|
+
const parentWidget = this.getParentWidget();
|
|
31
78
|
const title = this.props.title ?? "";
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
79
|
+
const childWidget = this.children[0]?.container ?? null;
|
|
80
|
+
if (childWidget) {
|
|
81
|
+
const wrappedChild = this.props.id
|
|
82
|
+
? Adw.NavigationPage.newWithTag(childWidget, title, this.props.id)
|
|
83
|
+
: new Adw.NavigationPage(childWidget, title);
|
|
84
|
+
this.wrappedPage = wrappedChild;
|
|
85
|
+
this.applyOwnProps(null, this.props);
|
|
86
|
+
if (parentWidget instanceof Adw.NavigationView) {
|
|
87
|
+
if (oldChild instanceof Adw.NavigationPage) {
|
|
88
|
+
parentWidget.remove(oldChild);
|
|
89
|
+
}
|
|
90
|
+
parentWidget.add(wrappedChild);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.applySlotChild(parentWidget, oldChild);
|
|
94
|
+
}
|
|
37
95
|
}
|
|
38
|
-
if (
|
|
96
|
+
else if (parentWidget instanceof Adw.NavigationView) {
|
|
39
97
|
if (oldChild instanceof Adw.NavigationPage) {
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
if (this.child) {
|
|
43
|
-
navigationView.add(this.child);
|
|
98
|
+
parentWidget.remove(oldChild);
|
|
44
99
|
}
|
|
100
|
+
this.wrappedPage = null;
|
|
45
101
|
}
|
|
46
102
|
else {
|
|
47
|
-
|
|
103
|
+
this.wrappedPage = null;
|
|
104
|
+
this.applySlotChild(parentWidget, oldChild);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
applySlotChild(parentWidget, oldChild) {
|
|
108
|
+
const propId = toCamelCase(this.props.id ?? "");
|
|
109
|
+
const setter = resolvePropertySetter(parentWidget, propId);
|
|
110
|
+
if (!setter) {
|
|
111
|
+
const parentType = parentWidget.constructor.glibTypeName;
|
|
112
|
+
throw new Error(`Unable to find property for slot '${propId}' on type '${parentType}'`);
|
|
113
|
+
}
|
|
114
|
+
if (oldChild && !this.wrappedPage) {
|
|
115
|
+
const focus = getFocusWidget(oldChild);
|
|
116
|
+
if (focus && isDescendantOf(focus, oldChild)) {
|
|
117
|
+
parentWidget.grabFocus();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
setter(this.wrappedPage);
|
|
121
|
+
}
|
|
122
|
+
getParentWidget() {
|
|
123
|
+
if (!this.parent) {
|
|
124
|
+
throw new Error("Expected parent widget to be set on NavigationPageNode");
|
|
48
125
|
}
|
|
126
|
+
return this.parent.container;
|
|
49
127
|
}
|
|
50
128
|
}
|
|
51
|
-
registerNodeClass(NavigationPageNode);
|
|
@@ -1 +1,16 @@
|
|
|
1
|
+
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
+
import type { AdwNavigationViewProps } from "../jsx.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import { NavigationPageNode } from "./navigation-page.js";
|
|
5
|
+
import { SlotNode } from "./slot.js";
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
declare const OWN_PROPS: readonly ["history", "onHistoryChanged"];
|
|
8
|
+
type NavigationViewProps = Pick<AdwNavigationViewProps, (typeof OWN_PROPS)[number]>;
|
|
9
|
+
type NavigationViewChild = NavigationPageNode | SlotNode | WidgetNode;
|
|
10
|
+
export declare class NavigationViewNode extends WidgetNode<Adw.NavigationView, NavigationViewProps, NavigationViewChild> {
|
|
11
|
+
isValidChild(child: Node): boolean;
|
|
12
|
+
commitUpdate(oldProps: NavigationViewProps | null, newProps: NavigationViewProps): void;
|
|
13
|
+
private applyOwnProps;
|
|
14
|
+
private getCurrentHistory;
|
|
15
|
+
}
|
|
1
16
|
export {};
|
|
@@ -1,89 +1,40 @@
|
|
|
1
1
|
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
-
import {
|
|
3
|
-
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
4
|
-
import { filterProps, hasChanged, matchesAnyClass, primitiveArrayEqual } from "./internal/utils.js";
|
|
2
|
+
import { filterProps, hasChanged, primitiveArrayEqual } from "./internal/props.js";
|
|
5
3
|
import { NavigationPageNode } from "./navigation-page.js";
|
|
6
4
|
import { SlotNode } from "./slot.js";
|
|
7
5
|
import { WidgetNode } from "./widget.js";
|
|
8
6
|
const OWN_PROPS = ["history", "onHistoryChanged"];
|
|
9
|
-
class NavigationViewNode extends WidgetNode {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return matchesAnyClass([Adw.NavigationView], containerOrClass);
|
|
7
|
+
export class NavigationViewNode extends WidgetNode {
|
|
8
|
+
isValidChild(child) {
|
|
9
|
+
return child instanceof NavigationPageNode || child instanceof SlotNode || child instanceof WidgetNode;
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
child.setParent(this.container);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (child instanceof SlotNode || child instanceof WidgetNode) {
|
|
20
|
-
super.appendChild(child);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
throw new Error(`Cannot append '${child.typeName}' to 'NavigationView': expected x.NavigationPage or Widget`);
|
|
24
|
-
}
|
|
25
|
-
insertBefore(child, before) {
|
|
26
|
-
if (child instanceof NavigationPageNode) {
|
|
27
|
-
child.setParent(this.container);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (child instanceof SlotNode || child instanceof WidgetNode) {
|
|
31
|
-
super.insertBefore(child, before);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
throw new Error(`Cannot insert '${child.typeName}' into 'NavigationView': expected x.NavigationPage or Widget`);
|
|
35
|
-
}
|
|
36
|
-
removeChild(child) {
|
|
37
|
-
if (child instanceof NavigationPageNode) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (child instanceof SlotNode || child instanceof WidgetNode) {
|
|
41
|
-
super.removeChild(child);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
throw new Error(`Cannot remove '${child.typeName}' from 'NavigationView': expected x.NavigationPage or Widget`);
|
|
45
|
-
}
|
|
46
|
-
updateProps(oldProps, newProps) {
|
|
47
|
-
super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
11
|
+
commitUpdate(oldProps, newProps) {
|
|
12
|
+
super.commitUpdate(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
48
13
|
this.applyOwnProps(oldProps, newProps);
|
|
49
14
|
}
|
|
50
15
|
applyOwnProps(oldProps, newProps) {
|
|
51
16
|
const oldHistory = oldProps?.history;
|
|
52
17
|
const newHistory = newProps.history;
|
|
53
18
|
if (newHistory && !primitiveArrayEqual(oldHistory, newHistory)) {
|
|
54
|
-
this.
|
|
19
|
+
this.container.replaceWithTags(newHistory, newHistory.length);
|
|
55
20
|
}
|
|
56
21
|
if (hasChanged(oldProps, newProps, "onHistoryChanged")) {
|
|
57
|
-
const onHistoryChanged = newProps
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
this.signalStore.set(this, this.container, "popped", handleHistoryChanged);
|
|
64
|
-
this.signalStore.set(this, this.container, "pushed", handleHistoryChanged);
|
|
65
|
-
this.signalStore.set(this, this.container, "replaced", handleHistoryChanged);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
this.signalStore.set(this, this.container, "popped", null);
|
|
69
|
-
this.signalStore.set(this, this.container, "pushed", null);
|
|
70
|
-
this.signalStore.set(this, this.container, "replaced", null);
|
|
71
|
-
}
|
|
22
|
+
const { onHistoryChanged } = newProps;
|
|
23
|
+
const handler = onHistoryChanged ? () => onHistoryChanged(this.getCurrentHistory()) : undefined;
|
|
24
|
+
this.signalStore.set(this, this.container, "popped", handler);
|
|
25
|
+
this.signalStore.set(this, this.container, "pushed", handler);
|
|
26
|
+
this.signalStore.set(this, this.container, "replaced", handler);
|
|
72
27
|
}
|
|
73
28
|
}
|
|
74
|
-
syncHistory(history) {
|
|
75
|
-
const container = this.container;
|
|
76
|
-
scheduleAfterCommit(() => {
|
|
77
|
-
container.replaceWithTags(history, history.length);
|
|
78
|
-
}, CommitPriority.NORMAL);
|
|
79
|
-
}
|
|
80
29
|
getCurrentHistory() {
|
|
81
30
|
const stack = this.container.getNavigationStack();
|
|
82
31
|
const history = [];
|
|
83
32
|
const nItems = stack.getNItems();
|
|
84
33
|
for (let i = 0; i < nItems; i++) {
|
|
85
34
|
const page = stack.getObject(i);
|
|
86
|
-
|
|
35
|
+
if (!(page instanceof Adw.NavigationPage))
|
|
36
|
+
continue;
|
|
37
|
+
const tag = page.getTag();
|
|
87
38
|
if (tag) {
|
|
88
39
|
history.push(tag);
|
|
89
40
|
}
|
|
@@ -91,4 +42,3 @@ class NavigationViewNode extends WidgetNode {
|
|
|
91
42
|
return history;
|
|
92
43
|
}
|
|
93
44
|
}
|
|
94
|
-
registerNodeClass(NavigationViewNode);
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
1
|
import type { SlotProps } from "../jsx.js";
|
|
3
|
-
import {
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
setPage(notebook: Gtk.Notebook | null, page: Gtk.Widget | null): void;
|
|
11
|
-
updateProps(oldProps: Props | null, newProps: Props): void;
|
|
2
|
+
import type { Node } from "../node.js";
|
|
3
|
+
import type { NotebookPageNode } from "./notebook-page.js";
|
|
4
|
+
import { VirtualNode } from "./virtual.js";
|
|
5
|
+
import { WidgetNode } from "./widget.js";
|
|
6
|
+
export declare class NotebookPageTabNode extends VirtualNode<SlotProps, NotebookPageNode, WidgetNode> {
|
|
7
|
+
isValidChild(child: Node): boolean;
|
|
8
|
+
isValidParent(parent: Node): boolean;
|
|
12
9
|
private getNotebook;
|
|
13
10
|
private getPage;
|
|
14
|
-
|
|
11
|
+
appendChild(child: WidgetNode): void;
|
|
12
|
+
removeChild(child: WidgetNode): void;
|
|
13
|
+
private onChildChange;
|
|
15
14
|
}
|
|
16
|
-
export {};
|