@scalar/blocks 0.6.3 → 0.7.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 (60) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/code-example/components/CodeExample.vue.d.ts +1 -1
  3. package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
  4. package/dist/code-example/components/CodeExample.vue.js +1 -1
  5. package/dist/code-example/components/CodeExample.vue.js.map +1 -1
  6. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js +141 -126
  7. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -1
  8. package/dist/code-example/helpers/generate-client-options.d.ts +1 -1
  9. package/dist/code-example/helpers/generate-client-options.d.ts.map +1 -1
  10. package/dist/code-example/helpers/generate-client-options.js +5 -1
  11. package/dist/code-example/helpers/generate-client-options.js.map +1 -1
  12. package/dist/code-example/helpers/get-clients.d.ts.map +1 -1
  13. package/dist/code-example/helpers/get-clients.js +17 -18
  14. package/dist/code-example/helpers/get-clients.js.map +1 -1
  15. package/dist/code-example/helpers/get-generated-payload-example.d.ts.map +1 -1
  16. package/dist/code-example/helpers/get-generated-payload-example.js +1 -4
  17. package/dist/code-example/helpers/get-generated-payload-example.js.map +1 -1
  18. package/dist/code-example/types.d.ts +1 -1
  19. package/dist/code-example/types.d.ts.map +1 -1
  20. package/dist/constants.js +1 -1
  21. package/dist/schema/SchemaPropertyExamples.vue.js +1 -1
  22. package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -1
  23. package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js.map +1 -1
  24. package/dist/schema/SchemaPropertyHeading.vue.d.ts +3 -3
  25. package/dist/schema/SchemaPropertyHeading.vue.d.ts.map +1 -1
  26. package/dist/schema/SchemaPropertyHeading.vue.js +1 -1
  27. package/dist/schema/SchemaPropertyHeading.vue.js.map +1 -1
  28. package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js +154 -137
  29. package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js.map +1 -1
  30. package/dist/schema/helpers/optimize-value-for-display.d.ts.map +1 -1
  31. package/dist/schema/helpers/optimize-value-for-display.js +8 -5
  32. package/dist/schema/helpers/optimize-value-for-display.js.map +1 -1
  33. package/dist/schema/index.d.ts +2 -0
  34. package/dist/schema/index.d.ts.map +1 -1
  35. package/dist/schema/index.js +12 -10
  36. package/dist/schema/protobuf-metadata.d.ts +11 -0
  37. package/dist/schema/protobuf-metadata.d.ts.map +1 -0
  38. package/dist/schema/protobuf-metadata.js +6 -0
  39. package/dist/schema/protobuf-metadata.js.map +1 -0
  40. package/dist/schema/recursive-metadata.d.ts +8 -0
  41. package/dist/schema/recursive-metadata.d.ts.map +1 -0
  42. package/dist/schema/recursive-metadata.js +6 -0
  43. package/dist/schema/recursive-metadata.js.map +1 -0
  44. package/dist/shared/Badge.vue.d.ts.map +1 -1
  45. package/dist/shared/Badge.vue.js +1 -1
  46. package/dist/shared/Badge.vue.js.map +1 -1
  47. package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js.map +1 -1
  48. package/dist/specification-extensions/ExtensionValue.vue.d.ts +2 -0
  49. package/dist/specification-extensions/ExtensionValue.vue.d.ts.map +1 -1
  50. package/dist/specification-extensions/ExtensionValue.vue.js.map +1 -1
  51. package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js +5 -1
  52. package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js.map +1 -1
  53. package/dist/specification-extensions/SpecificationExtensions.vue.d.ts +2 -0
  54. package/dist/specification-extensions/SpecificationExtensions.vue.d.ts.map +1 -1
  55. package/dist/specification-extensions/SpecificationExtensions.vue.js.map +1 -1
  56. package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js +19 -8
  57. package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js.map +1 -1
  58. package/dist/style.css +12 -4
  59. package/dist/vue-styles.css +1 -1
  60. package/package.json +10 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @scalar/blocks
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#10894](https://github.com/scalar/scalar/pull/10894): Substitute explicitly mapped reader credentials into custom code samples with default masking, public field opt-outs, and real values on copy.
8
+ - [#10893](https://github.com/scalar/scalar/pull/10893): Allow custom code samples to use separate picker headings with an optional `group` field.
9
+
10
+ ### Patch Changes
11
+
12
+ - [#10949](https://github.com/scalar/scalar/pull/10949): Show response header examples, including media type examples and OpenAPI 3.2 cookie examples, with explicit examples taking precedence over schema examples. Preserve this precedence through composed schemas and fall back to media type examples when header examples have no usable values.
13
+
14
+ Keep external example URLs visible and preserve line breaks in displayed string examples. Across all schemas, array-level examples take precedence over item examples.
15
+
16
+ Preserve `x-example` and `x-examples` on OpenAPI 2.0 response headers during upgrades.
17
+
18
+ - [#10902](https://github.com/scalar/scalar/pull/10902): Render self-contained Avro, RAML, and Protobuf schemas as native field and type documentation, retaining copyable source for unsupported schemas.
19
+
20
+ ## 0.6.4
21
+
22
+ ### Patch Changes
23
+
24
+ - [#10733](https://github.com/scalar/scalar/pull/10733): Align AsyncAPI message and server extensions with their surrounding content and reduce excess spacing.
25
+ - [#10814](https://github.com/scalar/scalar/pull/10814): fix(blocks): keep explicit badge colors above themed utility defaults
26
+ - [#10771](https://github.com/scalar/scalar/pull/10771): Place request actions below the method and path in narrow fallback cards, keeping button labels readable without clipping.
27
+ - [#10812](https://github.com/scalar/scalar/pull/10812): Keep deprecated schemas and properties in generated JSON and XML examples by default. Remove the `includeDeprecated` option; deprecation no longer filters example values. Read/write and optional-property filtering still apply.
28
+
3
29
  ## 0.6.3
4
30
 
5
31
  ## 0.6.2
@@ -1,5 +1,5 @@
1
1
  import { type WorkspaceEventBus } from '@scalar/workspace-store/events';
2
- import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
2
+ import { type SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
3
3
  import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
4
4
  import type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
5
5
  import type { ClientOptionGroup } from '../types';
@@ -1 +1 @@
1
- {"version":3,"file":"CodeExample.vue.d.ts","sourceRoot":"","sources":["../../../src/code-example/components/CodeExample.vue"],"names":[],"mappings":"AAssBA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAUvE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAkBrE,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,UAAU,CAAA;AAKjB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,uFAAuF;IACvF,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,WAAW,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,aAAa,EAAE,iBAAiB,EAAE,CAAA;IAClC;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IACpC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAA;IAC3B;;OAEG;IACH,eAAe,EAAE,0BAA0B,EAAE,CAAA;IAC7C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,SAAS,EAAE,eAAe,CAAA;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,MAAM,CAAA;IAC5B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;OAGG;IACH,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,CAAA;AAED;;;;;;;;GAQG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;;;;;YAuCN,MAAM,OAAO;IACvB,kGAAkG;qBACjF,MAAM,OAAO;YACpB,CAAC,EAAE,WAAW,EAAE,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO;EAyuB7D,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"CodeExample.vue.d.ts","sourceRoot":"","sources":["../../../src/code-example/components/CodeExample.vue"],"names":[],"mappings":"AA2vBA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAUvE,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAkBrE,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,UAAU,CAAA;AAKjB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,uFAAuF;IACvF,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,WAAW,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,aAAa,EAAE,iBAAiB,EAAE,CAAA;IAClC;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IACpC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAA;IAC3B;;OAEG;IACH,eAAe,EAAE,0BAA0B,EAAE,CAAA;IAC7C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,SAAS,EAAE,eAAe,CAAA;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,MAAM,CAAA;IAC5B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;OAGG;IACH,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,CAAA;AAED;;;;;;;;GAQG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;;;;;YAuCN,MAAM,OAAO;IACvB,kGAAkG;qBACjF,MAAM,OAAO;YACpB,CAAC,EAAE,WAAW,EAAE,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO;EAsyB7D,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -2,7 +2,7 @@ import e from "../../_virtual/_plugin-vue_export-helper.js";
2
2
  import t from "./CodeExample.vue_vue_type_script_setup_true_lang.js";
3
3
  /* empty css */
4
4
  //#region src/code-example/components/CodeExample.vue
5
- var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-5374efff"]]);
5
+ var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-9ef20696"]]);
6
6
  //#endregion
7
7
  export { n as default };
8
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"CodeExample.vue.js","names":["_sfc_main","_plugin_vue_export_helper_default","CodeExample_vue_vue_type_script_setup_true_lang_default","CodeExample_default"],"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 { ScalarCodeBlock } 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 type { SecuritySchemeObjectSecret } 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 onBeforeMount,\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\nonBeforeMount(() => {\n localExampleKey.value = resolveExampleKey(selectedExample)\n})\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 generatedCode = 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/** 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(() => getSecrets(securitySchemes))\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 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 <ScalarIconCaretDown\n class=\"ui-open:rotate-180 mt-px size-3 transition-transform duration-100\"\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\">\n <ScalarCodeBlock\n v-if=\"!shouldVirtualize\"\n class=\"bg-b-2 h-full\"\n :content=\"generatedCode\"\n :hideCredentials=\"secretCredentials\"\n :label=\"codeSampleAriaLabel\"\n :lang=\"codeBlockLanguage\"\n lineNumbers />\n <ScalarVirtualText\n v-else\n aria-label=\"Request code sample\"\n containerClass=\"custom-scroll scalar-code-block border rounded-b 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=\"generatedCode\" />\n </div>\n </ScalarCardSection>\n\n <!-- Footer -->\n <ScalarCardFooter\n v-if=\"showExamplePicker || $slots.footer || $slots['footer-start']\"\n class=\"request-card-footer bg-b-3\"\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 <ScalarCardSection class=\"request-card-simple\">\n <div class=\"request-header\">\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <slot name=\"header\" />\n </div>\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\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 * Footer-start content keeps its full width; when the footer is too narrow for everything,\n * 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.request-card-footer-addon {\n display: flex;\n align-items: center;\n\n flex: 1;\n min-width: 0;\n}\n.request-editor-section {\n display: flex;\n flex: 1;\n}\n.request-card-simple {\n display: flex;\n align-items: center;\n justify-content: space-between;\n\n padding: 8px 8px 8px 12px;\n\n font-size: var(--scalar-small);\n}\n.code-snippet {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n</style>\n"],"mappings":""}
1
+ {"version":3,"file":"CodeExample.vue.js","names":["_sfc_main","_plugin_vue_export_helper_default","CodeExample_vue_vue_type_script_setup_true_lang_default","CodeExample_default"],"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 onBeforeMount,\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\nonBeforeMount(() => {\n localExampleKey.value = resolveExampleKey(selectedExample)\n})\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 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 <ScalarIconCaretDown\n class=\"ui-open:rotate-180 mt-px size-3 transition-transform duration-100\"\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=\"bg-b-2 h-full\"\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 border rounded-b 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 bg-b-3\"\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 <ScalarCardSection class=\"request-card-simple\">\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 * Footer-start content keeps its full width; when the footer is too narrow for everything,\n * 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.request-card-footer-addon {\n display: flex;\n align-items: center;\n\n flex: 1;\n min-width: 0;\n}\n.request-editor-section {\n display: flex;\n flex: 1;\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":""}
@@ -2,42 +2,46 @@ import e from "./ExamplePicker.vue.js";
2
2
  import { filterClientsByQuery as t } from "../helpers/filter-clients-by-query.js";
3
3
  import { findClient as n } from "../helpers/find-client.js";
4
4
  import { operationToHar as r } from "../helpers/operation-to-har/operation-to-har.js";
5
- import { generateCodeSnippet as i } from "../helpers/generate-code-snippet.js";
6
- import { getCustomCodeSamples as a } from "../helpers/get-custom-code-samples.js";
7
- import { getClients as ee } from "../helpers/get-clients.js";
8
- import { getSecrets as te } from "../helpers/get-secrets.js";
9
- import o from "./HttpMethod.vue.js";
10
- import { Fragment as s, computed as c, createBlock as l, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createSlots as ne, createTextVNode as p, createVNode as m, defineComponent as h, normalizeClass as re, onBeforeMount as ie, openBlock as g, ref as _, renderSlot as v, toDisplayString as y, unref as b, useId as ae, watch as x, watchEffect as oe, withCtx as S } from "vue";
11
- import { ScalarCard as C, ScalarCardFooter as se, ScalarCardHeader as ce, ScalarCardSection as w } from "@scalar/components/card";
12
- import { ScalarCodeBlock as le } from "@scalar/components/code-block";
13
- import { ScalarButton as T } from "@scalar/components/button";
14
- import { ScalarIconCaretDown as ue } from "@scalar/icons";
15
- import { ScalarCombobox as de } from "@scalar/components/combobox";
16
- import { ScalarVirtualText as fe } from "@scalar/components/virtual-text";
17
- import { freezeElement as pe } from "@scalar/helpers/dom/freeze-element";
18
- import { getResolvedRef as E } from "@scalar/workspace-store/helpers/get-resolved-ref";
19
- import { getOperationExamples as D, resolveOperationExamples as O } from "@scalar/workspace-store/helpers/operation-examples";
20
- import { useExampleVisibility as k, useExternalExamples as A } from "@scalar/workspace-store/helpers/use-external-examples";
5
+ import { generateCodeSnippet as ee } from "../helpers/generate-code-snippet.js";
6
+ 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 ae, onBeforeMount as oe, openBlock as m, ref as h, renderSlot as g, toDisplayString as _, unref as v, useId as se, watch as y, watchEffect as ce, withCtx as b } from "vue";
11
+ import { ScalarCard as x, ScalarCardFooter as le, ScalarCardHeader as ue, ScalarCardSection as S } from "@scalar/components/card";
12
+ import { ScalarCodeBlock as de, ScalarCodeBlockCopy as fe } from "@scalar/components/code-block";
13
+ import { resolveCredentialPlaceholders as pe } from "@scalar/workspace-store/request-example";
14
+ import { ScalarButton as C } from "@scalar/components/button";
15
+ import { ScalarIconCaretDown as me } from "@scalar/icons";
16
+ import { ScalarCombobox as he } from "@scalar/components/combobox";
17
+ import { ScalarVirtualText as ge } from "@scalar/components/virtual-text";
18
+ import { freezeElement as _e } from "@scalar/helpers/dom/freeze-element";
19
+ import { getResolvedRef as ve } from "@scalar/workspace-store/helpers/get-resolved-ref";
20
+ import { getOperationExamples as ye, resolveOperationExamples as w } from "@scalar/workspace-store/helpers/operation-examples";
21
+ import { useExampleVisibility as T, useExternalExamples as E } from "@scalar/workspace-store/helpers/use-external-examples";
21
22
  //#region src/code-example/components/CodeExample.vue?vue&type=script&setup=true&lang.ts
22
- var j = ["innerHTML"], M = {
23
+ var D = ["innerHTML"], O = {
23
24
  key: 1,
24
25
  class: "text-c-2 flex h-full w-fit items-center px-0.5 py-0 text-base font-normal",
25
26
  "data-testid": "client-picker"
26
- }, N = {
27
+ }, k = {
27
28
  key: 0,
28
29
  class: "text-c-2 p-4",
29
30
  role: "status"
30
- }, P = {
31
+ }, A = {
31
32
  key: 1,
32
33
  class: "text-c-2 p-4",
33
34
  role: "status"
34
- }, F = ["id"], I = {
35
+ }, j = ["id"], M = {
35
36
  key: 0,
36
37
  class: "request-card-footer-addon"
37
- }, L = {
38
+ }, N = {
38
39
  key: 1,
39
40
  class: "request-card-footer-start"
40
- }, R = { class: "request-header" }, z = /*@__PURE__*/ h({
41
+ }, P = { class: "request-header" }, be = {
42
+ key: 0,
43
+ class: "request-card-actions relative max-w-full"
44
+ }, F = /*@__PURE__*/ p({
41
45
  __name: "CodeExample",
42
46
  props: {
43
47
  codeSampleUnavailable: { default: "No code sample available for this example." },
@@ -63,115 +67,115 @@ var j = ["innerHTML"], M = {
63
67
  requestBodyCompositionSelection: {}
64
68
  },
65
69
  emits: ["update:exampleKey"],
66
- setup(h, { emit: z }) {
67
- let B = z, V = c(() => {
68
- let e = E(h.operation.requestBody)?.content ?? {}, t = h.selectedContentType || Object.keys(e)[0];
70
+ setup(p, { emit: F }) {
71
+ let xe = F, I = o(() => {
72
+ let e = ve(p.operation.requestBody)?.content ?? {}, t = p.selectedContentType || Object.keys(e)[0];
69
73
  return t ? e[t]?.examples ?? {} : {};
70
- }), H = _(""), U = (e) => {
71
- let t = Object.keys(V.value);
72
- return e && t.includes(e) ? e : H.value && t.includes(H.value) ? H.value : t[0] ?? "";
74
+ }), L = h(""), R = (e) => {
75
+ let t = Object.keys(I.value);
76
+ return e && t.includes(e) ? e : L.value && t.includes(L.value) ? L.value : t[0] ?? "";
73
77
  };
74
- ie(() => {
75
- H.value = U(h.selectedExample);
76
- }), x(() => h.selectedExample, (e) => {
77
- H.value = U(e);
78
- }), x(() => h.selectedContentType, () => {
79
- Object.keys(V.value).includes(H.value) || (H.value = U(h.selectedExample));
80
- }), oe(() => {
81
- B("update:exampleKey", H.value);
78
+ oe(() => {
79
+ L.value = R(p.selectedExample);
80
+ }), y(() => p.selectedExample, (e) => {
81
+ L.value = R(e);
82
+ }), y(() => p.selectedContentType, () => {
83
+ Object.keys(I.value).includes(L.value) || (L.value = R(p.selectedExample));
84
+ }), ce(() => {
85
+ xe("update:exampleKey", L.value);
82
86
  });
83
- let me = (e) => {
84
- H.value = e, h.eventBus.emit("workspace:update:selected-example", e);
85
- }, W = c(() => a(h.operation)), G = c(() => ee(W.value.samples, h.clientOptions, W.value.label)), K = c(() => G.value.reduce((e, t) => e + t.options.length, 0)), q = _(n(G.value, h.selectedClient));
86
- x([() => h.selectedClient, G], ([e]) => {
87
- let t = n(G.value, e);
88
- t && (q.value = t);
87
+ let Se = (e) => {
88
+ L.value = e, p.eventBus.emit("workspace:update:selected-example", e);
89
+ }, 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 = h(n(B.value, p.selectedClient));
90
+ y([() => p.selectedClient, B], ([e]) => {
91
+ let t = n(B.value, e);
92
+ t && (H.value = t);
89
93
  });
90
- let he = c(() => [h.clientPickerLabel, q.value?.title].filter(Boolean).join(": ")), ge = c(() => [h.codeSampleLabel, q.value?.title].filter(Boolean).join(": ")), J = _(null), _e = k(J), Y = A(() => D(h.operation, H.value, h.selectedContentType), () => _e.value), X = c(() => O(h.operation, H.value, h.selectedContentType, Y.resolve)), Z = c(() => Object.keys(V.value).length > 1), Q = c(() => {
91
- if (!h.isWebhook) return null;
94
+ let Ce = o(() => [p.clientPickerLabel, H.value?.title].filter(Boolean).join(": ")), we = o(() => [p.codeSampleLabel, H.value?.title].filter(Boolean).join(": ")), U = h(null), Te = T(U), W = E(() => ye(p.operation, L.value, p.selectedContentType), () => Te.value), G = o(() => w(p.operation, L.value, p.selectedContentType, W.resolve)), K = o(() => Object.keys(I.value).length > 1), q = o(() => {
95
+ if (!p.isWebhook) return null;
92
96
  try {
93
97
  return r({
94
- operation: X.value,
95
- method: h.method,
96
- path: h.path,
97
- example: H.value,
98
- openapiVersion: h.openapiVersion,
99
- requestBodyCompositionSelection: h.requestBodyCompositionSelection,
98
+ operation: G.value,
99
+ method: p.method,
100
+ path: p.path,
101
+ example: L.value,
102
+ openapiVersion: p.openapiVersion,
103
+ requestBodyCompositionSelection: p.requestBodyCompositionSelection,
100
104
  defaultDisabledParameters: !0
101
105
  });
102
106
  } catch (e) {
103
107
  return console.error("[webhookHar]", e), null;
104
108
  }
105
- }), $ = c(() => h.isWebhook ? Q.value?.postData?.text ?? "" : i({
109
+ }), J = o(() => p.isWebhook ? q.value?.postData?.text ?? "" : ee({
106
110
  defaultDisabledParameters: !0,
107
- includeDefaultHeaders: h.integration === "client",
108
- clientId: q.value?.id,
109
- customCodeSamples: W.value.samples,
110
- operation: X.value,
111
- method: h.method,
112
- path: h.path,
113
- contentType: h.selectedContentType,
114
- server: h.selectedServer,
115
- securitySchemes: h.securitySchemes,
116
- example: H.value,
117
- globalCookies: h.globalCookies,
118
- openapiVersion: h.openapiVersion,
119
- requestBodyCompositionSelection: h.requestBodyCompositionSelection
120
- })), ve = c(() => h.isWebhook ? ye.value : q.value?.lang), ye = c(() => {
121
- if (!Q.value?.postData) return "json";
122
- let e = Q.value.postData.mimeType;
111
+ includeDefaultHeaders: p.integration === "client",
112
+ clientId: H.value?.id,
113
+ customCodeSamples: z.value.samples,
114
+ operation: G.value,
115
+ method: p.method,
116
+ path: p.path,
117
+ contentType: p.selectedContentType,
118
+ server: p.selectedServer,
119
+ securitySchemes: p.securitySchemes,
120
+ example: L.value,
121
+ globalCookies: p.globalCookies,
122
+ openapiVersion: p.openapiVersion,
123
+ requestBodyCompositionSelection: p.requestBodyCompositionSelection
124
+ })), Y = o(() => !p.isWebhook && H.value?.id.startsWith("custom/") && J.value !== null && p.securitySchemes.some((e) => "x-scalar-credential-placeholders" in e) ? pe(J.value, p.securitySchemes) : void 0), X = o(() => Y.value?.content ?? J.value), Z = o(() => Y.value?.displayContent ?? X.value), Q = o(() => p.isWebhook ? Ee.value : H.value?.lang), Ee = o(() => {
125
+ if (!q.value?.postData) return "json";
126
+ let e = q.value.postData.mimeType;
123
127
  return e?.includes("json") ? "json" : e?.includes("xml") ? "xml" : e?.includes("yaml") || e?.includes("yml") ? "yaml" : e?.includes("text/plain") ? "text" : "json";
124
- }), be = c(() => te(h.securitySchemes)), xe = (e) => {
125
- if (J.value) {
126
- let e = pe(J.value.$el);
128
+ }), De = o(() => Y.value ? [] : re(p.securitySchemes)), Oe = (e) => {
129
+ if (U.value) {
130
+ let e = _e(U.value.$el);
127
131
  setTimeout(() => {
128
132
  e();
129
133
  }, 300);
130
134
  }
131
- q.value = e, e && h.eventBus.emit("workspace:update:selected-client", e.id);
132
- }, Se = c(() => ($.value?.length ?? 0) > 2e4), Ce = ae();
133
- return (n, r) => $.value === null || $.value || b(Y).pending.value ? (g(), l(b(C), {
135
+ H.value = e, e && p.eventBus.emit("workspace:update:selected-client", e.id);
136
+ }, ke = o(() => (X.value?.length ?? 0) > 2e4), $ = se();
137
+ return (n, r) => X.value === null || X.value || v(W).pending.value ? (m(), s(v(x), {
134
138
  key: 0,
135
139
  ref_key: "elem",
136
- ref: J,
140
+ ref: U,
137
141
  class: "request-card dark-mode"
138
142
  }, {
139
- default: S(() => [
140
- m(b(ce), { class: "pr-2.5" }, ne({
141
- default: S(() => [
142
- r[1] ||= f("span", { class: "sr-only" }, "Request Example for", -1),
143
- m(o, {
143
+ default: b(() => [
144
+ f(v(ue), { class: "pr-2.5" }, ie({
145
+ default: b(() => [
146
+ r[1] ||= u("span", { class: "sr-only" }, "Request Example for", -1),
147
+ f(i, {
144
148
  as: "span",
145
149
  class: "request-method",
146
- method: h.method
150
+ method: p.method
147
151
  }, null, 8, ["method"]),
148
- h.generateLabel ? (g(), d("span", {
152
+ p.generateLabel ? (m(), l("span", {
149
153
  key: 0,
150
- innerHTML: h.generateLabel()
151
- }, null, 8, j)) : u("", !0),
152
- v(n.$slots, "header", {}, void 0, !0)
154
+ innerHTML: p.generateLabel()
155
+ }, null, 8, D)) : c("", !0),
156
+ g(n.$slots, "header", {}, void 0, !0)
153
157
  ]),
154
158
  _: 2
155
- }, [!h.isWebhook && K.value ? {
159
+ }, [!p.isWebhook && V.value ? {
156
160
  name: "actions",
157
- fn: S(() => [K.value > 1 ? (g(), l(b(de), {
161
+ fn: b(() => [V.value > 1 ? (m(), s(v(he), {
158
162
  key: 0,
159
163
  class: "max-h-80",
160
- filterFn: b(t),
161
- inputLabel: h.clientSearchLabel,
162
- modelValue: q.value,
163
- options: G.value,
164
+ filterFn: v(t),
165
+ inputLabel: p.clientSearchLabel,
166
+ modelValue: H.value,
167
+ options: B.value,
164
168
  placement: "bottom-end",
165
169
  teleport: "",
166
- "onUpdate:modelValue": r[0] ||= (e) => xe(e)
170
+ "onUpdate:modelValue": r[0] ||= (e) => Oe(e)
167
171
  }, {
168
- default: S(() => [m(b(T), {
169
- "aria-label": he.value,
172
+ default: b(() => [f(v(C), {
173
+ "aria-label": Ce.value,
170
174
  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",
171
175
  "data-testid": "client-picker",
172
176
  variant: "ghost"
173
177
  }, {
174
- default: S(() => [p(y(q.value?.title) + " ", 1), m(b(ue), {
178
+ default: b(() => [d(_(H.value?.title) + " ", 1), f(v(me), {
175
179
  class: "ui-open:rotate-180 mt-px size-3 transition-transform duration-100",
176
180
  weight: "bold"
177
181
  })]),
@@ -183,76 +187,87 @@ var j = ["innerHTML"], M = {
183
187
  "inputLabel",
184
188
  "modelValue",
185
189
  "options"
186
- ])) : (g(), d("span", M, y(q.value?.title), 1))]),
190
+ ])) : (m(), l("span", O, _(H.value?.title), 1))]),
187
191
  key: "0"
188
192
  } : void 0]), 1024),
189
- m(b(w), { class: "request-editor-section custom-scroll p-0" }, {
190
- default: S(() => [b(Y).pending.value ? (g(), d("div", N, [b(Y).failed.value ? (g(), d(s, { key: 0 }, [r[3] ||= p(" Could not load this example. ", -1), m(b(T), {
193
+ f(v(S), { class: "request-editor-section custom-scroll p-0" }, {
194
+ default: b(() => [v(W).pending.value ? (m(), l("div", k, [v(W).failed.value ? (m(), l(a, { key: 0 }, [r[3] ||= d(" Could not load this example. ", -1), f(v(C), {
191
195
  size: "sm",
192
196
  variant: "ghost",
193
- onClick: b(Y).retry
197
+ onClick: v(W).retry
194
198
  }, {
195
- default: S(() => [...r[2] ||= [p(" Retry ", -1)]]),
199
+ default: b(() => [...r[2] ||= [d(" Retry ", -1)]]),
196
200
  _: 1
197
- }, 8, ["onClick"])], 64)) : (g(), d(s, { key: 1 }, [p("Loading example…")], 64))])) : $.value === null ? (g(), d("div", P, y(h.codeSampleUnavailable), 1)) : (g(), d("div", {
201
+ }, 8, ["onClick"])], 64)) : (m(), l(a, { key: 1 }, [d("Loading example…")], 64))])) : X.value === null ? (m(), l("div", A, _(p.codeSampleUnavailable), 1)) : (m(), l("div", {
198
202
  key: 2,
199
- id: `${b(Ce)}-example`,
200
- class: "code-snippet"
201
- }, [Se.value ? (g(), l(b(fe), {
202
- key: 1,
203
+ id: `${v($)}-example`,
204
+ class: "code-snippet group/code-block relative"
205
+ }, [ke.value ? (m(), l(a, { key: 1 }, [f(v(fe), {
206
+ "aria-controls": `${v($)}-virtual-code`,
207
+ class: "scalar-code-copy absolute top-2.5 right-2.5 z-1",
208
+ content: X.value,
209
+ lang: Q.value
210
+ }, null, 8, [
211
+ "aria-controls",
212
+ "content",
213
+ "lang"
214
+ ]), f(v(ge), {
215
+ id: `${v($)}-virtual-code`,
203
216
  "aria-label": "Request code sample",
204
217
  containerClass: "custom-scroll scalar-code-block border rounded-b flex flex-1 max-h-screen",
205
218
  contentClass: "language-plaintext whitespace-pre font-code text-base p-2",
206
219
  lineHeight: 20,
207
220
  role: "region",
208
- text: $.value
209
- }, null, 8, ["text"])) : (g(), l(b(le), {
221
+ text: Z.value ?? ""
222
+ }, null, 8, ["id", "text"])], 64)) : (m(), s(v(de), {
210
223
  key: 0,
211
224
  class: "bg-b-2 h-full",
212
- content: $.value,
213
- hideCredentials: be.value,
214
- label: ge.value,
215
- lang: ve.value,
225
+ content: Z.value ?? "",
226
+ copyContent: Y.value ? X.value ?? "" : void 0,
227
+ hideCredentials: De.value,
228
+ label: we.value,
229
+ lang: Q.value,
216
230
  lineNumbers: ""
217
231
  }, null, 8, [
218
232
  "content",
233
+ "copyContent",
219
234
  "hideCredentials",
220
235
  "label",
221
236
  "lang"
222
- ]))], 8, F))]),
237
+ ]))], 8, j))]),
223
238
  _: 1
224
239
  }),
225
- Z.value || n.$slots.footer || n.$slots["footer-start"] ? (g(), l(b(se), {
240
+ K.value || n.$slots.footer || n.$slots["footer-start"] ? (m(), s(v(le), {
226
241
  key: 0,
227
- class: re(["request-card-footer bg-b-3", { "request-card-footer--wraps": !Z.value && n.$slots["footer-start"] }])
242
+ class: ae(["request-card-footer bg-b-3", { "request-card-footer--wraps": !K.value && n.$slots["footer-start"] }])
228
243
  }, {
229
- default: S(() => [Z.value ? (g(), d("div", I, [Object.keys(V.value).length ? (g(), l(e, {
244
+ default: b(() => [K.value ? (m(), l("div", M, [Object.keys(I.value).length ? (m(), s(e, {
230
245
  key: 0,
231
- examples: V.value,
232
- modelValue: H.value,
233
- "onUpdate:modelValue": me
234
- }, null, 8, ["examples", "modelValue"])) : u("", !0)])) : n.$slots["footer-start"] ? (g(), d("div", L, [v(n.$slots, "footer-start", {}, void 0, !0)])) : u("", !0), v(n.$slots, "footer", { exampleName: H.value }, void 0, !0)]),
246
+ examples: I.value,
247
+ modelValue: L.value,
248
+ "onUpdate:modelValue": Se
249
+ }, null, 8, ["examples", "modelValue"])) : c("", !0)])) : n.$slots["footer-start"] ? (m(), l("div", N, [g(n.$slots, "footer-start", {}, void 0, !0)])) : c("", !0), g(n.$slots, "footer", { exampleName: L.value }, void 0, !0)]),
235
250
  _: 3
236
- }, 8, ["class"])) : u("", !0)
251
+ }, 8, ["class"])) : c("", !0)
237
252
  ]),
238
253
  _: 3
239
- }, 512)) : h.fallback ? (g(), l(b(C), {
254
+ }, 512)) : p.fallback ? (m(), s(v(x), {
240
255
  key: 1,
241
256
  class: "request-card dark-mode"
242
257
  }, {
243
- default: S(() => [m(b(w), { class: "request-card-simple" }, {
244
- default: S(() => [f("div", R, [m(o, {
258
+ default: b(() => [f(v(S), { class: "request-card-simple" }, {
259
+ default: b(() => [u("div", P, [f(i, {
245
260
  as: "span",
246
261
  class: "request-method",
247
- method: h.method
248
- }, null, 8, ["method"]), v(n.$slots, "header", {}, void 0, !0)]), v(n.$slots, "footer", { exampleName: H.value }, void 0, !0)]),
262
+ method: p.method
263
+ }, null, 8, ["method"]), g(n.$slots, "header", {}, void 0, !0)]), n.$slots.footer ? (m(), l("div", be, [g(n.$slots, "footer", { exampleName: L.value }, void 0, !0)])) : c("", !0)]),
249
264
  _: 3
250
265
  })]),
251
266
  _: 3
252
- })) : u("", !0);
267
+ })) : c("", !0);
253
268
  }
254
269
  });
255
270
  //#endregion
256
- export { z as default };
271
+ export { F as default };
257
272
 
258
273
  //# sourceMappingURL=CodeExample.vue_vue_type_script_setup_true_lang.js.map