Comparing version 7.0.2 to 7.1.0
@@ -1,5 +0,12 @@ | ||
import {LiteralUnion} from 'type-fest'; | ||
import {BoxStyle, Boxes} from 'cli-boxes'; | ||
import {type LiteralUnion} from 'type-fest'; | ||
import {type BoxStyle, type Boxes as CLIBoxes} from 'cli-boxes'; | ||
/** | ||
All box styles. | ||
*/ | ||
type Boxes = { | ||
readonly none: BoxStyle; | ||
} & CLIBoxes; | ||
/** | ||
Characters used for custom border. | ||
@@ -25,3 +32,3 @@ | ||
*/ | ||
export interface CustomBorderStyle extends BoxStyle { | ||
export type CustomBorderStyle = { | ||
/** | ||
@@ -36,3 +43,3 @@ @deprecated Use `top` and `bottom` instead. | ||
vertical?: string; | ||
} | ||
} & BoxStyle; | ||
@@ -42,3 +49,3 @@ /** | ||
*/ | ||
export interface Spacing { | ||
export type Spacing = { | ||
readonly top?: number; | ||
@@ -48,5 +55,5 @@ readonly right?: number; | ||
readonly left?: number; | ||
} | ||
}; | ||
export interface Options { | ||
export type Options = { | ||
/** | ||
@@ -235,3 +242,3 @@ Color of the box border. | ||
readonly fullscreen?: boolean | ((width: number, height: number) => [width: number, height: number]); | ||
} | ||
}; | ||
@@ -238,0 +245,0 @@ /** |
43
index.js
@@ -59,2 +59,10 @@ import process from 'node:process'; | ||
// Create empty border style | ||
if (borderStyle === 'none') { | ||
borderStyle = {}; | ||
for (const side of sides) { | ||
borderStyle[side] = ''; | ||
} | ||
} | ||
if (typeof borderStyle === 'string') { | ||
@@ -80,3 +88,3 @@ characters = cliBoxes[borderStyle]; | ||
for (const side of sides) { | ||
if (!borderStyle[side] || typeof borderStyle[side] !== 'string') { | ||
if (borderStyle[side] === null || typeof borderStyle[side] !== 'string') { | ||
throw new TypeError(`Invalid border style: ${side}`); | ||
@@ -98,9 +106,13 @@ } | ||
switch (alignement) { | ||
case 'left': | ||
case 'left': { | ||
title = text + horizontal.slice(textWidth); | ||
break; | ||
case 'right': | ||
} | ||
case 'right': { | ||
title = horizontal.slice(textWidth) + text; | ||
break; | ||
default: | ||
} | ||
default: { | ||
horizontal = horizontal.slice(textWidth); | ||
@@ -117,2 +129,3 @@ | ||
break; | ||
} | ||
} | ||
@@ -141,11 +154,16 @@ | ||
switch (textAlignment) { | ||
case 'center': | ||
case 'center': { | ||
paddedLine = PAD.repeat((max - longestLength) / 2) + alignedLine; | ||
break; | ||
case 'right': | ||
} | ||
case 'right': { | ||
paddedLine = PAD.repeat(max - longestLength) + alignedLine; | ||
break; | ||
default: | ||
} | ||
default: { | ||
paddedLine = alignedLine; | ||
break; | ||
} | ||
} | ||
@@ -174,8 +192,13 @@ | ||
switch (textAlignment) { | ||
case 'center': | ||
case 'center': { | ||
return line + PAD.repeat(width - stringWidth(line)); | ||
case 'right': | ||
} | ||
case 'right': { | ||
return line + PAD.repeat(width - stringWidth(line)); | ||
default: | ||
} | ||
default: { | ||
return line + PAD.repeat(width - stringWidth(line)); | ||
} | ||
} | ||
@@ -182,0 +205,0 @@ } |
{ | ||
"name": "boxen", | ||
"version": "7.0.2", | ||
"version": "7.1.0", | ||
"description": "Create boxes in the terminal", | ||
@@ -39,4 +39,4 @@ "license": "MIT", | ||
"ansi-align": "^3.0.1", | ||
"camelcase": "^7.0.0", | ||
"chalk": "^5.0.1", | ||
"camelcase": "^7.0.1", | ||
"chalk": "^5.2.0", | ||
"cli-boxes": "^3.0.0", | ||
@@ -46,9 +46,9 @@ "string-width": "^5.1.2", | ||
"widest-line": "^4.0.1", | ||
"wrap-ansi": "^8.0.1" | ||
"wrap-ansi": "^8.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^4.3.0", | ||
"ava": "^5.2.0", | ||
"nyc": "^15.1.0", | ||
"tsd": "^0.21.0", | ||
"xo": "^0.50.0" | ||
"tsd": "^0.28.1", | ||
"xo": "^0.54.2" | ||
}, | ||
@@ -61,3 +61,10 @@ "ava": { | ||
} | ||
}, | ||
"xo": { | ||
"rules": { | ||
"@typescript-eslint/no-redundant-type-constituents": "off", | ||
"unicorn/prefer-logical-operator-over-ternary": "off", | ||
"@typescript-eslint/no-unsafe-assignment": "off" | ||
} | ||
} | ||
} |
@@ -120,3 +120,9 @@ # boxen | ||
``` | ||
- `'none'` | ||
``` | ||
foo | ||
``` | ||
Style of the box border. | ||
@@ -299,13 +305,1 @@ | ||
- [ink-box](https://github.com/sindresorhus/ink-box) - Box component for Ink that uses this package | ||
--- | ||
<div align="center"> | ||
<b> | ||
<a href="https://tidelift.com/subscription/pkg/npm-boxen?utm_source=npm-boxen&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> | ||
</b> | ||
<br> | ||
<sub> | ||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. | ||
</sub> | ||
</div> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23718
526
304
Updatedcamelcase@^7.0.1
Updatedchalk@^5.2.0
Updatedwrap-ansi@^8.1.0