@scalar/blocks 0.7.3 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/_virtual/_plugin-vue_export-helper.js +1 -2
  3. package/dist/code-example/components/AsyncApiCodeExample.vue.js +1 -2
  4. package/dist/code-example/components/AsyncApiCodeExample.vue.js.map +1 -1
  5. package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js +1 -2
  6. package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -1
  7. package/dist/code-example/components/CodeExample.vue.d.ts +2 -0
  8. package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
  9. package/dist/code-example/components/CodeExample.vue.js +4 -5
  10. package/dist/code-example/components/CodeExample.vue.js.map +1 -1
  11. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js +102 -100
  12. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -1
  13. package/dist/code-example/components/ExamplePicker.vue.js +1 -2
  14. package/dist/code-example/components/ExamplePicker.vue.js.map +1 -1
  15. package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js +1 -2
  16. package/dist/code-example/components/HttpMethod.vue.js +1 -2
  17. package/dist/code-example/components/HttpMethod.vue.js.map +1 -1
  18. package/dist/code-example/components/HttpMethod.vue_vue_type_script_setup_true_lang.js +1 -2
  19. package/dist/code-example/helpers/filter-clients-by-query.js +1 -2
  20. package/dist/code-example/helpers/find-client.js +1 -2
  21. package/dist/code-example/helpers/format-language.js +1 -2
  22. package/dist/code-example/helpers/generate-client-options.js +1 -2
  23. package/dist/code-example/helpers/generate-code-snippet.d.ts +2 -1
  24. package/dist/code-example/helpers/generate-code-snippet.d.ts.map +1 -1
  25. package/dist/code-example/helpers/generate-code-snippet.js +11 -11
  26. package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
  27. package/dist/code-example/helpers/get-asyncapi-example-context.js +1 -2
  28. package/dist/code-example/helpers/get-clients.js +8 -9
  29. package/dist/code-example/helpers/get-custom-code-samples.js +1 -2
  30. package/dist/code-example/helpers/get-generated-payload-example.js +1 -2
  31. package/dist/code-example/helpers/get-message-example-content.js +1 -2
  32. package/dist/code-example/helpers/get-secrets.js +1 -2
  33. package/dist/code-example/helpers/get-snippet.js +1 -2
  34. package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts +2 -1
  35. package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
  36. package/dist/code-example/helpers/operation-to-har/operation-to-har.js +32 -31
  37. package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
  38. package/dist/code-example/helpers/operation-to-har/process-body.d.ts +2 -2
  39. package/dist/code-example/helpers/operation-to-har/process-body.d.ts.map +1 -1
  40. package/dist/code-example/helpers/operation-to-har/process-body.js +80 -52
  41. package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -1
  42. package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts +2 -1
  43. package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
  44. package/dist/code-example/helpers/operation-to-har/process-parameters.js +65 -58
  45. package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -1
  46. package/dist/code-example/helpers/operation-to-har/process-security-schemes.d.ts.map +1 -1
  47. package/dist/code-example/helpers/operation-to-har/process-security-schemes.js +31 -28
  48. package/dist/code-example/helpers/operation-to-har/process-security-schemes.js.map +1 -1
  49. package/dist/code-example/helpers/operation-to-har/process-server-url.js +1 -2
  50. package/dist/code-example/index.js +10 -10
  51. package/dist/code-example/mount-asyncapi.js +7 -8
  52. package/dist/code-example/mount.js +5 -6
  53. package/dist/constants.js +2 -3
  54. package/dist/schema/LinkButton.vue.js +1 -2
  55. package/dist/schema/RenderString.vue.js +1 -2
  56. package/dist/schema/RenderString.vue.js.map +1 -1
  57. package/dist/schema/RenderString.vue_vue_type_script_setup_true_lang.js +1 -2
  58. package/dist/schema/Schema.vue.js +4 -5
  59. package/dist/schema/Schema.vue.js.map +1 -1
  60. package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js +67 -68
  61. package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js.map +1 -1
  62. package/dist/schema/SchemaCollapsedPreview.vue.js +1 -2
  63. package/dist/schema/SchemaCollapsedPreview.vue.js.map +1 -1
  64. package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js +1 -2
  65. package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js.map +1 -1
  66. package/dist/schema/SchemaComposition.vue.js +4 -5
  67. package/dist/schema/SchemaComposition.vue.js.map +1 -1
  68. package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js +26 -27
  69. package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js.map +1 -1
  70. package/dist/schema/SchemaEnumPropertyItem.vue.js +1 -2
  71. package/dist/schema/SchemaEnumPropertyItem.vue.js.map +1 -1
  72. package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js +1 -2
  73. package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
  74. package/dist/schema/SchemaEnums.vue.js +4 -5
  75. package/dist/schema/SchemaEnums.vue.js.map +1 -1
  76. package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js +12 -13
  77. package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js.map +1 -1
  78. package/dist/schema/SchemaGlyphPuck.vue.js +1 -2
  79. package/dist/schema/SchemaGlyphPuck.vue.js.map +1 -1
  80. package/dist/schema/SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js +1 -2
  81. package/dist/schema/SchemaGutterToggle.vue.js +1 -2
  82. package/dist/schema/SchemaGutterToggle.vue.js.map +1 -1
  83. package/dist/schema/SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js +1 -2
  84. package/dist/schema/SchemaHeading.vue.js +4 -5
  85. package/dist/schema/SchemaHeading.vue.js.map +1 -1
  86. package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js +1 -2
  87. package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js.map +1 -1
  88. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js +1 -2
  89. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js.map +1 -1
  90. package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js +1 -2
  91. package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
  92. package/dist/schema/SchemaObjectProperties.vue.js +1 -2
  93. package/dist/schema/SchemaObjectProperties.vue.js.map +1 -1
  94. package/dist/schema/SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js +1 -2
  95. package/dist/schema/SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js.map +1 -1
  96. package/dist/schema/SchemaProperty.vue.js +4 -5
  97. package/dist/schema/SchemaProperty.vue.js.map +1 -1
  98. package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js +48 -49
  99. package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js.map +1 -1
  100. package/dist/schema/SchemaPropertyDefault.vue.js +4 -5
  101. package/dist/schema/SchemaPropertyDefault.vue.js.map +1 -1
  102. package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js +9 -10
  103. package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js.map +1 -1
  104. package/dist/schema/SchemaPropertyDetail.vue.js +4 -5
  105. package/dist/schema/SchemaPropertyDetail.vue.js.map +1 -1
  106. package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js +1 -2
  107. package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js.map +1 -1
  108. package/dist/schema/SchemaPropertyExamples.vue.js +4 -5
  109. package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -1
  110. package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js +18 -19
  111. package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js.map +1 -1
  112. package/dist/schema/SchemaPropertyHeading.vue.js +4 -5
  113. package/dist/schema/SchemaPropertyHeading.vue.js.map +1 -1
  114. package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js +101 -102
  115. package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js.map +1 -1
  116. package/dist/schema/SchemaPropertyPattern.vue.js +4 -5
  117. package/dist/schema/SchemaPropertyPattern.vue.js.map +1 -1
  118. package/dist/schema/SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js +1 -2
  119. package/dist/schema/SchemaRailPanel.vue.js +1 -2
  120. package/dist/schema/SchemaRailPanel.vue.js.map +1 -1
  121. package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js +1 -2
  122. package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
  123. package/dist/schema/components/CopyLinkButton.vue.js +1 -2
  124. package/dist/schema/components/CopyLinkButton.vue.js.map +1 -1
  125. package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js +1 -2
  126. package/dist/schema/components/WithBreadcrumb.vue.js +1 -2
  127. package/dist/schema/components/WithBreadcrumb.vue.js.map +1 -1
  128. package/dist/schema/components/WithBreadcrumb.vue_vue_type_script_setup_true_lang.js +1 -2
  129. package/dist/schema/discriminator-metadata.js +1 -2
  130. package/dist/schema/helpers/dynamic-scope.js +1 -2
  131. package/dist/schema/helpers/format-example.js +1 -2
  132. package/dist/schema/helpers/format-value.js +1 -2
  133. package/dist/schema/helpers/get-compositions-to-render.js +19 -20
  134. package/dist/schema/helpers/get-discriminator-values.js +1 -2
  135. package/dist/schema/helpers/get-enum-values.js +1 -2
  136. package/dist/schema/helpers/get-property-description.js +1 -2
  137. package/dist/schema/helpers/get-ref-name.js +1 -2
  138. package/dist/schema/helpers/get-rendered-example.js +1 -2
  139. package/dist/schema/helpers/get-schema-type.js +1 -2
  140. package/dist/schema/helpers/get-type-signature-tokens.d.ts +2 -2
  141. package/dist/schema/helpers/get-type-signature-tokens.d.ts.map +1 -1
  142. package/dist/schema/helpers/get-type-signature-tokens.js +3 -4
  143. package/dist/schema/helpers/get-type-signature-tokens.js.map +1 -1
  144. package/dist/schema/helpers/has-complex-array-items.js +1 -2
  145. package/dist/schema/helpers/index.js +13 -13
  146. package/dist/schema/helpers/is-empty-schema-object.js +1 -2
  147. package/dist/schema/helpers/is-model-linkable.js +1 -2
  148. package/dist/schema/helpers/is-on-schema-target-path.js +1 -2
  149. package/dist/schema/helpers/is-type-object.js +1 -2
  150. package/dist/schema/helpers/merge-all-of-schemas.js +1 -2
  151. package/dist/schema/helpers/normalize-object-composition.js +1 -2
  152. package/dist/schema/helpers/optimize-value-for-display.js +1 -2
  153. package/dist/schema/helpers/partition-all-of-compositions.js +1 -2
  154. package/dist/schema/helpers/schema-composition.js +1 -2
  155. package/dist/schema/helpers/schema-cycle.js +1 -2
  156. package/dist/schema/helpers/schema-expansion.js +1 -2
  157. package/dist/schema/helpers/schema-keyboard-nav.js +1 -2
  158. package/dist/schema/helpers/schema-name.js +2 -3
  159. package/dist/schema/helpers/schema-name.js.map +1 -1
  160. package/dist/schema/helpers/should-display-description.js +1 -2
  161. package/dist/schema/helpers/should-display-heading.js +1 -2
  162. package/dist/schema/helpers/should-render-array-item-composition.js +1 -2
  163. package/dist/schema/helpers/sort-property-names.js +1 -2
  164. package/dist/schema/helpers/unwrap-for-read.js +1 -2
  165. package/dist/schema/index.js +8 -8
  166. package/dist/schema/localization/index.js +1 -2
  167. package/dist/schema/localization/locales/ar.js +1 -2
  168. package/dist/schema/localization/locales/de.js +1 -2
  169. package/dist/schema/localization/locales/en.js +1 -2
  170. package/dist/schema/localization/locales/es.js +1 -2
  171. package/dist/schema/localization/locales/fr.js +1 -2
  172. package/dist/schema/localization/locales/pt.js +1 -2
  173. package/dist/schema/localization/locales/ru.js +1 -2
  174. package/dist/schema/localization/locales/zh-cn.js +1 -2
  175. package/dist/schema/localization/locales/zh-tw.js +1 -2
  176. package/dist/schema/localization/translations.js +1 -2
  177. package/dist/schema/protobuf-metadata.js +1 -2
  178. package/dist/schema/recursive-metadata.js +1 -2
  179. package/dist/schema/request-body-composition-index.js +1 -2
  180. package/dist/shared/Badge.vue.d.ts.map +1 -1
  181. package/dist/shared/Badge.vue.js +4 -5
  182. package/dist/shared/Badge.vue.js.map +1 -1
  183. package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js +2 -3
  184. package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js.map +1 -1
  185. package/dist/shared/ExternalDocs.vue.js +1 -2
  186. package/dist/shared/ExternalDocs.vue.js.map +1 -1
  187. package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js +1 -2
  188. package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js.map +1 -1
  189. package/dist/shared/ScreenReader.vue.js +1 -2
  190. package/dist/shared/ScreenReader.vue.js.map +1 -1
  191. package/dist/shared/ScreenReader.vue_vue_type_script_setup_true_lang.js +1 -2
  192. package/dist/shared/index.js +4 -4
  193. package/dist/specification-extensions/ExtensionValue.vue.js +1 -2
  194. package/dist/specification-extensions/ExtensionValue.vue.js.map +1 -1
  195. package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js +5 -6
  196. package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js.map +1 -1
  197. package/dist/specification-extensions/SpecificationExtensions.vue.js +1 -2
  198. package/dist/specification-extensions/SpecificationExtensions.vue.js.map +1 -1
  199. package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js +1 -2
  200. package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js.map +1 -1
  201. package/dist/style.css +42 -22
  202. package/dist/vue-styles.css +1 -1
  203. package/package.json +24 -24
