mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[boxen] Add types (#31812)
This commit is contained in:
parent
a0f4fe7299
commit
44edbc65ed
37
types/boxen/boxen-tests.ts
Normal file
37
types/boxen/boxen-tests.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import boxen = require('boxen');
|
||||
|
||||
boxen('unicorn'); // $ExpectType string
|
||||
boxen('unicorn', { borderColor: 'black' }); // $ExpectType string
|
||||
boxen('unicorn', { borderStyle: 'double' }); // $ExpectType string
|
||||
boxen('unicorn', { borderStyle: 'foo' }); // $ExpectError
|
||||
// $ExpectType string
|
||||
boxen('unicorn', {
|
||||
borderStyle: {
|
||||
topLeft: '+',
|
||||
topRight: '+',
|
||||
bottomLeft: '+',
|
||||
bottomRight: '+',
|
||||
horizontal: '-',
|
||||
vertical: '|',
|
||||
},
|
||||
});
|
||||
boxen('unicorn', { dimBorder: true }); // $ExpectType string
|
||||
boxen('unicorn', { padding: 1 }); // $ExpectType string
|
||||
boxen('unicorn', { padding: { top: 1 } }); // $ExpectType string
|
||||
boxen('unicorn', { padding: { right: 1 } }); // $ExpectType string
|
||||
boxen('unicorn', { padding: { bottom: 1 } }); // $ExpectType string
|
||||
boxen('unicorn', { padding: { left: 1 } }); // $ExpectType string
|
||||
boxen('unicorn', { margin: 1 }); // $ExpectType string
|
||||
boxen('unicorn', { margin: { top: 1 } }); // $ExpectType string
|
||||
boxen('unicorn', { margin: { right: 1 } }); // $ExpectType string
|
||||
boxen('unicorn', { margin: { bottom: 1 } }); // $ExpectType string
|
||||
boxen('unicorn', { margin: { left: 1 } }); // $ExpectType string
|
||||
boxen('unicorn', { float: 'right' }); // $ExpectType string
|
||||
boxen('unicorn', { float: 'center' }); // $ExpectType string
|
||||
boxen('unicorn', { float: 'left' }); // $ExpectType string
|
||||
boxen('unicorn', { float: 'foo' }); // $ExpectError
|
||||
boxen('unicorn', { backgroundColor: 'white' }); // $ExpectType string
|
||||
boxen('unicorn', { align: 'left' }); // $ExpectType string
|
||||
boxen('unicorn', { align: 'center' }); // $ExpectType string
|
||||
boxen('unicorn', { align: 'right' }); // $ExpectType string
|
||||
boxen('unicorn', { align: 'foo' }); // $ExpectError
|
||||
114
types/boxen/index.d.ts
vendored
Normal file
114
types/boxen/index.d.ts
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
// Type definitions for boxen 2.1
|
||||
// Project: https://github.com/sindresorhus/boxen#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
import { BoxDefinition, BoxNames } from 'cli-boxes';
|
||||
|
||||
export = boxen;
|
||||
|
||||
/**
|
||||
* Create boxes in the terminal
|
||||
* @param input Text inside the box.
|
||||
*/
|
||||
declare function boxen(input: string, options?: boxen.Options): string;
|
||||
|
||||
declare namespace boxen {
|
||||
interface Options {
|
||||
/**
|
||||
* Color of the box border.
|
||||
* Values: `black` `red` `green` `yellow` `blue` `magenta` `cyan` `white` `gray` or a hex value like `#ff0000`
|
||||
*/
|
||||
borderColor?: string;
|
||||
|
||||
/**
|
||||
* Style of the box border.
|
||||
* Can be any of the above predefined styles or an object.
|
||||
*
|
||||
* Predefined values:
|
||||
* - `single`
|
||||
* ```
|
||||
* ┌───┐
|
||||
* │foo│
|
||||
* └───┘
|
||||
* ```
|
||||
* - `double`
|
||||
* ```
|
||||
* ╔═══╗
|
||||
* ║foo║
|
||||
* ╚═══╝
|
||||
* ```
|
||||
* - `round` (`single` sides with round corners)
|
||||
* ```
|
||||
* ╭───╮
|
||||
* │foo│
|
||||
* ╰───╯
|
||||
* ```
|
||||
* - `single-double` (`single` on top and bottom, `double` on right and left)
|
||||
* ```
|
||||
* ╓───╖
|
||||
* ║foo║
|
||||
* ╙───╜
|
||||
* ```
|
||||
* - `double-single` (`double` on top and bottom, `single` on right and left)
|
||||
* ```
|
||||
* ╒═══╕
|
||||
* │foo│
|
||||
* ╘═══╛
|
||||
* ```
|
||||
* - `classic`
|
||||
* ```
|
||||
* +---+
|
||||
* |foo|
|
||||
* +---+
|
||||
* ```
|
||||
*/
|
||||
borderStyle?: BoxNames | BoxDefinition;
|
||||
|
||||
/**
|
||||
* Reduce opacity of the border.
|
||||
* @default false
|
||||
*/
|
||||
dimBorder?: boolean;
|
||||
|
||||
/**
|
||||
* Space between the text and box border.
|
||||
* When a number is specified, the left/right padding is 3 times the top/bottom to make it look nice.
|
||||
* @default 0
|
||||
*/
|
||||
padding?: number | PositionOptions;
|
||||
|
||||
/**
|
||||
* Space around the box.
|
||||
* When a number is specified, the left/right margin is 3 times the top/bottom to make it look nice.
|
||||
* @default 0
|
||||
*/
|
||||
margin?: number | PositionOptions;
|
||||
|
||||
/**
|
||||
* Float the box on the available terminal screen space.
|
||||
* @default 'left'
|
||||
*/
|
||||
float?: 'right' | 'center' | 'left';
|
||||
|
||||
/**
|
||||
* Color of the background.
|
||||
* Values: `black` `red` `green` `yellow` `blue` `magenta` `cyan` `white` `gray` or a hex value like `#ff0000`
|
||||
*/
|
||||
backgroundColor?: string;
|
||||
|
||||
/**
|
||||
* Align the text in the box based on the widest line.
|
||||
* @default 'left'
|
||||
*/
|
||||
align?: 'left' | 'center' | 'right';
|
||||
}
|
||||
|
||||
interface PositionOptions {
|
||||
top?: number;
|
||||
right?: number;
|
||||
bottom?: number;
|
||||
left?: number;
|
||||
}
|
||||
}
|
||||
23
types/boxen/tsconfig.json
Normal file
23
types/boxen/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"boxen-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/boxen/tslint.json
Normal file
1
types/boxen/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user