@scalar/api-reference 1.17.13 → 1.17.15

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/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "vue",
16
16
  "vue3"
17
17
  ],
18
- "version": "1.17.13",
18
+ "version": "1.17.15",
19
19
  "engines": {
20
20
  "node": ">=18"
21
21
  },
@@ -65,13 +65,13 @@
65
65
  "unhead": "^1.8.3",
66
66
  "unified": "^11.0.4",
67
67
  "vue-sonner": "^1.0.3",
68
- "@scalar/api-client": "0.12.13",
69
- "@scalar/components": "0.4.1",
70
- "@scalar/swagger-editor": "0.10.14",
68
+ "@scalar/components": "0.4.2",
69
+ "@scalar/swagger-parser": "0.5.20",
70
+ "@scalar/api-client": "0.12.14",
71
+ "@scalar/swagger-editor": "0.10.15",
71
72
  "@scalar/themes": "0.5.10",
72
- "@scalar/use-modal": "0.2.8",
73
73
  "@scalar/use-tooltip": "0.5.11",
74
- "@scalar/swagger-parser": "0.5.19"
74
+ "@scalar/use-modal": "0.2.8"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@etchteam/storybook-addon-css-variables-theme": "^1.5.1",
@@ -1,415 +0,0 @@
1
- import { defineComponent as F, openBlock as p, createBlock as B, unref as r, withCtx as c, createElementVNode as y, normalizeClass as _, createVNode as u, normalizeStyle as R, createTextVNode as b, toDisplayString as M, createCommentVNode as S, renderSlot as k, reactive as L, useAttrs as W, ref as U, onMounted as H, createElementBlock as w, resolveDynamicComponent as P, mergeProps as J, withKeys as K, watch as N, Fragment as E, computed as O, isRef as Q } from "vue";
2
- import { c as j, a as $, _ as z, n as Y, H as D, b as I, f as q, C as G, h as X, R as Z } from "./index-RELYUG_m.js";
3
- import { u as Ne } from "./index-RELYUG_m.js";
4
- import { Dialog as ee, DialogPanel as te, DialogTitle as re, DialogDescription as oe } from "@headlessui/vue";
5
- import { useTextareaAutosize as ae, useMediaQuery as le, useFileDialog as se } from "@vueuse/core";
6
- const ne = () => L({
7
- open: !1,
8
- show() {
9
- this.open = !0;
10
- },
11
- hide() {
12
- this.open = !1;
13
- }
14
- }), ie = /* @__PURE__ */ F({
15
- __name: "ScalarModal",
16
- props: {
17
- state: {},
18
- title: {},
19
- bodyClass: {},
20
- maxWidth: {},
21
- size: { default: "md" },
22
- variant: {}
23
- },
24
- setup(d) {
25
- const f = j({
26
- base: [
27
- "scalar-modal",
28
- "col leading-snug relative mx-auto mb-0 mt-20 w-full rounded-lg bg-back-2 text-left text-fore-1 opacity-0"
29
- ].join(" "),
30
- variants: {
31
- size: {
32
- xs: "max-w-screen-xs",
33
- sm: "max-w-screen-sm",
34
- md: "max-w-screen-md",
35
- lg: "max-w-screen-lg"
36
- },
37
- variant: {
38
- history: "scalar-modal-history bg-back-1",
39
- search: "scalar-modal-search"
40
- }
41
- }
42
- });
43
- return (t, a) => (p(), B(r(ee), {
44
- open: t.state.open,
45
- onClose: a[0] || (a[0] = (h) => t.state.hide())
46
- }, {
47
- default: c(() => [
48
- y("div", {
49
- class: _(
50
- r($)(
51
- "scalar-modal-layout fixed left-0 top-0",
52
- "z-[1001] h-[100dvh] w-[100dvw]",
53
- "bg-backdrop p-5 opacity-0"
54
- )
55
- )
56
- }, [
57
- u(r(te), {
58
- class: _(r(f)({ size: t.size, variant: t.variant })),
59
- style: R({ maxWidth: t.maxWidth })
60
- }, {
61
- default: c(() => [
62
- t.title ? (p(), B(r(re), {
63
- key: 0,
64
- class: _(["scalar-modal-header font-semiBold m-0 rounded-lg px-6 py-3 text-left text-xs text-fore-1", { "pb-0 pt-6": t.variant === "history" }])
65
- }, {
66
- default: c(() => [
67
- b(M(t.title), 1)
68
- ]),
69
- _: 1
70
- }, 8, ["class"])) : S("", !0),
71
- u(r(oe), {
72
- class: _([
73
- "scalar-modal-body relative max-h-[calc(100dvh-240px)] overflow-y-auto rounded-lg bg-back-1 px-6 pb-4 pt-6",
74
- r($)(
75
- t.bodyClass,
76
- t.variant === "history" && "pt-3",
77
- t.variant === "search" && "col max-h-[440px] overflow-hidden p-0"
78
- )
79
- ])
80
- }, {
81
- default: c(() => [
82
- k(t.$slots, "default", {}, void 0, !0)
83
- ]),
84
- _: 3
85
- }, 8, ["class"])
86
- ]),
87
- _: 3
88
- }, 8, ["class", "style"])
89
- ], 2)
90
- ]),
91
- _: 3
92
- }, 8, ["open"]));
93
- }
94
- }), de = /* @__PURE__ */ z(ie, [["__scopeId", "data-v-53cbffc0"]]), ue = { class: "scalar-input-container relative" }, pe = ["for"], ce = { class: "icon-slot cursor-pointer text-ghost hover:text-fore-1 !empty:flex !empty:w-7 !empty:items-center !empty:pr-3" }, me = /* @__PURE__ */ F({
95
- __name: "ScalarTextField",
96
- props: {
97
- modelValue: {},
98
- placeholder: {},
99
- label: {},
100
- labelShadowColor: { default: "var(--theme-background-2, var(--default-theme-background-2))" },
101
- error: { type: Boolean },
102
- isMultiline: { type: Boolean },
103
- helperText: {},
104
- emitOnBlur: { type: Boolean, default: !0 },
105
- handleFieldSubmit: {},
106
- handleFieldChange: {},
107
- disableTrim: { type: Boolean, default: !1 }
108
- },
109
- emits: ["submit", "update:modelValue"],
110
- setup(d, { emit: f }) {
111
- const t = d, a = f, h = j({
112
- base: "scalar-input-wrapper relative flex items-center rounded border border-solid border-border",
113
- variants: {
114
- focus: {
115
- true: "scalar-input-wrapper-focus border-fore-3 has-actv-btn:border has-actv-btn:border-border"
116
- },
117
- error: { true: "scalar-input-wrapper-error border-error" }
118
- }
119
- }), n = W(), s = n.id || `id-${Y()}`, i = U(), x = U(!1);
120
- let o;
121
- if (t.isMultiline) {
122
- const { triggerResize: e } = ae({
123
- element: i,
124
- input: t.modelValue
125
- });
126
- o = e;
127
- }
128
- function v(e) {
129
- const l = e.target.value;
130
- t.isMultiline && o(), t.handleFieldChange ? t.handleFieldChange(l) : a("update:modelValue", l);
131
- }
132
- function m(e) {
133
- const l = e.target, g = t.disableTrim || t.isMultiline ? l.value : l.value.trim();
134
- t.handleFieldSubmit ? t.handleFieldSubmit(g) : a("submit", g);
135
- }
136
- function C(e) {
137
- x.value = !1, t.emitOnBlur && t.modelValue && m(e);
138
- }
139
- return H(() => {
140
- var e;
141
- Object.prototype.hasOwnProperty.call(n, "autofocus") && ((e = i.value) == null || e.focus());
142
- }), (e, l) => (p(), w("div", ue, [
143
- y("div", {
144
- class: _(r(h)({ error: e.error, focus: x.value }))
145
- }, [
146
- (p(), B(P(e.isMultiline ? "textarea" : "input"), J({ id: r(s) }, e.$attrs, {
147
- ref_key: "input",
148
- ref: i,
149
- class: [
150
- "scalar-input",
151
- r($)(
152
- { "min-h-[77px]": e.isMultiline },
153
- "z-10 w-full resize-none appearance-none border-0 bg-transparent p-3 text-sm text-fore-1",
154
- "outline-none transition-opacity"
155
- )
156
- ],
157
- placeholder: e.placeholder,
158
- value: e.modelValue,
159
- onBlur: C,
160
- onFocus: l[0] || (l[0] = (g) => x.value = !0),
161
- onInput: v,
162
- onKeyup: K(m, ["enter"])
163
- }), null, 16, ["id", "class", "placeholder", "value"])),
164
- e.label ? (p(), w("label", {
165
- key: 0,
166
- class: _(
167
- r($)(
168
- "scalar-input-label pointer-events-none absolute left-0 top-0 mx-2 my-3 px-1 text-xs",
169
- "shadow-current z-10 origin-top-left rounded text-fore-3 transition-transform"
170
- )
171
- ),
172
- for: r(s),
173
- style: R({
174
- "box-shadow": `0 0 4px 4px ${e.labelShadowColor}`,
175
- "background-color": e.labelShadowColor
176
- })
177
- }, M(e.label), 15, pe)) : S("", !0),
178
- y("div", ce, [
179
- k(e.$slots, "default", {}, void 0, !0)
180
- ])
181
- ], 2),
182
- y("span", {
183
- class: _(
184
- r($)(
185
- "helper-text before:rounded-full mt-1.5 flex items-center text-xs text-error before:font-black",
186
- "before:mr-1.5 before:block before:h-4 before:w-4 before:text-center before:text-xxs before:leading-4",
187
- "before:bg-error before:text-white before:content-['!'] empty:hidden"
188
- )
189
- )
190
- }, M(e.helperText), 3)
191
- ]));
192
- }
193
- }), fe = /* @__PURE__ */ z(me, [["__scopeId", "data-v-398eaaae"]]), ge = (d) => {
194
- if (typeof d != "string")
195
- return !1;
196
- try {
197
- JSON.parse(d);
198
- } catch {
199
- return !1;
200
- }
201
- return !0;
202
- }, he = { class: "swagger-editor-header" }, ve = { class: "swagger-editor-title" }, be = { class: "swagger-editor-actions" }, ye = { key: 0 }, we = { key: 0 }, xe = { class: "swagger-editor-modal-layout" }, _e = /* @__PURE__ */ F({
203
- __name: "SwaggerEditorHeader",
204
- props: {
205
- proxyUrl: {}
206
- },
207
- emits: ["import"],
208
- setup(d, { expose: f, emit: t }) {
209
- const a = d, h = t, n = le("(max-width: 1000px)"), { files: s, open: i, reset: x } = se({
210
- multiple: !1,
211
- accept: ".json,.yaml,.yml"
212
- }), o = ne(), v = U(null);
213
- f({
214
- importUrlModal: o,
215
- openFileDialog: i
216
- });
217
- const m = U(""), C = () => {
218
- v.value = "", q(m.value, a.proxyUrl).then(async (e) => {
219
- h("import", e), o.hide();
220
- }).catch((e) => {
221
- console.error("[importUrl]", e), v.value = e;
222
- });
223
- };
224
- return N(s, () => {
225
- var e;
226
- if ((e = s.value) != null && e.length) {
227
- const l = s.value[0], g = new FileReader();
228
- g.onload = (A) => {
229
- var T;
230
- const V = (T = A.target) == null ? void 0 : T.result;
231
- typeof V == "string" && (h("import", V), x());
232
- }, g.readAsText(l);
233
- }
234
- }), (e, l) => (p(), w(E, null, [
235
- y("div", he, [
236
- y("div", ve, [
237
- r(n) ? S("", !0) : (p(), w(E, { key: 0 }, [
238
- b("Swagger ")
239
- ], 64)),
240
- b("Editor ")
241
- ]),
242
- k(e.$slots, "tab-items", {}, void 0, !0),
243
- y("div", be, [
244
- u(D, {
245
- onClick: l[0] || (l[0] = () => r(i)())
246
- }, {
247
- default: c(() => [
248
- b(" Upload"),
249
- r(n) ? S("", !0) : (p(), w("span", ye, " File"))
250
- ]),
251
- _: 1
252
- }),
253
- u(D, {
254
- onClick: l[1] || (l[1] = (g) => r(o).show())
255
- }, {
256
- default: c(() => [
257
- r(n) ? S("", !0) : (p(), w("span", we, "Import ")),
258
- b("URL ")
259
- ]),
260
- _: 1
261
- })
262
- ])
263
- ]),
264
- u(r(de), {
265
- state: r(o),
266
- title: "Import Swagger from URL"
267
- }, {
268
- default: c(() => [
269
- y("div", xe, [
270
- u(r(fe), {
271
- modelValue: m.value,
272
- "onUpdate:modelValue": l[2] || (l[2] = (g) => m.value = g),
273
- autofocus: "",
274
- class: "swagger-editor-modal-layout-input",
275
- label: "URL",
276
- labelShadowColor: "var(--theme-background-1, var(--default-theme-background-1))",
277
- placeholder: "https://scalar.com/swagger.json"
278
- }, null, 8, ["modelValue"]),
279
- b(" " + M(v.value) + " ", 1),
280
- u(r(I), {
281
- variant: "outlined",
282
- onClick: l[3] || (l[3] = (g) => r(o).hide())
283
- }, {
284
- default: c(() => [
285
- b(" Cancel ")
286
- ]),
287
- _: 1
288
- }),
289
- u(r(I), { onClick: C }, {
290
- default: c(() => [
291
- b("Import")
292
- ]),
293
- _: 1
294
- })
295
- ])
296
- ]),
297
- _: 1
298
- }, 8, ["state"])
299
- ], 64));
300
- }
301
- }), Ce = /* @__PURE__ */ z(_e, [["__scopeId", "data-v-17d421af"]]), Se = { class: "swagger-editor-input" }, ke = /* @__PURE__ */ F({
302
- __name: "SwaggerEditorInput",
303
- props: {
304
- value: {}
305
- },
306
- emits: ["contentUpdate"],
307
- setup(d, { expose: f }) {
308
- const t = d;
309
- f({
310
- setCodeMirrorContent: (s) => {
311
- var i;
312
- (i = a.value) == null || i.setCodeMirrorContent(s);
313
- }
314
- });
315
- const a = U(null);
316
- function h(s) {
317
- return ge(s) ? "json" : "yaml";
318
- }
319
- const n = O(() => h(t.value));
320
- return (s, i) => (p(), w("div", Se, [
321
- u(r(G), {
322
- ref_key: "codeMirrorRef",
323
- ref: a,
324
- content: s.value,
325
- language: n.value,
326
- lineNumbers: "",
327
- onChange: i[0] || (i[0] = (x) => s.$emit("contentUpdate", x))
328
- }, null, 8, ["content", "language"])
329
- ]));
330
- }
331
- }), Ue = {}, $e = { class: "swagger-editor-notification swagger-editor-notification--error" };
332
- function Me(d, f) {
333
- return p(), w("div", $e, [
334
- k(d.$slots, "default")
335
- ]);
336
- }
337
- const Fe = /* @__PURE__ */ z(Ue, [["render", Me]]), ze = /* @__PURE__ */ F({
338
- __name: "SwaggerEditor",
339
- props: {
340
- value: {},
341
- theme: {},
342
- proxyUrl: {},
343
- error: {}
344
- },
345
- emits: ["contentUpdate", "import", "changeTheme"],
346
- setup(d, { expose: f, emit: t }) {
347
- const a = d, h = t, n = U(null), s = (o) => {
348
- h("contentUpdate", o);
349
- }, i = O(() => {
350
- if (a.error === void 0 || a.error === null || a.error === "")
351
- return "";
352
- const o = Q(a.error) ? a.error.value : a.error;
353
- return o.startsWith("YAMLException:") ? o.split(`
354
- `)[0] : o;
355
- });
356
- return N(
357
- () => a.value,
358
- async () => {
359
- a.value && s(a.value);
360
- },
361
- { immediate: !0 }
362
- ), f({
363
- handleOpenSwaggerEditor: (o) => {
364
- var v, m, C;
365
- o === "importUrl" ? (m = (v = n == null ? void 0 : n.value) == null ? void 0 : v.importUrlModal) == null || m.show() : o === "uploadFile" && ((C = n == null ? void 0 : n.value) == null || C.openFileDialog());
366
- }
367
- }), (o, v) => (p(), w(E, null, [
368
- u(r(X), { id: o.theme }, null, 8, ["id"]),
369
- u(Z, null, {
370
- default: c(({ styles: m }) => [
371
- y("div", {
372
- class: _(["swagger-editor", m])
373
- }, [
374
- u(Ce, {
375
- ref_key: "swaggerEditorHeaderRef",
376
- ref: n,
377
- proxyUrl: o.proxyUrl,
378
- onImport: s
379
- }, {
380
- "tab-items": c(() => [
381
- k(o.$slots, "tab-items", {}, void 0, !0)
382
- ]),
383
- _: 3
384
- }, 8, ["proxyUrl"]),
385
- i.value ? (p(), B(Fe, { key: 0 }, {
386
- default: c(() => [
387
- b(M(i.value), 1)
388
- ]),
389
- _: 1
390
- })) : S("", !0),
391
- k(o.$slots, "editor-input", {
392
- value: o.value,
393
- onContentUpdate: s
394
- }, () => [
395
- u(ke, {
396
- value: o.value,
397
- onContentUpdate: s
398
- }, null, 8, ["value"])
399
- ], !0)
400
- ], 2)
401
- ]),
402
- _: 3
403
- })
404
- ], 64));
405
- }
406
- }), De = /* @__PURE__ */ z(ze, [["__scopeId", "data-v-6759cff3"]]);
407
- export {
408
- De as CodeEditor,
409
- D as HeaderTabButton,
410
- Z as ResetStyles,
411
- De as SwaggerEditor,
412
- q as fetchSpecFromUrl,
413
- ge as isJsonString,
414
- Ne as useDarkModeState
415
- };