1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const react_1 = __importDefault(require("react"));
|
7 | const chalk_1 = __importDefault(require("chalk"));
|
8 | const colorize_1 = __importDefault(require("../colorize"));
|
9 |
|
10 |
|
11 |
|
12 | const Text = ({ color, backgroundColor, dimColor, bold, italic, underline, strikethrough, inverse, wrap, children }) => {
|
13 | if (children === undefined || children === null) {
|
14 | return null;
|
15 | }
|
16 | const transform = (children) => {
|
17 | if (dimColor) {
|
18 | children = chalk_1.default.dim(children);
|
19 | }
|
20 | if (color) {
|
21 | children = colorize_1.default(children, color, 'foreground');
|
22 | }
|
23 | if (backgroundColor) {
|
24 | children = colorize_1.default(children, backgroundColor, 'background');
|
25 | }
|
26 | if (bold) {
|
27 | children = chalk_1.default.bold(children);
|
28 | }
|
29 | if (italic) {
|
30 | children = chalk_1.default.italic(children);
|
31 | }
|
32 | if (underline) {
|
33 | children = chalk_1.default.underline(children);
|
34 | }
|
35 | if (strikethrough) {
|
36 | children = chalk_1.default.strikethrough(children);
|
37 | }
|
38 | if (inverse) {
|
39 | children = chalk_1.default.inverse(children);
|
40 | }
|
41 | return children;
|
42 | };
|
43 | return (react_1.default.createElement("ink-text", { style: { flexGrow: 0, flexShrink: 1, flexDirection: 'row', textWrap: wrap }, internal_transform: transform }, children));
|
44 | };
|
45 | Text.displayName = 'Text';
|
46 | Text.defaultProps = {
|
47 | dimColor: false,
|
48 | bold: false,
|
49 | italic: false,
|
50 | underline: false,
|
51 | strikethrough: false,
|
52 | wrap: 'wrap'
|
53 | };
|
54 | exports.default = Text;
|
55 |
|
\ | No newline at end of file |