@scalar/api-client 3.26.0 → 3.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/style.css +61 -26
  3. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.d.ts.map +1 -1
  4. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.js.map +1 -1
  5. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue_vue_type_script_setup_true_lang.js +88 -15
  6. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue_vue_type_script_setup_true_lang.js.map +1 -1
  7. package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts +6 -4
  8. package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts.map +1 -1
  9. package/dist/v2/blocks/request-block/components/RequestTable.vue.js +1 -1
  10. package/dist/v2/blocks/request-block/components/RequestTable.vue.js.map +1 -1
  11. package/dist/v2/blocks/request-block/components/RequestTable.vue_vue_type_script_setup_true_lang.js +3 -1
  12. package/dist/v2/blocks/request-block/components/RequestTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
  13. package/dist/v2/blocks/request-block/components/RequestTableFileList.vue.d.ts +35 -0
  14. package/dist/v2/blocks/request-block/components/RequestTableFileList.vue.d.ts.map +1 -0
  15. package/dist/v2/blocks/request-block/components/RequestTableFileList.vue.js +7 -0
  16. package/dist/v2/blocks/request-block/components/RequestTableFileList.vue.js.map +1 -0
  17. package/dist/v2/blocks/request-block/components/RequestTableFileList.vue_vue_type_script_setup_true_lang.js +111 -0
  18. package/dist/v2/blocks/request-block/components/RequestTableFileList.vue_vue_type_script_setup_true_lang.js.map +1 -0
  19. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts +9 -4
  20. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
  21. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js.map +1 -1
  22. package/dist/v2/blocks/request-block/components/RequestTableRow.vue_vue_type_script_setup_true_lang.js +65 -17
  23. package/dist/v2/blocks/request-block/components/RequestTableRow.vue_vue_type_script_setup_true_lang.js.map +1 -1
  24. package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.d.ts.map +1 -1
  25. package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.js.map +1 -1
  26. package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue_vue_type_script_setup_true_lang.js +22 -17
  27. package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue_vue_type_script_setup_true_lang.js.map +1 -1
  28. package/dist/v2/blocks/request-block/helpers/group-form-body-files.d.ts +9 -0
  29. package/dist/v2/blocks/request-block/helpers/group-form-body-files.d.ts.map +1 -0
  30. package/dist/v2/blocks/request-block/helpers/group-form-body-files.js +60 -0
  31. package/dist/v2/blocks/request-block/helpers/group-form-body-files.js.map +1 -0
  32. package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-oauth2-metadata.js +2 -2
  33. package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-oauth2-metadata.js.map +1 -1
  34. package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.d.ts +8 -8
  35. package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.d.ts.map +1 -1
  36. package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.js +9 -10
  37. package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.js.map +1 -1
  38. package/dist/v2/blocks/scalar-auth-selector-block/helpers/openid-discovery-to-flows.js +1 -1
  39. package/dist/v2/components/data-table/DataTableCheckbox.vue.d.ts +1 -0
  40. package/dist/v2/components/data-table/DataTableCheckbox.vue.d.ts.map +1 -1
  41. package/dist/v2/components/data-table/DataTableCheckbox.vue.js.map +1 -1
  42. package/dist/v2/components/data-table/DataTableCheckbox.vue_vue_type_script_setup_true_lang.js +14 -4
  43. package/dist/v2/components/data-table/DataTableCheckbox.vue_vue_type_script_setup_true_lang.js.map +1 -1
  44. package/dist/v2/constants.js +1 -1
  45. package/dist/v2/features/localization/locales/ar.d.ts +4 -0
  46. package/dist/v2/features/localization/locales/ar.d.ts.map +1 -1
  47. package/dist/v2/features/localization/locales/ar.js +4 -0
  48. package/dist/v2/features/localization/locales/ar.js.map +1 -1
  49. package/dist/v2/features/localization/locales/de.d.ts +4 -0
  50. package/dist/v2/features/localization/locales/de.d.ts.map +1 -1
  51. package/dist/v2/features/localization/locales/de.js +4 -0
  52. package/dist/v2/features/localization/locales/de.js.map +1 -1
  53. package/dist/v2/features/localization/locales/es.d.ts +4 -0
  54. package/dist/v2/features/localization/locales/es.d.ts.map +1 -1
  55. package/dist/v2/features/localization/locales/es.js +4 -0
  56. package/dist/v2/features/localization/locales/es.js.map +1 -1
  57. package/dist/v2/features/localization/locales/fr.d.ts +4 -0
  58. package/dist/v2/features/localization/locales/fr.d.ts.map +1 -1
  59. package/dist/v2/features/localization/locales/fr.js +4 -0
  60. package/dist/v2/features/localization/locales/fr.js.map +1 -1
  61. package/dist/v2/features/localization/locales/pt.d.ts +4 -0
  62. package/dist/v2/features/localization/locales/pt.d.ts.map +1 -1
  63. package/dist/v2/features/localization/locales/pt.js +4 -0
  64. package/dist/v2/features/localization/locales/pt.js.map +1 -1
  65. package/dist/v2/features/localization/locales/ru.d.ts +4 -0
  66. package/dist/v2/features/localization/locales/ru.d.ts.map +1 -1
  67. package/dist/v2/features/localization/locales/ru.js +4 -0
  68. package/dist/v2/features/localization/locales/ru.js.map +1 -1
  69. package/dist/v2/features/localization/locales/zh-cn.d.ts +4 -0
  70. package/dist/v2/features/localization/locales/zh-cn.d.ts.map +1 -1
  71. package/dist/v2/features/localization/locales/zh-cn.js +4 -0
  72. package/dist/v2/features/localization/locales/zh-cn.js.map +1 -1
  73. package/dist/v2/features/localization/locales/zh-tw.d.ts +4 -0
  74. package/dist/v2/features/localization/locales/zh-tw.d.ts.map +1 -1
  75. package/dist/v2/features/localization/locales/zh-tw.js +4 -0
  76. package/dist/v2/features/localization/locales/zh-tw.js.map +1 -1
  77. package/dist/v2/features/localization/translations.d.ts +4 -0
  78. package/dist/v2/features/localization/translations.d.ts.map +1 -1
  79. package/dist/v2/features/localization/translations.js +4 -0
  80. package/dist/v2/features/localization/translations.js.map +1 -1
  81. package/dist/vue-styles.css +3 -3
  82. package/package.json +17 -17
