@scalar/api-client 3.28.1 → 3.29.1

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 (48) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/style.css +117 -95
  3. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
  4. package/dist/v2/blocks/operation-block/OperationBlock.vue_vue_type_script_setup_true_lang.js +5 -1
  5. package/dist/v2/blocks/operation-block/OperationBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
  6. package/dist/v2/blocks/operation-block/helpers/send-request.js +1 -4
  7. package/dist/v2/blocks/operation-block/helpers/send-request.js.map +1 -1
  8. package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts +2 -0
  9. package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
  10. package/dist/v2/blocks/request-block/RequestBlock.vue.js +1 -1
  11. package/dist/v2/blocks/request-block/RequestBlock.vue_vue_type_script_setup_true_lang.js +5 -0
  12. package/dist/v2/blocks/request-block/RequestBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
  13. package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts +2 -0
  14. package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts.map +1 -1
  15. package/dist/v2/blocks/request-block/components/RequestBody.vue.js +1 -1
  16. package/dist/v2/blocks/request-block/components/RequestBody.vue_vue_type_script_setup_true_lang.js +6 -2
  17. package/dist/v2/blocks/request-block/components/RequestBody.vue_vue_type_script_setup_true_lang.js.map +1 -1
  18. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.d.ts +1 -0
  19. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.d.ts.map +1 -1
  20. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue_vue_type_script_setup_true_lang.js +7 -5
  21. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue_vue_type_script_setup_true_lang.js.map +1 -1
  22. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
  23. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue_vue_type_script_setup_true_lang.js +2 -0
  24. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue_vue_type_script_setup_true_lang.js.map +1 -1
  25. package/dist/v2/blocks/request-block/helpers/get-form-body-rows.d.ts +1 -1
  26. package/dist/v2/blocks/request-block/helpers/get-form-body-rows.d.ts.map +1 -1
  27. package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js +10 -3
  28. package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js.map +1 -1
  29. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
  30. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +1 -1
  31. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue_vue_type_script_setup_true_lang.js +5 -2
  32. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue_vue_type_script_setup_true_lang.js.map +1 -1
  33. package/dist/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.d.ts +3 -1
  34. package/dist/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.d.ts.map +1 -1
  35. package/dist/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.js +4 -2
  36. package/dist/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.js.map +1 -1
  37. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue_vue_type_script_setup_true_lang.js +1 -1
  38. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -1
  39. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +3 -3
  40. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js.map +1 -1
  41. package/dist/v2/components/data-table/DataTableCell.vue_vue_type_script_setup_true_lang.js +8 -1
  42. package/dist/v2/components/data-table/DataTableCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
  43. package/dist/v2/constants.js +1 -1
  44. package/dist/v2/features/operation/Operation.vue_vue_type_script_setup_true_lang.js +1 -1
  45. package/dist/v2/types/options.d.ts +1 -1
  46. package/dist/v2/types/options.d.ts.map +1 -1
  47. package/dist/vue-styles.css +21 -21
  48. package/package.json +24 -24
