UNPKG

2.68 kBTypeScriptView Raw
1/**
2 * @type {CustomElementRegistry}
3 */
4export const registry: CustomElementRegistry;
5export function define(name: string, constr: any, opts?: ElementDefinitionOptions | undefined): void;
6export function whenDefined(name: string): Promise<CustomElementConstructor>;
7/**
8 * @template S
9 */
10export class Lib0Component<S> extends HTMLElement {
11 /**
12 * @param {S} [state]
13 */
14 constructor(state?: S | undefined);
15 /**
16 * @type {S|null}
17 */
18 state: S | null;
19 /**
20 * @type {any}
21 */
22 _internal: any;
23 /**
24 * @param {S} state
25 * @param {boolean} [forceStateUpdate] Force that the state is rerendered even if state didn't change
26 */
27 setState(state: S, forceStateUpdate?: boolean | undefined): void;
28 /**
29 * @param {any} stateUpdate
30 */
31 updateState(stateUpdate: any): void;
32}
33export function createComponent<T>(name: string, { template, style, state: defaultState, onStateChange, childStates, attrs, listeners, slots }: CONF<T>): typeof Lib0Component;
34export function createComponentDefiner(definer: Function): () => any;
35export function defineListComponent(): any;
36export function defineLazyLoadingComponent(): any;
37export type CONF<S> = {
38 /**
39 * Template for the shadow dom.
40 */
41 template?: string | null | undefined;
42 /**
43 * shadow dom style. Is only used when
44 * `CONF.template` is defined
45 */
46 style?: string | undefined;
47 /**
48 * Initial component state.
49 */
50 state?: S | undefined;
51 /**
52 * Called when
53 * the state changes.
54 */
55 onStateChange?: ((arg0: S, arg1: S | null, arg2: Lib0Component<S>) => void) | undefined;
56 /**
57 * maps from
58 * CSS-selector to transformer function. The first element that matches the
59 * CSS-selector receives state updates via the transformer function.
60 */
61 childStates?: {
62 [x: string]: (arg0: any, arg1: any) => Object;
63 } | undefined;
64 /**
65 * attrs-keys and state-keys should be camelCase, but the DOM uses kebap-case. I.e.
66 * `attrs = { myAttr: 4 }` is represeted as `<my-elem my-attr="4" />` in the DOM
67 */
68 attrs?: {
69 [x: string]: "string" | "number" | "json" | "bool";
70 } | undefined;
71 /**
72 * Maps from dom-event-name
73 * to event listener.
74 */
75 listeners?: {
76 [x: string]: (arg0: CustomEvent, arg1: Lib0Component<any>) => boolean | void;
77 } | undefined;
78 /**
79 * Fill slots
80 * automatically when state changes. Maps from slot-name to slot-html.
81 */
82 slots?: ((arg0: S, arg1: S, arg2: Lib0Component<S>) => {
83 [x: string]: string;
84 }) | undefined;
85};
86//# sourceMappingURL=component.d.ts.map
\No newline at end of file