@@ -1 +1 @@
1
- {"version":3,"file":"RequestTable.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","DataTable","_withCtx","_createVNode","DataTableRow","DataTableHeader","_createTextVNode","_toDisplayString","_createElementBlock","_Fragment","_renderList","RequestTableRow"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestTable.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { computed, type ComponentPublicInstance } from 'vue'\n\nimport RequestTableRow, {\n type TableRow,\n type TableRowUpsertPayload,\n} from '@/v2/blocks/request-block/components/RequestTableRow.vue'\nimport {\n DataTable,\n DataTableHeader,\n DataTableRow,\n} from '@/v2/components/data-table'\nimport { useLocalization } from '@/v2/features/localization'\n\nconst {\n data,\n hasCheckboxDisabled,\n deferKeyUpdates,\n showUploadButton,\n allowUnknownFileUploads = true,\n showAddRowPlaceholder = true,\n environment,\n} = defineProps<{\n data: TableRow[]\n /** Save key edits on blur so changing a body name does not replace the focused row. */\n deferKeyUpdates?: boolean\n /** Hide the enabled column */\n hasCheckboxDisabled?: boolean\n invalidParams?: Set<string>\n label?: string\n showUploadButton?: boolean\n /** Keep manual uploads available for multipart requests without a body schema. */\n allowUnknownFileUploads?: boolean\n showAddRowPlaceholder?: boolean\n environment: XScalarEnvironment\n}>()\n\n/**\n * Make this component more generic that can be used also for the operation body\n */\nconst emit = defineEmits<{\n (e: 'upsertRow', index: number, payload: TableRowUpsertPayload): void\n (e: 'deleteRow', index: number): void\n\n /**\n * File upload events\n *\n * Each row has its own upload button, so we need to know which row to update\n * when the file is selected.\n */\n (e: 'uploadFile', index: number): void\n (e: 'removeFile', index: number): void\n (e: 'navigate', route: NonNullable<TableRow['globalRoute']>): void\n /** Select a value for a grouped global cookie preset at the given row index. */\n (e: 'selectPreset', index: number, value: string): void\n}>()\n\nconst { translate } = useLocalization()\n\nconst columns = computed(() => {\n if (showUploadButton) {\n return ['36px', '', '', 'minmax(0, 1fr)']\n }\n return ['36px', '', '']\n})\n\n/** Add the last empty row (for ui purposes only) */\nconst displayData = computed(() => {\n if (!showAddRowPlaceholder) {\n return data\n }\n\n const last = data.at(-1)\n\n if (last?.name !== '' || last.value !== '') {\n return [...data, { name: '', value: '', isDisabled: true }]\n }\n\n return data\n})\n\n/**\n * Stable identity key for each row so Vue never reuses a RequestTableRow instance for a different\n * parameter or the appended placeholder row. Parameter rows are keyed by their parameter identity —\n * the name plus the value path for expanded object parameters. The parts are combined through\n * JSON.stringify so the name/path boundary is unambiguous (for example `ab` + `['c']` never\n * collides with `a` + `['bc']`). Form rows use the name and its occurrence so repeated\n * multipart fields remain distinct while unrelated rows can move without losing their identity.\n */\nconst getRowKey = (row: TableRow, index: number): string => {\n // Body edits retain their row when blur commits a rename after focus moves into the value.\n if (deferKeyUpdates) {\n return `body:${index}`\n }\n if (row.originalParameter) {\n return JSON.stringify([\n row.originalParameter.name,\n ...(row.sourceParameterValuePath ?? []),\n ])\n }\n\n const occurrence = displayData.value\n .slice(0, index)\n .filter(\n (other) => !other.originalParameter && other.name === row.name,\n ).length\n return `row:${JSON.stringify([row.name, occurrence])}`\n}\n\n/** Keep an edited row mounted when saving it changes its parameter identity. */\ntype DisplayRow = {\n data: TableRow\n identity: string\n key: symbol\n}\n\nconst pendingUpdates = new Map<symbol, TableRowUpsertPayload>()\nconst rowRefs = new Map<symbol, InstanceType<typeof RequestTableRow>>()\n\nconst setRowRef = (\n key: symbol,\n element: Element | ComponentPublicInstance | null,\n): void => {\n if (element) {\n rowRefs.set(key, element as InstanceType<typeof RequestTableRow>)\n } else {\n rowRefs.delete(key)\n }\n}\n\nconst matchesPendingUpdate = (key: symbol, row: TableRow): boolean => {\n const update = pendingUpdates.get(key)\n return update?.name === row.name && update.value === row.value\n}\n\n// A saved parameter inherits the editor's key. The next placeholder gets a fresh key,\n// so it cannot retain the previous placeholder's text or focused input.\nconst keyedRows = computed<DisplayRow[]>((previous = []) => {\n const available = new Set(previous)\n // Reserve identities still present in the store before transferring an edited key.\n // The appended placeholder is excluded so a newly saved row can inherit its editor.\n const savedIdentities = new Set(data.map(getRowKey))\n const rows = displayData.value.map((row, index) => {\n const identity = getRowKey(row, index)\n const existing = [...available].find((entry) => entry.identity === identity)\n const pending = [...available].find(\n (entry) =>\n !savedIdentities.has(entry.identity) &&\n !entry.data.sourceParameterValuePath &&\n matchesPendingUpdate(entry.key, row),\n )\n const match = existing ?? pending\n\n if (match) {\n available.delete(match)\n if (matchesPendingUpdate(match.key, row)) {\n pendingUpdates.delete(match.key)\n }\n }\n\n return { data: row, identity, key: match?.key ?? Symbol() }\n })\n\n for (const removed of available) {\n pendingUpdates.delete(removed.key)\n }\n\n return rows\n})\n\nconst handleUpsertRow = (\n row: DisplayRow,\n index: number,\n payload: TableRowUpsertPayload,\n): void => {\n // The store may debounce the save. Transfer this key only when the saved row arrives.\n pendingUpdates.set(row.key, payload)\n emit('upsertRow', index, payload)\n}\n\ndefineExpose({\n focusValue: (index: number): void => {\n const row = keyedRows.value[index]\n if (row) {\n rowRefs.get(row.key)?.focusValue()\n }\n },\n})\n</script>\n<template>\n <DataTable\n class=\"group/table flex-1\"\n :columns=\"columns\">\n <DataTableRow class=\"sr-only !block\">\n <DataTableHeader>\n {{ label }}\n {{ translate('apiClient.requestTable.enabled') }}\n </DataTableHeader>\n <DataTableHeader>\n {{ label }}\n {{ translate('apiClient.requestTable.key') }}\n </DataTableHeader>\n <DataTableHeader>\n {{ label }}\n {{ translate('apiClient.requestTable.value') }}\n </DataTableHeader>\n </DataTableRow>\n\n <RequestTableRow\n v-for=\"(row, index) in keyedRows\"\n :key=\"row.key\"\n :ref=\"(el) => setRowRef(row.key, el)\"\n :allowUnknownFileUploads=\"allowUnknownFileUploads\"\n :data=\"row.data\"\n :deferKeyUpdates=\"deferKeyUpdates\"\n :environment=\"environment\"\n :hasCheckboxDisabled=\"hasCheckboxDisabled\"\n :invalidParams=\"invalidParams\"\n :label=\"label\"\n :showUploadButton=\"showUploadButton\"\n @deleteRow=\"emit('deleteRow', index)\"\n @navigate=\"(route) => emit('navigate', route)\"\n @removeFile=\"emit('removeFile', index)\"\n @selectPreset=\"(value) => emit('selectPreset', index, value)\"\n @uploadFile=\"emit('uploadFile', index)\"\n @upsertRow=\"(payload) => handleUpsertRow(row, index, payload)\" />\n </DataTable>\n</template>\n<style scoped>\n:deep(.code-input-lite__editor) {\n background-color: transparent;\n font-family: var(--scalar-font);\n font-size: var(--scalar-small);\n padding: 5px 8px;\n}\n:deep(.scalar-pill:not(:last-of-type)) {\n margin-right: 0.15em;\n}\n:deep(.scalar-pill:not(:first-of-type)) {\n margin-left: 0.5px;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCA,MAAM,OAAO;EAiBb,MAAM,EAAE,cAAc,gBAAgB;EAEtC,MAAM,UAAU,eAAe;GAC7B,IAAI,QAAA,kBACF,OAAO;IAAC;IAAQ;IAAI;IAAI;GAAgB;GAE1C,OAAO;IAAC;IAAQ;IAAI;GAAE;EACxB,CAAC;;EAGD,MAAM,cAAc,eAAe;GACjC,IAAI,CAAC,QAAA,uBACH,OAAO,QAAA;GAGT,MAAM,OAAO,QAAA,KAAK,GAAG,EAAE;GAEvB,IAAI,MAAM,SAAS,MAAM,KAAK,UAAU,IACtC,OAAO,CAAC,GAAG,QAAA,MAAM;IAAE,MAAM;IAAI,OAAO;IAAI,YAAY;GAAK,CAAC;GAG5D,OAAO,QAAA;EACT,CAAC;;;;;;;;;EAUD,MAAM,aAAa,KAAe,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Z,UAAA,GAAAC,YAiBmEY,yBAAA;MAfhE,KAAK,IAAI;;MACT,MAAM,OAAO,UAAU,IAAI,KAAK,EAAE;MAClC,yBAAyB,QAAA;MACzB,MAAM,IAAI;MACV,iBAAiB,QAAA;MACjB,aAAa,QAAA;MACb,qBAAqB,QAAA;MACrB,eAAe,QAAA;MACf,OAAO,QAAA;MACP,kBAAkB,QAAA;MAClB,cAAS,WAAE,KAAI,aAAc,KAAK;MAClC,YAAQ,OAAA,OAAA,OAAA,MAAG,UAAU,KAAI,YAAa,KAAK;MAC3C,eAAU,WAAE,KAAI,cAAe,KAAK;MACpC,iBAAe,UAAU,KAAI,gBAAiB,OAAO,KAAK;MAC1D,eAAU,WAAE,KAAI,cAAe,KAAK;MACpC,cAAY,YAAY,gBAAgB,KAAK,OAAO,OAAO"}
1
+ {"version":3,"file":"RequestTable.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","DataTable","_withCtx","_createVNode","DataTableRow","DataTableHeader","_createTextVNode","_toDisplayString","_createElementBlock","_Fragment","_renderList","RequestTableRow"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestTable.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { computed, type ComponentPublicInstance } from 'vue'\n\nimport RequestTableRow, {\n type TableRow,\n type TableRowUpsertPayload,\n} from '@/v2/blocks/request-block/components/RequestTableRow.vue'\nimport {\n DataTable,\n DataTableHeader,\n DataTableRow,\n} from '@/v2/components/data-table'\nimport { useLocalization } from '@/v2/features/localization'\n\nconst {\n data,\n hasCheckboxDisabled,\n deferKeyUpdates,\n showUploadButton,\n allowUnknownFileUploads = true,\n showAddRowPlaceholder = true,\n environment,\n} = defineProps<{\n data: TableRow[]\n /** Save key edits on blur so changing a body name does not replace the focused row. */\n deferKeyUpdates?: boolean\n /** Hide the enabled column */\n hasCheckboxDisabled?: boolean\n invalidParams?: Set<string>\n label?: string\n showUploadButton?: boolean\n /** Keep manual uploads available for multipart requests without a body schema. */\n allowUnknownFileUploads?: boolean\n showAddRowPlaceholder?: boolean\n environment: XScalarEnvironment\n}>()\n\n/**\n * Make this component more generic that can be used also for the operation body\n */\nconst emit = defineEmits<{\n (e: 'upsertRow', index: number, payload: TableRowUpsertPayload): void\n (e: 'deleteRow', index: number): void\n\n /**\n * File upload events\n *\n * Each row has its own upload button, so we need to know which row to update\n * when the file is selected.\n */\n (e: 'uploadFile', index: number): void\n (e: 'removeFile', index: number, fileIndex?: number): void\n (e: 'updateFile', fileIndex: number, isDisabled: boolean): void\n (e: 'navigate', route: NonNullable<TableRow['globalRoute']>): void\n /** Select a value for a grouped global cookie preset at the given row index. */\n (e: 'selectPreset', index: number, value: string): void\n}>()\n\nconst { translate } = useLocalization()\n\nconst columns = computed(() => {\n if (showUploadButton) {\n return ['36px', '', '', 'minmax(0, 1fr)']\n }\n return ['36px', '', '']\n})\n\n/** Add the last empty row (for ui purposes only) */\nconst displayData = computed(() => {\n if (!showAddRowPlaceholder) {\n return data\n }\n\n const last = data.at(-1)\n\n if (last?.name !== '' || last.value !== '') {\n return [...data, { name: '', value: '', isDisabled: true }]\n }\n\n return data\n})\n\n/**\n * Stable identity key for each row so Vue never reuses a RequestTableRow instance for a different\n * parameter or the appended placeholder row. Parameter rows are keyed by their parameter identity —\n * the name plus the value path for expanded object parameters. The parts are combined through\n * JSON.stringify so the name/path boundary is unambiguous (for example `ab` + `['c']` never\n * collides with `a` + `['bc']`). Form rows use the name and its occurrence so repeated\n * multipart fields remain distinct while unrelated rows can move without losing their identity.\n */\nconst getRowKey = (row: TableRow, index: number): string => {\n // Body edits retain their row when blur commits a rename after focus moves into the value.\n if (deferKeyUpdates) {\n return `body:${index}`\n }\n if (row.originalParameter) {\n return JSON.stringify([\n row.originalParameter.name,\n ...(row.sourceParameterValuePath ?? []),\n ])\n }\n\n const occurrence = displayData.value\n .slice(0, index)\n .filter(\n (other) => !other.originalParameter && other.name === row.name,\n ).length\n return `row:${JSON.stringify([row.name, occurrence])}`\n}\n\n/** Keep an edited row mounted when saving it changes its parameter identity. */\ntype DisplayRow = {\n data: TableRow\n identity: string\n key: symbol\n}\n\nconst pendingUpdates = new Map<symbol, TableRowUpsertPayload>()\nconst rowRefs = new Map<symbol, InstanceType<typeof RequestTableRow>>()\n\nconst setRowRef = (\n key: symbol,\n element: Element | ComponentPublicInstance | null,\n): void => {\n if (element) {\n rowRefs.set(key, element as InstanceType<typeof RequestTableRow>)\n } else {\n rowRefs.delete(key)\n }\n}\n\nconst matchesPendingUpdate = (key: symbol, row: TableRow): boolean => {\n const update = pendingUpdates.get(key)\n return update?.name === row.name && update.value === row.value\n}\n\n// A saved parameter inherits the editor's key. The next placeholder gets a fresh key,\n// so it cannot retain the previous placeholder's text or focused input.\nconst keyedRows = computed<DisplayRow[]>((previous = []) => {\n const available = new Set(previous)\n // Reserve identities still present in the store before transferring an edited key.\n // The appended placeholder is excluded so a newly saved row can inherit its editor.\n const savedIdentities = new Set(data.map(getRowKey))\n const rows = displayData.value.map((row, index) => {\n const identity = getRowKey(row, index)\n const existing = [...available].find((entry) => entry.identity === identity)\n const pending = [...available].find(\n (entry) =>\n !savedIdentities.has(entry.identity) &&\n !entry.data.sourceParameterValuePath &&\n matchesPendingUpdate(entry.key, row),\n )\n const match = existing ?? pending\n\n if (match) {\n available.delete(match)\n if (matchesPendingUpdate(match.key, row)) {\n pendingUpdates.delete(match.key)\n }\n }\n\n return { data: row, identity, key: match?.key ?? Symbol() }\n })\n\n for (const removed of available) {\n pendingUpdates.delete(removed.key)\n }\n\n return rows\n})\n\nconst handleUpsertRow = (\n row: DisplayRow,\n index: number,\n payload: TableRowUpsertPayload,\n): void => {\n // The store may debounce the save. Transfer this key only when the saved row arrives.\n pendingUpdates.set(row.key, payload)\n emit('upsertRow', index, payload)\n}\n\ndefineExpose({\n focusValue: (index: number): void => {\n const row = keyedRows.value[index]\n if (row) {\n rowRefs.get(row.key)?.focusValue()\n }\n },\n})\n</script>\n<template>\n <DataTable\n class=\"group/table flex-1\"\n :columns=\"columns\">\n <DataTableRow class=\"sr-only !block\">\n <DataTableHeader>\n {{ label }}\n {{ translate('apiClient.requestTable.enabled') }}\n </DataTableHeader>\n <DataTableHeader>\n {{ label }}\n {{ translate('apiClient.requestTable.key') }}\n </DataTableHeader>\n <DataTableHeader>\n {{ label }}\n {{ translate('apiClient.requestTable.value') }}\n </DataTableHeader>\n </DataTableRow>\n\n <RequestTableRow\n v-for=\"(row, index) in keyedRows\"\n :key=\"row.key\"\n :ref=\"(el) => setRowRef(row.key, el)\"\n :allowUnknownFileUploads=\"allowUnknownFileUploads\"\n :data=\"row.data\"\n :deferKeyUpdates=\"deferKeyUpdates\"\n :environment=\"environment\"\n :hasCheckboxDisabled=\"hasCheckboxDisabled\"\n :invalidParams=\"invalidParams\"\n :label=\"label\"\n :showUploadButton=\"showUploadButton\"\n @deleteRow=\"emit('deleteRow', index)\"\n @navigate=\"(route) => emit('navigate', route)\"\n @removeFile=\"(...args) => emit('removeFile', index, ...args)\"\n @selectPreset=\"(value) => emit('selectPreset', index, value)\"\n @updateFile=\"\n (fileIndex, disabled) => emit('updateFile', fileIndex, disabled)\n \"\n @uploadFile=\"emit('uploadFile', index)\"\n @upsertRow=\"(payload) => handleUpsertRow(row, index, payload)\" />\n </DataTable>\n</template>\n<style scoped>\n:deep(.code-input-lite__editor) {\n background-color: transparent;\n font-family: var(--scalar-font);\n font-size: var(--scalar-small);\n padding: 5px 8px;\n}\n:deep(.scalar-pill:not(:last-of-type)) {\n margin-right: 0.15em;\n}\n:deep(.scalar-pill:not(:first-of-type)) {\n margin-left: 0.5px;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCA,MAAM,OAAO;EAkBb,MAAM,EAAE,cAAc,gBAAgB;EAEtC,MAAM,UAAU,eAAe;GAC7B,IAAI,QAAA,kBACF,OAAO;IAAC;IAAQ;IAAI;IAA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AA,QAAA,KAAK,IAAG,MACXA,gBAAGP,MAAA,SAAA,CAAS,CAAA,4BAAA,CAAA,GAAA,CAAA,C;;;MAEdG,YAGkBH,MAAAK,uBAAA,GAAA,MAAA;OAFhB,SAAAH,cAAW,CAARI,gBAAAC,gBAAA,QAAA,KAAK,IAAG,MACXA,gBAAGP,MAAA,SAAA,CAAS,CAAA,8BAAA,CAAA,GAAA,CAAA,C;;;;;I,KAIhBF,UAAA,IAAA,GAAAU,mBAoBmEC,UAAA,MAAAC,WAnB1C,UAAA,QAAf,KAAK,UAAK;KADpB,OAAAZ,UAAA,GAAAC,YAoBmEY,yBAAA;MAlBhE,KAAK,IAAI;;MACT,MAAM,OAAO,UAAU,IAAI,KAAK,EAAE;MAClC,yBAAyB,QAAA;MACzB,MAAM,IAAI;MACV,iBAAiB,QAAA;MACjB,aAAa,QAAA;MACb,qBAAqB,QAAA;MACrB,eAAe,QAAA;MACf,OAAO,QAAA;MACP,kBAAkB,QAAA;MAClB,cAAS,WAAE,KAAI,aAAc,KAAK;MAClC,YAAQ,OAAA,OAAA,OAAA,MAAG,UAAU,KAAI,YAAa,KAAK;MAC3C,eAAU,GAAM,SAAS,KAAI,cAAe,OAAK,GAAK,IAAI;MAC1D,iBAAe,UAAU,KAAI,gBAAiB,OAAO,KAAK;MAC1D,cAAU,OAAA,OAAA,OAAA,MAAY,WAAW,aAAa,KAAI,cAAe,WAAW,QAAQ;MAGpF,eAAU,WAAE,KAAI,cAAe,KAAK;MACpC,cAAY,YAAY,gBAAgB,KAAK,OAAO,OAAO"}
@@ -0,0 +1,35 @@
1
+ /** A selected multipart file and its position in the underlying form rows. */
2
+ export type RequestTableFile = {
3
+ file: File;
4
+ index: number;
5
+ isDisabled: boolean;
6
+ };
7
+ type __VLS_Props = {
8
+ name: string;
9
+ files: RequestTableFile[];
10
+ disabled?: boolean;
11
+ };
12
+ declare var __VLS_24: {};
13
+ type __VLS_Slots = {} & {
14
+ default?: (props: typeof __VLS_24) => any;
15
+ };
16
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
17
+ focusUpload: () => void;
18
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
+ removeFile: (index: number) => any;
20
+ uploadFile: () => any;
21
+ updateFile: (index: number, isDisabled: boolean) => any;
22
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
23
+ onRemoveFile?: ((index: number) => any) | undefined;
24
+ onUploadFile?: (() => any) | undefined;
25
+ onUpdateFile?: ((index: number, isDisabled: boolean) => any) | undefined;
26
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
27
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
28
+ declare const _default: typeof __VLS_export;
29
+ export default _default;
30
+ type __VLS_WithSlots<T, S> = T & {
31
+ new (): {
32
+ $slots: S;
33
+ };
34
+ };
35
+ //# sourceMappingURL=RequestTableFileList.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequestTableFileList.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestTableFileList.vue"],"names":[],"mappings":"AA2IA,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,gBAAgB,EAAE,CAAA;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC;AAwQF,QAAA,IAAI,QAAQ,IAAY,CAAE;AAC1B,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAOhD,QAAA,MAAM,UAAU;uBAvPG,IAAI;;;;;;;;;kFA2PrB,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import RequestTableFileList_vue_vue_type_script_setup_true_lang_default from "./RequestTableFileList.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/v2/blocks/request-block/components/RequestTableFileList.vue
3
+ var RequestTableFileList_default = RequestTableFileList_vue_vue_type_script_setup_true_lang_default;
4
+ //#endregion
5
+ export { RequestTableFileList_default as default };
6
+
7
+ //# sourceMappingURL=RequestTableFileList.vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequestTableFileList.vue.js","names":["_sfc_main"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestTableFileList.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarCheckboxInput } from '@scalar/components/checkbox-input'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { ScalarIconPlus, ScalarIconUpload, ScalarIconX } from '@scalar/icons'\nimport { computed, nextTick, useTemplateRef } from 'vue'\n\nimport { useLocalization } from '@/v2/features/localization'\n\n/** A selected multipart file and its position in the underlying form rows. */\nexport type RequestTableFile = {\n file: File\n index: number\n isDisabled: boolean\n}\n\nconst {\n name,\n files,\n disabled = false,\n} = defineProps<{\n name: string\n files: RequestTableFile[]\n disabled?: boolean\n}>()\n\nconst emit = defineEmits<{\n uploadFile: []\n removeFile: [index: number]\n updateFile: [index: number, isDisabled: boolean]\n}>()\n\nconst { translate } = useLocalization()\nconst uploadLabel = computed<string>(() =>\n translate(\n files.length\n ? 'apiClient.requestTableRow.addFiles'\n : 'apiClient.requestTableRow.selectFiles',\n ),\n)\nconst root = useTemplateRef('root')\n\ndefineExpose({\n focusUpload: (): void =>\n root.value\n ?.querySelector<HTMLButtonElement>('[data-upload-files]')\n ?.focus(),\n})\n\nconst handleRemove = async (index: number, position: number): Promise<void> => {\n emit('removeFile', index)\n await nextTick()\n // Removing a focused button should keep keyboard navigation inside the file field.\n const remaining =\n root.value?.querySelectorAll<HTMLButtonElement>('[data-remove-file]')\n const next = remaining?.[Math.min(position, remaining.length - 1)]\n const target =\n next ?? root.value?.querySelector<HTMLButtonElement>('[data-upload-files]')\n target?.focus()\n}\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"flex min-w-0 flex-1 flex-col p-1\">\n <ul\n v-if=\"files.length\"\n :aria-label=\"name\"\n class=\"m-0 flex list-none flex-col p-0\">\n <li\n v-for=\"(item, position) in files\"\n :key=\"item.index\"\n class=\"flex min-w-0 items-center gap-1\">\n <ScalarCheckboxInput\n :aria-label=\"\n translate('apiClient.requestTableRow.include', {\n name: `${name}: ${item.file.name}`,\n })\n \"\n class=\"has-[:focus-visible]:outline-c-accent min-h-7 min-w-0 flex-1 rounded border-0 px-1 py-0 shadow-none has-[:focus-visible]:outline\"\n :disabled=\"disabled\"\n :modelValue=\"!item.isDisabled\"\n @update:modelValue=\"\n (enabled) => emit('updateFile', item.index, !enabled)\n \">\n <span\n :class=\"{ 'text-c-3': item.isDisabled }\"\n :title=\"item.file.name\"\n >{{ item.file.name }}</span\n >\n </ScalarCheckboxInput>\n <ScalarIconButton\n data-remove-file\n :disabled=\"disabled\"\n :icon=\"ScalarIconX\"\n :label=\"\n translate('apiClient.requestTableRow.removeFile', {\n name: item.file.name,\n field: name,\n })\n \"\n size=\"sm\"\n variant=\"ghost\"\n @click=\"handleRemove(item.index, position)\" />\n </li>\n </ul>\n <div class=\"flex items-center gap-1\">\n <ScalarButton\n :aria-label=\"\n translate('apiClient.requestTableRow.uploadFor', {\n action: uploadLabel,\n name: name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"text-c-2 h-7 px-1\"\n data-upload-files\n :disabled=\"disabled\"\n :icon=\"files.length ? ScalarIconPlus : ScalarIconUpload\"\n size=\"sm\"\n variant=\"ghost\"\n @click=\"emit('uploadFile')\">\n {{ uploadLabel }}\n </ScalarButton>\n <slot />\n </div>\n </div>\n</template>\n"],"mappings":""}
@@ -0,0 +1,111 @@
1
+ import { useLocalization } from "../../../features/localization/index.js";
2
+ import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, nextTick, normalizeClass, openBlock, renderList, renderSlot, toDisplayString, unref, useTemplateRef, withCtx } from "vue";
3
+ import { ScalarButton } from "@scalar/components/button";
4
+ import { ScalarIconPlus, ScalarIconUpload, ScalarIconX } from "@scalar/icons";
5
+ import { ScalarIconButton } from "@scalar/components/icon-button";
6
+ import { ScalarCheckboxInput } from "@scalar/components/checkbox-input";
7
+ //#region src/v2/blocks/request-block/components/RequestTableFileList.vue?vue&type=script&setup=true&lang.ts
8
+ var _hoisted_1 = ["aria-label"];
9
+ var _hoisted_2 = ["title"];
10
+ var _hoisted_3 = { class: "flex items-center gap-1" };
11
+ var RequestTableFileList_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
12
+ __name: "RequestTableFileList",
13
+ props: {
14
+ name: {},
15
+ files: {},
16
+ disabled: {
17
+ type: Boolean,
18
+ default: false
19
+ }
20
+ },
21
+ emits: [
22
+ "uploadFile",
23
+ "removeFile",
24
+ "updateFile"
25
+ ],
26
+ setup(__props, { expose: __expose, emit: __emit }) {
27
+ const emit = __emit;
28
+ const { translate } = useLocalization();
29
+ const uploadLabel = computed(() => translate(__props.files.length ? "apiClient.requestTableRow.addFiles" : "apiClient.requestTableRow.selectFiles"));
30
+ const root = useTemplateRef("root");
31
+ __expose({ focusUpload: () => root.value?.querySelector("[data-upload-files]")?.focus() });
32
+ const handleRemove = async (index, position) => {
33
+ emit("removeFile", index);
34
+ await nextTick();
35
+ const remaining = root.value?.querySelectorAll("[data-remove-file]");
36
+ (remaining?.[Math.min(position, remaining.length - 1)] ?? root.value?.querySelector("[data-upload-files]"))?.focus();
37
+ };
38
+ return (_ctx, _cache) => {
39
+ return openBlock(), createElementBlock("div", {
40
+ ref_key: "root",
41
+ ref: root,
42
+ class: "flex min-w-0 flex-1 flex-col p-1"
43
+ }, [__props.files.length ? (openBlock(), createElementBlock("ul", {
44
+ key: 0,
45
+ "aria-label": __props.name,
46
+ class: "m-0 flex list-none flex-col p-0"
47
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.files, (item, position) => {
48
+ return openBlock(), createElementBlock("li", {
49
+ key: item.index,
50
+ class: "flex min-w-0 items-center gap-1"
51
+ }, [createVNode(unref(ScalarCheckboxInput), {
52
+ "aria-label": unref(translate)("apiClient.requestTableRow.include", { name: `${__props.name}: ${item.file.name}` }),
53
+ class: "has-[:focus-visible]:outline-c-accent min-h-7 min-w-0 flex-1 rounded border-0 px-1 py-0 shadow-none has-[:focus-visible]:outline",
54
+ disabled: __props.disabled,
55
+ modelValue: !item.isDisabled,
56
+ "onUpdate:modelValue": (enabled) => emit("updateFile", item.index, !enabled)
57
+ }, {
58
+ default: withCtx(() => [createElementVNode("span", {
59
+ class: normalizeClass({ "text-c-3": item.isDisabled }),
60
+ title: item.file.name
61
+ }, toDisplayString(item.file.name), 11, _hoisted_2)]),
62
+ _: 2
63
+ }, 1032, [
64
+ "aria-label",
65
+ "disabled",
66
+ "modelValue",
67
+ "onUpdate:modelValue"
68
+ ]), createVNode(unref(ScalarIconButton), {
69
+ "data-remove-file": "",
70
+ disabled: __props.disabled,
71
+ icon: unref(ScalarIconX),
72
+ label: unref(translate)("apiClient.requestTableRow.removeFile", {
73
+ name: item.file.name,
74
+ field: __props.name
75
+ }),
76
+ size: "sm",
77
+ variant: "ghost",
78
+ onClick: ($event) => handleRemove(item.index, position)
79
+ }, null, 8, [
80
+ "disabled",
81
+ "icon",
82
+ "label",
83
+ "onClick"
84
+ ])]);
85
+ }), 128))], 8, _hoisted_1)) : createCommentVNode("", true), createElementVNode("div", _hoisted_3, [createVNode(unref(ScalarButton), {
86
+ "aria-label": unref(translate)("apiClient.requestTableRow.uploadFor", {
87
+ action: uploadLabel.value,
88
+ name: __props.name || unref(translate)("apiClient.requestTableRow.row")
89
+ }),
90
+ class: "text-c-2 h-7 px-1",
91
+ "data-upload-files": "",
92
+ disabled: __props.disabled,
93
+ icon: __props.files.length ? unref(ScalarIconPlus) : unref(ScalarIconUpload),
94
+ size: "sm",
95
+ variant: "ghost",
96
+ onClick: _cache[0] || (_cache[0] = ($event) => emit("uploadFile"))
97
+ }, {
98
+ default: withCtx(() => [createTextVNode(toDisplayString(uploadLabel.value), 1)]),
99
+ _: 1
100
+ }, 8, [
101
+ "aria-label",
102
+ "disabled",
103
+ "icon"
104
+ ]), renderSlot(_ctx.$slots, "default")])], 512);
105
+ };
106
+ }
107
+ });
108
+ //#endregion
109
+ export { RequestTableFileList_vue_vue_type_script_setup_true_lang_default as default };
110
+
111
+ //# sourceMappingURL=RequestTableFileList.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequestTableFileList.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_renderList","_createVNode","_unref","_withCtx","_createElementVNode","_normalizeClass","_toDisplayString","_createCommentVNode","_createTextVNode","_renderSlot"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestTableFileList.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarCheckboxInput } from '@scalar/components/checkbox-input'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { ScalarIconPlus, ScalarIconUpload, ScalarIconX } from '@scalar/icons'\nimport { computed, nextTick, useTemplateRef } from 'vue'\n\nimport { useLocalization } from '@/v2/features/localization'\n\n/** A selected multipart file and its position in the underlying form rows. */\nexport type RequestTableFile = {\n file: File\n index: number\n isDisabled: boolean\n}\n\nconst {\n name,\n files,\n disabled = false,\n} = defineProps<{\n name: string\n files: RequestTableFile[]\n disabled?: boolean\n}>()\n\nconst emit = defineEmits<{\n uploadFile: []\n removeFile: [index: number]\n updateFile: [index: number, isDisabled: boolean]\n}>()\n\nconst { translate } = useLocalization()\nconst uploadLabel = computed<string>(() =>\n translate(\n files.length\n ? 'apiClient.requestTableRow.addFiles'\n : 'apiClient.requestTableRow.selectFiles',\n ),\n)\nconst root = useTemplateRef('root')\n\ndefineExpose({\n focusUpload: (): void =>\n root.value\n ?.querySelector<HTMLButtonElement>('[data-upload-files]')\n ?.focus(),\n})\n\nconst handleRemove = async (index: number, position: number): Promise<void> => {\n emit('removeFile', index)\n await nextTick()\n // Removing a focused button should keep keyboard navigation inside the file field.\n const remaining =\n root.value?.querySelectorAll<HTMLButtonElement>('[data-remove-file]')\n const next = remaining?.[Math.min(position, remaining.length - 1)]\n const target =\n next ?? root.value?.querySelector<HTMLButtonElement>('[data-upload-files]')\n target?.focus()\n}\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"flex min-w-0 flex-1 flex-col p-1\">\n <ul\n v-if=\"files.length\"\n :aria-label=\"name\"\n class=\"m-0 flex list-none flex-col p-0\">\n <li\n v-for=\"(item, position) in files\"\n :key=\"item.index\"\n class=\"flex min-w-0 items-center gap-1\">\n <ScalarCheckboxInput\n :aria-label=\"\n translate('apiClient.requestTableRow.include', {\n name: `${name}: ${item.file.name}`,\n })\n \"\n class=\"has-[:focus-visible]:outline-c-accent min-h-7 min-w-0 flex-1 rounded border-0 px-1 py-0 shadow-none has-[:focus-visible]:outline\"\n :disabled=\"disabled\"\n :modelValue=\"!item.isDisabled\"\n @update:modelValue=\"\n (enabled) => emit('updateFile', item.index, !enabled)\n \">\n <span\n :class=\"{ 'text-c-3': item.isDisabled }\"\n :title=\"item.file.name\"\n >{{ item.file.name }}</span\n >\n </ScalarCheckboxInput>\n <ScalarIconButton\n data-remove-file\n :disabled=\"disabled\"\n :icon=\"ScalarIconX\"\n :label=\"\n translate('apiClient.requestTableRow.removeFile', {\n name: item.file.name,\n field: name,\n })\n \"\n size=\"sm\"\n variant=\"ghost\"\n @click=\"handleRemove(item.index, position)\" />\n </li>\n </ul>\n <div class=\"flex items-center gap-1\">\n <ScalarButton\n :aria-label=\"\n translate('apiClient.requestTableRow.uploadFor', {\n action: uploadLabel,\n name: name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"text-c-2 h-7 px-1\"\n data-upload-files\n :disabled=\"disabled\"\n :icon=\"files.length ? ScalarIconPlus : ScalarIconUpload\"\n size=\"sm\"\n variant=\"ghost\"\n @click=\"emit('uploadFile')\">\n {{ uploadLabel }}\n </ScalarButton>\n <slot />\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EA0BA,MAAM,OAAO;EAMb,MAAM,EAAE,cAAc,gBAAgB;EACtC,MAAM,cAAc,eAClB,UACE,QAAA,MAAM,SACF,uCACA,uCACN,CACF;EACA,MAAM,OAAO,eAAe,MAAM;EAElC,SAAa,EACX,mBACE,KAAK,OACD,cAAiC,qBAAqB,CAAA,EACtD,MAAM,EACd,CAAC;EAED,MAAM,eAAe,OAAO,OAAe,aAAoC;GAC7E,KAAK,cAAc,KAAK;GACxB,MAAM,SAAS;GAEf,MAAM,YACJ,KAAK,OAAO,iBAAoC,oBAAoB;GAItE,CAHa,YAAY,KAAK,IAAI,UAAU,UAAU,SAAS,CAAC,MAEtD,KAAK,OAAO,cAAiC,qBAAqB,EAAA,EACpE,MAAM;EAChB;;GAIE,OAAAA,UAAA,GAAAC,mBA+DM,OAAA;IA9DA,SAAA;IAAJ,KAAI;IACJ,OAAM;G,IAEE,QAAA,MAAM,UADdD,UAAA,GAAAC,mBAwCK,MAAA;;IAtCF,cAAY,QAAA;IACb,OAAM;G,KACND,UAAA,IAAA,GAAAC,mBAmCKC,UAAA,MAAAC,WAlCwB,QAAA,QAAnB,MAAM,aAAQ;IADxB,OAAAH,UAAA,GAAAC,mBAmCK,MAAA;KAj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import type { ApiReferenceEvents } from '@scalar/workspace-store/events';
2
2
  import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
