.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / enquirer / lib / styles.js
1 'use strict';
2
3 const utils = require('./utils');
4 const colors = require('ansi-colors');
5
6 const styles = {
7   default: colors.noop,
8   noop: colors.noop,
9
10   /**
11    * Modifiers
12    */
13
14   set inverse(custom) {
15     this._inverse = custom;
16   },
17   get inverse() {
18     return this._inverse || utils.inverse(this.primary);
19   },
20
21   set complement(custom) {
22     this._complement = custom;
23   },
24   get complement() {
25     return this._complement || utils.complement(this.primary);
26   },
27
28   /**
29    * Main color
30    */
31
32   primary: colors.cyan,
33
34   /**
35    * Main palette
36    */
37
38   success: colors.green,
39   danger: colors.magenta,
40   strong: colors.bold,
41   warning: colors.yellow,
42   muted: colors.dim,
43   disabled: colors.gray,
44   dark: colors.dim.gray,
45   underline: colors.underline,
46
47   set info(custom) {
48     this._info = custom;
49   },
50   get info() {
51     return this._info || this.primary;
52   },
53
54   set em(custom) {
55     this._em = custom;
56   },
57   get em() {
58     return this._em || this.primary.underline;
59   },
60
61   set heading(custom) {
62     this._heading = custom;
63   },
64   get heading() {
65     return this._heading || this.muted.underline;
66   },
67
68   /**
69    * Statuses
70    */
71
72   set pending(custom) {
73     this._pending = custom;
74   },
75   get pending() {
76     return this._pending || this.primary;
77   },
78
79   set submitted(custom) {
80     this._submitted = custom;
81   },
82   get submitted() {
83     return this._submitted || this.success;
84   },
85
86   set cancelled(custom) {
87     this._cancelled = custom;
88   },
89   get cancelled() {
90     return this._cancelled || this.danger;
91   },
92
93   /**
94    * Special styling
95    */
96
97   set typing(custom) {
98     this._typing = custom;
99   },
100   get typing() {
101     return this._typing || this.dim;
102   },
103
104   set placeholder(custom) {
105     this._placeholder = custom;
106   },
107   get placeholder() {
108     return this._placeholder || this.primary.dim;
109   },
110
111   set highlight(custom) {
112     this._highlight = custom;
113   },
114   get highlight() {
115     return this._highlight || this.inverse;
116   }
117 };
118
119 styles.merge = (options = {}) => {
120   if (options.styles && typeof options.styles.enabled === 'boolean') {
121     colors.enabled = options.styles.enabled;
122   }
123   if (options.styles && typeof options.styles.visible === 'boolean') {
124     colors.visible = options.styles.visible;
125   }
126
127   let result = utils.merge({}, styles, options.styles);
128   delete result.merge;
129
130   for (let key of Object.keys(colors)) {
131     if (!result.hasOwnProperty(key)) {
132       Reflect.defineProperty(result, key, { get: () => colors[key] });
133     }
134   }
135
136   for (let key of Object.keys(colors.styles)) {
137     if (!result.hasOwnProperty(key)) {
138       Reflect.defineProperty(result, key, { get: () => colors[key] });
139     }
140   }
141   return result;
142 };
143
144 module.exports = styles;