mirror of
https://github.com/jaandrle/deka-dom-el
synced 2024-11-25 01:39:37 +01:00
♻️ remove/change type definitions
This commit is contained in:
parent
6a52972373
commit
b9bbd105a5
@ -59,11 +59,7 @@ export function todosComponent({ todos= [ "Task A" ] }= {}){
|
||||
)
|
||||
}
|
||||
/**
|
||||
* @type {ddeComponent<
|
||||
* { textContent: ddeSignal<string, any>, value: number },
|
||||
* HTMLLIElement,
|
||||
* [ "click" ]
|
||||
* >}
|
||||
* @dispatch {number} remove
|
||||
* */
|
||||
function todoComponent({ textContent, value }){
|
||||
const { host }= scope;
|
||||
|
45
index.d.ts
vendored
45
index.d.ts
vendored
@ -1,16 +1,6 @@
|
||||
import { Signal } from "./signals";
|
||||
//TODO?
|
||||
/** Is filled when function is succesfully called ⇒ and returns component's root element. */
|
||||
type Host<el extends Element>= (extender?: ElementExtender<el>)=> el | undefined;
|
||||
declare global {
|
||||
/**
|
||||
* `ref` is filled when function is succesfully called ⇒ and returns component's root element.
|
||||
* */
|
||||
type ddeComponent<
|
||||
A extends Record<any, any>,
|
||||
R extends Element,
|
||||
T extends string[] = []
|
||||
>= (attrs: A, ref: Host<R>)=> R & { _events: T };
|
||||
type ddeComponentAttributes= Record<any, any> | undefined | string;
|
||||
type ddeElementExtender<El extends Element>= (element: El)=> El;
|
||||
}
|
||||
type ElementTagNameMap= HTMLElementTagNameMap & SVGElementTagNameMap & {
|
||||
'#text': Text
|
||||
@ -48,43 +38,45 @@ type ElementAttributes<T extends keyof ElementTagNameMap | ElementTagNameMap[key
|
||||
Omit<T,"classList"|"className"> & AttrsModified;
|
||||
export function assign<El extends Element>(element: El, ...attrs_array: Partial<ElementAttributes<El>>[]): El
|
||||
|
||||
type ElementExtender<El extends Element>= (element: El)=> El;
|
||||
type TagNameFragment= "<>";
|
||||
export function el<TAG extends keyof ElementTagNameMap>(
|
||||
tag_name: TAG,
|
||||
attrs?: Partial<ElementAttributes<ElementTagNameMap[TAG]>>,
|
||||
...extenders: ElementExtender<ElementTagNameMap[TAG]>[]
|
||||
...extenders: ddeElementExtender<ElementTagNameMap[TAG]>[]
|
||||
): ElementTagNameMap[TAG]
|
||||
export function el<T>(
|
||||
tag_name: TagNameFragment,
|
||||
): DocumentFragment
|
||||
export function el<R extends Element, T extends (attrs: any, host: Host<R>)=> R>(
|
||||
fComponent: T,
|
||||
attrs?: Parameters<T>,
|
||||
...extenders: ElementExtender<ReturnType<T>>[]
|
||||
): ReturnType<T>
|
||||
|
||||
export function el<
|
||||
A extends ddeComponentAttributes,
|
||||
C extends (attr: A)=> Element>(
|
||||
fComponent: C,
|
||||
attrs?: A,
|
||||
...extenders: ddeElementExtender<ReturnType<C>>[]
|
||||
): ReturnType<C>
|
||||
|
||||
export function dispatchEvent(element: HTMLElement, name: keyof DocumentEventMap): void;
|
||||
export function dispatchEvent(element: HTMLElement, name: string, data: any): void;
|
||||
interface On{
|
||||
<
|
||||
EE extends ElementExtender<Element>,
|
||||
El extends ( EE extends ElementExtender<infer El> ? El : never ),
|
||||
EE extends ddeElementExtender<Element>,
|
||||
El extends ( EE extends ddeElementExtender<infer El> ? El : never ),
|
||||
Event extends keyof DocumentEventMap>(
|
||||
type: Event,
|
||||
listener: (this: El, ev: DocumentEventMap[Event]) => any,
|
||||
options?: AddEventListenerOptions
|
||||
) : EE;
|
||||
connected<
|
||||
EE extends ElementExtender<Element>,
|
||||
El extends ( EE extends ElementExtender<infer El> ? El : never )
|
||||
EE extends ddeElementExtender<Element>,
|
||||
El extends ( EE extends ddeElementExtender<infer El> ? El : never )
|
||||
>(
|
||||
listener: (el: El) => any,
|
||||
options?: AddEventListenerOptions
|
||||
) : EE;
|
||||
disconnected<
|
||||
EE extends ElementExtender<Element>,
|
||||
El extends ( EE extends ElementExtender<infer El> ? El : never )
|
||||
EE extends ddeElementExtender<Element>,
|
||||
El extends ( EE extends ddeElementExtender<infer El> ? El : never )
|
||||
>(
|
||||
listener: (el: El) => any,
|
||||
options?: AddEventListenerOptions
|
||||
@ -92,9 +84,6 @@ interface On{
|
||||
}
|
||||
export const on: On;
|
||||
|
||||
//TODO?
|
||||
export type Fires<T extends string[]>= ( (...a: any[])=> any ) & { events: T };
|
||||
|
||||
//TODO for SVG
|
||||
declare global{
|
||||
interface HTMLDivElement{ append(...nodes: (Node | string)[]): HTMLDivElement; }
|
||||
|
Loading…
Reference in New Issue
Block a user