@scalar/pre-post-request-scripts 0.3.9 → 0.3.11
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/CHANGELOG.md +8 -0
- package/dist/PostResponseScripts-CrM65oAM.js +202 -0
- package/dist/PostResponseScripts-CrM65oAM.js.map +1 -0
- package/dist/TestResults-DIM8u91u.js +224 -0
- package/dist/TestResults-DIM8u91u.js.map +1 -0
- package/dist/ViewLayoutCollapse-BMrPz_sj.js +96 -0
- package/dist/ViewLayoutCollapse-BMrPz_sj.js.map +1 -0
- package/dist/components/ViewLayout/index.d.ts +1 -1
- package/dist/execute-scripts-BV13zq7B.js +125 -0
- package/dist/execute-scripts-BV13zq7B.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -7
- package/dist/libs/execute-scripts/index.d.ts +1 -1
- package/dist/libs/execute-scripts/index.js +2 -4
- package/dist/libs/execute-scripts/postman-sandbox-adapter.d.ts +2 -2
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.d.ts +1 -1
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.js +2 -4
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.d.ts +1 -1
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.d.ts +1 -1
- package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.d.ts +1 -1
- package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.d.ts +1 -1
- package/dist/plugins/post-response-scripts/components/TestResults/index.d.ts +1 -1
- package/dist/plugins/post-response-scripts/components/TestResults/index.js +2 -4
- package/dist/plugins/post-response-scripts/index.d.ts +1 -1
- package/dist/plugins/post-response-scripts/index.js +3 -4
- package/dist/post-response-scripts-ikk1wrl9.js +61 -0
- package/dist/post-response-scripts-ikk1wrl9.js.map +1 -0
- package/dist/style.css +64 -1
- package/package.json +8 -12
- package/dist/_virtual/_plugin-vue_export-helper.js +0 -9
- package/dist/components/ViewLayout/ValueEmitter.vue.js +0 -21
- package/dist/components/ViewLayout/ValueEmitter.vue2.js +0 -4
- package/dist/components/ViewLayout/ViewLayoutCollapse.vue.js +0 -89
- package/dist/components/ViewLayout/ViewLayoutCollapse.vue2.js +0 -4
- package/dist/consts/example-scripts.js +0 -88
- package/dist/libs/execute-scripts/context/console.js +0 -12
- package/dist/libs/execute-scripts/execute-post-response-script.js +0 -13
- package/dist/libs/execute-scripts/postman-sandbox-adapter.js +0 -88
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.js +0 -32
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue2.js +0 -4
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.js +0 -53
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue2.js +0 -4
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.js +0 -7
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue2.js +0 -33
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.js +0 -48
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue2.js +0 -4
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.js +0 -34
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue2.js +0 -4
- package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.js +0 -68
- package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue2.js +0 -4
- package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.js +0 -32
- package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue2.js +0 -4
- package/dist/plugins/post-response-scripts/post-response-scripts-plugin.js +0 -65
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { t as ViewLayoutCollapse_default } from "./ViewLayoutCollapse-BMrPz_sj.js";
|
|
2
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, ref, renderList, toDisplayString, toRef, unref, withCtx } from "vue";
|
|
3
|
+
import { javascript } from "@codemirror/lang-javascript";
|
|
4
|
+
import { useCodeMirror } from "@scalar/use-codemirror";
|
|
5
|
+
//#region src/consts/example-scripts.ts
|
|
6
|
+
var EXAMPLE_SCRIPTS = [
|
|
7
|
+
{
|
|
8
|
+
title: "Check the status code",
|
|
9
|
+
script: `pm.test("Status code is 200", () => {
|
|
10
|
+
pm.response.to.have.status(200)
|
|
11
|
+
})`,
|
|
12
|
+
mockResponse: {
|
|
13
|
+
status: 200,
|
|
14
|
+
body: { success: true }
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
title: "Check JSON response",
|
|
19
|
+
script: `pm.test("Response is valid JSON", () => {
|
|
20
|
+
const responseData = pm.response.json()
|
|
21
|
+
pm.expect(responseData).to.be.an('object')
|
|
22
|
+
})`,
|
|
23
|
+
mockResponse: {
|
|
24
|
+
status: 200,
|
|
25
|
+
body: { data: "test" },
|
|
26
|
+
headers: { "Content-Type": "application/json" }
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
title: "Check response headers",
|
|
31
|
+
script: `pm.test("Content-Type header is present", () => {
|
|
32
|
+
pm.response.to.have.header('Content-Type')
|
|
33
|
+
})`,
|
|
34
|
+
mockResponse: {
|
|
35
|
+
status: 200,
|
|
36
|
+
body: { success: true },
|
|
37
|
+
headers: { "Content-Type": "application/json" }
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
title: "Validate JSON schema",
|
|
42
|
+
script: `pm.test("Response matches schema", () => {
|
|
43
|
+
const schema = {
|
|
44
|
+
type: 'object',
|
|
45
|
+
required: ['id', 'name'],
|
|
46
|
+
properties: {
|
|
47
|
+
id: { type: 'number' },
|
|
48
|
+
name: { type: 'string' }
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
pm.response.to.have.jsonSchema(schema)
|
|
52
|
+
})`,
|
|
53
|
+
mockResponse: {
|
|
54
|
+
status: 200,
|
|
55
|
+
body: {
|
|
56
|
+
id: 1,
|
|
57
|
+
name: "Test Item"
|
|
58
|
+
},
|
|
59
|
+
headers: { "Content-Type": "application/json" }
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
title: "Check response body",
|
|
64
|
+
script: `pm.test("Response body contains string", () => {
|
|
65
|
+
pm.expect(pm.response.text()).to.include('success')
|
|
66
|
+
})`,
|
|
67
|
+
mockResponse: {
|
|
68
|
+
status: 200,
|
|
69
|
+
body: "This is a successful response"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
title: "Successful POST request",
|
|
74
|
+
script: `pm.test("Successful POST request", () => {
|
|
75
|
+
pm.expect(pm.response.code).to.be.oneOf([201, 202])
|
|
76
|
+
})`,
|
|
77
|
+
mockResponse: {
|
|
78
|
+
status: 201,
|
|
79
|
+
body: { success: true }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue?vue&type=script&setup=true&lang.ts
|
|
85
|
+
var _hoisted_1$2 = { class: "flex flex-wrap gap-1" };
|
|
86
|
+
var _hoisted_2$1 = ["onClick"];
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue
|
|
89
|
+
var ExampleScripts_default = /* @__PURE__ */ defineComponent({
|
|
90
|
+
__name: "ExampleScripts",
|
|
91
|
+
props: { modelValue: {} },
|
|
92
|
+
emits: ["update:modelValue"],
|
|
93
|
+
setup(__props, { emit: __emit }) {
|
|
94
|
+
const props = __props;
|
|
95
|
+
const emit = __emit;
|
|
96
|
+
const addExample = (example) => {
|
|
97
|
+
let addition = example;
|
|
98
|
+
if (props.modelValue.trim() !== "") addition = `\n\n${addition}`;
|
|
99
|
+
emit("update:modelValue", props.modelValue.trim() + addition);
|
|
100
|
+
};
|
|
101
|
+
return (_ctx, _cache) => {
|
|
102
|
+
return openBlock(), createElementBlock("ul", _hoisted_1$2, [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(EXAMPLE_SCRIPTS), (example) => {
|
|
103
|
+
return openBlock(), createElementBlock("li", {
|
|
104
|
+
key: example.title,
|
|
105
|
+
class: "bg-b-2 text-c-2 hover:bg-b-3 inline-flex flex-col rounded-full px-3 py-1 text-xs font-medium"
|
|
106
|
+
}, [createElementVNode("button", {
|
|
107
|
+
class: "w-full",
|
|
108
|
+
type: "button",
|
|
109
|
+
onClick: ($event) => addExample(example.script)
|
|
110
|
+
}, toDisplayString(example.title), 9, _hoisted_2$1)]);
|
|
111
|
+
}), 128))]);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue?vue&type=script&setup=true&lang.ts
|
|
117
|
+
var _hoisted_1$1 = { class: "script-editor text-sm" };
|
|
118
|
+
var ScriptEditor_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
119
|
+
__name: "ScriptEditor",
|
|
120
|
+
props: { modelValue: {} },
|
|
121
|
+
emits: ["update:modelValue"],
|
|
122
|
+
setup(__props, { emit: __emit }) {
|
|
123
|
+
const props = __props;
|
|
124
|
+
const emit = __emit;
|
|
125
|
+
const codeMirrorRef = ref(null);
|
|
126
|
+
useCodeMirror({
|
|
127
|
+
codeMirrorRef,
|
|
128
|
+
content: toRef(() => props.modelValue),
|
|
129
|
+
language: void 0,
|
|
130
|
+
extensions: [javascript()],
|
|
131
|
+
lineNumbers: true,
|
|
132
|
+
onChange: (value) => {
|
|
133
|
+
emit("update:modelValue", value);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return (_ctx, _cache) => {
|
|
137
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [createElementVNode("div", {
|
|
138
|
+
ref_key: "codeMirrorRef",
|
|
139
|
+
ref: codeMirrorRef,
|
|
140
|
+
class: "editor-container"
|
|
141
|
+
}, null, 512)]);
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region \0plugin-vue:export-helper
|
|
147
|
+
var _plugin_vue_export_helper_default = (sfc, props) => {
|
|
148
|
+
const target = sfc.__vccOpts || sfc;
|
|
149
|
+
for (const [key, val] of props) target[key] = val;
|
|
150
|
+
return target;
|
|
151
|
+
};
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue
|
|
154
|
+
var ScriptEditor_default = /* @__PURE__ */ _plugin_vue_export_helper_default(ScriptEditor_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-a9df3276"]]);
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue?vue&type=script&setup=true&lang.ts
|
|
157
|
+
var _hoisted_1 = { class: "w-full" };
|
|
158
|
+
var _hoisted_2 = { class: "mr-2" };
|
|
159
|
+
var _hoisted_3 = {
|
|
160
|
+
key: 0,
|
|
161
|
+
class: "bg-green h-2 w-2 rounded-full"
|
|
162
|
+
};
|
|
163
|
+
var _hoisted_4 = { class: "border-y p-3" };
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue
|
|
166
|
+
var PostResponseScripts_default = /* @__PURE__ */ defineComponent({
|
|
167
|
+
__name: "PostResponseScripts",
|
|
168
|
+
props: { operation: {} },
|
|
169
|
+
emits: ["operation:update:extension"],
|
|
170
|
+
setup(__props, { emit: __emit }) {
|
|
171
|
+
const emit = __emit;
|
|
172
|
+
const script = computed(() => __props.operation["x-post-response"] || "");
|
|
173
|
+
const updatePostResponseScript = (value) => {
|
|
174
|
+
emit("operation:update:extension", { "x-post-response": value });
|
|
175
|
+
};
|
|
176
|
+
return (_ctx, _cache) => {
|
|
177
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [createVNode(unref(ViewLayoutCollapse_default), {
|
|
178
|
+
class: "w-full",
|
|
179
|
+
defaultOpen: true
|
|
180
|
+
}, {
|
|
181
|
+
title: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Scripts", -1)])]),
|
|
182
|
+
suffix: withCtx(() => [createElementVNode("div", _hoisted_2, [script.value.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_3)) : createCommentVNode("", true)])]),
|
|
183
|
+
default: withCtx(() => [
|
|
184
|
+
_cache[1] || (_cache[1] = createElementVNode("div", { class: "text-c-3 flex h-8 items-center border-y px-3 text-sm" }, " Post-Response ", -1)),
|
|
185
|
+
createVNode(ScriptEditor_default, {
|
|
186
|
+
modelValue: script.value,
|
|
187
|
+
"onUpdate:modelValue": updatePostResponseScript
|
|
188
|
+
}, null, 8, ["modelValue"]),
|
|
189
|
+
createElementVNode("div", _hoisted_4, [createVNode(ExampleScripts_default, {
|
|
190
|
+
modelValue: script.value,
|
|
191
|
+
"onUpdate:modelValue": updatePostResponseScript
|
|
192
|
+
}, null, 8, ["modelValue"])])
|
|
193
|
+
]),
|
|
194
|
+
_: 1
|
|
195
|
+
})]);
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
//#endregion
|
|
200
|
+
export { PostResponseScripts_default as t };
|
|
201
|
+
|
|
202
|
+
//# sourceMappingURL=PostResponseScripts-CrM65oAM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostResponseScripts-CrM65oAM.js","names":[],"sources":["../src/consts/example-scripts.ts","../src/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue","../src/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue","../src/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue","../src/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue","../src/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue","../src/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue"],"sourcesContent":["type ExampleScript = {\n title: string\n script: string\n mockResponse: {\n body?: any\n status?: number\n headers?: Record<string, string>\n text?: () => string\n }\n}\n\nexport const EXAMPLE_SCRIPTS: ExampleScript[] = [\n {\n title: 'Check the status code',\n script: `pm.test(\"Status code is 200\", () => {\n pm.response.to.have.status(200)\n})`,\n mockResponse: {\n status: 200,\n body: { success: true },\n },\n },\n // TODO: We didn't add the proper response duration yet.\n // {\n // title: 'Check response time',\n // script: `pm.test(\"Response time is acceptable\", () => {\n // pm.expect(pm.response.responseTime).to.be.below(200)\n // })`,\n // mockResponse: {\n // status: 200,\n // body: { success: true },\n // },\n // },\n {\n title: 'Check JSON response',\n script: `pm.test(\"Response is valid JSON\", () => {\n const responseData = pm.response.json()\n pm.expect(responseData).to.be.an('object')\n})`,\n mockResponse: {\n status: 200,\n body: { data: 'test' },\n headers: { 'Content-Type': 'application/json' },\n },\n },\n {\n title: 'Check response headers',\n script: `pm.test(\"Content-Type header is present\", () => {\n pm.response.to.have.header('Content-Type')\n})`,\n mockResponse: {\n status: 200,\n body: { success: true },\n headers: { 'Content-Type': 'application/json' },\n },\n },\n {\n title: 'Validate JSON schema',\n script: `pm.test(\"Response matches schema\", () => {\n const schema = {\n type: 'object',\n required: ['id', 'name'],\n properties: {\n id: { type: 'number' },\n name: { type: 'string' }\n }\n }\n pm.response.to.have.jsonSchema(schema)\n})`,\n mockResponse: {\n status: 200,\n body: { id: 1, name: 'Test Item' },\n headers: { 'Content-Type': 'application/json' },\n },\n },\n {\n title: 'Check response body',\n script: `pm.test(\"Response body contains string\", () => {\n pm.expect(pm.response.text()).to.include('success')\n})`,\n mockResponse: {\n status: 200,\n body: 'This is a successful response',\n },\n },\n {\n title: 'Successful POST request',\n script: `pm.test(\"Successful POST request\", () => {\n pm.expect(pm.response.code).to.be.oneOf([201, 202])\n})`,\n mockResponse: {\n status: 201,\n body: { success: true },\n },\n },\n]\n","<script setup lang=\"ts\">\nimport { EXAMPLE_SCRIPTS } from '@/consts/example-scripts'\n\nconst props = defineProps<{\n modelValue: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: string): void\n}>()\n\nconst addExample = (example: string) => {\n let addition = example\n // Look at current value. If it's not empty, add a new line.\n if (props.modelValue.trim() !== '') {\n addition = `\\n\\n${addition}`\n }\n\n emit('update:modelValue', props.modelValue.trim() + addition)\n}\n</script>\n\n<template>\n <ul class=\"flex flex-wrap gap-1\">\n <li\n v-for=\"example in EXAMPLE_SCRIPTS\"\n :key=\"example.title\"\n class=\"bg-b-2 text-c-2 hover:bg-b-3 inline-flex flex-col rounded-full px-3 py-1 text-xs font-medium\">\n <button\n class=\"w-full\"\n type=\"button\"\n @click=\"addExample(example.script)\">\n {{ example.title }}\n </button>\n </li>\n </ul>\n</template>\n","<script setup lang=\"ts\">\nimport { EXAMPLE_SCRIPTS } from '@/consts/example-scripts'\n\nconst props = defineProps<{\n modelValue: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: string): void\n}>()\n\nconst addExample = (example: string) => {\n let addition = example\n // Look at current value. If it's not empty, add a new line.\n if (props.modelValue.trim() !== '') {\n addition = `\\n\\n${addition}`\n }\n\n emit('update:modelValue', props.modelValue.trim() + addition)\n}\n</script>\n\n<template>\n <ul class=\"flex flex-wrap gap-1\">\n <li\n v-for=\"example in EXAMPLE_SCRIPTS\"\n :key=\"example.title\"\n class=\"bg-b-2 text-c-2 hover:bg-b-3 inline-flex flex-col rounded-full px-3 py-1 text-xs font-medium\">\n <button\n class=\"w-full\"\n type=\"button\"\n @click=\"addExample(example.script)\">\n {{ example.title }}\n </button>\n </li>\n </ul>\n</template>\n","<script setup lang=\"ts\">\nimport { javascript } from '@codemirror/lang-javascript'\nimport { useCodeMirror } from '@scalar/use-codemirror'\nimport { ref, toRef } from 'vue'\n\nconst props = defineProps<{\n modelValue: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: string): void\n}>()\n\nconst codeMirrorRef = ref<HTMLDivElement | null>(null)\n\nuseCodeMirror({\n codeMirrorRef,\n content: toRef(() => props.modelValue),\n language: undefined,\n // We want to use some custom configuration for the syntax highlighting.\n extensions: [javascript()],\n lineNumbers: true,\n onChange: (value) => {\n emit('update:modelValue', value)\n },\n})\n</script>\n\n<template>\n <div class=\"script-editor text-sm\">\n <div\n ref=\"codeMirrorRef\"\n class=\"editor-container\" />\n </div>\n</template>\n\n<style scoped>\n.script-editor {\n width: 100%;\n height: 100%;\n position: relative;\n}\n\n.editor-container {\n width: 100%;\n height: 100%;\n background: var(--scalar-background-1);\n border-radius: var(--scalar-radius);\n overflow: hidden;\n padding-left: 3px;\n}\n\n:deep(.cm-editor) {\n height: 100%;\n outline: none;\n background: var(--scalar-background-1);\n}\n\n:deep(.cm-content) {\n font-family: var(--scalar-font-code);\n font-size: var(--scalar-small);\n padding: 8px 2px;\n}\n\n:deep(.cm-gutters) {\n border-right: none;\n color: var(--scalar-color-3);\n background: var(--scalar-background-1);\n font-size: var(--scalar-mini);\n line-height: 1.44;\n}\n\n:deep(.cm-gutters:before) {\n content: '';\n position: absolute;\n top: 2px;\n left: 2px;\n width: calc(100% - 2px);\n height: calc(100% - 4px);\n border-radius: var(--scalar-radius) 0 0 var(--scalar-radius);\n}\n\n:deep(.cm-gutterElement) {\n font-family: var(--scalar-font-code) !important;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n position: relative;\n}\n\n:deep(.cm-scroller) {\n overflow: auto;\n}\n\n:deep(.cm-activeLine),\n:deep(.cm-activeLineGutter) {\n background-color: var(--scalar-background-2);\n}\n\n:deep(.cm-selectionMatch),\n:deep(.cm-matchingBracket) {\n border-radius: var(--scalar-radius);\n background: var(--scalar-background-4) !important;\n}\n\n:deep(.cm-tooltip) {\n background: var(--scalar-background-1) !important;\n border: 1px solid var(--scalar-border-color) !important;\n border-radius: var(--scalar-radius);\n box-shadow: var(--scalar-shadow-2);\n}\n</style>\n","<script setup lang=\"ts\">\nimport { javascript } from '@codemirror/lang-javascript'\nimport { useCodeMirror } from '@scalar/use-codemirror'\nimport { ref, toRef } from 'vue'\n\nconst props = defineProps<{\n modelValue: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: string): void\n}>()\n\nconst codeMirrorRef = ref<HTMLDivElement | null>(null)\n\nuseCodeMirror({\n codeMirrorRef,\n content: toRef(() => props.modelValue),\n language: undefined,\n // We want to use some custom configuration for the syntax highlighting.\n extensions: [javascript()],\n lineNumbers: true,\n onChange: (value) => {\n emit('update:modelValue', value)\n },\n})\n</script>\n\n<template>\n <div class=\"script-editor text-sm\">\n <div\n ref=\"codeMirrorRef\"\n class=\"editor-container\" />\n </div>\n</template>\n\n<style scoped>\n.script-editor {\n width: 100%;\n height: 100%;\n position: relative;\n}\n\n.editor-container {\n width: 100%;\n height: 100%;\n background: var(--scalar-background-1);\n border-radius: var(--scalar-radius);\n overflow: hidden;\n padding-left: 3px;\n}\n\n:deep(.cm-editor) {\n height: 100%;\n outline: none;\n background: var(--scalar-background-1);\n}\n\n:deep(.cm-content) {\n font-family: var(--scalar-font-code);\n font-size: var(--scalar-small);\n padding: 8px 2px;\n}\n\n:deep(.cm-gutters) {\n border-right: none;\n color: var(--scalar-color-3);\n background: var(--scalar-background-1);\n font-size: var(--scalar-mini);\n line-height: 1.44;\n}\n\n:deep(.cm-gutters:before) {\n content: '';\n position: absolute;\n top: 2px;\n left: 2px;\n width: calc(100% - 2px);\n height: calc(100% - 4px);\n border-radius: var(--scalar-radius) 0 0 var(--scalar-radius);\n}\n\n:deep(.cm-gutterElement) {\n font-family: var(--scalar-font-code) !important;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n position: relative;\n}\n\n:deep(.cm-scroller) {\n overflow: auto;\n}\n\n:deep(.cm-activeLine),\n:deep(.cm-activeLineGutter) {\n background-color: var(--scalar-background-2);\n}\n\n:deep(.cm-selectionMatch),\n:deep(.cm-matchingBracket) {\n border-radius: var(--scalar-radius);\n background: var(--scalar-background-4) !important;\n}\n\n:deep(.cm-tooltip) {\n background: var(--scalar-background-1) !important;\n border: 1px solid var(--scalar-border-color) !important;\n border-radius: var(--scalar-radius);\n box-shadow: var(--scalar-shadow-2);\n}\n</style>\n","<script setup lang=\"ts\">\nimport type { Operation } from '@scalar/oas-utils/entities/spec'\nimport { computed } from 'vue'\n\nimport { ViewLayoutCollapse } from '@/components/ViewLayout'\n\nimport ExampleScripts from './ExampleScripts.vue'\nimport ScriptEditor from './ScriptEditor.vue'\n\nconst { operation } = defineProps<{\n operation: Pick<Operation, 'x-post-response'>\n}>()\n\nconst emit = defineEmits<{\n (e: 'operation:update:extension', payload: any): void\n}>()\n\nconst script = computed(() => (operation['x-post-response'] as string) || '')\n\nconst updatePostResponseScript = (value: string) => {\n emit('operation:update:extension', {\n 'x-post-response': value,\n })\n}\n</script>\n\n<template>\n <div class=\"w-full\">\n <ViewLayoutCollapse\n class=\"w-full\"\n :defaultOpen=\"true\">\n <template #title>Scripts</template>\n <template #suffix>\n <!-- Show an indicator whether we have a script -->\n <div class=\"mr-2\">\n <div\n v-if=\"script.length > 0\"\n class=\"bg-green h-2 w-2 rounded-full\" />\n </div>\n </template>\n\n <div class=\"text-c-3 flex h-8 items-center border-y px-3 text-sm\">\n Post-Response\n </div>\n\n <ScriptEditor\n :modelValue=\"script\"\n @update:modelValue=\"updatePostResponseScript\" />\n\n <div class=\"border-y p-3\">\n <ExampleScripts\n :modelValue=\"script\"\n @update:modelValue=\"updatePostResponseScript\" />\n </div>\n </ViewLayoutCollapse>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { Operation } from '@scalar/oas-utils/entities/spec'\nimport { computed } from 'vue'\n\nimport { ViewLayoutCollapse } from '@/components/ViewLayout'\n\nimport ExampleScripts from './ExampleScripts.vue'\nimport ScriptEditor from './ScriptEditor.vue'\n\nconst { operation } = defineProps<{\n operation: Pick<Operation, 'x-post-response'>\n}>()\n\nconst emit = defineEmits<{\n (e: 'operation:update:extension', payload: any): void\n}>()\n\nconst script = computed(() => (operation['x-post-response'] as string) || '')\n\nconst updatePostResponseScript = (value: string) => {\n emit('operation:update:extension', {\n 'x-post-response': value,\n })\n}\n</script>\n\n<template>\n <div class=\"w-full\">\n <ViewLayoutCollapse\n class=\"w-full\"\n :defaultOpen=\"true\">\n <template #title>Scripts</template>\n <template #suffix>\n <!-- Show an indicator whether we have a script -->\n <div class=\"mr-2\">\n <div\n v-if=\"script.length > 0\"\n class=\"bg-green h-2 w-2 rounded-full\" />\n </div>\n </template>\n\n <div class=\"text-c-3 flex h-8 items-center border-y px-3 text-sm\">\n Post-Response\n </div>\n\n <ScriptEditor\n :modelValue=\"script\"\n @update:modelValue=\"updatePostResponseScript\" />\n\n <div class=\"border-y p-3\">\n <ExampleScripts\n :modelValue=\"script\"\n @update:modelValue=\"updatePostResponseScript\" />\n </div>\n </ViewLayoutCollapse>\n </div>\n</template>\n"],"mappings":";;;;;AAWA,IAAa,kBAAmC;CAC9C;EACE,OAAO;EACP,QAAQ;;;EAGR,cAAc;GACZ,QAAQ;GACR,MAAM,EAAE,SAAS,MAAM;GACxB;EACF;CAYD;EACE,OAAO;EACP,QAAQ;;;;EAIR,cAAc;GACZ,QAAQ;GACR,MAAM,EAAE,MAAM,QAAQ;GACtB,SAAS,EAAE,gBAAgB,oBAAoB;GAChD;EACF;CACD;EACE,OAAO;EACP,QAAQ;;;EAGR,cAAc;GACZ,QAAQ;GACR,MAAM,EAAE,SAAS,MAAM;GACvB,SAAS,EAAE,gBAAgB,oBAAoB;GAChD;EACF;CACD;EACE,OAAO;EACP,QAAQ;;;;;;;;;;;EAWR,cAAc;GACZ,QAAQ;GACR,MAAM;IAAE,IAAI;IAAG,MAAM;IAAa;GAClC,SAAS,EAAE,gBAAgB,oBAAoB;GAChD;EACF;CACD;EAC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A,EAAA;IAzBnB,OAAM;IACL,aAAa;;IACH,OAAK,cAAQ,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAAP,WAAO,GAAA,CAAA,EAAA,CAAA;IACb,QAAM,cAMT,CAJN,mBAIM,OAJN,YAIM,CAFI,OAAA,MAAO,SAAM,KAAA,WAAA,EADrB,mBAE0C,OAF1C,WAE0C,IAAA,mBAAA,IAAA,KAAA,CAAA,CAAA,CAAA,CAAA;2BAMxC;+BAFN,mBAEM,OAAA,EAFD,OAAM,wDAAsD,EAAC,mBAElE,GAAA;KAEA,YAEkD,sBAAA;MAD/C,YAAY,OAAA;MACZ,uBAAmB;;KAEtB,mBAIM,OAJN,YAIM,CAHJ,YAEkD,wBAAA;MAD/C,YAAY,OAAA;MACZ,uBAAmB"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { t as ViewLayoutCollapse_default } from "./ViewLayoutCollapse-BMrPz_sj.js";
|
|
2
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeClass, normalizeProps, openBlock, renderList, toDisplayString, unref, withCtx } from "vue";
|
|
3
|
+
import { ScalarIcon, cva, useBindCx } from "@scalar/components";
|
|
4
|
+
//#region src/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var _hoisted_1$3 = {
|
|
6
|
+
key: 1,
|
|
7
|
+
class: "ml-1.25 capitalize"
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue
|
|
11
|
+
var TestResultIndicator_default = /* @__PURE__ */ defineComponent({
|
|
12
|
+
__name: "TestResultIndicator",
|
|
13
|
+
props: {
|
|
14
|
+
state: {},
|
|
15
|
+
failedTestsCount: {},
|
|
16
|
+
pendingTestsCount: {},
|
|
17
|
+
totalTestsCount: {},
|
|
18
|
+
inline: { type: Boolean }
|
|
19
|
+
},
|
|
20
|
+
setup(__props) {
|
|
21
|
+
const { cx } = useBindCx();
|
|
22
|
+
const icon = computed(() => {
|
|
23
|
+
if (__props.state === "passed") return {
|
|
24
|
+
name: "Checkmark",
|
|
25
|
+
color: "text-green p-0.25"
|
|
26
|
+
};
|
|
27
|
+
if (__props.state === "failed") return {
|
|
28
|
+
name: "Close",
|
|
29
|
+
color: "text-red"
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
name: "Ellipses",
|
|
33
|
+
color: "text-c-1"
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
const statusVariants = cva({
|
|
37
|
+
base: "flex items-center gap-1.5 rounded-full border pr-2 pl-1.25",
|
|
38
|
+
variants: { status: {
|
|
39
|
+
passed: "text-green",
|
|
40
|
+
failed: "text-red",
|
|
41
|
+
pending: "text-orange"
|
|
42
|
+
} }
|
|
43
|
+
});
|
|
44
|
+
const textVariants = cva({
|
|
45
|
+
base: "text-c-2",
|
|
46
|
+
variants: { inline: {
|
|
47
|
+
true: "text-xs",
|
|
48
|
+
false: "text-sm"
|
|
49
|
+
} }
|
|
50
|
+
});
|
|
51
|
+
const getTestCountDisplay = computed(() => {
|
|
52
|
+
if (__props.totalTestsCount === void 0) return "";
|
|
53
|
+
if (__props.failedTestsCount) return `${__props.failedTestsCount}/${__props.totalTestsCount}`;
|
|
54
|
+
return `${__props.totalTestsCount - (__props.pendingTestsCount || 0) - (__props.failedTestsCount || 0)}/${__props.totalTestsCount}`;
|
|
55
|
+
});
|
|
56
|
+
return (_ctx, _cache) => {
|
|
57
|
+
return openBlock(), createElementBlock("div", normalizeProps(guardReactiveProps(unref(cx)(unref(statusVariants)({ status: __props.state })))), [
|
|
58
|
+
__props.state ? (openBlock(), createBlock(unref(ScalarIcon), {
|
|
59
|
+
key: 0,
|
|
60
|
+
class: normalizeClass(icon.value.color),
|
|
61
|
+
icon: icon.value.name,
|
|
62
|
+
size: "sm"
|
|
63
|
+
}, null, 8, ["class", "icon"])) : createCommentVNode("", true),
|
|
64
|
+
!__props.inline ? (openBlock(), createElementBlock("span", _hoisted_1$3, toDisplayString(__props.state), 1)) : createCommentVNode("", true),
|
|
65
|
+
__props.totalTestsCount !== void 0 ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 2 }, unref(cx)(unref(textVariants)({ inline: __props.inline })))), toDisplayString(getTestCountDisplay.value), 17)) : createCommentVNode("", true)
|
|
66
|
+
], 16);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/plugins/post-response-scripts/components/TestResults/TestResultItem.vue?vue&type=script&setup=true&lang.ts
|
|
72
|
+
var _hoisted_1$2 = { class: "flex flex-col" };
|
|
73
|
+
var _hoisted_2$1 = { class: "flex items-center gap-3 p-2" };
|
|
74
|
+
var _hoisted_3$1 = { class: "text-c-2 overflow-hidden text-ellipsis whitespace-nowrap" };
|
|
75
|
+
var _hoisted_4 = { class: "text-c-3 ml-auto whitespace-nowrap" };
|
|
76
|
+
var _hoisted_5 = {
|
|
77
|
+
key: 0,
|
|
78
|
+
class: "bg-b-danger text-c-1 flex items-center pr-3 pb-1.5 pl-9"
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/plugins/post-response-scripts/components/TestResults/TestResultItem.vue
|
|
82
|
+
var TestResultItem_default = /* @__PURE__ */ defineComponent({
|
|
83
|
+
__name: "TestResultItem",
|
|
84
|
+
props: {
|
|
85
|
+
result: {},
|
|
86
|
+
currentState: {}
|
|
87
|
+
},
|
|
88
|
+
setup(__props) {
|
|
89
|
+
const resultStatus = computed(() => {
|
|
90
|
+
if (__props.result.passed) return {
|
|
91
|
+
icon: "Checkmark",
|
|
92
|
+
color: "text-green p-0.25"
|
|
93
|
+
};
|
|
94
|
+
if (!__props.result.passed && __props.currentState !== "pending") return {
|
|
95
|
+
icon: "Close",
|
|
96
|
+
color: "text-red"
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
icon: "Ellipses",
|
|
100
|
+
color: "text-c-1"
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
return (_ctx, _cache) => {
|
|
104
|
+
return openBlock(), createElementBlock("div", _hoisted_1$2, [createElementVNode("div", { class: normalizeClass(["flex h-8 items-center gap-2 pr-3 pl-2.25", __props.result.error && "bg-b-danger"]) }, [createElementVNode("div", _hoisted_2$1, [createVNode(unref(ScalarIcon), {
|
|
105
|
+
class: normalizeClass(resultStatus.value.color),
|
|
106
|
+
icon: resultStatus.value.icon,
|
|
107
|
+
size: "sm"
|
|
108
|
+
}, null, 8, ["class", "icon"]), createElementVNode("span", _hoisted_3$1, toDisplayString(__props.result.title), 1)]), createElementVNode("span", _hoisted_4, toDisplayString(__props.result.duration) + " ms ", 1)], 2), __props.result.error ? (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString(__props.result.error), 1)) : createCommentVNode("", true)]);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/plugins/post-response-scripts/components/TestResults/TestSummary.vue?vue&type=script&setup=true&lang.ts
|
|
114
|
+
var _hoisted_1$1 = { class: "flex h-8 items-center gap-1.5 pr-3 pl-1" };
|
|
115
|
+
var _hoisted_2 = {
|
|
116
|
+
key: 0,
|
|
117
|
+
class: "text-orange"
|
|
118
|
+
};
|
|
119
|
+
var _hoisted_3 = { class: "text-c-3 ml-auto" };
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/plugins/post-response-scripts/components/TestResults/TestSummary.vue
|
|
122
|
+
var TestSummary_default = /* @__PURE__ */ defineComponent({
|
|
123
|
+
__name: "TestSummary",
|
|
124
|
+
props: {
|
|
125
|
+
results: {},
|
|
126
|
+
passedTests: {},
|
|
127
|
+
failedTests: {},
|
|
128
|
+
pendingTests: {},
|
|
129
|
+
allTestsPassed: { type: Boolean },
|
|
130
|
+
totalDuration: {}
|
|
131
|
+
},
|
|
132
|
+
setup(__props) {
|
|
133
|
+
return (_ctx, _cache) => {
|
|
134
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
135
|
+
createVNode(TestResultIndicator_default, {
|
|
136
|
+
failedTestsCount: __props.failedTests?.length,
|
|
137
|
+
passedTestsCount: __props.passedTests?.length,
|
|
138
|
+
pendingTestsCount: __props.pendingTests?.length,
|
|
139
|
+
state: __props.allTestsPassed ? "passed" : "failed",
|
|
140
|
+
totalTestsCount: __props.results?.length
|
|
141
|
+
}, null, 8, [
|
|
142
|
+
"failedTestsCount",
|
|
143
|
+
"passedTestsCount",
|
|
144
|
+
"pendingTestsCount",
|
|
145
|
+
"state",
|
|
146
|
+
"totalTestsCount"
|
|
147
|
+
]),
|
|
148
|
+
__props.pendingTests?.length ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(__props.pendingTests?.length) + " Pending ", 1)) : createCommentVNode("", true),
|
|
149
|
+
createElementVNode("span", _hoisted_3, toDisplayString(__props.totalDuration.toFixed(1)) + " ms ", 1)
|
|
150
|
+
]);
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/plugins/post-response-scripts/components/TestResults/TestResults.vue?vue&type=script&setup=true&lang.ts
|
|
156
|
+
var _hoisted_1 = { class: "max-h-[calc(100%-32px)] divide-y overflow-y-auto border-t" };
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/plugins/post-response-scripts/components/TestResults/TestResults.vue
|
|
159
|
+
var TestResults_default = /* @__PURE__ */ defineComponent({
|
|
160
|
+
__name: "TestResults",
|
|
161
|
+
props: { results: {} },
|
|
162
|
+
setup(__props) {
|
|
163
|
+
const passedTests = computed(() => __props.results?.value?.filter((result) => result.status === "passed"));
|
|
164
|
+
const pendingTests = computed(() => __props.results?.value?.filter((result) => result.status === "pending"));
|
|
165
|
+
const failedTests = computed(() => __props.results?.value?.filter((result) => result.status === "failed"));
|
|
166
|
+
const allTestsPassed = computed(() => passedTests.value?.length === __props.results?.value?.length);
|
|
167
|
+
const currentState = computed(() => {
|
|
168
|
+
if (allTestsPassed.value) return "passed";
|
|
169
|
+
if (pendingTests.value?.length) return "pending";
|
|
170
|
+
return "failed";
|
|
171
|
+
});
|
|
172
|
+
const totalDuration = computed(() => __props.results?.value?.reduce((acc, curr) => acc + curr.duration, 0) ?? 0);
|
|
173
|
+
return (_ctx, _cache) => {
|
|
174
|
+
return __props.results?.value?.length ? (openBlock(), createBlock(unref(ViewLayoutCollapse_default), {
|
|
175
|
+
key: 0,
|
|
176
|
+
class: "overflow-auto text-sm",
|
|
177
|
+
defaultOpen: true
|
|
178
|
+
}, {
|
|
179
|
+
title: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode(" Tests ", -1)])]),
|
|
180
|
+
suffix: withCtx(() => [createVNode(TestResultIndicator_default, {
|
|
181
|
+
failedTestsCount: failedTests.value?.length,
|
|
182
|
+
inline: "",
|
|
183
|
+
passedTestsCount: passedTests.value?.length,
|
|
184
|
+
pendingTestsCount: pendingTests.value?.length,
|
|
185
|
+
state: currentState.value,
|
|
186
|
+
totalTestsCount: __props.results?.value?.length
|
|
187
|
+
}, null, 8, [
|
|
188
|
+
"failedTestsCount",
|
|
189
|
+
"passedTestsCount",
|
|
190
|
+
"pendingTestsCount",
|
|
191
|
+
"state",
|
|
192
|
+
"totalTestsCount"
|
|
193
|
+
])]),
|
|
194
|
+
default: withCtx(() => [createElementVNode("div", _hoisted_1, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.results?.value, (result) => {
|
|
195
|
+
return openBlock(), createBlock(TestResultItem_default, {
|
|
196
|
+
key: result.title,
|
|
197
|
+
currentState: result.status,
|
|
198
|
+
result
|
|
199
|
+
}, null, 8, ["currentState", "result"]);
|
|
200
|
+
}), 128)), __props.results ? (openBlock(), createBlock(TestSummary_default, {
|
|
201
|
+
key: 0,
|
|
202
|
+
allTestsPassed: allTestsPassed.value,
|
|
203
|
+
failedTests: failedTests.value ?? [],
|
|
204
|
+
passedTests: passedTests.value ?? [],
|
|
205
|
+
pendingTests: pendingTests.value ?? [],
|
|
206
|
+
results: __props.results?.value,
|
|
207
|
+
totalDuration: totalDuration.value
|
|
208
|
+
}, null, 8, [
|
|
209
|
+
"allTestsPassed",
|
|
210
|
+
"failedTests",
|
|
211
|
+
"passedTests",
|
|
212
|
+
"pendingTests",
|
|
213
|
+
"results",
|
|
214
|
+
"totalDuration"
|
|
215
|
+
])) : createCommentVNode("", true)])]),
|
|
216
|
+
_: 1
|
|
217
|
+
})) : createCommentVNode("", true);
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
//#endregion
|
|
222
|
+
export { TestResults_default as t };
|
|
223
|
+
|
|
224
|
+
//# sourceMappingURL=TestResults-DIM8u91u.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestResults-DIM8u91u.js","names":[],"sources":["../src/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue","../src/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue","../src/plugins/post-response-scripts/components/TestResults/TestResultItem.vue","../src/plugins/post-response-scripts/components/TestResults/TestResultItem.vue","../src/plugins/post-response-scripts/components/TestResults/TestSummary.vue","../src/plugins/post-response-scripts/components/TestResults/TestSummary.vue","../src/plugins/post-response-scripts/components/TestResults/TestResults.vue","../src/plugins/post-response-scripts/components/TestResults/TestResults.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { cva, ScalarIcon, useBindCx, type Icon } from '@scalar/components'\nimport { computed } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nconst { state, totalTestsCount, pendingTestsCount, failedTestsCount } =\n defineProps<{\n state?: TestResult['status']\n failedTestsCount: number | undefined\n pendingTestsCount: number | undefined\n totalTestsCount: number | undefined\n inline?: boolean\n }>()\n\nconst { cx } = useBindCx()\n\nconst icon = computed(() => {\n if (state === 'passed') {\n return { name: 'Checkmark', color: 'text-green p-0.25' }\n }\n\n if (state === 'failed') {\n return { name: 'Close', color: 'text-red' }\n }\n\n return { name: 'Ellipses', color: 'text-c-1' }\n})\n\nconst statusVariants = cva({\n base: 'flex items-center gap-1.5 rounded-full border pr-2 pl-1.25',\n variants: {\n status: {\n passed: 'text-green',\n failed: 'text-red',\n pending: 'text-orange',\n },\n },\n})\n\nconst textVariants = cva({\n base: 'text-c-2',\n variants: {\n inline: {\n true: 'text-xs',\n false: 'text-sm',\n },\n },\n})\n\n// Display the number of tests that passed e.g 1/3\nconst getTestCountDisplay = computed(() => {\n // When there are no tests, show nothing\n if (totalTestsCount === undefined) {\n return ''\n }\n\n // When they failed, show failed/total\n if (failedTestsCount) {\n return `${failedTestsCount}/${totalTestsCount}`\n }\n\n // When they passed, show passed/total\n const completedTests =\n totalTestsCount - (pendingTestsCount || 0) - (failedTestsCount || 0)\n return `${completedTests}/${totalTestsCount}`\n})\n</script>\n\n<template>\n <div v-bind=\"cx(statusVariants({ status: state }))\">\n <ScalarIcon\n v-if=\"state\"\n :class=\"icon.color\"\n :icon=\"icon.name as Icon\"\n size=\"sm\" />\n <span\n v-if=\"!inline\"\n class=\"ml-1.25 capitalize\">\n {{ state }}\n </span>\n <span\n v-if=\"totalTestsCount !== undefined\"\n v-bind=\"cx(textVariants({ inline }))\">\n {{ getTestCountDisplay }}\n </span>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { cva, ScalarIcon, useBindCx, type Icon } from '@scalar/components'\nimport { computed } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nconst { state, totalTestsCount, pendingTestsCount, failedTestsCount } =\n defineProps<{\n state?: TestResult['status']\n failedTestsCount: number | undefined\n pendingTestsCount: number | undefined\n totalTestsCount: number | undefined\n inline?: boolean\n }>()\n\nconst { cx } = useBindCx()\n\nconst icon = computed(() => {\n if (state === 'passed') {\n return { name: 'Checkmark', color: 'text-green p-0.25' }\n }\n\n if (state === 'failed') {\n return { name: 'Close', color: 'text-red' }\n }\n\n return { name: 'Ellipses', color: 'text-c-1' }\n})\n\nconst statusVariants = cva({\n base: 'flex items-center gap-1.5 rounded-full border pr-2 pl-1.25',\n variants: {\n status: {\n passed: 'text-green',\n failed: 'text-red',\n pending: 'text-orange',\n },\n },\n})\n\nconst textVariants = cva({\n base: 'text-c-2',\n variants: {\n inline: {\n true: 'text-xs',\n false: 'text-sm',\n },\n },\n})\n\n// Display the number of tests that passed e.g 1/3\nconst getTestCountDisplay = computed(() => {\n // When there are no tests, show nothing\n if (totalTestsCount === undefined) {\n return ''\n }\n\n // When they failed, show failed/total\n if (failedTestsCount) {\n return `${failedTestsCount}/${totalTestsCount}`\n }\n\n // When they passed, show passed/total\n const completedTests =\n totalTestsCount - (pendingTestsCount || 0) - (failedTestsCount || 0)\n return `${completedTests}/${totalTestsCount}`\n})\n</script>\n\n<template>\n <div v-bind=\"cx(statusVariants({ status: state }))\">\n <ScalarIcon\n v-if=\"state\"\n :class=\"icon.color\"\n :icon=\"icon.name as Icon\"\n size=\"sm\" />\n <span\n v-if=\"!inline\"\n class=\"ml-1.25 capitalize\">\n {{ state }}\n </span>\n <span\n v-if=\"totalTestsCount !== undefined\"\n v-bind=\"cx(textVariants({ inline }))\">\n {{ getTestCountDisplay }}\n </span>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ScalarIcon, type Icon } from '@scalar/components'\nimport { computed } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nconst { currentState, result } = defineProps<{\n result: TestResult\n currentState: TestResult['status']\n}>()\n\nconst resultStatus = computed(() => {\n if (result.passed) {\n return { icon: 'Checkmark', color: 'text-green p-0.25' }\n }\n\n if (!result.passed && currentState !== 'pending') {\n return { icon: 'Close', color: 'text-red' }\n }\n\n return { icon: 'Ellipses', color: 'text-c-1' }\n})\n</script>\n\n<template>\n <div class=\"flex flex-col\">\n <div\n class=\"flex h-8 items-center gap-2 pr-3 pl-2.25\"\n :class=\"result.error && 'bg-b-danger'\">\n <!-- Title -->\n <div class=\"flex items-center gap-3 p-2\">\n <ScalarIcon\n :class=\"resultStatus.color\"\n :icon=\"resultStatus.icon as Icon\"\n size=\"sm\" />\n\n <span class=\"text-c-2 overflow-hidden text-ellipsis whitespace-nowrap\">\n {{ result.title }}\n </span>\n </div>\n <!-- Duration -->\n <span class=\"text-c-3 ml-auto whitespace-nowrap\">\n {{ result.duration }} ms\n </span>\n </div>\n <!-- Error -->\n <div\n v-if=\"result.error\"\n class=\"bg-b-danger text-c-1 flex items-center pr-3 pb-1.5 pl-9\">\n {{ result.error }}\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ScalarIcon, type Icon } from '@scalar/components'\nimport { computed } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nconst { currentState, result } = defineProps<{\n result: TestResult\n currentState: TestResult['status']\n}>()\n\nconst resultStatus = computed(() => {\n if (result.passed) {\n return { icon: 'Checkmark', color: 'text-green p-0.25' }\n }\n\n if (!result.passed && currentState !== 'pending') {\n return { icon: 'Close', color: 'text-red' }\n }\n\n return { icon: 'Ellipses', color: 'text-c-1' }\n})\n</script>\n\n<template>\n <div class=\"flex flex-col\">\n <div\n class=\"flex h-8 items-center gap-2 pr-3 pl-2.25\"\n :class=\"result.error && 'bg-b-danger'\">\n <!-- Title -->\n <div class=\"flex items-center gap-3 p-2\">\n <ScalarIcon\n :class=\"resultStatus.color\"\n :icon=\"resultStatus.icon as Icon\"\n size=\"sm\" />\n\n <span class=\"text-c-2 overflow-hidden text-ellipsis whitespace-nowrap\">\n {{ result.title }}\n </span>\n </div>\n <!-- Duration -->\n <span class=\"text-c-3 ml-auto whitespace-nowrap\">\n {{ result.duration }} ms\n </span>\n </div>\n <!-- Error -->\n <div\n v-if=\"result.error\"\n class=\"bg-b-danger text-c-1 flex items-center pr-3 pb-1.5 pl-9\">\n {{ result.error }}\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { TestResult } from '@/libs/execute-scripts'\n\nimport TestResultIndicator from './TestResultIndicator.vue'\n\ndefineProps<{\n results: TestResult[]\n passedTests: TestResult[]\n failedTests: TestResult[]\n pendingTests: TestResult[]\n allTestsPassed: boolean\n totalDuration: number\n}>()\n</script>\n\n<template>\n <div class=\"flex h-8 items-center gap-1.5 pr-3 pl-1\">\n <TestResultIndicator\n :failedTestsCount=\"failedTests?.length\"\n :passedTestsCount=\"passedTests?.length\"\n :pendingTestsCount=\"pendingTests?.length\"\n :state=\"allTestsPassed ? 'passed' : 'failed'\"\n :totalTestsCount=\"results?.length\" />\n <span\n v-if=\"pendingTests?.length\"\n class=\"text-orange\">\n {{ pendingTests?.length }}\n Pending\n </span>\n <span class=\"text-c-3 ml-auto\"> {{ totalDuration.toFixed(1) }} ms </span>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { TestResult } from '@/libs/execute-scripts'\n\nimport TestResultIndicator from './TestResultIndicator.vue'\n\ndefineProps<{\n results: TestResult[]\n passedTests: TestResult[]\n failedTests: TestResult[]\n pendingTests: TestResult[]\n allTestsPassed: boolean\n totalDuration: number\n}>()\n</script>\n\n<template>\n <div class=\"flex h-8 items-center gap-1.5 pr-3 pl-1\">\n <TestResultIndicator\n :failedTestsCount=\"failedTests?.length\"\n :passedTestsCount=\"passedTests?.length\"\n :pendingTestsCount=\"pendingTests?.length\"\n :state=\"allTestsPassed ? 'passed' : 'failed'\"\n :totalTestsCount=\"results?.length\" />\n <span\n v-if=\"pendingTests?.length\"\n class=\"text-orange\">\n {{ pendingTests?.length }}\n Pending\n </span>\n <span class=\"text-c-3 ml-auto\"> {{ totalDuration.toFixed(1) }} ms </span>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, type Ref } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nimport { ViewLayoutCollapse } from '../../../../components/ViewLayout'\nimport TestResultIndicator from './TestResultIndicator.vue'\nimport TestResultItem from './TestResultItem.vue'\nimport TestSummary from './TestSummary.vue'\n\nconst { results } = defineProps<{\n results?: Ref<TestResult[]> | undefined\n}>()\n\nconst passedTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'passed'),\n)\n\nconst pendingTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'pending'),\n)\n\nconst failedTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'failed'),\n)\n\nconst allTestsPassed = computed(\n () => passedTests.value?.length === results?.value?.length,\n)\n\nconst currentState = computed(() => {\n if (allTestsPassed.value) {\n return 'passed'\n }\n\n if (pendingTests.value?.length) {\n return 'pending'\n }\n\n return 'failed'\n})\n\nconst totalDuration = computed(\n () =>\n results?.value?.reduce(\n (acc: number, curr: TestResult) => acc + curr.duration,\n 0,\n ) ?? 0,\n)\n</script>\n\n<template>\n <ViewLayoutCollapse\n v-if=\"results?.value?.length\"\n class=\"overflow-auto text-sm\"\n :defaultOpen=\"true\">\n <template #title> Tests </template>\n <template #suffix>\n <TestResultIndicator\n :failedTestsCount=\"failedTests?.length\"\n inline\n :passedTestsCount=\"passedTests?.length\"\n :pendingTestsCount=\"pendingTests?.length\"\n :state=\"currentState\"\n :totalTestsCount=\"results?.value?.length\" />\n </template>\n\n <div class=\"max-h-[calc(100%-32px)] divide-y overflow-y-auto border-t\">\n <!-- Results -->\n <TestResultItem\n v-for=\"result in results?.value\"\n :key=\"result.title\"\n :currentState=\"result.status\"\n :result=\"result\" />\n\n <TestSummary\n v-if=\"results\"\n :allTestsPassed=\"allTestsPassed\"\n :failedTests=\"failedTests ?? []\"\n :passedTests=\"passedTests ?? []\"\n :pendingTests=\"pendingTests ?? []\"\n :results=\"results?.value\"\n :totalDuration=\"totalDuration\" />\n </div>\n </ViewLayoutCollapse>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, type Ref } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nimport { ViewLayoutCollapse } from '../../../../components/ViewLayout'\nimport TestResultIndicator from './TestResultIndicator.vue'\nimport TestResultItem from './TestResultItem.vue'\nimport TestSummary from './TestSummary.vue'\n\nconst { results } = defineProps<{\n results?: Ref<TestResult[]> | undefined\n}>()\n\nconst passedTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'passed'),\n)\n\nconst pendingTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'pending'),\n)\n\nconst failedTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'failed'),\n)\n\nconst allTestsPassed = computed(\n () => passedTests.value?.length === results?.value?.length,\n)\n\nconst currentState = computed(() => {\n if (allTestsPassed.value) {\n return 'passed'\n }\n\n if (pendingTests.value?.length) {\n return 'pending'\n }\n\n return 'failed'\n})\n\nconst totalDuration = computed(\n () =>\n results?.value?.reduce(\n (acc: number, curr: TestResult) => acc + curr.duration,\n 0,\n ) ?? 0,\n)\n</script>\n\n<template>\n <ViewLayoutCollapse\n v-if=\"results?.value?.length\"\n class=\"overflow-auto text-sm\"\n :defaultOpen=\"true\">\n <template #title> Tests </template>\n <template #suffix>\n <TestResultIndicator\n :failedTestsCount=\"failedTests?.length\"\n inline\n :passedTestsCount=\"passedTests?.length\"\n :pendingTestsCount=\"pendingTests?.length\"\n :state=\"currentState\"\n :totalTestsCount=\"results?.value?.length\" />\n </template>\n\n <div class=\"max-h-[calc(100%-32px)] divide-y overflow-y-auto border-t\">\n <!-- Results -->\n <TestResultItem\n v-for=\"result in results?.value\"\n :key=\"result.title\"\n :currentState=\"result.status\"\n :result=\"result\" />\n\n <TestSummary\n v-if=\"results\"\n :allTestsPassed=\"allTestsPassed\"\n :failedTests=\"failedTests ?? []\"\n :passedTests=\"passedTests ?? []\"\n :pendingTests=\"pendingTests ?? []\"\n :results=\"results?.value\"\n :totalDuration=\"totalDuration\" />\n </div>\n </ViewLayoutCollapse>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;ECeA,MAAM,EAAE,OAAO,WAAU;EAEzB,MAAM,OAAO,eAAe;AAC1B,OAAI,QAAA,UAAU,SACZ,QAAO;IAAE,MAAM;IAAa,OAAO;IAAoB;AAG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Ae,cAAA"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, normalizeClass, onBeforeUnmount, openBlock, renderSlot, toDisplayString, unref, useId, watch, withCtx } from "vue";
|
|
2
|
+
import { Disclosure, DisclosureButton, DisclosurePanel } from "@headlessui/vue";
|
|
3
|
+
import { ScalarIcon } from "@scalar/components";
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/components/ViewLayout/ValueEmitter.vue
|
|
6
|
+
var ValueEmitter_default = /* @__PURE__ */ defineComponent({
|
|
7
|
+
name: "ValueEmitter",
|
|
8
|
+
props: { value: {} },
|
|
9
|
+
emits: ["change", "unmount"],
|
|
10
|
+
setup(__props, { emit: __emit }) {
|
|
11
|
+
const emit = __emit;
|
|
12
|
+
watch(() => __props.value, (newValue) => emit("change", newValue), { immediate: true });
|
|
13
|
+
onBeforeUnmount(() => emit("unmount"));
|
|
14
|
+
return (_ctx, _cache) => {
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/components/ViewLayout/ViewLayoutCollapse.vue?vue&type=script&setup=true&lang.ts
|
|
21
|
+
var _hoisted_1 = ["aria-labelledby"];
|
|
22
|
+
var _hoisted_2 = { class: "text-c-1 m-0 flex flex-1 items-center gap-1.5 leading-[20px]" };
|
|
23
|
+
var _hoisted_3 = ["id"];
|
|
24
|
+
var _hoisted_4 = {
|
|
25
|
+
key: 0,
|
|
26
|
+
class: "sr-only"
|
|
27
|
+
};
|
|
28
|
+
var _hoisted_5 = {
|
|
29
|
+
key: 0,
|
|
30
|
+
class: "bg-b-2 text-c-2 inline-flex h-5 w-5 items-center justify-center rounded-full border text-xs font-semibold"
|
|
31
|
+
};
|
|
32
|
+
var _hoisted_6 = { class: "sr-only" };
|
|
33
|
+
var _hoisted_7 = {
|
|
34
|
+
key: 0,
|
|
35
|
+
class: "ui-not-open:hidden flex items-center gap-2 pr-0.75"
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/components/ViewLayout/ViewLayoutCollapse.vue
|
|
39
|
+
var ViewLayoutCollapse_default = /* @__PURE__ */ defineComponent({
|
|
40
|
+
name: "CollapsibleSection",
|
|
41
|
+
props: {
|
|
42
|
+
defaultOpen: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: true
|
|
45
|
+
},
|
|
46
|
+
itemCount: { default: 0 },
|
|
47
|
+
isStatic: { type: Boolean }
|
|
48
|
+
},
|
|
49
|
+
emits: ["update:modelValue"],
|
|
50
|
+
setup(__props, { emit: __emit }) {
|
|
51
|
+
const emit = __emit;
|
|
52
|
+
const headingId = useId();
|
|
53
|
+
return (_ctx, _cache) => {
|
|
54
|
+
return openBlock(), createBlock(unref(Disclosure), {
|
|
55
|
+
as: "div",
|
|
56
|
+
class: normalizeClass(["group/collapse text-c-2 focus-within:text-c-1 last:ui-open:border-b-0 border-b", __props.isStatic && "last-of-type:first-of-type:border-b-0"]),
|
|
57
|
+
defaultOpen: __props.defaultOpen,
|
|
58
|
+
static: __props.isStatic
|
|
59
|
+
}, {
|
|
60
|
+
default: withCtx(({ open }) => [createVNode(ValueEmitter_default, {
|
|
61
|
+
value: open,
|
|
62
|
+
onChange: _cache[0] || (_cache[0] = (value) => emit("update:modelValue", value))
|
|
63
|
+
}, null, 8, ["value"]), createElementVNode("section", {
|
|
64
|
+
"aria-labelledby": unref(headingId),
|
|
65
|
+
class: "contents"
|
|
66
|
+
}, [createElementVNode("div", { class: normalizeClass(["bg-b-2 flex items-center", __props.isStatic && "rounded-t-lg border border-b-0"]) }, [createVNode(unref(DisclosureButton), {
|
|
67
|
+
class: normalizeClass(["hover:text-c-1 group box-content flex max-h-8 flex-1 items-center gap-2.5 overflow-hidden px-1 py-1.5 text-base font-medium outline-none md:px-1.5 xl:pr-0.5 xl:pl-2", __props.isStatic && "!pl-3"]),
|
|
68
|
+
disabled: __props.isStatic
|
|
69
|
+
}, {
|
|
70
|
+
default: withCtx(() => [!__props.isStatic ? (openBlock(), createBlock(unref(ScalarIcon), {
|
|
71
|
+
key: 0,
|
|
72
|
+
class: "text-c-3 group-hover:text-c-1 rounded-px ui-open:rotate-90 ui-not-open:rotate-0 outline-offset-2 group-focus-visible:outline",
|
|
73
|
+
icon: "ChevronRight",
|
|
74
|
+
size: "md"
|
|
75
|
+
})) : createCommentVNode("", true), createElementVNode("h2", _hoisted_2, [createElementVNode("span", {
|
|
76
|
+
id: unref(headingId),
|
|
77
|
+
class: "contents"
|
|
78
|
+
}, [renderSlot(_ctx.$slots, "title", { open }), !open ? (openBlock(), createElementBlock("span", _hoisted_4, " (Collapsed) ")) : createCommentVNode("", true)], 8, _hoisted_3), !open && __props.itemCount ? (openBlock(), createElementBlock("span", _hoisted_5, [createTextVNode(toDisplayString(__props.itemCount) + " ", 1), createElementVNode("span", _hoisted_6, "Item" + toDisplayString(__props.itemCount === 1 ? "" : "s"), 1)])) : createCommentVNode("", true)])]),
|
|
79
|
+
_: 2
|
|
80
|
+
}, 1032, ["class", "disabled"]), _ctx.$slots.actions ? (openBlock(), createElementBlock("div", _hoisted_7, [renderSlot(_ctx.$slots, "actions", { open })])) : createCommentVNode("", true)], 2), createVNode(unref(DisclosurePanel), mergeProps(_ctx.$attrs, { class: "diclosure-panel h-full max-h-fit rounded-b" }), {
|
|
81
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", { open })]),
|
|
82
|
+
_: 2
|
|
83
|
+
}, 1040)], 8, _hoisted_1)]),
|
|
84
|
+
_: 3
|
|
85
|
+
}, 8, [
|
|
86
|
+
"class",
|
|
87
|
+
"defaultOpen",
|
|
88
|
+
"static"
|
|
89
|
+
]);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
//#endregion
|
|
94
|
+
export { ViewLayoutCollapse_default as t };
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=ViewLayoutCollapse-BMrPz_sj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewLayoutCollapse-BMrPz_sj.js","names":["$slots","$attrs"],"sources":["../src/components/ViewLayout/ValueEmitter.vue","../src/components/ViewLayout/ValueEmitter.vue","../src/components/ViewLayout/ViewLayoutCollapse.vue","../src/components/ViewLayout/ViewLayoutCollapse.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * This component takes in any value and emits it back\n *\n * This is useful when we need to catch the open state of a disclosure from its v-slot\n */\nexport default {\n name: 'ValueEmitter',\n}\n</script>\n\n<script setup lang=\"ts\" generic=\"T\">\nimport { onBeforeUnmount, watch } from 'vue'\n\nconst { value } = defineProps<{ value: T }>()\nconst emit = defineEmits<{\n (e: 'change', value: T): void\n (e: 'unmount'): void\n}>()\n\nwatch(\n () => value,\n (newValue) => emit('change', newValue),\n { immediate: true },\n)\n\nonBeforeUnmount(() => emit('unmount'))\n</script>\n\n<!-- eslint-disable-next-line vue/valid-template-root -->\n<template>\n <!-- We use this hack to emit the slot value back to the parent -->\n</template>\n","<script lang=\"ts\">\n/**\n * This component takes in any value and emits it back\n *\n * This is useful when we need to catch the open state of a disclosure from its v-slot\n */\nexport default {\n name: 'ValueEmitter',\n}\n</script>\n\n<script setup lang=\"ts\" generic=\"T\">\nimport { onBeforeUnmount, watch } from 'vue'\n\nconst { value } = defineProps<{ value: T }>()\nconst emit = defineEmits<{\n (e: 'change', value: T): void\n (e: 'unmount'): void\n}>()\n\nwatch(\n () => value,\n (newValue) => emit('change', newValue),\n { immediate: true },\n)\n\nonBeforeUnmount(() => emit('unmount'))\n</script>\n\n<!-- eslint-disable-next-line vue/valid-template-root -->\n<template>\n <!-- We use this hack to emit the slot value back to the parent -->\n</template>\n","<script lang=\"ts\">\n/**\n * Simple collapsible section component that can be used to wrap content that should be collapsed and expanded\n *\n * Would like to replace with details/summary elements, but they are not supported in all browsers yet?\n */\nexport default {\n name: 'CollapsibleSection',\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'\nimport { ScalarIcon } from '@scalar/components'\nimport { useId } from 'vue'\n\nimport ValueEmitter from './ValueEmitter.vue'\n\nconst {\n defaultOpen = true,\n itemCount = 0,\n isStatic,\n} = defineProps<{\n /** Whether the disclosure is open by default. */\n defaultOpen?: boolean\n /** Number of items to show in badge when collapsed. */\n itemCount?: number\n /** Whether the disclosure is static and cannot be toggled. */\n isStatic?: boolean\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: boolean): void\n}>()\n\nconst headingId = useId()\n</script>\n\n<template>\n <Disclosure\n v-slot=\"{ open }\"\n as=\"div\"\n class=\"group/collapse text-c-2 focus-within:text-c-1 last:ui-open:border-b-0 border-b\"\n :class=\"isStatic && 'last-of-type:first-of-type:border-b-0'\"\n :defaultOpen=\"defaultOpen\"\n :static=\"isStatic\">\n <!-- We use this hack to emit the slot value back to the parent -->\n <ValueEmitter\n :value=\"open as boolean\"\n @change=\"(value) => emit('update:modelValue', value)\" />\n\n <section\n :aria-labelledby=\"headingId\"\n class=\"contents\">\n <div\n class=\"bg-b-2 flex items-center\"\n :class=\"isStatic && 'rounded-t-lg border border-b-0'\">\n <!-- Main disclosure button that toggles the panel -->\n <DisclosureButton\n class=\"hover:text-c-1 group box-content flex max-h-8 flex-1 items-center gap-2.5 overflow-hidden px-1 py-1.5 text-base font-medium outline-none md:px-1.5 xl:pr-0.5 xl:pl-2\"\n :class=\"isStatic && '!pl-3'\"\n :disabled=\"isStatic\">\n <ScalarIcon\n v-if=\"!isStatic\"\n class=\"text-c-3 group-hover:text-c-1 rounded-px ui-open:rotate-90 ui-not-open:rotate-0 outline-offset-2 group-focus-visible:outline\"\n icon=\"ChevronRight\"\n size=\"md\" />\n\n <!-- Heading with title -->\n <h2\n class=\"text-c-1 m-0 flex flex-1 items-center gap-1.5 leading-[20px]\">\n <span\n :id=\"headingId\"\n class=\"contents\">\n <slot\n name=\"title\"\n :open=\"open\" />\n <span\n v-if=\"!open\"\n class=\"sr-only\">\n (Collapsed)\n </span>\n </span>\n\n <!-- Badge showing item count when collapsed. -->\n <span\n v-if=\"!open && itemCount\"\n class=\"bg-b-2 text-c-2 inline-flex h-5 w-5 items-center justify-center rounded-full border text-xs font-semibold\">\n {{ itemCount }}\n <span class=\"sr-only\">Item{{ itemCount === 1 ? '' : 's' }}</span>\n </span>\n </h2>\n </DisclosureButton>\n\n <!-- Optional actions slot that hides when the panel is closed. -->\n <div\n v-if=\"$slots.actions\"\n class=\"ui-not-open:hidden flex items-center gap-2 pr-0.75\">\n <slot\n name=\"actions\"\n :open=\"open\" />\n </div>\n </div>\n\n <!-- The collapsible content panel. -->\n <DisclosurePanel\n v-bind=\"$attrs\"\n class=\"diclosure-panel h-full max-h-fit rounded-b\">\n <slot :open=\"open\" />\n </DisclosurePanel>\n </section>\n </Disclosure>\n</template>\n","<script lang=\"ts\">\n/**\n * Simple collapsible section component that can be used to wrap content that should be collapsed and expanded\n *\n * Would like to replace with details/summary elements, but they are not supported in all browsers yet?\n */\nexport default {\n name: 'CollapsibleSection',\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'\nimport { ScalarIcon } from '@scalar/components'\nimport { useId } from 'vue'\n\nimport ValueEmitter from './ValueEmitter.vue'\n\nconst {\n defaultOpen = true,\n itemCount = 0,\n isStatic,\n} = defineProps<{\n /** Whether the disclosure is open by default. */\n defaultOpen?: boolean\n /** Number of items to show in badge when collapsed. */\n itemCount?: number\n /** Whether the disclosure is static and cannot be toggled. */\n isStatic?: boolean\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: boolean): void\n}>()\n\nconst headingId = useId()\n</script>\n\n<template>\n <Disclosure\n v-slot=\"{ open }\"\n as=\"div\"\n class=\"group/collapse text-c-2 focus-within:text-c-1 last:ui-open:border-b-0 border-b\"\n :class=\"isStatic && 'last-of-type:first-of-type:border-b-0'\"\n :defaultOpen=\"defaultOpen\"\n :static=\"isStatic\">\n <!-- We use this hack to emit the slot value back to the parent -->\n <ValueEmitter\n :value=\"open as boolean\"\n @change=\"(value) => emit('update:modelValue', value)\" />\n\n <section\n :aria-labelledby=\"headingId\"\n class=\"contents\">\n <div\n class=\"bg-b-2 flex items-center\"\n :class=\"isStatic && 'rounded-t-lg border border-b-0'\">\n <!-- Main disclosure button that toggles the panel -->\n <DisclosureButton\n class=\"hover:text-c-1 group box-content flex max-h-8 flex-1 items-center gap-2.5 overflow-hidden px-1 py-1.5 text-base font-medium outline-none md:px-1.5 xl:pr-0.5 xl:pl-2\"\n :class=\"isStatic && '!pl-3'\"\n :disabled=\"isStatic\">\n <ScalarIcon\n v-if=\"!isStatic\"\n class=\"text-c-3 group-hover:text-c-1 rounded-px ui-open:rotate-90 ui-not-open:rotate-0 outline-offset-2 group-focus-visible:outline\"\n icon=\"ChevronRight\"\n size=\"md\" />\n\n <!-- Heading with title -->\n <h2\n class=\"text-c-1 m-0 flex flex-1 items-center gap-1.5 leading-[20px]\">\n <span\n :id=\"headingId\"\n class=\"contents\">\n <slot\n name=\"title\"\n :open=\"open\" />\n <span\n v-if=\"!open\"\n class=\"sr-only\">\n (Collapsed)\n </span>\n </span>\n\n <!-- Badge showing item count when collapsed. -->\n <span\n v-if=\"!open && itemCount\"\n class=\"bg-b-2 text-c-2 inline-flex h-5 w-5 items-center justify-center rounded-full border text-xs font-semibold\">\n {{ itemCount }}\n <span class=\"sr-only\">Item{{ itemCount === 1 ? '' : 's' }}</span>\n </span>\n </h2>\n </DisclosureButton>\n\n <!-- Optional actions slot that hides when the panel is closed. -->\n <div\n v-if=\"$slots.actions\"\n class=\"ui-not-open:hidden flex items-center gap-2 pr-0.75\">\n <slot\n name=\"actions\"\n :open=\"open\" />\n </div>\n </div>\n\n <!-- The collapsible content panel. -->\n <DisclosurePanel\n v-bind=\"$attrs\"\n class=\"diclosure-panel h-full max-h-fit rounded-b\">\n <slot :open=\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