@hitools/tui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/element.js +46 -0
- package/elements/confirm.js +56 -0
- package/elements/error.js +22 -0
- package/elements/index.js +19 -0
- package/elements/loader.js +47 -0
- package/elements/message.js +23 -0
- package/elements/multiselect.js +62 -0
- package/elements/question.js +52 -0
- package/elements/select.js +60 -0
- package/elements/task.js +25 -0
- package/examples/index.js +1 -0
- package/index.js +85 -0
- package/package.json +29 -0
- package/prompt.js +152 -0
- package/readme.md +555 -0
- package/theme.js +328 -0
package/theme.js
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// const spinnerFrames = '◜◝◞◟'
|
|
2
|
+
// const spinnerFrames = '◐◑◒◓◔◕'
|
|
3
|
+
// const spinnerFrames = '⬖⬗⬘⬙'
|
|
4
|
+
// const spinnerFrames = '│/─\\'
|
|
5
|
+
// const spinnerFrames = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
|
|
6
|
+
|
|
7
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/named-color
|
|
8
|
+
const HTMLColors = {
|
|
9
|
+
black: "000000",
|
|
10
|
+
silver: "c0c0c0",
|
|
11
|
+
gray: "808080",
|
|
12
|
+
white: "ffffff",
|
|
13
|
+
maroon: "800000",
|
|
14
|
+
red: "ff0000",
|
|
15
|
+
purple: "800080",
|
|
16
|
+
fuchsia: "ff00ff",
|
|
17
|
+
green: "008000",
|
|
18
|
+
lime: "00ff00",
|
|
19
|
+
olive: "808000",
|
|
20
|
+
yellow: "ffff00",
|
|
21
|
+
navy: "000080",
|
|
22
|
+
blue: "0000ff",
|
|
23
|
+
teal: "008080",
|
|
24
|
+
aqua: "00ffff",
|
|
25
|
+
|
|
26
|
+
aliceblue: "f0f8ff",
|
|
27
|
+
antiquewhite: "faebd7",
|
|
28
|
+
aqua: "00ffff",
|
|
29
|
+
aquamarine: "7fffd4",
|
|
30
|
+
azure: "f0ffff",
|
|
31
|
+
beige: "f5f5dc",
|
|
32
|
+
bisque: "ffe4c4",
|
|
33
|
+
black: "000000",
|
|
34
|
+
blanchedalmond: "ffebcd",
|
|
35
|
+
blue: "0000ff",
|
|
36
|
+
blueviolet: "8a2be2",
|
|
37
|
+
brown: "a52a2a",
|
|
38
|
+
burlywood: "deb887",
|
|
39
|
+
cadetblue: "5f9ea0",
|
|
40
|
+
chartreuse: "7fff00",
|
|
41
|
+
chocolate: "d2691e",
|
|
42
|
+
coral: "ff7f50",
|
|
43
|
+
cornflowerblue: "6495ed",
|
|
44
|
+
cornsilk: "fff8dc",
|
|
45
|
+
crimson: "dc143c",
|
|
46
|
+
cyan: "00ffff",
|
|
47
|
+
darkblue: "00008b",
|
|
48
|
+
darkcyan: "008b8b",
|
|
49
|
+
darkgoldenrod: "b8860b",
|
|
50
|
+
darkgray: "a9a9a9",
|
|
51
|
+
darkgreen: "006400",
|
|
52
|
+
darkgrey: "a9a9a9",
|
|
53
|
+
darkkhaki: "bdb76b",
|
|
54
|
+
darkmagenta: "8b008b",
|
|
55
|
+
darkolivegreen: "556b2f",
|
|
56
|
+
darkorange: "ff8c00",
|
|
57
|
+
darkorchid: "9932cc",
|
|
58
|
+
darkred: "8b0000",
|
|
59
|
+
darksalmon: "e9967a",
|
|
60
|
+
darkseagreen: "8fbc8f",
|
|
61
|
+
darkslateblue: "483d8b",
|
|
62
|
+
darkslategray: "2f4f4f",
|
|
63
|
+
darkslategrey: "2f4f4f",
|
|
64
|
+
darkturquoise: "00ced1",
|
|
65
|
+
darkviolet: "9400d3",
|
|
66
|
+
deeppink: "ff1493",
|
|
67
|
+
deepskyblue: "00bfff",
|
|
68
|
+
dimgray: "696969",
|
|
69
|
+
dimgrey: "696969",
|
|
70
|
+
dodgerblue: "1e90ff",
|
|
71
|
+
firebrick: "b22222",
|
|
72
|
+
floralwhite: "fffaf0",
|
|
73
|
+
forestgreen: "228b22",
|
|
74
|
+
fuchsia: "ff00ff",
|
|
75
|
+
gainsboro: "dcdcdc",
|
|
76
|
+
ghostwhite: "f8f8ff",
|
|
77
|
+
gold: "ffd700",
|
|
78
|
+
goldenrod: "daa520",
|
|
79
|
+
gray: "808080",
|
|
80
|
+
green: "008000",
|
|
81
|
+
greenyellow: "adff2f",
|
|
82
|
+
grey: "808080",
|
|
83
|
+
honeydew: "f0fff0",
|
|
84
|
+
hotpink: "ff69b4",
|
|
85
|
+
indianred: "cd5c5c",
|
|
86
|
+
indigo: "4b0082",
|
|
87
|
+
ivory: "fffff0",
|
|
88
|
+
khaki: "f0e68c",
|
|
89
|
+
lavender: "e6e6fa",
|
|
90
|
+
lavenderblush: "fff0f5",
|
|
91
|
+
lawngreen: "7cfc00",
|
|
92
|
+
lemonchiffon: "fffacd",
|
|
93
|
+
lightblue: "add8e6",
|
|
94
|
+
lightcoral: "f08080",
|
|
95
|
+
lightcyan: "e0ffff",
|
|
96
|
+
lightgoldenrodyellow: "fafad2",
|
|
97
|
+
lightgray: "d3d3d3",
|
|
98
|
+
lightgreen: "90ee90",
|
|
99
|
+
lightgrey: "d3d3d3",
|
|
100
|
+
lightpink: "ffb6c1",
|
|
101
|
+
lightsalmon: "ffa07a",
|
|
102
|
+
lightseagreen: "20b2aa",
|
|
103
|
+
lightskyblue: "87cefa",
|
|
104
|
+
lightslategray: "778899",
|
|
105
|
+
lightslategrey: "778899",
|
|
106
|
+
lightsteelblue: "b0c4de",
|
|
107
|
+
lightyellow: "ffffe0",
|
|
108
|
+
lime: "00ff00",
|
|
109
|
+
limegreen: "32cd32",
|
|
110
|
+
linen: "faf0e6",
|
|
111
|
+
magenta: "#ff00ff",
|
|
112
|
+
maroon: "800000",
|
|
113
|
+
mediumaquamarine: "66cdaa",
|
|
114
|
+
mediumblue: "0000cd",
|
|
115
|
+
mediumorchid: "ba55d3",
|
|
116
|
+
mediumpurple: "9370db",
|
|
117
|
+
mediumseagreen: "3cb371",
|
|
118
|
+
mediumslateblue: "7b68ee",
|
|
119
|
+
mediumspringgreen: "00fa9a",
|
|
120
|
+
mediumturquoise: "48d1cc",
|
|
121
|
+
mediumvioletred: "c71585",
|
|
122
|
+
midnightblue: "191970",
|
|
123
|
+
mintcream: "f5fffa",
|
|
124
|
+
mistyrose: "ffe4e1",
|
|
125
|
+
moccasin: "ffe4b5",
|
|
126
|
+
navajowhite: "ffdead",
|
|
127
|
+
navy: "000080",
|
|
128
|
+
oldlace: "fdf5e6",
|
|
129
|
+
olive: "808000",
|
|
130
|
+
olivedrab: "6b8e23",
|
|
131
|
+
orange: "ffa500",
|
|
132
|
+
orangered: "ff4500",
|
|
133
|
+
orchid: "da70d6",
|
|
134
|
+
palegoldenrod: "eee8aa",
|
|
135
|
+
palegreen: "98fb98",
|
|
136
|
+
paleturquoise: "afeeee",
|
|
137
|
+
palevioletred: "db7093",
|
|
138
|
+
papayawhip: "ffefd5",
|
|
139
|
+
peachpuff: "ffdab9",
|
|
140
|
+
peru: "cd853f",
|
|
141
|
+
pink: "ffc0cb",
|
|
142
|
+
plum: "dda0dd",
|
|
143
|
+
powderblue: "b0e0e6",
|
|
144
|
+
purple: "800080",
|
|
145
|
+
rebeccapurple: "663399",
|
|
146
|
+
red: "ff0000",
|
|
147
|
+
rosybrown: "bc8f8f",
|
|
148
|
+
royalblue: "4169e1",
|
|
149
|
+
saddlebrown: "8b4513",
|
|
150
|
+
salmon: "fa8072",
|
|
151
|
+
sandybrown: "f4a460",
|
|
152
|
+
seagreen: "2e8b57",
|
|
153
|
+
seashell: "fff5ee",
|
|
154
|
+
sienna: "a0522d",
|
|
155
|
+
silver: "c0c0c0",
|
|
156
|
+
skyblue: "87ceeb",
|
|
157
|
+
slateblue: "6a5acd",
|
|
158
|
+
slategray: "708090",
|
|
159
|
+
slategrey: "708090",
|
|
160
|
+
snow: "fffafa",
|
|
161
|
+
springgreen: "00ff7f",
|
|
162
|
+
steelblue: "4682b4",
|
|
163
|
+
tan: "d2b48c",
|
|
164
|
+
teal: "008080",
|
|
165
|
+
thistle: "d8bfd8",
|
|
166
|
+
tomato: "ff6347",
|
|
167
|
+
transparent: "",
|
|
168
|
+
turquoise: "40e0d0",
|
|
169
|
+
violet: "ee82ee",
|
|
170
|
+
wheat: "f5deb3",
|
|
171
|
+
white: "ffffff",
|
|
172
|
+
whitesmoke: "f5f5f5",
|
|
173
|
+
yellow: "ffff00",
|
|
174
|
+
yellowgreen: "9acd32",
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const Palette = {
|
|
178
|
+
text: {
|
|
179
|
+
black: '\x1b[38;5;0m',
|
|
180
|
+
white: '\x1b[38;5;231m',
|
|
181
|
+
grey: '\x1b[38;5;249m',
|
|
182
|
+
yellow: '\x1b[38;5;221m',
|
|
183
|
+
orange: '\x1b[38;5;214m',
|
|
184
|
+
blue: '\x1b[38;5;26m', //'\x1b[38;5;45m',
|
|
185
|
+
green: '\x1b[38;5;42m',
|
|
186
|
+
red: '\x1b[38;5;196m',
|
|
187
|
+
pink: '\x1b[38;5;212m',
|
|
188
|
+
purple: '\x1b[38;5;133m',
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const Reset = '\x1b[0m'
|
|
193
|
+
|
|
194
|
+
const Styles = {
|
|
195
|
+
|
|
196
|
+
color: {
|
|
197
|
+
text: Palette.text.black,
|
|
198
|
+
label: Palette.text.black,
|
|
199
|
+
placeholder: Palette.text.grey,
|
|
200
|
+
muted: Palette.text.grey,
|
|
201
|
+
success: Palette.text.green,
|
|
202
|
+
error: Palette.text.red,
|
|
203
|
+
info: Palette.text.blue,
|
|
204
|
+
border: Palette.text.grey,
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
symbol: {
|
|
208
|
+
carret: '►',
|
|
209
|
+
current: '○',
|
|
210
|
+
skipped: '○',
|
|
211
|
+
finished: '○',
|
|
212
|
+
bullet: '●',
|
|
213
|
+
radioOn: '●',
|
|
214
|
+
radioOff: '○',
|
|
215
|
+
checkboxOn: '■',
|
|
216
|
+
checkboxOff: '□',
|
|
217
|
+
step: '◆',
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
spinner: {
|
|
221
|
+
circleFill: '◐◑◒◓◔◕',
|
|
222
|
+
circleLine: '◜◝◞◟',
|
|
223
|
+
circle: '◌◯◉●◉◯◌',
|
|
224
|
+
diamond: '⬖⬗⬘⬙'
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
marker: {
|
|
228
|
+
current: `\n${Palette.text.blue}◆${Reset}`,
|
|
229
|
+
success: `\n${Palette.text.green}◆${Reset}`,
|
|
230
|
+
error: `\n${Palette.text.red}◆${Reset}`,
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
border: `\n${Palette.text.grey}│${Reset}`,
|
|
234
|
+
|
|
235
|
+
end: `\n${Palette.text.grey}└${Reset}`
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
const Theme = {
|
|
245
|
+
reset: '\x1b[0m',
|
|
246
|
+
accentColor: '',
|
|
247
|
+
neutralColor: '',
|
|
248
|
+
textColor: '',
|
|
249
|
+
placeholderColor: '\x1b[38;5;249m',
|
|
250
|
+
mutedColor: '',
|
|
251
|
+
borderColor: '',
|
|
252
|
+
infoColor: '',
|
|
253
|
+
successColor: '',
|
|
254
|
+
warningColor: '',
|
|
255
|
+
errorColor: '',
|
|
256
|
+
spinnerColor: 'rgb(0,0,0)',
|
|
257
|
+
// spinner: '◜◝◞◟',
|
|
258
|
+
spinner: '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏',
|
|
259
|
+
padding: {
|
|
260
|
+
top: 2,
|
|
261
|
+
right: 10,
|
|
262
|
+
bottom: 2,
|
|
263
|
+
left: 10,
|
|
264
|
+
},
|
|
265
|
+
carret: '►',
|
|
266
|
+
groupStart: '┌',
|
|
267
|
+
groupMarker: {
|
|
268
|
+
current: '◆',
|
|
269
|
+
success: '◆',
|
|
270
|
+
error: '◆',
|
|
271
|
+
},
|
|
272
|
+
groupBorder: '│',
|
|
273
|
+
groupEnd: '└',
|
|
274
|
+
frame: '│┌─┬┐├─┼┤└─┴┘',
|
|
275
|
+
checkbox: {
|
|
276
|
+
checked: '■',
|
|
277
|
+
unchecked: '□',
|
|
278
|
+
},
|
|
279
|
+
radio: {
|
|
280
|
+
selected: '●',
|
|
281
|
+
unselected: '○'
|
|
282
|
+
},
|
|
283
|
+
template: {}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
Theme.template.message = `\n${Theme.groupMarker.current} {{label}}\n${Theme.groupBorder}`
|
|
287
|
+
// Theme.template.message = `\n┌${''.padEnd(80, '─')}┐\n│ {{label | asciiFill(79)}}│\n└${''.padEnd(80, '─')}┘`
|
|
288
|
+
|
|
289
|
+
Theme.template.select = {
|
|
290
|
+
current: `\n${Theme.groupMarker.current} {{label}} {{filter}}\n${Theme.groupBorder} {{options}}\n${Theme.groupEnd}`,
|
|
291
|
+
finished: `\n${Theme.groupMarker.current} {{label}} {{filter}}\n${Theme.groupBorder} {{options}}\n${Theme.groupEnd}`,
|
|
292
|
+
option: {
|
|
293
|
+
selected: `\n${Theme.groupBorder} ► {{title}}`,
|
|
294
|
+
unselected: `\n${Theme.groupBorder} {{title}}`,
|
|
295
|
+
},
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
Theme.template.multiselect = {
|
|
299
|
+
current: `\n${Theme.groupMarker.current} {{label}} {{filter}}\n${Theme.groupBorder} {{options}}\n${Theme.groupEnd}`,
|
|
300
|
+
finished: `\n${Theme.groupMarker.current} {{label}} {{filter}}\n${Theme.groupBorder} {{options}}\n${Theme.groupEnd}`,
|
|
301
|
+
option: {
|
|
302
|
+
startCurrent: `\n${Theme.groupBorder} ►`,
|
|
303
|
+
start: `\n${Theme.groupBorder} `,
|
|
304
|
+
selected: ` [X] {{title}}`,
|
|
305
|
+
unselected: ` [ ] {{title}}`,
|
|
306
|
+
},
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
Theme.template.confirm = {
|
|
310
|
+
current: `\n${Theme.groupMarker.current} {{label}} \n${Theme.groupBorder}{{options}}\n${Theme.groupEnd}`,
|
|
311
|
+
finished: `\n${Theme.groupMarker.current} {{label}} \n${Theme.groupBorder}{{options}}\n${Theme.groupBorder}`,
|
|
312
|
+
option: {
|
|
313
|
+
selected: ` ● {{title}}`,
|
|
314
|
+
unselected: ` ○ {{title}}`
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
Theme.template.question = `{{if finished}}\n${Theme.groupMarker.current} {{label}} \n${Theme.groupBorder} {{value}}\n${Theme.groupBorder}{{else}}\n${Theme.groupMarker.current} {{label}} \n${Theme.groupBorder} {{if value}}{{value}}{{else}}\x1b[38;5;249m{{placeholder}}\x1b[0m{{endif}}\n${Theme.groupEnd}{{endif}}`
|
|
319
|
+
// Theme.template.question = `\n┌${''.padEnd(80, '─')}┐
|
|
320
|
+
// │ \x1b[1m{{label | asciiFill(79)}}\x1b[0m│
|
|
321
|
+
// ├${''.padEnd(80, '─')}┤
|
|
322
|
+
// {{if finished}}│ {{value | asciiFill(79)}}│{{else}}│ {{if value}}{{value | asciiFill(79)}}│{{else}}\x1b[38;5;249m{{placeholder | asciiFill(79)}}\x1b[0m│{{endif}}{{endif}}
|
|
323
|
+
// └${''.padEnd(80, '─')}┘`
|
|
324
|
+
Theme.template.error = `\n${Theme.groupMarker.current} ${Styles.color.error}[ ERROR ]${Reset} {{label}}\n${Theme.groupBorder}`
|
|
325
|
+
Theme.template.loader = `${Styles.marker.error} {{label}}\n${Theme.groupBorder}`
|
|
326
|
+
Theme.template.task = `\n${Theme.groupMarker.current} Running task... {{label}}\n${Theme.groupBorder}`
|
|
327
|
+
|
|
328
|
+
export default Theme
|