@gtkx/react 0.8.0 → 0.9.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.
- package/dist/{container-interfaces.d.ts → containers.d.ts} +10 -37
- package/dist/containers.js +1 -0
- package/dist/factory.d.ts +1 -1
- package/dist/factory.js +3 -3
- package/dist/{reconciler/host-config.d.ts → host-config.d.ts} +2 -2
- package/dist/{reconciler/host-config.js → host-config.js} +2 -2
- package/dist/node.d.ts +5 -6
- package/dist/node.js +54 -72
- package/dist/nodes/about-dialog.d.ts +2 -3
- package/dist/nodes/about-dialog.js +6 -4
- package/dist/nodes/column-view.d.ts +10 -9
- package/dist/nodes/column-view.js +53 -40
- package/dist/nodes/flow-box.js +1 -1
- package/dist/nodes/grid.d.ts +4 -1
- package/dist/nodes/grid.js +39 -1
- package/dist/nodes/header-bar.d.ts +15 -14
- package/dist/nodes/header-bar.js +79 -39
- package/dist/nodes/indexed-child-container.d.ts +1 -1
- package/dist/nodes/list-box.js +2 -2
- package/dist/nodes/list-item-factory.js +3 -3
- package/dist/nodes/list-view.d.ts +1 -2
- package/dist/nodes/list-view.js +2 -2
- package/dist/nodes/menu.d.ts +28 -12
- package/dist/nodes/menu.js +64 -37
- package/dist/nodes/notebook.d.ts +4 -1
- package/dist/nodes/notebook.js +48 -4
- package/dist/nodes/overlay.d.ts +1 -1
- package/dist/nodes/overlay.js +1 -1
- package/dist/nodes/paged-stack.d.ts +7 -3
- package/dist/nodes/paged-stack.js +47 -2
- package/dist/nodes/root.d.ts +1 -1
- package/dist/nodes/root.js +2 -2
- package/dist/nodes/selectable-list.d.ts +7 -3
- package/dist/nodes/selectable-list.js +37 -5
- package/dist/nodes/slot.d.ts +3 -4
- package/dist/nodes/slot.js +11 -10
- package/dist/nodes/stack-page-props.d.ts +1 -1
- package/dist/nodes/stack.d.ts +1 -1
- package/dist/nodes/stack.js +2 -2
- package/dist/nodes/string-list-container.d.ts +5 -12
- package/dist/nodes/string-list-container.js +34 -6
- package/dist/nodes/string-list-item.d.ts +10 -6
- package/dist/nodes/string-list-item.js +19 -17
- package/dist/nodes/toggle-button.d.ts +0 -3
- package/dist/nodes/toggle-button.js +0 -28
- package/dist/nodes/toolbar-view.d.ts +2 -3
- package/dist/nodes/toolbar-view.js +10 -9
- package/dist/nodes/view-stack.d.ts +1 -1
- package/dist/nodes/view-stack.js +2 -2
- package/dist/nodes/virtual-item.d.ts +9 -5
- package/dist/nodes/virtual-item.js +16 -20
- package/dist/nodes/virtual-slot.d.ts +4 -4
- package/dist/nodes/virtual-slot.js +12 -26
- package/dist/nodes/window.d.ts +2 -1
- package/dist/nodes/window.js +7 -3
- package/dist/predicates.d.ts +9 -18
- package/dist/predicates.js +31 -18
- package/dist/reconciler.d.ts +1 -1
- package/dist/reconciler.js +1 -1
- package/dist/types.d.ts +2 -0
- package/package.json +5 -5
- package/dist/container-interfaces.js +0 -26
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
const hasGetId = (node) => {
|
|
4
|
-
return typeof node.getId === "function";
|
|
5
|
-
};
|
|
1
|
+
import { Node as NodeClass } from "../node.js";
|
|
2
|
+
import { isItemContainer } from "../predicates.js";
|
|
6
3
|
/**
|
|
7
4
|
* Base class for virtual item nodes used in list-based containers.
|
|
8
5
|
* Virtual nodes don't create GTK widgets directly but represent items
|
|
9
6
|
* in list models (ListView, GridView, ColumnView).
|
|
10
7
|
*/
|
|
11
|
-
export class VirtualItemNode extends
|
|
8
|
+
export class VirtualItemNode extends NodeClass {
|
|
12
9
|
static consumedPropNames = ["id", "item"];
|
|
13
10
|
isVirtual() {
|
|
14
11
|
return true;
|
|
15
12
|
}
|
|
16
13
|
id = "";
|
|
17
14
|
item;
|
|
15
|
+
parentContainer = null;
|
|
18
16
|
initialize(props) {
|
|
19
17
|
this.id = props.id;
|
|
20
18
|
this.item = props.item;
|
|
@@ -26,23 +24,21 @@ export class VirtualItemNode extends Node {
|
|
|
26
24
|
getItem() {
|
|
27
25
|
return this.item;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
parent.addItem(this.id, this.item);
|
|
32
|
-
}
|
|
27
|
+
setParentContainer(container) {
|
|
28
|
+
this.parentContainer = container;
|
|
33
29
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.attachToParent(parent);
|
|
40
|
-
}
|
|
30
|
+
addToContainer(container) {
|
|
31
|
+
container.addItem(this.id, this.item);
|
|
32
|
+
}
|
|
33
|
+
insertBeforeInContainer(container, beforeId) {
|
|
34
|
+
container.insertItemBefore(this.id, this.item, beforeId);
|
|
41
35
|
}
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
|
|
36
|
+
unmount() {
|
|
37
|
+
if (this.parentContainer) {
|
|
38
|
+
this.parentContainer.removeItem(this.id);
|
|
45
39
|
}
|
|
40
|
+
this.parentContainer = null;
|
|
41
|
+
super.unmount();
|
|
46
42
|
}
|
|
47
43
|
updateProps(oldProps, newProps) {
|
|
48
44
|
const newId = newProps.id;
|
|
@@ -16,10 +16,10 @@ export declare abstract class VirtualSlotNode<TContainer, TProps> extends Node<n
|
|
|
16
16
|
protected abstract extractSlotProps(props: Props): TProps;
|
|
17
17
|
initialize(props: Props): void;
|
|
18
18
|
getChildWidget(): Gtk.Widget | null;
|
|
19
|
+
getSlotProps(): TProps;
|
|
20
|
+
setParentContainer(container: Node & TContainer): void;
|
|
21
|
+
getBeforeWidget(before: Node): Gtk.Widget | null;
|
|
19
22
|
appendChild(child: Node): void;
|
|
20
|
-
|
|
21
|
-
attachToParentBefore(parent: Node, before: Node): void;
|
|
22
|
-
protected getBeforeWidget(before: Node): Gtk.Widget | null;
|
|
23
|
-
detachFromParent(parent: Node): void;
|
|
23
|
+
unmount(): void;
|
|
24
24
|
protected updateSlotPropsIfChanged(oldProps: Props, newProps: Props, propKeys: string[]): boolean;
|
|
25
25
|
}
|
|
@@ -22,29 +22,11 @@ export class VirtualSlotNode extends Node {
|
|
|
22
22
|
getChildWidget() {
|
|
23
23
|
return this.childWidget;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (childWidget) {
|
|
28
|
-
this.childWidget = childWidget;
|
|
29
|
-
}
|
|
25
|
+
getSlotProps() {
|
|
26
|
+
return this.slotProps;
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.parentContainer = parent;
|
|
34
|
-
this.addToContainer(parent, this.childWidget, this.slotProps);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
attachToParentBefore(parent, before) {
|
|
38
|
-
if (this.isValidContainer(parent) && this.childWidget) {
|
|
39
|
-
this.parentContainer = parent;
|
|
40
|
-
const beforeWidget = this.getBeforeWidget(before);
|
|
41
|
-
if (beforeWidget) {
|
|
42
|
-
this.insertBeforeInContainer(parent, this.childWidget, this.slotProps, beforeWidget);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
this.addToContainer(parent, this.childWidget, this.slotProps);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
28
|
+
setParentContainer(container) {
|
|
29
|
+
this.parentContainer = container;
|
|
48
30
|
}
|
|
49
31
|
getBeforeWidget(before) {
|
|
50
32
|
if (before instanceof VirtualSlotNode) {
|
|
@@ -52,12 +34,16 @@ export class VirtualSlotNode extends Node {
|
|
|
52
34
|
}
|
|
53
35
|
return before.getWidget() ?? null;
|
|
54
36
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.
|
|
37
|
+
appendChild(child) {
|
|
38
|
+
const childWidget = child.getWidget();
|
|
39
|
+
if (childWidget) {
|
|
40
|
+
this.childWidget = childWidget;
|
|
59
41
|
}
|
|
60
42
|
}
|
|
43
|
+
unmount() {
|
|
44
|
+
this.parentContainer = null;
|
|
45
|
+
super.unmount();
|
|
46
|
+
}
|
|
61
47
|
updateSlotPropsIfChanged(oldProps, newProps, propKeys) {
|
|
62
48
|
const changed = propKeys.some((key) => oldProps[key] !== newProps[key]);
|
|
63
49
|
if (changed) {
|
package/dist/nodes/window.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import { Node } from "../node.js";
|
|
|
4
4
|
export declare class WindowNode extends Node<Gtk.Window> {
|
|
5
5
|
static consumedPropNames: string[];
|
|
6
6
|
static matches(type: string): boolean;
|
|
7
|
+
protected isStandalone(): boolean;
|
|
7
8
|
protected createWidget(type: string, _props: Props): Gtk.Window;
|
|
8
|
-
detachFromParent(_parent: Node): void;
|
|
9
9
|
mount(): void;
|
|
10
|
+
unmount(): void;
|
|
10
11
|
updateProps(oldProps: Props, newProps: Props): void;
|
|
11
12
|
}
|
package/dist/nodes/window.js
CHANGED
|
@@ -8,6 +8,9 @@ export class WindowNode extends Node {
|
|
|
8
8
|
static matches(type) {
|
|
9
9
|
return WINDOW_TYPES.has(normalizeWidgetType(type));
|
|
10
10
|
}
|
|
11
|
+
isStandalone() {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
11
14
|
createWidget(type, _props) {
|
|
12
15
|
const widgetType = normalizeWidgetType(type);
|
|
13
16
|
if (widgetType === "ApplicationWindow") {
|
|
@@ -21,12 +24,13 @@ export class WindowNode extends Node {
|
|
|
21
24
|
}
|
|
22
25
|
return new Gtk.Window();
|
|
23
26
|
}
|
|
24
|
-
detachFromParent(_parent) {
|
|
25
|
-
this.widget.destroy();
|
|
26
|
-
}
|
|
27
27
|
mount() {
|
|
28
28
|
this.widget.present();
|
|
29
29
|
}
|
|
30
|
+
unmount() {
|
|
31
|
+
this.widget.destroy();
|
|
32
|
+
super.unmount();
|
|
33
|
+
}
|
|
30
34
|
updateProps(oldProps, newProps) {
|
|
31
35
|
const widthChanged = oldProps.defaultWidth !== newProps.defaultWidth;
|
|
32
36
|
const heightChanged = oldProps.defaultHeight !== newProps.defaultHeight;
|
package/dist/predicates.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { ChildContainer, GridContainer, ItemContainer, PackContainer, PageContainer, StackPageContainer, StringListContainer } from "./containers.js";
|
|
3
|
+
import type { Node } from "./node.js";
|
|
2
4
|
interface Appendable extends Gtk.Widget {
|
|
3
5
|
append(child: unknown): void;
|
|
4
6
|
}
|
|
@@ -11,28 +13,17 @@ interface SingleChild extends Gtk.Widget {
|
|
|
11
13
|
interface Removable extends Gtk.Widget {
|
|
12
14
|
remove(child: unknown): void;
|
|
13
15
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Type guard that checks if a GTK widget supports appending children via an append method.
|
|
16
|
-
*/
|
|
17
16
|
export declare const isAppendable: (widget: Gtk.Widget) => widget is Appendable;
|
|
18
|
-
/**
|
|
19
|
-
* Type guard that checks if a GTK widget supports adding children via an add method.
|
|
20
|
-
*/
|
|
21
17
|
export declare const isAddable: (widget: Gtk.Widget) => widget is Addable;
|
|
22
|
-
/**
|
|
23
|
-
* Type guard that checks if a GTK widget supports a single child via setChild method.
|
|
24
|
-
*/
|
|
25
18
|
export declare const isSingleChild: (widget: Gtk.Widget) => widget is SingleChild;
|
|
26
|
-
/**
|
|
27
|
-
* Type guard that checks if a GTK widget supports removing children via a remove method.
|
|
28
|
-
*/
|
|
29
19
|
export declare const isRemovable: (widget: Gtk.Widget) => widget is Removable;
|
|
30
|
-
/**
|
|
31
|
-
* Type guard that checks if a GTK widget is a FlowBoxChild.
|
|
32
|
-
*/
|
|
33
20
|
export declare const isFlowBoxChild: (widget: Gtk.Widget) => widget is Gtk.FlowBoxChild;
|
|
34
|
-
/**
|
|
35
|
-
* Type guard that checks if a GTK widget is a ListBoxRow.
|
|
36
|
-
*/
|
|
37
21
|
export declare const isListBoxRow: (widget: Gtk.Widget) => widget is Gtk.ListBoxRow;
|
|
22
|
+
export declare const isChildContainer: (node: Node) => node is Node & ChildContainer;
|
|
23
|
+
export declare const isPageContainer: (node: Node) => node is Node & PageContainer;
|
|
24
|
+
export declare const isStackPageContainer: (node: Node) => node is Node & StackPageContainer;
|
|
25
|
+
export declare const isGridContainer: (node: Node) => node is Node & GridContainer;
|
|
26
|
+
export declare const isItemContainer: (node: Node) => node is Node & ItemContainer<unknown>;
|
|
27
|
+
export declare const isPackContainer: (node: Node) => node is Node & PackContainer;
|
|
28
|
+
export declare const isStringListContainer: (node: Node) => node is Node & StringListContainer;
|
|
38
29
|
export {};
|
package/dist/predicates.js
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type guard that checks if a GTK widget supports appending children via an append method.
|
|
3
|
-
*/
|
|
4
1
|
export const isAppendable = (widget) => "append" in widget && typeof widget.append === "function";
|
|
5
|
-
/**
|
|
6
|
-
* Type guard that checks if a GTK widget supports adding children via an add method.
|
|
7
|
-
*/
|
|
8
2
|
export const isAddable = (widget) => "add" in widget && typeof widget.add === "function";
|
|
9
|
-
/**
|
|
10
|
-
* Type guard that checks if a GTK widget supports a single child via setChild method.
|
|
11
|
-
*/
|
|
12
3
|
export const isSingleChild = (widget) => "setChild" in widget && typeof widget.setChild === "function";
|
|
13
|
-
/**
|
|
14
|
-
* Type guard that checks if a GTK widget supports removing children via a remove method.
|
|
15
|
-
*/
|
|
16
4
|
export const isRemovable = (widget) => "remove" in widget && typeof widget.remove === "function";
|
|
17
|
-
/**
|
|
18
|
-
* Type guard that checks if a GTK widget is a FlowBoxChild.
|
|
19
|
-
*/
|
|
20
5
|
export const isFlowBoxChild = (widget) => "getIndex" in widget && "getChild" in widget && typeof widget.getIndex === "function";
|
|
21
|
-
/**
|
|
22
|
-
* Type guard that checks if a GTK widget is a ListBoxRow.
|
|
23
|
-
*/
|
|
24
6
|
export const isListBoxRow = (widget) => "getIndex" in widget && "isSelected" in widget && typeof widget.getIndex === "function";
|
|
7
|
+
const createContainerGuard = (requiredMethods) => (node) => requiredMethods.every((method) => method in node);
|
|
8
|
+
export const isChildContainer = createContainerGuard([
|
|
9
|
+
"attachChild",
|
|
10
|
+
"detachChild",
|
|
11
|
+
"insertChildBefore",
|
|
12
|
+
]);
|
|
13
|
+
export const isPageContainer = createContainerGuard([
|
|
14
|
+
"addPage",
|
|
15
|
+
"removePage",
|
|
16
|
+
"insertPageBefore",
|
|
17
|
+
"updatePageLabel",
|
|
18
|
+
]);
|
|
19
|
+
export const isStackPageContainer = createContainerGuard([
|
|
20
|
+
"addStackPage",
|
|
21
|
+
"removeStackPage",
|
|
22
|
+
"updateStackPageProps",
|
|
23
|
+
]);
|
|
24
|
+
export const isGridContainer = createContainerGuard(["attachToGrid", "removeFromGrid"]);
|
|
25
|
+
export const isItemContainer = createContainerGuard([
|
|
26
|
+
"addItem",
|
|
27
|
+
"insertItemBefore",
|
|
28
|
+
"removeItem",
|
|
29
|
+
"updateItem",
|
|
30
|
+
]);
|
|
31
|
+
export const isPackContainer = createContainerGuard(["packStart", "packEnd", "removeFromPack"]);
|
|
32
|
+
export const isStringListContainer = createContainerGuard([
|
|
33
|
+
"addStringListItem",
|
|
34
|
+
"insertStringListItemBefore",
|
|
35
|
+
"removeStringListItem",
|
|
36
|
+
"updateStringListItem",
|
|
37
|
+
]);
|
package/dist/reconciler.d.ts
CHANGED
package/dist/reconciler.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ReactReconciler from "react-reconciler";
|
|
2
2
|
import packageJson from "../package.json" with { type: "json" };
|
|
3
3
|
import { createNode } from "./factory.js";
|
|
4
|
-
import { createHostConfig } from "./
|
|
4
|
+
import { createHostConfig } from "./host-config.js";
|
|
5
5
|
class Reconciler {
|
|
6
6
|
instance;
|
|
7
7
|
constructor() {
|
package/dist/types.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ export type ColumnViewColumnProps<T = unknown> = {
|
|
|
61
61
|
fixedWidth?: number;
|
|
62
62
|
/** Unique identifier for the column. Used for sorting. */
|
|
63
63
|
id?: string;
|
|
64
|
+
/** Whether this column header can be clicked to trigger sorting. */
|
|
65
|
+
sortable?: boolean;
|
|
64
66
|
/**
|
|
65
67
|
* Render function for column cells.
|
|
66
68
|
* Called with null during setup (for loading state) and with the actual item during bind.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Build GTK4 desktop applications with React and TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtk",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"react-reconciler": "^0.33.0",
|
|
39
|
-
"@gtkx/ffi": "0.
|
|
39
|
+
"@gtkx/ffi": "0.9.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@gtkx/gir": "0.
|
|
43
|
-
"@gtkx/native": "0.
|
|
42
|
+
"@gtkx/gir": "0.9.1",
|
|
43
|
+
"@gtkx/native": "0.9.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": "^19"
|
|
@@ -48,6 +48,6 @@
|
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsc -b && cp ../../README.md .",
|
|
50
50
|
"codegen": "tsx scripts/codegen.ts",
|
|
51
|
-
"test": "
|
|
51
|
+
"test": "../../scripts/run-tests.sh"
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const createContainerGuard = (requiredMethods) => (node) => requiredMethods.every((method) => method in node);
|
|
2
|
-
export const isChildContainer = createContainerGuard([
|
|
3
|
-
"attachChild",
|
|
4
|
-
"detachChild",
|
|
5
|
-
"insertChildBefore",
|
|
6
|
-
]);
|
|
7
|
-
export const isPageContainer = createContainerGuard([
|
|
8
|
-
"addPage",
|
|
9
|
-
"removePage",
|
|
10
|
-
"insertPageBefore",
|
|
11
|
-
"updatePageLabel",
|
|
12
|
-
]);
|
|
13
|
-
export const isStackPageContainer = createContainerGuard([
|
|
14
|
-
"addStackPage",
|
|
15
|
-
"removeStackPage",
|
|
16
|
-
"updateStackPageProps",
|
|
17
|
-
]);
|
|
18
|
-
export const isGridContainer = createContainerGuard(["attachToGrid", "removeFromGrid"]);
|
|
19
|
-
export const isItemContainer = createContainerGuard([
|
|
20
|
-
"addItem",
|
|
21
|
-
"insertItemBefore",
|
|
22
|
-
"removeItem",
|
|
23
|
-
"updateItem",
|
|
24
|
-
]);
|
|
25
|
-
export const isColumnContainer = createContainerGuard(["addColumn", "removeColumn", "getItems"]);
|
|
26
|
-
export const isPackContainer = createContainerGuard(["packStart", "packEnd", "removeFromPack"]);
|