Skip to content

Commit

Permalink
generar tipos
Browse files Browse the repository at this point in the history
  • Loading branch information
everskyblue committed Aug 14, 2024
1 parent cd8e555 commit 27f50b1
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 60 deletions.
9 changes: 6 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NavigationView } from "tabris";
import type { Page, Action, SearchAction } from "tabris";
export default addView;
import type { Page, Action, SearchAction, Widget, Constructor } from "tabris";
export * from "./modal";
export * from "./navigation";
export * from "./preference";
Expand All @@ -13,7 +12,11 @@ declare abstract class VoirRender {
abstract render(): Page;
constructor();
}
export interface Render {
renderAction(): (Action | SearchAction)[];
render(): Widget;
}
export declare const Voir: Readonly<{
Render: typeof VoirRender;
factory(Class: VoirRender): VoirRender;
factory(Class: Constructor<Render>): (new () => Render) & (() => Render);
}>;
2 changes: 2 additions & 0 deletions types/modal/toast.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import AnimationTime from "./animation-time";
export default class Toast extends AnimationTime {
show: (time: number) => any;
readonly _message: import("tabris").widgets.TextView;
readonly _modal: import("tabris").widgets.Composite<import("tabris").Widget<any>>;
constructor(message: string, duration: number);
static makeText(msg: string, duration?: number): Toast;
}
36 changes: 19 additions & 17 deletions types/navigation/CoordinatePage.d.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
import { type AnyWidget, NavigationView, Action, Properties as PropertiesTabris } from "tabris";
import { type IMenuItemOption, type MenuItemOf } from "./menu";
import { type EventObject, type WidgetCollection, NavigationView, Widget, NativeObject } from "tabris";
import { MenuItem } from "./menu";
type TypeWidget = any[] | Array<any[]>;
/**
* @description
* utilizar en JSX <CoordinatePageComponent></CoordinatePageComponent>
* encapsula la logica del menu de acciones del AppBar
* encapsula la lógica del menu de acciones del AppBar
* cuando se añade un Page con Action o SearchAction
* estas acciones desapareceran si la no es visible
* estas acciones desaparecerán si la no es visible
* haciendo que la nueva pagina no tenga los menus anteriores
*/
export declare class CoordinatePageComponent extends NavigationView {
private _onActionSelect;
private _onDrawerItemSelected;
private _dataMenuDrawer;
private _contentDrawer;
set contentDrawer(view: AnyWidget);
get contentDrawer(): AnyWidget;
set onActionSelect(event: (itemAction: Action) => void);
get onActionSelect(): (itemAction: Action) => void;
set menuDrawer(menu: () => IMenuItemOption[]);
get menuDrawer(): IMenuItemOption[];
set onDrawerItemSelected(event: (item: MenuItemOf) => void);
get onDrawerItemSelected(): (item: MenuItemOf) => void;
private _render;
constructor(props: PropertiesTabris<CoordinatePageComponent>);
onActionSelected?: any;
onDrawerItemSelected?: any;
static readonly events: string[];
set contentDrawer(view: Widget);
get contentDrawer(): Widget;
set menuDrawer(menu: WidgetCollection<MenuItem>);
get menuDrawer(): WidgetCollection<MenuItem>;
constructor(props: any);
private readonly _renderWidgetInDrawer;
on(type: string, listener: (event: EventObject<NativeObject>) => any, context?: object): this;
on(listeners: {
[event: string]: (event: EventObject<NativeObject>) => void;
}): this;
protected _addChild(child: Widget): void;
append(...widgets: TypeWidget): this;
}
/**
* @description
* encapsula en un proxy cuando se ejecute como funcion o instancia
*/
export declare const CoordinatePage: import("../utils/proxy").Callback<CoordinatePageComponent>;
export declare const CoordinatePage: import("tabris").Constructor<CoordinatePageComponent>;
export {};
31 changes: 19 additions & 12 deletions types/navigation/menu.d.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
import { type Widget, Composite } from "tabris";
type MenuItemOf = MenuItem;
export interface IMenuItemOption {
import { type Widget, WidgetCollection, Row, Composite } from "tabris";
export type MenuItemOf = MenuItem;
export type MenuOption = {
[key: string]: MenuItemOption;
};
export interface MenuItemOption {
id: string;
text: string;
image?: string;
}
declare class MenuItem extends Composite {
constructor(id: string);
export declare class MenuAction extends Composite {
constructor(id?: string);
}
export declare class MenuItem extends Row {
constructor(props: any);
_setElements(img: any, text: string): void;
text: string;
image: any;
}
/**
* @version 0.4
* no posee hijos y su padre es DrawerMenu
*/
export declare const DrawerMenuItem: (props: IMenuItemOption) => () => IMenuItemOption;
export declare const DrawerMenuItem: typeof MenuItem;
/**
* @version 0.4
* contenedor para DrawerMenuItem
*/
export declare const DrawerMenu: ({ children }: {
children: ReturnType<typeof DrawerMenuItem>[];
}) => () => IMenuItemOption[];
export type { MenuItemOf };
children: Widget<typeof DrawerMenuItem>[];
}) => WidgetCollection<Widget<any>>;
/**
* @deprecated
* emite un warning desde la version 0.4
*/
export declare const menuDrawer: (menus: IMenuItemOption[], eventSelectMenu: (menu: MenuItem) => void) => void;
export declare const menuDrawer: (menus: MenuItemOption[] | WidgetCollection<MenuItem>, eventSelectMenu: (menu: MenuAction) => void) => void;
/**
* @version 0.4
*/
export declare function setMenuDrawer(menus: IMenuItemOption[], eventSelectMenu: (menu: MenuItem) => void): void;
export declare function setMenuDrawer(menus: MenuItemOption[] | WidgetCollection<MenuItem>, eventSelectMenu?: (menu: MenuAction) => void): void;
/**
* @version 0.4
*/
Expand Down
2 changes: 1 addition & 1 deletion types/preference/CheckBoxPreference.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export declare class CheckBoxPreferenceComponent extends Checked {
constructor(props: Properties<CheckBoxPreferenceComponent>);
_getButton(props: Properties<CheckBoxPreferenceComponent>): import("tabris").widgets.CheckBox;
}
export declare const CheckBoxPreference: import("../utils/proxy").Callback<CheckBoxPreferenceComponent>;
export declare const CheckBoxPreference: import("tabris").Constructor<CheckBoxPreferenceComponent>;
2 changes: 1 addition & 1 deletion types/preference/ListPreference.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export declare class ListPreferenceComponent extends Checked {
onSelect?: any;
});
}
export declare const ListPreference: import("../utils/proxy").Callback<ListPreferenceComponent>;
export declare const ListPreference: import("tabris").Constructor<ListPreferenceComponent>;
2 changes: 1 addition & 1 deletion types/preference/PreferenceScreen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { Page, Properties } from "tabris";
export declare class PreferenceScreenComponent extends Page {
constructor(props?: Properties<PreferenceScreenComponent>);
}
export declare const PreferenceScreen: import("../utils/proxy").Callback<PreferenceScreenComponent>;
export declare const PreferenceScreen: import("tabris").Constructor<PreferenceScreenComponent>;
2 changes: 1 addition & 1 deletion types/preference/SwitchPreference.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export declare class SwitchPreferenceComponent extends Checked {
constructor(props: Properties<SwitchPreferenceComponent>);
_getButton(props: Properties<SwitchPreferenceComponent>): import("tabris").widgets.Switch;
}
export declare const SwitchPreference: import("../utils/proxy").Callback<SwitchPreferenceComponent>;
export declare const SwitchPreference: import("tabris").Constructor<SwitchPreferenceComponent>;
2 changes: 1 addition & 1 deletion types/preference/TextPreference.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import ItemPreference from "./AbstractItemPreference";
export declare class TextPreferenceComponent extends ItemPreference {
constructor(props: Properties<TextView>);
}
export declare const TextPreference: import("../utils/proxy").Callback<TextPreferenceComponent>;
export declare const TextPreference: import("tabris").Constructor<TextPreferenceComponent>;
5 changes: 5 additions & 0 deletions types/utils/custom-events.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function customEvent(construct: any, defEvent: any): void;
export namespace customEvent {
function addListener(ctx: any, name: any, handler: any): void;
function listener(ctx: any, ctx2: any): void;
}
5 changes: 2 additions & 3 deletions types/utils/helpers.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import type { CallbackInstance } from "./proxy";
import type { Composite } from "tabris";
export declare function createInstance<ClassType extends Composite>(props: any, $Class: CallbackInstance<ClassType>): ClassType;
import type { Composite, Constructor } from "tabris";
export declare function createInstance<ClassType extends Composite>(props: any, $Class: Constructor<ClassType>): ClassType;
25 changes: 5 additions & 20 deletions types/utils/proxy.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
import { PreferenceParams } from "../preference/AbstractItemPreference";
import { CoordinatePageComponent } from "../navigation";
import { IEntry, ListPreferenceComponent, PreferenceScreenComponent } from "../preference";
import type { AnyWidget, CheckBox, Composite, JSXAttributes, PropertyChangedEvent, RadioButton, RadioButtonSelectEvent, Switch } from "tabris";
type CallbackAppend = (widgets: any[]) => any;
type OptionalAtrributes<T> = {
[K in keyof T]?: T[K];
};
type Attributes<View> = View extends PreferenceScreenComponent | CoordinatePageComponent ? JSXAttributes<View> & {
children?: AnyWidget[];
} : OptionalAtrributes<PreferenceParams> & {
onSelect?: (event: View extends RadioButton ? RadioButtonSelectEvent : PropertyChangedEvent<RadioButton | Switch | CheckBox, boolean>) => any;
} & (View extends ListPreferenceComponent ? {
entries: IEntry[];
} : {});
export type CallbackInstance<View extends AnyWidget> = new (props: Attributes<View>) => View;
export type Callable<View extends AnyWidget> = (props?: Attributes<View>) => View;
export type Callback<View extends AnyWidget> = CallbackInstance<View> | Callable<View>;
export declare function createProxies<T extends Composite>(funReceivedProxy: Callback<T>, funAppend?: CallbackAppend): Callback<T>;
export declare function factory<T = any>(fac: T): void;
import { Constructor } from "tabris";
type Callback<T> = Constructor<T> | (() => T);
type Handler<T> = (new () => T) & (() => T);
export declare function createProxies<T>(component: Constructor<T>): Constructor<T>;
export declare function factory<T>(fac: Callback<T>): Handler<T>;
export {};

0 comments on commit 27f50b1

Please sign in to comment.