@gez/date-time-kit
Version:
72 lines (71 loc) • 4 kB
TypeScript
import type { Lang } from '../../i18n';
type EmitType = Record<string, any>;
export type Emit2EventMap<Emit extends EmitType> = {
[K in keyof Emit]: CustomEvent<Emit[K]>;
};
export type ListenerFn<Emit extends EmitType, K extends keyof Emit | keyof HTMLElementEventMap> = (this: HTMLElement, ev: K extends keyof Emit ? CustomEvent<Emit[K]> : HTMLElementEventMap[K & keyof HTMLElementEventMap]) => any;
export type EventListenerObj<Emit extends EmitType, K extends keyof Emit | keyof HTMLElementEventMap> = {
handleEvent: ListenerFn<Emit, K>;
};
export type EventListenerOrListenerObj<Emit extends EmitType, K extends keyof Emit | keyof HTMLElementEventMap> = ListenerFn<Emit, K> | EventListenerObj<Emit, K>;
type getAttrType<Attr, K extends keyof Attr> = Extract<Attr[K], string> extends never ? string : Extract<Attr[K], string>;
export interface BaseAttrs {
/**
* The language of the component.
* @type `Lang`
*/
lang?: Lang;
}
export interface BaseEmits {
'dt-attribute-changed': {
name: string;
oldValue: string | null;
newValue: string | null;
};
}
declare const HTMLElementBase: {
new (): HTMLElement;
prototype: HTMLElement;
};
type Elements = HTMLElement | HTMLElement[];
export declare class UiBase<Attr extends BaseAttrs = BaseAttrs, Emit extends BaseEmits = BaseEmits> extends HTMLElementBase {
static readonly tagName: string;
protected static _definePromise: Promise<CustomElementConstructor> | null;
static define(): Promise<CustomElementConstructor> | undefined;
static get observedAttributes(): string[];
protected static _style: string;
protected static _template: string;
private get _constructor();
private _initTemplate;
get _staticEls(): Record<string, Elements>;
get _dynamicEls(): Record<string, Elements | undefined>;
private _staticElsCache;
protected get _els(): this['_staticEls'] & this['_dynamicEls'];
constructor();
protected _getAttr<K extends keyof Attr>(qualifiedName: K): getAttrType<Attr, K> | null;
protected _getAttr<K extends keyof Attr>(qualifiedName: K, defaultValue: getAttrType<Attr, K> | string): getAttrType<Attr, K>;
protected $<E extends HTMLElement = HTMLElement>(selector: string | TemplateStringsArray, ...args: unknown[]): any[];
protected $0<E extends HTMLElement = HTMLElement>(selector: string | TemplateStringsArray, ...args: unknown[]): E | undefined;
private _unbindFnCache;
protected _bindEvt<Ele>(elsOrSelector: Ele | Ele[] | string | TemplateStringsArray, ...strSlot: unknown[]): Ele extends string | TemplateStringsArray ? HTMLElement['addEventListener'] : Ele extends {
addEventListener: infer F;
} ? F : never;
protected _onAttrChanged(_name: string, _oldVal: string | null, _newVal: string | null): void;
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
/** return `false | void` means not continue */
connectedCallback(): boolean | void;
/** return `false | void` means not continue */
disconnectedCallback(): boolean | void;
connectedMoveCallback(): void;
adoptedCallback(): void;
protected _onScreenSizeChanged(isSmall: boolean): void;
protected get _isSmallScreen(): boolean;
dispatchEvent(event: Event): boolean;
dispatchEvent<K extends keyof Emit>(type: K, data: Emit[K], global?: boolean): boolean;
dispatchEvent(type: string, data?: any, global?: boolean): boolean;
protected _stopEvent: (e: Event) => void;
addEventListener<K extends keyof Emit | keyof HTMLElementEventMap>(type: K | string, listener: EventListenerOrListenerObj<Emit, K>, options?: boolean | EventListenerOptions): void;
removeEventListener<K extends keyof Emit | keyof HTMLElementEventMap>(type: K | string, listener: EventListenerOrListenerObj<Emit, K>, options?: boolean | EventListenerOptions): void;
protected _genRenderFn<F extends (...args: any) => void>(fn: F): F;
}
export {};