@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
@@ -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","_Fragment","_normalizeClass","ExamplePicker","ExamplePicker_default","HttpMethod_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","CodeExample_vue_vue_type_script_setup_true_lang_default","__emit","emit","requestBodyExamples","computed","content","getResolvedRef","__props","contentType","localExampleKey","ref","resolveExampleKey","keys","preferred","onBeforeMount","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","generatedCode","generateCodeSnippet","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","ScalarCardSection","Fragment","ScalarVirtualText","ScalarCodeBlock","ScalarCardFooter","normalizeClass"],"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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqNA,IAAM6B,IAAOD,GAmBPE,IAAsBC,QAAe;GACzC,IAAMC,IAAUC,EAAeC,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;EA+BA,AA5BAE,SAAoB;GAClB,EAAgB,QAAQH,EAAkBJ,EAAA,eAAe;EAC3D,CAAC,GAGDQ,QACQR,EAAA,kBACL,MAAc;GACb,EAAgB,QAAQI,EAAkBE,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ADf,aAAa7D,EAAA,MAAe,GAAA,KAAA,GAAA,EAAA,C"}
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","_Fragment","_normalizeClass","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","onBeforeMount","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","ScalarCardSection","Fragment","ScalarCodeBlockCopy","ScalarVirtualText","ScalarCodeBlock","ScalarCardFooter","normalizeClass"],"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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2NA,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,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;EA+BA,AA5BAE,SAAoB;GAClB,EAAgB,QAAQH,EAAkBJ,EAAA,eAAe;EAC3D,CAAC,GAGDQ,QACQR,EAAA,kBACL,MAAc;GACb,EAAgB,QAAQI,EAAkBE,CAAS;EACrD,CACF,GAGAE,QACQR,EAAA,2BACA;GACJ,AACG,OAAO,KAAKJ,EAAoB,KAAK,CAAC,CAAC,SAASM,EAAgB,KAAK,MAItE,EAAgB,QAAQE,EAAkBJ,EAAA,eAAe;EAE7D,CACF,GAIAS,SAAkB;GAChB,GAAK,qBAAqBP,EAAgB,KAAK;EACjD,CAAC;EAGD,IAAMQ,MAAiB,MAAgB;GAErC,AADA,EAAgB,QAAQC,GACxBX,EAAA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AAA,GAAAC,EAmBaF,EAAA4F,CAAA,GAAA;;GAjBX,OAAM;;GACN,SAAAzF,QAeoB,CAfpBC,EAeoBJ,EAAA8G,CAAA,GAAA,EAfD,OAAM,sBAAqB,GAAA;IAC5C,SAAA3G,QAMM,CANNG,EAMM,OANNmB,GAMM,CALJrB,EAGqBG,GAAA;KAFnB,IAAG;KACH,OAAM;KACL,QAAQ2B,EAAA;I,yBACXxB,EAAsB4F,EAAA,QAAA,UAAA,CAAA,GAAA,KAAA,GAAA,EAAA,C,IAGhBvG,EAAAA,OAAO,UADfE,EAAA,GAAAO,EAMM,OANNkB,IAMM,CAHJhB,EAEkB4F,EAAA,QAAA,UAAA,EADf,aAAalE,EAAA,MAAe,GAAA,KAAA,GAAA,EAAA,C"}
@@ -11,7 +11,7 @@ export type CustomCodeSampleId = `custom/${string}`;
11
11
  * key the id by language rather than by position: the first sample of a language
12
12
  * becomes `custom/<lang>`, and any further samples that repeat a language fall back
13
13
  * to `custom/<lang>/<n>` so they stay individually selectable within the operation.
14
- * Linked request examples with the same language and label share an id.
14
+ * Linked request examples with the same language, label, and group share an id.
15
15
  *