@@ -1 +1 @@
1
- {"version":3,"file":"RequestBodyForm.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","RequestTable"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestBodyForm.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport { isFileSchema } from '@scalar/workspace-store/helpers/is-file-schema'\nimport { resolveFormSchema } from '@scalar/workspace-store/helpers/resolve-form-schema'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type {\n ExampleObject,\n MediaTypeObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\nimport { computed, ref, watch } from 'vue'\n\nimport { useFileDialog } from '@/hooks/use-file-dialog'\nimport RequestTable from '@/v2/blocks/request-block/components/RequestTable.vue'\nimport type { TableRow } from '@/v2/blocks/request-block/components/RequestTableRow.vue'\nimport {\n getFormBodyRows,\n getFormBodyValue,\n} from '@/v2/blocks/request-block/helpers/get-form-body-rows'\nimport { groupFormBodyFiles } from '@/v2/blocks/request-block/helpers/group-form-body-files'\n\nconst {\n example,\n bodySchema,\n encoding,\n selectedContentType,\n environment,\n compositionSelection,\n} = defineProps<{\n example: ExampleObject | undefined | null\n /** Resolved schema for the form body so the table can show enums and validation per field */\n bodySchema?: SchemaObject\n /** Encoding overrides for individual multipart fields. */\n encoding?: MediaTypeObject['encoding']\n /** Selected request-body variants, shared with example generation and serialization. */\n compositionSelection?: Record<string, number>\n selectedContentType: string\n environment: XScalarEnvironment\n}>()\n\nconst emit = defineEmits<{\n (\n e: 'update:formValue',\n payload: ApiReferenceEvents['operation:update:requestBody:formValue']['payload'],\n ): void\n}>()\n\n/** Local state for form body rows */\nconst localFormBodyRows = ref<TableRow[]>([])\n\nconst formFields = computed(() =>\n selectedContentType === 'multipart/form-data'\n ? groupFormBodyFiles(localFormBodyRows.value)\n : localFormBodyRows.value.map((data, index) => ({\n data,\n sourceIndices: [index],\n })),\n)\nconst displayedRows = computed<TableRow[]>(() =>\n formFields.value.map((field) => field.data),\n)\n\n/** Sync the local form body rows with the example and schema */\nwatch(\n () =>\n [\n example,\n bodySchema,\n selectedContentType,\n compositionSelection,\n encoding,\n ] as const,\n ([newExample, schema, contentType, selection, fieldEncoding]) => {\n localFormBodyRows.value = getFormBodyRows(\n newExample,\n contentType,\n schema,\n selection,\n fieldEncoding,\n )\n },\n { immediate: true },\n)\n\n/** Undeclared fields follow additionalProperties instead of losing uploads whenever a schema exists. */\nconst allowUnknownFileUploads = computed<boolean>(() => {\n const schema = resolveFormSchema(bodySchema, compositionSelection)\n const additional =\n schema && 'additionalProperties' in schema\n ? schema.additionalProperties\n : undefined\n return typeof additional === 'object'\n ? isFileSchema(resolveFormSchema(additional) ?? { __scalar_: '' })\n : additional !== false\n})\n\nconst handleUpdateFormValue = (rows: TableRow[]): void => {\n emit(\n 'update:formValue',\n rows.map((row) => ({\n name: row.name,\n value:\n selectedContentType === 'multipart/form-data'\n ? getFormBodyValue(row)\n : (row.value as string | File),\n isDisabled: row.isDisabled ?? false,\n ...(row.isDisabledByDefault ? { isDisabledByDefault: true } : {}),\n ...(selectedContentType === 'multipart/form-data' && row.isArray\n ? { isArray: true }\n : {}),\n })),\n )\n}\n\n/** Update a row in the table, combines with the previous data so we emit a whole row */\nconst handleUpsertRow = (\n index: number | number[],\n payload: Partial<{\n name: string\n value: string | File | undefined\n isDisabled: boolean\n }>,\n): void => {\n const indices = Array.isArray(index) ? index : [index]\n // Add new row\n if (\n indices[0] !== undefined &&\n indices[0] >= localFormBodyRows.value.length\n ) {\n localFormBodyRows.value = [\n ...localFormBodyRows.value,\n { name: '', value: '', ...payload, isDisabled: false },\n ]\n handleUpdateFormValue(localFormBodyRows.value)\n return\n }\n\n localFormBodyRows.value = localFormBodyRows.value.map((row, i) => {\n if (!indices.includes(i)) {\n return row\n }\n\n const valueChanged = 'value' in payload && payload.value !== row.value\n const disabledChanged =\n payload.isDisabled !== undefined && payload.isDisabled !== row.isDisabled\n\n return {\n ...row,\n ...payload,\n // File selection bypasses the text input, but also expresses intent to send a value.\n ...(valueChanged && payload.value !== undefined && row.isDisabledByDefault\n ? { isDisabled: false }\n : {}),\n // Preserve untouched defaults while keeping deliberate checkbox choices explicit.\n isDisabledByDefault:\n row.isDisabledByDefault && !valueChanged && !disabledChanged,\n }\n })\n handleUpdateFormValue(localFormBodyRows.value)\n}\n\n/** Remember individual choices while the whole file field is temporarily disabled. */\nconst disabledFileChoices = new WeakMap<File, boolean>()\n\n/** Apply field edits to all its parts without replacing sibling files with the first file. */\nconst handleFieldUpsert = (\n index: number,\n payload: Parameters<typeof handleUpsertRow>[1],\n): void => {\n const field = formFields.value[index]\n if (\n field?.data.files?.length &&\n payload.isDisabled !== undefined &&\n payload.isDisabled !== field.data.isDisabled\n ) {\n localFormBodyRows.value = localFormBodyRows.value.map((row, i) => {\n if (!field.sourceIndices.includes(i) || !(row.value instanceof File)) {\n return row\n }\n if (payload.isDisabled) {\n disabledFileChoices.set(row.value, row.isDisabled ?? false)\n }\n const isDisabled =\n payload.isDisabled || (disabledFileChoices.get(row.value) ?? false)\n if (!payload.isDisabled) {\n disabledFileChoices.delete(row.value)\n }\n return { ...row, isDisabled, isDisabledByDefault: false }\n })\n handleUpdateFormValue(localFormBodyRows.value)\n return\n }\n handleUpsertRow(\n field?.sourceIndices ?? localFormBodyRows.value.length,\n field?.data.files\n ? {\n ...(payload.name !== undefined ? { name: payload.name } : {}),\n ...(payload.isDisabled !== undefined &&\n payload.isDisabled !== field.data.isDisabled\n ? { isDisabled: payload.isDisabled }\n : {}),\n }\n : payload,\n )\n}\n\n/** Delete a row from the table */\nconst handleDeleteRow = (index: number): void => {\n const indices = formFields.value[index]?.sourceIndices ?? [index]\n localFormBodyRows.value = localFormBodyRows.value.filter(\n (_, i) => !indices.includes(i),\n )\n handleUpdateFormValue(localFormBodyRows.value)\n}\n\n/** Remove a selected file, retaining one empty field after the last file is removed. */\nconst handleRemoveFile = (index: number, fileIndex?: number): void => {\n const field = formFields.value[index]\n const sourceIndex = fileIndex ?? field?.sourceIndices[0] ?? index\n if (field?.data.files) {\n const remaining = localFormBodyRows.value.filter(\n (row, i) =>\n field.sourceIndices.includes(i) &&\n i !== sourceIndex &&\n row.value instanceof File,\n )\n const original = localFormBodyRows.value[sourceIndex]\n if (!original) {\n return\n }\n const replacement = remaining.length\n ? remaining\n : [{ ...original, value: '[]', isArray: true }]\n localFormBodyRows.value = localFormBodyRows.value.flatMap((row, i) => {\n if (i === field.sourceIndices[0]) {\n return replacement\n }\n return field.sourceIndices.includes(i) ? [] : [row]\n })\n handleUpdateFormValue(localFormBodyRows.value)\n return\n }\n handleUpsertRow(sourceIndex, { value: undefined })\n}\n\n/** Handle file upload for a specific row index */\nconst handleFileUpload = (index: number): void => {\n const field = formFields.value[index]\n const sourceIndices = field?.sourceIndices ?? [localFormBodyRows.value.length]\n const sourceIndex = sourceIndices[0] ?? localFormBodyRows.value.length\n const currentRow = localFormBodyRows.value[sourceIndex]\n // Array fields accept multiple files, serialized as separate multipart parts under the same name.\n const allowMultiple = Boolean(\n currentRow?.schema && isArraySchema(currentRow.schema),\n )\n\n const { open } = useFileDialog({\n onChange: (files) => {\n const selected = files ? Array.from(files) : []\n if (selected.length === 0) {\n return\n }\n\n // Every selected file shares the field key, falling back to the first file name when\n // the row has no name yet (e.g. schema-less requests).\n const fieldName = currentRow?.name || selected[0]?.name || ''\n\n // Keep a selection together beside its field, and emit once so consumers never\n // observe a partially applied selection.\n const selectedRows: TableRow[] = selected.map((file) => ({\n ...currentRow,\n name: fieldName,\n value: file,\n // Selecting files enables untouched optional fields while preserving explicit choices.\n isDisabled: field?.data.isDisabledByDefault\n ? false\n : (field?.data.isDisabled ?? false),\n isDisabledByDefault: false,\n }))\n const existingFiles = field?.data.files\n ? localFormBodyRows.value.filter(\n (row, i) => sourceIndices.includes(i) && row.value instanceof File,\n )\n : []\n const remaining = localFormBodyRows.value.filter(\n (_, i) => !sourceIndices.includes(i),\n )\n localFormBodyRows.value = [\n ...remaining.slice(0, sourceIndex),\n ...existingFiles,\n ...selectedRows,\n ...remaining.slice(sourceIndex),\n ]\n handleUpdateFormValue(localFormBodyRows.value)\n },\n multiple: allowMultiple,\n accept: '*/*',\n })\n void open()\n}\n</script>\n\n<template>\n <!-- Form Data -->\n <template v-if=\"selectedContentType === 'multipart/form-data'\">\n <RequestTable\n :allowUnknownFileUploads=\"allowUnknownFileUploads\"\n :data=\"displayedRows\"\n deferKeyUpdates\n :environment=\"environment\"\n showUploadButton\n @deleteRow=\"handleDeleteRow\"\n @removeFile=\"handleRemoveFile\"\n @updateFile=\"\n (index, disabled) => handleUpsertRow(index, { isDisabled: disabled })\n \"\n @uploadFile=\"handleFileUpload\"\n @upsertRow=\"handleFieldUpsert\" />\n </template>\n\n <!-- Form URL Encoded -->\n <template v-else>\n <RequestTable\n :data=\"localFormBodyRows\"\n deferKeyUpdates\n :environment=\"environment\"\n @deleteRow=\"handleDeleteRow\"\n @upsertRow=\"handleUpsertRow\" />\n </template>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAyCA,MAAM,OAAO;;EAQb,MAAM,oBAAoB,IAAgB,CAAC,CAAC;EAE5C,MAAM,aAAa,eACjB,QAAA,wBAAwB,wBACpB,mBAAmB,kBAAkB,KAAK,IAC1C,kBAAkB,MAAM,KAAK,MAAM,WAAW;GAC5C;GACA,eAAe,CAAC,KAAK;EACvB,EAAE,CACR;EACA,MAAM,gBAAgB,eACpB,WAAW,MAAM,KAAK,UAAU,MAAM,IAAI,CAC5C;;EAGA,YAEI;GACE,Q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AS,EAAE,EAAE,QAAQ;KAI3D,MAAM,eAA2B,SAAS,KAAK,UAAU;MACvD,GAAG;MACH,MAAM;MACN,OAAO;MAEP,YAAY,OAAO,KAAK,sBACpB,QACC,OAAO,KAAK,cAAc;MAC/B,qBAAqB;KACvB,EAAE;KACF,MAAM,gBAAgB,OAAO,KAAK,QAC9B,kBAAkB,MAAM,QACrB,KAAK,MAAM,cAAc,SAAS,CAAC,KAAK,IAAI,iBAAiB,IAChE,IACA,CAAC;KACL,MAAM,YAAY,kBAAkB,MAAM,QACvC,GAAG,MAAM,CAAC,cAAc,SAAS,CAAC,CACrC;KACA,kBAAkB,QAAQ;MACxB,GAAG,UAAU,MAAM,GAAG,WAAW;MACjC,GAAG;MACH,GAAG;MACH,GAAG,UAAU,MAAM,WAAW;KAChC;KACA,sBAAsB,kBAAkB,KAAK;IAC/C;IACA,UAAU;IACV,QAAQ;GACV,CAAC;GACD,KAAU;EACZ;;GAKkB,OAAA,QAAA,wBAAmB,yBACjCA,UAAA,GAAAC,YAYmCC,sBAAA;;IAXhC,yBAAyB,wBAAA;IACzB,MAAM,cAAA;IACP,iBAAA;IACC,aAAa,QAAA;IACd,kBAAA;IACC,aAAW;IACX,cAAY;IACZ,cAAU,OAAA,OAAA,OAAA,MAAY,OAAO,aAAa,gBAAgB,OAAK,EAAA,YAAgB,SAAQ,CAAA;IAGvF,cAAY;IACZ,aAAW;;;;;G,OAKdF,UAAA,GAAAC,YAKiCC,sBAAA;;IAJ9B,MAAM,kBAAA;IACP,iBAAA;IACC,aAAa,QAAA;IACb,aAAW;IACX,aAAW"}
1
+ {"version":3,"file":"RequestBodyForm.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","RequestTable"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestBodyForm.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport { isFileSchema } from '@scalar/workspace-store/helpers/is-file-schema'\nimport { resolveFormSchema } from '@scalar/workspace-store/helpers/resolve-form-schema'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type {\n ExampleObject,\n MediaTypeObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\nimport { computed, ref, watch } from 'vue'\n\nimport { useFileDialog } from '@/hooks/use-file-dialog'\nimport RequestTable from '@/v2/blocks/request-block/components/RequestTable.vue'\nimport type { TableRow } from '@/v2/blocks/request-block/components/RequestTableRow.vue'\nimport {\n getFormBodyRows,\n getFormBodyValue,\n} from '@/v2/blocks/request-block/helpers/get-form-body-rows'\nimport { groupFormBodyFiles } from '@/v2/blocks/request-block/helpers/group-form-body-files'\n\nconst {\n example,\n bodySchema,\n encoding,\n aspNetFormNaming,\n selectedContentType,\n environment,\n compositionSelection,\n} = defineProps<{\n example: ExampleObject | undefined | null\n /** Resolved schema for the form body so the table can show enums and validation per field */\n bodySchema?: SchemaObject\n /** Encoding overrides for individual multipart fields. */\n encoding?: MediaTypeObject['encoding']\n aspNetFormNaming?: boolean\n /** Selected request-body variants, shared with example generation and serialization. */\n compositionSelection?: Record<string, number>\n selectedContentType: string\n environment: XScalarEnvironment\n}>()\n\nconst emit = defineEmits<{\n (\n e: 'update:formValue',\n payload: ApiReferenceEvents['operation:update:requestBody:formValue']['payload'],\n ): void\n}>()\n\n/** Local state for form body rows */\nconst localFormBodyRows = ref<TableRow[]>([])\n\nconst formFields = computed(() =>\n selectedContentType === 'multipart/form-data'\n ? groupFormBodyFiles(localFormBodyRows.value)\n : localFormBodyRows.value.map((data, index) => ({\n data,\n sourceIndices: [index],\n })),\n)\nconst displayedRows = computed<TableRow[]>(() =>\n formFields.value.map((field) => field.data),\n)\n\n/** Sync the local form body rows with the example and schema */\nwatch(\n () =>\n [\n example,\n bodySchema,\n selectedContentType,\n compositionSelection,\n encoding,\n aspNetFormNaming,\n ] as const,\n ([\n newExample,\n schema,\n contentType,\n selection,\n fieldEncoding,\n aspNetNaming,\n ]) => {\n localFormBodyRows.value = getFormBodyRows(\n newExample,\n contentType,\n schema,\n selection,\n fieldEncoding,\n aspNetNaming,\n )\n },\n { immediate: true },\n)\n\n/** Undeclared fields follow additionalProperties instead of losing uploads whenever a schema exists. */\nconst allowUnknownFileUploads = computed<boolean>(() => {\n const schema = resolveFormSchema(bodySchema, compositionSelection)\n const additional =\n schema && 'additionalProperties' in schema\n ? schema.additionalProperties\n : undefined\n return typeof additional === 'object'\n ? isFileSchema(resolveFormSchema(additional) ?? { __scalar_: '' })\n : additional !== false\n})\n\nconst handleUpdateFormValue = (rows: TableRow[]): void => {\n emit(\n 'update:formValue',\n rows.map((row) => ({\n name: row.name,\n value:\n selectedContentType === 'multipart/form-data' || aspNetFormNaming\n ? getFormBodyValue(row)\n : (row.value as string | File),\n isDisabled: row.isDisabled ?? false,\n ...(row.isDisabledByDefault ? { isDisabledByDefault: true } : {}),\n ...((selectedContentType === 'multipart/form-data' || aspNetFormNaming) &&\n row.isArray\n ? { isArray: true }\n : {}),\n })),\n )\n}\n\n/** Update a row in the table, combines with the previous data so we emit a whole row */\nconst handleUpsertRow = (\n index: number | number[],\n payload: Partial<{\n name: string\n value: string | File | undefined\n isDisabled: boolean\n }>,\n): void => {\n const indices = Array.isArray(index) ? index : [index]\n // Add new row\n if (\n indices[0] !== undefined &&\n indices[0] >= localFormBodyRows.value.length\n ) {\n localFormBodyRows.value = [\n ...localFormBodyRows.value,\n { name: '', value: '', ...payload, isDisabled: false },\n ]\n handleUpdateFormValue(localFormBodyRows.value)\n return\n }\n\n localFormBodyRows.value = localFormBodyRows.value.map((row, i) => {\n if (!indices.includes(i)) {\n return row\n }\n\n const valueChanged = 'value' in payload && payload.value !== row.value\n const disabledChanged =\n payload.isDisabled !== undefined && payload.isDisabled !== row.isDisabled\n\n return {\n ...row,\n ...payload,\n // File selection bypasses the text input, but also expresses intent to send a value.\n ...(valueChanged && payload.value !== undefined && row.isDisabledByDefault\n ? { isDisabled: false }\n : {}),\n // Preserve untouched defaults while keeping deliberate checkbox choices explicit.\n isDisabledByDefault:\n row.isDisabledByDefault && !valueChanged && !disabledChanged,\n }\n })\n handleUpdateFormValue(localFormBodyRows.value)\n}\n\n/** Remember individual choices while the whole file field is temporarily disabled. */\nconst disabledFileChoices = new WeakMap<File, boolean>()\n\n/** Apply field edits to all its parts without replacing sibling files with the first file. */\nconst handleFieldUpsert = (\n index: number,\n payload: Parameters<typeof handleUpsertRow>[1],\n): void => {\n const field = formFields.value[index]\n if (\n field?.data.files?.length &&\n payload.isDisabled !== undefined &&\n payload.isDisabled !== field.data.isDisabled\n ) {\n localFormBodyRows.value = localFormBodyRows.value.map((row, i) => {\n if (!field.sourceIndices.includes(i) || !(row.value instanceof File)) {\n return row\n }\n if (payload.isDisabled) {\n disabledFileChoices.set(row.value, row.isDisabled ?? false)\n }\n const isDisabled =\n payload.isDisabled || (disabledFileChoices.get(row.value) ?? false)\n if (!payload.isDisabled) {\n disabledFileChoices.delete(row.value)\n }\n return { ...row, isDisabled, isDisabledByDefault: false }\n })\n handleUpdateFormValue(localFormBodyRows.value)\n return\n }\n handleUpsertRow(\n field?.sourceIndices ?? localFormBodyRows.value.length,\n field?.data.files\n ? {\n ...(payload.name !== undefined ? { name: payload.name } : {}),\n ...(payload.isDisabled !== undefined &&\n payload.isDisabled !== field.data.isDisabled\n ? { isDisabled: payload.isDisabled }\n : {}),\n }\n : payload,\n )\n}\n\n/** Delete a row from the table */\nconst handleDeleteRow = (index: number): void => {\n const indices = formFields.value[index]?.sourceIndices ?? [index]\n localFormBodyRows.value = localFormBodyRows.value.filter(\n (_, i) => !indices.includes(i),\n )\n handleUpdateFormValue(localFormBodyRows.value)\n}\n\n/** Remove a selected file, retaining one empty field after the last file is removed. */\nconst handleRemoveFile = (index: number, fileIndex?: number): void => {\n const field = formFields.value[index]\n const sourceIndex = fileIndex ?? field?.sourceIndices[0] ?? index\n if (field?.data.files) {\n const remaining = localFormBodyRows.value.filter(\n (row, i) =>\n field.sourceIndices.includes(i) &&\n i !== sourceIndex &&\n row.value instanceof File,\n )\n const original = localFormBodyRows.value[sourceIndex]\n if (!original) {\n return\n }\n const replacement = remaining.length\n ? remaining\n : [{ ...original, value: '[]', isArray: true }]\n localFormBodyRows.value = localFormBodyRows.value.flatMap((row, i) => {\n if (i === field.sourceIndices[0]) {\n return replacement\n }\n return field.sourceIndices.includes(i) ? [] : [row]\n })\n handleUpdateFormValue(localFormBodyRows.value)\n return\n }\n handleUpsertRow(sourceIndex, { value: undefined })\n}\n\n/** Handle file upload for a specific row index */\nconst handleFileUpload = (index: number): void => {\n const field = formFields.value[index]\n const sourceIndices = field?.sourceIndices ?? [localFormBodyRows.value.length]\n const sourceIndex = sourceIndices[0] ?? localFormBodyRows.value.length\n const currentRow = localFormBodyRows.value[sourceIndex]\n // Array fields accept multiple files, serialized as separate multipart parts under the same name.\n const allowMultiple = Boolean(\n currentRow?.schema && isArraySchema(currentRow.schema),\n )\n\n const { open } = useFileDialog({\n onChange: (files) => {\n const selected = files ? Array.from(files) : []\n if (selected.length === 0) {\n return\n }\n\n // Every selected file shares the field key, falling back to the first file name when\n // the row has no name yet (e.g. schema-less requests).\n const fieldName = currentRow?.name || selected[0]?.name || ''\n\n // Keep a selection together beside its field, and emit once so consumers never\n // observe a partially applied selection.\n const selectedRows: TableRow[] = selected.map((file) => ({\n ...currentRow,\n name: fieldName,\n value: file,\n // Selecting files enables untouched optional fields while preserving explicit choices.\n isDisabled: field?.data.isDisabledByDefault\n ? false\n : (field?.data.isDisabled ?? false),\n isDisabledByDefault: false,\n }))\n const existingFiles = field?.data.files\n ? localFormBodyRows.value.filter(\n (row, i) => sourceIndices.includes(i) && row.value instanceof File,\n )\n : []\n const remaining = localFormBodyRows.value.filter(\n (_, i) => !sourceIndices.includes(i),\n )\n localFormBodyRows.value = [\n ...remaining.slice(0, sourceIndex),\n ...existingFiles,\n ...selectedRows,\n ...remaining.slice(sourceIndex),\n ]\n handleUpdateFormValue(localFormBodyRows.value)\n },\n multiple: allowMultiple,\n accept: '*/*',\n })\n void open()\n}\n</script>\n\n<template>\n <!-- Form Data -->\n <template v-if=\"selectedContentType === 'multipart/form-data'\">\n <RequestTable\n :allowUnknownFileUploads=\"allowUnknownFileUploads\"\n :data=\"displayedRows\"\n deferKeyUpdates\n :environment=\"environment\"\n showUploadButton\n @deleteRow=\"handleDeleteRow\"\n @removeFile=\"handleRemoveFile\"\n @updateFile=\"\n (index, disabled) => handleUpsertRow(index, { isDisabled: disabled })\n \"\n @uploadFile=\"handleFileUpload\"\n @upsertRow=\"handleFieldUpsert\" />\n </template>\n\n <!-- Form URL Encoded -->\n <template v-else>\n <RequestTable\n :data=\"localFormBodyRows\"\n deferKeyUpdates\n :environment=\"environment\"\n @deleteRow=\"handleDeleteRow\"\n @upsertRow=\"handleUpsertRow\" />\n </template>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,OAAO;;EAQb,MAAM,oBAAoB,IAAgB,CAAC,CAAC;EAE5C,MAAM,aAAa,eACjB,QAAA,wBAAwB,wBACpB,mBAAmB,kBAAkB,KAAK,IAC1C,kBAAkB,MAAM,KAAK,MAAM,WAAW;GAC5C;GACA,eAAe,CAAC,KAAK;EACvB,EAAE,CACR;EACA,MAAM,gBAAgB,eACpB,WAAW,MAAM,KAAK,UAAU,MAAM,IAAI,CAC5C;;EAGA,YAEI;GACE,QAAA;GACA,QAAA;GACA,QAAA;GACA,QAAA;GACA,QAAA;GACA,QAAA;EACF,IACD,CACC,YACA,QACA,aACA,WACA,eACA,kBACI;GACJ,kBAAkB,QAAQ,gBACxB,YACA,aACA,QACA,WACA,eACA,YACF;EACF,GACA,EAAE,WAAW,KAAK,CACpB;;EAGA,MAAM,0BAA0B,eAAwB;GACtD,MAAM,SAAS,kBAAkB,QAAA,YAAY,QAAA,oBAAoB;GACjE,MAAM,aACJ,UAAU,0BAA0B,SAChC,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iBAAiB,IAChE,IACA,CAAC;KACL,MAAM,YAAY,kBAAkB,MAAM,QACvC,GAAG,MAAM,CAAC,cAAc,SAAS,CAAC,CACrC;KACA,kBAAkB,QAAQ;MACxB,GAAG,UAAU,MAAM,GAAG,WAAW;MACjC,GAAG;MACH,GAAG;MACH,GAAG,UAAU,MAAM,WAAW;KAChC;KACA,sBAAsB,kBAAkB,KAAK;IAC/C;IACA,UAAU;IACV,QAAQ;GACV,CAAC;GACD,KAAU;EACZ;;GAKkB,OAAA,QAAA,wBAAmB,yBACjCA,UAAA,GAAAC,YAYmCC,sBAAA;;IAXhC,yBAAyB,wBAAA;IACzB,MAAM,cAAA;IACP,iBAAA;IACC,aAAa,QAAA;IACd,kBAAA;IACC,aAAW;IACX,cAAY;IACZ,cAAU,OAAA,OAAA,OAAA,MAAY,OAAO,aAAa,gBAAgB,OAAK,EAAA,YAAgB,SAAQ,CAAA;IAGvF,cAAY;IACZ,aAAW;;;;;G,OAKdF,UAAA,GAAAC,YAKiCC,sBAAA;;IAJ9B,MAAM,kBAAA;IACP,iBAAA;IACC,aAAa,QAAA;IACb,aAAW;IACX,aAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"RequestCodeSnippet.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"names":[],"mappings":"AAqLA,OAAO,EAOL,KAAK,gBAAgB,EAEtB,MAAM,6BAA6B,CAAA;AAMpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAOvE,KAAK,WAAW,GAAG,gBAAgB,GAAG;IAAE,QAAQ,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAoUtE,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"RequestCodeSnippet.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"names":[],"mappings":"AAuLA,OAAO,EAOL,KAAK,gBAAgB,EAEtB,MAAM,6BAA6B,CAAA;AAMpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAOvE,KAAK,WAAW,GAAG,gBAAgB,GAAG;IAAE,QAAQ,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAsUtE,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -41,6 +41,7 @@ var RequestCodeSnippet_vue_vue_type_script_setup_true_lang_default = /*@__PURE__
41
41
  globalCookies: {},
42
42
  openapiVersion: {},
43
43
  jsonSchemaDialect: {},
44
+ multipartNaming: {},
44
45
  requestBodyCompositionSelection: {}
45
46
  },
46
47
  setup(__props) {
@@ -86,6 +87,7 @@ var RequestCodeSnippet_vue_vue_type_script_setup_true_lang_default = /*@__PURE__
86
87
  globalCookies: __props.globalCookies,
87
88
  openapiVersion: __props.openapiVersion,
88
89
  jsonSchemaDialect: __props.jsonSchemaDialect,
90
+ multipartNaming: __props.multipartNaming,
89
91
  requestBodyCompositionSelection: __props.requestBodyCompositionSelection,
90
92
  includeDefaultHeaders: __props.integration === "client"
91
93
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"RequestCodeSnippet.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","CollapsibleSection","_withCtx","_createTextVNode","_toDisplayString","_createElementVNode","_createVNode","_normalizeClass","DataTable","DataTableRow","_createElementBlock"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n findClient,\n generateCodeSnippet,\n getClients,\n getCustomCodeSamples,\n getSecrets,\n type ClientOption,\n type CodeExampleProps,\n type CustomClientOption,\n} from '@scalar/blocks/code-example'\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarErrorBoundary } from '@scalar/components/error-boundary'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { computed, ref, watch } from 'vue'\n\nimport { DataTable, DataTableRow } from '@/v2/components/data-table'\nimport { CollapsibleSection } from '@/v2/components/layout'\nimport { useLocalization } from '@/v2/features/localization'\n\nconst {\n clientOptions,\n eventBus,\n operation,\n method,\n path,\n selectedContentType,\n selectedServer = null,\n selectedExample,\n securitySchemes,\n selectedClient,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n integration,\n} = defineProps<CodeExampleProps & { eventBus: WorkspaceEventBus }>()\n\nconst { translate } = useLocalization()\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/**\n * The locally selected client which would include code samples from this operation only\n * Must be local state because it contains custom code samples from this operation only\n */\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/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() => getSecrets(securitySchemes ?? []))\n\n/** Handle client change */\nconst handleClientChange = (option: ClientOption | undefined) => {\n localSelectedClient.value = option\n\n // Sync the selection globally (built-in client or custom sample keyed by language)\n if (option) {\n eventBus.emit('workspace:update:selected-client', option.id)\n }\n}\n\n/** Generate the code snippet for the selected example */\nconst generatedCode = computed<string | null>(() =>\n generateCodeSnippet({\n defaultDisabledParameters: true,\n clientId: localSelectedClient.value?.id,\n customCodeSamples: customCodeSamples.value.samples,\n operation,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: selectedExample,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n includeDefaultHeaders: integration === 'client',\n }),\n)\n\n/** Check if there are any clients available (built-in or custom code samples) */\nconst hasClients = computed(() =>\n clients.value.some((group) => group.options.length > 0),\n)\n</script>\n\n<template>\n <CollapsibleSection\n v-if=\"hasClients\"\n class=\"group/preview w-full border-t\"\n :defaultOpen=\"false\">\n <template #title>\n {{ translate('apiClient.requestCodeSnippet.codeSnippet') }}\n </template>\n\n <!-- Client selector -->\n <template #actions>\n <div class=\"flex flex-1\">\n <ScalarCombobox\n :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n @update:modelValue=\"\n (ev) => handleClientChange(ev as ClientOption | undefined)\n \">\n <template #default=\"{ open }\">\n <ScalarButton\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=\"mt-0.25 size-3 transition-transform duration-100\"\n :class=\"open && 'rotate-180'\"\n weight=\"bold\" />\n </ScalarButton>\n </template>\n </ScalarCombobox>\n </div>\n </template>\n\n <!-- Code snippet -->\n <ScalarErrorBoundary>\n <DataTable\n :columns=\"['']\"\n presentational>\n <DataTableRow>\n <div class=\"overflow-hidden\">\n <div\n v-if=\"generatedCode === null\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n {{ translate('apiClient.requestCodeSnippet.unavailable') }}\n </div>\n <ScalarCodeBlock\n v-else\n class=\"text-base\"\n :content=\"generatedCode\"\n :hideCredentials=\"secretCredentials\"\n :label=\"translate('apiClient.requestCodeSnippet.codeSnippet')\"\n :lang=\"localSelectedClient?.lang ?? 'plaintext'\"\n lineNumbers />\n </div>\n </DataTableRow>\n </D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ection","_withCtx","_createTextVNode","_toDisplayString","_createElementVNode","_createVNode","_normalizeClass","DataTable","DataTableRow","_createElementBlock"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n findClient,\n generateCodeSnippet,\n getClients,\n getCustomCodeSamples,\n getSecrets,\n type ClientOption,\n type CodeExampleProps,\n type CustomClientOption,\n} from '@scalar/blocks/code-example'\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarErrorBoundary } from '@scalar/components/error-boundary'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { computed, ref, watch } from 'vue'\n\nimport { DataTable, DataTableRow } from '@/v2/components/data-table'\nimport { CollapsibleSection } from '@/v2/components/layout'\nimport { useLocalization } from '@/v2/features/localization'\n\nconst {\n clientOptions,\n eventBus,\n operation,\n method,\n path,\n selectedContentType,\n selectedServer = null,\n selectedExample,\n securitySchemes,\n selectedClient,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n multipartNaming,\n requestBodyCompositionSelection,\n integration,\n} = defineProps<CodeExampleProps & { eventBus: WorkspaceEventBus }>()\n\nconst { translate } = useLocalization()\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/**\n * The locally selected client which would include code samples from this operation only\n * Must be local state because it contains custom code samples from this operation only\n */\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/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() => getSecrets(securitySchemes ?? []))\n\n/** Handle client change */\nconst handleClientChange = (option: ClientOption | undefined) => {\n localSelectedClient.value = option\n\n // Sync the selection globally (built-in client or custom sample keyed by language)\n if (option) {\n eventBus.emit('workspace:update:selected-client', option.id)\n }\n}\n\n/** Generate the code snippet for the selected example */\nconst generatedCode = computed<string | null>(() =>\n generateCodeSnippet({\n defaultDisabledParameters: true,\n clientId: localSelectedClient.value?.id,\n customCodeSamples: customCodeSamples.value.samples,\n operation,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: selectedExample,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n multipartNaming,\n requestBodyCompositionSelection,\n includeDefaultHeaders: integration === 'client',\n }),\n)\n\n/** Check if there are any clients available (built-in or custom code samples) */\nconst hasClients = computed(() =>\n clients.value.some((group) => group.options.length > 0),\n)\n</script>\n\n<template>\n <CollapsibleSection\n v-if=\"hasClients\"\n class=\"group/preview w-full border-t\"\n :defaultOpen=\"false\">\n <template #title>\n {{ translate('apiClient.requestCodeSnippet.codeSnippet') }}\n </template>\n\n <!-- Client selector -->\n <template #actions>\n <div class=\"flex flex-1\">\n <ScalarCombobox\n :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n @update:modelValue=\"\n (ev) => handleClientChange(ev as ClientOption | undefined)\n \">\n <template #default=\"{ open }\">\n <ScalarButton\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=\"mt-0.25 size-3 transition-transform duration-100\"\n :class=\"open && 'rotate-180'\"\n weight=\"bold\" />\n </ScalarButton>\n </template>\n </ScalarCombobox>\n </div>\n </template>\n\n <!-- Code snippet -->\n <ScalarErrorBoundary>\n <DataTable\n :columns=\"['']\"\n presentational>\n <DataTableRow>\n <div class=\"overflow-hidden\">\n <div\n v-if=\"generatedCode === null\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n {{ translate('apiClient.requestCodeSnippet.unavailable') }}\n </div>\n <ScalarCodeBlock\n v-else\n class=\"text-base\"\n :content=\"generatedCode\"\n :hideCredentials=\"secretCredentials\"\n :label=\"translate('apiClient.requestCodeSnippet.codeSnippet')\"\n :lang=\"localSelectedClient?.lang ?? 'plaintext'\"\n lineNumbers />\n </div>\n </DataTableRow>\n </DataTable>\n </ScalarErrorBoundary>\n </CollapsibleSection>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0CA,MAAM,EAAE,cAAc,gBAAgB;;EAGtC,MAAM,oBAAoB,eAAe,qBAAqB,QAAA,SAAS,CAAC;;EAGxE,MAAM,UAAU,eACd,WACE,kBAAkB,MAAM,SACxB,QAAA,eACA,kBAAkB,MAAM,KAC1B,CACF;;;;;EAMA,MAAM,sBAAsB,IAC1B,WAAW,QAAQ,OAAO,QAAA,cAAc,CAC1C;;;;;;;EAQA,MAAM,OAAO,QAAA,gBAAgB,OAAO,IAAI,CAAC,eAAe;GACtD,MAAM,SAAS,WAAW,QAAQ,OAAO,SAAS;GAClD,IAAI,QACF,oBAAoB,QAAQ;EAEhC,CAAC;;EAGD,MAAM,oBAAoB,eAAe,WAAW,QAAA,mBAAmB,CAAC,CAAC,CAAC;;EAG1E,MAAM,sBAAsB,WAAqC;GAC/D,oBAAoB,QAAQ;GAG5B,IAAI,QACF,QAAA,SAAS,KAAK,oCAAoC,OAAO,EAAE;EAE/D;;EAGA,MAAM,gBAAgB,eACpB,oBAAoB;GAClB,2BAA2B;GAC3B,UAAU,oBAAoB,OAAO;GACrC,mBAAmB,kBAAkB,MAAM;GAC3C,WAAQ,QAA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Bb,SAAAP,cAeM,CAfNG,mBAeM,OAfN,YAeM,CAbI,cAAA,UAAa,QADrBP,UAAA,GAAAY,mBAKM,OALN,YAKMN,gBADDJ,MAAA,SAAA,CAAS,CAAA,0CAAA,CAAA,GAAA,CAAA,MAEdF,UAAA,GAAAC,YAOgBC,MAAA,eAAA,GAAA;;QALd,OAAM;QACL,SAAS,cAAA;QACT,iBAAiB,kBAAA;QACjB,OAAOA,MAAA,SAAA,CAAS,CAAA,0CAAA;QAChB,MAAM,oBAAA,OAAqB,QAAI;QAChC,aAAA"}
@@ -32,5 +32,5 @@ export declare const collectExampleRows: (example: unknown, schema: SchemaObject
32
32
  /** Restore array values after text editing without parsing ordinary string fields. */
33
33
  export declare const getFormBodyValue: (row: TableRow) => string | File | unknown[] | undefined;
34
34
  /** Build the table rows for the form data, optionally enriched with schema (e.g. enum) per property */
35
- export declare const getFormBodyRows: (example: ExampleObject | undefined | null, contentType: string, formBodySchema?: SchemaObject, compositionSelection?: Record<string, number>, encoding?: MediaTypeObject["encoding"]) => TableRow[];
35
+ export declare const getFormBodyRows: (example: ExampleObject | undefined | null, contentType: string, formBodySchema?: SchemaObject, compositionSelection?: Record<string, number>, encoding?: MediaTypeObject["encoding"], aspNetFormNaming?: boolean) => TableRow[];
36
36
  //# sourceMappingURL=get-form-body-rows.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-form-body-rows.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/get-form-body-rows.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAGrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0DAA0D,CAAA;AAExF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,WAQ5C,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,MAAM,EAAE,YAAY,GAAG,SAAS,CAAA;IAChC,UAAU,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,YAAY,EACpB,aAAY,MAAM,EAAO,EACzB,wBAAqB,EACrB,oBAAoB,MAAM,KACzB,OAAO,EA6BT,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,OAAO,EAChB,QAAQ,YAAY,GAAG,SAAS,EAChC,aAAY,MAAM,EAAO,KACxB;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAqCpC,CAAA;AAED,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,GAAI,KAAK,QAAQ,KAAG,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,SAG5E,CAAA;AAED,uGAAuG;AACvG,eAAO,MAAM,eAAe,GAC1B,SAAS,aAAa,GAAG,SAAS,GAAG,IAAI,EACzC,aAAa,MAAM,EACnB,iBAAiB,YAAY,EAC7B,uBAAuB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7C,WAAW,eAAe,CAAC,UAAU,CAAC,KACrC,QAAQ,EA8JV,CAAA"}
1
+ {"version":3,"file":"get-form-body-rows.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/get-form-body-rows.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAGrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0DAA0D,CAAA;AAExF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,WAQ5C,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,MAAM,EAAE,YAAY,GAAG,SAAS,CAAA;IAChC,UAAU,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,YAAY,EACpB,aAAY,MAAM,EAAO,EACzB,wBAAqB,EACrB,oBAAoB,MAAM,KACzB,OAAO,EA6BT,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,OAAO,EAChB,QAAQ,YAAY,GAAG,SAAS,EAChC,aAAY,MAAM,EAAO,KACxB;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAqCpC,CAAA;AAED,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,GAAI,KAAK,QAAQ,KAAG,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,SAG5E,CAAA;AAED,uGAAuG;AACvG,eAAO,MAAM,eAAe,GAC1B,SAAS,aAAa,GAAG,SAAS,GAAG,IAAI,EACzC,aAAa,MAAM,EACnB,iBAAiB,YAAY,EAC7B,uBAAuB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7C,WAAW,eAAe,CAAC,UAAU,CAAC,EACtC,0BAAwB,KACvB,QAAQ,EA0KV,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { objectEntries } from "@scalar/helpers/object/object-entries";
2
- import { coerceLeafValueToSchemaType } from "@scalar/workspace-store/request-example";
2
+ import { coerceLeafValueToSchemaType, getAspNetFormFields } from "@scalar/workspace-store/request-example";
3
3
  import { isObject } from "@scalar/helpers/object/is-object";
4
4
  import { isObjectSchema } from "@scalar/workspace-store/schemas/v3.2/strict/type-guards";
5
5
  import { resolveFormSchema } from "@scalar/workspace-store/helpers/resolve-form-schema";
@@ -79,7 +79,7 @@ var getFormBodyValue = (row) => {
79
79
  return Array.isArray(value) ? value : row.value ?? void 0;
80
80
  };
81
81
  /** Build the table rows for the form data, optionally enriched with schema (e.g. enum) per property */
82
- var getFormBodyRows = (example, contentType, formBodySchema, compositionSelection, encoding) => {
82
+ var getFormBodyRows = (example, contentType, formBodySchema, compositionSelection, encoding, aspNetFormNaming = false) => {
83
83
  const value = example?.dataValue !== void 0 ? example.dataValue : example?.value;
84
84
  if (!value || contentType !== "multipart/form-data" && contentType !== "application/x-www-form-urlencoded") return [];
85
85
  const resolvedBodySchema = resolveFormSchema(formBodySchema, compositionSelection);
@@ -121,9 +121,16 @@ var getFormBodyRows = (example, contentType, formBodySchema, compositionSelectio
121
121
  value: value instanceof File || value == null ? value ?? "" : stringifyValue(value),
122
122
  isDisabled
123
123
  });
124
- if (contentType === "multipart/form-data" && (Array.isArray(value) || isArray)) row.isArray = true;
124
+ if ((contentType === "multipart/form-data" || aspNetFormNaming) && (Array.isArray(value) || isArray)) row.isArray = true;
125
125
  return [row];
126
126
  };
127
+ if (aspNetFormNaming) return getAspNetFormFields(value, schemaWithProperties, compositionSelection, true).flatMap((field) => mapValue(field.name, field.value, field.isDisabled, field.isArray).map((row) => ({
128
+ ...row,
129
+ schema: field.schema ?? row.schema,
130
+ description: field.schema?.description ?? row.description,
131
+ isRequired: field.isRequired || row.isRequired,
132
+ ...field.isDisabledByDefault ? { isDisabledByDefault: true } : {}
133
+ })));
127
134
  if (Array.isArray(value)) return value.flatMap((exampleValue) => {
128
135
  if (isObject(exampleValue)) {
129
136
  const name = String(exampleValue.name);
@@ -1 +1 @@
1
- {"version":3,"file":"get-form-body-rows.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/helpers/get-form-body-rows.ts"],"sourcesContent":["import { isObject } from '@scalar/helpers/object/is-object'\nimport { objectEntries } from '@scalar/helpers/object/object-entries'\nimport { resolveFormSchema } from '@scalar/workspace-store/helpers/resolve-form-schema'\nimport { resolveSchemaWithAnnotations } from '@scalar/workspace-store/helpers/resolve-schema-with-annotations'\nimport { coerceLeafValueToSchemaType } from '@scalar/workspace-store/request-example'\nimport type {\n ExampleObject,\n MediaTypeObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\nimport type { TableRow } from '@/v2/blocks/request-block/components/RequestTableRow.vue'\n\nexport const stringifyValue = (value: unknown) => {\n if (value instanceof File) {\n return value.name\n }\n if (typeof value === 'object' && value !== null) {\n return JSON.stringify(value)\n }\n return String(value)\n}\n\nexport type LeafRow = {\n path: string[]\n schema: SchemaObject | undefined\n isRequired: boolean\n description?: string\n}\n\n/**\n * Walk a (possibly nested) object schema and collect one entry per leaf property.\n *\n * A \"leaf\" is any property whose resolved schema is not an `{ type: 'object' }` schema\n * with named `properties` — i.e. primitives, arrays, files, and `additionalProperties`\n * placeholders all stop the recursion. Object properties recurse, so the widget example\n * (`file` + `props.{name,description,created_at}`) yields four leaves.\n */\nexport const collectLeafProperties = (\n schema: SchemaObject,\n parentPath: string[] = [],\n parentRequired = true,\n parentDescription?: string,\n): LeafRow[] => {\n // Nothing to walk if this is not an object schema or has no declared properties.\n if (!isObjectSchema(schema) || !schema.properties) {\n return []\n }\n\n // `required` is a list of property names on *this* schema, so build it once per level.\n const requiredSet = new Set(schema.required ?? [])\n const leaves: LeafRow[] = []\n\n for (const [key, rawChildSchema] of objectEntries(schema.properties)) {\n const childSchema = resolveSchemaWithAnnotations(rawChildSchema)\n const path = [...parentPath, String(key)]\n\n // A leaf is only required when *every* ancestor was also required — a non-required\n // parent makes the whole subtree optional regardless of inner `required` lists.\n const isRequired = parentRequired && requiredSet.has(String(key))\n\n // Nested objects with named properties recurse so each leaf gets its own row;\n // everything else (primitives, arrays, files, additionalProperties placeholders)\n // is treated as a leaf and stops the descent.\n if (childSchema && isObjectSchema(childSchema) && childSchema.properties) {\n leaves.push(...collectLeafProperties(childSchema, path, isRequired, childSchema.description ?? parentDescription))\n } else {\n leaves.push({ path, schema: childSchema, isRequired, description: childSchema?.description ?? parentDescription })\n }\n }\n\n return leaves\n}\n\n/**\n * Walk a schema + example together and collect one row per leaf, including example-only\n * keys that the schema does not declare. Schema-declared properties come first in schema\n * order; extras present in the example follow in example order at each level.\n *\n * Unlike `collectLeafProperties` (which is schema-only and feeds the dotted-name index),\n * this walker drives what the user actually sees in the form: a row for every leaf the\n * example contains, even when the schema is partial or out of date.\n */\nexport const collectExampleRows = (\n example: unknown,\n schema: SchemaObject | undefined,\n parentPath: string[] = [],\n): { path: string[]; value: unknown }[] => {\n const rows: { path: string[]; value: unknown }[] = []\n const exampleEntries = isObject(example) ? objectEntries(example) : []\n const exampleByKey = new Map<string, unknown>(exampleEntries.map(([key, value]) => [String(key), value]))\n const declaredKeys = new Set<string>()\n const schemaProperties = schema && isObjectSchema(schema) ? (schema.properties ?? {}) : {}\n\n // Schema-declared properties first, in schema order. Nested object schemas recurse so\n // each leaf gets its own row; otherwise the schema-declared key is a leaf and uses the\n // matching example value (or `undefined` when the example does not provide one).\n for (const [key, rawChildSchema] of objectEntries(schemaProperties)) {\n const keyStr = String(key)\n declaredKeys.add(keyStr)\n const childSchema = resolveSchemaWithAnnotations(rawChildSchema)\n const path = [...parentPath, keyStr]\n const exampleSubvalue = exampleByKey.get(keyStr)\n\n if (childSchema && isObjectSchema(childSchema) && childSchema.properties) {\n rows.push(...collectExampleRows(exampleSubvalue, childSchema, path))\n } else {\n rows.push({ path, value: exampleSubvalue })\n }\n }\n\n // Example-only properties at this level (preserve example order). Their inner shape is\n // not descended into — without a schema saying \"this is a nested object\" we have no\n // signal to flatten, so an object value becomes a single JSON-stringified row, matching\n // the schema-less fallback below.\n for (const [key, value] of exampleEntries) {\n const keyStr = String(key)\n if (declaredKeys.has(keyStr)) {\n continue\n }\n rows.push({ path: [...parentPath, keyStr], value })\n }\n\n return rows\n}\n\n/** Restore array values after text editing without parsing ordinary string fields. */\nexport const getFormBodyValue = (row: TableRow): string | File | unknown[] | undefined => {\n const value = coerceLeafValueToSchemaType(row.value, row.isArray ? { type: 'array' } : row.schema)\n return Array.isArray(value) ? value : (row.value ?? undefined)\n}\n\n/** Build the table rows for the form data, optionally enriched with schema (e.g. enum) per property */\nexport const getFormBodyRows = (\n example: ExampleObject | undefined | null,\n contentType: string,\n formBodySchema?: SchemaObject,\n compositionSelection?: Record<string, number>,\n encoding?: MediaTypeObject['encoding'],\n): TableRow[] => {\n // Forms use structured data even when the raw example also supplies wire text.\n const value = example?.dataValue !== undefined ? example.dataValue : example?.value\n // We only need the rows for formData\n if (!value || (contentType !== 'multipart/form-data' && contentType !== 'application/x-www-form-urlencoded')) {\n return []\n }\n\n // Get all the schema properties if the schema is an object schema\n const resolvedBodySchema = resolveFormSchema(formBodySchema, compositionSelection)\n const schemaWithProperties =\n resolvedBodySchema &&\n (isObjectSchema(resolvedBodySchema) ||\n 'properties' in resolvedBodySchema ||\n 'additionalProperties' in resolvedBodySchema)\n ? { ...resolvedBodySchema, type: 'object' as const }\n : undefined\n // The request builder preserves composed fields because members can make them required.\n // Keep those fields checked so the initial form matches the body that will be sent.\n const isComposed = Boolean(schemaWithProperties?.allOf || schemaWithProperties?.oneOf || schemaWithProperties?.anyOf)\n const requiredSet = schemaWithProperties ? new Set(schemaWithProperties.required ?? []) : undefined\n\n // Pre-compute the leaf-by-dotted-name index up front so both the array and the\n // schema-driven branches can pull each row's leaf schema and required flag without\n // re-walking the schema. Without this, edited rows lose the per-leaf `Required`\n // badge because a top-level `properties[name]` lookup misses dotted names.\n const leafByDottedName = new Map<string, LeafRow>()\n if (schemaWithProperties) {\n for (const leaf of collectLeafProperties(schemaWithProperties)) {\n leafByDottedName.set(leaf.path.join('.'), leaf)\n }\n }\n\n const mapRow = ({\n name,\n value,\n isDisabled,\n }: {\n name: string\n value: string | File\n isDisabled?: boolean\n }): TableRow => {\n const row: TableRow = {\n name,\n value,\n isDisabled: isDisabled ?? false,\n ...(encoding?.[name]?.contentType ? { contentType: encoding[name].contentType } : {}),\n }\n if (!schemaWithProperties || !name) {\n return row\n }\n // Prefer the pre-resolved leaf (handles dotted names like `props.name`); fall back\n // to a top-level property lookup so user-added rows keep working.\n const leaf = leafByDottedName.get(name)\n const propSchema =\n leaf?.schema ??\n resolveSchemaWithAnnotations(\n schemaWithProperties.properties?.[name] ??\n (typeof schemaWithProperties.additionalProperties === 'object'\n ? schemaWithProperties.additionalProperties\n : schemaWithProperties.additionalProperties === false\n ? undefined\n : { __scalar_: '' }),\n )\n row.schema = propSchema\n row.description = leaf?.description ?? propSchema?.description\n row.isRequired = leaf?.isRequired ?? requiredSet?.has(name) ?? false\n\n // Top-level optional properties default to disabled (unchecked), matching how optional\n // parameters behave. Scoped to top-level declared properties on purpose: the send side\n // (`build-request-body`) only drops top-level optional keys, so auto-disabling a nested\n // leaf (e.g. `props.name`) would leave it unchecked yet still transmitted. `Object.hasOwn`\n // (not `in`) keeps example-only keys named like `Object.prototype` members enabled. An\n // explicit `isDisabled` (from a stored form-row array) always wins.\n if (\n isDisabled === undefined &&\n !isComposed &&\n schemaWithProperties.properties &&\n Object.hasOwn(schemaWithProperties.properties, name)\n ) {\n row.isDisabled = !row.isRequired\n // Mark the row as disabled by default (no explicit `isDisabled` was stored) so typing a\n // value auto-enables it in `RequestTableRow`, matching how optional parameters behave. An\n // explicit `isDisabled` from a stored form-row array skips this branch and keeps winning.\n row.isDisabledByDefault = row.isDisabled\n }\n return row\n }\n\n const mapValue = (name: string, value: unknown, isDisabled?: boolean, isArray?: boolean): TableRow[] => {\n // Uploaded files must never pass through JSON.stringify, which discards their bytes.\n if (\n contentType === 'multipart/form-data' &&\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => item instanceof File)\n ) {\n return value.map((file) => mapRow({ name, value: file, isDisabled }))\n }\n const row = mapRow({\n name,\n value: value instanceof File || value == null ? (value ?? '') : stringifyValue(value),\n isDisabled,\n })\n if (contentType === 'multipart/form-data' && (Array.isArray(value) || isArray)) {\n // Example-only arrays also need their type to survive a form-table round trip.\n row.isArray = true\n }\n return [row]\n }\n\n // We have form data stored as an array\n if (Array.isArray(value)) {\n return value.flatMap((exampleValue) => {\n if (isObject(exampleValue)) {\n const name = String(exampleValue.name)\n const rows =\n contentType === 'multipart/form-data'\n ? mapValue(name, exampleValue.value, Boolean(exampleValue.isDisabled), exampleValue.isArray === true)\n : [\n mapRow({\n name,\n value: exampleValue.value instanceof File ? exampleValue.value : String(exampleValue.value),\n isDisabled: Boolean(exampleValue.isDisabled),\n }),\n ]\n // An untouched optional row stays eligible for auto-enabling after another row is edited.\n return rows.map((row) =>\n row.isDisabled && exampleValue.isDisabledByDefault === true ? { ...row, isDisabledByDefault: true } : row,\n )\n }\n return { name: '', value: exampleValue, isDisabled: false }\n })\n }\n\n // Schema-driven path: when the form body schema describes nested objects, emit one row\n // per leaf so users can edit individual fields. The dotted name (`props.name`) is folded\n // back into a single JSON multipart part by `build-request-body.ts` before the request is\n // sent. Gated to `multipart/form-data` because urlencoded has no regrouping step on send,\n // so dotted leaves would otherwise reach the wire as separate `props.name`-style fields.\n //\n // We walk the example alongside the schema so example-only properties (top-level extras\n // or undeclared keys inside a nested object) are still visible and editable instead of\n // being silently dropped to whatever the schema happens to declare.\n if (contentType === 'multipart/form-data' && schemaWithProperties && typeof value === 'object') {\n return collectExampleRows(value, schemaWithProperties).flatMap(({ path, value }) => mapValue(path.join('.'), value))\n }\n\n // We got an object try to convert it to an array of rows\n if (typeof value === 'object' && value) {\n return objectEntries(value).flatMap(([key, value]) =>\n contentType === 'multipart/form-data'\n ? mapValue(String(key), value)\n : mapRow({ name: String(key), value: stringifyValue(value) }),\n )\n }\n\n return []\n}\n"],"mappings":";;;;;;;AAcA,IAAa,kBAAkB,UAAmB;CAChD,IAAI,iBAAiB,MACnB,OAAO,MAAM;CAEf,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO,KAAK,UAAU,KAAK;CAE7B,OAAO,OAAO,KAAK;AACrB;;;;;;;;;AAiBA,IAAa,yBACX,QACA,aAAuB,CAAC,GACxB,iBAAiB,MACjB,sBACc;CAEd,IAAI,CAAC,eAAe,MAAM,KAAK,CAAC,OAAO,YACrC,OAAO,CAAC;CA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AiB,OAAO,aAAa,QAAQ,OAAO,aAAa,KAAK;IAC1F,YAAY,QAAQ,aAAa,UAAU;GAC7C,CAAC,CACH,EAAA,CAEM,KAAK,QACf,IAAI,cAAc,aAAa,wBAAwB,OAAO;IAAE,GAAG;IAAK,qBAAqB;GAAK,IAAI,GACxG;EACF;EACA,OAAO;GAAE,MAAM;GAAI,OAAO;GAAc,YAAY;EAAM;CAC5D,CAAC;CAYH,IAAI,gBAAgB,yBAAyB,wBAAwB,OAAO,UAAU,UACpF,OAAO,mBAAmB,OAAO,oBAAoB,CAAC,CAAC,SAAS,EAAE,MAAM,YAAY,SAAS,KAAK,KAAK,GAAG,GAAG,KAAK,CAAC;CAIrH,IAAI,OAAO,UAAU,YAAY,OAC/B,OAAO,cAAc,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,WACzC,gBAAgB,wBACZ,SAAS,OAAO,GAAG,GAAG,KAAK,IAC3B,OAAO;EAAE,MAAM,OAAO,GAAG;EAAG,OAAO,eAAe,KAAK;CAAE,CAAC,CAChE;CAGF,OAAO,CAAC;AACV"}
1
+ {"version":3,"file":"get-form-body-rows.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/helpers/get-form-body-rows.ts"],"sourcesContent":["import { isObject } from '@scalar/helpers/object/is-object'\nimport { objectEntries } from '@scalar/helpers/object/object-entries'\nimport { resolveFormSchema } from '@scalar/workspace-store/helpers/resolve-form-schema'\nimport { resolveSchemaWithAnnotations } from '@scalar/workspace-store/helpers/resolve-schema-with-annotations'\nimport { coerceLeafValueToSchemaType, getAspNetFormFields } from '@scalar/workspace-store/request-example'\nimport type {\n ExampleObject,\n MediaTypeObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\nimport type { TableRow } from '@/v2/blocks/request-block/components/RequestTableRow.vue'\n\nexport const stringifyValue = (value: unknown) => {\n if (value instanceof File) {\n return value.name\n }\n if (typeof value === 'object' && value !== null) {\n return JSON.stringify(value)\n }\n return String(value)\n}\n\nexport type LeafRow = {\n path: string[]\n schema: SchemaObject | undefined\n isRequired: boolean\n description?: string\n}\n\n/**\n * Walk a (possibly nested) object schema and collect one entry per leaf property.\n *\n * A \"leaf\" is any property whose resolved schema is not an `{ type: 'object' }` schema\n * with named `properties` — i.e. primitives, arrays, files, and `additionalProperties`\n * placeholders all stop the recursion. Object properties recurse, so the widget example\n * (`file` + `props.{name,description,created_at}`) yields four leaves.\n */\nexport const collectLeafProperties = (\n schema: SchemaObject,\n parentPath: string[] = [],\n parentRequired = true,\n parentDescription?: string,\n): LeafRow[] => {\n // Nothing to walk if this is not an object schema or has no declared properties.\n if (!isObjectSchema(schema) || !schema.properties) {\n return []\n }\n\n // `required` is a list of property names on *this* schema, so build it once per level.\n const requiredSet = new Set(schema.required ?? [])\n const leaves: LeafRow[] = []\n\n for (const [key, rawChildSchema] of objectEntries(schema.properties)) {\n const childSchema = resolveSchemaWithAnnotations(rawChildSchema)\n const path = [...parentPath, String(key)]\n\n // A leaf is only required when *every* ancestor was also required — a non-required\n // parent makes the whole subtree optional regardless of inner `required` lists.\n const isRequired = parentRequired && requiredSet.has(String(key))\n\n // Nested objects with named properties recurse so each leaf gets its own row;\n // everything else (primitives, arrays, files, additionalProperties placeholders)\n // is treated as a leaf and stops the descent.\n if (childSchema && isObjectSchema(childSchema) && childSchema.properties) {\n leaves.push(...collectLeafProperties(childSchema, path, isRequired, childSchema.description ?? parentDescription))\n } else {\n leaves.push({ path, schema: childSchema, isRequired, description: childSchema?.description ?? parentDescription })\n }\n }\n\n return leaves\n}\n\n/**\n * Walk a schema + example together and collect one row per leaf, including example-only\n * keys that the schema does not declare. Schema-declared properties come first in schema\n * order; extras present in the example follow in example order at each level.\n *\n * Unlike `collectLeafProperties` (which is schema-only and feeds the dotted-name index),\n * this walker drives what the user actually sees in the form: a row for every leaf the\n * example contains, even when the schema is partial or out of date.\n */\nexport const collectExampleRows = (\n example: unknown,\n schema: SchemaObject | undefined,\n parentPath: string[] = [],\n): { path: string[]; value: unknown }[] => {\n const rows: { path: string[]; value: unknown }[] = []\n const exampleEntries = isObject(example) ? objectEntries(example) : []\n const exampleByKey = new Map<string, unknown>(exampleEntries.map(([key, value]) => [String(key), value]))\n const declaredKeys = new Set<string>()\n const schemaProperties = schema && isObjectSchema(schema) ? (schema.properties ?? {}) : {}\n\n // Schema-declared properties first, in schema order. Nested object schemas recurse so\n // each leaf gets its own row; otherwise the schema-declared key is a leaf and uses the\n // matching example value (or `undefined` when the example does not provide one).\n for (const [key, rawChildSchema] of objectEntries(schemaProperties)) {\n const keyStr = String(key)\n declaredKeys.add(keyStr)\n const childSchema = resolveSchemaWithAnnotations(rawChildSchema)\n const path = [...parentPath, keyStr]\n const exampleSubvalue = exampleByKey.get(keyStr)\n\n if (childSchema && isObjectSchema(childSchema) && childSchema.properties) {\n rows.push(...collectExampleRows(exampleSubvalue, childSchema, path))\n } else {\n rows.push({ path, value: exampleSubvalue })\n }\n }\n\n // Example-only properties at this level (preserve example order). Their inner shape is\n // not descended into — without a schema saying \"this is a nested object\" we have no\n // signal to flatten, so an object value becomes a single JSON-stringified row, matching\n // the schema-less fallback below.\n for (const [key, value] of exampleEntries) {\n const keyStr = String(key)\n if (declaredKeys.has(keyStr)) {\n continue\n }\n rows.push({ path: [...parentPath, keyStr], value })\n }\n\n return rows\n}\n\n/** Restore array values after text editing without parsing ordinary string fields. */\nexport const getFormBodyValue = (row: TableRow): string | File | unknown[] | undefined => {\n const value = coerceLeafValueToSchemaType(row.value, row.isArray ? { type: 'array' } : row.schema)\n return Array.isArray(value) ? value : (row.value ?? undefined)\n}\n\n/** Build the table rows for the form data, optionally enriched with schema (e.g. enum) per property */\nexport const getFormBodyRows = (\n example: ExampleObject | undefined | null,\n contentType: string,\n formBodySchema?: SchemaObject,\n compositionSelection?: Record<string, number>,\n encoding?: MediaTypeObject['encoding'],\n aspNetFormNaming = false,\n): TableRow[] => {\n // Forms use structured data even when the raw example also supplies wire text.\n const value = example?.dataValue !== undefined ? example.dataValue : example?.value\n // We only need the rows for formData\n if (!value || (contentType !== 'multipart/form-data' && contentType !== 'application/x-www-form-urlencoded')) {\n return []\n }\n\n // Get all the schema properties if the schema is an object schema\n const resolvedBodySchema = resolveFormSchema(formBodySchema, compositionSelection)\n const schemaWithProperties =\n resolvedBodySchema &&\n (isObjectSchema(resolvedBodySchema) ||\n 'properties' in resolvedBodySchema ||\n 'additionalProperties' in resolvedBodySchema)\n ? { ...resolvedBodySchema, type: 'object' as const }\n : undefined\n // The request builder preserves composed fields because members can make them required.\n // Keep those fields checked so the initial form matches the body that will be sent.\n const isComposed = Boolean(schemaWithProperties?.allOf || schemaWithProperties?.oneOf || schemaWithProperties?.anyOf)\n const requiredSet = schemaWithProperties ? new Set(schemaWithProperties.required ?? []) : undefined\n\n // Pre-compute the leaf-by-dotted-name index up front so both the array and the\n // schema-driven branches can pull each row's leaf schema and required flag without\n // re-walking the schema. Without this, edited rows lose the per-leaf `Required`\n // badge because a top-level `properties[name]` lookup misses dotted names.\n const leafByDottedName = new Map<string, LeafRow>()\n if (schemaWithProperties) {\n for (const leaf of collectLeafProperties(schemaWithProperties)) {\n leafByDottedName.set(leaf.path.join('.'), leaf)\n }\n }\n\n const mapRow = ({\n name,\n value,\n isDisabled,\n }: {\n name: string\n value: string | File\n isDisabled?: boolean\n }): TableRow => {\n const row: TableRow = {\n name,\n value,\n isDisabled: isDisabled ?? false,\n ...(encoding?.[name]?.contentType ? { contentType: encoding[name].contentType } : {}),\n }\n if (!schemaWithProperties || !name) {\n return row\n }\n // Prefer the pre-resolved leaf (handles dotted names like `props.name`); fall back\n // to a top-level property lookup so user-added rows keep working.\n const leaf = leafByDottedName.get(name)\n const propSchema =\n leaf?.schema ??\n resolveSchemaWithAnnotations(\n schemaWithProperties.properties?.[name] ??\n (typeof schemaWithProperties.additionalProperties === 'object'\n ? schemaWithProperties.additionalProperties\n : schemaWithProperties.additionalProperties === false\n ? undefined\n : { __scalar_: '' }),\n )\n row.schema = propSchema\n row.description = leaf?.description ?? propSchema?.description\n row.isRequired = leaf?.isRequired ?? requiredSet?.has(name) ?? false\n\n // Top-level optional properties default to disabled (unchecked), matching how optional\n // parameters behave. Scoped to top-level declared properties on purpose: the send side\n // (`build-request-body`) only drops top-level optional keys, so auto-disabling a nested\n // leaf (e.g. `props.name`) would leave it unchecked yet still transmitted. `Object.hasOwn`\n // (not `in`) keeps example-only keys named like `Object.prototype` members enabled. An\n // explicit `isDisabled` (from a stored form-row array) always wins.\n if (\n isDisabled === undefined &&\n !isComposed &&\n schemaWithProperties.properties &&\n Object.hasOwn(schemaWithProperties.properties, name)\n ) {\n row.isDisabled = !row.isRequired\n // Mark the row as disabled by default (no explicit `isDisabled` was stored) so typing a\n // value auto-enables it in `RequestTableRow`, matching how optional parameters behave. An\n // explicit `isDisabled` from a stored form-row array skips this branch and keeps winning.\n row.isDisabledByDefault = row.isDisabled\n }\n return row\n }\n\n const mapValue = (name: string, value: unknown, isDisabled?: boolean, isArray?: boolean): TableRow[] => {\n // Uploaded files must never pass through JSON.stringify, which discards their bytes.\n if (\n contentType === 'multipart/form-data' &&\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => item instanceof File)\n ) {\n return value.map((file) => mapRow({ name, value: file, isDisabled }))\n }\n const row = mapRow({\n name,\n value: value instanceof File || value == null ? (value ?? '') : stringifyValue(value),\n isDisabled,\n })\n if ((contentType === 'multipart/form-data' || aspNetFormNaming) && (Array.isArray(value) || isArray)) {\n // Example-only arrays also need their type to survive a form-table round trip.\n row.isArray = true\n }\n return [row]\n }\n\n if (aspNetFormNaming) {\n return getAspNetFormFields(value, schemaWithProperties, compositionSelection, true).flatMap((field) =>\n mapValue(field.name, field.value, field.isDisabled, field.isArray).map((row) => ({\n ...row,\n schema: field.schema ?? row.schema,\n description: field.schema?.description ?? row.description,\n isRequired: field.isRequired || row.isRequired,\n ...(field.isDisabledByDefault ? { isDisabledByDefault: true } : {}),\n })),\n )\n }\n\n // We have form data stored as an array\n if (Array.isArray(value)) {\n return value.flatMap((exampleValue) => {\n if (isObject(exampleValue)) {\n const name = String(exampleValue.name)\n const rows =\n contentType === 'multipart/form-data'\n ? mapValue(name, exampleValue.value, Boolean(exampleValue.isDisabled), exampleValue.isArray === true)\n : [\n mapRow({\n name,\n value: exampleValue.value instanceof File ? exampleValue.value : String(exampleValue.value),\n isDisabled: Boolean(exampleValue.isDisabled),\n }),\n ]\n // An untouched optional row stays eligible for auto-enabling after another row is edited.\n return rows.map((row) =>\n row.isDisabled && exampleValue.isDisabledByDefault === true ? { ...row, isDisabledByDefault: true } : row,\n )\n }\n return { name: '', value: exampleValue, isDisabled: false }\n })\n }\n\n // Schema-driven path: when the form body schema describes nested objects, emit one row\n // per leaf so users can edit individual fields. The dotted name (`props.name`) is folded\n // back into a single JSON multipart part by `build-request-body.ts` before the request is\n // sent. Gated to `multipart/form-data` because urlencoded has no regrouping step on send,\n // so dotted leaves would otherwise reach the wire as separate `props.name`-style fields.\n //\n // We walk the example alongside the schema so example-only properties (top-level extras\n // or undeclared keys inside a nested object) are still visible and editable instead of\n // being silently dropped to whatever the schema happens to declare.\n if (contentType === 'multipart/form-data' && schemaWithProperties && typeof value === 'object') {\n return collectExampleRows(value, schemaWithProperties).flatMap(({ path, value }) => mapValue(path.join('.'), value))\n }\n\n // We got an object try to convert it to an array of rows\n if (typeof value === 'object' && value) {\n return objectEntries(value).flatMap(([key, value]) =>\n contentType === 'multipart/form-data'\n ? mapValue(String(key), value)\n : mapRow({ name: String(key), value: stringifyValue(value) }),\n )\n }\n\n return []\n}\n"],"mappings":";;;;;;;AAcA,IAAa,kBAAkB,UAAmB;CAChD,IAAI,iBAAiB,MACnB,OAAO,MAAM;CAEf,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO,KAAK,UAAU,KAAK;CAE7B,OAAO,OAAO,KAAK;AACrB;;;;;;;;;AAiBA,IAAa,yBACX,QACA,aAAuB,CAAC,G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/components/AddressBar.vue"],"names":[],"mappings":"AAowBA,OAAO,KAAK,EAEV,UAAU,EACV,iBAAiB,EAClB,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAqBhG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAA0B,EAAE,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAGzE;;;;GAIG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAKzC,MAAM,MAAM,eAAe,GAAG;IAC5B,8DAA8D;IAC9D,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,gEAAgE;IAChE,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,4BAA4B;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAA;IAClB,gCAAgC;IAChC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,mDAAmD;IACnD,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,8BAA8B;IAC9B,OAAO,EAAE,OAAO,EAAE,CAAA;IAClB,oBAAoB;IACpB,MAAM,EAAE,YAAY,CAAA;IACpB,gBAAgB;IAChB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,kBAAkB;IAClB,WAAW,EAAE,kBAAkB,CAAA;IAC/B,sCAAsC;IACtC,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AACD,QAAA,MAAM,YAAY;;;;;eAwB6B,MAAM;;;;;;;eAAN,MAAM;;;;;kFAihCjD,CAAC"}
1
+ {"version":3,"file":"AddressBar.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-address-bar-block/components/AddressBar.vue"],"names":[],"mappings":"AAywBA,OAAO,KAAK,EAEV,UAAU,EACV,iBAAiB,EAClB,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAqBhG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAA0B,EAAE,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAGzE;;;;GAIG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAKzC,MAAM,MAAM,eAAe,GAAG;IAC5B,8DAA8D;IAC9D,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,gEAAgE;IAChE,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,4BAA4B;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAA;IAClB,gCAAgC;IAChC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,mDAAmD;IACnD,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,8BAA8B;IAC9B,OAAO,EAAE,OAAO,EAAE,CAAA;IAClB,oBAAoB;IACpB,MAAM,EAAE,YAAY,CAAA;IACpB,gBAAgB;IAChB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,kBAAkB;IAClB,WAAW,EAAE,kBAAkB,CAAA;IAC/B,sCAAsC;IACtC,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AACD,QAAA,MAAM,YAAY;;;;;eAwB6B,MAAM;;;;;;;eAAN,MAAM;;;;;kFAohCjD,CAAC"}
@@ -2,7 +2,7 @@ import AddressBar_vue_vue_type_script_setup_true_lang_default from "./AddressBar
2
2
  /* empty css */
3
3
  import _plugin_vue_export_helper_default from "../../../../_virtual/_plugin-vue_export-helper.js";
4
4
  // src/v2/blocks/scalar-address-bar-block/components/AddressBar.vue
5
- var AddressBar_default = /*#__PURE__*/ _plugin_vue_export_helper_default(AddressBar_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-b5b0a654"]]);
5
+ var AddressBar_default = /*#__PURE__*/ _plugin_vue_export_helper_default(AddressBar_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-7abeb15f"]]);
6
6
  export { AddressBar_default as default };
7
7
 
8
8
  //# sourceMappingURL=AddressBar.vue.js.map
@@ -17,6 +17,7 @@ import { EditorView } from "@scalar/use-codemirror";
17
17
  import { ScalarTooltip } from "@scalar/components/tooltip";
18
18
  import { getSelector } from "@scalar/helpers/dom/get-selector";
19
19
  import { extractServerFromPath } from "@scalar/helpers/url/extract-server-from-path";
20
+ import { useDocumentRoot } from "@scalar/use-hooks/useDocumentRoot";
20
21
  // src/v2/blocks/scalar-address-bar-block/components/AddressBar.vue?vue&type=script&setup=true&lang.ts
21
22
  var _hoisted_1 = { class: "order-last flex h-auto w-full max-w-3xl grow-3 flex-wrap items-stretch [--scalar-address-bar-height:32px] @3xl:order-0 @3xl:flex-nowrap" };
22
23
  var _hoisted_2 = ["id"];
@@ -76,6 +77,8 @@ var AddressBar_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
76
77
  setup(__props, { expose: __expose, emit: __emit }) {
77
78
  const emit = __emit;
78
79
  const { translate } = useLocalization();
80
+ /** Where the blur target is looked up again, the shadow root when the client is embedded in one */
81
+ const documentRoot = useDocumentRoot();
79
82
  const id = useId();
80
83
  const sendButtonRef = useTemplateRef("sendButtonRef");
81
84
  const mobileSendButtonRef = useTemplateRef("mobileSendButtonRef");
@@ -167,7 +170,7 @@ var AddressBar_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
167
170
  emit("update:webhook-url", webhookUrl);
168
171
  methodConflict.value = null;
169
172
  pathConflict.value = null;
170
- nextTick(() => refocusBlurTarget(blurTargetSelector));
173
+ nextTick(() => refocusBlurTarget(blurTargetSelector, documentRoot));
171
174
  return;
172
175
  }
173
176
  const extractedPath = extractAndSelectServer(targetPath);
@@ -194,7 +197,7 @@ var AddressBar_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
194
197
  }
195
198
  const mirrorContent = addressBarRef.value?.codeMirrorRef?.textContent;
196
199
  if (status === "no-change" && mirrorContent && mirrorContent !== extractedPath) addressBarRef.value?.setCodeMirrorContent(extractedPath);
197
- nextTick(() => refocusBlurTarget(returnedSelector));
200
+ nextTick(() => refocusBlurTarget(returnedSelector, documentRoot));
198
201
  }
199
202
  });
200
203
  };
@@ -1 +1 @@
1
- {"version":3,"file":"AddressBar.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_unref","_normalizeClass","_normalizeStyle","_createVNode","HttpMethod","_createBlock","ServerDropdown","CodeInput","_withKeys","_withCtx","_toDisplayString","AddressBarHistory"],"sources":["../../../../../src/v2/blocks/scalar-address-bar-block/components/AddressBar.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * AddressBar component\n * This component is used to display the address bar for the operation block\n * It is used to display the path, method, server, and history for the operation\n */\nexport default {\n name: 'AddressBar',\n}\nexport type AddressBarProps = {\n /** An external example must finish loading before sending. */\n executionDisabled?: boolean\n /** Current request path */\n path: string\n /** Current request method */\n method: string\n /** Whether the request target belongs to an OpenAPI webhook. */\n isWebhook?: boolean\n /** Openapi document slug */\n documentSlug: string\n /** Currently selected example key for the current operation */\n exampleKey: string\n /** Currently selected server */\n server: ServerObject | null\n /** Server list available for operation/document */\n servers: ServerObject[]\n /** List of request history */\n history: History[]\n /** Client layout */\n layout: ClientLayout\n /** Event bus */\n eventBus: WorkspaceEventBus\n /** Environment */\n environment: XScalarEnvironment\n /** Meta information for the server */\n serverMeta: ServerMeta\n}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarTooltip } from '@scalar/components/tooltip'\nimport { getSelector } from '@scalar/helpers/dom/get-selector'\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport { extractServerFromPath } from '@scalar/helpers/url/extract-server-from-path'\nimport {\n ScalarIconArrowSquareOut,\n ScalarIconCopy,\n ScalarIconWarningCircle,\n} from '@scalar/icons'\nimport { EditorView } from '@scalar/use-codemirror'\nimport type {\n ApiReferenceEvents,\n ServerMeta,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n useId,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { HttpMethod } from '@/components/HttpMethod'\nimport { getOperationExampleKey } from '@/v2/blocks/operation-block/helpers/response-cache'\nimport { isPlaceholderPath } from '@/v2/blocks/scalar-address-bar-block/helpers/is-placeholder-path'\nimport { refocusBlurTarget } from '@/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target'\nimport { useLoadingAnimation } from '@/v2/blocks/scalar-address-bar-block/hooks/use-loading-animation'\nimport { usePathMasking } from '@/v2/blocks/scalar-address-bar-block/hooks/use-path-masking'\nimport { CodeInput } from '@/v2/components/code-input'\nimport { ServerDropdown } from '@/v2/components/server'\nimport { useLocalization } from '@/v2/features/localization'\nimport type { ClientLayout } from '@/v2/types/layout'\n\nimport AddressBarHistory, { type History } from './AddressBarHistory.vue'\n\nconst {\n path,\n method,\n layout,\n eventBus,\n exampleKey,\n documentSlug,\n server,\n servers,\n environment,\n serverMeta,\n isWebhook = false,\n executionDisabled = false,\n} = defineProps<AddressBarProps>()\n\nconst emit = defineEmits<{\n /** Open the GET destination using browser navigation. */\n (e: 'open:browser'): void\n /** Execute the current operation example */\n (e: 'execute'): void\n /** Select a request history item by index */\n (e: 'select:history:item', payload: { index: number }): void\n /** Update the full destination URL used to deliver a webhook. */\n (e: 'update:webhook-url', url: string): void\n}>()\n\nconst { translate } = useLocalization()\n\n// ───────────────────────────────────────────────────────────────────\n// Template refs & reactive state\n// ───────────────────────────────────────────────────────────────────\n\nconst id = useId()\nconst sendButtonRef = useTemplateRef('sendButtonRef')\nconst mobileSendButtonRef = useTemplateRef('mobileSendButtonRef')\nconst addressBarRef = useTemplateRef('addressBarRef')\n\nconst { percentage, startLoading, stopLoading, isLoading } =\n useLoadingAnimation()\n\nconst pathConflict = ref<string | null>(null)\nconst methodConflict = ref<string | null>(null)\nconst tabbedOut = ref(false)\nconst isServerDropdownOpen = ref(false)\nconst isHistoryDropdownOpen = ref(false)\n\n// ───────────────────────────────────────────────────────────────────\n// Derived state\n// ───────────────────────────────────────────────────────────────────\n\n/** Keeps the cursor visible past the fade-right overlay while typing */\nconst addressBarScrollMargins = EditorView.scrollMargins.of(() => ({\n right: 24,\n}))\n\n/** Animated background transform for the loading indicator */\nconst style = computed(() => ({\n backgroundColor: `color-mix(in srgb, transparent 90%, ${getHttpMethodInfo(method).colorVar})`,\n transform: `translate3d(-${percentage.value}%,0,0)`,\n}))\n\n/** Whether there is a path or method conflict */\nconst hasConflict = computed(() => methodConflict.value || pathConflict.value)\n\n/**\n * Placeholder for the path field.\n *\n * Webhooks have no server to prefix the path, so the field doubles as the full\n * destination URL. Hint that a complete URL (including the host) is expected,\n * rather than a bare path.\n */\nconst pathPlaceholder = computed(() => {\n if (server) {\n return ''\n }\n return isWebhook\n ? translate('apiClient.addressBar.webhookUrlPlaceholder')\n : translate('apiClient.addressBar.urlPlaceholder')\n})\n\n/** Whether either dropdown (server or history) is open */\nconst isDropdownOpen = computed(\n () => isServerDropdownOpen.value || isHistoryDropdownOpen.value,\n)\n\n/** Uniquely identifies the currently selected operation + example */\nconst uniqueKey = computed(() =>\n getOperationExampleKey(method, path, exampleKey, documentSlug),\n)\n\n/** Clear conflict state when switching to a different operation */\nwatch(uniqueKey, () => {\n pathConflict.value = null\n methodConflict.value = null\n})\n\n// ───────────────────────────────────────────────────────────────────\n// Focus helpers\n// ───────────────────────────────────────────────────────────────────\n\nconst handleFocusSendButton = (): void => {\n const desktop = sendButtonRef.value?.$el\n const mobile = mobileSendButtonRef.value?.$el\n\n // Focus whichever send button is currently visible\n if (desktop && desktop.offsetParent !== null) {\n desktop.focus()\n } else {\n mobile?.focus()\n }\n}\n\nconst handleFocusAddressBar = (\n payload: ApiReferenceEvents['ui:focus:address-bar'],\n): void => {\n // On non-desktop layouts, if already focused we let the browser handle the\n // native behavior (e.g. selecting the browser's own address bar).\n if (addressBarRef.value?.isFocused && layout !== 'desktop') {\n return\n }\n\n addressBarRef.value?.focus('end')\n\n if (payload && 'clear' in payload && payload.clear) {\n addressBarRef.value?.setCodeMirrorContent('')\n }\n\n if (payload && 'event' in payload) {\n payload.event.preventDefault()\n }\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Path masking\n//\n// Drafts on `/` and auto-generated `/_scalar_temp...` paths are internal\n// placeholders — the address bar focuses and clears on mount and on\n// navigation so the user sees a blank prompt instead of the internal\n// path. The deferred mask only clears when CodeMirror still contains that\n// placeholder path, so a user edit that lands before the frame is preserved.\n// ───────────────────────────────────────────────────────────────────\n\nusePathMasking({\n isReady: () => addressBarRef.value?.codeMirror,\n operationKey: () => uniqueKey.value,\n shouldMask: () => isPlaceholderPath(path, documentSlug),\n // Defer to the next frame so focus() runs after click-handler side\n // effects that move focus (e.g. a dropdown refocusing its trigger),\n // which would otherwise blur our input and emit a spurious path\n // update against the now-empty value.\n onMask: () =>\n requestAnimationFrame(() => {\n const editorContent =\n addressBarRef.value?.codeMirror?.state.doc.toString()\n\n if (editorContent && editorContent !== path) {\n return\n }\n\n handleFocusAddressBar({ clear: true })\n }),\n})\n\n// ───────────────────────────────────────────────────────────────────\n// Server extraction\n// ───────────────────────────────────────────────────────────────────\n\n/** If the path contains a server URL, extract it and select or add that server */\nconst extractAndSelectServer = (targetPath: string): string => {\n const extracted = extractServerFromPath(targetPath)\n if (!extracted) {\n return targetPath\n }\n\n const [url, remainingPath] = extracted\n\n // Server is already selected — nothing to do\n if (url === server?.url) {\n return remainingPath\n }\n\n const matchingServer = servers.find((s) => s.url === url)\n if (matchingServer) {\n eventBus.emit('server:update:selected', { url, meta: serverMeta })\n } else {\n eventBus.emit('server:add:server', {\n url,\n select: true,\n meta: { type: 'operation', path, method },\n })\n }\n\n return remainingPath\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Path / method updates\n// ───────────────────────────────────────────────────────────────────\n\nconst normalizePath = (value: string): string =>\n value.startsWith('/') ? value : `/${value}`\n\n/** Emit a path/method update and reconcile conflicts + cursor state on the result */\nconst emitPathMethodUpdate = (\n targetMethod: string,\n targetPath: string,\n blurTargetSelector: string | null = null,\n): void => {\n if (isWebhook) {\n // A webhook has no OpenAPI server, so the field holds the full destination\n // URL. Keep exactly what the user entered — do not split it into an invisible\n // server plus a leftover path, and do not force a leading slash. That split\n // is what made a typed URL collapse to a stray \"/\" on blur.\n const webhookUrl = targetPath.trim()\n addressBarRef.value?.setCodeMirrorContent(webhookUrl)\n emit('update:webhook-url', webhookUrl)\n methodConflict.value = null\n pathConflict.value = null\n nextTick(() => refocusBlurTarget(blurTargetSelector))\n return\n }\n\n const extractedPath = extractAndSelectServer(targetPath)\n const normalizedPath = normalizePath(extractedPath)\n\n // Keep CodeMirror in sync so a conflict does not leave a stale value on screen\n addressBarRef.value?.setCodeMirrorContent(normalizedPath)\n\n eventBus.emit('operation:update:pathMethod', {\n meta: { method, path },\n blurTargetSelector,\n payload: { method: targetMethod, path: normalizedPath },\n callback: (status, returnedSelector) => {\n if (status === 'success' || status === 'no-change') {\n methodConflict.value = null\n pathConflict.value = null\n } else if (status === 'conflict') {\n if (targetMethod !== method) {\n methodConflict.value = targetMethod\n }\n if (normalizedPath !== path) {\n pathConflict.value = normalizedPath\n }\n\n return\n }\n\n // Edge case: pasting a full URL extracts the server but leaves the path\n // unchanged. CodeMirror still shows the full URL, so force it back to\n // just the path.\n const mirrorContent = addressBarRef.value?.codeMirrorRef?.textContent\n if (\n status === 'no-change' &&\n mirrorContent &&\n mirrorContent !== extractedPath\n ) {\n addressBarRef.value?.setCodeMirrorContent(extractedPath)\n }\n\n nextTick(() => refocusBlurTarget(returnedSelector))\n },\n })\n}\n\n/** Change the operation's method, preferring the conflicting path if present */\nconst handleMethodChange = (newMethod: string): void =>\n emitPathMethodUpdate(newMethod, pathConflict.value ?? path)\n\n/**\n * Save the path on blur and replay the click that caused the blur (so e.g. a\n * click on the Send button still fires after the async update resolves).\n *\n * Tab-outs do not replay — tabbing to a button should not trigger its click\n * (`tabbedOut` is set on `@keydown.tab`).\n *\n * Programmatic focus moves also do not replay. On first navigation into a\n * draft operation, `usePathMasking` focuses and clears the address bar while\n * `ScalarSidebarNestedItems` focuses the drilled-in Back button in\n * `nextTick`. That steals focus from CodeMirror, fires blur with a\n * `relatedTarget` (the Back button), and without a guard we would treat it\n * like a user click: capture the selector, then `refocusBlurTarget` would\n * synthesize `.click()` on Back and navigate away.\n *\n * `FocusEvent.sourceCapabilities` is null when no input device caused the\n * focus change (e.g. `element.focus()`). A real pointer click sets it on the\n * blur that precedes the click, so we still replay Send and other buttons.\n */\nconst handlePathBlur = (newPath: string, event: FocusEvent): void => {\n const relatedTarget =\n event.relatedTarget instanceof Element ? event.relatedTarget : null\n const blurTargetSelector =\n tabbedOut.value ||\n ('sourceCapabilities' in event && event.sourceCapabilities === null)\n ? null\n : getSelector(relatedTarget)\n tabbedOut.value = false\n\n emitPathMethodUpdate(\n methodConflict.value ?? method,\n newPath,\n blurTargetSelector,\n )\n}\n\n/** Save the path on Enter and trigger the Send button after the update resolves */\nconst handlePathSubmit = (\n newPath: string,\n event: KeyboardEvent | FocusEvent,\n): void => {\n // Prevent the global hotkey listener from also handling this Enter press\n event.stopPropagation()\n\n emitPathMethodUpdate(\n methodConflict.value ?? method,\n newPath,\n '[data-addressbar-action=\"send\"]',\n )\n}\n\n/** Unset the server when backspace is pressed on an empty path */\nconst handlePathBackspace = (event: KeyboardEvent): void => {\n if (event.target instanceof HTMLElement && event.target.innerText === '\\n') {\n // A webhook has no server to unset; its full URL lives in the field itself.\n if (isWebhook) {\n return\n }\n eventBus.emit('server:update:selected', { url: '', meta: serverMeta })\n }\n}\n\nconst handleServerSelect = (\n payload: ApiReferenceEvents['server:update:selected'],\n): void => {\n eventBus.emit('server:update:selected', payload)\n}\n\nconst handleServerVariable = (\n payload: ApiReferenceEvents['server:update:variables'],\n): void => {\n eventBus.emit('server:update:variables', payload)\n}\n\nconst isGetRequest = computed(() => method.toLowerCase() === 'get')\nconst isOpenInBrowserDisabled = computed(\n () => executionDisabled || !!hasConflict.value,\n)\n\nconst requestOpenInBrowser = (): void => {\n if (isOpenInBrowserDisabled.value) return\n emit('open:browser')\n}\n\n/** Address bar copy is handled in OperationBlock (same URL as Send). */\nconst requestCopyUrl = (): void => {\n eventBus.emit('copy-url:address-bar')\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Navigation\n// ───────────────────────────────────────────────────────────────────\n\nconst navigateToServersPage = (): void => {\n if (serverMeta.type === 'operation') {\n eventBus.emit('ui:navigate', {\n page: 'operation',\n path: 'servers',\n operationPath: serverMeta.path,\n method: serverMeta.method,\n })\n return\n }\n\n eventBus.emit('ui:navigate', { page: 'document', path: 'servers' })\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Lifecycle\n// ───────────────────────────────────────────────────────────────────\n\nconst unsubscribes: Array<() => void> = []\n\nonMounted(() => {\n unsubscribes.push(\n eventBus.on('ui:focus:address-bar', handleFocusAddressBar),\n eventBus.on('ui:focus:send-button', handleFocusSendButton),\n eventBus.on('hooks:on:request:sent', startLoading),\n eventBus.on('hooks:on:request:complete', stopLoading),\n )\n})\n\nonBeforeUnmount(() => {\n for (const unsubscribe of unsubscribes) {\n unsubscribe()\n }\n\n // Prevents the loading animation from continuing after unmount\n stopLoading()\n})\n\ndefineExpose({\n methodConflict,\n pathConflict,\n})\n</script>\n<template>\n <!--\n Address bar.\n\n The wide-container layout is a single row:\n `[Method | URL | Copy | History | Send]`. When the surrounding\n `@container` drops below `@3xl` only the send button moves to a\n second row, where it spans the full width. The method and copy\n controls stay inside the bar at every width so they keep belonging\n to the URL they act on rather than floating beside it.\n -->\n <div\n class=\"order-last flex h-auto w-full max-w-3xl grow-3 flex-wrap items-stretch [--scalar-address-bar-height:32px] @3xl:order-0 @3xl:flex-nowrap\">\n <!-- Address Bar -->\n <div\n :id=\"id\"\n class=\"address-bar-bg-states text-xxs group relative flex h-(--scalar-address-bar-height) w-full flex-1 flex-row items-stretch rounded-lg p-0.75\"\n :class=\"{\n 'outline-c-danger outline': hasConflict,\n 'rounded-b-none': isDropdownOpen,\n }\">\n <div\n class=\"pointer-events-none absolute top-0 left-0 block h-full w-full overflow-hidden rounded-lg border\"\n :class=\"{\n 'rounded-b-none': isDropdownOpen,\n }\">\n <div\n class=\"absolute top-0 left-0 h-full w-full\"\n :style />\n </div>\n\n <!-- Only Send leaves the bar below `@3xl`; see the trailing row. -->\n <div class=\"flex\">\n <HttpMethod\n :isEditable=\"layout !== 'modal' && !isWebhook\"\n isSquare\n :method=\"methodConflict ?? method\"\n teleport\n @change=\"handleMethodChange\" />\n </div>\n\n <div\n class=\"scroll-timeline-x scroll-timeline-x-hidden relative flex w-full bg-blend-normal\"\n dir=\"ltr\">\n <!-- Servers -->\n <ServerDropdown\n v-if=\"servers.length\"\n :layout=\"isWebhook ? 'modal' : layout\"\n :meta=\"serverMeta\"\n :server=\"server\"\n :servers=\"servers\"\n :target=\"id\"\n @update:open=\"(value) => (isServerDropdownOpen = value)\"\n @update:selectedServer=\"handleServerSelect\"\n @update:servers=\"navigateToServersPage\"\n @update:variable=\"handleServerVariable\" />\n\n <!-- Path + URL + env vars -->\n <CodeInput\n ref=\"addressBarRef\"\n alwaysEmitChange\n :aria-label=\"translate('apiClient.addressBar.path')\"\n class=\"ml-1 min-w-fit pl-px outline-none\"\n disableCloseBrackets\n :disabled=\"layout === 'modal' && !isWebhook\"\n disableEnter\n disableTabIndent\n :emitOnBlur=\"false\"\n :environment=\"environment\"\n :extensions=\"[addressBarScrollMargins]\"\n importCurl\n :layout=\"layout\"\n :modelValue=\"path\"\n :placeholder=\"pathPlaceholder\"\n server\n @blur=\"handlePathBlur\"\n @keydown.delete=\"handlePathBackspace\"\n @keydown.tab=\"tabbedOut = true\"\n @submit=\"handlePathSubmit\" />\n </div>\n\n <!-- Copy url button -->\n <ScalarButton\n class=\"hover:bg-b-3 mx-1 flex\"\n size=\"xs\"\n variant=\"ghost\"\n @click=\"requestCopyUrl\">\n <ScalarIconCopy />\n <span class=\"sr-only\">{{\n translate('apiClient.addressBar.copyUrl')\n }}</span>\n </ScalarButton>\n\n <ScalarTooltip\n v-if=\"isGetRequest\"\n :content=\"translate('apiClient.addressBar.openInBrowserHint')\">\n <ScalarButton\n :aria-label=\"translate('apiClient.addressBar.openInBrowser')\"\n class=\"hover:bg-b-3 mr-1 flex\"\n :disabled=\"isOpenInBrowserDisabled\"\n size=\"xs\"\n variant=\"ghost\"\n @click=\"requestOpenInBrowser\">\n <ScalarIconArrowSquareOut />\n </ScalarButton>\n </ScalarTooltip>\n\n <AddressBarHistory\n :history=\"history\"\n :target=\"id\"\n @select:history:item=\"(payload) => emit('select:history:item', payload)\"\n @update:open=\"(value) => (isHistoryDropdownOpen = value)\" />\n <!-- Error message -->\n <div\n v-if=\"hasConflict\"\n class=\"z-context absolute inset-x-0 top-[calc(100%+4px)] flex flex-col items-center rounded px-6\">\n <div\n class=\"text-c-danger bg-b-danger border-c-danger flex items-center gap-1 rounded border p-1\">\n <ScalarIconWarningCircle size=\"sm\" />\n <div class=\"min-w-0 flex-1\">\n {{\n translate('apiClient.addressBar.duplicateRequest', {\n method: (methodConflict ?? method).toUpperCase(),\n path: pathConflict ?? path,\n })\n }}\n </div>\n </div>\n </div>\n\n <ScalarButton\n ref=\"sendButtonRef\"\n class=\"relative hidden h-auto shrink-0 overflow-hidden py-1 pr-2.5 pl-2 font-bold @3xl:flex\"\n data-addressbar-action=\"send\"\n :disabled=\"isLoading || executionDisabled\"\n @click=\"emit('execute')\">\n <span\n aria-hidden=\"true\"\n class=\"inline-flex items-center gap-1\">\n <ScalarIcon\n class=\"relative shrink-0 fill-current\"\n icon=\"Play\"\n size=\"xs\" />\n <span class=\"text-xxs flex\">{{\n translate('apiClient.addressBar.send')\n }}</span>\n </span>\n <span class=\"sr-only\"\n >{{\n translate('apiClient.addressBar.sendRequest', {\n method,\n url: `${server?.url ?? ''}${path}`,\n })\n }}\n </span>\n </ScalarButton>\n </div>\n\n <!--\n Below `@3xl` the send button moves out of the bar onto its own row\n and spans the full width, so the primary action stays easy to hit\n once the container is too narrow to hold it beside the URL.\n -->\n <ScalarButton\n ref=\"mobileSendButtonRef\"\n class=\"relative mt-2 h-(--scalar-address-bar-height) w-full shrink-0 justify-center overflow-hidden py-1 font-bold @3xl:hidden\"\n data-addressbar-action=\"send\"\n :disabled=\"isLoading || executionDisabled\"\n @click=\"emit('execute')\">\n <span\n aria-hidden=\"true\"\n class=\"inline-flex items-center gap-1\">\n <ScalarIcon\n class=\"relative shrink-0 fill-current\"\n icon=\"Play\"\n size=\"xs\" />\n <span class=\"text-xxs\">{{\n translate('apiClient.addressBar.send')\n }}</span>\n </span>\n <span class=\"sr-only\"\n >{{\n translate('apiClient.addressBar.sendRequest', {\n method,\n url: `${server?.url ?? ''}${path}`,\n })\n }}\n </span>\n </ScalarButton>\n </div>\n</template>\n<style scoped>\n:deep(.cm-editor) {\n height: 100%;\n outline: none;\n width: 100%;\n}\n:deep(.cm-line) {\n padding: 0;\n}\n:deep(.cm-content) {\n padding: 0;\n display: flex;\n align-items: center;\n font-size: var(--scalar-small);\n}\n.scroll-timeline-x {\n -ms-overflow-style: none;\n /* Fade the URL at the viewport edges. Mask lives on the scrollport (this\n element) rather than on `.cm-scroller`, whose width follows the URL's\n full content and pushes the right edge off-screen when overflowing. */\n mask-image: linear-gradient(\n to right,\n transparent 0,\n black 6px,\n black calc(100% - 24px),\n transparent 100%\n );\n}\n.scroll-timeline-x-hidden {\n overflow-x: auto;\n}\n.scroll-timeline-x-hidden :deep(.cm-scroller) {\n scrollbar-width: none;\n -ms-overflow-style: none;\n padding-right: 20px;\n overflow: auto;\n}\n.scroll-timeline-x-hidden::-webkit-scrollbar {\n width: 0;\n height: 0;\n display: none;\n}\n.scroll-timeline-x-hidden :deep(.cm-scroller::-webkit-scrollbar) {\n width: 0;\n height: 0;\n display: none;\n}\n.scroll-timeline-x-address {\n line-height: 27px;\n scrollbar-width: none; /* Firefox */\n}\n/* make clickable are to left of send button */\n.scroll-timeline-x-address:after {\n content: '';\n position: absolute;\n height: 100%;\n width: 24px;\n right: 0;\n cursor: text;\n}\n\n.address-bar-bg-states {\n --scalar-address-bar-bg: color-mix(\n in srgb,\n var(--scalar-background-1),\n var(--scalar-background-2)\n );\n background: var(--scalar-address-bar-bg);\n}\n.address-bar-bg-states:has(.cm-focused) {\n --scalar-address-bar-bg: var(--scalar-background-1);\n border-color: var(--scalar-border-color);\n outline-width: 1px;\n outline-style: solid;\n}\n.address-bar-bg-states:has(.cm-focused) .fade-left,\n.address-bar-bg-states:has(.cm-focused) .fade-right {\n --scalar-address-bar-bg: var(--scalar-background-1);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0FR,MAAM,OAAO;EAWb,MAAM,EAAE,cAAc,gBAAgB;EAMtC,MAAM,KAAK,MAAM;EACjB,MAAM,gBAAgB,eAAe,eAAe;EACpD,MAAM,sBAAsB,eAAe,qBAAqB;EAChE,MAAM,gBAAgB,eAAe,eAAe;EAEpD,MAAM,EAAE,YAAY,cAAc,aAAa,cAC7C,oBAAoB;EAEtB,MAAM,eAAe,IAAmB,IAAI;EAC5C,MAAM,iBAAiB,IAAmB,IAAI;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B,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,SAAA;;IACZ,SAAAS,cAUO,CAVPV,mBAUO,QAVP,aAUO,CAPLI,YAGcH,MAAA,UAAA,GAAA;KAFZ,OAAM;KACN,MAAK;KACL,MAAK;I,IACPD,mBAES,QAFT,aAESW,gBADPV,MAAA,SAAA,CAAS,CAAA,2BAAA,CAAA,GAAA,CAAA,C,IAGbD,mBAOO,QAPP,aAOOW,gBALHV,MAAA,SAAA,CAAS,CAAA,oCAAA;KAAmD,QAAA,QAAA;KAA4B,KAAA,GAAA,QAAA,QAAQ,OAAG,KAAS,QAAA"}
1
+ {"version":3,"file":"AddressBar.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_unref","_normalizeClass","_normalizeStyle","_createVNode","HttpMethod","_createBlock","ServerDropdown","CodeInput","_withKeys","_withCtx","_toDisplayString","AddressBarHistory"],"sources":["../../../../../src/v2/blocks/scalar-address-bar-block/components/AddressBar.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * AddressBar component\n * This component is used to display the address bar for the operation block\n * It is used to display the path, method, server, and history for the operation\n */\nexport default {\n name: 'AddressBar',\n}\nexport type AddressBarProps = {\n /** An external example must finish loading before sending. */\n executionDisabled?: boolean\n /** Current request path */\n path: string\n /** Current request method */\n method: string\n /** Whether the request target belongs to an OpenAPI webhook. */\n isWebhook?: boolean\n /** Openapi document slug */\n documentSlug: string\n /** Currently selected example key for the current operation */\n exampleKey: string\n /** Currently selected server */\n server: ServerObject | null\n /** Server list available for operation/document */\n servers: ServerObject[]\n /** List of request history */\n history: History[]\n /** Client layout */\n layout: ClientLayout\n /** Event bus */\n eventBus: WorkspaceEventBus\n /** Environment */\n environment: XScalarEnvironment\n /** Meta information for the server */\n serverMeta: ServerMeta\n}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarTooltip } from '@scalar/components/tooltip'\nimport { getSelector } from '@scalar/helpers/dom/get-selector'\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport { extractServerFromPath } from '@scalar/helpers/url/extract-server-from-path'\nimport {\n ScalarIconArrowSquareOut,\n ScalarIconCopy,\n ScalarIconWarningCircle,\n} from '@scalar/icons'\nimport { EditorView } from '@scalar/use-codemirror'\nimport { useDocumentRoot } from '@scalar/use-hooks/useDocumentRoot'\nimport type {\n ApiReferenceEvents,\n ServerMeta,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n useId,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { HttpMethod } from '@/components/HttpMethod'\nimport { getOperationExampleKey } from '@/v2/blocks/operation-block/helpers/response-cache'\nimport { isPlaceholderPath } from '@/v2/blocks/scalar-address-bar-block/helpers/is-placeholder-path'\nimport { refocusBlurTarget } from '@/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target'\nimport { useLoadingAnimation } from '@/v2/blocks/scalar-address-bar-block/hooks/use-loading-animation'\nimport { usePathMasking } from '@/v2/blocks/scalar-address-bar-block/hooks/use-path-masking'\nimport { CodeInput } from '@/v2/components/code-input'\nimport { ServerDropdown } from '@/v2/components/server'\nimport { useLocalization } from '@/v2/features/localization'\nimport type { ClientLayout } from '@/v2/types/layout'\n\nimport AddressBarHistory, { type History } from './AddressBarHistory.vue'\n\nconst {\n path,\n method,\n layout,\n eventBus,\n exampleKey,\n documentSlug,\n server,\n servers,\n environment,\n serverMeta,\n isWebhook = false,\n executionDisabled = false,\n} = defineProps<AddressBarProps>()\n\nconst emit = defineEmits<{\n /** Open the GET destination using browser navigation. */\n (e: 'open:browser'): void\n /** Execute the current operation example */\n (e: 'execute'): void\n /** Select a request history item by index */\n (e: 'select:history:item', payload: { index: number }): void\n /** Update the full destination URL used to deliver a webhook. */\n (e: 'update:webhook-url', url: string): void\n}>()\n\nconst { translate } = useLocalization()\n\n/** Where the blur target is looked up again, the shadow root when the client is embedded in one */\nconst documentRoot = useDocumentRoot()\n\n// ───────────────────────────────────────────────────────────────────\n// Template refs & reactive state\n// ───────────────────────────────────────────────────────────────────\n\nconst id = useId()\nconst sendButtonRef = useTemplateRef('sendButtonRef')\nconst mobileSendButtonRef = useTemplateRef('mobileSendButtonRef')\nconst addressBarRef = useTemplateRef('addressBarRef')\n\nconst { percentage, startLoading, stopLoading, isLoading } =\n useLoadingAnimation()\n\nconst pathConflict = ref<string | null>(null)\nconst methodConflict = ref<string | null>(null)\nconst tabbedOut = ref(false)\nconst isServerDropdownOpen = ref(false)\nconst isHistoryDropdownOpen = ref(false)\n\n// ───────────────────────────────────────────────────────────────────\n// Derived state\n// ───────────────────────────────────────────────────────────────────\n\n/** Keeps the cursor visible past the fade-right overlay while typing */\nconst addressBarScrollMargins = EditorView.scrollMargins.of(() => ({\n right: 24,\n}))\n\n/** Animated background transform for the loading indicator */\nconst style = computed(() => ({\n backgroundColor: `color-mix(in srgb, transparent 90%, ${getHttpMethodInfo(method).colorVar})`,\n transform: `translate3d(-${percentage.value}%,0,0)`,\n}))\n\n/** Whether there is a path or method conflict */\nconst hasConflict = computed(() => methodConflict.value || pathConflict.value)\n\n/**\n * Placeholder for the path field.\n *\n * Webhooks have no server to prefix the path, so the field doubles as the full\n * destination URL. Hint that a complete URL (including the host) is expected,\n * rather than a bare path.\n */\nconst pathPlaceholder = computed(() => {\n if (server) {\n return ''\n }\n return isWebhook\n ? translate('apiClient.addressBar.webhookUrlPlaceholder')\n : translate('apiClient.addressBar.urlPlaceholder')\n})\n\n/** Whether either dropdown (server or history) is open */\nconst isDropdownOpen = computed(\n () => isServerDropdownOpen.value || isHistoryDropdownOpen.value,\n)\n\n/** Uniquely identifies the currently selected operation + example */\nconst uniqueKey = computed(() =>\n getOperationExampleKey(method, path, exampleKey, documentSlug),\n)\n\n/** Clear conflict state when switching to a different operation */\nwatch(uniqueKey, () => {\n pathConflict.value = null\n methodConflict.value = null\n})\n\n// ───────────────────────────────────────────────────────────────────\n// Focus helpers\n// ───────────────────────────────────────────────────────────────────\n\nconst handleFocusSendButton = (): void => {\n const desktop = sendButtonRef.value?.$el\n const mobile = mobileSendButtonRef.value?.$el\n\n // Focus whichever send button is currently visible\n if (desktop && desktop.offsetParent !== null) {\n desktop.focus()\n } else {\n mobile?.focus()\n }\n}\n\nconst handleFocusAddressBar = (\n payload: ApiReferenceEvents['ui:focus:address-bar'],\n): void => {\n // On non-desktop layouts, if already focused we let the browser handle the\n // native behavior (e.g. selecting the browser's own address bar).\n if (addressBarRef.value?.isFocused && layout !== 'desktop') {\n return\n }\n\n addressBarRef.value?.focus('end')\n\n if (payload && 'clear' in payload && payload.clear) {\n addressBarRef.value?.setCodeMirrorContent('')\n }\n\n if (payload && 'event' in payload) {\n payload.event.preventDefault()\n }\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Path masking\n//\n// Drafts on `/` and auto-generated `/_scalar_temp...` paths are internal\n// placeholders — the address bar focuses and clears on mount and on\n// navigation so the user sees a blank prompt instead of the internal\n// path. The deferred mask only clears when CodeMirror still contains that\n// placeholder path, so a user edit that lands before the frame is preserved.\n// ───────────────────────────────────────────────────────────────────\n\nusePathMasking({\n isReady: () => addressBarRef.value?.codeMirror,\n operationKey: () => uniqueKey.value,\n shouldMask: () => isPlaceholderPath(path, documentSlug),\n // Defer to the next frame so focus() runs after click-handler side\n // effects that move focus (e.g. a dropdown refocusing its trigger),\n // which would otherwise blur our input and emit a spurious path\n // update against the now-empty value.\n onMask: () =>\n requestAnimationFrame(() => {\n const editorContent =\n addressBarRef.value?.codeMirror?.state.doc.toString()\n\n if (editorContent && editorContent !== path) {\n return\n }\n\n handleFocusAddressBar({ clear: true })\n }),\n})\n\n// ───────────────────────────────────────────────────────────────────\n// Server extraction\n// ───────────────────────────────────────────────────────────────────\n\n/** If the path contains a server URL, extract it and select or add that server */\nconst extractAndSelectServer = (targetPath: string): string => {\n const extracted = extractServerFromPath(targetPath)\n if (!extracted) {\n return targetPath\n }\n\n const [url, remainingPath] = extracted\n\n // Server is already selected — nothing to do\n if (url === server?.url) {\n return remainingPath\n }\n\n const matchingServer = servers.find((s) => s.url === url)\n if (matchingServer) {\n eventBus.emit('server:update:selected', { url, meta: serverMeta })\n } else {\n eventBus.emit('server:add:server', {\n url,\n select: true,\n meta: { type: 'operation', path, method },\n })\n }\n\n return remainingPath\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Path / method updates\n// ───────────────────────────────────────────────────────────────────\n\nconst normalizePath = (value: string): string =>\n value.startsWith('/') ? value : `/${value}`\n\n/** Emit a path/method update and reconcile conflicts + cursor state on the result */\nconst emitPathMethodUpdate = (\n targetMethod: string,\n targetPath: string,\n blurTargetSelector: string | null = null,\n): void => {\n if (isWebhook) {\n // A webhook has no OpenAPI server, so the field holds the full destination\n // URL. Keep exactly what the user entered — do not split it into an invisible\n // server plus a leftover path, and do not force a leading slash. That split\n // is what made a typed URL collapse to a stray \"/\" on blur.\n const webhookUrl = targetPath.trim()\n addressBarRef.value?.setCodeMirrorContent(webhookUrl)\n emit('update:webhook-url', webhookUrl)\n methodConflict.value = null\n pathConflict.value = null\n nextTick(() => refocusBlurTarget(blurTargetSelector, documentRoot))\n return\n }\n\n const extractedPath = extractAndSelectServer(targetPath)\n const normalizedPath = normalizePath(extractedPath)\n\n // Keep CodeMirror in sync so a conflict does not leave a stale value on screen\n addressBarRef.value?.setCodeMirrorContent(normalizedPath)\n\n eventBus.emit('operation:update:pathMethod', {\n meta: { method, path },\n blurTargetSelector,\n payload: { method: targetMethod, path: normalizedPath },\n callback: (status, returnedSelector) => {\n if (status === 'success' || status === 'no-change') {\n methodConflict.value = null\n pathConflict.value = null\n } else if (status === 'conflict') {\n if (targetMethod !== method) {\n methodConflict.value = targetMethod\n }\n if (normalizedPath !== path) {\n pathConflict.value = normalizedPath\n }\n\n return\n }\n\n // Edge case: pasting a full URL extracts the server but leaves the path\n // unchanged. CodeMirror still shows the full URL, so force it back to\n // just the path.\n const mirrorContent = addressBarRef.value?.codeMirrorRef?.textContent\n if (\n status === 'no-change' &&\n mirrorContent &&\n mirrorContent !== extractedPath\n ) {\n addressBarRef.value?.setCodeMirrorContent(extractedPath)\n }\n\n nextTick(() => refocusBlurTarget(returnedSelector, documentRoot))\n },\n })\n}\n\n/** Change the operation's method, preferring the conflicting path if present */\nconst handleMethodChange = (newMethod: string): void =>\n emitPathMethodUpdate(newMethod, pathConflict.value ?? path)\n\n/**\n * Save the path on blur and replay the click that caused the blur (so e.g. a\n * click on the Send button still fires after the async update resolves).\n *\n * Tab-outs do not replay — tabbing to a button should not trigger its click\n * (`tabbedOut` is set on `@keydown.tab`).\n *\n * Programmatic focus moves also do not replay. On first navigation into a\n * draft operation, `usePathMasking` focuses and clears the address bar while\n * `ScalarSidebarNestedItems` focuses the drilled-in Back button in\n * `nextTick`. That steals focus from CodeMirror, fires blur with a\n * `relatedTarget` (the Back button), and without a guard we would treat it\n * like a user click: capture the selector, then `refocusBlurTarget` would\n * synthesize `.click()` on Back and navigate away.\n *\n * `FocusEvent.sourceCapabilities` is null when no input device caused the\n * focus change (e.g. `element.focus()`). A real pointer click sets it on the\n * blur that precedes the click, so we still replay Send and other buttons.\n */\nconst handlePathBlur = (newPath: string, event: FocusEvent): void => {\n const relatedTarget =\n event.relatedTarget instanceof Element ? event.relatedTarget : null\n const blurTargetSelector =\n tabbedOut.value ||\n ('sourceCapabilities' in event && event.sourceCapabilities === null)\n ? null\n : getSelector(relatedTarget)\n tabbedOut.value = false\n\n emitPathMethodUpdate(\n methodConflict.value ?? method,\n newPath,\n blurTargetSelector,\n )\n}\n\n/** Save the path on Enter and trigger the Send button after the update resolves */\nconst handlePathSubmit = (\n newPath: string,\n event: KeyboardEvent | FocusEvent,\n): void => {\n // Prevent the global hotkey listener from also handling this Enter press\n event.stopPropagation()\n\n emitPathMethodUpdate(\n methodConflict.value ?? method,\n newPath,\n '[data-addressbar-action=\"send\"]',\n )\n}\n\n/** Unset the server when backspace is pressed on an empty path */\nconst handlePathBackspace = (event: KeyboardEvent): void => {\n if (event.target instanceof HTMLElement && event.target.innerText === '\\n') {\n // A webhook has no server to unset; its full URL lives in the field itself.\n if (isWebhook) {\n return\n }\n eventBus.emit('server:update:selected', { url: '', meta: serverMeta })\n }\n}\n\nconst handleServerSelect = (\n payload: ApiReferenceEvents['server:update:selected'],\n): void => {\n eventBus.emit('server:update:selected', payload)\n}\n\nconst handleServerVariable = (\n payload: ApiReferenceEvents['server:update:variables'],\n): void => {\n eventBus.emit('server:update:variables', payload)\n}\n\nconst isGetRequest = computed(() => method.toLowerCase() === 'get')\nconst isOpenInBrowserDisabled = computed(\n () => executionDisabled || !!hasConflict.value,\n)\n\nconst requestOpenInBrowser = (): void => {\n if (isOpenInBrowserDisabled.value) return\n emit('open:browser')\n}\n\n/** Address bar copy is handled in OperationBlock (same URL as Send). */\nconst requestCopyUrl = (): void => {\n eventBus.emit('copy-url:address-bar')\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Navigation\n// ───────────────────────────────────────────────────────────────────\n\nconst navigateToServersPage = (): void => {\n if (serverMeta.type === 'operation') {\n eventBus.emit('ui:navigate', {\n page: 'operation',\n path: 'servers',\n operationPath: serverMeta.path,\n method: serverMeta.method,\n })\n return\n }\n\n eventBus.emit('ui:navigate', { page: 'document', path: 'servers' })\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Lifecycle\n// ───────────────────────────────────────────────────────────────────\n\nconst unsubscribes: Array<() => void> = []\n\nonMounted(() => {\n unsubscribes.push(\n eventBus.on('ui:focus:address-bar', handleFocusAddressBar),\n eventBus.on('ui:focus:send-button', handleFocusSendButton),\n eventBus.on('hooks:on:request:sent', startLoading),\n eventBus.on('hooks:on:request:complete', stopLoading),\n )\n})\n\nonBeforeUnmount(() => {\n for (const unsubscribe of unsubscribes) {\n unsubscribe()\n }\n\n // Prevents the loading animation from continuing after unmount\n stopLoading()\n})\n\ndefineExpose({\n methodConflict,\n pathConflict,\n})\n</script>\n<template>\n <!--\n Address bar.\n\n The wide-container layout is a single row:\n `[Method | URL | Copy | History | Send]`. When the surrounding\n `@container` drops below `@3xl` only the send button moves to a\n second row, where it spans the full width. The method and copy\n controls stay inside the bar at every width so they keep belonging\n to the URL they act on rather than floating beside it.\n -->\n <div\n class=\"order-last flex h-auto w-full max-w-3xl grow-3 flex-wrap items-stretch [--scalar-address-bar-height:32px] @3xl:order-0 @3xl:flex-nowrap\">\n <!-- Address Bar -->\n <div\n :id=\"id\"\n class=\"address-bar-bg-states text-xxs group relative flex h-(--scalar-address-bar-height) w-full flex-1 flex-row items-stretch rounded-lg p-0.75\"\n :class=\"{\n 'outline-c-danger outline': hasConflict,\n 'rounded-b-none': isDropdownOpen,\n }\">\n <div\n class=\"pointer-events-none absolute top-0 left-0 block h-full w-full overflow-hidden rounded-lg border\"\n :class=\"{\n 'rounded-b-none': isDropdownOpen,\n }\">\n <div\n class=\"absolute top-0 left-0 h-full w-full\"\n :style />\n </div>\n\n <!-- Only Send leaves the bar below `@3xl`; see the trailing row. -->\n <div class=\"flex\">\n <HttpMethod\n :isEditable=\"layout !== 'modal' && !isWebhook\"\n isSquare\n :method=\"methodConflict ?? method\"\n teleport\n @change=\"handleMethodChange\" />\n </div>\n\n <div\n class=\"scroll-timeline-x scroll-timeline-x-hidden relative flex w-full bg-blend-normal\"\n dir=\"ltr\">\n <!-- Servers -->\n <ServerDropdown\n v-if=\"servers.length\"\n :layout=\"isWebhook ? 'modal' : layout\"\n :meta=\"serverMeta\"\n :server=\"server\"\n :servers=\"servers\"\n :target=\"id\"\n @update:open=\"(value) => (isServerDropdownOpen = value)\"\n @update:selectedServer=\"handleServerSelect\"\n @update:servers=\"navigateToServersPage\"\n @update:variable=\"handleServerVariable\" />\n\n <!-- Path + URL + env vars -->\n <CodeInput\n ref=\"addressBarRef\"\n alwaysEmitChange\n :aria-label=\"translate('apiClient.addressBar.path')\"\n class=\"ml-1 min-w-fit pl-px outline-none\"\n disableCloseBrackets\n :disabled=\"layout === 'modal' && !isWebhook\"\n disableEnter\n disableTabIndent\n :emitOnBlur=\"false\"\n :environment=\"environment\"\n :extensions=\"[addressBarScrollMargins]\"\n importCurl\n :layout=\"layout\"\n :modelValue=\"path\"\n :placeholder=\"pathPlaceholder\"\n server\n @blur=\"handlePathBlur\"\n @keydown.delete=\"handlePathBackspace\"\n @keydown.tab=\"tabbedOut = true\"\n @submit=\"handlePathSubmit\" />\n </div>\n\n <!-- Copy url button -->\n <ScalarButton\n class=\"hover:bg-b-3 mx-1 flex\"\n size=\"xs\"\n variant=\"ghost\"\n @click=\"requestCopyUrl\">\n <ScalarIconCopy />\n <span class=\"sr-only\">{{\n translate('apiClient.addressBar.copyUrl')\n }}</span>\n </ScalarButton>\n\n <ScalarTooltip\n v-if=\"isGetRequest\"\n :content=\"translate('apiClient.addressBar.openInBrowserHint')\">\n <ScalarButton\n :aria-label=\"translate('apiClient.addressBar.openInBrowser')\"\n class=\"hover:bg-b-3 mr-1 flex\"\n :disabled=\"isOpenInBrowserDisabled\"\n size=\"xs\"\n variant=\"ghost\"\n @click=\"requestOpenInBrowser\">\n <ScalarIconArrowSquareOut />\n </ScalarButton>\n </ScalarTooltip>\n\n <AddressBarHistory\n :history=\"history\"\n :target=\"id\"\n @select:history:item=\"(payload) => emit('select:history:item', payload)\"\n @update:open=\"(value) => (isHistoryDropdownOpen = value)\" />\n <!-- Error message -->\n <div\n v-if=\"hasConflict\"\n class=\"z-context absolute inset-x-0 top-[calc(100%+4px)] flex flex-col items-center rounded px-6\">\n <div\n class=\"text-c-danger bg-b-danger border-c-danger flex items-center gap-1 rounded border p-1\">\n <ScalarIconWarningCircle size=\"sm\" />\n <div class=\"min-w-0 flex-1\">\n {{\n translate('apiClient.addressBar.duplicateRequest', {\n method: (methodConflict ?? method).toUpperCase(),\n path: pathConflict ?? path,\n })\n }}\n </div>\n </div>\n </div>\n\n <ScalarButton\n ref=\"sendButtonRef\"\n class=\"relative hidden h-auto shrink-0 overflow-hidden py-1 pr-2.5 pl-2 font-bold @3xl:flex\"\n data-addressbar-action=\"send\"\n :disabled=\"isLoading || executionDisabled\"\n @click=\"emit('execute')\">\n <span\n aria-hidden=\"true\"\n class=\"inline-flex items-center gap-1\">\n <ScalarIcon\n class=\"relative shrink-0 fill-current\"\n icon=\"Play\"\n size=\"xs\" />\n <span class=\"text-xxs flex\">{{\n translate('apiClient.addressBar.send')\n }}</span>\n </span>\n <span class=\"sr-only\"\n >{{\n translate('apiClient.addressBar.sendRequest', {\n method,\n url: `${server?.url ?? ''}${path}`,\n })\n }}\n </span>\n </ScalarButton>\n </div>\n\n <!--\n Below `@3xl` the send button moves out of the bar onto its own row\n and spans the full width, so the primary action stays easy to hit\n once the container is too narrow to hold it beside the URL.\n -->\n <ScalarButton\n ref=\"mobileSendButtonRef\"\n class=\"relative mt-2 h-(--scalar-address-bar-height) w-full shrink-0 justify-center overflow-hidden py-1 font-bold @3xl:hidden\"\n data-addressbar-action=\"send\"\n :disabled=\"isLoading || executionDisabled\"\n @click=\"emit('execute')\">\n <span\n aria-hidden=\"true\"\n class=\"inline-flex items-center gap-1\">\n <ScalarIcon\n class=\"relative shrink-0 fill-current\"\n icon=\"Play\"\n size=\"xs\" />\n <span class=\"text-xxs\">{{\n translate('apiClient.addressBar.send')\n }}</span>\n </span>\n <span class=\"sr-only\"\n >{{\n translate('apiClient.addressBar.sendRequest', {\n method,\n url: `${server?.url ?? ''}${path}`,\n })\n }}\n </span>\n </ScalarButton>\n </div>\n</template>\n<style scoped>\n:deep(.cm-editor) {\n height: 100%;\n outline: none;\n width: 100%;\n}\n:deep(.cm-line) {\n padding: 0;\n}\n:deep(.cm-content) {\n padding: 0;\n display: flex;\n align-items: center;\n font-size: var(--scalar-small);\n}\n.scroll-timeline-x {\n -ms-overflow-style: none;\n /* Fade the URL at the viewport edges. Mask lives on the scrollport (this\n element) rather than on `.cm-scroller`, whose width follows the URL's\n full content and pushes the right edge off-screen when overflowing. */\n mask-image: linear-gradient(\n to right,\n transparent 0,\n black 6px,\n black calc(100% - 24px),\n transparent 100%\n );\n}\n.scroll-timeline-x-hidden {\n overflow-x: auto;\n}\n.scroll-timeline-x-hidden :deep(.cm-scroller) {\n scrollbar-width: none;\n -ms-overflow-style: none;\n padding-right: 20px;\n overflow: auto;\n}\n.scroll-timeline-x-hidden::-webkit-scrollbar {\n width: 0;\n height: 0;\n display: none;\n}\n.scroll-timeline-x-hidden :deep(.cm-scroller::-webkit-scrollbar) {\n width: 0;\n height: 0;\n display: none;\n}\n.scroll-timeline-x-address {\n line-height: 27px;\n scrollbar-width: none; /* Firefox */\n}\n/* make clickable are to left of send button */\n.scroll-timeline-x-address:after {\n content: '';\n position: absolute;\n height: 100%;\n width: 24px;\n right: 0;\n cursor: text;\n}\n\n.address-bar-bg-states {\n --scalar-address-bar-bg: color-mix(\n in srgb,\n var(--scalar-background-1),\n var(--scalar-background-2)\n );\n background: var(--scalar-address-bar-bg);\n}\n.address-bar-bg-states:has(.cm-focused) {\n --scalar-address-bar-bg: var(--scalar-background-1);\n border-color: var(--scalar-border-color);\n outline-width: 1px;\n outline-style: solid;\n}\n.address-bar-bg-states:has(.cm-focused) .fade-left,\n.address-bar-bg-states:has(.cm-focused) .fade-right {\n --scalar-address-bar-bg: var(--scalar-background-1);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2FR,MAAM,OAAO;EAWb,MAAM,EAAE,cAAc,gBAAgB;;EAGtC,MAAM,eAAe,gBAAgB;EAMrC,MAAM,KAAK,MAAM;EACjB,MAAM,gBAAgB,eAAe,eAAe;EACpD,MAAM,sBAAsB,eAAe,qBAAqB;EAChE,MAAM,gBAAgB,eAAe,eAAe;EAEpD,MAAM,EA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yBeH,MAAA,YAAA,GAAA;IAxBT,SAAA;IAAJ,KAAI;IACJ,OAAM;IACN,0BAAuB;IACtB,UAAUA,MAAA,SAAA,KAAa,QAAA;IACvB,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,SAAA;;IACZ,SAAAS,cAUO,CAVPV,mBAUO,QAVP,aAUO,CAPLI,YAGcH,MAAA,UAAA,GAAA;KAFZ,OAAM;KACN,MAAK;KACL,MAAK;I,IACPD,mBAES,QAFT,aAESW,gBADPV,MAAA,SAAA,CAAS,CAAA,2BAAA,CAAA,GAAA,CAAA,C,IAGbD,mBAOO,QAPP,aAOOW,gBALHV,MAAA,SAAA,CAAS,CAAA,oCAAA;KAAmD,QAAA,QAAA;KAA4B,KAAA,GAAA,QAAA,QAAQ,OAAG,KAAS,QAAA"}
@@ -11,6 +11,8 @@
11
11
  * - Text inputs and contenteditable elements regain focus so typing resumes
12
12
  * where the user intended.
13
13
  * - Anything else is ignored silently.
14
+ *
15
+ * @param root - Where the selector was captured, so it resolves inside a shadow root too
14
16
  */
15
- export declare const refocusBlurTarget: (selector: string | null) => void;
17
+ export declare const refocusBlurTarget: (selector: string | null, root?: Document | ShadowRoot) => void;
16
18
  //# sourceMappingURL=refocus-blur-target.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"refocus-blur-target.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,GAAG,IAAI,KAAG,IAoB3D,CAAA"}
1
+ {"version":3,"file":"refocus-blur-target.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,GAAG,IAAI,EAAE,OAAM,QAAQ,GAAG,UAAqB,KAAG,IAoBnG,CAAA"}
@@ -12,10 +12,12 @@
12
12
  * - Text inputs and contenteditable elements regain focus so typing resumes
13
13
  * where the user intended.
14
14
  * - Anything else is ignored silently.
15
+ *
16
+ * @param root - Where the selector was captured, so it resolves inside a shadow root too
15
17
  */
16
- var refocusBlurTarget = (selector) => {
18
+ var refocusBlurTarget = (selector, root = document) => {
17
19
  if (!selector) return;
18
- const element = document.querySelector(selector);
20
+ const element = root.querySelector(selector);
19
21
  if (element instanceof HTMLButtonElement) {
20
22
  element.click();
21
23
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"refocus-blur-target.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.ts"],"sourcesContent":["/**\n * Re-triggers the interaction that caused the address bar to blur.\n *\n * When the user clicks a button or focuses another input while the address\n * bar is focused, CodeMirror's blur fires first and the path/method update\n * event runs asynchronously. By the time the update resolves, the click has\n * already been consumed — so we capture the blur target via a selector and\n * replay the original interaction once the update completes.\n *\n * - Buttons get a synthetic click to complete the action the user started.\n * - Text inputs and contenteditable elements regain focus so typing resumes\n * where the user intended.\n * - Anything else is ignored silently.\n */\nexport const refocusBlurTarget = (selector: string | null): void => {\n if (!selector) {\n return\n }\n\n const element = document.querySelector(selector)\n\n if (element instanceof HTMLButtonElement) {\n element.click()\n return\n }\n\n const isEditable =\n element instanceof HTMLInputElement ||\n element instanceof HTMLTextAreaElement ||\n (element instanceof HTMLElement && element.getAttribute('contenteditable') === 'true')\n\n if (isEditable) {\n element.focus()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,IAAa,qBAAqB,aAAkC;CAClE,IAAI,CAAC,UACH;CAGF,MAAM,UAAU,SAAS,cAAc,QAAQ;CAE/C,IAAI,mBAAmB,mBAAmB;EACxC,QAAQ,MAAM;EACd;CACF;CAOA,IAJE,mBAAmB,oBACnB,mBAAmB,uBAClB,mBAAmB,eAAe,QAAQ,aAAa,iBAAiB,MAAM,QAG/E,QAAQ,MAAM;AAElB"}
1
+ {"version":3,"file":"refocus-blur-target.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.ts"],"sourcesContent":["/**\n * Re-triggers the interaction that caused the address bar to blur.\n *\n * When the user clicks a button or focuses another input while the address\n * bar is focused, CodeMirror's blur fires first and the path/method update\n * event runs asynchronously. By the time the update resolves, the click has\n * already been consumed — so we capture the blur target via a selector and\n * replay the original interaction once the update completes.\n *\n * - Buttons get a synthetic click to complete the action the user started.\n * - Text inputs and contenteditable elements regain focus so typing resumes\n * where the user intended.\n * - Anything else is ignored silently.\n *\n * @param root - Where the selector was captured, so it resolves inside a shadow root too\n */\nexport const refocusBlurTarget = (selector: string | null, root: Document | ShadowRoot = document): void => {\n if (!selector) {\n return\n }\n\n const element = root.querySelector(selector)\n\n if (element instanceof HTMLButtonElement) {\n element.click()\n return\n }\n\n const isEditable =\n element instanceof HTMLInputElement ||\n element instanceof HTMLTextAreaElement ||\n (element instanceof HTMLElement && element.getAttribute('contenteditable') === 'true')\n\n if (isEditable) {\n element.focus()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,IAAa,qBAAqB,UAAyB,OAA8B,aAAmB;CAC1G,IAAI,CAAC,UACH;CAGF,MAAM,UAAU,KAAK,cAAc,QAAQ;CAE3C,IAAI,mBAAmB,mBAAmB;EACxC,QAAQ,MAAM;EACd;CACF;CAOA,IAJE,mBAAmB,oBACnB,mBAAmB,uBAClB,mBAAmB,eAAe,QAAQ,aAAa,iBAAiB,MAAM,QAG/E,QAAQ,MAAM;AAElB"}
@@ -11,7 +11,7 @@ var RequestAuthDataTableInput_vue_vue_type_script_setup_true_lang_default = /*@_
11
11
  type: Boolean,
12
12
  default: false
13
13
  },
14
- containerClass: {},
14
+ containerClass: { type: [Object, Function] },
15
15
  environment: {},
16
16
  readOnly: {
17
17
  type: Boolean,