mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #17512 from selkinvitaly/master
added typings for bem-cn
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import * as block from "bem-cn";
|
||||
|
||||
// expected 'block'
|
||||
block("block")();
|
||||
|
||||
// expected 'block__elem'
|
||||
block("block")("elem")();
|
||||
|
||||
// expected 'block__elem block__elem_disabled block__elem_size_small'
|
||||
block("block")("elem", { disabled: true, size: 'small' })();
|
||||
|
||||
// expected 'block block_disabled'
|
||||
block("block")({ disabled: true})();
|
||||
|
||||
// expected 'block mix'
|
||||
block("block").mix("mix");
|
||||
|
||||
// expected 'block mix mix2'
|
||||
block("block").mix(["mix", "mix2"]);
|
||||
|
||||
// expected 'block is-hidden'
|
||||
block("block").state({ hidden: true });
|
||||
|
||||
// expected 'block'
|
||||
block("block").state({ hidden: false });
|
||||
|
||||
// expected 'block is-hidden is-error'
|
||||
block("block").state({ hidden: true, error: true });
|
||||
|
||||
// expected 'block is-loading'
|
||||
block("block").is({ loading: true });
|
||||
|
||||
// expected 'block has-content'
|
||||
block("block").has({ content: true });
|
||||
|
||||
block.setup({
|
||||
el: '~~',
|
||||
mod: '--',
|
||||
modValue: '-'
|
||||
});
|
||||
|
||||
// expected 'block~~elem'
|
||||
block("block")("elem");
|
||||
|
||||
// expected 'block block--mod-value'
|
||||
block("block")({ mod: "value"});
|
||||
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
// Type definitions for bem-cn 2.1
|
||||
// Project: https://github.com/albburtsev/bem-cn
|
||||
// Definitions by: Vitaly Selkin <https://github.com/selkinvitaly>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
type StateFn = (states: { [key: string]: boolean }) => Inner;
|
||||
|
||||
interface Modifications {
|
||||
[key: string]: (string | boolean);
|
||||
}
|
||||
|
||||
interface Block {
|
||||
(name: string): Inner;
|
||||
|
||||
reset(): void;
|
||||
setup(settings?: Settings): void;
|
||||
}
|
||||
|
||||
interface Inner {
|
||||
(elem: string | Modifications): Inner;
|
||||
(elem: string, mods: Modifications): Inner;
|
||||
(): string;
|
||||
|
||||
mix(mixes: string | string[]): Inner;
|
||||
has: StateFn;
|
||||
state: StateFn;
|
||||
is: StateFn;
|
||||
toString(): string;
|
||||
split(separator: string, limit?: number): string[];
|
||||
}
|
||||
|
||||
interface Settings {
|
||||
ns?: string;
|
||||
el?: string;
|
||||
mod?: string;
|
||||
modValue?: string;
|
||||
classMap?: { [className: string]: string } | null;
|
||||
}
|
||||
|
||||
declare const block: Block;
|
||||
export = block;
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"bem-cn-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user