mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-03 23:42:50 +00:00
redom: Provides its own types (#39534)
This commit is contained in:
parent
91c3deba3c
commit
fc00a1eb58
@ -3456,6 +3456,12 @@
|
||||
"sourceRepoURL": "https://github.com/sindresorhus/redent",
|
||||
"asOfVersion": "3.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "redom",
|
||||
"typingsPackageName": "redom",
|
||||
"sourceRepoURL": "https://github.com/redom/redom/",
|
||||
"asOfVersion": "3.23.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "reduce-reducers",
|
||||
"typingsPackageName": "reduce-reducers",
|
||||
|
||||
103
types/redom/index.d.ts
vendored
103
types/redom/index.d.ts
vendored
@ -1,103 +0,0 @@
|
||||
// Type definitions for redom 3.12
|
||||
// Project: https://github.com/redom/redom/, https://redom.js.org
|
||||
// Definitions by: Rauli Laine <https://github.com/RauliL>
|
||||
// Felix Nehrke <https://github.com/nemoinho>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export type RedomElement = Node | RedomComponent;
|
||||
export type RedomQuery = string | RedomElement;
|
||||
export type RedomMiddleware = (el: HTMLElement) => void;
|
||||
export type RedomQueryArgumentValue = RedomElement | string | number | { [key: string]: any } | RedomMiddleware;
|
||||
export type RedomQueryArgument = RedomQueryArgumentValue | RedomQueryArgumentValue[];
|
||||
|
||||
export interface RedomComponent {
|
||||
el: HTMLElement;
|
||||
|
||||
update?(item: any, index: number, data: any, context?: any): void;
|
||||
|
||||
onmount?(): void;
|
||||
|
||||
onremount?(): void;
|
||||
|
||||
onunmount?(): void;
|
||||
}
|
||||
|
||||
export interface RedomComponentConstructor {
|
||||
new (): RedomComponent;
|
||||
}
|
||||
|
||||
export class ListPool {
|
||||
constructor(View: RedomComponentConstructor, key?: string, initData?: any);
|
||||
|
||||
update(data: any[], context?: any): void;
|
||||
}
|
||||
|
||||
export class List implements RedomComponent {
|
||||
el: HTMLElement;
|
||||
|
||||
constructor(parent: RedomQuery, View: RedomComponentConstructor, key?: string, initData?: any);
|
||||
|
||||
update(data: any[], context?: any): void;
|
||||
|
||||
onmount?(): void;
|
||||
|
||||
onremount?(): void;
|
||||
|
||||
onunmount?(): void;
|
||||
|
||||
static extend(parent: RedomQuery, View: RedomComponentConstructor, key?: string, initData?: any): RedomComponentConstructor;
|
||||
}
|
||||
|
||||
export class Place implements RedomComponent {
|
||||
el: HTMLElement;
|
||||
|
||||
constructor(View: RedomComponentConstructor, initData?: any);
|
||||
|
||||
update(visible: boolean, data?: any): void;
|
||||
}
|
||||
|
||||
export class Router implements RedomComponent {
|
||||
el: HTMLElement;
|
||||
|
||||
constructor(parent: RedomQuery, Views: RouterDictionary, initData?: any);
|
||||
|
||||
update(route: string, data?: any): void;
|
||||
}
|
||||
|
||||
export interface RouterDictionary {
|
||||
[key: string]: RedomComponentConstructor;
|
||||
}
|
||||
|
||||
export function html(query: RedomQuery, ...args: RedomQueryArgument[]): HTMLElement;
|
||||
export function h(query: RedomQuery, ...args: RedomQueryArgument[]): HTMLElement;
|
||||
export function el(query: RedomQuery, ...args: RedomQueryArgument[]): HTMLElement;
|
||||
|
||||
export function listPool(View: RedomComponentConstructor, key?: string, initData?: any): ListPool;
|
||||
export function list(parent: RedomQuery, View: RedomComponentConstructor, key?: string, initData?: any): List;
|
||||
|
||||
export function mount(parent: RedomElement, child: RedomElement, before?: RedomElement): RedomElement;
|
||||
export function unmount(parent: RedomElement, child: RedomElement): RedomElement;
|
||||
|
||||
export function place(View: RedomComponentConstructor, initData?: any): Place;
|
||||
|
||||
export function router(parent: RedomQuery, Views: RouterDictionary, initData?: any): Router;
|
||||
|
||||
export function setAttr(view: RedomElement, arg1: string | object, arg2?: string): void;
|
||||
|
||||
export function setStyle(view: RedomElement, arg1: string | object, arg2?: string): void;
|
||||
|
||||
export function setChildren(parent: RedomElement, children: RedomElement[]): void;
|
||||
|
||||
export function svg(query: RedomQuery, ...args: RedomQueryArgument[]): SVGElement;
|
||||
export function s(query: RedomQuery, ...args: RedomQueryArgument[]): SVGElement;
|
||||
|
||||
export function text(str: string): Text;
|
||||
|
||||
export namespace list {
|
||||
function extend(parent: RedomQuery, View: RedomComponentConstructor, key?: string, initData?: any): RedomComponentConstructor;
|
||||
}
|
||||
|
||||
export namespace svg {
|
||||
function extend(query: RedomQuery): RedomComponentConstructor;
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
import * as redom from 'redom';
|
||||
|
||||
const el1: HTMLElement = redom.el('');
|
||||
const el2: HTMLElement = redom.el('p', 'Hello, World!', (el: HTMLElement) => { el.setAttribute('ok', '!'); });
|
||||
const el3: HTMLElement = redom.html('p', 2, { color: 'red' });
|
||||
|
||||
redom.mount(document.body, el1);
|
||||
redom.mount(document.body, el2, el1);
|
||||
redom.unmount(document.body, el1);
|
||||
|
||||
redom.setAttr(el3, 'ok', '!');
|
||||
redom.setAttr(el3, { ok: '!' });
|
||||
redom.setStyle(el3, { color: 'blue' });
|
||||
redom.setChildren(el1, [el2, el3]);
|
||||
|
||||
redom.mount(document.body, redom.text('Hello, World!'));
|
||||
|
||||
class Td implements redom.RedomComponent {
|
||||
el: HTMLElement;
|
||||
constructor() {
|
||||
this.el = redom.h('td');
|
||||
}
|
||||
update(value: any) {
|
||||
this.el.textContent = value;
|
||||
}
|
||||
onmount() {
|
||||
console.log('mounted td');
|
||||
}
|
||||
}
|
||||
const Tr = redom.list.extend('tr', Td);
|
||||
const table = redom.list('table', Tr);
|
||||
table.onmount = () => console.log('mounted table');
|
||||
|
||||
table.update([
|
||||
[1, 2],
|
||||
[3, 4],
|
||||
]);
|
||||
|
||||
redom.mount(document.body, table);
|
||||
@ -1,25 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"redom-tests.ts"
|
||||
]
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user