diff options
-rw-r--r-- | gjs/src/astalify.ts | 14 | ||||
-rw-r--r-- | gjs/src/jsx/jsx-runtime.ts | 53 |
2 files changed, 36 insertions, 31 deletions
diff --git a/gjs/src/astalify.ts b/gjs/src/astalify.ts index 6df57b4..d99711d 100644 --- a/gjs/src/astalify.ts +++ b/gjs/src/astalify.ts @@ -171,11 +171,11 @@ function ctor(self: any, config: any = {}, children: any = []) { function proxify< C extends { new(...args: any[]): any }, >(klass: C) { - klass.prototype.hook = function(obj: any, sig: any, callback: any) { + klass.prototype.hook = function (obj: any, sig: any, callback: any) { return hook(this, obj, sig, callback) } - klass.prototype.toggleClassName = function(name: string, on = true) { + klass.prototype.toggleClassName = function (name: string, on = true) { Astal.widget_toggle_class_name(this, name, on) } @@ -184,7 +184,7 @@ function proxify< set(v) { Astal.widget_set_class_names(this, v.split(/\s+/)) }, }) - klass.prototype.set_class_name = function(name: string) { + klass.prototype.set_class_name = function (name: string) { this.className = name } @@ -193,7 +193,7 @@ function proxify< set(v) { Astal.widget_set_css(this, v) }, }) - klass.prototype.set_css = function(css: string) { + klass.prototype.set_css = function (css: string) { this.css = css } @@ -202,7 +202,7 @@ function proxify< set(v) { Astal.widget_set_cursor(this, v) }, }) - klass.prototype.set_cursor = function(cursor: string) { + klass.prototype.set_cursor = function (cursor: string) { this.cursor = cursor } @@ -211,7 +211,7 @@ function proxify< set(v) { Astal.widget_set_click_through(this, v) }, }) - klass.prototype.set_click_through = function(clickThrough: boolean) { + klass.prototype.set_click_through = function (clickThrough: boolean) { this.clickThrough = clickThrough } @@ -245,7 +245,7 @@ export default function astalify< type BindableProps<T> = { - [K in keyof T]: Binding<NonNullable<T[K]>> | T[K]; + [K in keyof T]: Binding<T[K]> | T[K]; } type SigHandler< diff --git a/gjs/src/jsx/jsx-runtime.ts b/gjs/src/jsx/jsx-runtime.ts index e96f7c2..bb6f4f3 100644 --- a/gjs/src/jsx/jsx-runtime.ts +++ b/gjs/src/jsx/jsx-runtime.ts @@ -10,6 +10,8 @@ export function jsx( if (!Array.isArray(children)) children = [children] + children = children.filter(Boolean) + if (typeof ctor === "string") return (ctors as any)[ctor](props, children) @@ -44,30 +46,33 @@ const ctors = { "window": Widget.Window, } -// eslint-disable-next-line @typescript-eslint/no-namespace -export namespace JSX { - export type Element = Gtk.Widget - export interface IntrinsicElements { - "box": Widget.BoxProps, - "button": Widget.ButtonProps, - "centerbox": Widget.CenterBoxProps, - // TODO: circularprogress - "drawingarea": Widget.DrawingAreaProps, - "entry": Widget.EntryProps, - "eventbox": Widget.EventBoxProps, - // TODO: fixed - // TODO: flowbox - "icon": Widget.IconProps, - "label": Widget.LabelProps, - "levelbar": Widget.LevelBarProps, - // TODO: listbox - "overlay": Widget.OverlayProps, - "revealer": Widget.RevealerProps, - "scrollable": Widget.ScrollableProps, - "slider": Widget.SliderProps, - // TODO: stack - "switch": Widget.SwitchProps, - "window": Widget.WindowProps, +declare global { + // eslint-disable-next-line @typescript-eslint/no-namespace + namespace JSX { + type Element = Gtk.Widget + type ElementClass = Gtk.Widget + interface IntrinsicElements { + "box": Widget.BoxProps, + "button": Widget.ButtonProps, + "centerbox": Widget.CenterBoxProps, + // TODO: circularprogress + "drawingarea": Widget.DrawingAreaProps, + "entry": Widget.EntryProps, + "eventbox": Widget.EventBoxProps, + // TODO: fixed + // TODO: flowbox + "icon": Widget.IconProps, + "label": Widget.LabelProps, + "levelbar": Widget.LevelBarProps, + // TODO: listbox + "overlay": Widget.OverlayProps, + "revealer": Widget.RevealerProps, + "scrollable": Widget.ScrollableProps, + "slider": Widget.SliderProps, + // TODO: stack + "switch": Widget.SwitchProps, + "window": Widget.WindowProps, + } } } |