Actualizar sigpro.d.ts
This commit is contained in:
407
sigpro.d.ts
vendored
407
sigpro.d.ts
vendored
@@ -1,287 +1,188 @@
|
|||||||
declare module 'sigpro' {
|
// sigpro.d.ts
|
||||||
type Signal<T> = {
|
|
||||||
|
declare const SIG_BRAND: unique symbol;
|
||||||
|
|
||||||
|
export interface Signal<T = any> {
|
||||||
|
readonly [SIG_BRAND]: true;
|
||||||
(): T;
|
(): T;
|
||||||
(value: T | ((prev: T) => T)): T;
|
(value: T): T;
|
||||||
};
|
(updater: (prev: T) => T): T;
|
||||||
|
}
|
||||||
|
|
||||||
type ComputedSignal<T> = () => T;
|
export interface Computed<T = any> {
|
||||||
|
readonly [SIG_BRAND]: true;
|
||||||
|
(): T;
|
||||||
|
}
|
||||||
|
|
||||||
type Unsubscribe = () => void;
|
export interface RuntimeInstance {
|
||||||
|
readonly _isRuntime: true;
|
||||||
|
readonly container: HTMLElement;
|
||||||
|
destroy(): void;
|
||||||
|
}
|
||||||
|
|
||||||
type ViewInstance = {
|
export interface TransitionOptions {
|
||||||
_isRuntime: true;
|
on?: (el: HTMLElement) => void;
|
||||||
container: HTMLDivElement;
|
off?: (el: HTMLElement, destroy: () => void) => void;
|
||||||
destroy: () => void;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
type ComponentFunction<P = {}> = (props?: P) => HTMLElement | ViewInstance | string | null;
|
export interface Route {
|
||||||
type ComponentChild = HTMLElement | ViewInstance | string | number | boolean | null | undefined;
|
|
||||||
type ComponentChildren = ComponentChild | ComponentChild[];
|
|
||||||
|
|
||||||
interface BaseProps {
|
|
||||||
class?: string | (() => string);
|
|
||||||
style?: string | Record<string, string> | (() => string | Record<string, string>);
|
|
||||||
id?: string | (() => string);
|
|
||||||
ref?: ((el: HTMLElement) => void) | { current: HTMLElement | null };
|
|
||||||
}
|
|
||||||
|
|
||||||
interface EventProps {
|
|
||||||
onclick?: (event: MouseEvent) => void;
|
|
||||||
oninput?: (event: Event) => void;
|
|
||||||
onchange?: (event: Event) => void;
|
|
||||||
onblur?: (event: FocusEvent) => void;
|
|
||||||
onfocus?: (event: FocusEvent) => void;
|
|
||||||
onkeydown?: (event: KeyboardEvent) => void;
|
|
||||||
onkeyup?: (event: KeyboardEvent) => void;
|
|
||||||
onmouseenter?: (event: MouseEvent) => void;
|
|
||||||
onmouseleave?: (event: MouseEvent) => void;
|
|
||||||
onsubmit?: (event: Event) => void;
|
|
||||||
[key: `on${string}`]: ((event: any) => void) | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HtmlProps extends BaseProps, EventProps {
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Route {
|
|
||||||
path: string;
|
path: string;
|
||||||
component: ComponentFunction | (() => Promise<ComponentFunction>);
|
component: (params: Record<string, string>) => any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RouterOutlet {
|
export interface RenderContext {
|
||||||
params: Signal<Record<string, string>>;
|
onCleanup: (fn: () => void) => void;
|
||||||
to: (path: string) => void;
|
}
|
||||||
back: () => void;
|
|
||||||
path: () => string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Transition {
|
export interface TagProps extends Record<string, any> {
|
||||||
in: (el: HTMLElement) => void;
|
ref?: ((el: HTMLElement) => void) | { current: HTMLElement | null };
|
||||||
out: (el: HTMLElement, done: () => void) => void;
|
class?: string | (() => string);
|
||||||
}
|
style?: string | (() => string);
|
||||||
|
}
|
||||||
|
|
||||||
function $<T>(initial: T, storageKey?: string): Signal<T>;
|
export type ReactiveObject<T extends object> = {
|
||||||
function $<T>(computed: () => T): ComputedSignal<T>;
|
[K in keyof T]: T[K] extends object ? ReactiveObject<T[K]> : T[K];
|
||||||
|
};
|
||||||
|
|
||||||
function $$<T extends object>(obj: T): T;
|
export function $<T>(val: T, key?: string | null): Signal<T>;
|
||||||
|
export function $<T>(val: () => T): Computed<T>;
|
||||||
|
|
||||||
function Watch(
|
export function $$<T>(fn: () => T): Computed<T>;
|
||||||
target: () => any,
|
|
||||||
callback?: never
|
|
||||||
): Unsubscribe;
|
|
||||||
function Watch(
|
|
||||||
target: Array<() => any>,
|
|
||||||
callback: () => void
|
|
||||||
): Unsubscribe;
|
|
||||||
|
|
||||||
function Tag(
|
export function $_<T extends object>(obj: T): ReactiveObject<T>;
|
||||||
tag: string,
|
|
||||||
props?: HtmlProps | ComponentChildren,
|
|
||||||
children?: ComponentChildren
|
|
||||||
): HTMLElement;
|
|
||||||
|
|
||||||
function If(
|
export function untrack<T>(fn: () => T): T;
|
||||||
condition: boolean | (() => boolean),
|
|
||||||
thenVal: ComponentFunction | ComponentChild,
|
|
||||||
otherwiseVal?: ComponentFunction | ComponentChild,
|
|
||||||
transition?: Transition
|
|
||||||
): HTMLDivElement;
|
|
||||||
|
|
||||||
function For<T>(
|
export function Watch(cb: () => void): () => void;
|
||||||
|
export function Watch(cb: () => () => void): () => void;
|
||||||
|
|
||||||
|
export function Render<T>(fn: (ctx: RenderContext) => T): RuntimeInstance;
|
||||||
|
|
||||||
|
export function Tag(tag: string, props?: TagProps | null, children?: any[]): HTMLElement;
|
||||||
|
export function Tag(tag: string, children?: any[]): HTMLElement;
|
||||||
|
|
||||||
|
export function If(
|
||||||
|
cond: boolean | (() => boolean),
|
||||||
|
a: any | (() => any),
|
||||||
|
b?: any | (() => any) | null,
|
||||||
|
options?: TransitionOptions
|
||||||
|
): HTMLElement;
|
||||||
|
|
||||||
|
export function For<T>(
|
||||||
source: T[] | (() => T[]),
|
source: T[] | (() => T[]),
|
||||||
render: (item: T, index: number) => ComponentChild,
|
renderFn: (item: T, index: number) => any,
|
||||||
keyFn?: (item: T, index: number) => string | number,
|
keyFn?: (item: T, index: number) => any,
|
||||||
tag?: string,
|
tag?: string,
|
||||||
props?: HtmlProps
|
props?: TagProps
|
||||||
): HTMLElement;
|
): HTMLElement;
|
||||||
|
|
||||||
function Router(routes: Route[]): RouterOutlet;
|
export function Router(routes: Route[]): HTMLElement;
|
||||||
|
|
||||||
function Mount(
|
export namespace Router {
|
||||||
component: ComponentFunction | HTMLElement,
|
const params: Signal<Record<string, string>>;
|
||||||
|
function to(path: string): void;
|
||||||
|
function back(): void;
|
||||||
|
function path(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Mount(
|
||||||
|
component: (() => any) | any,
|
||||||
target: string | HTMLElement
|
target: string | HTMLElement
|
||||||
): ViewInstance | undefined;
|
): RuntimeInstance;
|
||||||
|
|
||||||
const Div: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
export function Share<T>(key: string, value: T): void;
|
||||||
const Span: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const P: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const H1: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const H2: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const H3: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const H4: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const H5: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const H6: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Button: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Input: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Textarea: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Select: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Option: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Label: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Form: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const A: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Img: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Ul: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Ol: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Li: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Nav: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Header: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Footer: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Section: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Article: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Aside: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Main: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Table: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Thead: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Tbody: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Tr: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Th: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
const Td: (props?: HtmlProps | ComponentChildren, children?: ComponentChildren) => HTMLElement;
|
|
||||||
|
|
||||||
const SigPro: {
|
export function Use<T>(key: string, defaultValue?: T): T | undefined;
|
||||||
|
|
||||||
|
// Funciones JSX (etiquetas globales)
|
||||||
|
export const Div: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Span: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const P: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const H1: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const H2: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const H3: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const H4: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const H5: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const H6: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Button: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const A: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Img: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Input: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Textarea: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Select: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Option: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Form: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Label: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Ul: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Ol: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Li: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Table: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Tr: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Td: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Th: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Section: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Article: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Aside: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Nav: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Header: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Footer: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
export const Main: (props?: TagProps, children?: any[]) => HTMLElement;
|
||||||
|
|
||||||
|
export interface SigProAPI {
|
||||||
$: typeof $;
|
$: typeof $;
|
||||||
$$: typeof $$;
|
$$: typeof $$;
|
||||||
|
$_: typeof $_;
|
||||||
|
untrack: typeof untrack;
|
||||||
|
Render: typeof Render;
|
||||||
Watch: typeof Watch;
|
Watch: typeof Watch;
|
||||||
Tag: typeof Tag;
|
Tag: typeof Tag;
|
||||||
If: typeof If;
|
If: typeof If;
|
||||||
For: typeof For;
|
For: typeof For;
|
||||||
Router: typeof Router;
|
Router: typeof Router;
|
||||||
Mount: typeof Mount;
|
Mount: typeof Mount;
|
||||||
};
|
Share: typeof Share;
|
||||||
|
Use: typeof Use;
|
||||||
export default SigPro;
|
|
||||||
export {
|
|
||||||
$,
|
|
||||||
$$,
|
|
||||||
Watch,
|
|
||||||
Tag,
|
|
||||||
If,
|
|
||||||
For,
|
|
||||||
Router,
|
|
||||||
Mount,
|
|
||||||
Div,
|
|
||||||
Span,
|
|
||||||
P,
|
|
||||||
H1,
|
|
||||||
H2,
|
|
||||||
H3,
|
|
||||||
H4,
|
|
||||||
H5,
|
|
||||||
H6,
|
|
||||||
Button,
|
|
||||||
Input,
|
|
||||||
Textarea,
|
|
||||||
Select,
|
|
||||||
Option,
|
|
||||||
Label,
|
|
||||||
Form,
|
|
||||||
A,
|
|
||||||
Img,
|
|
||||||
Ul,
|
|
||||||
Ol,
|
|
||||||
Li,
|
|
||||||
Nav,
|
|
||||||
Header,
|
|
||||||
Footer,
|
|
||||||
Section,
|
|
||||||
Article,
|
|
||||||
Aside,
|
|
||||||
Main,
|
|
||||||
Table,
|
|
||||||
Thead,
|
|
||||||
Tbody,
|
|
||||||
Tr,
|
|
||||||
Th,
|
|
||||||
Td,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare const SigPro: SigProAPI;
|
||||||
|
export default SigPro;
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
const $: typeof import('sigpro').$;
|
namespace JSX {
|
||||||
const $$: typeof import('sigpro').$$;
|
interface IntrinsicElements {
|
||||||
const Watch: typeof import('sigpro').Watch;
|
div: TagProps;
|
||||||
const Tag: typeof import('sigpro').Tag;
|
span: TagProps;
|
||||||
const If: typeof import('sigpro').If;
|
p: TagProps;
|
||||||
const For: typeof import('sigpro').For;
|
h1: TagProps;
|
||||||
const Router: typeof import('sigpro').Router;
|
h2: TagProps;
|
||||||
const Mount: typeof import('sigpro').Mount;
|
h3: TagProps;
|
||||||
const Div: typeof import('sigpro').Div;
|
h4: TagProps;
|
||||||
const Span: typeof import('sigpro').Span;
|
h5: TagProps;
|
||||||
const P: typeof import('sigpro').P;
|
h6: TagProps;
|
||||||
const H1: typeof import('sigpro').H1;
|
button: TagProps;
|
||||||
const H2: typeof import('sigpro').H2;
|
a: TagProps;
|
||||||
const H3: typeof import('sigpro').H3;
|
img: TagProps;
|
||||||
const H4: typeof import('sigpro').H4;
|
input: TagProps;
|
||||||
const H5: typeof import('sigpro').H5;
|
textarea: TagProps;
|
||||||
const H6: typeof import('sigpro').H6;
|
select: TagProps;
|
||||||
const Button: typeof import('sigpro').Button;
|
option: TagProps;
|
||||||
const Input: typeof import('sigpro').Input;
|
form: TagProps;
|
||||||
const Textarea: typeof import('sigpro').Textarea;
|
label: TagProps;
|
||||||
const Select: typeof import('sigpro').Select;
|
ul: TagProps;
|
||||||
const Option: typeof import('sigpro').Option;
|
ol: TagProps;
|
||||||
const Label: typeof import('sigpro').Label;
|
li: TagProps;
|
||||||
const Form: typeof import('sigpro').Form;
|
table: TagProps;
|
||||||
const A: typeof import('sigpro').A;
|
tr: TagProps;
|
||||||
const Img: typeof import('sigpro').Img;
|
td: TagProps;
|
||||||
const Ul: typeof import('sigpro').Ul;
|
th: TagProps;
|
||||||
const Ol: typeof import('sigpro').Ol;
|
section: TagProps;
|
||||||
const Li: typeof import('sigpro').Li;
|
article: TagProps;
|
||||||
const Nav: typeof import('sigpro').Nav;
|
aside: TagProps;
|
||||||
const Header: typeof import('sigpro').Header;
|
nav: TagProps;
|
||||||
const Footer: typeof import('sigpro').Footer;
|
header: TagProps;
|
||||||
const Section: typeof import('sigpro').Section;
|
footer: TagProps;
|
||||||
const Article: typeof import('sigpro').Article;
|
main: TagProps;
|
||||||
const Aside: typeof import('sigpro').Aside;
|
}
|
||||||
const Main: typeof import('sigpro').Main;
|
interface Element extends HTMLElement {}
|
||||||
const Table: typeof import('sigpro').Table;
|
|
||||||
const Thead: typeof import('sigpro').Thead;
|
|
||||||
const Tbody: typeof import('sigpro').Tbody;
|
|
||||||
const Tr: typeof import('sigpro').Tr;
|
|
||||||
const Th: typeof import('sigpro').Th;
|
|
||||||
const Td: typeof import('sigpro').Td;
|
|
||||||
|
|
||||||
interface Window {
|
|
||||||
$: typeof $;
|
|
||||||
$$: typeof $$;
|
|
||||||
Watch: typeof Watch;
|
|
||||||
Tag: typeof Tag;
|
|
||||||
If: typeof If;
|
|
||||||
For: typeof For;
|
|
||||||
Router: typeof Router;
|
|
||||||
Mount: typeof Mount;
|
|
||||||
SigPro: typeof import('sigpro').default;
|
|
||||||
Div: typeof Div;
|
|
||||||
Span: typeof Span;
|
|
||||||
P: typeof P;
|
|
||||||
H1: typeof H1;
|
|
||||||
H2: typeof H2;
|
|
||||||
H3: typeof H3;
|
|
||||||
H4: typeof H4;
|
|
||||||
H5: typeof H5;
|
|
||||||
H6: typeof H6;
|
|
||||||
Button: typeof Button;
|
|
||||||
Input: typeof Input;
|
|
||||||
Textarea: typeof Textarea;
|
|
||||||
Select: typeof Select;
|
|
||||||
Option: typeof Option;
|
|
||||||
Label: typeof Label;
|
|
||||||
Form: typeof Form;
|
|
||||||
A: typeof A;
|
|
||||||
Img: typeof Img;
|
|
||||||
Ul: typeof Ul;
|
|
||||||
Ol: typeof Ol;
|
|
||||||
Li: typeof Li;
|
|
||||||
Nav: typeof Nav;
|
|
||||||
Header: typeof Header;
|
|
||||||
Footer: typeof Footer;
|
|
||||||
Section: typeof Section;
|
|
||||||
Article: typeof Article;
|
|
||||||
Aside: typeof Aside;
|
|
||||||
Main: typeof Main;
|
|
||||||
Table: typeof Table;
|
|
||||||
Thead: typeof Thead;
|
|
||||||
Tbody: typeof Tbody;
|
|
||||||
Tr: typeof Tr;
|
|
||||||
Th: typeof Th;
|
|
||||||
Td: typeof Td;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user