3
3
  import type { ParameterObject, SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
4
+ import { type RequestTableFile } from './RequestTableFileList.vue.js';
4
5
  type __VLS_Props = {
5
6
  data: TableRow;
6
7
  /** Keep key edits local until blur when the row identity depends on its name. */
@@ -18,6 +19,8 @@ export type TableRow = {
18
19
  name: string;
19
20
  /** The parameter value, can be a string, file, or null */
20
21
  value: string | File | null;
22
+ /** Selected files grouped for display; source rows remain separate multipart parts. */
23
+ files?: RequestTableFile[];
21
24
  /** Optional description for the parameter */
22
25
  description?: string;
23
26
  /** Optional route for global parameters (e.g., cookies shared across workspace) */
@@ -63,6 +66,7 @@ export type TableRowUpsertPayload = {
63
66
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
64
67
  focusValue: () => void;
65
68
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
69
+ removeFile: (fileIndex?: number | undefined) => any;
66
70
  deleteRow: () => any;
67
71
  navigate: (route: NonNullable<({
68
72
  replace?: boolean;
@@ -89,11 +93,12 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
89
93
  method: string;
90
94
  documentSlug?: string;
91
95
  })) | undefined>) => any;
92
- upsertRow: (payload: TableRowUpsertPayload) => any;
93
96
  uploadFile: () => any;
94
- removeFile: () => any;
97
+ updateFile: (fileIndex: number, isDisabled: boolean) => any;
98
+ upsertRow: (payload: TableRowUpsertPayload) => any;
95
99
  selectPreset: (value: string) => any;
96
100
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
101
+ onRemoveFile?: ((fileIndex?: number | undefined) => any) | undefined;
97
102
  onDeleteRow?: (() => any) | undefined;
98
103
  onNavigate?: ((route: NonNullable<({
99
104
  replace?: boolean;
@@ -120,9 +125,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
120
125
  method: string;
121
126
  documentSlug?: string;
122
127
  })) | undefined>) => any) | undefined;
123
- onUpsertRow?: ((payload: TableRowUpsertPayload) => any) | undefined;
124
128
  onUploadFile?: (() => any) | undefined;
125
- onRemoveFile?: (() => any) | undefined;
129
+ onUpdateFile?: ((fileIndex: number, isDisabled: boolean) => any) | undefined;
130
+ onUpsertRow?: ((payload: TableRowUpsertPayload) => any) | undefined;
126
131
  onSelectPreset?: ((value: string) => any) | undefined;
127
132
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
128
133
  declare const _default: typeof __VLS_export;
@@ -1 +1 @@
1
- {"version":3,"file":"RequestTableRow.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestTableRow.vue"],"names":[],"mappings":"AAqbA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAIxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAgBrE,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,QAAQ,CAAA;IACd,iFAAiF;IACjF,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,kBAAkB,CAAA;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,oFAAoF;IACpF,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC,CAAC;AA6BF,MAAM,MAAM,QAAQ,GAAG;IACrB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,0DAA0D;IAC1D,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3B,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mFAAmF;IACnF,WAAW,CAAC,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAA;IAC/C,iDAAiD;IACjD,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,4FAA4F;IAC5F,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,wEAAwE;IACxE,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAA;IAC1C,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,mDAAmD;IACnD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,eAAe,CAAA;IACnC,2FAA2F;IAC3F,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC,CAAA;AA6tBD,QAAA,MAAM,YAAY;sBA/wBsB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kFAmxB1C,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"RequestTableRow.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestTableRow.vue"],"names":[],"mappings":"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D,aAAa,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAA;IAC1C,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,mDAAmD;IACnD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,eAAe,CAAA;IACnC,2FAA2F;IAC3F,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC,CAAA;AAq1BD,QAAA,MAAM,YAAY;sBAh5BA,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kFAo5BpB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"RequestTableRow.vue.js","names":["_sfc_main"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestTableRow.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { ScalarIconGlobe, ScalarIconTrash } from '@scalar/icons'\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport { isFileSchema } from '@scalar/workspace-store/helpers/is-file-schema'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type {\n ParameterObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed, ref, useTemplateRef, watch } from 'vue'\n\nimport { getFileName } from '@/v2/blocks/request-block/helpers/files'\nimport { validateParameter } from '@/v2/blocks/request-block/helpers/validate-parameter'\nimport { CodeInputLite } from '@/v2/components/code-input'\nimport {\n DataTableCell,\n DataTableCheckbox,\n DataTableInputSelect,\n DataTableRow,\n} from '@/v2/components/data-table'\nimport { useLocalization } from '@/v2/features/localization'\n\nimport RequestTableTooltip from './RequestTableTooltip.vue'\n\nconst {\n data,\n environment,\n hasCheckboxDisabled,\n deferKeyUpdates,\n invalidParams,\n showUploadButton,\n allowUnknownFileUploads = true,\n} = defineProps<{\n data: TableRow\n /** Keep key edits local until blur when the row identity depends on its name. */\n deferKeyUpdates?: boolean\n hasCheckboxDisabled?: boolean\n invalidParams?: Set<string>\n label?: string\n environment: XScalarEnvironment\n showUploadButton?: boolean\n /** Unknown fields remain editable as files only in free-form multipart requests. */\n allowUnknownFileUploads?: boolean\n}>()\n\nconst emit = defineEmits<{\n (e: 'upsertRow', payload: TableRowUpsertPayload): void\n (e: 'deleteRow'): void\n (e: 'uploadFile'): void\n (e: 'removeFile'): void\n (e: 'navigate', route: NonNullable<TableRow['globalRoute']>): void\n /** Select a value for a grouped global cookie preset. */\n (e: 'selectPreset', value: string): void\n}>()\n\nconst { translate } = useLocalization()\n\nconst valueInput = useTemplateRef('valueInput')\ndefineExpose({ focusValue: (): void => valueInput.value?.focus() })\n\nexport type TableRow = {\n /** The parameter or field name/key */\n name: string\n /** The parameter value, can be a string, file, or null */\n value: string | File | null\n /** Optional description for the parameter */\n description?: string\n /** Optional route for global parameters (e.g., cookies shared across workspace) */\n globalRoute?: ApiReferenceEvents['ui:navigate']\n /** Whether the parameter is disabled/inactive */\n isDisabled?: boolean\n /** Whether an optional parameter is disabled because it has no explicit x-disabled value */\n isDisabledByDefault?: boolean\n /** OpenAPI schema object with type, validation rules, examples, etc. */\n schema?: SchemaObject\n /** Explicit media type for this multipart field. */\n contentType?: string\n /** Preserve array values even while their JSON text is temporarily invalid. */\n isArray?: boolean\n /** Text representation used by array enum controls. */\n arrayEncoding?: 'json' | 'comma-separated'\n /** Whether the parameter is required */\n isRequired?: boolean\n /**\n * Whether the parameter is readonly and can not be modifies directly\n * User can still override the parameter which is going to show up with the linethrough style\n */\n isReadonly?: boolean\n /** Whether the parameter is overridden later on */\n isOverridden?: boolean\n /** Track the original parameter so we can update it */\n originalParameter?: ParameterObject\n /** Path to a value inside the original parameter example for expanded object parameters */\n sourceParameterValuePath?: string[]\n /**\n * Selectable values for a grouped global cookie preset. When set, the value cell renders a\n * dropdown to switch between predefined values (for example a `Culture` cookie with `PL`/`EN`)\n * instead of an editable input.\n */\n presetOptions?: string[]\n}\n\nexport type TableRowUpsertPayload = {\n name: string\n value: string | File\n isDisabled: boolean\n shouldRenameExpandedRow?: boolean\n}\n\n/**\n * Track local state for the row\n *\n * Now this is required because of the way we get default values from the schema.\n * If we have a default value in data.value, then we update isDisabled to true. We lose the default value since now\n * we have an example where value: ''. This is why we need to track the local state and update all of the params at the\n * same time.\n */\nconst name = ref<string>(data.name ?? '')\nconst value = ref<string | File>(unpackProxyObject(data.value) ?? '')\nconst isDisabled = ref<boolean>(data.isDisabled ?? false)\n\n// Keep the above state synced with the data prop\nwatch(\n () => data.name,\n (newName) => {\n // Do not overwrite a valid local name with an empty incoming prop — this\n // can happen when the placeholder row (appended by displayData) is briefly\n // mapped onto this component instance before Vue re-keys the list.\n if (!newName && name.value && !deferKeyUpdates) {\n return\n }\n name.value = newName ?? ''\n },\n)\nwatch(\n () => data.value,\n (newValue) => (value.value = unpackProxyObject(newValue) ?? ''),\n)\nwatch(\n () => data.isDisabled,\n (newIsDisabled) => (isDisabled.value = newIsDisabled ?? false),\n)\n\n/** Check if the value is a File instance */\nconst isFile = computed(() => value.value instanceof File)\n\n/** Whether this row’s schema accepts a file part. */\nconst canUploadFile = computed<boolean>(() =>\n data.schema\n ? isFileSchema(data.schema, true, data.contentType)\n : allowUnknownFileUploads,\n)\n\n/** Display value handles File instances and shows filename instead */\nconst displayValue = computed(\n () =>\n (isFile.value\n ? getFileName(value.value as File)\n : (value.value as string)) ?? '',\n)\n\nconst defaultValue = computed(() => data.schema?.default as string)\n\n/** See if we can extract enum values from the schema */\nconst enumValue = computed<unknown[]>(() => {\n if (!data.schema) {\n return []\n }\n\n // Grab the enum from the schema\n if (data.schema.enum) {\n return data.schema.enum.map((item) => String(item))\n }\n\n // Grab the enum from the items schema\n if ('items' in data.schema) {\n const resolved = resolve.schema(data.schema.items)\n if (resolved?.enum) {\n return data.arrayEncoding === 'json'\n ? resolved.enum\n : resolved.enum.map((item) => String(item))\n }\n }\n\n return []\n})\n\nconst typeValue = computed(() =>\n data.schema && 'type' in data.schema ? data.schema.type : undefined,\n)\n\nconst validationResult = computed(() =>\n validateParameter(data.schema, value.value),\n)\n\n/** Handle row updates while preserving existing properties */\nconst handleUpdateRow = (\n payload: Partial<{ name: string; value: string; isDisabled: boolean }>,\n options: { shouldRenameExpandedRow?: boolean; commitKey?: boolean } = {},\n): void => {\n // Update our local state\n if (payload.name !== undefined) {\n name.value = payload.name\n }\n if (payload.value !== undefined) {\n value.value = payload.value\n\n // Optional parameters start unchecked, but entering a value expresses intent to send it.\n // Explicit x-disabled values stay unchanged so a deliberate opt-out is preserved.\n if (data.isDisabledByDefault) {\n isDisabled.value = false\n }\n }\n\n // Is disabled should only be updated when explicitly provided in the payload\n if (payload.isDisabled !== undefined) {\n isDisabled.value = payload.isDisabled\n }\n\n if (\n payload.name !== undefined &&\n (deferKeyUpdates || data.sourceParameterValuePath) &&\n !options.shouldRenameExpandedRow &&\n !options.commitKey\n ) {\n return\n }\n\n // Emit all of the local state\n emit('upsertRow', {\n name: name.value,\n value: value.value,\n isDisabled: isDisabled.value,\n ...(options.shouldRenameExpandedRow\n ? { shouldRenameExpandedRow: true }\n : {}),\n })\n}\n\n/**\n * Commit a key edit when the input loses focus. Body and expanded-object rows defer their rename to blur (see\n * handleUpdateRow), so we only emit when the key actually changed. Focusing and blurring the field\n * without typing should not re-emit the row or silently reset its disabled state. The current\n * disabled state is passed through so a renamed row keeps it.\n */\nconst handleKeyBlur = (newName: string): void => {\n if (newName === data.name) {\n return\n }\n // Do not emit an update that would blank the parameter name — this can fire\n // when CodeInputLite blurs before it has rendered its initial value.\n if (!newName && data.name && (!deferKeyUpdates || name.value !== '')) {\n return\n }\n\n handleUpdateRow(\n { name: newName, isDisabled: isDisabled.value },\n {\n shouldRenameExpandedRow: Boolean(data.sourceParameterValuePath),\n commitKey: true,\n },\n )\n}\n\n/** Save a pending body key before the send shortcut reaches the request handler. */\nconst handleKeydown = (event: KeyboardEvent): void => {\n if (\n deferKeyUpdates &&\n event.key === 'Enter' &&\n (event.metaKey || event.ctrlKey)\n ) {\n handleKeyBlur(name.value)\n }\n}\n</script>\n\n<template>\n <DataTableRow\n :id=\"data.name\"\n :class=\"{\n alert: validationResult.ok === false,\n error: validationResult.ok === false && invalidParams?.has(data.name),\n }\">\n <DataTableCheckbox\n :ariaLabel=\"\n translate('apiClient.requestTableRow.include', {\n name: data.name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"!border-r\"\n :disabled=\"hasCheckboxDisabled ?? false\"\n :modelValue=\"!isDisabled\"\n @update:modelValue=\"(v) => handleUpdateRow({ isDisabled: !v })\" />\n\n <!-- Name -->\n <DataTableCell>\n <CodeInputLite\n :aria-label=\"\n translate('apiClient.requestTableRow.keyLabel', { name: label ?? '' })\n \"\n :disabled=\"data.isReadonly\"\n :environment=\"environment\"\n :modelValue=\"name\"\n :placeholder=\"translate('apiClient.requestTableRow.key')\"\n :required=\"Boolean(data.isRequired)\"\n @blur=\"(v) => handleKeyBlur(v)\"\n @keydown.capture=\"handleKeydown\"\n @navigate=\"(route) => emit('navigate', route)\"\n @update:modelValue=\"(v) => handleUpdateRow({ name: v })\" />\n </DataTableCell>\n\n <!-- Value -->\n <DataTableCell>\n <!-- Preset switcher for grouped global cookies that share a name -->\n <DataTableInputSelect\n v-if=\"data.presetOptions?.length\"\n :canAddCustomValue=\"false\"\n :modelValue=\"displayValue\"\n :value=\"data.presetOptions\"\n @update:modelValue=\"(v) => emit('selectPreset', v)\" />\n <CodeInputLite\n v-else\n ref=\"valueInput\"\n :aria-label=\"\n translate('apiClient.requestTableRow.valueLabel', {\n name: label ?? '',\n })\n \"\n :arrayEncoding=\"data.arrayEncoding\"\n class=\"pr-6 group-hover:pr-10 group-has-[.code-input-lite__editor:focus]:pr-10\"\n :default=\"defaultValue\"\n :disabled=\"data.isReadonly\"\n :enum=\"enumValue\"\n :environment=\"environment\"\n :examples=\"\n data.schema?.examples?.map((example) => String(example)) ?? []\n \"\n :linethrough=\"data.isOverridden\"\n :modelValue=\"displayValue\"\n :placeholder=\"translate('apiClient.requestTableRow.value')\"\n :type=\"typeValue\"\n withFakeData\n @navigate=\"(route) => emit('navigate', route)\"\n @update:modelValue=\"(v) => handleUpdateRow({ value: v })\">\n <template #icon>\n <ScalarButton\n v-if=\"\n Boolean(data.name || value) &&\n !data.isRequired &&\n data.isReadonly !== true\n \"\n :aria-label=\"\n translate('apiClient.requestTableRow.deleteRow', {\n name: data.name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 hidden h-fit rounded p-1 group-hover:flex group-has-[.code-input-lite__editor:focus]:flex\"\n size=\"sm\"\n variant=\"ghost\"\n @click=\"emit('deleteRow')\">\n <ScalarIconTrash class=\"size-3.5\" />\n </ScalarButton>\n\n <ScalarIconButton\n v-if=\"data.globalRoute !== undefined\"\n class=\"text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 h-fit\"\n :icon=\"ScalarIconGlobe\"\n :label=\"translate('apiClient.requestTableRow.globalCookieHint')\"\n size=\"xs\"\n tooltip=\"top\"\n variant=\"ghost\"\n @click=\"emit('navigate', data.globalRoute)\" />\n\n <RequestTableTooltip\n v-if=\"data.isReadonly\"\n :description=\"translate('apiClient.requestTableRow.readOnlyHint')\"\n :value=\"null\" />\n <RequestTableTooltip\n v-else-if=\"data.schema\"\n :description=\"data.description\"\n :schema=\"data.schema\"\n :value />\n </template>\n </CodeInputLite>\n </DataTableCell>\n\n <!-- File upload -->\n <DataTableCell\n v-if=\"showUploadButton\"\n class=\"group/upload flex items-center justify-center whitespace-nowrap\">\n <template v-if=\"isFile\">\n <div\n class=\"text-c-2 flex w-full max-w-[100%] items-center justify-center overflow-hidden p-1\">\n <span\n class=\"truncate\"\n :title=\"displayValue\"\n >{{ displayValue }}</span\n >\n </div>\n <button\n class=\"bg-b-2 mt-1 block rounded p-0.5 text-center text-xs font-medium md:pointer-events-none md:absolute md:inset-x-1 md:top-1/2 md:mt-0 md:-translate-y-1/2 md:opacity-0 md:group-hover/upload:pointer-events-auto md:group-hover/upload:opacity-100\"\n type=\"button\"\n @click=\"emit('removeFile')\">\n {{ translate('apiClient.requestTableRow.delete') }}\n </button>\n </template>\n <template v-else-if=\"canUploadFile\">\n <div class=\"p-0.5\">\n <ScalarButton\n class=\"bg-b-2 hover:bg-b-3 text-c-2 h-fit border-0 py-px shadow-none\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"emit('uploadFile')\">\n <span>{{ translate('apiClient.requestTableRow.selectFile') }}</span>\n <ScalarIcon\n class=\"ml-1\"\n icon=\"Upload\"\n size=\"xs\"\n thickness=\"2.5\" />\n </ScalarButton>\n </div>\n </template>\n </DataTableCell>\n </DataTableRow>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"RequestTableRow.vue.js","names":["_sfc_main"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestTableRow.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { ScalarIconGlobe, ScalarIconTrash } from '@scalar/icons'\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport { isFileSchema } from '@scalar/workspace-store/helpers/is-file-schema'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type {\n ParameterObject,\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, useTemplateRef, watch } from 'vue'\n\nimport { getFileName } from '@/v2/blocks/request-block/helpers/files'\nimport { validateParameter } from '@/v2/blocks/request-block/helpers/validate-parameter'\nimport { CodeInputLite } from '@/v2/components/code-input'\nimport {\n DataTableCell,\n DataTableCheckbox,\n DataTableInputSelect,\n DataTableRow,\n} from '@/v2/components/data-table'\nimport { useLocalization } from '@/v2/features/localization'\n\nimport RequestTableTooltip from './RequestTableTooltip.vue'\nimport RequestTableFileList, {\n type RequestTableFile,\n} from './RequestTableFileList.vue'\n\nconst {\n data,\n environment,\n hasCheckboxDisabled,\n deferKeyUpdates,\n invalidParams,\n showUploadButton,\n allowUnknownFileUploads = true,\n} = defineProps<{\n data: TableRow\n /** Keep key edits local until blur when the row identity depends on its name. */\n deferKeyUpdates?: boolean\n hasCheckboxDisabled?: boolean\n invalidParams?: Set<string>\n label?: string\n environment: XScalarEnvironment\n showUploadButton?: boolean\n /** Unknown fields remain editable as files only in free-form multipart requests. */\n allowUnknownFileUploads?: boolean\n}>()\n\nconst emit = defineEmits<{\n (e: 'upsertRow', payload: TableRowUpsertPayload): void\n (e: 'deleteRow'): void\n (e: 'uploadFile'): void\n (e: 'removeFile', fileIndex?: number): void\n (e: 'updateFile', fileIndex: number, isDisabled: boolean): void\n (e: 'navigate', route: NonNullable<TableRow['globalRoute']>): void\n /** Select a value for a grouped global cookie preset. */\n (e: 'selectPreset', value: string): void\n}>()\n\nconst { translate } = useLocalization()\n\nconst valueInput = useTemplateRef('valueInput')\nconst fileList = useTemplateRef('fileList')\ndefineExpose({\n focusValue: (): void => {\n if (data.files) {\n fileList.value?.focusUpload()\n } else {\n valueInput.value?.focus()\n }\n },\n})\n\nexport type TableRow = {\n /** The parameter or field name/key */\n name: string\n /** The parameter value, can be a string, file, or null */\n value: string | File | null\n /** Selected files grouped for display; source rows remain separate multipart parts. */\n files?: RequestTableFile[]\n /** Optional description for the parameter */\n description?: string\n /** Optional route for global parameters (e.g., cookies shared across workspace) */\n globalRoute?: ApiReferenceEvents['ui:navigate']\n /** Whether the parameter is disabled/inactive */\n isDisabled?: boolean\n /** Whether an optional parameter is disabled because it has no explicit x-disabled value */\n isDisabledByDefault?: boolean\n /** OpenAPI schema object with type, validation rules, examples, etc. */\n schema?: SchemaObject\n /** Explicit media type for this multipart field. */\n contentType?: string\n /** Preserve array values even while their JSON text is temporarily invalid. */\n isArray?: boolean\n /** Text representation used by array enum controls. */\n arrayEncoding?: 'json' | 'comma-separated'\n /** Whether the parameter is required */\n isRequired?: boolean\n /**\n * Whether the parameter is readonly and can not be modifies directly\n * User can still override the parameter which is going to show up with the linethrough style\n */\n isReadonly?: boolean\n /** Whether the parameter is overridden later on */\n isOverridden?: boolean\n /** Track the original parameter so we can update it */\n originalParameter?: ParameterObject\n /** Path to a value inside the original parameter example for expanded object parameters */\n sourceParameterValuePath?: string[]\n /**\n * Selectable values for a grouped global cookie preset. When set, the value cell renders a\n * dropdown to switch between predefined values (for example a `Culture` cookie with `PL`/`EN`)\n * instead of an editable input.\n */\n presetOptions?: string[]\n}\n\nexport type TableRowUpsertPayload = {\n name: string\n value: string | File\n isDisabled: boolean\n shouldRenameExpandedRow?: boolean\n}\n\n/**\n * Track local state for the row\n *\n * Now this is required because of the way we get default values from the schema.\n * If we have a default value in data.value, then we update isDisabled to true. We lose the default value since now\n * we have an example where value: ''. This is why we need to track the local state and update all of the params at the\n * same time.\n */\nconst name = ref<string>(data.name ?? '')\nconst value = ref<string | File>(unpackProxyObject(data.value) ?? '')\nconst isDisabled = ref<boolean>(data.isDisabled ?? false)\n\n// Keep the above state synced with the data prop\nwatch(\n () => data.name,\n (newName) => {\n // Do not overwrite a valid local name with an empty incoming prop — this\n // can happen when the placeholder row (appended by displayData) is briefly\n // mapped onto this component instance before Vue re-keys the list.\n if (!newName && name.value && !deferKeyUpdates) {\n return\n }\n name.value = newName ?? ''\n },\n)\nwatch(\n () => data.value,\n (newValue) => (value.value = unpackProxyObject(newValue) ?? ''),\n)\nwatch(\n () => data.isDisabled,\n (newIsDisabled) => (isDisabled.value = newIsDisabled ?? false),\n)\n\n/** Check if the value is a File instance */\nconst isFile = computed(() => value.value instanceof File)\n\n/** Whether this row’s schema accepts a file part. */\nconst canUploadFile = computed<boolean>(() =>\n data.schema\n ? isFileSchema(data.schema, true, data.contentType)\n : allowUnknownFileUploads,\n)\n\nconst fileUploadLabel = computed<string>(() =>\n translate(\n data.schema && isArraySchema(data.schema)\n ? 'apiClient.requestTableRow.selectFiles'\n : 'apiClient.requestTableRow.selectFile',\n ),\n)\n\nconst hasMixedFileSelection = computed<boolean>(() =>\n Boolean(\n data.files?.some((file) => file.isDisabled) &&\n data.files.some((file) => !file.isDisabled),\n ),\n)\n\n/** Display value handles File instances and shows filename instead */\nconst displayValue = computed(\n () =>\n (isFile.value\n ? getFileName(value.value as File)\n : (value.value as string)) ?? '',\n)\n\nconst defaultValue = computed(() => data.schema?.default as string)\n\n/** See if we can extract enum values from the schema */\nconst enumValue = computed<unknown[]>(() => {\n if (!data.schema) {\n return []\n }\n\n // Grab the enum from the schema\n if (data.schema.enum) {\n return data.schema.enum.map((item) => String(item))\n }\n\n // Grab the enum from the items schema\n if ('items' in data.schema) {\n const resolved = resolve.schema(data.schema.items)\n if (resolved?.enum) {\n return data.arrayEncoding === 'json'\n ? resolved.enum\n : resolved.enum.map((item) => String(item))\n }\n }\n\n return []\n})\n\nconst typeValue = computed(() =>\n data.schema && 'type' in data.schema ? data.schema.type : undefined,\n)\n\nconst validationResult = computed(() =>\n validateParameter(data.schema, value.value),\n)\n\n/** Handle row updates while preserving existing properties */\nconst handleUpdateRow = (\n payload: Partial<{ name: string; value: string; isDisabled: boolean }>,\n options: { shouldRenameExpandedRow?: boolean; commitKey?: boolean } = {},\n): void => {\n // Update our local state\n if (payload.name !== undefined) {\n name.value = payload.name\n }\n if (payload.value !== undefined) {\n value.value = payload.value\n\n // Optional parameters start unchecked, but entering a value expresses intent to send it.\n // Explicit x-disabled values stay unchanged so a deliberate opt-out is preserved.\n if (data.isDisabledByDefault) {\n isDisabled.value = false\n }\n }\n\n // Is disabled should only be updated when explicitly provided in the payload\n if (payload.isDisabled !== undefined) {\n isDisabled.value = payload.isDisabled\n }\n\n if (\n payload.name !== undefined &&\n (deferKeyUpdates || data.sourceParameterValuePath) &&\n !options.shouldRenameExpandedRow &&\n !options.commitKey\n ) {\n return\n }\n\n // Emit all of the local state\n emit('upsertRow', {\n name: name.value,\n value: value.value,\n isDisabled: isDisabled.value,\n ...(options.shouldRenameExpandedRow\n ? { shouldRenameExpandedRow: true }\n : {}),\n })\n}\n\n/**\n * Commit a key edit when the input loses focus. Body and expanded-object rows defer their rename to blur (see\n * handleUpdateRow), so we only emit when the key actually changed. Focusing and blurring the field\n * without typing should not re-emit the row or silently reset its disabled state. The current\n * disabled state is passed through so a renamed row keeps it.\n */\nconst handleKeyBlur = (newName: string): void => {\n if (newName === data.name) {\n return\n }\n // Do not emit an update that would blank the parameter name — this can fire\n // when CodeInputLite blurs before it has rendered its initial value.\n if (!newName && data.name && (!deferKeyUpdates || name.value !== '')) {\n return\n }\n\n handleUpdateRow(\n { name: newName, isDisabled: isDisabled.value },\n {\n shouldRenameExpandedRow: Boolean(data.sourceParameterValuePath),\n commitKey: true,\n },\n )\n}\n\n/** Save a pending body key before the send shortcut reaches the request handler. */\nconst handleKeydown = (event: KeyboardEvent): void => {\n if (\n deferKeyUpdates &&\n event.key === 'Enter' &&\n (event.metaKey || event.ctrlKey)\n ) {\n handleKeyBlur(name.value)\n }\n}\n</script>\n\n<template>\n <DataTableRow\n :id=\"data.name\"\n :class=\"{\n alert: validationResult.ok === false,\n error: validationResult.ok === false && invalidParams?.has(data.name),\n }\">\n <DataTableCheckbox\n :ariaLabel=\"\n translate('apiClient.requestTableRow.include', {\n name: data.name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"!border-r\"\n :class=\"{ 'max-h-none': data.files }\"\n :disabled=\"hasCheckboxDisabled ?? false\"\n :indeterminate=\"hasMixedFileSelection\"\n :modelValue=\"!isDisabled\"\n @update:modelValue=\"(v) => handleUpdateRow({ isDisabled: !v })\" />\n\n <!-- Name -->\n <DataTableCell :class=\"{ 'max-h-none': data.files }\">\n <CodeInputLite\n :aria-label=\"\n translate('apiClient.requestTableRow.keyLabel', { name: label ?? '' })\n \"\n :disabled=\"data.isReadonly\"\n :environment=\"environment\"\n :modelValue=\"name\"\n :placeholder=\"translate('apiClient.requestTableRow.key')\"\n :required=\"Boolean(data.isRequired)\"\n @blur=\"(v) => handleKeyBlur(v)\"\n @keydown.capture=\"handleKeydown\"\n @navigate=\"(route) => emit('navigate', route)\"\n @update:modelValue=\"(v) => handleUpdateRow({ name: v })\" />\n </DataTableCell>\n\n <!-- Value -->\n <DataTableCell\n v-if=\"data.files\"\n class=\"col-span-2 max-h-none\"\n :colspan=\"2\">\n <RequestTableFileList\n ref=\"fileList\"\n :disabled=\"data.isReadonly\"\n :files=\"data.files\"\n :name=\"name\"\n @removeFile=\"(index) => emit('removeFile', index)\"\n @updateFile=\"(index, disabled) => emit('updateFile', index, disabled)\"\n @uploadFile=\"emit('uploadFile')\">\n <RequestTableTooltip\n v-if=\"data.schema\"\n :description=\"data.description\"\n :schema=\"data.schema\"\n :value=\"value\" />\n </RequestTableFileList>\n </DataTableCell>\n <DataTableCell v-else>\n <!-- Preset switcher for grouped global cookies that share a name -->\n <DataTableInputSelect\n v-if=\"data.presetOptions?.length\"\n :canAddCustomValue=\"false\"\n :modelValue=\"displayValue\"\n :value=\"data.presetOptions\"\n @update:modelValue=\"(v) => emit('selectPreset', v)\" />\n <CodeInputLite\n v-else\n ref=\"valueInput\"\n :aria-label=\"\n translate('apiClient.requestTableRow.valueLabel', {\n name: label ?? '',\n })\n \"\n :arrayEncoding=\"data.arrayEncoding\"\n class=\"pr-6 group-hover:pr-10 group-has-[.code-input-lite__editor:focus]:pr-10\"\n :default=\"defaultValue\"\n :disabled=\"data.isReadonly\"\n :enum=\"enumValue\"\n :environment=\"environment\"\n :examples=\"\n data.schema?.examples?.map((example) => String(example)) ?? []\n \"\n :linethrough=\"data.isOverridden\"\n :modelValue=\"displayValue\"\n :placeholder=\"translate('apiClient.requestTableRow.value')\"\n :type=\"typeValue\"\n withFakeData\n @navigate=\"(route) => emit('navigate', route)\"\n @update:modelValue=\"(v) => handleUpdateRow({ value: v })\">\n <template #icon>\n <ScalarButton\n v-if=\"\n Boolean(data.name || value) &&\n !data.isRequired &&\n data.isReadonly !== true\n \"\n :aria-label=\"\n translate('apiClient.requestTableRow.deleteRow', {\n name: data.name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 hidden h-fit rounded p-1 group-hover:flex group-has-[.code-input-lite__editor:focus]:flex\"\n size=\"sm\"\n variant=\"ghost\"\n @click=\"emit('deleteRow')\">\n <ScalarIconTrash class=\"size-3.5\" />\n </ScalarButton>\n\n <ScalarIconButton\n v-if=\"data.globalRoute !== undefined\"\n class=\"text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 h-fit\"\n :icon=\"ScalarIconGlobe\"\n :label=\"translate('apiClient.requestTableRow.globalCookieHint')\"\n size=\"xs\"\n tooltip=\"top\"\n variant=\"ghost\"\n @click=\"emit('navigate', data.globalRoute)\" />\n\n <RequestTableTooltip\n v-if=\"data.isReadonly\"\n :description=\"translate('apiClient.requestTableRow.readOnlyHint')\"\n :value=\"null\" />\n <RequestTableTooltip\n v-else-if=\"data.schema\"\n :description=\"data.description\"\n :schema=\"data.schema\"\n :value />\n </template>\n </CodeInputLite>\n </DataTableCell>\n\n <!-- File upload -->\n <DataTableCell\n v-if=\"showUploadButton && !data.files\"\n class=\"group/upload flex items-center justify-center whitespace-nowrap\">\n <template v-if=\"isFile\">\n <div\n class=\"text-c-2 flex w-full max-w-[100%] items-center justify-center overflow-hidden p-1\">\n <span\n class=\"truncate\"\n :title=\"displayValue\"\n >{{ displayValue }}</span\n >\n </div>\n <button\n class=\"bg-b-2 mt-1 block rounded p-0.5 text-center text-xs font-medium md:pointer-events-none md:absolute md:inset-x-1 md:top-1/2 md:mt-0 md:-translate-y-1/2 md:opacity-0 md:group-hover/upload:pointer-events-auto md:group-hover/upload:opacity-100\"\n type=\"button\"\n @click=\"emit('removeFile')\">\n {{ translate('apiClient.requestTableRow.delete') }}\n </button>\n </template>\n <template v-else-if=\"canUploadFile\">\n <div class=\"p-0.5\">\n <ScalarButton\n :aria-label=\"\n translate('apiClient.requestTableRow.uploadFor', {\n action: fileUploadLabel,\n name: name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"bg-b-2 hover:bg-b-3 text-c-2 h-fit border-0 py-px shadow-none\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"emit('uploadFile')\">\n <span>{{ fileUploadLabel }}</span>\n <ScalarIcon\n class=\"ml-1\"\n icon=\"Upload\"\n size=\"xs\"\n thickness=\"2.5\" />\n </ScalarButton>\n </div>\n </template>\n </DataTableCell>\n </DataTableRow>\n</template>\n"],"mappings":""}
@@ -7,6 +7,7 @@ import DataTableRow_default from "../../../components/data-table/DataTableRow.vu
7
7
  import { getFileName } from "../helpers/files.js";
8
8
  import { validateParameter } from "../helpers/validate-parameter.js";
9
9
  import RequestTableTooltip_default from "./RequestTableTooltip.vue.js";
10
+ import RequestTableFileList_default from "./RequestTableFileList.vue.js";
10
11
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, openBlock, ref, toDisplayString, unref, useTemplateRef, watch, withCtx } from "vue";
11
12
  import { ScalarButton } from "@scalar/components/button";
12
13
  import { ScalarIconGlobe, ScalarIconTrash } from "@scalar/icons";
@@ -14,6 +15,7 @@ import { ScalarIcon } from "@scalar/components/icon";
14
15
  import { ScalarIconButton } from "@scalar/components/icon-button";
15
16
  import { unpackProxyObject } from "@scalar/workspace-store/helpers/unpack-proxy";
16
17
  import { resolve } from "@scalar/workspace-store/resolve";
18
+ import { isArraySchema } from "@scalar/workspace-store/schemas/v3.2/strict/type-guards";
17
19
  import { isFileSchema } from "@scalar/workspace-store/helpers/is-file-schema";
18
20
  //#region src/v2/blocks/request-block/components/RequestTableRow.vue?vue&type=script&setup=true&lang.ts
19
21
  var _hoisted_1 = { class: "text-c-2 flex w-full max-w-[100%] items-center justify-center overflow-hidden p-1" };
@@ -50,6 +52,7 @@ var RequestTableRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
50
52
  "deleteRow",
51
53
  "uploadFile",
52
54
  "removeFile",
55
+ "updateFile",
53
56
  "navigate",
54
57
  "selectPreset"
55
58
  ],
@@ -57,7 +60,11 @@ var RequestTableRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
57
60
  const emit = __emit;
58
61
  const { translate } = useLocalization();
59
62
  const valueInput = useTemplateRef("valueInput");
60
- __expose({ focusValue: () => valueInput.value?.focus() });
63
+ const fileList = useTemplateRef("fileList");
64
+ __expose({ focusValue: () => {
65
+ if (__props.data.files) fileList.value?.focusUpload();
66
+ else valueInput.value?.focus();
67
+ } });
61
68
  const name = ref(__props.data.name ?? "");
62
69
  const value = ref(unpackProxyObject(__props.data.value) ?? "");
63
70
  const isDisabled = ref(__props.data.isDisabled ?? false);
@@ -71,6 +78,8 @@ var RequestTableRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
71
78
  const isFile = computed(() => value.value instanceof File);
72
79
  /** Whether this row’s schema accepts a file part. */
73
80
  const canUploadFile = computed(() => __props.data.schema ? isFileSchema(__props.data.schema, true, __props.data.contentType) : __props.allowUnknownFileUploads);
81
+ const fileUploadLabel = computed(() => translate(__props.data.schema && isArraySchema(__props.data.schema) ? "apiClient.requestTableRow.selectFiles" : "apiClient.requestTableRow.selectFile"));
82
+ const hasMixedFileSelection = computed(() => Boolean(__props.data.files?.some((file) => file.isDisabled) && __props.data.files.some((file) => !file.isDisabled)));
74
83
  /** Display value handles File instances and shows filename instead */
75
84
  const displayValue = computed(() => (isFile.value ? getFileName(value.value) : value.value) ?? "");
76
85
  const defaultValue = computed(() => __props.data.schema?.default);
@@ -134,16 +143,19 @@ var RequestTableRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
134
143
  default: withCtx(() => [
135
144
  createVNode(unref(DataTableCheckbox_default), {
136
145
  ariaLabel: unref(translate)("apiClient.requestTableRow.include", { name: __props.data.name || unref(translate)("apiClient.requestTableRow.row") }),
137
- class: "!border-r",
146
+ class: normalizeClass(["!border-r", { "max-h-none": __props.data.files }]),
138
147
  disabled: __props.hasCheckboxDisabled ?? false,
148
+ indeterminate: hasMixedFileSelection.value,
139
149
  modelValue: !isDisabled.value,
140
150
  "onUpdate:modelValue": _cache[0] || (_cache[0] = (v) => handleUpdateRow({ isDisabled: !v }))
141
151
  }, null, 8, [
142
152
  "ariaLabel",
153
+ "class",
143
154
  "disabled",
155
+ "indeterminate",
144
156
  "modelValue"
145
157
  ]),
146
- createVNode(unref(DataTableCell_default), null, {
158
+ createVNode(unref(DataTableCell_default), { class: normalizeClass({ "max-h-none": __props.data.files }) }, {
147
159
  default: withCtx(() => [createVNode(unref(CodeInputLite_default), {
148
160
  "aria-label": unref(translate)("apiClient.requestTableRow.keyLabel", { name: __props.label ?? "" }),
149
161
  disabled: __props.data.isReadonly,
@@ -164,14 +176,46 @@ var RequestTableRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
164
176
  "required"
165
177
  ])]),
166
178
  _: 1
167
- }),
168
- createVNode(unref(DataTableCell_default), null, {
179
+ }, 8, ["class"]),
180
+ __props.data.files ? (openBlock(), createBlock(unref(DataTableCell_default), {
181
+ key: 0,
182
+ class: "col-span-2 max-h-none",
183
+ colspan: 2
184
+ }, {
185
+ default: withCtx(() => [createVNode(RequestTableFileList_default, {
186
+ ref_key: "fileList",
187
+ ref: fileList,
188
+ disabled: __props.data.isReadonly,
189
+ files: __props.data.files,
190
+ name: name.value,
191
+ onRemoveFile: _cache[4] || (_cache[4] = (index) => emit("removeFile", index)),
192
+ onUpdateFile: _cache[5] || (_cache[5] = (index, disabled) => emit("updateFile", index, disabled)),
193
+ onUploadFile: _cache[6] || (_cache[6] = ($event) => emit("uploadFile"))
194
+ }, {
195
+ default: withCtx(() => [__props.data.schema ? (openBlock(), createBlock(RequestTableTooltip_default, {
196
+ key: 0,
197
+ description: __props.data.description,
198
+ schema: __props.data.schema,
199
+ value: value.value
200
+ }, null, 8, [
201
+ "description",
202
+ "schema",
203
+ "value"
204
+ ])) : createCommentVNode("", true)]),
205
+ _: 1
206
+ }, 8, [
207
+ "disabled",
208
+ "files",
209
+ "name"
210
+ ])]),
211
+ _: 1
212
+ })) : (openBlock(), createBlock(unref(DataTableCell_default), { key: 1 }, {
169
213
  default: withCtx(() => [__props.data.presetOptions?.length ? (openBlock(), createBlock(unref(DataTableInputSelect_default), {
170
214
  key: 0,
171
215
  canAddCustomValue: false,
172
216
  modelValue: displayValue.value,
173
217
  value: __props.data.presetOptions,
174
- "onUpdate:modelValue": _cache[4] || (_cache[4] = (v) => emit("selectPreset", v))
218
+ "onUpdate:modelValue": _cache[7] || (_cache[7] = (v) => emit("selectPreset", v))
175
219
  }, null, 8, ["modelValue", "value"])) : (openBlock(), createBlock(unref(CodeInputLite_default), {
176
220
  key: 1,
177
221
  ref_key: "valueInput",
@@ -189,8 +233,8 @@ var RequestTableRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
189
233
  placeholder: unref(translate)("apiClient.requestTableRow.value"),
190
234
  type: typeValue.value,
191
235
  withFakeData: "",
192
- onNavigate: _cache[7] || (_cache[7] = (route) => emit("navigate", route)),
193
- "onUpdate:modelValue": _cache[8] || (_cache[8] = (v) => handleUpdateRow({ value: v }))
236
+ onNavigate: _cache[10] || (_cache[10] = (route) => emit("navigate", route)),
237
+ "onUpdate:modelValue": _cache[11] || (_cache[11] = (v) => handleUpdateRow({ value: v }))
194
238
  }, {
195
239
  icon: withCtx(() => [
196
240
  Boolean(__props.data.name || value.value) && !__props.data.isRequired && __props.data.isReadonly !== true ? (openBlock(), createBlock(unref(ScalarButton), {
@@ -199,7 +243,7 @@ var RequestTableRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
199
243
  class: "text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 hidden h-fit rounded p-1 group-hover:flex group-has-[.code-input-lite__editor:focus]:flex",
200
244
  size: "sm",
201
245
  variant: "ghost",
202
- onClick: _cache[5] || (_cache[5] = ($event) => emit("deleteRow"))
246
+ onClick: _cache[8] || (_cache[8] = ($event) => emit("deleteRow"))
203
247
  }, {
204
248
  default: withCtx(() => [createVNode(unref(ScalarIconTrash), { class: "size-3.5" })]),
205
249
  _: 1
@@ -212,7 +256,7 @@ var RequestTableRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
212
256
  size: "xs",
213
257
  tooltip: "top",
214
258
  variant: "ghost",
215
- onClick: _cache[6] || (_cache[6] = ($event) => emit("navigate", __props.data.globalRoute))
259
+ onClick: _cache[9] || (_cache[9] = ($event) => emit("navigate", __props.data.globalRoute))
216
260
  }, null, 8, ["icon", "label"])) : createCommentVNode("", true),
217
261
  __props.data.isReadonly ? (openBlock(), createBlock(RequestTableTooltip_default, {
218
262
  key: 2,
@@ -244,9 +288,9 @@ var RequestTableRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
244
288
  "type"
245
289
  ]))]),
246
290
  _: 1
247
- }),
248
- __props.showUploadButton ? (openBlock(), createBlock(unref(DataTableCell_default), {
249
- key: 0,
291
+ })),
292
+ __props.showUploadButton && !__props.data.files ? (openBlock(), createBlock(unref(DataTableCell_default), {
293
+ key: 2,
250
294
  class: "group/upload flex items-center justify-center whitespace-nowrap"
251
295
  }, {
252
296
  default: withCtx(() => [isFile.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("div", _hoisted_1, [createElementVNode("span", {
@@ -255,21 +299,25 @@ var RequestTableRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
255
299
  }, toDisplayString(displayValue.value), 9, _hoisted_2)]), createElementVNode("button", {
256
300
  class: "bg-b-2 mt-1 block rounded p-0.5 text-center text-xs font-medium md:pointer-events-none md:absolute md:inset-x-1 md:top-1/2 md:mt-0 md:-translate-y-1/2 md:opacity-0 md:group-hover/upload:pointer-events-auto md:group-hover/upload:opacity-100",
257
301
  type: "button",
258
- onClick: _cache[9] || (_cache[9] = ($event) => emit("removeFile"))
302
+ onClick: _cache[12] || (_cache[12] = ($event) => emit("removeFile"))
259
303
  }, toDisplayString(unref(translate)("apiClient.requestTableRow.delete")), 1)], 64)) : canUploadFile.value ? (openBlock(), createElementBlock("div", _hoisted_3, [createVNode(unref(ScalarButton), {
304
+ "aria-label": unref(translate)("apiClient.requestTableRow.uploadFor", {
305
+ action: fileUploadLabel.value,
306
+ name: name.value || unref(translate)("apiClient.requestTableRow.row")
307
+ }),
260
308
  class: "bg-b-2 hover:bg-b-3 text-c-2 h-fit border-0 py-px shadow-none",
261
309
  size: "sm",
262
310
  variant: "outlined",
263
- onClick: _cache[10] || (_cache[10] = ($event) => emit("uploadFile"))
311
+ onClick: _cache[13] || (_cache[13] = ($event) => emit("uploadFile"))
264
312
  }, {
265
- default: withCtx(() => [createElementVNode("span", null, toDisplayString(unref(translate)("apiClient.requestTableRow.selectFile")), 1), createVNode(unref(ScalarIcon), {
313
+ default: withCtx(() => [createElementVNode("span", null, toDisplayString(fileUploadLabel.value), 1), createVNode(unref(ScalarIcon), {
266
314
  class: "ml-1",
267
315
  icon: "Upload",
268
316
  size: "xs",
269
317
  thickness: "2.5"
270
318
  })]),
271
319
  _: 1
272
- })])) : createCommentVNode("", true)]),
320
+ }, 8, ["aria-label"])])) : createCommentVNode("", true)]),
273
321
  _: 1
274
322
  })) : createCommentVNode("", true)
275
323
  ]),