1+ "use strict" ;
2+
3+ Object . defineProperty ( exports , "__esModule" , {
4+ value : true
5+ } ) ;
6+ exports . Break = exports . Text = exports . Section = undefined ;
7+
8+ var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ; // strict
9+
10+ var _wrapAnsi = require ( "wrap-ansi" ) ;
11+
12+ var _wrapAnsi2 = _interopRequireDefault ( _wrapAnsi ) ;
13+
14+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
15+
16+ function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
17+
18+ // this module is helpful for dealing with ansi characters, but it returns a
19+ // string with embedded new lines. We need it as an array, so we'll split it here
20+ var wrapAnsi = function wrapAnsi ( input , columns ) {
21+ return ( 0 , _wrapAnsi2 . default ) ( input , columns ) . split ( "\n" ) ;
22+ } ;
23+
24+ var Border = function ( ) {
25+ function Border ( _ref ) {
26+ var vertical = _ref . vertical ,
27+ horizontal = _ref . horizontal ,
28+ cornerTopLeft = _ref . cornerTopLeft ,
29+ cornerTopRight = _ref . cornerTopRight ,
30+ cornerBottomLeft = _ref . cornerBottomLeft ,
31+ cornerBottomRight = _ref . cornerBottomRight ;
32+
33+ _classCallCheck ( this , Border ) ;
34+
35+ this . vertical = vertical ;
36+ this . horizontal = horizontal ;
37+ this . cornerTopLeft = cornerTopLeft ;
38+ this . cornerTopRight = cornerTopRight ;
39+ this . cornerBottomLeft = cornerBottomLeft ;
40+ this . cornerBottomRight = cornerBottomRight ;
41+ }
42+
43+ _createClass ( Border , [ {
44+ key : "horizontalWidth" ,
45+ value : function horizontalWidth ( ) {
46+ return Math . max ( this . vertical ? this . vertical . length : 0 , this . cornerTopLeft ? this . cornerTopLeft . length : 0 , this . cornerBottomLeft ? this . cornerBottomLeft . length : 0 ) + Math . max ( this . vertical ? this . vertical . length : 0 , this . cornerTopRight ? this . cornerTopRight . length : 0 , this . cornerBottomRight ? this . cornerBottomRight . length : 0 ) ;
47+ }
48+ } , {
49+ key : "verticalHeight" ,
50+ value : function verticalHeight ( ) {
51+ return Math . max ( this . horizontal ? this . horizontal . length : 0 , this . cornerTopLeft ? this . cornerTopLeft . length : 0 , this . cornerTopRight ? this . cornerTopRight . length : 0 ) + Math . max ( this . horizontal ? this . horizontal . length : 0 , this . cornerBottomLeft ? this . cornerBottomLeft . length : 0 , this . cornerBottomRight ? this . cornerBottomRight . length : 0 ) ;
52+ }
53+ } ] ) ;
54+
55+ return Border ;
56+ } ( ) ;
57+
58+ var Section = exports . Section = function ( ) {
59+ function Section ( _ref2 ) {
60+ var _ref2$useHorizontalOr = _ref2 . useHorizontalOrientation ,
61+ useHorizontalOrientation = _ref2$useHorizontalOr === undefined ? false : _ref2$useHorizontalOr ,
62+ _ref2$align = _ref2 . align ,
63+ align = _ref2$align === undefined ? "left" : _ref2$align ,
64+ _ref2$border = _ref2 . border ,
65+ border = _ref2$border === undefined ? { } : _ref2$border ;
66+
67+ _classCallCheck ( this , Section ) ;
68+
69+ this . children = [ ] ;
70+
71+ this . orientation = useHorizontalOrientation ? "horizontal" : "vertical" ;
72+ this . align = align ;
73+ this . border = new Border ( border ) ;
74+ }
75+
76+ _createClass ( Section , [ {
77+ key : "convertTextToArray" ,
78+ value : function convertTextToArray ( text , totalWidth ) {
79+ return wrapAnsi ( text . text , totalWidth - this . border . horizontalWidth ( ) ) ;
80+ }
81+ } ] ) ;
82+
83+ return Section ;
84+ } ( ) ;
85+
86+ Section . type = "div" ;
87+
88+ var Text = exports . Text = function Text ( text ) {
89+ _classCallCheck ( this , Text ) ;
90+
91+ this . text = text ;
92+ } ;
93+
94+ var Break = exports . Break = function Break ( ) {
95+ _classCallCheck ( this , Break ) ;
96+ } ;
97+
98+ Break . type = "br" ;
0 commit comments