@@ -1,25 +1,25 @@
1
- import e from "./ExamplePicker.vue.js";
2
- import { filterClientsByQuery as t } from "../helpers/filter-clients-by-query.js";
3
- import { findClient as n } from "../helpers/find-client.js";
4
- import { operationToHar as r } from "../helpers/operation-to-har/operation-to-har.js";
5
- import { generateCodeSnippet as ee } from "../helpers/generate-code-snippet.js";
1
+ import { filterClientsByQuery as e } from "../helpers/filter-clients-by-query.js";
2
+ import { findClient as t } from "../helpers/find-client.js";
3
+ import { generateCodeSnippet as n } from "../helpers/generate-code-snippet.js";
4
+ import { getClients as ee } from "../helpers/get-clients.js";
6
5
  import { getCustomCodeSamples as te } from "../helpers/get-custom-code-samples.js";
7
- import { getClients as ne } from "../helpers/get-clients.js";
8
- import { getSecrets as re } from "../helpers/get-secrets.js";
9
- import i from "./HttpMethod.vue.js";
10
- import { Fragment as a, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createSlots as ie, createTextVNode as d, createVNode as f, defineComponent as p, normalizeClass as m, openBlock as h, ref as g, renderSlot as _, toDisplayString as v, unref as y, useId as ae, watch as b, watchEffect as oe, withCtx as x } from "vue";
11
- import { ScalarCard as S, ScalarCardFooter as se, ScalarCardHeader as ce, ScalarCardSection as C } from "@scalar/components/card";
12
- import { ScalarCodeBlock as le, ScalarCodeBlockCopy as ue } from "@scalar/components/code-block";
13
- import { resolveCredentialPlaceholders as de } from "@scalar/workspace-store/request-example";
14
- import { ScalarButton as w } from "@scalar/components/button";
15
- import { ScalarIconCaretDown as fe } from "@scalar/icons";
16
- import { getResolvedRef as pe } from "@scalar/workspace-store/helpers/get-resolved-ref";
17
- import { ScalarCombobox as me } from "@scalar/components/combobox";
18
- import { ScalarVirtualText as he } from "@scalar/components/virtual-text";
19
- import { freezeElement as ge } from "@scalar/helpers/dom/freeze-element";
20
- import { getOperationExamples as _e, resolveOperationExamples as ve } from "@scalar/workspace-store/helpers/operation-examples";
21
- import { useExampleVisibility as T, useExternalExamples as ye } from "@scalar/workspace-store/helpers/use-external-examples";
22
- //#region src/code-example/components/CodeExample.vue?vue&type=script&setup=true&lang.ts
6
+ import { getSecrets as ne } from "../helpers/get-secrets.js";
7
+ import { operationToHar as re } from "../helpers/operation-to-har/operation-to-har.js";
8
+ import ie from "./ExamplePicker.vue.js";
9
+ import r from "./HttpMethod.vue.js";
10
+ import { Fragment as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createSlots as ae, createTextVNode as u, createVNode as d, defineComponent as f, normalizeClass as p, openBlock as m, ref as h, renderSlot as g, toDisplayString as _, unref as v, useId as oe, watch as y, watchEffect as se, withCtx as b } from "vue";
11
+ import { ScalarCard as x, ScalarCardFooter as ce, ScalarCardHeader as le, ScalarCardSection as S } from "@scalar/components/card";
12
+ import { ScalarCodeBlock as ue, ScalarCodeBlockCopy as de } from "@scalar/components/code-block";
13
+ import { resolveCredentialPlaceholders as fe } from "@scalar/workspace-store/request-example";
14
+ import { ScalarButton as C } from "@scalar/components/button";
15
+ import { ScalarIconCaretDown as pe } from "@scalar/icons";
16
+ import { getResolvedRef as me } from "@scalar/workspace-store/helpers/get-resolved-ref";
17
+ import { ScalarCombobox as he } from "@scalar/components/combobox";
18
+ import { ScalarVirtualText as ge } from "@scalar/components/virtual-text";
19
+ import { freezeElement as _e } from "@scalar/helpers/dom/freeze-element";
20
+ import { getOperationExamples as ve, resolveOperationExamples as ye } from "@scalar/workspace-store/helpers/operation-examples";
21
+ import { useExampleVisibility as w, useExternalExamples as T } from "@scalar/workspace-store/helpers/use-external-examples";
22
+ // src/code-example/components/CodeExample.vue?vue&type=script&setup=true&lang.ts
23
23
  var E = ["innerHTML"], D = {
24
24
  key: 1,
25
25
  class: "text-c-2 flex h-full w-fit items-center px-0.5 py-0 text-base font-normal",
@@ -41,7 +41,7 @@ var E = ["innerHTML"], D = {
41
41
  }, N = { class: "request-header" }, P = {
42
42
  key: 0,
43
43
  class: "request-card-actions relative max-w-full"
44
- }, F = /*@__PURE__*/ p({
44
+ }, F = /*@__PURE__*/ f({
45
45
  __name: "CodeExample",
46
46
  props: {
47
47
  codeSampleUnavailable: { default: "No code sample available for this example." },
@@ -64,117 +64,120 @@ var E = ["innerHTML"], D = {
64
64
  isWebhook: { type: Boolean },
65
65
  globalCookies: {},
66
66
  openapiVersion: {},
67
+ jsonSchemaDialect: {},
67
68
  requestBodyCompositionSelection: {}
68
69
  },
69
70
  emits: ["update:exampleKey"],
70
- setup(p, { emit: F }) {
71
- let be = F, I = o(() => {
72
- let e = pe(p.operation.requestBody)?.content ?? {}, t = p.selectedContentType || Object.keys(e)[0];
71
+ setup(f, { emit: F }) {
72
+ let be = F, I = a(() => {
73
+ let e = me(f.operation.requestBody)?.content ?? {}, t = f.selectedContentType || Object.keys(e)[0];
73
74
  return t ? e[t]?.examples ?? {} : {};
74
- }), L = g(""), R = (e) => {
75
+ }), L = h(""), R = (e) => {
75
76
  let t = Object.keys(I.value);
76
77
  return e && t.includes(e) ? e : L.value && t.includes(L.value) ? L.value : t[0] ?? "";
77
78
  };
78
- L.value = R(p.selectedExample), b(() => p.selectedExample, (e) => {
79
+ L.value = R(f.selectedExample), y(() => f.selectedExample, (e) => {
79
80
  L.value = R(e);
80
- }), b(() => p.selectedContentType, () => {
81
- Object.keys(I.value).includes(L.value) || (L.value = R(p.selectedExample));
82
- }), oe(() => {
81
+ }), y(() => f.selectedContentType, () => {
82
+ Object.keys(I.value).includes(L.value) || (L.value = R(f.selectedExample));
83
+ }), se(() => {
83
84
  be("update:exampleKey", L.value);
84
85
  });
85
86
  let xe = (e) => {
86
- L.value = e, p.eventBus.emit("workspace:update:selected-example", e);
87
- }, z = o(() => te(p.operation)), B = o(() => ne(z.value.samples, p.clientOptions, z.value.label)), V = o(() => B.value.reduce((e, t) => e + t.options.length, 0)), H = g(n(B.value, p.selectedClient));
88
- b([() => p.selectedClient, B], ([e]) => {
89
- let t = n(B.value, e);
90
- t && (H.value = t);
87
+ L.value = e, f.eventBus.emit("workspace:update:selected-example", e);
88
+ }, z = a(() => te(f.operation)), B = a(() => ee(z.value.samples, f.clientOptions, z.value.label)), V = a(() => B.value.reduce((e, t) => e + t.options.length, 0)), H = h(t(B.value, f.selectedClient));
89
+ y([() => f.selectedClient, B], ([e]) => {
90
+ let n = t(B.value, e);
91
+ n && (H.value = n);
91
92
  });
92
- let Se = o(() => [p.clientPickerLabel, H.value?.title].filter(Boolean).join(": ")), Ce = o(() => [p.codeSampleLabel, H.value?.title].filter(Boolean).join(": ")), U = g(null), we = T(U), W = ye(() => _e(p.operation, L.value, p.selectedContentType), () => we.value), G = o(() => ve(p.operation, L.value, p.selectedContentType, W.resolve)), K = o(() => Object.keys(I.value).length > 1), q = o(() => {
93
- if (!p.isWebhook) return null;
93
+ let Se = a(() => [f.clientPickerLabel, H.value?.title].filter(Boolean).join(": ")), Ce = a(() => [f.codeSampleLabel, H.value?.title].filter(Boolean).join(": ")), U = h(null), we = w(U), W = T(() => ve(f.operation, L.value, f.selectedContentType), () => we.value), G = a(() => ye(f.operation, L.value, f.selectedContentType, W.resolve)), K = a(() => Object.keys(I.value).length > 1), q = a(() => {
94
+ if (!f.isWebhook) return null;
94
95
  try {
95
- return r({
96
+ return re({
96
97
  operation: G.value,
97
- method: p.method,
98
- path: p.path,
98
+ method: f.method,
99
+ path: f.path,
99
100
  example: L.value,
100
- openapiVersion: p.openapiVersion,
101
- requestBodyCompositionSelection: p.requestBodyCompositionSelection,
101
+ openapiVersion: f.openapiVersion,
102
+ jsonSchemaDialect: f.jsonSchemaDialect,
103
+ requestBodyCompositionSelection: f.requestBodyCompositionSelection,
102
104
  defaultDisabledParameters: !0
103
105
  });
104
106
  } catch (e) {
105
107
  return console.error("[webhookHar]", e), null;
106
108
  }
107
- }), J = o(() => p.isWebhook ? q.value?.postData?.text ?? "" : ee({
109
+ }), J = a(() => f.isWebhook ? q.value?.postData?.text ?? "" : n({
108
110
  defaultDisabledParameters: !0,
109
- includeDefaultHeaders: p.integration === "client",
111
+ includeDefaultHeaders: f.integration === "client",
110
112
  clientId: H.value?.id,
111
113
  customCodeSamples: z.value.samples,
112
114
  operation: G.value,
113
- method: p.method,
114
- path: p.path,
115
- contentType: p.selectedContentType,
116
- server: p.selectedServer,
117
- securitySchemes: p.securitySchemes,
115
+ method: f.method,
116
+ path: f.path,
117
+ contentType: f.selectedContentType,
118
+ server: f.selectedServer,
119
+ securitySchemes: f.securitySchemes,
118
120
  example: L.value,
119
- globalCookies: p.globalCookies,
120
- openapiVersion: p.openapiVersion,
121
- requestBodyCompositionSelection: p.requestBodyCompositionSelection
122
- })), Y = o(() => !p.isWebhook && H.value?.id.startsWith("custom/") && J.value !== null && p.securitySchemes.some((e) => "x-scalar-credential-placeholders" in e) ? de(J.value, p.securitySchemes) : void 0), X = o(() => Y.value?.content ?? J.value), Z = o(() => Y.value?.displayContent ?? X.value), Q = o(() => p.isWebhook ? Te.value : H.value?.lang), Te = o(() => {
121
+ globalCookies: f.globalCookies,
122
+ openapiVersion: f.openapiVersion,
123
+ jsonSchemaDialect: f.jsonSchemaDialect,
124
+ requestBodyCompositionSelection: f.requestBodyCompositionSelection
125
+ })), Y = a(() => !f.isWebhook && H.value?.id.startsWith("custom/") && J.value !== null && f.securitySchemes.some((e) => "x-scalar-credential-placeholders" in e) ? fe(J.value, f.securitySchemes) : void 0), X = a(() => Y.value?.content ?? J.value), Z = a(() => Y.value?.displayContent ?? X.value), Q = a(() => f.isWebhook ? Te.value : H.value?.lang), Te = a(() => {
123
126
  if (!q.value?.postData) return "json";
124
127
  let e = q.value.postData.mimeType;
125
128
  return e?.includes("json") ? "json" : e?.includes("xml") ? "xml" : e?.includes("yaml") || e?.includes("yml") ? "yaml" : e?.includes("text/plain") ? "text" : "json";
126
- }), Ee = o(() => Y.value ? [] : re(p.securitySchemes)), De = (e) => {
129
+ }), Ee = a(() => Y.value ? [] : ne(f.securitySchemes)), De = (e) => {
127
130
  if (U.value) {
128
- let e = ge(U.value.$el);
131
+ let e = _e(U.value.$el);
129
132
  setTimeout(() => {
130
133
  e();
131
134
  }, 300);
132
135
  }
133
- H.value = e, e && p.eventBus.emit("workspace:update:selected-client", e.id);
134
- }, Oe = o(() => (X.value?.length ?? 0) > 2e4), $ = ae();
135
- return (n, r) => X.value === null || X.value || y(W).pending.value ? (h(), s(y(S), {
136
+ H.value = e, e && f.eventBus.emit("workspace:update:selected-client", e.id);
137
+ }, Oe = a(() => (X.value?.length ?? 0) > 2e4), $ = oe();
138
+ return (t, n) => X.value === null || X.value || v(W).pending.value ? (m(), o(v(x), {
136
139
  key: 0,
137
140
  ref_key: "elem",
138
141
  ref: U,
139
142
  class: "request-card dark-mode"
140
143
  }, {
141
- default: x(() => [
142
- f(y(ce), { class: "pr-2.5" }, ie({
143
- default: x(() => [
144
- r[1] ||= u("span", { class: "sr-only" }, "Request Example for", -1),
145
- f(i, {
144
+ default: b(() => [
145
+ d(v(le), { class: "pr-2.5" }, ae({
146
+ default: b(() => [
147
+ n[1] ||= l("span", { class: "sr-only" }, "Request Example for", -1),
148
+ d(r, {
146
149
  as: "span",
147
150
  class: "request-method",
148
- method: p.method
151
+ method: f.method
149
152
  }, null, 8, ["method"]),
150
- p.generateLabel ? (h(), l("span", {
153
+ f.generateLabel ? (m(), c("span", {
151
154
  key: 0,
152
- innerHTML: p.generateLabel()
153
- }, null, 8, E)) : c("", !0),
154
- _(n.$slots, "header", {}, void 0, !0)
155
+ innerHTML: f.generateLabel()
156
+ }, null, 8, E)) : s("", !0),
157
+ g(t.$slots, "header", {}, void 0, !0)
155
158
  ]),
156
159
  _: 2
157
- }, [!p.isWebhook && V.value ? {
160
+ }, [!f.isWebhook && V.value ? {
158
161
  name: "actions",
159
- fn: x(() => [V.value > 1 ? (h(), s(y(me), {
162
+ fn: b(() => [V.value > 1 ? (m(), o(v(he), {
160
163
  key: 0,
161
164
  class: "max-h-80",
162
- filterFn: y(t),
163
- inputLabel: p.clientSearchLabel,
165
+ filterFn: v(e),
166
+ inputLabel: f.clientSearchLabel,
164
167
  modelValue: H.value,
165
168
  options: B.value,
166
169
  placement: "bottom-end",
167
170
  teleport: "",
168
- "onUpdate:modelValue": r[0] ||= (e) => De(e)
171
+ "onUpdate:modelValue": n[0] ||= (e) => De(e)
169
172
  }, {
170
- default: x(({ open: e }) => [f(y(w), {
173
+ default: b(({ open: e }) => [d(v(C), {
171
174
  "aria-label": Se.value,
172
175
  class: "text-c-2 hover:text-c-1 flex h-full w-fit gap-1.5 px-0.5 py-0 text-base font-normal",
173
176
  "data-testid": "client-picker",
174
177
  variant: "ghost"
175
178
  }, {
176
- default: x(() => [d(v(H.value?.title) + " ", 1), f(y(fe), {
177
- class: m(["mt-px size-3 transition-transform duration-100", { "rotate-180": e }]),
179
+ default: b(() => [u(_(H.value?.title) + " ", 1), d(v(pe), {
180
+ class: p(["mt-px size-3 transition-transform duration-100", { "rotate-180": e }]),
178
181
  weight: "bold"
179
182
  }, null, 8, ["class"])]),
180
183
  _: 2
@@ -185,23 +188,23 @@ var E = ["innerHTML"], D = {
185
188
  "inputLabel",
186
189
  "modelValue",
187
190
  "options"
188
- ])) : (h(), l("span", D, v(H.value?.title), 1))]),
191
+ ])) : (m(), c("span", D, _(H.value?.title), 1))]),
189
192
  key: "0"
190
193
  } : void 0]), 1024),
191
- f(y(C), { class: "request-editor-section custom-scroll p-0" }, {
192
- default: x(() => [y(W).pending.value ? (h(), l("div", O, [y(W).failed.value ? (h(), l(a, { key: 0 }, [r[3] ||= d(" Could not load this example. ", -1), f(y(w), {
194
+ d(v(S), { class: "request-editor-section custom-scroll p-0" }, {
195
+ default: b(() => [v(W).pending.value ? (m(), c("div", O, [v(W).failed.value ? (m(), c(i, { key: 0 }, [n[3] ||= u(" Could not load this example. ", -1), d(v(C), {
193
196
  size: "sm",
194
197
  variant: "ghost",
195
- onClick: y(W).retry
198
+ onClick: v(W).retry
196
199
  }, {
197
- default: x(() => [...r[2] ||= [d(" Retry ", -1)]]),
200
+ default: b(() => [...n[2] ||= [u(" Retry ", -1)]]),
198
201
  _: 1
199
- }, 8, ["onClick"])], 64)) : (h(), l(a, { key: 1 }, [d("Loading example…")], 64))])) : X.value === null ? (h(), l("div", k, v(p.codeSampleUnavailable), 1)) : (h(), l("div", {
202
+ }, 8, ["onClick"])], 64)) : (m(), c(i, { key: 1 }, [u("Loading example…")], 64))])) : X.value === null ? (m(), c("div", k, _(f.codeSampleUnavailable), 1)) : (m(), c("div", {
200
203
  key: 2,
201
- id: `${y($)}-example`,
204
+ id: `${v($)}-example`,
202
205
  class: "code-snippet group/code-block relative"
203
- }, [Oe.value ? (h(), l(a, { key: 1 }, [f(y(ue), {
204
- "aria-controls": `${y($)}-virtual-code`,
206
+ }, [Oe.value ? (m(), c(i, { key: 1 }, [d(v(de), {
207
+ "aria-controls": `${v($)}-virtual-code`,
205
208
  class: "scalar-code-copy absolute top-2.5 right-2.5 z-1",
206
209
  content: X.value,
207
210
  lang: Q.value
@@ -209,15 +212,15 @@ var E = ["innerHTML"], D = {
209
212
  "aria-controls",
210
213
  "content",
211
214
  "lang"
212
- ]), f(y(he), {
213
- id: `${y($)}-virtual-code`,
215
+ ]), d(v(ge), {
216
+ id: `${v($)}-virtual-code`,
214
217
  "aria-label": "Request code sample",
215
218
  containerClass: "custom-scroll scalar-code-block flex flex-1 max-h-screen",
216
219
  contentClass: "language-plaintext whitespace-pre font-code text-base p-2",
217
220
  lineHeight: 20,
218
221
  role: "region",
219
222
  text: Z.value ?? ""
220
- }, null, 8, ["id", "text"])], 64)) : (h(), s(y(le), {
223
+ }, null, 8, ["id", "text"])], 64)) : (m(), o(v(ue), {
221
224
  key: 0,
222
225
  class: "h-full bg-transparent",
223
226
  content: Z.value ?? "",
@@ -235,37 +238,36 @@ var E = ["innerHTML"], D = {
235
238
  ]))], 8, A))]),
236
239
  _: 1
237
240
  }),
238
- K.value || n.$slots.footer || n.$slots["footer-start"] ? (h(), s(y(se), {
241
+ K.value || t.$slots.footer || t.$slots["footer-start"] ? (m(), o(v(ce), {
239
242
  key: 0,
240
- class: m(["request-card-footer", { "request-card-footer--wraps": K.value || n.$slots["footer-start"] }])
243
+ class: p(["request-card-footer", { "request-card-footer--wraps": K.value || t.$slots["footer-start"] }])
241
244
  }, {
242
- default: x(() => [K.value ? (h(), l("div", j, [Object.keys(I.value).length ? (h(), s(e, {
245
+ default: b(() => [K.value ? (m(), c("div", j, [Object.keys(I.value).length ? (m(), o(ie, {
243
246
  key: 0,
244
247
  examples: I.value,
245
248
  modelValue: L.value,
246
249
  "onUpdate:modelValue": xe
247
- }, null, 8, ["examples", "modelValue"])) : c("", !0)])) : n.$slots["footer-start"] ? (h(), l("div", M, [_(n.$slots, "footer-start", {}, void 0, !0)])) : c("", !0), _(n.$slots, "footer", { exampleName: L.value }, void 0, !0)]),
250
+ }, null, 8, ["examples", "modelValue"])) : s("", !0)])) : t.$slots["footer-start"] ? (m(), c("div", M, [g(t.$slots, "footer-start", {}, void 0, !0)])) : s("", !0), g(t.$slots, "footer", { exampleName: L.value }, void 0, !0)]),
248
251
  _: 3
249
- }, 8, ["class"])) : c("", !0)
252
+ }, 8, ["class"])) : s("", !0)
250
253
  ]),
251
254
  _: 3
252
- }, 512)) : p.fallback ? (h(), s(y(S), {
255
+ }, 512)) : f.fallback ? (m(), o(v(x), {
253
256
  key: 1,
254
257
  class: "request-card dark-mode"
255
258
  }, {
256
- default: x(() => [f(y(C), { class: "request-card-simple bg-transparent shadow-none" }, {
257
- default: x(() => [u("div", N, [f(i, {
259
+ default: b(() => [d(v(S), { class: "request-card-simple bg-transparent shadow-none" }, {
260
+ default: b(() => [l("div", N, [d(r, {
258
261
  as: "span",
259
262
  class: "request-method",
260
- method: p.method
261
- }, null, 8, ["method"]), _(n.$slots, "header", {}, void 0, !0)]), n.$slots.footer ? (h(), l("div", P, [_(n.$slots, "footer", { exampleName: L.value }, void 0, !0)])) : c("", !0)]),
263
+ method: f.method
264
+ }, null, 8, ["method"]), g(t.$slots, "header", {}, void 0, !0)]), t.$slots.footer ? (m(), c("div", P, [g(t.$slots, "footer", { exampleName: L.value }, void 0, !0)])) : s("", !0)]),
262
265
  _: 3
263
266
  })]),
264
267
  _: 3
265
- })) : c("", !0);
268
+ })) : s("", !0);
266
269
  }
267
270
  });
268
- //#endregion
269
271
  export { F as default };
270
272
 
271
273
  //# sourceMappingURL=CodeExample.vue_vue_type_script_setup_true_lang.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeExample.vue_vue_type_script_setup_true_lang.js","names":["$slots","_unref","_openBlock","_createBlock","_withCtx","_createVNode","_createSlots","_createElementVNode","HttpMethod","_createElementBlock","_createCommentVNode","_renderSlot","_createTextVNode","_toDisplayString","_normalizeClass","_Fragment","ExamplePicker","ExamplePicker_default","HttpMethod_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","CodeExample_vue_vue_type_script_setup_true_lang_default","__emit","emit","requestBodyExamples","computed","content","getResolvedRef","__props","contentType","localExampleKey","ref","resolveExampleKey","keys","preferred","watch","watchEffect","selectExample","key","customCodeSamples","getCustomCodeSamples","clients","getClients","clientCount","total","group","localSelectedClient","findClient","newClient","client","clientPickerAriaLabel","codeSampleAriaLabel","elem","visible","useExampleVisibility","externalExamples","useExternalExamples","getOperationExamples","resolvedOperation","resolveOperationExamples","showExamplePicker","webhookHar","operationToHar","error","generatedTemplate","generateCodeSnippet","resolvedCredentials","scheme","resolveCredentialPlaceholders","generatedCode","displayCode","codeBlockLanguage","webhookLanguage","secretCredentials","getSecrets","selectClient","unfreeze","freezeElement","option","shouldVirtualize","id","useId","unref","openBlock","createBlock","ScalarCard","withCtx","createVNode","ScalarCardHeader","createSlots","_cache","createElementVNode","createElementBlock","createCommentVNode","renderSlot","_ctx","ScalarCombobox","filterClientsByQuery","$event","ScalarButton","createTextVNode","toDisplayString","ScalarIconCaretDown","normalizeClass","open","ScalarCardSection","Fragment","ScalarCodeBlockCopy","ScalarVirtualText","ScalarCodeBlock","ScalarCardFooter"],"sources":["../../../src/code-example/components/CodeExample.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type CodeExampleProps = {\n /** Localized status text shown when the selected example has no linked code sample. */\n codeSampleUnavailable?: string\n /**\n * Localized purpose of the client picker. It opens the button's accessible name and the\n * selected client's title is appended, so the name still contains the visible label.\n */\n clientPickerLabel?: string\n /** Localized accessible name for the search field inside the client picker. */\n clientSearchLabel?: string\n /**\n * Localized accessible name for the focusable code sample. The selected client's title is\n * appended so the announcement also says which language the sample is in.\n */\n codeSampleLabel?: string\n /**\n * Integration type: determines if the code sample is displayed in a client environment\n * or in an API reference environment.\n */\n integration?: 'client' | 'reference'\n /**\n * List of all http clients formatted into option groups for the client selector\n */\n clientOptions: ClientOptionGroup[]\n /**\n * Pre-selected client, this will determine which client is initially selected in the dropdown.\n * Either a built-in client id (e.g. `js/fetch`) or a custom sample id (e.g. `custom/python`).\n *\n * Typed as a plain string: unioning the (large) client-id union with the `custom/...`\n * ids overflows TypeScript's union-complexity limit inside this component's `defineProps`.\n *\n * @defaults to a custom sample if one is available, otherwise shell/curl\n */\n selectedClient?: string\n /**\n * Which server from the spec to use for the code example\n */\n selectedServer?: ServerObject | null\n /**\n * The selected content type from the requestBody.content, this will determine which examples are available\n * as well as the content type of the code example\n *\n * @defaults to the first content type if not provided\n */\n selectedContentType?: string\n /**\n * Example name to use for resolving example values for parameters AND requestBody.\n *\n * This is the document-wide selection: it is honored only when this operation defines an example\n * with the same key, so picking an example on one operation syncs the rest without blanking out\n * operations that do not share that key.\n *\n * @example \"limited\"\n * ```ts\n * parameters: {\n * name: 'foobar',\n * in: 'query',\n * examples: {\n * limited: {\n * dataValue: 10,\n * }\n * }\n * },\n * body: {\n * content: {\n * 'application/json': {\n * examples: {\n * limited: {\n * dataValue: { foo: 'bar' },\n * }\n * }\n * }\n * }\n * }\n *\n * ```\n */\n selectedExample?: string\n /**\n * Event bus\n */\n eventBus: WorkspaceEventBus\n /**\n * The security schemes which are applicable to this operation\n */\n securitySchemes: SecuritySchemeObjectSecret[]\n /**\n * HTTP method of the operation\n */\n method: string\n /**\n * Path of the operation\n */\n path: string\n /**\n * De-referenced OpenAPI Operation object\n */\n operation: OperationObject\n /**\n * If true and there's no example, we will display a small card with the method and path only\n */\n fallback?: boolean\n /**\n * A method to generate the label of the block, should return an html string\n */\n generateLabel?: () => string\n /**\n * If true, render this as a webhook request example\n */\n isWebhook?: boolean\n /**\n * Workspace + document cookies\n */\n globalCookies?: XScalarCookie[]\n /**\n * When the request body schema uses oneOf/anyOf, use these selected variants\n * for the example snippet (e.g. from the schema dropdowns in the API reference).\n */\n /** Originating OpenAPI version, used for XML mapping rules. */\n openapiVersion?: string\n requestBodyCompositionSelection?: Record<string, number>\n}\n\n/**\n * Request Example\n *\n * The core component for rendering a request example block,\n * this component does not have much of its own state but operates on props and custom events\n *\n * @event workspace:update:selected-client - Emitted when the selected client changes\n * @event workspace:update:selected-example - Emitted when the selected example changes, so other operations can sync\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarCard,\n ScalarCardFooter,\n ScalarCardHeader,\n ScalarCardSection,\n} from '@scalar/components/card'\nimport {\n ScalarCodeBlock,\n ScalarCodeBlockCopy,\n} from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarVirtualText } from '@scalar/components/virtual-text'\nimport { freezeElement } from '@scalar/helpers/dom/freeze-element'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport { type WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getOperationExamples,\n resolveOperationExamples,\n} from '@scalar/workspace-store/helpers/operation-examples'\nimport {\n useExampleVisibility,\n useExternalExamples,\n} from '@scalar/workspace-store/helpers/use-external-examples'\nimport {\n resolveCredentialPlaceholders,\n type SecuritySchemeObjectSecret,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OperationObject,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport {\n computed,\n ref,\n useId,\n watch,\n watchEffect,\n type ComponentPublicInstance,\n} from 'vue'\n\nimport { filterClientsByQuery } from '../helpers/filter-clients-by-query'\nimport { findClient } from '../helpers/find-client'\nimport { generateCodeSnippet } from '../helpers/generate-code-snippet'\nimport { getClients } from '../helpers/get-clients'\nimport { getCustomCodeSamples } from '../helpers/get-custom-code-samples'\nimport { getSecrets } from '../helpers/get-secrets'\nimport { operationToHar } from '../helpers/operation-to-har/operation-to-har'\nimport type {\n ClientOption,\n ClientOptionGroup,\n CustomClientOption,\n} from '../types'\nimport ExamplePicker from './ExamplePicker.vue'\nimport HttpMethod from './HttpMethod.vue'\n\nconst {\n integration,\n codeSampleUnavailable = 'No code sample available for this example.',\n clientPickerLabel = 'Change code sample language',\n clientSearchLabel = 'Search clients',\n codeSampleLabel = 'Code sample',\n clientOptions,\n selectedClient,\n selectedServer = null,\n selectedContentType,\n selectedExample,\n securitySchemes = [],\n method,\n eventBus,\n path,\n operation,\n isWebhook,\n generateLabel,\n globalCookies,\n openapiVersion,\n requestBodyCompositionSelection,\n} = defineProps<CodeExampleProps>()\n\nconst emit = defineEmits<{\n /**\n * Emitted whenever the example key actually shown for this operation changes.\n *\n * This is the resolved local key (not the raw document-wide selection), so layouts that render\n * the test-request button outside this component can open the client with the same example the\n * snippet displays.\n */\n (e: 'update:exampleKey', value: string): void\n}>()\n\ndefineSlots<{\n 'header': () => unknown\n /** Rendered at the start of the footer, only while the example picker does not need that space */\n 'footer-start'?: () => unknown\n 'footer': ({ exampleName }: { exampleName: string }) => unknown\n}>()\n\n/** Grab the examples for the given content type */\nconst requestBodyExamples = computed(() => {\n const content = getResolvedRef(operation.requestBody)?.content ?? {}\n const contentType = selectedContentType || Object.keys(content)[0]\n if (!contentType) return {}\n\n const examples = content[contentType]?.examples ?? {}\n\n return examples\n})\n\n/**\n * The example key actually shown for this operation.\n *\n * `selectedExample` is the document-wide selection that syncs across operations. We honor it only\n * when this operation actually defines that key, otherwise we keep the local example: a selection\n * on one operation should never blank out an operation that does not share the same example.\n */\nconst localExampleKey = ref('')\n\n/** Resolve the key to display, preferring the document-wide selection when this operation has it */\nconst resolveExampleKey = (preferred: string | undefined): string => {\n const keys = Object.keys(requestBodyExamples.value)\n if (preferred && keys.includes(preferred)) {\n return preferred\n }\n // Keep the current local example when it is still valid, otherwise fall back to the first one\n if (localExampleKey.value && keys.includes(localExampleKey.value)) {\n return localExampleKey.value\n }\n return keys[0] ?? ''\n}\n\n// Set the initial example from the document-wide selection, falling back to the first example.\n// This runs during setup so the server renders the same example as the browser.\nlocalExampleKey.value = resolveExampleKey(selectedExample)\n\n// Follow the document-wide selection when it changes and this operation has that example\nwatch(\n () => selectedExample,\n (preferred) => {\n localExampleKey.value = resolveExampleKey(preferred)\n },\n)\n\n/** Reset the selected example key if the content type changes and the new content type doesn't have the previously selected example */\nwatch(\n () => selectedContentType,\n () => {\n if (\n !Object.keys(requestBodyExamples.value).includes(localExampleKey.value)\n ) {\n // Re-resolve so the new content type still follows the document-wide selection when it has\n // that key, instead of always snapping back to the first example\n localExampleKey.value = resolveExampleKey(selectedExample)\n }\n },\n)\n\n// Keep the parent informed of the resolved key so a test-request button rendered outside this\n// component (e.g. the classic layout header) opens the client with the example the snippet shows\nwatchEffect(() => {\n emit('update:exampleKey', localExampleKey.value)\n})\n\n/** Select an example locally and sync the choice across the document */\nconst selectExample = (key: string) => {\n localExampleKey.value = key\n eventBus.emit('workspace:update:selected-example', key)\n}\n\n/** Grab any custom code samples from the operation */\nconst customCodeSamples = computed(() => getCustomCodeSamples(operation))\n\n/** Merge custom code samples with the client options */\nconst clients = computed(() =>\n getClients(\n customCodeSamples.value.samples,\n clientOptions,\n customCodeSamples.value.label,\n ),\n)\n\n/** Total number of available clients across all option groups */\nconst clientCount = computed(() =>\n clients.value.reduce((total, group) => total + group.options.length, 0),\n)\n\n/** The locally selected client which would include code samples from this operation only */\nconst localSelectedClient = ref<ClientOption | CustomClientOption | undefined>(\n findClient(clients.value, selectedClient),\n)\n\n/**\n * Re-resolve the local client whenever the global selection or the available\n * clients change. Watching `clients` matters when navigating between operations:\n * the stored id stays the same, but the matching option (e.g. a custom sample)\n * differs per operation, so without this the snippet could go stale.\n */\nwatch([() => selectedClient, clients], ([newClient]) => {\n const client = findClient(clients.value, newClient)\n if (client) {\n localSelectedClient.value = client\n }\n})\n\n/**\n * Accessible name for the client picker.\n *\n * On its own the button reads as its current value (\"C Libcurl\"), which never\n * says what activating it does. The visible title stays part of the name so it\n * still matches what is on screen.\n */\nconst clientPickerAriaLabel = computed(() =>\n [clientPickerLabel, localSelectedClient.value?.title]\n .filter(Boolean)\n .join(': '),\n)\n\n/**\n * Accessible name for the focusable code sample, e.g. \"Code sample: Shell cURL\".\n *\n * Screen readers announce only the name and role when focus lands on the scroller, so the\n * name tells the user both what the region is and which client it is generated for.\n */\nconst codeSampleAriaLabel = computed(() =>\n [codeSampleLabel, localSelectedClient.value?.title]\n .filter(Boolean)\n .join(': '),\n)\n\nconst elem = ref<ComponentPublicInstance | null>(null)\nconst visible = useExampleVisibility(elem)\nconst externalExamples = useExternalExamples(\n () =>\n getOperationExamples(operation, localExampleKey.value, selectedContentType),\n () => visible.value,\n)\nconst resolvedOperation = computed(() =>\n resolveOperationExamples(\n operation,\n localExampleKey.value,\n selectedContentType,\n externalExamples.resolve,\n ),\n)\n\n/** Keep the picker available because it also selects the example opened by Test Request. */\nconst showExamplePicker = computed(\n () => Object.keys(requestBodyExamples.value).length > 1,\n)\n\n/** Generate HAR data for webhook requests */\nconst webhookHar = computed(() => {\n if (!isWebhook) return null\n\n try {\n return operationToHar({\n operation: resolvedOperation.value,\n method,\n path,\n example: localExampleKey.value,\n openapiVersion,\n requestBodyCompositionSelection,\n // Only required parameters are shown in code examples; optional parameters\n // are omitted unless explicitly enabled via `x-disabled: false`.\n defaultDisabledParameters: true,\n })\n } catch (error) {\n console.error('[webhookHar]', error)\n return null\n }\n})\n\n/** Generate the code snippet for the selected example */\nconst generatedTemplate = computed<string | null>(() => {\n if (isWebhook) {\n return webhookHar.value?.postData?.text ?? ''\n }\n\n return generateCodeSnippet({\n // Only required parameters are shown in code examples; optional parameters\n // are omitted unless explicitly enabled via `x-disabled: false`.\n defaultDisabledParameters: true,\n includeDefaultHeaders: integration === 'client',\n clientId: localSelectedClient.value?.id,\n customCodeSamples: customCodeSamples.value.samples,\n operation: resolvedOperation.value,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: localExampleKey.value,\n globalCookies,\n openapiVersion,\n requestBodyCompositionSelection,\n })\n})\n\n/** Resolve custom templates at render time so auth changes never mutate the document. */\nconst resolvedCredentials = computed(() =>\n !isWebhook &&\n localSelectedClient.value?.id.startsWith('custom/') &&\n generatedTemplate.value !== null &&\n securitySchemes.some((scheme) => 'x-scalar-credential-placeholders' in scheme)\n ? resolveCredentialPlaceholders(generatedTemplate.value, securitySchemes)\n : undefined,\n)\n\nconst generatedCode = computed(\n () => resolvedCredentials.value?.content ?? generatedTemplate.value,\n)\n\n/** Mask inserted secrets before escaping or syntax tokenization can split their values. */\nconst displayCode = computed(\n () => resolvedCredentials.value?.displayContent ?? generatedCode.value,\n)\n\n/** The language for the code block, used for syntax highlighting */\nconst codeBlockLanguage = computed(() => {\n if (isWebhook) {\n return webhookLanguage.value\n }\n\n return localSelectedClient.value?.lang\n})\n\n/** Determine the language for webhook content based on MIME type */\nconst webhookLanguage = computed<string>(() => {\n if (!webhookHar.value?.postData) return 'json'\n\n const contentType = webhookHar.value.postData.mimeType\n if (contentType?.includes('json')) return 'json'\n if (contentType?.includes('xml')) return 'xml'\n if (contentType?.includes('yaml') || contentType?.includes('yml'))\n return 'yaml'\n if (contentType?.includes('text/plain')) return 'text'\n\n return 'json'\n})\n\n/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() =>\n resolvedCredentials.value ? [] : getSecrets(securitySchemes),\n)\n\n/** Set custom example, or update the selected HTTP client globally */\nconst selectClient = (option: ClientOption) => {\n // We need to freeze the ui to prevent scrolling as the clients change\n if (elem.value) {\n const unfreeze = freezeElement(elem.value.$el)\n setTimeout(() => {\n unfreeze()\n }, 300)\n }\n // Update to the local example\n localSelectedClient.value = option\n\n // Sync the selection globally so other operations follow along. Custom samples\n // sync too (keyed by language), so picking e.g. the Python SDK example here\n // shows the Python example on every operation that ships one.\n if (option) {\n eventBus.emit('workspace:update:selected-client', option.id)\n }\n}\n\n// Virtualize the code block if it's too large\n// This prevents the entire app from freezing up if there's a massive example\n// We set a lower threshold here as code examples can get quite large\nconst VIRTUALIZATION_THRESHOLD = 20_000\n\nconst shouldVirtualize = computed(\n () => (generatedCode.value?.length ?? 0) > VIRTUALIZATION_THRESHOLD,\n)\n\nconst id = useId()\n</script>\n<template>\n <ScalarCard\n v-if=\"\n generatedCode === null || generatedCode || externalExamples.pending.value\n \"\n ref=\"elem\"\n class=\"request-card dark-mode\">\n <!-- Header -->\n <ScalarCardHeader class=\"pr-2.5\">\n <span class=\"sr-only\">Request Example for</span>\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <span\n v-if=\"generateLabel\"\n v-html=\"generateLabel()\" />\n <slot name=\"header\" />\n <!-- Client picker -->\n <template\n v-if=\"!isWebhook && clientCount\"\n #actions>\n <!-- Multiple clients: render a dropdown to switch between them -->\n <ScalarCombobox\n v-if=\"clientCount > 1\"\n v-slot=\"{ open }\"\n class=\"max-h-80\"\n :filterFn=\"filterClientsByQuery\"\n :inputLabel=\"clientSearchLabel\"\n :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n teleport\n @update:modelValue=\"selectClient($event as ClientOption)\">\n <ScalarButton\n :aria-label=\"clientPickerAriaLabel\"\n class=\"text-c-2 hover:text-c-1 flex h-full w-fit gap-1.5 px-0.5 py-0 text-base font-normal\"\n data-testid=\"client-picker\"\n variant=\"ghost\">\n {{ localSelectedClient?.title }}\n <!--\n Follow this picker's own state. The `ui-open:` variant also matches any open\n Headless UI ancestor, such as an expanded operation in the classic layout.\n -->\n <ScalarIconCaretDown\n class=\"mt-px size-3 transition-transform duration-100\"\n :class=\"{ 'rotate-180': open }\"\n weight=\"bold\" />\n </ScalarButton>\n </ScalarCombobox>\n <!-- Single client: just show its label, no need for a dropdown -->\n <span\n v-else\n class=\"text-c-2 flex h-full w-fit items-center px-0.5 py-0 text-base font-normal\"\n data-testid=\"client-picker\">\n {{ localSelectedClient?.title }}\n </span>\n </template>\n </ScalarCardHeader>\n\n <!-- Code snippet -->\n <ScalarCardSection class=\"request-editor-section custom-scroll p-0\">\n <div\n v-if=\"externalExamples.pending.value\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n <template v-if=\"externalExamples.failed.value\">\n Could not load this example.\n <ScalarButton\n size=\"sm\"\n variant=\"ghost\"\n @click=\"externalExamples.retry\">\n Retry\n </ScalarButton>\n </template>\n <template v-else>Loading example…</template>\n </div>\n <div\n v-else-if=\"generatedCode === null\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n {{ codeSampleUnavailable }}\n </div>\n <div\n v-else\n :id=\"`${id}-example`\"\n class=\"code-snippet group/code-block relative\">\n <ScalarCodeBlock\n v-if=\"!shouldVirtualize\"\n class=\"h-full bg-transparent\"\n :content=\"displayCode ?? ''\"\n :copyContent=\"resolvedCredentials ? (generatedCode ?? '') : undefined\"\n :hideCredentials=\"secretCredentials\"\n :label=\"codeSampleAriaLabel\"\n :lang=\"codeBlockLanguage\"\n lineNumbers />\n <template v-else>\n <ScalarCodeBlockCopy\n :aria-controls=\"`${id}-virtual-code`\"\n class=\"scalar-code-copy absolute top-2.5 right-2.5 z-1\"\n :content=\"generatedCode\"\n :lang=\"codeBlockLanguage\" />\n <ScalarVirtualText\n :id=\"`${id}-virtual-code`\"\n aria-label=\"Request code sample\"\n containerClass=\"custom-scroll scalar-code-block flex flex-1 max-h-screen\"\n contentClass=\"language-plaintext whitespace-pre font-code text-base p-2\"\n :lineHeight=\"20\"\n role=\"region\"\n :text=\"displayCode ?? ''\" />\n </template>\n </div>\n </ScalarCardSection>\n\n <!-- Footer -->\n <ScalarCardFooter\n v-if=\"showExamplePicker || $slots.footer || $slots['footer-start']\"\n class=\"request-card-footer\"\n :class=\"{\n 'request-card-footer--wraps':\n showExamplePicker || $slots['footer-start'],\n }\">\n <!-- Example picker -->\n <div\n v-if=\"showExamplePicker\"\n class=\"request-card-footer-addon\">\n <template v-if=\"Object.keys(requestBodyExamples).length\">\n <ExamplePicker\n :examples=\"requestBodyExamples\"\n :modelValue=\"localExampleKey\"\n @update:modelValue=\"selectExample\" />\n </template>\n </div>\n <!-- Otherwise the start of the footer is free for the caller -->\n <div\n v-else-if=\"$slots['footer-start']\"\n class=\"request-card-footer-start\">\n <slot name=\"footer-start\" />\n </div>\n\n <!-- Footer -->\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </ScalarCardFooter>\n </ScalarCard>\n\n <!-- Fallback card with just method and path in the case of no examples -->\n <ScalarCard\n v-else-if=\"fallback\"\n class=\"request-card dark-mode\">\n <!-- A single row of method, path and actions reads as a header, so it stays on the card -->\n <ScalarCardSection class=\"request-card-simple bg-transparent shadow-none\">\n <div class=\"request-header\">\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <slot name=\"header\" />\n </div>\n <div\n v-if=\"$slots.footer\"\n class=\"request-card-actions relative max-w-full\">\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </div>\n </ScalarCardSection>\n </ScalarCard>\n</template>\n<style scoped>\n.request-card {\n color: var(--scalar-color-1);\n font-size: var(--scalar-font-size-3);\n}\n.request-method {\n font-family: var(--scalar-font-code);\n margin-right: 6px;\n}\n.request-card-footer {\n display: flex;\n justify-content: flex-end;\n padding: 6px;\n flex-shrink: 0;\n position: relative;\n}\n/*\n * The example picker or footer-start content keeps room for itself; when the footer is too narrow\n * for everything, the end controls wrap onto a second line instead of squeezing or covering it.\n */\n.request-card-footer--wraps {\n flex-wrap: wrap;\n row-gap: 4px;\n}\n.request-card-footer-start {\n display: flex;\n align-items: center;\n flex: 1 0 auto;\n}\n/*\n * The picker asks for its example name's width, capped at 7em (about eight characters), so on a\n * narrow card the end controls wrap rather than squeeze the name out of view. The cap keeps a long\n * name truncating beside them on wider cards, as before. The picker never grows past its name, and\n * the end margin holds it at the start of the line.\n */\n.request-card-footer-addon {\n display: flex;\n align-items: center;\n\n flex: 1 1 7em;\n min-width: 0;\n max-width: max-content;\n margin-inline-end: auto;\n}\n.request-editor-section {\n display: flex;\n flex: 1;\n}\n/*\n * A long sample is drawn as virtual text with its own copy button rather than a code block, so\n * that button gets the same raised fill a code block gives its button on a card's surface.\n */\n.code-snippet > .scalar-code-copy {\n background: var(--scalar-card-surface-raised, var(--scalar-background-2));\n}\n.request-card-simple {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n\n padding: 8px 8px 8px 12px;\n\n font-size: var(--scalar-small);\n}\n.request-header {\n /* Give spare inline space to the path, while actions fill their own row after wrapping. */\n flex: 999 1 auto;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.request-card-actions {\n flex: 1 0 auto;\n}\n.code-snippet {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0NA,IAAM8B,KAAOD,GAmBPE,IAAsBC,QAAe;GACzC,IAAMC,IAAUC,GAAeC,EAAA,UAAU,WAAW,CAAC,EAAE,WAAW,CAAC,GAC7DC,IAAcD,EAAA,uBAAuB,OAAO,KAAKF,CAAO,CAAC,CAAC;GAKhE,OAJKG,IAEYH,EAAQG,EAAY,EAAE,YAAY,CAAC,IAF3B,CAAC;EAK5B,CAAC,GASKC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ock","_createBlock","_withCtx","_createVNode","_createSlots","_createElementVNode","HttpMethod","_createElementBlock","_renderSlot","_createTextVNode","_toDisplayString","_normalizeClass","_Fragment","ExamplePicker","ExamplePicker_default","HttpMethod_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","CodeExample_vue_vue_type_script_setup_true_lang_default","__emit","emit","requestBodyExamples","computed","content","getResolvedRef","__props","contentType","localExampleKey","ref","resolveExampleKey","keys","preferred","watch","watchEffect","selectExample","key","customCodeSamples","getCustomCodeSamples","clients","getClients","clientCount","total","group","localSelectedClient","findClient","newClient","client","clientPickerAriaLabel","codeSampleAriaLabel","elem","visible","useExampleVisibility","externalExamples","useExternalExamples","getOperationExamples","resolvedOperation","resolveOperationExamples","showExamplePicker","webhookHar","operationToHar","error","generatedTemplate","generateCodeSnippet","resolvedCredentials","scheme","resolveCredentialPlaceholders","generatedCode","displayCode","codeBlockLanguage","webhookLanguage","secretCredentials","getSecrets","selectClient","unfreeze","freezeElement","option","shouldVirtualize","id","useId","unref","openBlock","createBlock","ScalarCard","withCtx","createVNode","ScalarCardHeader","createSlots","_cache","createElementVNode","createElementBlock","createCommentVNode","renderSlot","_ctx","ScalarCombobox","filterClientsByQuery","$event","ScalarButton","createTextVNode","toDisplayString","ScalarIconCaretDown","normalizeClass","open","ScalarCardSection","Fragment","ScalarCodeBlockCopy","ScalarVirtualText","ScalarCodeBlock","ScalarCardFooter"],"sources":["../../../src/code-example/components/CodeExample.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type CodeExampleProps = {\n /** Localized status text shown when the selected example has no linked code sample. */\n codeSampleUnavailable?: string\n /**\n * Localized purpose of the client picker. It opens the button's accessible name and the\n * selected client's title is appended, so the name still contains the visible label.\n */\n clientPickerLabel?: string\n /** Localized accessible name for the search field inside the client picker. */\n clientSearchLabel?: string\n /**\n * Localized accessible name for the focusable code sample. The selected client's title is\n * appended so the announcement also says which language the sample is in.\n */\n codeSampleLabel?: string\n /**\n * Integration type: determines if the code sample is displayed in a client environment\n * or in an API reference environment.\n */\n integration?: 'client' | 'reference'\n /**\n * List of all http clients formatted into option groups for the client selector\n */\n clientOptions: ClientOptionGroup[]\n /**\n * Pre-selected client, this will determine which client is initially selected in the dropdown.\n * Either a built-in client id (e.g. `js/fetch`) or a custom sample id (e.g. `custom/python`).\n *\n * Typed as a plain string: unioning the (large) client-id union with the `custom/...`\n * ids overflows TypeScript's union-complexity limit inside this component's `defineProps`.\n *\n * @defaults to a custom sample if one is available, otherwise shell/curl\n */\n selectedClient?: string\n /**\n * Which server from the spec to use for the code example\n */\n selectedServer?: ServerObject | null\n /**\n * The selected content type from the requestBody.content, this will determine which examples are available\n * as well as the content type of the code example\n *\n * @defaults to the first content type if not provided\n */\n selectedContentType?: string\n /**\n * Example name to use for resolving example values for parameters AND requestBody.\n *\n * This is the document-wide selection: it is honored only when this operation defines an example\n * with the same key, so picking an example on one operation syncs the rest without blanking out\n * operations that do not share that key.\n *\n * @example \"limited\"\n * ```ts\n * parameters: {\n * name: 'foobar',\n * in: 'query',\n * examples: {\n * limited: {\n * dataValue: 10,\n * }\n * }\n * },\n * body: {\n * content: {\n * 'application/json': {\n * examples: {\n * limited: {\n * dataValue: { foo: 'bar' },\n * }\n * }\n * }\n * }\n * }\n *\n * ```\n */\n selectedExample?: string\n /**\n * Event bus\n */\n eventBus: WorkspaceEventBus\n /**\n * The security schemes which are applicable to this operation\n */\n securitySchemes: SecuritySchemeObjectSecret[]\n /**\n * HTTP method of the operation\n */\n method: string\n /**\n * Path of the operation\n */\n path: string\n /**\n * De-referenced OpenAPI Operation object\n */\n operation: OperationObject\n /**\n * If true and there's no example, we will display a small card with the method and path only\n */\n fallback?: boolean\n /**\n * A method to generate the label of the block, should return an html string\n */\n generateLabel?: () => string\n /**\n * If true, render this as a webhook request example\n */\n isWebhook?: boolean\n /**\n * Workspace + document cookies\n */\n globalCookies?: XScalarCookie[]\n /**\n * When the request body schema uses oneOf/anyOf, use these selected variants\n * for the example snippet (e.g. from the schema dropdowns in the API reference).\n */\n /** Originating OpenAPI version, used for XML mapping rules. */\n openapiVersion?: string\n /** Document-level JSON Schema dialect used when generating array `contains` examples. */\n jsonSchemaDialect?: string\n requestBodyCompositionSelection?: Record<string, number>\n}\n\n/**\n * Request Example\n *\n * The core component for rendering a request example block,\n * this component does not have much of its own state but operates on props and custom events\n *\n * @event workspace:update:selected-client - Emitted when the selected client changes\n * @event workspace:update:selected-example - Emitted when the selected example changes, so other operations can sync\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarCard,\n ScalarCardFooter,\n ScalarCardHeader,\n ScalarCardSection,\n} from '@scalar/components/card'\nimport {\n ScalarCodeBlock,\n ScalarCodeBlockCopy,\n} from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarVirtualText } from '@scalar/components/virtual-text'\nimport { freezeElement } from '@scalar/helpers/dom/freeze-element'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport { type WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getOperationExamples,\n resolveOperationExamples,\n} from '@scalar/workspace-store/helpers/operation-examples'\nimport {\n useExampleVisibility,\n useExternalExamples,\n} from '@scalar/workspace-store/helpers/use-external-examples'\nimport {\n resolveCredentialPlaceholders,\n type SecuritySchemeObjectSecret,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OperationObject,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport {\n computed,\n ref,\n useId,\n watch,\n watchEffect,\n type ComponentPublicInstance,\n} from 'vue'\n\nimport { filterClientsByQuery } from '../helpers/filter-clients-by-query'\nimport { findClient } from '../helpers/find-client'\nimport { generateCodeSnippet } from '../helpers/generate-code-snippet'\nimport { getClients } from '../helpers/get-clients'\nimport { getCustomCodeSamples } from '../helpers/get-custom-code-samples'\nimport { getSecrets } from '../helpers/get-secrets'\nimport { operationToHar } from '../helpers/operation-to-har/operation-to-har'\nimport type {\n ClientOption,\n ClientOptionGroup,\n CustomClientOption,\n} from '../types'\nimport ExamplePicker from './ExamplePicker.vue'\nimport HttpMethod from './HttpMethod.vue'\n\nconst {\n integration,\n codeSampleUnavailable = 'No code sample available for this example.',\n clientPickerLabel = 'Change code sample language',\n clientSearchLabel = 'Search clients',\n codeSampleLabel = 'Code sample',\n clientOptions,\n selectedClient,\n selectedServer = null,\n selectedContentType,\n selectedExample,\n securitySchemes = [],\n method,\n eventBus,\n path,\n operation,\n isWebhook,\n generateLabel,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n} = defineProps<CodeExampleProps>()\n\nconst emit = defineEmits<{\n /**\n * Emitted whenever the example key actually shown for this operation changes.\n *\n * This is the resolved local key (not the raw document-wide selection), so layouts that render\n * the test-request button outside this component can open the client with the same example the\n * snippet displays.\n */\n (e: 'update:exampleKey', value: string): void\n}>()\n\ndefineSlots<{\n 'header': () => unknown\n /** Rendered at the start of the footer, only while the example picker does not need that space */\n 'footer-start'?: () => unknown\n 'footer': ({ exampleName }: { exampleName: string }) => unknown\n}>()\n\n/** Grab the examples for the given content type */\nconst requestBodyExamples = computed(() => {\n const content = getResolvedRef(operation.requestBody)?.content ?? {}\n const contentType = selectedContentType || Object.keys(content)[0]\n if (!contentType) return {}\n\n const examples = content[contentType]?.examples ?? {}\n\n return examples\n})\n\n/**\n * The example key actually shown for this operation.\n *\n * `selectedExample` is the document-wide selection that syncs across operations. We honor it only\n * when this operation actually defines that key, otherwise we keep the local example: a selection\n * on one operation should never blank out an operation that does not share the same example.\n */\nconst localExampleKey = ref('')\n\n/** Resolve the key to display, preferring the document-wide selection when this operation has it */\nconst resolveExampleKey = (preferred: string | undefined): string => {\n const keys = Object.keys(requestBodyExamples.value)\n if (preferred && keys.includes(preferred)) {\n return preferred\n }\n // Keep the current local example when it is still valid, otherwise fall back to the first one\n if (localExampleKey.value && keys.includes(localExampleKey.value)) {\n return localExampleKey.value\n }\n return keys[0] ?? ''\n}\n\n// Set the initial example from the document-wide selection, falling back to the first example.\n// This runs during setup so the server renders the same example as the browser.\nlocalExampleKey.value = resolveExampleKey(selectedExample)\n\n// Follow the document-wide selection when it changes and this operation has that example\nwatch(\n () => selectedExample,\n (preferred) => {\n localExampleKey.value = resolveExampleKey(preferred)\n },\n)\n\n/** Reset the selected example key if the content type changes and the new content type doesn't have the previously selected example */\nwatch(\n () => selectedContentType,\n () => {\n if (\n !Object.keys(requestBodyExamples.value).includes(localExampleKey.value)\n ) {\n // Re-resolve so the new content type still follows the document-wide selection when it has\n // that key, instead of always snapping back to the first example\n localExampleKey.value = resolveExampleKey(selectedExample)\n }\n },\n)\n\n// Keep the parent informed of the resolved key so a test-request button rendered outside this\n// component (e.g. the classic layout header) opens the client with the example the snippet shows\nwatchEffect(() => {\n emit('update:exampleKey', localExampleKey.value)\n})\n\n/** Select an example locally and sync the choice across the document */\nconst selectExample = (key: string) => {\n localExampleKey.value = key\n eventBus.emit('workspace:update:selected-example', key)\n}\n\n/** Grab any custom code samples from the operation */\nconst customCodeSamples = computed(() => getCustomCodeSamples(operation))\n\n/** Merge custom code samples with the client options */\nconst clients = computed(() =>\n getClients(\n customCodeSamples.value.samples,\n clientOptions,\n customCodeSamples.value.label,\n ),\n)\n\n/** Total number of available clients across all option groups */\nconst clientCount = computed(() =>\n clients.value.reduce((total, group) => total + group.options.length, 0),\n)\n\n/** The locally selected client which would include code samples from this operation only */\nconst localSelectedClient = ref<ClientOption | CustomClientOption | undefined>(\n findClient(clients.value, selectedClient),\n)\n\n/**\n * Re-resolve the local client whenever the global selection or the available\n * clients change. Watching `clients` matters when navigating between operations:\n * the stored id stays the same, but the matching option (e.g. a custom sample)\n * differs per operation, so without this the snippet could go stale.\n */\nwatch([() => selectedClient, clients], ([newClient]) => {\n const client = findClient(clients.value, newClient)\n if (client) {\n localSelectedClient.value = client\n }\n})\n\n/**\n * Accessible name for the client picker.\n *\n * On its own the button reads as its current value (\"C Libcurl\"), which never\n * says what activating it does. The visible title stays part of the name so it\n * still matches what is on screen.\n */\nconst clientPickerAriaLabel = computed(() =>\n [clientPickerLabel, localSelectedClient.value?.title]\n .filter(Boolean)\n .join(': '),\n)\n\n/**\n * Accessible name for the focusable code sample, e.g. \"Code sample: Shell cURL\".\n *\n * Screen readers announce only the name and role when focus lands on the scroller, so the\n * name tells the user both what the region is and which client it is generated for.\n */\nconst codeSampleAriaLabel = computed(() =>\n [codeSampleLabel, localSelectedClient.value?.title]\n .filter(Boolean)\n .join(': '),\n)\n\nconst elem = ref<ComponentPublicInstance | null>(null)\nconst visible = useExampleVisibility(elem)\nconst externalExamples = useExternalExamples(\n () =>\n getOperationExamples(operation, localExampleKey.value, selectedContentType),\n () => visible.value,\n)\nconst resolvedOperation = computed(() =>\n resolveOperationExamples(\n operation,\n localExampleKey.value,\n selectedContentType,\n externalExamples.resolve,\n ),\n)\n\n/** Keep the picker available because it also selects the example opened by Test Request. */\nconst showExamplePicker = computed(\n () => Object.keys(requestBodyExamples.value).length > 1,\n)\n\n/** Generate HAR data for webhook requests */\nconst webhookHar = computed(() => {\n if (!isWebhook) return null\n\n try {\n return operationToHar({\n operation: resolvedOperation.value,\n method,\n path,\n example: localExampleKey.value,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n // Only required parameters are shown in code examples; optional parameters\n // are omitted unless explicitly enabled via `x-disabled: false`.\n defaultDisabledParameters: true,\n })\n } catch (error) {\n console.error('[webhookHar]', error)\n return null\n }\n})\n\n/** Generate the code snippet for the selected example */\nconst generatedTemplate = computed<string | null>(() => {\n if (isWebhook) {\n return webhookHar.value?.postData?.text ?? ''\n }\n\n return generateCodeSnippet({\n // Only required parameters are shown in code examples; optional parameters\n // are omitted unless explicitly enabled via `x-disabled: false`.\n defaultDisabledParameters: true,\n includeDefaultHeaders: integration === 'client',\n clientId: localSelectedClient.value?.id,\n customCodeSamples: customCodeSamples.value.samples,\n operation: resolvedOperation.value,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: localExampleKey.value,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n })\n})\n\n/** Resolve custom templates at render time so auth changes never mutate the document. */\nconst resolvedCredentials = computed(() =>\n !isWebhook &&\n localSelectedClient.value?.id.startsWith('custom/') &&\n generatedTemplate.value !== null &&\n securitySchemes.some((scheme) => 'x-scalar-credential-placeholders' in scheme)\n ? resolveCredentialPlaceholders(generatedTemplate.value, securitySchemes)\n : undefined,\n)\n\nconst generatedCode = computed(\n () => resolvedCredentials.value?.content ?? generatedTemplate.value,\n)\n\n/** Mask inserted secrets before escaping or syntax tokenization can split their values. */\nconst displayCode = computed(\n () => resolvedCredentials.value?.displayContent ?? generatedCode.value,\n)\n\n/** The language for the code block, used for syntax highlighting */\nconst codeBlockLanguage = computed(() => {\n if (isWebhook) {\n return webhookLanguage.value\n }\n\n return localSelectedClient.value?.lang\n})\n\n/** Determine the language for webhook content based on MIME type */\nconst webhookLanguage = computed<string>(() => {\n if (!webhookHar.value?.postData) return 'json'\n\n const contentType = webhookHar.value.postData.mimeType\n if (contentType?.includes('json')) return 'json'\n if (contentType?.includes('xml')) return 'xml'\n if (contentType?.includes('yaml') || contentType?.includes('yml'))\n return 'yaml'\n if (contentType?.includes('text/plain')) return 'text'\n\n return 'json'\n})\n\n/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() =>\n resolvedCredentials.value ? [] : getSecrets(securitySchemes),\n)\n\n/** Set custom example, or update the selected HTTP client globally */\nconst selectClient = (option: ClientOption) => {\n // We need to freeze the ui to prevent scrolling as the clients change\n if (elem.value) {\n const unfreeze = freezeElement(elem.value.$el)\n setTimeout(() => {\n unfreeze()\n }, 300)\n }\n // Update to the local example\n localSelectedClient.value = option\n\n // Sync the selection globally so other operations follow along. Custom samples\n // sync too (keyed by language), so picking e.g. the Python SDK example here\n // shows the Python example on every operation that ships one.\n if (option) {\n eventBus.emit('workspace:update:selected-client', option.id)\n }\n}\n\n// Virtualize the code block if it's too large\n// This prevents the entire app from freezing up if there's a massive example\n// We set a lower threshold here as code examples can get quite large\nconst VIRTUALIZATION_THRESHOLD = 20_000\n\nconst shouldVirtualize = computed(\n () => (generatedCode.value?.length ?? 0) > VIRTUALIZATION_THRESHOLD,\n)\n\nconst id = useId()\n</script>\n<template>\n <ScalarCard\n v-if=\"\n generatedCode === null || generatedCode || externalExamples.pending.value\n \"\n ref=\"elem\"\n class=\"request-card dark-mode\">\n <!-- Header -->\n <ScalarCardHeader class=\"pr-2.5\">\n <span class=\"sr-only\">Request Example for</span>\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <span\n v-if=\"generateLabel\"\n v-html=\"generateLabel()\" />\n <slot name=\"header\" />\n <!-- Client picker -->\n <template\n v-if=\"!isWebhook && clientCount\"\n #actions>\n <!-- Multiple clients: render a dropdown to switch between them -->\n <ScalarCombobox\n v-if=\"clientCount > 1\"\n v-slot=\"{ open }\"\n class=\"max-h-80\"\n :filterFn=\"filterClientsByQuery\"\n :inputLabel=\"clientSearchLabel\"\n :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n teleport\n @update:modelValue=\"selectClient($event as ClientOption)\">\n <ScalarButton\n :aria-label=\"clientPickerAriaLabel\"\n class=\"text-c-2 hover:text-c-1 flex h-full w-fit gap-1.5 px-0.5 py-0 text-base font-normal\"\n data-testid=\"client-picker\"\n variant=\"ghost\">\n {{ localSelectedClient?.title }}\n <!--\n Follow this picker's own state. The `ui-open:` variant also matches any open\n Headless UI ancestor, such as an expanded operation in the classic layout.\n -->\n <ScalarIconCaretDown\n class=\"mt-px size-3 transition-transform duration-100\"\n :class=\"{ 'rotate-180': open }\"\n weight=\"bold\" />\n </ScalarButton>\n </ScalarCombobox>\n <!-- Single client: just show its label, no need for a dropdown -->\n <span\n v-else\n class=\"text-c-2 flex h-full w-fit items-center px-0.5 py-0 text-base font-normal\"\n data-testid=\"client-picker\">\n {{ localSelectedClient?.title }}\n </span>\n </template>\n </ScalarCardHeader>\n\n <!-- Code snippet -->\n <ScalarCardSection class=\"request-editor-section custom-scroll p-0\">\n <div\n v-if=\"externalExamples.pending.value\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n <template v-if=\"externalExamples.failed.value\">\n Could not load this example.\n <ScalarButton\n size=\"sm\"\n variant=\"ghost\"\n @click=\"externalExamples.retry\">\n Retry\n </ScalarButton>\n </template>\n <template v-else>Loading example…</template>\n </div>\n <div\n v-else-if=\"generatedCode === null\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n {{ codeSampleUnavailable }}\n </div>\n <div\n v-else\n :id=\"`${id}-example`\"\n class=\"code-snippet group/code-block relative\">\n <ScalarCodeBlock\n v-if=\"!shouldVirtualize\"\n class=\"h-full bg-transparent\"\n :content=\"displayCode ?? ''\"\n :copyContent=\"resolvedCredentials ? (generatedCode ?? '') : undefined\"\n :hideCredentials=\"secretCredentials\"\n :label=\"codeSampleAriaLabel\"\n :lang=\"codeBlockLanguage\"\n lineNumbers />\n <template v-else>\n <ScalarCodeBlockCopy\n :aria-controls=\"`${id}-virtual-code`\"\n class=\"scalar-code-copy absolute top-2.5 right-2.5 z-1\"\n :content=\"generatedCode\"\n :lang=\"codeBlockLanguage\" />\n <ScalarVirtualText\n :id=\"`${id}-virtual-code`\"\n aria-label=\"Request code sample\"\n containerClass=\"custom-scroll scalar-code-block flex flex-1 max-h-screen\"\n contentClass=\"language-plaintext whitespace-pre font-code text-base p-2\"\n :lineHeight=\"20\"\n role=\"region\"\n :text=\"displayCode ?? ''\" />\n </template>\n </div>\n </ScalarCardSection>\n\n <!-- Footer -->\n <ScalarCardFooter\n v-if=\"showExamplePicker || $slots.footer || $slots['footer-start']\"\n class=\"request-card-footer\"\n :class=\"{\n 'request-card-footer--wraps':\n showExamplePicker || $slots['footer-start'],\n }\">\n <!-- Example picker -->\n <div\n v-if=\"showExamplePicker\"\n class=\"request-card-footer-addon\">\n <template v-if=\"Object.keys(requestBodyExamples).length\">\n <ExamplePicker\n :examples=\"requestBodyExamples\"\n :modelValue=\"localExampleKey\"\n @update:modelValue=\"selectExample\" />\n </template>\n </div>\n <!-- Otherwise the start of the footer is free for the caller -->\n <div\n v-else-if=\"$slots['footer-start']\"\n class=\"request-card-footer-start\">\n <slot name=\"footer-start\" />\n </div>\n\n <!-- Footer -->\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </ScalarCardFooter>\n </ScalarCard>\n\n <!-- Fallback card with just method and path in the case of no examples -->\n <ScalarCard\n v-else-if=\"fallback\"\n class=\"request-card dark-mode\">\n <!-- A single row of method, path and actions reads as a header, so it stays on the card -->\n <ScalarCardSection class=\"request-card-simple bg-transparent shadow-none\">\n <div class=\"request-header\">\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <slot name=\"header\" />\n </div>\n <div\n v-if=\"$slots.footer\"\n class=\"request-card-actions relative max-w-full\">\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </div>\n </ScalarCardSection>\n </ScalarCard>\n</template>\n<style scoped>\n.request-card {\n color: var(--scalar-color-1);\n font-size: var(--scalar-font-size-3);\n}\n.request-method {\n font-family: var(--scalar-font-code);\n margin-right: 6px;\n}\n.request-card-footer {\n display: flex;\n justify-content: flex-end;\n padding: 6px;\n flex-shrink: 0;\n position: relative;\n}\n/*\n * The example picker or footer-start content keeps room for itself; when the footer is too narrow\n * for everything, the end controls wrap onto a second line instead of squeezing or covering it.\n */\n.request-card-footer--wraps {\n flex-wrap: wrap;\n row-gap: 4px;\n}\n.request-card-footer-start {\n display: flex;\n align-items: center;\n flex: 1 0 auto;\n}\n/*\n * The picker asks for its example name's width, capped at 7em (about eight characters), so on a\n * narrow card the end controls wrap rather than squeeze the name out of view. The cap keeps a long\n * name truncating beside them on wider cards, as before. The picker never grows past its name, and\n * the end margin holds it at the start of the line.\n */\n.request-card-footer-addon {\n display: flex;\n align-items: center;\n\n flex: 1 1 7em;\n min-width: 0;\n max-width: max-content;\n margin-inline-end: auto;\n}\n.request-editor-section {\n display: flex;\n flex: 1;\n}\n/*\n * A long sample is drawn as virtual text with its own copy button rather than a code block, so\n * that button gets the same raised fill a code block gives its button on a card's surface.\n */\n.code-snippet > .scalar-code-copy {\n background: var(--scalar-card-surface-raised, var(--scalar-background-2));\n}\n.request-card-simple {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n\n padding: 8px 8px 8px 12px;\n\n font-size: var(--scalar-small);\n}\n.request-header {\n /* Give spare inline space to the path, while actions fill their own row after wrapping. */\n flex: 999 1 auto;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.request-card-actions {\n flex: 1 0 auto;\n}\n.code-snippet {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6NA,IAAM6B,KAAOD,GAmBPE,IAAsBC,QAAe;GACzC,IAAMC,IAAUC,GAAeC,EAAA,UAAU,WAAW,CAAC,EAAE,WAAW,CAAC,GAC7DC,IAAcD,EAAA,uBAAuB,OAAO,KAAKF,CAAO,CAAC,CAAC;GAKhE,OAJKG,IAEYH,EAAQG,EAAY,EAAE,YAAY,CAAC,IAF3B,CAAC;EAK5B,CAAC,GASKC,IAAkBC,EAAI,EAAE,GAGxBC,KAAqB,MAA0C;GACnE,IAAMC,IAAO,OAAO,KAAKT,EAAoB,KAAK;GAQlD,OAPIU,KAAaD,EAAK,SAASC,CAAS,IAC/BA,IAGLJ,EAAgB,SAASG,EAAK,SAASH,EAAgB,KAAK,IACvDA,EAAgB,QAElBG,EAAK,MAAM;EACpB;EA8B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BAC+BqD,EAAA,SAAqBlE,EAAAA,OAAM,gB;;KAKrF,SAAAI,QASM,CARE8D,EAAA,SADRhE,EAAA,GAAAO,EASM,OATNc,GASM,CANY,OAAO,KAAKO,EAAA,KAAmB,CAAA,CAAE,UAC/C5B,EAAA,GAAAC,EAGuCY,IAAA;;MAFpC,UAAUe,EAAA;MACV,YAAYM,EAAA;MACZ,uBAAmBO;K,0DAKb3C,EAAAA,OAAM,mBADnBE,EAAA,GAAAO,EAIM,OAJNe,GAIM,CADJd,EAA4B2F,EAAA,QAAA,gBAAA,CAAA,GAAA,KAAA,GAAA,EAAA,C,iBAI9B3F,EAEkB2F,EAAA,QAAA,UAAA,EADf,aAAajE,EAAA,MAAe,GAAA,KAAA,GAAA,EAAA,C;;;;;E,WAOtBF,EAAA,YADbhC,EAAA,GAAAC,EAoBaF,EAAA0F,CAAA,GAAA;;GAlBX,OAAM;;GAEN,SAAAvF,QAeoB,CAfpBC,EAeoBJ,EAAA8G,CAAA,GAAA,EAfD,OAAM,iDAAgD,GAAA;IACvE,SAAA3G,QAMM,CANNG,EAMM,OANNkB,GAMM,CALJpB,EAGqBG,GAAA;KAFnB,IAAG;KACH,OAAM;KACL,QAAQ0B,EAAA;I,yBACXxB,EAAsB2F,EAAA,QAAA,UAAA,CAAA,GAAA,KAAA,GAAA,EAAA,C,IAGhBrG,EAAAA,OAAO,UADfE,EAAA,GAAAO,EAMM,OANNiB,GAMM,CAHJhB,EAEkB2F,EAAA,QAAA,UAAA,EADf,aAAajE,EAAA,MAAe,GAAA,KAAA,GAAA,EAAA,C"}
@@ -1,7 +1,6 @@
1
1
  import e from "./ExamplePicker.vue_vue_type_script_setup_true_lang.js";
2
- //#region src/code-example/components/ExamplePicker.vue
2
+ // src/code-example/components/ExamplePicker.vue
3
3
  var t = e;
4
- //#endregion
5
4
  export { t as default };
6
5
 
7
6
  //# sourceMappingURL=ExamplePicker.vue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExamplePicker.vue.js","names":["_sfc_main","ExamplePicker_vue_vue_type_script_setup_true_lang_default","ExamplePicker_default"],"sources":["../../../src/code-example/components/ExamplePicker.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarListbox,\n type ScalarListboxOption,\n} from '@scalar/components/listbox'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { MediaTypeObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed } from 'vue'\n\nimport { getExampleSummary } from '../../schema/helpers/get-rendered-example'\n\nconst { examples = {} } = defineProps<{\n examples?: MediaTypeObject['examples'] | Record<string, string>\n}>()\n\nconst selectedExampleKey = defineModel<string>({\n required: true,\n})\n\ndefineOptions({ inheritAttrs: false })\n\nconst exampleOptions = computed<ScalarListboxOption[]>(() =>\n Object.entries(examples).map(([key, example]) => ({\n id: key,\n label: getExampleSummary(example) || key,\n })),\n)\n\nconst selectedExample = computed<ScalarListboxOption | undefined>({\n get: () =>\n exampleOptions.value.find(({ id }) => id === selectedExampleKey.value),\n set: (v) => (selectedExampleKey.value = v?.id ?? ''),\n})\n</script>\n\n<template>\n <ScalarListbox\n v-slot=\"{ open }\"\n v-model=\"selectedExample\"\n class=\"w-fit min-w-32\"\n :options=\"exampleOptions\"\n placement=\"bottom-start\"\n teleport>\n <ScalarButton\n class=\"text-c-2 hover:text-c-1 flex h-full w-fit min-w-0 gap-1.5 px-1.5 py-0.75 text-base font-normal\"\n data-testid=\"example-picker\"\n variant=\"ghost\"\n v-bind=\"$attrs\">\n <div class=\"min-w-0 flex-1 truncate\">\n {{ selectedExample?.label ?? 'Select an example' }}\n </div>\n <!--\n Follow this listbox's own state. The `ui-open:` variant also matches any open\n Headless UI ancestor, such as an expanded operation in the classic layout.\n -->\n <ScalarIconCaretDown\n class=\"mt-0.25 size-3 transition-transform duration-100\"\n :class=\"{ 'rotate-180': open }\"\n weight=\"bold\" />\n </ScalarButton>\n </ScalarListbox>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"ExamplePicker.vue.js","names":["ExamplePicker_vue_vue_type_script_setup_true_lang_default","ExamplePicker_default"],"sources":[],"mappings":""}
@@ -3,7 +3,7 @@ import { computed as t, createBlock as n, createElementVNode as r, createVNode a
3
3
  import { ScalarButton as m } from "@scalar/components/button";
4
4
  import { ScalarListbox as h } from "@scalar/components/listbox";
5
5
  import { ScalarIconCaretDown as g } from "@scalar/icons";
6
- //#region src/code-example/components/ExamplePicker.vue?vue&type=script&setup=true&lang.ts
6
+ // src/code-example/components/ExamplePicker.vue?vue&type=script&setup=true&lang.ts
7
7
  var _ = { class: "min-w-0 flex-1 truncate" }, v = /*@__PURE__*/ a({
8
8
  inheritAttrs: !1,
9
9
  __name: "ExamplePicker",
@@ -43,7 +43,6 @@ var _ = { class: "min-w-0 flex-1 truncate" }, v = /*@__PURE__*/ a({
43
43
  }, 8, ["modelValue", "options"]));
44
44
  }
45
45
  });
46
- //#endregion
47
46
  export { v as default };
48
47
 
49
48
  //# sourceMappingURL=ExamplePicker.vue_vue_type_script_setup_true_lang.js.map
@@ -1,7 +1,6 @@
1
1
  import e from "./HttpMethod.vue_vue_type_script_setup_true_lang.js";
2
- //#region src/code-example/components/HttpMethod.vue
2
+ // src/code-example/components/HttpMethod.vue
3
3
  var t = e;
4
- //#endregion
5
4
  export { t as default };
6
5
 
7
6
  //# sourceMappingURL=HttpMethod.vue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HttpMethod.vue.js","names":["_sfc_main","HttpMethod_vue_vue_type_script_setup_true_lang_default","HttpMethod_default"],"sources":["../../../src/code-example/components/HttpMethod.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { computed, type Component } from 'vue'\n\nconst props = defineProps<{\n /** The type of element to render as, defaults to `span` */\n as?: Component | string\n /** The css style property or variable that will be set to the request method color, defaults to `color` */\n property?: string\n /** Whether or not to abbreviated the slot content */\n short?: boolean\n /** The HTTP method to show */\n method: string\n}>()\n\n/** Grabs the method info object which contains abbreviation, color, and background color etc */\nconst httpMethodInfo = computed(() =>\n getHttpMethodInfo(String(props.method || '')),\n)\n\n/** Full method name */\nconst normalized = computed(() => {\n if (typeof props.method !== 'string' || !props.method.trim()) {\n return 'get'\n }\n const method = props.method.trim()\n return isHttpMethod(method.toLowerCase()) ? method.toLowerCase() : method\n})\n</script>\n\n<template>\n <component\n :is=\"as ?? 'span'\"\n :class=\"{ uppercase: isHttpMethod(normalized) }\"\n :style=\"{ [property || 'color']: httpMethodInfo.colorVar }\">\n <slot />\n {{ short ? httpMethodInfo.short : normalized }}\n </component>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"HttpMethod.vue.js","names":["HttpMethod_vue_vue_type_script_setup_true_lang_default","HttpMethod_default"],"sources":[],"mappings":""}
@@ -1,7 +1,7 @@
1
1
  import { computed as e, createBlock as t, createTextVNode as n, defineComponent as r, normalizeClass as i, normalizeStyle as a, openBlock as o, renderSlot as s, resolveDynamicComponent as c, toDisplayString as l, unref as u, withCtx as d } from "vue";
2
2
  import { getHttpMethodInfo as f } from "@scalar/helpers/http/http-info";
3
3
  import { isHttpMethod as p } from "@scalar/helpers/http/is-http-method";
4
- //#region src/code-example/components/HttpMethod.vue?vue&type=script&setup=true&lang.ts
4
+ // src/code-example/components/HttpMethod.vue?vue&type=script&setup=true&lang.ts
5
5
  var m = /*@__PURE__*/ r({
6
6
  __name: "HttpMethod",
7
7
  props: {
@@ -25,7 +25,6 @@ var m = /*@__PURE__*/ r({
25
25
  }, 8, ["class", "style"]));
26
26
  }
27
27
  });
28
- //#endregion
29
28
  export { m as default };
30
29
 
31
30
  //# sourceMappingURL=HttpMethod.vue_vue_type_script_setup_true_lang.js.map
@@ -1,4 +1,4 @@
1
- //#region src/code-example/helpers/filter-clients-by-query.ts
1
+ // src/code-example/helpers/filter-clients-by-query.ts
2
2
  var e = (e, t) => {
3
3
  let n = t.toLowerCase();
4
4
  return e.label.toLowerCase().includes(n) || e.clientKey.toLowerCase().includes(n) || e.lang.toLowerCase().includes(n);
@@ -15,7 +15,6 @@ var e = (e, t) => {
15
15
  }
16
16
  return r.filter((t) => e(t, a));
17
17
  });
18
- //#endregion
19
18
  export { n as filterClientsByQuery };
20
19
 
21
20
  //# sourceMappingURL=filter-clients-by-query.js.map