16
16
  * The language is lower-cased so a selection still matches when operations (or
17
17
  * extensions) spell the same language with different casing (e.g. `Python` vs
@@ -1 +1 @@
1
- {"version":3,"file":"generate-client-options.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/generate-client-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAY,MAAM,kBAAkB,CAAA;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AAGvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD,qCAAqC;AACrC,MAAM,MAAM,kBAAkB,GAAG,UAAU,MAAM,EAAE,CAAA;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,WAAW,EAAE,KAAG,kBAAkB,EAsB7E,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,iBAAgB,gBAAoC,KAAG,iBAAiB,EAuC7G,CAAA"}
1
+ {"version":3,"file":"generate-client-options.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/generate-client-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAY,MAAM,kBAAkB,CAAA;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AAGvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD,qCAAqC;AACrC,MAAM,MAAM,kBAAkB,GAAG,UAAU,MAAM,EAAE,CAAA;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,WAAW,EAAE,KAAG,kBAAkB,EA0B7E,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,iBAAgB,gBAAoC,KAAG,iBAAiB,EAuC7G,CAAA"}
@@ -4,7 +4,11 @@ import { AVAILABLE_CLIENTS as t, snippetz as n } from "@scalar/snippetz";
4
4
  var r = (e) => {
5
5
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
6
6
  return e.map((e) => {
7
- let r = (e.lang || "plaintext").toLowerCase(), i = JSON.stringify([r, e.label ?? ""]), a = e.example === void 0 ? void 0 : n.get(i);
7
+ let r = (e.lang || "plaintext").toLowerCase(), i = JSON.stringify([
8
+ r,
9
+ e.label ?? "",
10
+ typeof e.group == "string" ? e.group.trim() : ""
11
+ ]), a = e.example === void 0 ? void 0 : n.get(i);
8
12
  if (a) return a;
9
13
  let o = t.get(r) ?? 0;
10
14
  t.set(r, o + 1);
@@ -1 +1 @@
1
- {"version":3,"file":"generate-client-options.js","names":["getCustomClientIds","countByLang","linkedGroups","samples","lang","sample","group","existing","seen","id","generateClientOptions","AVAILABLE_CLIENTS","allowedClientsSet","allowedClients","snippetz","options","plugin","capitalize"],"sources":["../../../src/code-example/helpers/generate-client-options.ts"],"sourcesContent":["import { AVAILABLE_CLIENTS, type AvailableClients, snippetz } from '@scalar/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport { capitalize } from 'vue'\n\nimport type { ClientOptionGroup } from '../types'\n\n/** Type of custom code sample IDs */\nexport type CustomCodeSampleId = `custom/${string}`\n\n/**\n * Build stable, language-keyed ids for an operation's custom code samples.\n *\n * Custom samples are defined per operation, but a selection (e.g. the Python SDK\n * example) should sync across every operation that ships the same language. So we\n * key the id by language rather than by position: the first sample of a language\n * becomes `custom/<lang>`, and any further samples that repeat a language fall back\n * to `custom/<lang>/<n>` so they stay individually selectable within the operation.\n * Linked request examples with the same language and label share an id.\n *\n * The language is lower-cased so a selection still matches when operations (or\n * extensions) spell the same language with different casing (e.g. `Python` vs\n * `python`).\n *\n * @param samples - The custom code samples for a single operation\n * @returns A list of ids aligned by index with the input samples\n */\nexport const getCustomClientIds = (samples: XCodeSample[]): CustomCodeSampleId[] => {\n const countByLang = new Map<string, number>()\n const linkedGroups = new Map<string, CustomCodeSampleId>()\n\n return samples.map((sample): CustomCodeSampleId => {\n const lang = (sample.lang || 'plaintext').toLowerCase()\n const group = JSON.stringify([lang, sample.label ?? ''])\n const existing = sample.example !== undefined ? linkedGroups.get(group) : undefined\n if (existing) {\n return existing\n }\n\n const seen = countByLang.get(lang) ?? 0\n countByLang.set(lang, seen + 1)\n\n const id: CustomCodeSampleId = seen === 0 ? `custom/${lang}` : `custom/${lang}/${seen}`\n // Named request examples share one language option; legacy samples remain separate.\n if (sample.example !== undefined) {\n linkedGroups.set(group, id)\n }\n return id\n })\n}\n\n/**\n * Generate client options for the request example block by filtering by allowed clients\n *\n * @param allowedClients - The list of allowed clients to include in the options\n * @returns A list of client option groups\n */\nexport const generateClientOptions = (allowedClients: AvailableClients = AVAILABLE_CLIENTS): ClientOptionGroup[] => {\n /** Create set of allowlist for quicker lookups */\n const allowedClientsSet = new Set(allowedClients)\n\n const options = snippetz()\n .clients()\n .flatMap((group) => {\n const options = group.clients.flatMap((plugin) => {\n const id: AvailableClients[number] = `${group.key}/${plugin.client}`\n\n // If the client is not allowed, skip it\n if (!allowedClientsSet.has(id)) {\n return []\n }\n\n return {\n id,\n lang: plugin.client === 'curl' ? ('curl' as const) : group.key,\n title: `${capitalize(group.title)} ${plugin.title}`,\n label: plugin.title,\n targetKey: group.key,\n targetTitle: group.title,\n clientKey: plugin.client,\n }\n })\n\n // If no clients are allowed, skip this group\n if (options.length === 0) {\n return []\n }\n\n return {\n label: group.title,\n key: group.key,\n options,\n }\n })\n\n return options\n}\n"],"mappings":";;;AA0BA,IAAaA,KAAsB,MAAiD;CAClF,IAAMC,oBAAc,IAAI,IAAoB,GACtCC,oBAAe,IAAI,IAAgC;CAEzD,OAAOC,EAAQ,KAAK,MAA+B;EACjD,IAAMC,KAAQC,EAAO,QAAQ,YAAA,CAAa,YAAY,GAChDC,IAAQ,KAAK,UAAU,CAACF,GAAMC,EAAO,SAAS,EAAE,CAAC,GACjDE,IAAWF,EAAO,YAAY,KAAA,IAAsC,KAAA,IAA1BH,EAAa,IAAII,CAAK;EACtE,IAAIC,GACF,OAAOA;EAGT,IAAMC,IAAOP,EAAY,IAAIG,CAAI,KAAK;EACtC,EAAY,IAAIA,GAAMI,IAAO,CAAC;EAE9B,IAAMC,IAAyBD,MAAS,IAAI,UAAUJ,MAAS,UAAUA,EAAK,GAAGI;EAKjF,OAHIH,EAAO,YAAY,KAAA,KACrBH,EAAa,IAAII,GAAOG,CAAE,GAErBA;CACT,CAAC;AACH,GAQaC,KAAyB,IAAmCC,MAA2C;CAElH,IAAMC,IAAoB,IAAI,IAAIC,CAAc;CAoChD,OAlCgBC,EAAS,CAAC,CACvB,QAAQ,CAAC,CACT,SAAS,MAAU;EAClB,IAAMC,IAAUT,EAAM,QAAQ,SAAS,MAAW;GAChD,IAAMG,IAA+B,GAAGH,EAAM,IAAI,GAAGU,EAAO;GAO5D,OAJKJ,EAAkB,IAAIH,CAAE,IAItB;IACL;IACA,MAAMO,EAAO,WAAW,SAAU,SAAmBV,EAAM;IAC3D,OAAO,GAAGW,EAAWX,EAAM,KAAK,EAAE,GAAGU,EAAO;IAC5C,OAAOA,EAAO;IACd,WAAWV,EAAM;IACjB,aAAaA,EAAM;IACnB,WAAWU,EAAO;GACpB,IAXS,CAAC;EAYZ,CAAC;EAOD,OAJID,EAAQ,WAAW,IACd,CAAC,IAGH;GACL,OAAOT,EAAM;GACb,KAAKA,EAAM;GACX;EACF;CACF,CAEK;AACT"}
1
+ {"version":3,"file":"generate-client-options.js","names":["getCustomClientIds","countByLang","linkedGroups","samples","lang","sample","group","existing","seen","id","generateClientOptions","AVAILABLE_CLIENTS","allowedClientsSet","allowedClients","snippetz","options","plugin","capitalize"],"sources":["../../../src/code-example/helpers/generate-client-options.ts"],"sourcesContent":["import { AVAILABLE_CLIENTS, type AvailableClients, snippetz } from '@scalar/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport { capitalize } from 'vue'\n\nimport type { ClientOptionGroup } from '../types'\n\n/** Type of custom code sample IDs */\nexport type CustomCodeSampleId = `custom/${string}`\n\n/**\n * Build stable, language-keyed ids for an operation's custom code samples.\n *\n * Custom samples are defined per operation, but a selection (e.g. the Python SDK\n * example) should sync across every operation that ships the same language. So we\n * key the id by language rather than by position: the first sample of a language\n * becomes `custom/<lang>`, and any further samples that repeat a language fall back\n * to `custom/<lang>/<n>` so they stay individually selectable within the operation.\n * Linked request examples with the same language, label, and group share an id.\n *\n * The language is lower-cased so a selection still matches when operations (or\n * extensions) spell the same language with different casing (e.g. `Python` vs\n * `python`).\n *\n * @param samples - The custom code samples for a single operation\n * @returns A list of ids aligned by index with the input samples\n */\nexport const getCustomClientIds = (samples: XCodeSample[]): CustomCodeSampleId[] => {\n const countByLang = new Map<string, number>()\n const linkedGroups = new Map<string, CustomCodeSampleId>()\n\n return samples.map((sample): CustomCodeSampleId => {\n const lang = (sample.lang || 'plaintext').toLowerCase()\n const group = JSON.stringify([\n lang,\n sample.label ?? '',\n typeof sample.group === 'string' ? sample.group.trim() : '',\n ])\n const existing = sample.example !== undefined ? linkedGroups.get(group) : undefined\n if (existing) {\n return existing\n }\n\n const seen = countByLang.get(lang) ?? 0\n countByLang.set(lang, seen + 1)\n\n const id: CustomCodeSampleId = seen === 0 ? `custom/${lang}` : `custom/${lang}/${seen}`\n // Named request examples share one language option; legacy samples remain separate.\n if (sample.example !== undefined) {\n linkedGroups.set(group, id)\n }\n return id\n })\n}\n\n/**\n * Generate client options for the request example block by filtering by allowed clients\n *\n * @param allowedClients - The list of allowed clients to include in the options\n * @returns A list of client option groups\n */\nexport const generateClientOptions = (allowedClients: AvailableClients = AVAILABLE_CLIENTS): ClientOptionGroup[] => {\n /** Create set of allowlist for quicker lookups */\n const allowedClientsSet = new Set(allowedClients)\n\n const options = snippetz()\n .clients()\n .flatMap((group) => {\n const options = group.clients.flatMap((plugin) => {\n const id: AvailableClients[number] = `${group.key}/${plugin.client}`\n\n // If the client is not allowed, skip it\n if (!allowedClientsSet.has(id)) {\n return []\n }\n\n return {\n id,\n lang: plugin.client === 'curl' ? ('curl' as const) : group.key,\n title: `${capitalize(group.title)} ${plugin.title}`,\n label: plugin.title,\n targetKey: group.key,\n targetTitle: group.title,\n clientKey: plugin.client,\n }\n })\n\n // If no clients are allowed, skip this group\n if (options.length === 0) {\n return []\n }\n\n return {\n label: group.title,\n key: group.key,\n options,\n }\n })\n\n return options\n}\n"],"mappings":";;;AA0BA,IAAaA,KAAsB,MAAiD;CAClF,IAAMC,oBAAc,IAAI,IAAoB,GACtCC,oBAAe,IAAI,IAAgC;CAEzD,OAAOC,EAAQ,KAAK,MAA+B;EACjD,IAAMC,KAAQC,EAAO,QAAQ,YAAA,CAAa,YAAY,GAChDC,IAAQ,KAAK,UAAU;GAC3BF;GACAC,EAAO,SAAS;GAChB,OAAOA,EAAO,SAAU,WAAWA,EAAO,MAAM,KAAK,IAAI;EAC3D,CAAC,GACKE,IAAWF,EAAO,YAAY,KAAA,IAAsC,KAAA,IAA1BH,EAAa,IAAII,CAAK;EACtE,IAAIC,GACF,OAAOA;EAGT,IAAMC,IAAOP,EAAY,IAAIG,CAAI,KAAK;EACtC,EAAY,IAAIA,GAAMI,IAAO,CAAC;EAE9B,IAAMC,IAAyBD,MAAS,IAAI,UAAUJ,MAAS,UAAUA,EAAK,GAAGI;EAKjF,OAHIH,EAAO,YAAY,KAAA,KACrBH,EAAa,IAAII,GAAOG,CAAE,GAErBA;CACT,CAAC;AACH,GAQaC,KAAyB,IAAmCC,MAA2C;CAElH,IAAMC,IAAoB,IAAI,IAAIC,CAAc;CAoChD,OAlCgBC,EAAS,CAAC,CACvB,QAAQ,CAAC,CACT,SAAS,MAAU;EAClB,IAAMC,IAAUT,EAAM,QAAQ,SAAS,MAAW;GAChD,IAAMG,IAA+B,GAAGH,EAAM,IAAI,GAAGU,EAAO;GAO5D,OAJKJ,EAAkB,IAAIH,CAAE,IAItB;IACL;IACA,MAAMO,EAAO,WAAW,SAAU,SAAmBV,EAAM;IAC3D,OAAO,GAAGW,EAAWX,EAAM,KAAK,EAAE,GAAGU,EAAO;IAC5C,OAAOA,EAAO;IACd,WAAWV,EAAM;IACjB,aAAaA,EAAM;IACnB,WAAWU,EAAO;GACpB,IAXS,CAAC;EAYZ,CAAC;EAOD,OAJID,EAAQ,WAAW,IACd,CAAC,IAGH;GACL,OAAOT,EAAM;GACb,KAAKA,EAAM;GACX;EACF;CACF,CAEK;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-clients.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/get-clients.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AAEvF,OAAO,KAAK,EAAE,iBAAiB,EAAsB,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAK9F;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACrB,mBAAmB,WAAW,EAAE,EAChC,eAAe,iBAAiB,EAAE,EAClC,QAAO,MAAkC,KACxC,uBAAuB,EAkCzB,CAAA"}
1
+ {"version":3,"file":"get-clients.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/get-clients.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AAEvF,OAAO,KAAK,EAAE,iBAAiB,EAAsB,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAK9F;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACrB,mBAAmB,WAAW,EAAE,EAChC,eAAe,iBAAiB,EAAE,EAClC,QAAO,MAAkC,KACxC,uBAAuB,EA6BzB,CAAA"}
@@ -3,26 +3,25 @@ import { formatLanguage as t } from "./format-language.js";
3
3
  import { CODE_EXAMPLES_GROUP_LABEL as n } from "./get-custom-code-samples.js";
4
4
  //#region src/code-example/helpers/get-clients.ts
5
5
  var r = (r, i, a = n) => {
6
- if (r.length) {
7
- let n = e(r);
8
- return [{
9
- label: a,
6
+ if (!r.length) return i;
7
+ let o = e(r), s = /* @__PURE__ */ new Map();
8
+ for (let [e, n] of r.entries()) {
9
+ let r = o[e];
10
+ if (!r || o.indexOf(r) !== e) continue;
11
+ let i = typeof n.group == "string" && n.group.trim() || a, c = s.get(i) ?? {
12
+ label: i,
10
13
  key: "custom",
11
- options: r.flatMap((e, r) => {
12
- let i = n[r] ?? `custom/${r}`;
13
- if (n.indexOf(i) !== r) return [];
14
- let a = e.label || t(e.lang) || i;
15
- return {
16
- id: i,
17
- lang: e.lang || "plaintext",
18
- title: a,
19
- label: a,
20
- clientKey: "custom"
21
- };
22
- })
23
- }, ...i];
14
+ options: []
15
+ }, l = n.label || t(n.lang) || r;
16
+ c.options.push({
17
+ id: r,
18
+ lang: n.lang || "plaintext",
19
+ title: l,
20
+ label: l,
21
+ clientKey: "custom"
22
+ }), s.set(i, c);
24
23
  }
25
- return i;
24
+ return [...s.values(), ...i];
26
25
  };
27
26
  //#endregion
28
27
  export { r as getClients };
@@ -1 +1 @@
1
- {"version":3,"file":"get-clients.js","names":["getClients","CODE_EXAMPLES_GROUP_LABEL","customCodeSamples","ids","getCustomClientIds","id","index","label","sample","formatLanguage","clientOptions"],"sources":["../../../src/code-example/helpers/get-clients.ts"],"sourcesContent":["import type { TargetId } from '@scalar/types/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\n\nimport type { ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from '../types'\nimport { formatLanguage } from './format-language'\nimport { getCustomClientIds } from './generate-client-options'\nimport { CODE_EXAMPLES_GROUP_LABEL } from './get-custom-code-samples'\n\n/**\n * Merges custom code samples with the client options\n *\n * @param customCodeSamples - The custom code samples from the operation to merge with the client options\n * @param clientOptions - The client options to merge with the custom code samples\n * @param label - The label for the custom samples group (e.g. \"SDK\" or \"Code Examples\")\n * @returns A list of client option groups\n */\nexport const getClients = (\n customCodeSamples: XCodeSample[],\n clientOptions: ClientOptionGroup[],\n label: string = CODE_EXAMPLES_GROUP_LABEL,\n): CustomClientOptionGroup[] => {\n // Handle custom code examples\n if (customCodeSamples.length) {\n // Language-keyed ids so the same sample can be selected across operations\n const ids = getCustomClientIds(customCodeSamples)\n\n const customClients = customCodeSamples.flatMap((sample, index) => {\n const id = ids[index] ?? `custom/${index}`\n if (ids.indexOf(id) !== index) {\n return []\n }\n const label = sample.label || formatLanguage(sample.lang) || id\n const lang = (sample.lang as TargetId) || 'plaintext'\n\n return {\n id,\n lang,\n title: label,\n label,\n clientKey: 'custom',\n } satisfies CustomClientOption\n })\n\n return [\n {\n label,\n key: 'custom',\n options: customClients,\n },\n ...clientOptions,\n ]\n }\n\n return clientOptions\n}\n"],"mappings":";;;;AAgBA,IAAaA,KACX,GACA,GACA,IAAgBC,MACc;CAE9B,IAAIC,EAAkB,QAAQ;EAE5B,IAAMC,IAAMC,EAAmBF,CAAiB;EAmBhD,OAAO,CACL;GACE;GACA,KAAK;GACL,SArBkBA,EAAkB,SAAS,GAAQ,MAAU;IACjE,IAAMG,IAAKF,EAAIG,MAAU,UAAUA;IACnC,IAAIH,EAAI,QAAQE,CAAE,MAAMC,GACtB,OAAO,CAAC;IAEV,IAAMC,IAAQC,EAAO,SAASC,EAAeD,EAAO,IAAI,KAAKH;IAG7D,OAAO;KACL;KACA,MAJYG,EAAO,QAAqB;KAKxC,OAAOD;KACP;KACA,WAAW;IACb;GACF,CAMa;EACX,GACA,GAAGG,CACL;CACF;CAEA,OAAOA;AACT"}
1
+ {"version":3,"file":"get-clients.js","names":["getClients","CODE_EXAMPLES_GROUP_LABEL","customCodeSamples","clientOptions","ids","getCustomClientIds","groups","index","sample","id","groupLabel","label","group","optionLabel","formatLanguage"],"sources":["../../../src/code-example/helpers/get-clients.ts"],"sourcesContent":["import type { TargetId } from '@scalar/types/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\n\nimport type { ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from '../types'\nimport { formatLanguage } from './format-language'\nimport { getCustomClientIds } from './generate-client-options'\nimport { CODE_EXAMPLES_GROUP_LABEL } from './get-custom-code-samples'\n\n/**\n * Merges custom code samples with the client options\n *\n * @param customCodeSamples - The custom code samples from the operation to merge with the client options\n * @param clientOptions - The client options to merge with the custom code samples\n * @param label - The label for the custom samples group (e.g. \"SDK\" or \"Code Examples\")\n * @returns A list of client option groups\n */\nexport const getClients = (\n customCodeSamples: XCodeSample[],\n clientOptions: ClientOptionGroup[],\n label: string = CODE_EXAMPLES_GROUP_LABEL,\n): CustomClientOptionGroup[] => {\n if (!customCodeSamples.length) {\n return clientOptions\n }\n\n const ids = getCustomClientIds(customCodeSamples)\n const groups = new Map<string, CustomClientOptionGroup>()\n\n for (const [index, sample] of customCodeSamples.entries()) {\n const id = ids[index]\n if (!id || ids.indexOf(id) !== index) {\n continue\n }\n\n // Empty headings retain the source extension's existing default group.\n const groupLabel = (typeof sample.group === 'string' && sample.group.trim()) || label\n const group = groups.get(groupLabel) ?? { label: groupLabel, key: 'custom', options: [] }\n const optionLabel = sample.label || formatLanguage(sample.lang) || id\n group.options.push({\n id,\n lang: (sample.lang as TargetId) || 'plaintext',\n title: optionLabel,\n label: optionLabel,\n clientKey: 'custom',\n } satisfies CustomClientOption)\n groups.set(groupLabel, group)\n }\n\n return [...groups.values(), ...clientOptions]\n}\n"],"mappings":";;;;AAgBA,IAAaA,KACX,GACA,GACA,IAAgBC,MACc;CAC9B,IAAI,CAACC,EAAkB,QACrB,OAAOC;CAGT,IAAMC,IAAMC,EAAmBH,CAAiB,GAC1CI,oBAAS,IAAI,IAAqC;CAExD,KAAK,IAAM,CAACC,GAAOC,MAAWN,EAAkB,QAAQ,GAAG;EACzD,IAAMO,IAAKL,EAAIG;EACf,IAAI,CAACE,KAAML,EAAI,QAAQK,CAAE,MAAMF,GAC7B;EAIF,IAAMG,IAAc,OAAOF,EAAO,SAAU,YAAYA,EAAO,MAAM,KAAK,KAAMG,GAC1EC,IAAQN,EAAO,IAAII,CAAU,KAAK;GAAE,OAAOA;GAAY,KAAK;GAAU,SAAS,CAAC;EAAE,GAClFG,IAAcL,EAAO,SAASM,EAAeN,EAAO,IAAI,KAAKC;EAQnE,AAPAG,EAAM,QAAQ,KAAK;GACjB;GACA,MAAOJ,EAAO,QAAqB;GACnC,OAAOK;GACP,OAAOA;GACP,WAAW;EACb,CAA8B,GAC9BP,EAAO,IAAII,GAAYE,CAAK;CAC9B;CAEA,OAAO,CAAC,GAAGN,EAAO,OAAO,GAAG,GAAGH,CAAa;AAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-generated-payload-example.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/get-generated-payload-example.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAmBvE,8EAA8E;AAC9E,eAAO,MAAM,0BAA0B,GAAI,SAAS,qBAAqB,KAAG,OA4B3E,CAAA"}
1
+ {"version":3,"file":"get-generated-payload-example.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/get-generated-payload-example.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAmBvE,8EAA8E;AAC9E,eAAO,MAAM,0BAA0B,GAAI,SAAS,qBAAqB,KAAG,OA0B3E,CAAA"}
@@ -14,10 +14,7 @@ var a = (n, r = /* @__PURE__ */ new Set()) => {
14
14
  let c = n(o.payload), l = c?.kind === "schema" ? c.schema : void 0;
15
15
  if (!l || a(l)) return;
16
16
  let u = r(l);
17
- return i(u, {
18
- emptyString: "string",
19
- includeDeprecated: !0
20
- });
17
+ return i(u, { emptyString: "string" });
21
18
  };
22
19
  //#endregion
23
20
  export { o as getGeneratedPayloadExample };
@@ -1 +1 @@
1
- {"version":3,"file":"get-generated-payload-example.js","names":["hasFalseAllOfMember","schema","getResolvedAsyncApiRef","source","isObject","seen","member","getGeneratedPayloadExample","message","example","payload","resolved","resolveAsyncApiSchema","snapshot","snapshotSchema","getExampleFromSchema"],"sources":["../../../src/code-example/helpers/get-generated-payload-example.ts"],"sourcesContent":["import { isObject } from '@scalar/helpers/object/is-object'\nimport type { AsyncApiMessageObject } from '@scalar/types/asyncapi/3.1'\nimport { getResolvedAsyncApiRef } from '@scalar/workspace-store/helpers/get-resolved-async-api-ref'\nimport { resolveAsyncApiSchema } from '@scalar/workspace-store/helpers/resolve-async-api-schema'\nimport { snapshotSchema } from '@scalar/workspace-store/helpers/snapshot-schema'\nimport { getExampleFromSchema } from '@scalar/workspace-store/request-example'\n\n/** An allOf containing a false schema cannot have a valid example. */\nconst hasFalseAllOfMember = (source: unknown, seen = new Set<unknown>()): boolean => {\n const schema = getResolvedAsyncApiRef(source)\n if (schema === false) {\n return true\n }\n if (!isObject(schema) || seen.has(schema)) {\n return false\n }\n seen.add(schema)\n return Array.isArray(schema.allOf) && schema.allOf.some((member) => hasFalseAllOfMember(member, seen))\n}\n\n/** Generate a payload only when the document does not already provide one. */\nexport const getGeneratedPayloadExample = (message: AsyncApiMessageObject): unknown => {\n if (message.examples?.some((example) => getResolvedAsyncApiRef(example)?.payload !== undefined)) {\n return undefined\n }\n\n const payload = getResolvedAsyncApiRef(message.payload)\n // Boolean schemas describe validation, but do not suggest a representative payload.\n if (\n typeof payload === 'boolean' ||\n (isObject(payload) && 'schemaFormat' in payload && typeof getResolvedAsyncApiRef(payload.schema) === 'boolean')\n ) {\n return undefined\n }\n\n const resolved = resolveAsyncApiSchema(message.payload)\n const schema = resolved?.kind === 'schema' ? resolved.schema : undefined\n if (!schema || hasFalseAllOfMember(schema)) {\n return undefined\n }\n\n // Snapshot reactive schemas so in-place edits do not reuse the generator's identity cache.\n // The generator resolves schema references itself, preserving literal $ref fields in payload data.\n const snapshot = snapshotSchema(schema)\n return getExampleFromSchema(snapshot, {\n emptyString: 'string',\n // Match the message schema, which displays fields regardless of their read/write annotations.\n includeDeprecated: true,\n })\n}\n"],"mappings":";;;;;;AAQA,IAAMA,KAAuB,GAAiB,oBAAO,IAAI,IAAa,MAAe;CACnF,IAAMC,IAASC,EAAuBC,CAAM;CAQ5C,OAPIF,MAAW,KACN,KAEL,CAACG,EAASH,CAAM,KAAKI,EAAK,IAAIJ,CAAM,IAC/B,MAETI,EAAK,IAAIJ,CAAM,GACR,MAAM,QAAQA,EAAO,KAAK,KAAKA,EAAO,MAAM,MAAM,MAAWD,EAAoBM,GAAQD,CAAI,CAAC;AACvG,GAGaE,KAA8B,MAA4C;CACrF,IAAIC,EAAQ,UAAU,MAAM,MAAYN,EAAuBO,CAAO,CAAC,EAAE,YAAY,KAAA,CAAS,GAC5F;CAGF,IAAMC,IAAUR,EAAuBM,EAAQ,OAAO;CAEtD,IACE,OAAOE,KAAY,aAClBN,EAASM,CAAO,KAAK,kBAAkBA,KAAW,OAAOR,EAAuBQ,EAAQ,MAAM,KAAM,WAErG;CAGF,IAAMC,IAAWC,EAAsBJ,EAAQ,OAAO,GAChDP,IAASU,GAAU,SAAS,WAAWA,EAAS,SAAS,KAAA;CAC/D,IAAI,CAACV,KAAUD,EAAoBC,CAAM,GACvC;CAKF,IAAMY,IAAWC,EAAeb,CAAM;CACtC,OAAOc,EAAqBF,GAAU;EACpC,aAAa;EAEb,mBAAmB;CACrB,CAAC;AACH"}
1
+ {"version":3,"file":"get-generated-payload-example.js","names":["hasFalseAllOfMember","schema","getResolvedAsyncApiRef","source","isObject","seen","member","getGeneratedPayloadExample","message","example","payload","resolved","resolveAsyncApiSchema","snapshot","snapshotSchema","getExampleFromSchema"],"sources":["../../../src/code-example/helpers/get-generated-payload-example.ts"],"sourcesContent":["import { isObject } from '@scalar/helpers/object/is-object'\nimport type { AsyncApiMessageObject } from '@scalar/types/asyncapi/3.1'\nimport { getResolvedAsyncApiRef } from '@scalar/workspace-store/helpers/get-resolved-async-api-ref'\nimport { resolveAsyncApiSchema } from '@scalar/workspace-store/helpers/resolve-async-api-schema'\nimport { snapshotSchema } from '@scalar/workspace-store/helpers/snapshot-schema'\nimport { getExampleFromSchema } from '@scalar/workspace-store/request-example'\n\n/** An allOf containing a false schema cannot have a valid example. */\nconst hasFalseAllOfMember = (source: unknown, seen = new Set<unknown>()): boolean => {\n const schema = getResolvedAsyncApiRef(source)\n if (schema === false) {\n return true\n }\n if (!isObject(schema) || seen.has(schema)) {\n return false\n }\n seen.add(schema)\n return Array.isArray(schema.allOf) && schema.allOf.some((member) => hasFalseAllOfMember(member, seen))\n}\n\n/** Generate a payload only when the document does not already provide one. */\nexport const getGeneratedPayloadExample = (message: AsyncApiMessageObject): unknown => {\n if (message.examples?.some((example) => getResolvedAsyncApiRef(example)?.payload !== undefined)) {\n return undefined\n }\n\n const payload = getResolvedAsyncApiRef(message.payload)\n // Boolean schemas describe validation, but do not suggest a representative payload.\n if (\n typeof payload === 'boolean' ||\n (isObject(payload) && 'schemaFormat' in payload && typeof getResolvedAsyncApiRef(payload.schema) === 'boolean')\n ) {\n return undefined\n }\n\n const resolved = resolveAsyncApiSchema(message.payload)\n const schema = resolved?.kind === 'schema' ? resolved.schema : undefined\n if (!schema || hasFalseAllOfMember(schema)) {\n return undefined\n }\n\n // Snapshot reactive schemas so in-place edits do not reuse the generator's identity cache.\n // The generator resolves schema references itself, preserving literal $ref fields in payload data.\n const snapshot = snapshotSchema(schema)\n return getExampleFromSchema(snapshot, {\n emptyString: 'string',\n })\n}\n"],"mappings":";;;;;;AAQA,IAAMA,KAAuB,GAAiB,oBAAO,IAAI,IAAa,MAAe;CACnF,IAAMC,IAASC,EAAuBC,CAAM;CAQ5C,OAPIF,MAAW,KACN,KAEL,CAACG,EAASH,CAAM,KAAKI,EAAK,IAAIJ,CAAM,IAC/B,MAETI,EAAK,IAAIJ,CAAM,GACR,MAAM,QAAQA,EAAO,KAAK,KAAKA,EAAO,MAAM,MAAM,MAAWD,EAAoBM,GAAQD,CAAI,CAAC;AACvG,GAGaE,KAA8B,MAA4C;CACrF,IAAIC,EAAQ,UAAU,MAAM,MAAYN,EAAuBO,CAAO,CAAC,EAAE,YAAY,KAAA,CAAS,GAC5F;CAGF,IAAMC,IAAUR,EAAuBM,EAAQ,OAAO;CAEtD,IACE,OAAOE,KAAY,aAClBN,EAASM,CAAO,KAAK,kBAAkBA,KAAW,OAAOR,EAAuBQ,EAAQ,MAAM,KAAM,WAErG;CAGF,IAAMC,IAAWC,EAAsBJ,EAAQ,OAAO,GAChDP,IAASU,GAAU,SAAS,WAAWA,EAAS,SAAS,KAAA;CAC/D,IAAI,CAACV,KAAUD,EAAoBC,CAAM,GACvC;CAKF,IAAMY,IAAWC,EAAeb,CAAM;CACtC,OAAOc,EAAqBF,GAAU,EACpC,aAAa,SACf,CAAC;AACH"}
@@ -40,7 +40,7 @@ export type CustomClientOption = ScalarComboboxOption & {
40
40
  export type CustomOrDefaultClientOption = ClientOption | CustomClientOption;
41
41
  /** Augments the base combobox option group with CustomClientOptions */
42
42
  export type CustomClientOptionGroup = ScalarComboboxOptionGroup<CustomOrDefaultClientOption> & {
43
- /** Key of the group */
43
+ /** Client category, shared by all custom sample groups; not a unique heading identifier. */
44
44
  key: 'custom' | TargetId;
45
45
  };
46
46
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/code-example/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE5E;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,oBAAoB,GAAG;IAChD,yBAAyB;IACzB,EAAE,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC5B,8FAA8F;IAC9F,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAA;IACrC,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAA;IACb,6EAA6E;IAC7E,SAAS,EAAE,QAAQ,CAAA;IACnB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,gCAAgC;IAChC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;CAC9B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,yBAAyB,CAAC,YAAY,CAAC,GAAG;IACxE,uBAAuB;IACvB,GAAG,EAAE,QAAQ,CAAA;CACd,CAAA;AAED,qEAAqE;AACrE,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GAAG;IACtD,kBAAkB;IAClB,EAAE,EAAE,UAAU,MAAM,EAAE,CAAA;IACtB,8FAA8F;IAC9F,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAA;IACrC,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAA;IACb,gCAAgC;IAChC,SAAS,EAAE,QAAQ,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,2BAA2B,G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Q,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAE3E,uEAAuE;AACvE,MAAM,MAAM,uBAAuB,GAAG,yBAAyB,CAAC,2BAA2B,CAAC,GAAG;IAC7F,4FAA4F;IAC5F,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAAA;CACzB,CAAA"}
package/dist/constants.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/constants.ts
2
- var e = typeof OVERRIDE_PACKAGE_VERSION < "u" ? OVERRIDE_PACKAGE_VERSION : "0.6.3";
2
+ var e = typeof OVERRIDE_PACKAGE_VERSION < "u" ? OVERRIDE_PACKAGE_VERSION : "0.7.0";
3
3
  //#endregion
4
4
  export { e as APP_VERSION };
5
5
 
@@ -2,7 +2,7 @@ import e from "../_virtual/_plugin-vue_export-helper.js";
2
2
  import t from "./SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js";
3
3
  /* empty css */
4
4
  //#region src/schema/SchemaPropertyExamples.vue
5
- var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-1380dfca"]]);
5
+ var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-a431d692"]]);
6
6
  //#endregion
7
7
  export { n as default };
8
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaPropertyExamples.vue.js","names":["_sfc_main","_plugin_vue_export_helper_default","SchemaPropertyExamples_vue_vue_type_script_setup_true_lang_default","SchemaPropertyExamples_default"],"sources":["../../src/schema/SchemaPropertyExamples.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { isObject, isObjectLike } from '@scalar/helpers/object/is-object'\nimport { useClipboard } from '@scalar/use-hooks/useClipboard'\nimport { onClickOutside, onKeyStroke } from '@vueuse/core'\nimport { computed, ref, useId } from 'vue'\n\nimport { formatExample } from './helpers/format-example'\nimport LinkButton from './LinkButton.vue'\nimport { useLocalization } from './localization'\n\nconst {\n examples,\n example,\n align = 'center',\n} = defineProps<{\n /** Align the popup with its label when centering would overlap adjacent content. */\n align?: 'center' | 'start'\n examples?: unknown\n example?: unknown\n}>()\n\nconst { copyToClipboard } = useClipboard()\nconst { translate } = useLocalization()\n\n// `null` is a meaningful example value for nullable schemas, so only treat\n// `undefined` as \"not provided\".\nconst hasSingleExample = computed(() => example !== undefined)\n\nconst normalizedExamples = computed<Record<string, unknown>>(() => {\n if (isObjectLike(examples)) {\n return examples\n }\n\n return {}\n})\n\nconst hasMultipleExamples = computed(\n () => Object.keys(normalizedExamples.value).length > 0,\n)\n\nconst multipleExamplesLabel = computed(() =>\n Object.keys(normalizedExamples.value).length === 1\n ? translate('schema.example')\n : translate('schema.examples'),\n)\n\n/**\n * Unwrap an OpenAPI 3 Example Object (`{ value, externalValue, summary, description }`)\n * to the actual sample. Plain values pass through untouched.\n */\nfunction unwrapExampleObject(value: unknown): unknown {\n if (isObject(value)) {\n if ('value' in value) {\n return value.value\n }\n if ('externalValue' in value) {\n return value.externalValue\n }\n }\n return value\n}\n\n/**\n * Hover/`:focus-within` CSS alone left the popup unreachable by Enter, Escape\n * or touch, so it is pinned open on click (as in SchemaPropertyPattern.vue).\n * `example` and `examples` can both render, so each popup has its own state.\n */\nconst singleRootRef = ref<HTMLElement | null>(null)\nconst singleTriggerRef = ref<HTMLElement | { $el: HTMLElement } | null>(null)\nconst isSingleOpen = ref(false)\nconst singlePopupId = useId()\n\nconst multipleRootRef = ref<HTMLElement | null>(null)\nconst multipleTriggerRef = ref<HTMLElement | { $el: HTMLElement } | null>(null)\nconst isMultipleOpen = ref(false)\nconst multiplePopupId = useId()\n\n/**\n * Focus opens the popup through the same state as the click, not a separate\n * `:focus-within` rule; with both, a click's own `focusin` opened it first and\n * the click closed it again. This flag stops a pointer press counting as focus.\n */\nlet openedByPointer = false\n\n/** Long enough to span a touch tap's delayed compatibility mouse events. */\nconst POINTER_GUARD_MS = 500\nlet pointerGuardTimer = 0\n\n/**\n * `closeAndRestore` refocuses the trigger, and `focus()` fires `focusin`\n * synchronously, which would re-open the popup and make the first Escape inert.\n */\nlet restoringFocus = false\n\nconst onPointerDown = (): void => {\n /*\n * A touch tap's compatibility mousedown (which moves focus) lands 50-150ms\n * after touchend, past any one-frame guard, so the tap opened then closed.\n */\n openedByPointer = true\n window.clearTimeout(pointerGuardTimer)\n pointerGuardTimer = window.setTimeout(() => {\n openedByPointer = false\n }, POINTER_GUARD_MS)\n}\n\nconst leftPopup = (event: FocusEvent, root: HTMLElement | null): boolean => {\n const next = event.relatedTarget\n\n return !(next instanceof Node) || !root?.contains(next)\n}\n\nconst onSingleFocusIn = (): void => {\n if (!openedByPointer && !restoringFocus) {\n isSingleOpen.value = true\n }\n}\n\nconst onSingleFocusOut = (event: FocusEvent): void => {\n if (leftPopup(event, singleRootRef.value)) {\n isSingleOpen.value = false\n }\n}\n\nconst onMultipleFocusIn = (): void => {\n if (!openedByPointer && !restoringFocus) {\n isMultipleOpen.value = true\n }\n}\n\nconst onMultipleFocusOut = (event: FocusEvent): void => {\n if (leftPopup(event, multipleRootRef.value)) {\n isMultipleOpen.value = false\n }\n}\n\nonClickOutside(singleRootRef, () => {\n isSingleOpen.value = false\n})\n\nonClickOutside(multipleRootRef, () => {\n isMultipleOpen.value = false\n})\n\n/**\n * Closing hides the popup outright, so focus is handed back deliberately, or\n * Escape from inside it drops focus to <body>.\n */\nconst closeAndRestore = (\n open: typeof isSingleOpen,\n root: typeof singleRootRef,\n trigger: typeof singleTriggerRef,\n): void => {\n if (!open.value) {\n return\n }\n\n const wasInside = root.value?.contains(document.activeElement)\n\n open.value = false\n\n if (wasInside) {\n const element = trigger.value\n const focusable = element instanceof HTMLElement ? element : element?.$el\n\n restoringFocus = true\n focusable?.focus?.()\n restoringFocus = false\n }\n}\n\nonKeyStroke('Escape', () => {\n closeAndRestore(isSingleOpen, singleRootRef, singleTriggerRef)\n closeAndRestore(isMultipleOpen, multipleRootRef, multipleTriggerRef)\n})\n</script>\n<template>\n <!-- single example (deprecated) -->\n <template v-if=\"hasSingleExample\">\n <div\n ref=\"singleRootRef\"\n class=\"property-example\"\n :class=\"{ 'is-open': isSingleOpen }\"\n @focusin=\"onSingleFocusIn\"\n @focusout=\"onSingleFocusOut\">\n <LinkButton\n ref=\"singleTriggerRef\"\n :aria-controls=\"singlePopupId\"\n :aria-expanded=\"isSingleOpen\"\n class=\"decoration-dotted\"\n @click=\"isSingleOpen = !isSingleOpen\"\n @pointerdown=\"onPointerDown\">\n {{ translate('schema.example') }}\n </LinkButton>\n <div\n :id=\"singlePopupId\"\n class=\"property-example-value-list\"\n :class=\"{\n 'flex!': isSingleOpen,\n 'property-example-value-list-start': align === 'start',\n }\">\n <button\n :aria-label=\"`${translate('common.copyExample')}: ${formatExample(example)}`\"\n class=\"property-example-value group\"\n type=\"button\"\n @click=\"copyToClipboard(formatExample(example))\">\n <span>\n {{ formatExample(example) }}\n </span>\n <ScalarIcon\n aria-hidden=\"true\"\n class=\"group-hover:text-c-1 text-c-3 ml-auto min-h-3 min-w-3\"\n icon=\"Clipboard\"\n size=\"xs\" />\n </button>\n </div>\n </div>\n </template>\n\n <!-- multiple examples -->\n <template v-if=\"hasMultipleExamples\">\n <div\n ref=\"multipleRootRef\"\n class=\"property-example\"\n :class=\"{ 'is-open': isMultipleOpen }\"\n @focusin=\"onMultipleFocusIn\"\n @focusout=\"onMultipleFocusOut\">\n <LinkButton\n ref=\"multipleTriggerRef\"\n :aria-controls=\"multiplePopupId\"\n :aria-expanded=\"isMultipleOpen\"\n class=\"decoration-dotted\"\n @click=\"isMultipleOpen = !isMultipleOpen\"\n @pointerdown=\"onPointerDown\">\n {{ multipleExamplesLabel }}\n </LinkButton>\n <div\n :id=\"multiplePopupId\"\n class=\"property-example-value-list\"\n :class=\"{\n 'flex!': isMultipleOpen,\n 'property-example-value-list-start': align === 'start',\n }\">\n <button\n v-for=\"(ex, key) in normalizedExamples\"\n :key=\"key\"\n :aria-label=\"`${translate('common.copyExample')}: ${formatExample(unwrapExampleObject(ex))}`\"\n class=\"property-example-value group\"\n type=\"button\"\n @click=\"copyToClipboard(formatExample(unwrapExampleObject(ex)))\">\n <span>{{ formatExample(unwrapExampleObject(ex)) }} </span>\n <ScalarIcon\n aria-hidden=\"true\"\n class=\"text-c-3 group-hover:text-c-1 ml-auto min-h-3 min-w-3\"\n icon=\"Clipboard\"\n size=\"xs\" />\n </button>\n </div>\n </div>\n </template>\n</template>\n\n<style scoped>\n@reference \"../style.css\";\n\n.property-example {\n display: flex;\n flex-direction: column;\n font-size: var(--scalar-mini);\n position: relative;\n}\n.property-example:hover:before {\n pointer-events: none;\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 20px;\n border-radius: var(--scalar-radius);\n}\n.property-example-value {\n font-family: var(--scalar-font-code);\n display: flex;\n gap: 8px;\n align-items: center;\n width: 100%;\n padding: 6px;\n}\n.property-example-value span {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.property-example-value :deep(svg) {\n color: var(--scalar-color-3);\n}\n\n.property-example-value:hover :deep(svg) {\n color: var(--scalar-color-1);\n}\n\n.property-example-value {\n background: var(--scalar-background-2);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius);\n}\n.property-example-value-list {\n position: absolute;\n top: 18px;\n left: 50%;\n transform: translate3d(-50%, 0, 0);\n overflow: auto;\n background-color: var(--scalar-background-1);\n box-shadow: var(--scalar-shadow-1);\n border-radius: var(--scalar-radius-lg);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n padding: 9px;\n min-width: 200px;\n max-width: 300px;\n flex-direction: column;\n gap: 3px;\n display: none;\n @apply z-context;\n}\n.property-example-value-list-start {\n left: 0;\n transform: none;\n}\n.property-example:hover .property-example-value-list {\n display: flex;\n}\n</style>\n"],"mappings":""}
1
+ {"version":3,"file":"SchemaPropertyExamples.vue.js","names":["_sfc_main","_plugin_vue_export_helper_default","SchemaPropertyExamples_vue_vue_type_script_setup_true_lang_default","SchemaPropertyExamples_default"],"sources":["../../src/schema/SchemaPropertyExamples.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { isObject, isObjectLike } from '@scalar/helpers/object/is-object'\nimport { useClipboard } from '@scalar/use-hooks/useClipboard'\nimport { onClickOutside, onKeyStroke } from '@vueuse/core'\nimport { computed, ref, useId } from 'vue'\n\nimport { formatExample } from './helpers/format-example'\nimport LinkButton from './LinkButton.vue'\nimport { useLocalization } from './localization'\n\nconst {\n examples,\n example,\n align = 'center',\n} = defineProps<{\n /** Align the popup with its label when centering would overlap adjacent content. */\n align?: 'center' | 'start'\n examples?: unknown\n example?: unknown\n}>()\n\nconst { copyToClipboard } = useClipboard()\nconst { translate } = useLocalization()\n\n// `null` is a meaningful example value for nullable schemas, so only treat\n// `undefined` as \"not provided\".\nconst hasSingleExample = computed(() => example !== undefined)\n\nconst normalizedExamples = computed<Record<string, unknown>>(() => {\n if (isObjectLike(examples)) {\n return examples\n }\n\n return {}\n})\n\nconst hasMultipleExamples = computed(\n () => Object.keys(normalizedExamples.value).length > 0,\n)\n\nconst multipleExamplesLabel = computed(() =>\n Object.keys(normalizedExamples.value).length === 1\n ? translate('schema.example')\n : translate('schema.examples'),\n)\n\n/**\n * Unwrap an OpenAPI 3 Example Object (`{ value, externalValue, summary, description }`)\n * to the actual sample. Plain values pass through untouched.\n */\nfunction unwrapExampleObject(value: unknown): unknown {\n if (isObject(value)) {\n if ('value' in value) {\n return value.value\n }\n if ('externalValue' in value) {\n return value.externalValue\n }\n }\n return value\n}\n\n/**\n * Hover/`:focus-within` CSS alone left the popup unreachable by Enter, Escape\n * or touch, so it is pinned open on click (as in SchemaPropertyPattern.vue).\n * `example` and `examples` can both render, so each popup has its own state.\n */\nconst singleRootRef = ref<HTMLElement | null>(null)\nconst singleTriggerRef = ref<HTMLElement | { $el: HTMLElement } | null>(null)\nconst isSingleOpen = ref(false)\nconst singlePopupId = useId()\n\nconst multipleRootRef = ref<HTMLElement | null>(null)\nconst multipleTriggerRef = ref<HTMLElement | { $el: HTMLElement } | null>(null)\nconst isMultipleOpen = ref(false)\nconst multiplePopupId = useId()\n\n/**\n * Focus opens the popup through the same state as the click, not a separate\n * `:focus-within` rule; with both, a click's own `focusin` opened it first and\n * the click closed it again. This flag stops a pointer press counting as focus.\n */\nlet openedByPointer = false\n\n/** Long enough to span a touch tap's delayed compatibility mouse events. */\nconst POINTER_GUARD_MS = 500\nlet pointerGuardTimer = 0\n\n/**\n * `closeAndRestore` refocuses the trigger, and `focus()` fires `focusin`\n * synchronously, which would re-open the popup and make the first Escape inert.\n */\nlet restoringFocus = false\n\nconst onPointerDown = (): void => {\n /*\n * A touch tap's compatibility mousedown (which moves focus) lands 50-150ms\n * after touchend, past any one-frame guard, so the tap opened then closed.\n */\n openedByPointer = true\n window.clearTimeout(pointerGuardTimer)\n pointerGuardTimer = window.setTimeout(() => {\n openedByPointer = false\n }, POINTER_GUARD_MS)\n}\n\nconst leftPopup = (event: FocusEvent, root: HTMLElement | null): boolean => {\n const next = event.relatedTarget\n\n return !(next instanceof Node) || !root?.contains(next)\n}\n\nconst onSingleFocusIn = (): void => {\n if (!openedByPointer && !restoringFocus) {\n isSingleOpen.value = true\n }\n}\n\nconst onSingleFocusOut = (event: FocusEvent): void => {\n if (leftPopup(event, singleRootRef.value)) {\n isSingleOpen.value = false\n }\n}\n\nconst onMultipleFocusIn = (): void => {\n if (!openedByPointer && !restoringFocus) {\n isMultipleOpen.value = true\n }\n}\n\nconst onMultipleFocusOut = (event: FocusEvent): void => {\n if (leftPopup(event, multipleRootRef.value)) {\n isMultipleOpen.value = false\n }\n}\n\nonClickOutside(singleRootRef, () => {\n isSingleOpen.value = false\n})\n\nonClickOutside(multipleRootRef, () => {\n isMultipleOpen.value = false\n})\n\n/**\n * Closing hides the popup outright, so focus is handed back deliberately, or\n * Escape from inside it drops focus to <body>.\n */\nconst closeAndRestore = (\n open: typeof isSingleOpen,\n root: typeof singleRootRef,\n trigger: typeof singleTriggerRef,\n): void => {\n if (!open.value) {\n return\n }\n\n const wasInside = root.value?.contains(document.activeElement)\n\n open.value = false\n\n if (wasInside) {\n const element = trigger.value\n const focusable = element instanceof HTMLElement ? element : element?.$el\n\n restoringFocus = true\n focusable?.focus?.()\n restoringFocus = false\n }\n}\n\nonKeyStroke('Escape', () => {\n closeAndRestore(isSingleOpen, singleRootRef, singleTriggerRef)\n closeAndRestore(isMultipleOpen, multipleRootRef, multipleTriggerRef)\n})\n</script>\n<template>\n <!-- single example (deprecated) -->\n <template v-if=\"hasSingleExample\">\n <div\n ref=\"singleRootRef\"\n class=\"property-example\"\n :class=\"{ 'is-open': isSingleOpen }\"\n @focusin=\"onSingleFocusIn\"\n @focusout=\"onSingleFocusOut\">\n <LinkButton\n ref=\"singleTriggerRef\"\n :aria-controls=\"singlePopupId\"\n :aria-expanded=\"isSingleOpen\"\n class=\"decoration-dotted\"\n @click=\"isSingleOpen = !isSingleOpen\"\n @pointerdown=\"onPointerDown\">\n {{ translate('schema.example') }}\n </LinkButton>\n <div\n :id=\"singlePopupId\"\n class=\"property-example-value-list\"\n :class=\"{\n 'flex!': isSingleOpen,\n 'property-example-value-list-start': align === 'start',\n }\">\n <button\n :aria-label=\"`${translate('common.copyExample')}: ${formatExample(example)}`\"\n class=\"property-example-value group\"\n type=\"button\"\n @click=\"copyToClipboard(formatExample(example))\">\n <span>\n {{ formatExample(example) }}\n </span>\n <ScalarIcon\n aria-hidden=\"true\"\n class=\"group-hover:text-c-1 text-c-3 ml-auto min-h-3 min-w-3\"\n icon=\"Clipboard\"\n size=\"xs\" />\n </button>\n </div>\n </div>\n </template>\n\n <!-- multiple examples -->\n <template v-if=\"hasMultipleExamples\">\n <div\n ref=\"multipleRootRef\"\n class=\"property-example\"\n :class=\"{ 'is-open': isMultipleOpen }\"\n @focusin=\"onMultipleFocusIn\"\n @focusout=\"onMultipleFocusOut\">\n <LinkButton\n ref=\"multipleTriggerRef\"\n :aria-controls=\"multiplePopupId\"\n :aria-expanded=\"isMultipleOpen\"\n class=\"decoration-dotted\"\n @click=\"isMultipleOpen = !isMultipleOpen\"\n @pointerdown=\"onPointerDown\">\n {{ multipleExamplesLabel }}\n </LinkButton>\n <div\n :id=\"multiplePopupId\"\n class=\"property-example-value-list\"\n :class=\"{\n 'flex!': isMultipleOpen,\n 'property-example-value-list-start': align === 'start',\n }\">\n <button\n v-for=\"(ex, key) in normalizedExamples\"\n :key=\"key\"\n :aria-label=\"`${translate('common.copyExample')}: ${formatExample(unwrapExampleObject(ex))}`\"\n class=\"property-example-value group\"\n type=\"button\"\n @click=\"copyToClipboard(formatExample(unwrapExampleObject(ex)))\">\n <span>{{ formatExample(unwrapExampleObject(ex)) }} </span>\n <ScalarIcon\n aria-hidden=\"true\"\n class=\"text-c-3 group-hover:text-c-1 ml-auto min-h-3 min-w-3\"\n icon=\"Clipboard\"\n size=\"xs\" />\n </button>\n </div>\n </div>\n </template>\n</template>\n\n<style scoped>\n@reference \"../style.css\";\n\n.property-example {\n display: flex;\n flex-direction: column;\n font-size: var(--scalar-mini);\n position: relative;\n}\n.property-example:hover:before {\n pointer-events: none;\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 20px;\n border-radius: var(--scalar-radius);\n}\n.property-example-value {\n font-family: var(--scalar-font-code);\n display: flex;\n gap: 8px;\n align-items: center;\n width: 100%;\n padding: 6px;\n}\n.property-example-value span {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: pre;\n}\n.property-example-value :deep(svg) {\n color: var(--scalar-color-3);\n}\n\n.property-example-value:hover :deep(svg) {\n color: var(--scalar-color-1);\n}\n\n.property-example-value {\n background: var(--scalar-background-2);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius);\n}\n.property-example-value-list {\n position: absolute;\n top: 18px;\n left: 50%;\n transform: translate3d(-50%, 0, 0);\n overflow: auto;\n background-color: var(--scalar-background-1);\n box-shadow: var(--scalar-shadow-1);\n border-radius: var(--scalar-radius-lg);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n padding: 9px;\n min-width: 200px;\n max-width: 300px;\n flex-direction: column;\n gap: 3px;\n display: none;\n @apply z-context;\n}\n.property-example-value-list-start {\n left: 0;\n transform: none;\n}\n.property-example:hover .property-example-value-list {\n display: flex;\n}\n</style>\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_normalizeClass","_createVNode","LinkButton","_unref","_withCtx","_createTextVNode","_toDisplayString","_createElementVNode","_createCommentVNode","_renderList","LinkButton_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","POINTER_GUARD_MS","SchemaPropertyExamples_vue_vue_type_script_setup_true_lang_default","useClipboard","useLocalization","hasSingleExample","computed","__props","normalizedExamples","isObjectLike","hasMultipleExamples","multipleExamplesLabel","translate","unwrapExampleObject","isObject","value","singleRootRef","ref","singleTriggerRef","isSingleOpen","singlePopupId","useId","multipleRootRef","multipleTriggerRef","isMultipleOpen","multiplePopupId","openedByPointer","pointerGuardTimer","restoringFocus","onPointerDown","leftPopup","next","event","root","onSingleFocusIn","onSingleFocusOut","onMultipleFocusIn","onMultipleFocusOut","onClickOutside","closeAndRestore","open","wasInside","element","trigger","focusable","onKeyStroke","openBlock","createElementBlock","Fragment","normalizeClass","createVNode","unref","_cache","withCtx","createTextVNode","toDisplayString","createElementVNode","formatExample","copyToClipboard","ScalarIcon","createCommentVNode","renderList","ex"],"sources":["../../src/schema/SchemaPropertyExamples.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { isObject, isObjectLike } from '@scalar/helpers/object/is-object'\nimport { useClipboard } from '@scalar/use-hooks/useClipboard'\nimport { onClickOutside, onKeyStroke } from '@vueuse/core'\nimport { computed, ref, useId } from 'vue'\n\nimport { formatExample } from './helpers/format-example'\nimport LinkButton from './LinkButton.vue'\nimport { useLocalization } from './localization'\n\nconst {\n examples,\n example,\n align = 'center',\n} = defineProps<{\n /** Align the popup with its label when centering would overlap adjacent content. */\n align?: 'center' | 'start'\n examples?: unknown\n example?: unknown\n}>()\n\nconst { copyToClipboard } = useClipboard()\nconst { translate } = useLocalization()\n\n// `null` is a meaningful example value for nullable schemas, so only treat\n// `undefined` as \"not provided\".\nconst hasSingleExample = computed(() => example !== undefined)\n\nconst normalizedExamples = computed<Record<string, unknown>>(() => {\n if (isObjectLike(examples)) {\n return examples\n }\n\n return {}\n})\n\nconst hasMultipleExamples = computed(\n () => Object.keys(normalizedExamples.value).length > 0,\n)\n\nconst multipleExamplesLabel = computed(() =>\n Object.keys(normalizedExamples.value).length === 1\n ? translate('schema.example')\n : translate('schema.examples'),\n)\n\n/**\n * Unwrap an OpenAPI 3 Example Object (`{ value, externalValue, summary, description }`)\n * to the actual sample. Plain values pass through untouched.\n */\nfunction unwrapExampleObject(value: unknown): unknown {\n if (isObject(value)) {\n if ('value' in value) {\n return value.value\n }\n if ('externalValue' in value) {\n return value.externalValue\n }\n }\n return value\n}\n\n/**\n * Hover/`:focus-within` CSS alone left the popup unreachable by Enter, Escape\n * or touch, so it is pinned open on click (as in SchemaPropertyPattern.vue).\n * `example` and `examples` can both render, so each popup has its own state.\n */\nconst singleRootRef = ref<HTMLElement | null>(null)\nconst singleTriggerRef = ref<HTMLElement | { $el: HTMLElement } | null>(null)\nconst isSingleOpen = ref(false)\nconst singlePopupId = useId()\n\nconst multipleRootRef = ref<HTMLElement | null>(null)\nconst multipleTriggerRef = ref<HTMLElement | { $el: HTMLElement } | null>(null)\nconst isMultipleOpen = ref(false)\nconst multiplePopupId = useId()\n\n/**\n * Focus opens the popup through the same state as the click, not a separate\n * `:focus-within` rule; with both, a click's own `focusin` opened it first and\n * the click closed it again. This flag stops a pointer press counting as focus.\n */\nlet openedByPointer = false\n\n/** Long enough to span a touch tap's delayed compatibility mouse events. */\nconst POINTER_GUARD_MS = 500\nlet pointerGuardTimer = 0\n\n/**\n * `closeAndRestore` refocuses the trigger, and `focus()` fires `focusin`\n * synchronously, which would re-open the popup and make the first Escape inert.\n */\nlet restoringFocus = false\n\nconst onPointerDown = (): void => {\n /*\n * A touch tap's compatibility mousedown (which moves focus) lands 50-150ms\n * after touchend, past any one-frame guard, so the tap opened then closed.\n */\n openedByPointer = true\n window.clearTimeout(pointerGuardTimer)\n pointerGuardTimer = window.setTimeout(() => {\n openedByPointer = false\n }, POINTER_GUARD_MS)\n}\n\nconst leftPopup = (event: FocusEvent, root: HTMLElement | null): boolean => {\n const next = event.relatedTarget\n\n return !(next instanceof Node) || !root?.contains(next)\n}\n\nconst onSingleFocusIn = (): void => {\n if (!openedByPointer && !restoringFocus) {\n isSingleOpen.value = true\n }\n}\n\nconst onSingleFocusOut = (event: FocusEvent): void => {\n if (leftPopup(event, singleRootRef.value)) {\n isSingleOpen.value = false\n }\n}\n\nconst onMultipleFocusIn = (): void => {\n if (!openedByPointer && !restoringFocus) {\n isMultipleOpen.value = true\n }\n}\n\nconst onMultipleFocusOut = (event: FocusEvent): void => {\n if (leftPopup(event, multipleRootRef.value)) {\n isMultipleOpen.value = false\n }\n}\n\nonClickOutside(singleRootRef, () => {\n isSingleOpen.value = false\n})\n\nonClickOutside(multipleRootRef, () => {\n isMultipleOpen.value = false\n})\n\n/**\n * Closing hides the popup outright, so focus is handed back deliberately, or\n * Escape from inside it drops focus to <body>.\n */\nconst closeAndRestore = (\n open: typeof isSingleOpen,\n root: typeof singleRootRef,\n trigger: typeof singleTriggerRef,\n): void => {\n if (!open.value) {\n return\n }\n\n const wasInside = root.value?.contains(document.activeElement)\n\n open.value = false\n\n if (wasInside) {\n const element = trigger.value\n const focusable = element instanceof HTMLElement ? element : element?.$el\n\n restoringFocus = true\n focusable?.focus?.()\n restoringFocus = false\n }\n}\n\nonKeyStroke('Escape', () => {\n closeAndRestore(isSingleOpen, singleRootRef, singleTriggerRef)\n closeAndRestore(isMultipleOpen, multipleRootRef, multipleTriggerRef)\n})\n</script>\n<template>\n <!-- single example (deprecated) -->\n <template v-if=\"hasSingleExample\">\n <div\n ref=\"singleRootRef\"\n class=\"property-example\"\n :class=\"{ 'is-open': isSingleOpen }\"\n @focusin=\"onSingleFocusIn\"\n @focusout=\"onSingleFocusOut\">\n <LinkButton\n ref=\"singleTriggerRef\"\n :aria-controls=\"singlePopupId\"\n :aria-expanded=\"isSingleOpen\"\n class=\"decoration-dotted\"\n @click=\"isSingleOpen = !isSingleOpen\"\n @pointerdown=\"onPointerDown\">\n {{ translate('schema.example') }}\n </LinkButton>\n <div\n :id=\"singlePopupId\"\n class=\"property-example-value-list\"\n :class=\"{\n 'flex!': isSingleOpen,\n 'property-example-value-list-start': align === 'start',\n }\">\n <button\n :aria-label=\"`${translate('common.copyExample')}: ${formatExample(example)}`\"\n class=\"property-example-value group\"\n type=\"button\"\n @click=\"copyToClipboard(formatExample(example))\">\n <span>\n {{ formatExample(example) }}\n </span>\n <ScalarIcon\n aria-hidden=\"true\"\n class=\"group-hover:text-c-1 text-c-3 ml-auto min-h-3 min-w-3\"\n icon=\"Clipboard\"\n size=\"xs\" />\n </button>\n </div>\n </div>\n </template>\n\n <!-- multiple examples -->\n <template v-if=\"hasMultipleExamples\">\n <div\n ref=\"multipleRootRef\"\n class=\"property-example\"\n :class=\"{ 'is-open': isMultipleOpen }\"\n @focusin=\"onMultipleFocusIn\"\n @focusout=\"onMultipleFocusOut\">\n <LinkButton\n ref=\"multipleTriggerRef\"\n :aria-controls=\"multiplePopupId\"\n :aria-expanded=\"isMultipleOpen\"\n class=\"decoration-dotted\"\n @click=\"isMultipleOpen = !isMultipleOpen\"\n @pointerdown=\"onPointerDown\">\n {{ multipleExamplesLabel }}\n </LinkButton>\n <div\n :id=\"multiplePopupId\"\n class=\"property-example-value-list\"\n :class=\"{\n 'flex!': isMultipleOpen,\n 'property-example-value-list-start': align === 'start',\n }\">\n <button\n v-for=\"(ex, key) in normalizedExamples\"\n :key=\"key\"\n :aria-label=\"`${translate('common.copyExample')}: ${formatExample(unwrapExampleObject(ex))}`\"\n class=\"property-example-value group\"\n type=\"button\"\n @click=\"copyToClipboard(formatExample(unwrapExampleObject(ex)))\">\n <span>{{ formatExample(unwrapExampleObject(ex)) }} </span>\n <ScalarIcon\n aria-hidden=\"true\"\n class=\"text-c-3 group-hover:text-c-1 ml-auto min-h-3 min-w-3\"\n icon=\"Clipboard\"\n size=\"xs\" />\n </button>\n </div>\n </div>\n </template>\n</template>\n\n<style scoped>\n@reference \"../style.css\";\n\n.property-example {\n display: flex;\n flex-direction: column;\n font-size: var(--scalar-mini);\n position: relative;\n}\n.property-example:hover:before {\n pointer-events: none;\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 20px;\n border-radius: var(--scalar-radius);\n}\n.property-example-value {\n font-family: var(--scalar-font-code);\n display: flex;\n gap: 8px;\n align-items: center;\n width: 100%;\n padding: 6px;\n}\n.property-example-value span {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.property-example-value :deep(svg) {\n color: var(--scalar-color-3);\n}\n\n.property-example-value:hover :deep(svg) {\n color: var(--scalar-color-1);\n}\n\n.property-example-value {\n background: var(--scalar-background-2);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius);\n}\n.property-example-value-list {\n position: absolute;\n top: 18px;\n left: 50%;\n transform: translate3d(-50%, 0, 0);\n overflow: auto;\n background-color: var(--scalar-background-1);\n box-shadow: var(--scalar-shadow-1);\n border-radius: var(--scalar-radius-lg);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n padding: 9px;\n min-width: 200px;\n max-width: 300px;\n flex-direction: column;\n gap: 3px;\n display: none;\n @apply z-context;\n}\n.property-example-value-list-start {\n left: 0;\n transform: none;\n}\n.property-example:hover .property-example-value-list {\n display: flex;\n}\n</style>\n"],"mappings":";;;;;;;;;A,+EAsFMkB,IAAmB,K;;;;;;;;EAhEzB,IAAM,EAAE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BvB,EAAAoE,CAAA,CAAa,CAAC5C,EAAoBiD,CAAE,CAAA;GACxF,OAAM;GACN,MAAK;GACJ,UAAK,MAAEzE,EAAAqE,CAAA,CAAe,CAACrE,EAAAoE,CAAA,CAAa,CAAC5C,EAAoBiD,CAAE,CAAA,CAAA;E,IAC5DrE,EAA0D,QAAA,MAAAD,EAAjDH,EAAAoE,CAAA,CAAa,CAAC5C,EAAoBiD,CAAE,CAAA,CAAA,GAAA,CAAA,GAC7C3E,EAIcE,EAAAsE,CAAA,GAAA;GAHZ,eAAY;GACZ,OAAM;GACN,MAAK;GACL,MAAK"}
1
+ {"version":3,"file":"SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_normalizeClass","_createVNode","LinkButton","_unref","_withCtx","_createTextVNode","_toDisplayString","_createElementVNode","_createCommentVNode","_renderList","LinkButton_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","POINTER_GUARD_MS","SchemaPropertyExamples_vue_vue_type_script_setup_true_lang_default","useClipboard","useLocalization","hasSingleExample","computed","__props","normalizedExamples","isObjectLike","hasMultipleExamples","multipleExamplesLabel","translate","unwrapExampleObject","isObject","value","singleRootRef","ref","singleTriggerRef","isSingleOpen","singlePopupId","useId","multipleRootRef","multipleTriggerRef","isMultipleOpen","multiplePopupId","openedByPointer","pointerGuardTimer","restoringFocus","onPointerDown","leftPopup","next","event","root","onSingleFocusIn","onSingleFocusOut","onMultipleFocusIn","onMultipleFocusOut","onClickOutside","closeAndRestore","open","wasInside","element","trigger","focusable","onKeyStroke","openBlock","createElementBlock","Fragment","normalizeClass","createVNode","unref","_cache","withCtx","createTextVNode","toDisplayString","createElementVNode","formatExample","copyToClipboard","ScalarIcon","createCommentVNode","renderList","ex"],"sources":["../../src/schema/SchemaPropertyExamples.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { isObject, isObjectLike } from '@scalar/helpers/object/is-object'\nimport { useClipboard } from '@scalar/use-hooks/useClipboard'\nimport { onClickOutside, onKeyStroke } from '@vueuse/core'\nimport { computed, ref, useId } from 'vue'\n\nimport { formatExample } from './helpers/format-example'\nimport LinkButton from './LinkButton.vue'\nimport { useLocalization } from './localization'\n\nconst {\n examples,\n example,\n align = 'center',\n} = defineProps<{\n /** Align the popup with its label when centering would overlap adjacent content. */\n align?: 'center' | 'start'\n examples?: unknown\n example?: unknown\n}>()\n\nconst { copyToClipboard } = useClipboard()\nconst { translate } = useLocalization()\n\n// `null` is a meaningful example value for nullable schemas, so only treat\n// `undefined` as \"not provided\".\nconst hasSingleExample = computed(() => example !== undefined)\n\nconst normalizedExamples = computed<Record<string, unknown>>(() => {\n if (isObjectLike(examples)) {\n return examples\n }\n\n return {}\n})\n\nconst hasMultipleExamples = computed(\n () => Object.keys(normalizedExamples.value).length > 0,\n)\n\nconst multipleExamplesLabel = computed(() =>\n Object.keys(normalizedExamples.value).length === 1\n ? translate('schema.example')\n : translate('schema.examples'),\n)\n\n/**\n * Unwrap an OpenAPI 3 Example Object (`{ value, externalValue, summary, description }`)\n * to the actual sample. Plain values pass through untouched.\n */\nfunction unwrapExampleObject(value: unknown): unknown {\n if (isObject(value)) {\n if ('value' in value) {\n return value.value\n }\n if ('externalValue' in value) {\n return value.externalValue\n }\n }\n return value\n}\n\n/**\n * Hover/`:focus-within` CSS alone left the popup unreachable by Enter, Escape\n * or touch, so it is pinned open on click (as in SchemaPropertyPattern.vue).\n * `example` and `examples` can both render, so each popup has its own state.\n */\nconst singleRootRef = ref<HTMLElement | null>(null)\nconst singleTriggerRef = ref<HTMLElement | { $el: HTMLElement } | null>(null)\nconst isSingleOpen = ref(false)\nconst singlePopupId = useId()\n\nconst multipleRootRef = ref<HTMLElement | null>(null)\nconst multipleTriggerRef = ref<HTMLElement | { $el: HTMLElement } | null>(null)\nconst isMultipleOpen = ref(false)\nconst multiplePopupId = useId()\n\n/**\n * Focus opens the popup through the same state as the click, not a separate\n * `:focus-within` rule; with both, a click's own `focusin` opened it first and\n * the click closed it again. This flag stops a pointer press counting as focus.\n */\nlet openedByPointer = false\n\n/** Long enough to span a touch tap's delayed compatibility mouse events. */\nconst POINTER_GUARD_MS = 500\nlet pointerGuardTimer = 0\n\n/**\n * `closeAndRestore` refocuses the trigger, and `focus()` fires `focusin`\n * synchronously, which would re-open the popup and make the first Escape inert.\n */\nlet restoringFocus = false\n\nconst onPointerDown = (): void => {\n /*\n * A touch tap's compatibility mousedown (which moves focus) lands 50-150ms\n * after touchend, past any one-frame guard, so the tap opened then closed.\n */\n openedByPointer = true\n window.clearTimeout(pointerGuardTimer)\n pointerGuardTimer = window.setTimeout(() => {\n openedByPointer = false\n }, POINTER_GUARD_MS)\n}\n\nconst leftPopup = (event: FocusEvent, root: HTMLElement | null): boolean => {\n const next = event.relatedTarget\n\n return !(next instanceof Node) || !root?.contains(next)\n}\n\nconst onSingleFocusIn = (): void => {\n if (!openedByPointer && !restoringFocus) {\n isSingleOpen.value = true\n }\n}\n\nconst onSingleFocusOut = (event: FocusEvent): void => {\n if (leftPopup(event, singleRootRef.value)) {\n isSingleOpen.value = false\n }\n}\n\nconst onMultipleFocusIn = (): void => {\n if (!openedByPointer && !restoringFocus) {\n isMultipleOpen.value = true\n }\n}\n\nconst onMultipleFocusOut = (event: FocusEvent): void => {\n if (leftPopup(event, multipleRootRef.value)) {\n isMultipleOpen.value = false\n }\n}\n\nonClickOutside(singleRootRef, () => {\n isSingleOpen.value = false\n})\n\nonClickOutside(multipleRootRef, () => {\n isMultipleOpen.value = false\n})\n\n/**\n * Closing hides the popup outright, so focus is handed back deliberately, or\n * Escape from inside it drops focus to <body>.\n */\nconst closeAndRestore = (\n open: typeof isSingleOpen,\n root: typeof singleRootRef,\n trigger: typeof singleTriggerRef,\n): void => {\n if (!open.value) {\n return\n }\n\n const wasInside = root.value?.contains(document.activeElement)\n\n open.value = false\n\n if (wasInside) {\n const element = trigger.value\n const focusable = element instanceof HTMLElement ? element : element?.$el\n\n restoringFocus = true\n focusable?.focus?.()\n restoringFocus = false\n }\n}\n\nonKeyStroke('Escape', () => {\n closeAndRestore(isSingleOpen, singleRootRef, singleTriggerRef)\n closeAndRestore(isMultipleOpen, multipleRootRef, multipleTriggerRef)\n})\n</script>\n<template>\n <!-- single example (deprecated) -->\n <template v-if=\"hasSingleExample\">\n <div\n ref=\"singleRootRef\"\n class=\"property-example\"\n :class=\"{ 'is-open': isSingleOpen }\"\n @focusin=\"onSingleFocusIn\"\n @focusout=\"onSingleFocusOut\">\n <LinkButton\n ref=\"singleTriggerRef\"\n :aria-controls=\"singlePopupId\"\n :aria-expanded=\"isSingleOpen\"\n class=\"decoration-dotted\"\n @click=\"isSingleOpen = !isSingleOpen\"\n @pointerdown=\"onPointerDown\">\n {{ translate('schema.example') }}\n </LinkButton>\n <div\n :id=\"singlePopupId\"\n class=\"property-example-value-list\"\n :class=\"{\n 'flex!': isSingleOpen,\n 'property-example-value-list-start': align === 'start',\n }\">\n <button\n :aria-label=\"`${translate('common.copyExample')}: ${formatExample(example)}`\"\n class=\"property-example-value group\"\n type=\"button\"\n @click=\"copyToClipboard(formatExample(example))\">\n <span>\n {{ formatExample(example) }}\n </span>\n <ScalarIcon\n aria-hidden=\"true\"\n class=\"group-hover:text-c-1 text-c-3 ml-auto min-h-3 min-w-3\"\n icon=\"Clipboard\"\n size=\"xs\" />\n </button>\n </div>\n </div>\n </template>\n\n <!-- multiple examples -->\n <template v-if=\"hasMultipleExamples\">\n <div\n ref=\"multipleRootRef\"\n class=\"property-example\"\n :class=\"{ 'is-open': isMultipleOpen }\"\n @focusin=\"onMultipleFocusIn\"\n @focusout=\"onMultipleFocusOut\">\n <LinkButton\n ref=\"multipleTriggerRef\"\n :aria-controls=\"multiplePopupId\"\n :aria-expanded=\"isMultipleOpen\"\n class=\"decoration-dotted\"\n @click=\"isMultipleOpen = !isMultipleOpen\"\n @pointerdown=\"onPointerDown\">\n {{ multipleExamplesLabel }}\n </LinkButton>\n <div\n :id=\"multiplePopupId\"\n class=\"property-example-value-list\"\n :class=\"{\n 'flex!': isMultipleOpen,\n 'property-example-value-list-start': align === 'start',\n }\">\n <button\n v-for=\"(ex, key) in normalizedExamples\"\n :key=\"key\"\n :aria-label=\"`${translate('common.copyExample')}: ${formatExample(unwrapExampleObject(ex))}`\"\n class=\"property-example-value group\"\n type=\"button\"\n @click=\"copyToClipboard(formatExample(unwrapExampleObject(ex)))\">\n <span>{{ formatExample(unwrapExampleObject(ex)) }} </span>\n <ScalarIcon\n aria-hidden=\"true\"\n class=\"text-c-3 group-hover:text-c-1 ml-auto min-h-3 min-w-3\"\n icon=\"Clipboard\"\n size=\"xs\" />\n </button>\n </div>\n </div>\n </template>\n</template>\n\n<style scoped>\n@reference \"../style.css\";\n\n.property-example {\n display: flex;\n flex-direction: column;\n font-size: var(--scalar-mini);\n position: relative;\n}\n.property-example:hover:before {\n pointer-events: none;\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 20px;\n border-radius: var(--scalar-radius);\n}\n.property-example-value {\n font-family: var(--scalar-font-code);\n display: flex;\n gap: 8px;\n align-items: center;\n width: 100%;\n padding: 6px;\n}\n.property-example-value span {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: pre;\n}\n.property-example-value :deep(svg) {\n color: var(--scalar-color-3);\n}\n\n.property-example-value:hover :deep(svg) {\n color: var(--scalar-color-1);\n}\n\n.property-example-value {\n background: var(--scalar-background-2);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius);\n}\n.property-example-value-list {\n position: absolute;\n top: 18px;\n left: 50%;\n transform: translate3d(-50%, 0, 0);\n overflow: auto;\n background-color: var(--scalar-background-1);\n box-shadow: var(--scalar-shadow-1);\n border-radius: var(--scalar-radius-lg);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n padding: 9px;\n min-width: 200px;\n max-width: 300px;\n flex-direction: column;\n gap: 3px;\n display: none;\n @apply z-context;\n}\n.property-example-value-list-start {\n left: 0;\n transform: none;\n}\n.property-example:hover .property-example-value-list {\n display: flex;\n}\n</style>\n"],"mappings":";;;;;;;;;A,+EAsFMkB,IAAmB,K;;;;;;;;EAhEzB,IAAM,EAAE,uBAAoBE,EAAa,GACnC,EAAE,iBAAcC,EAAgB,GAIhCC,IAAmBC,QAAeC,EAAA,YAAY,KAAA,CAAS,GAEvDC,IAAqBF,QACrBG,EAAaF,EAAA,QAAQ,IAChBA,EAAA,WAGF,CAAC,CACT,GAEKG,IAAsBJ,QACpB,OAAO,KAAKE,EAAmB,KAAK,CAAC,CAAC,SAAS,CACvD,GAEMG,IAAwBL,QAC5B,OAAO,KAAKE,EAAmB,KAAK,CAAC,CAAC,WAAW,IAC7CI,EAAU,gBAAgB,IAC1BA,EAAU,iBAAiB,CACjC;EAMA,SAASC,EAAoB,GAAyB;GACpD,IAAIC,EAASC,CAAK,GAAG;IACnB,IAAI,WAAWA,GACb,OAAOA,EAAM;IAEf,IAAI,mBAAmBA,GACrB,OAAOA,EAAM;GAEjB;GACA,OAAOA;EACT;EAOA,IAAMC,IAAgBC,EAAwB,IAAI,GAC5CC,IAAmBD,EAA+C,IAAI,GACtEE,IAAeF,EAAI,EAAK,GACxBG,IAAgBC,EAAM,GAEtBC,IAAkBL,EAAwB,IAAI,GAC9CM,IAAqBN,EAA+C,IAAI,GACxEO,IAAiBP,EAAI,EAAK,GAC1BQ,IAAkBJ,EAAM,GAO1BK,IAAkB,IAIlBC,IAAoB,GAMpBC,IAAiB,IAEfC,UAA4B;GAOhC,AAFA,IAAkB,IAClB,OAAO,aAAaF,CAAiB,GACrC,IAAoB,OAAO,iBAAiB;IAC1C,IAAkB;GACpB,GAAG1B,CAAgB;EACrB,GAEM6B,KAAa,GAAmB,MAAsC;GAC1E,IAAMC,IAAOC,EAAM;GAEnB,OAAO,EAAED,aAAgB,SAAS,CAACE,GAAM,SAASF,CAAI;EACxD,GAEMG,UAA8B;GAClC,AAAI,CAACR,KAAmB,CAACE,MACvB,EA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MAAAU,EAZaa,EAAA,QAAZ,GAAI,OADdzB,EAAA,GAAAC,EAaS,UAAA;GAXD;GACL,cAAU,GAAKK,EAAAuB,CAAA,CAAS,CAAA,oBAAA,EAAA,IAA2BvB,EAAAoE,CAAA,CAAa,CAAC5C,EAAoBiD,CAAE,CAAA;GACxF,OAAM;GACN,MAAK;GACJ,UAAK,MAAEzE,EAAAqE,CAAA,CAAe,CAACrE,EAAAoE,CAAA,CAAa,CAAC5C,EAAoBiD,CAAE,CAAA,CAAA;E,IAC5DrE,EAA0D,QAAA,MAAAD,EAAjDH,EAAAoE,CAAA,CAAa,CAAC5C,EAAoBiD,CAAE,CAAA,CAAA,GAAA,CAAA,GAC7C3E,EAIcE,EAAAsE,CAAA,GAAA;GAHZ,eAAY;GACZ,OAAM;GACN,MAAK;GACL,MAAK"}
@@ -35,13 +35,13 @@ type __VLS_Props = {
35
35
  */
36
36
  recursiveTo?: string;
37
37
  };
38
- declare var __VLS_1: {}, __VLS_85: {}, __VLS_87: {};
38
+ declare var __VLS_1: {}, __VLS_97: {}, __VLS_99: {};
39
39
  type __VLS_Slots = {} & {
40
40
  name?: (props: typeof __VLS_1) => any;
41
41
  } & {
42
- preview?: (props: typeof __VLS_85) => any;
42
+ preview?: (props: typeof __VLS_97) => any;
43
43
  } & {
44
- trailing?: (props: typeof __VLS_87) => any;
44
+ trailing?: (props: typeof __VLS_99) => any;
45
45
  };
46
46
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
47
47
  required: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaPropertyHeading.vue.d.ts","sourceRoot":"","sources":["../../src/schema/SchemaPropertyHeading.vue"],"names":[],"mappings":"AAorBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,KAAK,EAAE,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ACrB,CAAC;AA61BJ,QAAA,IAAI,OAAO,IAAU,EAAE,QAAQ,IAAW,EAAE,QAAQ,IAAY,CAAE;AAClE,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GACzC;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,GAC7C;IAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAKjD,QAAA,MAAM,UAAU;cAj4BD,OAAO;cAaP,iBAAiB,GAAG,IAAI;oBAVlB,OAAO;qBANN,OAAO;kBAKV,OAAO;6EAk4BxB,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,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 "./SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js";
3
3
  /* empty css */
4
4
  //#region src/schema/SchemaPropertyHeading.vue
5
- var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-d9e2f10e"]]);
5
+ var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-09888606"]]);
6
6
  //#endregion
7
7
  export { n as default };
8
8