@scalar/api-client 0.2.0 → 0.2.1
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/dist/components/SimpleTable/SimpleCell.vue.d.ts.map +1 -1
- package/dist/components/SimpleTable/SimpleHeader.vue.d.ts.map +1 -1
- package/dist/components/SimpleTable/SimpleRow.vue.d.ts.map +1 -1
- package/dist/components/SimpleTable/SimpleTable.vue.d.ts.map +1 -1
- package/dist/fixtures/index.d.ts +1 -1
- package/dist/fixtures/index.d.ts.map +1 -1
- package/dist/index.js +37 -26
- package/package.json +6 -6
- package/src/components/ApiClient/AddressBar.vue +462 -0
- package/src/components/ApiClient/ApiClient.vue +266 -0
- package/src/components/ApiClient/Request/Request.vue +271 -0
- package/src/components/ApiClient/Request/RequestAuth.vue +221 -0
- package/src/components/ApiClient/Request/RequestBody.vue +39 -0
- package/src/components/ApiClient/Request/RequestHeaders.vue +24 -0
- package/src/components/ApiClient/Request/RequestQuery.vue +25 -0
- package/src/components/ApiClient/Request/RequestVariables.vue +25 -0
- package/src/components/ApiClient/Request/index.ts +1 -0
- package/src/components/ApiClient/RequestHistory.vue +114 -0
- package/src/components/ApiClient/RequestHistoryItem.vue +59 -0
- package/src/components/ApiClient/Response/Copilot.vue.bak +385 -0
- package/src/components/ApiClient/Response/Response.vue +120 -0
- package/src/components/ApiClient/Response/ResponseBody.vue +23 -0
- package/src/components/ApiClient/Response/ResponseHeaders.vue +52 -0
- package/src/components/ApiClient/Response/ResponseMetaInformation.vue +58 -0
- package/src/components/ApiClient/Response/index.ts +1 -0
- package/src/components/ApiClient/index.ts +1 -0
- package/src/components/CodeMirror/CodeMirror.vue +232 -0
- package/src/components/CodeMirror/extensions/variables.ts +41 -0
- package/src/components/CodeMirror/index.ts +1 -0
- package/src/components/CollapsibleSection/CollapsibleSection.vue +149 -0
- package/src/components/CollapsibleSection/index.ts +1 -0
- package/src/components/FlowModal.vue +133 -0
- package/src/components/Grid/Grid.vue +511 -0
- package/src/components/Grid/SimpleGrid.vue +33 -0
- package/src/components/Grid/index.ts +2 -0
- package/src/components/HelpfulLink.vue +19 -0
- package/src/components/SimpleTable/SimpleCell.vue +47 -0
- package/src/components/SimpleTable/SimpleHeader.vue +17 -0
- package/src/components/SimpleTable/SimpleRow.vue +14 -0
- package/src/components/SimpleTable/SimpleTable.vue +13 -0
- package/src/components/SimpleTable/index.ts +4 -0
- package/src/fixtures/httpHeaders.ts +530 -0
- package/src/fixtures/httpStatusCodes.ts +259 -0
- package/src/fixtures/index.ts +6 -0
- package/src/helpers/createPlaceholderRequest.ts +16 -0
- package/src/helpers/generateParameters.ts +19 -0
- package/src/helpers/generateRequest.ts +26 -0
- package/src/helpers/index.ts +5 -0
- package/src/helpers/mapFromArray.ts +16 -0
- package/src/helpers/sendRequest.ts +94 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useCopilot.ts +64 -0
- package/src/hooks/useOperation.test.ts +7 -0
- package/src/hooks/useOperation.ts +43 -0
- package/src/index.ts +9 -0
- package/src/stores/apiClientRequestStore.ts +103 -0
- package/src/stores/apiClientStore.ts +57 -0
- package/src/stores/index.ts +5 -0
- package/src/types.ts +181 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useKeyboardEvent } from '@scalar/use-keyboard-event'
|
|
3
|
+
import { useMediaQuery } from '@vueuse/core'
|
|
4
|
+
import TimeAgo from 'javascript-time-ago'
|
|
5
|
+
import en from 'javascript-time-ago/locale/en'
|
|
6
|
+
import { computed, ref } from 'vue'
|
|
7
|
+
|
|
8
|
+
import { sendRequest } from '../../helpers/sendRequest'
|
|
9
|
+
import { useApiClientRequestStore } from '../../stores/apiClientRequestStore'
|
|
10
|
+
import { CodeMirror } from '../CodeMirror'
|
|
11
|
+
import FlowModal, { useModalState } from '../FlowModal.vue'
|
|
12
|
+
import RequestHistory from './RequestHistory.vue'
|
|
13
|
+
|
|
14
|
+
const props = defineProps<{
|
|
15
|
+
proxyUrl: string
|
|
16
|
+
}>()
|
|
17
|
+
|
|
18
|
+
const emits = defineEmits<{
|
|
19
|
+
(event: 'onSend'): void
|
|
20
|
+
}>()
|
|
21
|
+
|
|
22
|
+
TimeAgo.addLocale(en)
|
|
23
|
+
const timeAgo = new TimeAgo('en-US')
|
|
24
|
+
|
|
25
|
+
const showHistory = ref(false)
|
|
26
|
+
const loading = ref(false)
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
activeRequest,
|
|
30
|
+
addRequestToHistory,
|
|
31
|
+
requestHistory,
|
|
32
|
+
requestHistoryOrder,
|
|
33
|
+
readOnly,
|
|
34
|
+
setActiveRequest,
|
|
35
|
+
} = useApiClientRequestStore()
|
|
36
|
+
|
|
37
|
+
const historyModal = useModalState()
|
|
38
|
+
|
|
39
|
+
// https://petstore3.swagger.io/api/v3
|
|
40
|
+
const url = computed(() => activeRequest.url)
|
|
41
|
+
// GET, POST …
|
|
42
|
+
const requestType = computed(() => activeRequest.type)
|
|
43
|
+
// /pet/{petId}
|
|
44
|
+
const requestPath = computed(() => activeRequest.path)
|
|
45
|
+
// true|false
|
|
46
|
+
const isSmallScreen = useMediaQuery('(max-width: 820px)')
|
|
47
|
+
|
|
48
|
+
// https://petstore3.swagger.io/api/v3/pet/{petId} -> /api/v3/pet/{petId}
|
|
49
|
+
function getShortUrl(longURL: string): string {
|
|
50
|
+
try {
|
|
51
|
+
const urlObject = new URL(longURL)
|
|
52
|
+
const { pathname } = urlObject
|
|
53
|
+
|
|
54
|
+
return pathname
|
|
55
|
+
} catch {
|
|
56
|
+
return longURL
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const formattedUrl = computed(() => {
|
|
61
|
+
const fullUrl = `${url.value}${requestPath.value}`
|
|
62
|
+
|
|
63
|
+
return isSmallScreen.value ? `...${getShortUrl(fullUrl)}` : fullUrl
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
async function send() {
|
|
67
|
+
loading.value = true
|
|
68
|
+
emits('onSend')
|
|
69
|
+
const result = await sendRequest(activeRequest, props.proxyUrl)
|
|
70
|
+
|
|
71
|
+
if (result) {
|
|
72
|
+
addRequestToHistory(result)
|
|
73
|
+
}
|
|
74
|
+
loading.value = false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const lastRequestTimestamp = computed(() => {
|
|
78
|
+
const lastRequestKey = requestHistoryOrder.value[0]
|
|
79
|
+
return requestHistory[lastRequestKey]
|
|
80
|
+
? timeAgo.format(requestHistory[lastRequestKey].sentTime)
|
|
81
|
+
: 'History'
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
useKeyboardEvent({
|
|
85
|
+
keyList: ['enter'],
|
|
86
|
+
withCtrlCmd: true,
|
|
87
|
+
handler: send,
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const onChange = (value: string) => {
|
|
91
|
+
if (activeRequest.url + activeRequest.path === value) {
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
setActiveRequest({ ...activeRequest, url: value })
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<template>
|
|
100
|
+
<div
|
|
101
|
+
class="scalar-api-client__address-bar"
|
|
102
|
+
:class="{ 'scalar-api-client__address-bar__on': showHistory }">
|
|
103
|
+
<div class="scalar-api-client__url-form">
|
|
104
|
+
<div class="scalar-api-client__field">
|
|
105
|
+
<div class="scalar-api-client__request-type">
|
|
106
|
+
<i :class="requestType.toLowerCase()" />
|
|
107
|
+
<span>{{ requestType }}</span>
|
|
108
|
+
</div>
|
|
109
|
+
<CodeMirror
|
|
110
|
+
class="scalar-api-client__url-input"
|
|
111
|
+
:content="formattedUrl"
|
|
112
|
+
:disableEnter="true"
|
|
113
|
+
:readOnly="readOnly"
|
|
114
|
+
:withVariables="true"
|
|
115
|
+
:withoutTheme="true"
|
|
116
|
+
@change="onChange" />
|
|
117
|
+
</div>
|
|
118
|
+
<button
|
|
119
|
+
class="scalar-api-client__send-request-button"
|
|
120
|
+
:class="[
|
|
121
|
+
{ 'scalar-api-client__send-request-button--loading': loading },
|
|
122
|
+
]"
|
|
123
|
+
type="submit"
|
|
124
|
+
@click="send">
|
|
125
|
+
<svg
|
|
126
|
+
fill="none"
|
|
127
|
+
height="48"
|
|
128
|
+
viewBox="0 0 14 14"
|
|
129
|
+
width="48"
|
|
130
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
131
|
+
<g id="send-email--mail-send-email-paper-airplane">
|
|
132
|
+
<path
|
|
133
|
+
id="Subtract"
|
|
134
|
+
clip-rule="evenodd"
|
|
135
|
+
d="M11.8215 0.0977331C12.1097 -0.0075178 12.422 -0.0287134 12.7219 0.0367172C13.0248 0.102803 13.3024 0.254481 13.5216 0.473719C13.7409 0.692957 13.8926 0.970537 13.9586 1.27346C14.0241 1.57338 14.0029 1.88566 13.8976 2.17389L10.3236 12.8859L10.3234 12.8866C10.2363 13.15 10.083 13.3867 9.87813 13.5739C9.67383 13.7606 9.42512 13.8917 9.15575 13.9549C8.88633 14.0206 8.60444 14.015 8.33777 13.9388C8.07134 13.8627 7.82929 13.7187 7.63532 13.5209L5.71798 11.6123L3.70392 12.6538C3.54687 12.735 3.3586 12.7272 3.20877 12.6333C3.05895 12.5395 2.96984 12.3734 2.97443 12.1967L3.057 9.01294L10.102 3.89553C10.3812 3.69267 10.4432 3.30182 10.2403 3.02255C10.0375 2.74327 9.64662 2.68133 9.36734 2.88419L2.20286 8.0884L0.473156 6.35869L0.473098 6.35864L0.472971 6.35851C0.285648 6.17132 0.147746 5.94054 0.0716498 5.68688C-0.00390565 5.43503 -0.016181 5.16847 0.0358684 4.91079C0.087985 4.62928 0.213827 4.36658 0.400607 4.14951C0.588668 3.93095 0.831681 3.76658 1.10453 3.67339L1.1079 3.67224L1.1079 3.67225L11.8215 0.0977331Z"
|
|
136
|
+
fill="currentColor"
|
|
137
|
+
fill-rule="evenodd"></path>
|
|
138
|
+
</g>
|
|
139
|
+
</svg>
|
|
140
|
+
<span>Send Request</span>
|
|
141
|
+
</button>
|
|
142
|
+
</div>
|
|
143
|
+
<div
|
|
144
|
+
class="scalar-api-client__address-bar__close"
|
|
145
|
+
@click="showHistory = false" />
|
|
146
|
+
<div class="scalar-api-client__address-bar__content">
|
|
147
|
+
<FlowModal
|
|
148
|
+
:state="historyModal"
|
|
149
|
+
title="Request History"
|
|
150
|
+
variant="large">
|
|
151
|
+
<RequestHistory
|
|
152
|
+
:showHistory="showHistory"
|
|
153
|
+
@toggle="showHistory = !showHistory" />
|
|
154
|
+
</FlowModal>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
<div
|
|
158
|
+
v-if="requestHistoryOrder.length"
|
|
159
|
+
class="scalar-api-client__history">
|
|
160
|
+
<div
|
|
161
|
+
class="scalar-api-client__history-toggle"
|
|
162
|
+
@click="historyModal.show()">
|
|
163
|
+
<svg
|
|
164
|
+
fill="none"
|
|
165
|
+
height="48"
|
|
166
|
+
viewBox="0 0 14 14"
|
|
167
|
+
width="48"
|
|
168
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
169
|
+
<g id="rewind-clock--back-return-clock-timer-countdown">
|
|
170
|
+
<path
|
|
171
|
+
id="Vector 1561 (Stroke)"
|
|
172
|
+
clip-rule="evenodd"
|
|
173
|
+
d="M6.99999 2.75C7.4142 2.75 7.74999 3.08579 7.74999 3.5V7.5C7.74999 7.76345 7.61177 8.00758 7.38586 8.14312L4.88586 9.64312C4.53068 9.85623 4.06998 9.74106 3.85687 9.38587C3.64376 9.03069 3.75893 8.56999 4.11412 8.35688L6.24999 7.07536V3.5C6.24999 3.08579 6.58578 2.75 6.99999 2.75Z"
|
|
174
|
+
fill="currentColor"
|
|
175
|
+
fill-rule="evenodd"></path>
|
|
176
|
+
<path
|
|
177
|
+
id="Union"
|
|
178
|
+
clip-rule="evenodd"
|
|
179
|
+
d="M12.5 7C12.5 3.96243 10.0376 1.5 7 1.5C5.24916 1.5 3.68853 2.31796 2.68066 3.59456L3.64645 4.56034C3.96143 4.87533 3.73835 5.4139 3.29289 5.4139H0.5C0.223857 5.4139 0 5.19004 0 4.9139V2.121C0 1.67555 0.53857 1.45247 0.853553 1.76745L1.61439 2.52829C2.89781 0.984301 4.83356 0 7 0C10.866 0 14 3.13401 14 7C14 10.866 10.866 14 7 14C3.68902 14 0.916591 11.702 0.187329 8.61473C0.0921059 8.21161 0.341704 7.80762 0.744824 7.7124C1.14794 7.61717 1.55193 7.86677 1.64715 8.26989C2.22013 10.6955 4.40025 12.5 7 12.5C10.0376 12.5 12.5 10.0376 12.5 7Z"
|
|
180
|
+
fill="currentColor"
|
|
181
|
+
fill-rule="evenodd"></path>
|
|
182
|
+
</g>
|
|
183
|
+
</svg>
|
|
184
|
+
<span>{{ lastRequestTimestamp }}</span>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
</template>
|
|
189
|
+
<style>
|
|
190
|
+
.scalar-api-client__address-bar {
|
|
191
|
+
width: 100%;
|
|
192
|
+
padding: 12px 12px 10px 12px;
|
|
193
|
+
display: flex;
|
|
194
|
+
align-items: center;
|
|
195
|
+
position: relative;
|
|
196
|
+
background: var(--theme-background-1);
|
|
197
|
+
}
|
|
198
|
+
.scalar-api-client__url-form {
|
|
199
|
+
display: flex;
|
|
200
|
+
width: 100%;
|
|
201
|
+
align-items: stretch;
|
|
202
|
+
border-radius: var(--theme-radius-lg);
|
|
203
|
+
}
|
|
204
|
+
.scalar-api-client__field {
|
|
205
|
+
border: 1px solid var(--theme-border-color);
|
|
206
|
+
border-right: 0;
|
|
207
|
+
border-radius: var(--theme-radius-lg) 0 0 var(--theme-radius-lg);
|
|
208
|
+
display: flex;
|
|
209
|
+
align-items: stretch;
|
|
210
|
+
width: 100%;
|
|
211
|
+
}
|
|
212
|
+
.scalar-api-client__address-bar-data {
|
|
213
|
+
width: 100%;
|
|
214
|
+
}
|
|
215
|
+
.scalar-api-client__address-bar-data-meta {
|
|
216
|
+
display: flex;
|
|
217
|
+
margin-top: 5px;
|
|
218
|
+
}
|
|
219
|
+
.scalar-api-client__request-type {
|
|
220
|
+
display: flex;
|
|
221
|
+
align-items: center;
|
|
222
|
+
background: var(--theme-background-2);
|
|
223
|
+
color: var(--theme-color-disabled);
|
|
224
|
+
appearance: none;
|
|
225
|
+
-webkit-appearance: none;
|
|
226
|
+
padding: 0 12px;
|
|
227
|
+
border-right: 1px solid var(--theme-border-color);
|
|
228
|
+
border-radius: var(--theme-radius-lg) 0 0 var(--theme-radius-lg);
|
|
229
|
+
position: relative;
|
|
230
|
+
}
|
|
231
|
+
.scalar-api-client__request-type span {
|
|
232
|
+
font-family: var(--theme-font-code);
|
|
233
|
+
font-size: 500;
|
|
234
|
+
font-size: 12px;
|
|
235
|
+
text-transform: uppercase;
|
|
236
|
+
}
|
|
237
|
+
.scalar-api-client__request-type svg {
|
|
238
|
+
margin-left: 6px;
|
|
239
|
+
width: 8px;
|
|
240
|
+
}
|
|
241
|
+
.scalar-api-client__request-type i {
|
|
242
|
+
width: 10px;
|
|
243
|
+
height: 10px;
|
|
244
|
+
border-radius: 50%;
|
|
245
|
+
margin-right: 6px;
|
|
246
|
+
text-align: center;
|
|
247
|
+
line-height: 18px;
|
|
248
|
+
font-style: normal;
|
|
249
|
+
flex-shrink: 0;
|
|
250
|
+
display: inline-block;
|
|
251
|
+
color: var(--theme-color-disabled);
|
|
252
|
+
background: var(--scalar-api-client-color);
|
|
253
|
+
}
|
|
254
|
+
.meta-request-break {
|
|
255
|
+
margin: 0 5px;
|
|
256
|
+
}
|
|
257
|
+
.scalar-api-client__history {
|
|
258
|
+
appearance: none;
|
|
259
|
+
-webkit-appearance: none;
|
|
260
|
+
background: transparent;
|
|
261
|
+
color: var(--theme-color-2);
|
|
262
|
+
display: flex;
|
|
263
|
+
align-items: center;
|
|
264
|
+
border-radius: var(--theme-radius-lg);
|
|
265
|
+
height: 100%;
|
|
266
|
+
}
|
|
267
|
+
.scalar-api-client__send-request-button[type='submit'] {
|
|
268
|
+
font-size: var(--theme-mini);
|
|
269
|
+
letter-spacing: 0.25px;
|
|
270
|
+
line-height: 30px;
|
|
271
|
+
font-weight: var(--theme-semibold);
|
|
272
|
+
color: white;
|
|
273
|
+
border: none;
|
|
274
|
+
white-space: nowrap;
|
|
275
|
+
padding: 0 10px;
|
|
276
|
+
text-transform: uppercase;
|
|
277
|
+
cursor: pointer;
|
|
278
|
+
outline: none;
|
|
279
|
+
border-radius: 0 var(--theme-radius-lg) var(--theme-radius-lg) 0;
|
|
280
|
+
background: var(--scalar-api-client-color);
|
|
281
|
+
/** #087f5b */
|
|
282
|
+
display: flex;
|
|
283
|
+
align-items: center;
|
|
284
|
+
}
|
|
285
|
+
.scalar-api-client__send-request-button svg {
|
|
286
|
+
width: 12px;
|
|
287
|
+
height: 12px;
|
|
288
|
+
margin-right: 6px;
|
|
289
|
+
}
|
|
290
|
+
.scalar-api-client__send-request-button--loading {
|
|
291
|
+
font-size: 0;
|
|
292
|
+
display: flex;
|
|
293
|
+
align-items: center;
|
|
294
|
+
justify-content: center;
|
|
295
|
+
min-width: 127px;
|
|
296
|
+
}
|
|
297
|
+
.scalar-api-client__send-request-button--loading svg {
|
|
298
|
+
display: none;
|
|
299
|
+
}
|
|
300
|
+
.scalar-api-client__send-request-button--loading:before {
|
|
301
|
+
content: '';
|
|
302
|
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
|
303
|
+
border-top: 1px solid white;
|
|
304
|
+
animation: urlloader 0.45s linear infinite;
|
|
305
|
+
background: transparent;
|
|
306
|
+
width: 14px;
|
|
307
|
+
height: 14px;
|
|
308
|
+
margin-left: 0;
|
|
309
|
+
margin-right: 9px;
|
|
310
|
+
border-radius: 50%;
|
|
311
|
+
}
|
|
312
|
+
.scalar-api-client__send-request-button--loading:after {
|
|
313
|
+
content: 'Loading';
|
|
314
|
+
font-size: 12px;
|
|
315
|
+
}
|
|
316
|
+
@keyframes urlloader {
|
|
317
|
+
0% {
|
|
318
|
+
transform: rotate(0deg);
|
|
319
|
+
}
|
|
320
|
+
to {
|
|
321
|
+
transform: rotate(1turn);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
.scalar-api-client__history-toggle {
|
|
325
|
+
padding: 0 9px;
|
|
326
|
+
line-height: 30px;
|
|
327
|
+
color: var(--theme-color-disabled);
|
|
328
|
+
font-size: var(--theme-mini);
|
|
329
|
+
letter-spacing: 0.125px;
|
|
330
|
+
font-weight: var(--theme-semibold);
|
|
331
|
+
text-transform: uppercase;
|
|
332
|
+
height: 100%;
|
|
333
|
+
display: flex;
|
|
334
|
+
align-items: center;
|
|
335
|
+
cursor: pointer;
|
|
336
|
+
white-space: nowrap;
|
|
337
|
+
border: 1px solid var(--theme-border-color);
|
|
338
|
+
margin-left: 12px;
|
|
339
|
+
border-radius: var(--theme-radius-lg);
|
|
340
|
+
}
|
|
341
|
+
.scalar-api-client__history-toggle:hover {
|
|
342
|
+
background: var(--theme-background-2);
|
|
343
|
+
}
|
|
344
|
+
.scalar-api-client__history-toggle svg {
|
|
345
|
+
height: 13px;
|
|
346
|
+
width: 13px;
|
|
347
|
+
margin-right: 6px;
|
|
348
|
+
color: var(--theme-color-disabled);
|
|
349
|
+
}
|
|
350
|
+
.scalar-api-client__address-bar-close {
|
|
351
|
+
fill: var(--theme-color-disabled);
|
|
352
|
+
margin-left: 12px;
|
|
353
|
+
height: 24px;
|
|
354
|
+
}
|
|
355
|
+
.scalar-api-client__address-bar-close:hover {
|
|
356
|
+
cursor: pointer;
|
|
357
|
+
fill: var(--theme-color-1);
|
|
358
|
+
}
|
|
359
|
+
.scalar-api-client__address-bar__content {
|
|
360
|
+
width: 640px;
|
|
361
|
+
height: 100%;
|
|
362
|
+
background: var(--theme-background-1);
|
|
363
|
+
position: fixed;
|
|
364
|
+
top: 0;
|
|
365
|
+
right: 0;
|
|
366
|
+
z-index: 1000;
|
|
367
|
+
transform: translate3d(640px, 0, 0);
|
|
368
|
+
opacity: 0;
|
|
369
|
+
transition: transform 0.5s cubic-bezier(0.77, 0, 0.175, 1),
|
|
370
|
+
opacity 0.01s ease-in-out 0.5s;
|
|
371
|
+
pointer-events: none;
|
|
372
|
+
}
|
|
373
|
+
.scalar-api-client__address-bar-content-item {
|
|
374
|
+
height: 100vh;
|
|
375
|
+
max-height: 100vh;
|
|
376
|
+
overflow: auto;
|
|
377
|
+
}
|
|
378
|
+
.scalar-api-client__address-bar__on {
|
|
379
|
+
z-index: 100000;
|
|
380
|
+
}
|
|
381
|
+
.scalar-api-client__address-bar__on .scalar-api-client__address-bar__content {
|
|
382
|
+
transform: translate3d(0, 0, 0);
|
|
383
|
+
opacity: 1;
|
|
384
|
+
pointer-events: all;
|
|
385
|
+
transition: transform 0.5s cubic-bezier(0.77, 0, 0.175, 1);
|
|
386
|
+
}
|
|
387
|
+
.scalar-api-client__address-bar__on .scalar-api-client__address-bar__close {
|
|
388
|
+
opacity: 1;
|
|
389
|
+
pointer-events: all;
|
|
390
|
+
cursor: pointer;
|
|
391
|
+
}
|
|
392
|
+
.scalar-api-client__address-bar .navtable-item__active {
|
|
393
|
+
background: var(--theme-background-2);
|
|
394
|
+
cursor: default;
|
|
395
|
+
}
|
|
396
|
+
.scalar-api-client__address-bar .navtable-item__active .radio:before {
|
|
397
|
+
display: none;
|
|
398
|
+
}
|
|
399
|
+
.navigation-back {
|
|
400
|
+
stroke: var(--theme-color-2);
|
|
401
|
+
cursor: pointer;
|
|
402
|
+
}
|
|
403
|
+
.navigation-back:hover {
|
|
404
|
+
stroke: var(--theme-color-1);
|
|
405
|
+
}
|
|
406
|
+
.scalar-api-client__address-bar__close {
|
|
407
|
+
width: 100%;
|
|
408
|
+
height: 100%;
|
|
409
|
+
position: fixed;
|
|
410
|
+
top: 0;
|
|
411
|
+
left: 0;
|
|
412
|
+
/* background: rgba(0,0,0,.55);
|
|
413
|
+
*/
|
|
414
|
+
pointer-events: none;
|
|
415
|
+
opacity: 0;
|
|
416
|
+
transition: all 0.1s ease-in-out;
|
|
417
|
+
z-index: 1000;
|
|
418
|
+
}
|
|
419
|
+
.navtable-item-request span {
|
|
420
|
+
padding: 8px 9px 8px 0;
|
|
421
|
+
border: none;
|
|
422
|
+
outline: none;
|
|
423
|
+
font-size: 12px;
|
|
424
|
+
color: var(--theme-color-1);
|
|
425
|
+
width: 100%;
|
|
426
|
+
display: block;
|
|
427
|
+
overflow: hidden;
|
|
428
|
+
white-space: nowrap;
|
|
429
|
+
text-overflow: ellipsis;
|
|
430
|
+
}
|
|
431
|
+
.navtable-item-request span em {
|
|
432
|
+
text-transform: uppercase;
|
|
433
|
+
font-style: normal;
|
|
434
|
+
font-family: var(--theme-font-code);
|
|
435
|
+
font-size: 11px;
|
|
436
|
+
margin-right: 6px;
|
|
437
|
+
font-weight: var(--theme-bold);
|
|
438
|
+
color: var(--theme-color-disabled);
|
|
439
|
+
}
|
|
440
|
+
.navtable-item-time {
|
|
441
|
+
font-size: 12px;
|
|
442
|
+
color: var(--theme-color-1);
|
|
443
|
+
text-transform: capitalize;
|
|
444
|
+
padding: 0 9px;
|
|
445
|
+
}
|
|
446
|
+
@media screen and (max-width: 720px) {
|
|
447
|
+
.scalar-api-client__history-toggle span,
|
|
448
|
+
.scalar-api-client__send-request-button span {
|
|
449
|
+
display: none;
|
|
450
|
+
}
|
|
451
|
+
.scalar-api-client__history-toggle svg,
|
|
452
|
+
.scalar-api-client__send-request-button svg {
|
|
453
|
+
margin-right: 0;
|
|
454
|
+
}
|
|
455
|
+
.scalar-api-client__history-toggle,
|
|
456
|
+
.scalar-api-client__send-request-button {
|
|
457
|
+
height: 31.5px;
|
|
458
|
+
width: 31.5px;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
</style>
|
|
462
|
+
../../../../use-keyboard-event/src
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Tab, TabGroup, TabList, TabPanel, TabPanels } from '@headlessui/vue'
|
|
3
|
+
import { useKeyboardEvent } from '@scalar/use-keyboard-event'
|
|
4
|
+
import { useMediaQuery } from '@vueuse/core'
|
|
5
|
+
import { ref } from 'vue'
|
|
6
|
+
|
|
7
|
+
import { useApiClientRequestStore } from '../../stores'
|
|
8
|
+
import AdressBar from './AddressBar.vue'
|
|
9
|
+
import { Request } from './Request'
|
|
10
|
+
import { Response } from './Response'
|
|
11
|
+
|
|
12
|
+
defineProps<{
|
|
13
|
+
proxyUrl: string
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
const emit = defineEmits<{
|
|
17
|
+
(e: 'escapeKeyPress'): void
|
|
18
|
+
}>()
|
|
19
|
+
|
|
20
|
+
const { activeRequest } = useApiClientRequestStore()
|
|
21
|
+
|
|
22
|
+
const isSmallScreen = useMediaQuery('(max-width: 820px)')
|
|
23
|
+
|
|
24
|
+
const selectedTab = ref(0)
|
|
25
|
+
|
|
26
|
+
const Tabs = {
|
|
27
|
+
Request: 0,
|
|
28
|
+
Response: 1,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function changeTab(index: number) {
|
|
32
|
+
selectedTab.value = index
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
useKeyboardEvent({
|
|
36
|
+
keyList: ['escape'],
|
|
37
|
+
handler: () => emit('escapeKeyPress'),
|
|
38
|
+
})
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<div
|
|
43
|
+
class="scalar-api-client"
|
|
44
|
+
:class="`scalar-api-client--${activeRequest.type.toLowerCase() || 'get'}`"
|
|
45
|
+
@keydown.esc="emit('escapeKeyPress')">
|
|
46
|
+
<AdressBar
|
|
47
|
+
:proxyUrl="proxyUrl"
|
|
48
|
+
@onSend="changeTab(Tabs.Response)" />
|
|
49
|
+
<div class="scalar-api-client__main">
|
|
50
|
+
<!-- Desktop-->
|
|
51
|
+
<template v-if="!isSmallScreen">
|
|
52
|
+
<Request />
|
|
53
|
+
<Response />
|
|
54
|
+
</template>
|
|
55
|
+
<!-- Mobile-->
|
|
56
|
+
<template v-else>
|
|
57
|
+
<TabGroup
|
|
58
|
+
:selectedIndex="selectedTab"
|
|
59
|
+
@change="changeTab">
|
|
60
|
+
<TabList class="scalar-api-client__mobile-navigation">
|
|
61
|
+
<Tab
|
|
62
|
+
v-slot="{ selected }"
|
|
63
|
+
class="scalar-api-client__mobile-navigation__toggle">
|
|
64
|
+
<button
|
|
65
|
+
:class="{
|
|
66
|
+
'scalar-api-client__mobile-navigation--active': selected,
|
|
67
|
+
}"
|
|
68
|
+
type="button">
|
|
69
|
+
Request
|
|
70
|
+
</button>
|
|
71
|
+
</Tab>
|
|
72
|
+
<Tab
|
|
73
|
+
v-slot="{ selected }"
|
|
74
|
+
class="scalar-api-client__mobile-navigation__toggle">
|
|
75
|
+
<button
|
|
76
|
+
:class="{
|
|
77
|
+
'scalar-api-client__mobile-navigation--active': selected,
|
|
78
|
+
}"
|
|
79
|
+
type="button">
|
|
80
|
+
Response
|
|
81
|
+
</button>
|
|
82
|
+
</Tab>
|
|
83
|
+
</TabList>
|
|
84
|
+
<TabPanels>
|
|
85
|
+
<TabPanel>
|
|
86
|
+
<Request />
|
|
87
|
+
</TabPanel>
|
|
88
|
+
<TabPanel>
|
|
89
|
+
<Response />
|
|
90
|
+
</TabPanel>
|
|
91
|
+
</TabPanels>
|
|
92
|
+
</TabGroup>
|
|
93
|
+
</template>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<style src="../../../../theme/theme.css"></style>
|
|
99
|
+
|
|
100
|
+
<style>
|
|
101
|
+
.scalar-api-client {
|
|
102
|
+
background: var(--theme-background-1);
|
|
103
|
+
position: relative;
|
|
104
|
+
height: 100%;
|
|
105
|
+
overflow: hidden !important;
|
|
106
|
+
display: flex;
|
|
107
|
+
flex-direction: column;
|
|
108
|
+
font-family: var(--theme-font);
|
|
109
|
+
}
|
|
110
|
+
@media screen and (max-width: 1000px) {
|
|
111
|
+
.scalar-api-client {
|
|
112
|
+
width: 100%;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
.scalar-api-client pre {
|
|
116
|
+
font-family: var(--theme-font-code);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.scalar-api-client--post {
|
|
120
|
+
--scalar-api-client-color: var(--theme-post-color);
|
|
121
|
+
--scalar-api-client-background: var(--theme-post-background);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.scalar-api-client--delete {
|
|
125
|
+
--scalar-api-client-color: var(--theme-delete-color);
|
|
126
|
+
--scalar-api-client-background: var(--theme-delete-background);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.scalar-api-client--patch {
|
|
130
|
+
--scalar-api-client-color: var(--theme-patch-color);
|
|
131
|
+
--scalar-api-client-background: var(--theme-patch-background);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.scalar-api-client--get {
|
|
135
|
+
--scalar-api-client-color: var(--theme-get-color);
|
|
136
|
+
--scalar-api-client-background: var(--theme-get-background);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.scalar-api-client--put {
|
|
140
|
+
--scalar-api-client-color: var(--theme-put-color);
|
|
141
|
+
--scalar-api-client-background: var(--theme-put-background);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.scalar-api-client__mobile-navigation {
|
|
145
|
+
padding: 12px 12px 0 12px;
|
|
146
|
+
display: flex;
|
|
147
|
+
font-size: var(--theme-small);
|
|
148
|
+
color: var(--theme-color-2);
|
|
149
|
+
font-weight: var(--theme-bold);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.scalar-api-client__mobile-navigation__toggle {
|
|
153
|
+
appearance: none;
|
|
154
|
+
margin-right: 9px;
|
|
155
|
+
cursor: pointer;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.scalar-api-client__mobile-navigation--active {
|
|
159
|
+
color: var(--theme-color-1);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.scalar-api-client__mobile-navigation--active:hover {
|
|
163
|
+
cursor: pointer;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.scalar-api-client__main {
|
|
167
|
+
display: flex;
|
|
168
|
+
height: 100%;
|
|
169
|
+
min-height: 0;
|
|
170
|
+
background: var(--theme-background-1);
|
|
171
|
+
border-top: 1px solid var(--theme-border-color);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@media screen and (max-width: 820px) {
|
|
175
|
+
.scalar-api-client__main {
|
|
176
|
+
display: block;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** TODO: Consider to make a Column component */
|
|
181
|
+
.scalar-api-client__main__content {
|
|
182
|
+
padding: 12px;
|
|
183
|
+
background: var(--theme-background-1);
|
|
184
|
+
top: 0;
|
|
185
|
+
position: sticky;
|
|
186
|
+
z-index: 100;
|
|
187
|
+
}
|
|
188
|
+
.scalar-api-client__main__content label {
|
|
189
|
+
font-size: var(--theme-small);
|
|
190
|
+
color: var(--theme-color-1);
|
|
191
|
+
font-weight: var(--theme-bold);
|
|
192
|
+
display: flex;
|
|
193
|
+
align-items: center;
|
|
194
|
+
}
|
|
195
|
+
@media screen and (max-width: 820px) {
|
|
196
|
+
.scalar-api-client__main__content {
|
|
197
|
+
padding: 0 0 12px 0;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.scalar-api-client__main__content label {
|
|
201
|
+
display: none;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.meta {
|
|
206
|
+
display: flex;
|
|
207
|
+
font-size: var(--theme-font-size-2);
|
|
208
|
+
font-weight: var(--theme-font-size-2);
|
|
209
|
+
color: var(--scalar-api-client-color2);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.meta-item svg {
|
|
213
|
+
fill: var(--theme-color-ghost);
|
|
214
|
+
height: 14px;
|
|
215
|
+
width: 14px;
|
|
216
|
+
margin-right: 6px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.meta-item {
|
|
220
|
+
display: flex;
|
|
221
|
+
align-items: center;
|
|
222
|
+
margin-right: 12px;
|
|
223
|
+
white-space: nowrap;
|
|
224
|
+
font-weight: var(--theme-bold);
|
|
225
|
+
font-size: 12px;
|
|
226
|
+
color: var(--theme-color-disabled);
|
|
227
|
+
padding: 3px 0;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.meta-item__input {
|
|
231
|
+
padding: 3px 0;
|
|
232
|
+
background: transparent;
|
|
233
|
+
width: 100%;
|
|
234
|
+
margin-right: 0;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.types {
|
|
238
|
+
margin: auto;
|
|
239
|
+
width: 580px;
|
|
240
|
+
display: flex;
|
|
241
|
+
align-items: center;
|
|
242
|
+
justify-content: center;
|
|
243
|
+
flex-flow: wrap;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.types-heading {
|
|
247
|
+
width: 100%;
|
|
248
|
+
text-align: center;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.types-heading b {
|
|
252
|
+
font-size: 42px;
|
|
253
|
+
}
|
|
254
|
+
.types-heading p {
|
|
255
|
+
margin-bottom: 20px;
|
|
256
|
+
margin-top: 12px;
|
|
257
|
+
font-size: 24px;
|
|
258
|
+
}
|
|
259
|
+
.scalar-api-client__empty-state {
|
|
260
|
+
border: 1px dashed var(--theme-border-color);
|
|
261
|
+
width: 100%;
|
|
262
|
+
text-align: center;
|
|
263
|
+
font-size: var(--theme-small);
|
|
264
|
+
padding: 20px;
|
|
265
|
+
}
|
|
266
|
+
</style>
|