UNPKG

cui-light

Version:
546 lines (526 loc) 18.6 kB
// Generated by dts-bundle v0.7.3 export const CUI_LIGHT_VERSION = "0.3.0"; global { interface Window { cuiInit: CuiInit; } } export class CuiInit { #private; constructor(); init(data: CuiInitData): Promise<boolean>; } export class CuiInstance { #private; constructor(setup: CuiSetupInit, plugins: ICuiPlugin[], components: ICuiComponent[]); init(): CuiInstance; finish(): void; get(selector: string): ElementManager | undefined; collection(selector: string): CollectionManager | undefined; toast(message: string): Promise<boolean>; select(selector: string): Element | null; all(selector: string): Element[] | undefined; getUtils(): CuiUtils; on(event: string, callback: any, element?: CuiElement): void; detach(event: string, id: string): void; detachAll(event: string): void; emit(event: string, element: Element | string, ...args: any[]): void; alert(id: string, type: CuiAlertType, data: CuiAlertData): void; getPlugin(name: string): ICuiPlugin | undefined; createCuiElement<T extends object>(element: HTMLElement, arg: string, data: T): boolean; } export interface CuiInitData { plugins?: ICuiPlugin[]; components?: ICuiComponent[]; setup?: CuiSetupInit; icons?: any; swipeAnimations?: CuiAnimationsDefinition; } export interface CuiInitResult { result: boolean; message?: string; } export class CuiInitializer { #private; constructor(); init(setup: CuiInitData): Promise<CuiInitResult>; } interface CuiSetupCommon { prefix?: string; logLevel?: CuiLogLevel; cacheSize?: number; autoLightMode?: boolean; animationTime?: number; animationTimeShort?: number; animationTimeLong?: number; scrollThreshold?: number; resizeThreshold?: number; } export class CuiSetup implements CuiSetupCommon { prefix: string; logLevel?: CuiLogLevel; cacheSize?: number; autoLightMode?: boolean; animationTime?: number; animationTimeShort?: number; animationTimeLong?: number; scrollThreshold: number; resizeThreshold: number; plugins: any; constructor(); fromInit(init: CuiSetupInit): CuiSetup; } export class CuiSetupInit implements CuiSetupCommon { prefix: string; app: string; interaction: CuiInteractionsType; logLevel: CuiLogLevel; cacheSize: number; autoLightMode?: boolean; animationTime: number; animationTimeShort: number; animationTimeLong: number; scrollThreshold: number; resizeThreshold: number; busSetup?: ICuiEventBusQueueSetup[]; development: ICuiDevelopmentTool | undefined; root: HTMLElement; constructor(); } export {}; export interface ICuiLogger { debug(message: string, functionName?: string): void; error(message: string, functionName?: string): void; warning(message: string, functionName?: string): void; exception(e: Error, functionName?: string): void; performance(callback: any, functionName?: string): void; setId(id: string): void; } export interface IUIInteractionProvider { mutate(callback: any, ctx: any, ...args: any[]): void; fetch(callback: any, ctx: any, ...args: any[]): void; } export interface ICuiDictionary<T> { add(key: string, value: T): void; remove(key: string): void; get(key: string): T | undefined; containsKey(key: string): boolean; keys(): string[]; values(): T[]; indexOf(key: string): number; update(key: string, value: T): void; clear(): void; } export interface ICuiDictionaryItem<T> { key: string; value: T; } export interface ICuiComponentHandler { handle(args: any): void; refresh(args: any): void; destroy(): void; } export interface ICuiOpenable { open(args?: any): Promise<boolean>; } export interface ICuiSwitchable { switch(index: number): Promise<boolean>; } export interface ICuiClosable { close(args?: any): Promise<boolean>; } export interface CuiCachable { refresh(): boolean; } export interface ICuiParsable { parse(val: any): void; } export interface ICui { getId(): string; } export interface ICuiManager<T> { put(key: string, element: T): void; get(key: string): T | undefined; has(key: string): boolean; remove(key: string): boolean; clear(): void; } export interface ICuiPlugin { description: string; name: string; setup: any; init(utils: CuiUtils): void; destroy(): void; } export interface ICuiMutiationPlugin { mutation(record: MutationRecord): Promise<boolean>; } export interface ICuiEventBus { on(name: string, callback: any, cui?: CuiElement): string | null; detach(name: string, id: string, cui?: CuiElement): void; detachAll(name: string, cui?: CuiElement): void; emit(event: string, cuid: string | null, ...args: any[]): Promise<boolean>; isSubscribing(name: string, id: string, cui?: CuiElement): boolean; detachByCuid(event: string, cuid: string): void; } export interface ICuiCallbackExecutor { execute(callback: any, args: any[]): Promise<void>; } export interface CuiEventObj { callback: any; $cuid: string | null; } export interface CuiEventReceiver { [id: string]: CuiEventObj; } export interface ICuiEventEmitHandler { handle(receiver: CuiEventReceiver, cuid: string | null, args: any[]): Promise<void>; } export interface CuiContext { getId(): string; } export interface ICuiComponentFactory { get(element: Element, sutils: CuiUtils): ICuiComponentHandler; } export interface ICuiComponent { attribute: string; getStyle(): string | null; get(element: HTMLElement, sutils: CuiUtils): ICuiComponentHandler; } export interface ICuiPluginManager { init(utils: CuiUtils): void; get(name: string): ICuiPlugin | undefined; onMutation(mutation: MutationRecord): Promise<boolean>; } export interface ICuiObservableArg { } export interface ICuiObservable { key: string; on(arg: ICuiObservableArg): Promise<boolean>; } export interface CuiObservables { [key: string]: ICuiObservable; } export interface CuiHandlers { [id: string]: ICuiComponentHandler; } export interface CuiElement { $cuid: string | null; $handlers?: CuiHandlers; } export interface ICuiObserver { observe(target: Element): void; unobserve(target: Element): void; connect(): void; disconnect(): void; } export interface ICuiEventListener<T> { setCallback(callback: (t: T) => void): void; isInProgress(): boolean; attach(): void; detach(): void; isAttached(): boolean; } export interface CuiAlertData { title: string; message: string; reverse?: boolean; onCancel?: () => void; onOk?: () => void; onYes?: () => void; onNo?: () => void; } export interface ICuiDevelopmentTool { registerElement(element: HTMLElement, cuid: string, component: string): void; unregisterElement(cuid: string, component: string): void; setProperty<T>(cuid: string, component: string, name: string, t: T): void; pushState(cuid: string, component: string, type: CuiDevelopmentStateType, message: string, functionName?: string): void; log(type: CuiDevelopmentStateType, message: string, functionName?: string): void; } export interface ICuiDevelopmentToolApi { getProperty<T>(cuid: string, component: string, name: string): T; getElement<T>(cuid: string): CuiDevelopmentElement<T>; } export interface CuiDevelopmentElement<T> { element: HTMLElement; cuid: string; components: CuiDevelopmentComponents<T>; properties: CuiDevelopmentProperties<T>; } export interface CuiDevelopmentProperties<T> { [name: string]: T; } export interface CuiDevelopmentComponents<T> { [name: string]: CuiDevelopmentComponent<T>; } export interface CuiDevelopmentComponent<T> { name: string; registerDt: number; properties: CuiDevelopmentProperties<T>; state: CuiDevelopmentState[]; } export interface CuiDevelopmentState { message: string; function: string; timestamp: number; type: CuiDevelopmentStateType; } export interface KeyDownEvent { timestamp: number; event: KeyboardEvent; } export type CuiDevelopmentStateType = "info" | "error" | "warning"; export class CuiUtils { #private; interactions: IUIInteractionProvider; bus: ICuiEventBus; setup: CuiSetup; cache: ICuiManager<CuiCachable>; colors: CuiInstanceColorHandler; styleAppender: ICuiDocumentStyleAppender; development: CuiDevelopmentToolManager; constructor(initialSetup: CuiSetupInit); setLightMode(mode: CuiLightMode): void; getLightMode(): CuiLightMode; setPrintMode(flag: boolean): void; isPrintMode(): boolean; setProperty(name: string, value: string): void; } export class ElementManager implements CuiCachable { #private; constructor(elements: Element[], utils: CuiUtils); toggleClass(className: string): Promise<boolean>; toggleClassAs(className: string): Promise<boolean>; setClass(className: string): Promise<boolean>; setClassAs(className: string): Promise<boolean>; removeClass(className: string): Promise<boolean>; removeClassAs(className: string): Promise<boolean>; getAttribute(attributeName: string): string[]; setAttribute(attributeName: string, attributeValue?: string): Promise<boolean>; setAttributeAs(attributeName: string, attributeValue?: string): Promise<boolean>; removeAttribute(attributeName: string): Promise<boolean>; removeAttributeAs(attributeName: string): Promise<boolean>; toggleAttribute(attributeName: string, attributeValue?: string): Promise<boolean>; toggleAttributeAs(attributeName: string, attributeValue?: string): Promise<boolean>; click(onClick: (ev: MouseEvent) => void): Promise<boolean>; event(eventName: string, callback: any): Promise<boolean>; call(callback: (element: Element, index: Number) => void, functionName?: string): Promise<boolean>; animate(className: string, timeout?: number): Promise<boolean>; open(openClass: string, animationClass: string, timeout?: number): Promise<boolean>; close(closeClass: string, animationClass: string, timeout?: number): Promise<boolean>; emit(event: string, ...args: any[]): void; on(event: string, callback: any): string[]; detach(event: string, id: string): void; read(callback: any, ...args: any[]): void; change(callback: any, ...args: any[]): void; elements(): Element[]; count(): number; lock(): void; unlock(): void; isLocked(): boolean; refresh(): boolean; } export class CollectionManager implements CuiCachable { #private; constructor(elements: Element[], interactions: IUIInteractionProvider); setToggle(className: string): void; setElements(elements: Element[]): void; click(callback: (element: Element, index: number) => void): void; next(): Promise<boolean>; previous(): Promise<boolean>; set(index: number): Promise<boolean>; setWithAnimation(index: number, animClassIn: string, animClassOut: string, duration: number): Promise<boolean>; getCurrentIndex(): number; length(): number; refresh(): boolean; } export type CuiLogLevel = "none" | "error" | "warning" | "debug"; export type CuiInteractionsType = 'sync' | 'async'; export type CuiColorSetType = 'light' | 'dark' | 'accent' | 'secondary' | 'success' | 'warning' | 'error'; export type CuiClearCacheType = 'element' | "collection" | "all"; export type CuiLightMode = 'light' | 'dark'; export type CuiWindowSize = 'small' | 'medium' | 'large' | 'xlarge' | "none"; export type CuiAlertType = "Info" | "OkCancel" | "YesNoCancel"; export interface AnimationDefinition { previous: DefinitionItem; current: DefinitionItem; } export interface DefinitionItem { left: AnimationProperty<PropsTypes>; right: AnimationProperty<PropsTypes>; } export interface CuiAnimationsDefinition { [id: string]: AnimationDefinition; } export const SWIPE_ANIMATIONS_DEFINITIONS: CuiAnimationsDefinition; export interface CuiBusExtStatisticsItem { name: string; emits: number; queueNumber: number; } export interface CuiBusExtStatistics { queueCount: number; events: { [name: string]: CuiBusExtStatisticsItem; }; } export interface ICuiEventBusQueueSetup { name: string; handler: "tasked" | string; eventsDef: string[]; priority: number; } export interface ICuiDocumentStyleAppender { append(style: string): boolean; } export class CuiDocumentStyleAppender implements ICuiDocumentStyleAppender { #private; constructor(interactions: IUIInteractionProvider); append(style: string): boolean; } export class CuiInstanceColorHandler { #private; constructor(interactions: IUIInteractionProvider); setAppBackground(light: CuiColor, dark: CuiColor): void; setComponentBackground(light: CuiColor, dark: CuiColor): void; setBordersColors(light: CuiColor, dark: CuiColor): void; setColor(type: CuiColorSetType, set: CuiColorSet): void; setLightenFactor(factor: number): void; setDarkenFactor(factor: number): void; setProperty(propertyName: string, value: string): void; setPropertyIn(propertyName: string, value: string): void; } export class CuiDevelopmentToolManager implements ICuiDevelopmentTool { #private; constructor(tool?: ICuiDevelopmentTool); pushState(cuid: string, component: string, type: CuiDevelopmentStateType, message: string, functionName?: string): void; registerElement(element: HTMLElement, cuid: string, component: string): void; unregisterElement(cuid: string, component: string): void; setProperty<T>(cuid: string, component: string, name: string, t: T): void; log(type: CuiDevelopmentStateType, message: string, functionName?: string): void; } export type PropsTypes = AnimatorPropertyValue | TransformAnimatorProperty; export class CuiAnimation { #private; constructor(element?: Element); setElement(element: Element): void; setTimeout(timeout: number): void; onError(callback: (e: Error) => void): void; onFinish(callback: OnAnimationFinishCallback): void; perform(props: AnimationProperty<PropsTypes>, timeout?: number, factor?: number): void; } export class CuiAnimationEngine { #private; constructor(cleanOnFinish?: boolean); onFinish(callback: OnAnimationFinishCallback): void; setAnimators(animators: ICuiPropertyAnimator<PropsTypes>[]): void; setProps(props: AnimationProperty<PropsTypes>): void; setElement(element: Element): void; setOnError(callback: (e: Error) => void): void; animate(timeout: number, progress?: number, revert?: boolean): void; isLocked(): boolean; } export class CuiSwipeAnimationEngine { #private; constructor(shouldCleanOnFinish?: boolean); setElement(element: Element): void; setOnFinish(callback: OnAnimationFinishCallback): void; setOnError(callback: (e: Error) => void): void; setProps(props: AnimationProperty<PropsTypes>): void; /** * Perform single update on animators * @param progress - progress value to be set to animators 0..1 */ update(progress: number): void; /** * Perform single update on animators in RAF * @param progress - progress value to be set to animators 0..1 */ updateAsync(progress: number): void; /** * Finish swipe animation using animation engine * @param progress - initial progress value 0..1 * @param timeout - time for animation to perform * @param revert - whether animation should return back to 0 or progress to the end */ finish(progress: number, timeout: number, revert: boolean): void; } export interface ICuiPropertyAnimator<T> { perform(element: any, progress: number, factor: number): void; setProperty(prop: T): void; } export interface AnimationProperty<T> { [id: string]: T; } export interface AnimatorPropertyValue { from: number; to: number; unit?: string; } export interface TransformAnimatorProperty { [name: string]: AnimatorPropertyValue; } export interface OnAnimationFinishCallback { (element: Element | undefined, reverted: boolean, error: boolean): void; } export interface AnimationDefinition { previous: DefinitionItem; current: DefinitionItem; } export interface DefinitionItem { left: AnimationProperty<PropsTypes>; right: AnimationProperty<PropsTypes>; } export interface CuiAnimationsDefinition { [id: string]: AnimationDefinition; } export class CuiColor { #private; constructor(red: number, green: number, blue: number, alpha?: number); static create(colorStr: string): CuiColor; set(red: number, green: number, blue: number, alpha?: number): void; setRed(red: number): void; setGreen(green: number): void; setBlue(blue: number): void; opacity(val: number): CuiColor; lighten(amount: number): CuiColor; darken(amount: number): CuiColor; invert(): CuiColor; getColorValue(type: string): number; toCssString(): string; clone(): CuiColor; } export interface CuiColorSet { base: CuiColor; muted?: CuiColor; active?: CuiColor; } export interface CuiColorTheme { base: string; muted: string; active: string; } export interface CuiColorPair { light: string; dark: string; } interface ColorParser { trim(): void; isValid(): boolean; parse(): CuiColor | undefined; } export class HexColorParser implements ColorParser { #private; constructor(colorStr: string); trim(): void; isValid(): boolean; parse(): CuiColor | undefined; } export class RgbColorParser implements ColorParser { #private; constructor(colorStr: string); trim(): void; isValid(): boolean; parse(): CuiColor | undefined; } export {};