3
3
<!-- Query -->
4
4
<div
5
5
v-show =" shouldShowQuery"
6
- :class =" {
7
- 'vue-command__query': !invert,
8
- 'vue-command__query--invert': invert
9
- }" >
10
- <span
11
- v-if =" !hidePrompt"
12
- :class =" {
13
- 'vue-command__query__prompt': !invert,
14
- 'vue-command__query__prompt--invert': invert
15
- }" >
16
- {{ local.prompt }}
17
- </span >
18
-
19
- <!-- TODO Make textarea to enforce word break -->
6
+ class =" vue-command__query" >
7
+ <!-- Prompt -->
8
+ <VueCommandPrompt />
9
+
10
+ <!-- Query -->
11
+ <!-- TODO Convert to textarea to enforce word breaks -->
20
12
<input
21
13
ref =" queryRef"
22
14
v-model =" local.query"
23
- :class =" {
24
- 'vue-command__query__input': !invert,
25
- 'vue-command__query__input--invert': invert
26
- }"
15
+ class =" vue-command__query__input"
27
16
:disabled =" isOutdatedQuery"
28
17
:placeholder =" placeholder"
29
18
autocapitalize =" none"
43
32
v-for =" (multilineQuery, index) in multilineQueries"
44
33
v-show =" isBeforeReverseISearch(index)"
45
34
:key =" index"
46
- :class =" {
47
- 'vue-command__multiline-query': !invert,
48
- 'vue-command__multiline-query--invert': invert
49
- }" >
35
+ class =" vue-command__multiline-query" >
50
36
<span
51
- :class =" {
52
- 'vue-command__multiline-query__prompt': !invert,
53
- 'vue-command__multiline-query__prompt--invert': invert
54
- }" >></span >
37
+ class =" vue-command__multiline-query__prompt" >></span >
55
38
<input
56
39
ref =" multilineQueryRefs"
57
- :class =" {
58
- 'vue-command__multiline-query__input': !invert,
59
- 'vue-command__multiline-query__input--invert': invert
60
- }"
40
+ class =" vue-command__multiline-query__input"
61
41
:disabled =" isOutdatedMultilineQuery(index)"
62
42
:value =" multilineQuery"
63
43
autocapitalize =" none"
75
55
<!-- Reverse I search -->
76
56
<div
77
57
v-if =" isReverseISearch"
78
- :class =" {
79
- 'vue-command__reverse-i-search': !invert,
80
- 'vue-command__reverse-i-search--invert': invert
81
- }" >
58
+ class =" vue-command__reverse-i-search" >
82
59
<span
83
- :class =" {
84
- 'vue-command__reverse-i-search-status': !invert,
85
- 'vue-command__reverse-i-search-status--invert': invert
86
- }" >({{ reverseISearchStatus }})`</span ><input
60
+ class =" vue-command__reverse-i-search-status" >({{ reverseISearchStatus }})`</span ><input
87
61
ref =" reverseISearchRef"
88
62
v-model =" reverseISearch"
89
- :class =" {
90
- 'vue-command__reverse-i-search__input': !invert,
91
- 'vue-command__reverse-i-search__input--invert': invert
92
- }"
63
+ class =" vue-command__reverse-i-search__input"
93
64
:disabled =" isOutdated"
94
65
autocapitalize =" none"
95
66
autocorrect =" off"
@@ -116,7 +87,9 @@ import {
116
87
onBeforeUnmount ,
117
88
reactive ,
118
89
nextTick ,
119
- computed
90
+ computed ,
91
+ Fragment ,
92
+ h
120
93
} from ' vue'
121
94
import {
122
95
and ,
@@ -140,13 +113,13 @@ import {
140
113
set ,
141
114
trimStart ,
142
115
lt ,
143
- join
116
+ join ,
117
+ isUndefined
144
118
} from ' lodash'
145
119
146
120
const appendToHistory = inject (' appendToHistory' )
147
121
const dispatch = inject (' dispatch' )
148
122
const hidePrompt = inject (' hidePrompt' )
149
- const invert = inject (' invert' )
150
123
const helpText = inject (' helpText' )
151
124
const helpTimeout = inject (' helpTimeout' )
152
125
const optionsResolver = inject (' optionsResolver' )
@@ -156,6 +129,7 @@ const setCursorPosition = inject('setCursorPosition')
156
129
const setQuery = inject (' setQuery' )
157
130
const showHelp = inject (' showHelp' )
158
131
const signals = inject (' signals' )
132
+ const slots = inject (' slots' )
159
133
const terminal = inject (' terminal' )
160
134
161
135
// Indicates if the query, including multiline queries and reverse I search, is
@@ -169,6 +143,23 @@ const reverseISearchRef = ref(null)
169
143
const reverseISearchStatus = ref (' reverse-i-search' )
170
144
const queryRef = ref (null )
171
145
146
+ // Prompt slot with fallback
147
+ const VueCommandPrompt = computed (() => {
148
+ if (hidePrompt) {
149
+ return h (Fragment)
150
+ }
151
+
152
+ // Render prompt slot if given
153
+ if (! isUndefined (slots .prompt )) {
154
+ return h (Fragment, slots .prompt ())
155
+ }
156
+
157
+ // Show default prompt slot
158
+ return h (Fragment, h (' span' , {
159
+ class: ' vue-command__query__prompt'
160
+ }, terminal .value .prompt ))
161
+ })
162
+
172
163
const local = reactive ({
173
164
prompt: terminal .value .prompt ,
174
165
query: ' '
0 commit comments