forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type definitions for RE:DOM 3.6 (DefinitelyTyped#20469)
Introduce new type definition package into repository which adds type definitions for a library called RE:DOM. These type definitions are made against RE:DOM version 3.6.2.
- Loading branch information
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Type definitions for redom 3.6 | ||
// Project: https://github.com/redom/redom/ | ||
// Definitions by: Rauli Laine <https://github.com/RauliL> | ||
// 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; | ||
} | ||
|
||
export interface RedomComponentConstructor { | ||
new (): RedomComponent; | ||
} | ||
|
||
export class List implements RedomComponent { | ||
el: HTMLElement; | ||
|
||
constructor(parent: RedomQuery, View: RedomComponentConstructor, key?: string, initData?: any); | ||
|
||
update(data: any[], context?: any): void; | ||
} | ||
|
||
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 el(query: RedomQuery, ...args: RedomQueryArgument[]): HTMLElement; | ||
|
||
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 text(str: string): Text; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
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!')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "extends": "dtslint/dt.json" } |