feat(ags4): write own ConstructProps to exclude props
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2025-01-15 18:17:27 -05:00
parent bd6fa7ba28
commit e7accbd7bd
19 changed files with 65 additions and 33 deletions

View file

@ -108,6 +108,7 @@ export default <
this.setChildren(this, children); this.setChildren(this, children);
} }
private _cursorName: Cursor = 'default'; private _cursorName: Cursor = 'default';
@property(String) @property(String)

View file

@ -1,6 +1,8 @@
import { Gtk } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import { Binding } from 'astal/binding'; import { Binding } from 'astal/binding';
import { EventController } from './controller';
// A mixin class must have a constructor with a single rest parameter of type 'any[]' // A mixin class must have a constructor with a single rest parameter of type 'any[]'
// eslint-disable-next-line "@typescript-eslint/no-explicit-any" // eslint-disable-next-line "@typescript-eslint/no-explicit-any"
export type MixinParams = any[]; export type MixinParams = any[];
@ -28,6 +30,30 @@ export interface AstalifyProps {
cursorName: Cursor cursorName: Cursor
} }
type SigHandler<
W extends InstanceType<typeof Gtk.Widget>,
Args extends unknown[],
> = ((self: W, ...args: Args) => unknown) | string | string[];
export type ConstructProps<
Self extends InstanceType<typeof Gtk.Widget>,
Props extends Gtk.Widget.ConstructorProps,
Signals extends Record<`on${string}`, unknown[]> = Record<`on${string}`, unknown[]>,
> = Partial<{
// @ts-expect-error can't assign to unknown, but it works as expected though
[S in keyof Signals]: SigHandler<Self, Signals[S]>
}> & Partial<Record<`on${string}`, SigHandler<Self, unknown[]>>> & Partial<BindableProps<Omit<
Props,
'cssName' | 'css_name' | 'cursor'
>>> & {
noImplicitDestroy?: true
type?: string
cssName?: string
} & EventController<Self> & {
onDestroy?: (self: Self) => unknown
setup?: (self: Self) => void
};
export type Cursor = export type Cursor =
| 'default' | 'default'
| 'help' | 'help'

View file

@ -2,4 +2,9 @@ import astalify from './astalify';
export default astalify; export default astalify;
export { type AstalifyProps, type BindableProps, childType } from './generics'; export {
type AstalifyProps,
type BindableProps,
type ConstructProps,
childType,
} from './generics';

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Astal, type ConstructProps, Gtk } from 'astal/gtk4'; import { Astal, Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type BoxProps = ConstructProps< export type BoxProps = ConstructProps<

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
type ButtonSignals = Record<`on${string}`, unknown[]> & { type ButtonSignals = Record<`on${string}`, unknown[]> & {

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
type CalendarSignals = Record<`on${string}`, unknown[]> & { type CalendarSignals = Record<`on${string}`, unknown[]> & {

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type CenterBoxProps = ConstructProps< export type CenterBoxProps = ConstructProps<

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
type EntrySignals = Record<`on${string}`, unknown[]> & { type EntrySignals = Record<`on${string}`, unknown[]> & {

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type ImageProps = ConstructProps< export type ImageProps = ConstructProps<

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type LabelProps = ConstructProps< export type LabelProps = ConstructProps<

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type LevelBarProps = ConstructProps< export type LevelBarProps = ConstructProps<

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type MenuButtonProps = ConstructProps< export type MenuButtonProps = ConstructProps<

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { childType, type AstalifyProps } from '../astalify'; import astalify, { childType, type AstalifyProps, type ConstructProps } from '../astalify';
export type OverlayProps = ConstructProps< export type OverlayProps = ConstructProps<

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type PopoverProps = ConstructProps< export type PopoverProps = ConstructProps<

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type RevealerProps = ConstructProps< export type RevealerProps = ConstructProps<

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Astal, type ConstructProps } from 'astal/gtk4'; import { Astal } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
type SliderSignals = Record<`on${string}`, unknown[]> & { type SliderSignals = Record<`on${string}`, unknown[]> & {

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type StackProps = ConstructProps< export type StackProps = ConstructProps<

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4'; import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type SwitchProps = ConstructProps< export type SwitchProps = ConstructProps<

View file

@ -1,7 +1,7 @@
import { register } from 'astal'; import { register } from 'astal';
import { Astal, type ConstructProps } from 'astal/gtk4'; import { Astal } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify'; import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type WindowProps = ConstructProps< export type WindowProps = ConstructProps<