summaryrefslogtreecommitdiff
path: root/lang/gjs/src/gtk3/jsx-runtime.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lang/gjs/src/gtk3/jsx-runtime.ts')
-rw-r--r--lang/gjs/src/gtk3/jsx-runtime.ts33
1 files changed, 6 insertions, 27 deletions
diff --git a/lang/gjs/src/gtk3/jsx-runtime.ts b/lang/gjs/src/gtk3/jsx-runtime.ts
index 9da4bb6..ee720af 100644
--- a/lang/gjs/src/gtk3/jsx-runtime.ts
+++ b/lang/gjs/src/gtk3/jsx-runtime.ts
@@ -1,11 +1,8 @@
import Gtk from "gi://Gtk?version=3.0"
-import { mergeBindings, type BindableChild } from "./astalify.js"
+import { type BindableChild } from "./astalify.js"
+import { mergeBindings, jsx as _jsx } from "../_astal.js"
import * as Widget from "./widget.js"
-function isArrowFunction(func: any): func is (args: any) => any {
- return !Object.hasOwn(func, "prototype")
-}
-
export function Fragment({ children = [], child }: {
child?: BindableChild
children?: Array<BindableChild>
@@ -16,29 +13,9 @@ export function Fragment({ children = [], child }: {
export function jsx(
ctor: keyof typeof ctors | typeof Gtk.Widget,
- { children, ...props }: any,
+ props: any,
) {
- children ??= []
-
- if (!Array.isArray(children))
- children = [children]
-
- children = children.filter(Boolean)
-
- if (children.length === 1)
- props.child = children[0]
- else if (children.length > 1)
- props.children = children
-
- if (typeof ctor === "string") {
- return new ctors[ctor](props)
- }
-
- if (isArrowFunction(ctor))
- return ctor(props)
-
- // @ts-expect-error can be class or function
- return new ctor(props)
+ return _jsx(ctors, ctor as any, props)
}
const ctors = {
@@ -55,6 +32,7 @@ const ctors = {
label: Widget.Label,
levelbar: Widget.LevelBar,
// TODO: listbox
+ menubutton: Widget.MenuButton,
overlay: Widget.Overlay,
revealer: Widget.Revealer,
scrollable: Widget.Scrollable,
@@ -83,6 +61,7 @@ declare global {
label: Widget.LabelProps
levelbar: Widget.LevelBarProps
// TODO: listbox
+ menubutton: Widget.MenuButtonProps
overlay: Widget.OverlayProps
revealer: Widget.RevealerProps
scrollable: Widget.ScrollableProps