@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @scalar/api-client
2
2
 
3
+ ## 3.27.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#9591](https://github.com/scalar/scalar/pull/9591): Select multiple files for array-typed multipart fields and display them in one field with controls to add, remove, and disable individual files. Each enabled file is sent as a separate multipart part under the same field name. Preserve text editing for arrays that also accept text and individual file choices when toggling the field.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#11086](https://github.com/scalar/scalar/pull/11086): Replace the direct TypeBox dependency with `@scalar/validation` for OpenID Connect discovery and OAuth2 metadata parsing.
12
+
13
+ Remove invalid and empty entries from supported grant types in discovery and metadata responses.
14
+ - [#11004](https://github.com/scalar/scalar/pull/11004): Support TypeScript 6 builds and compiler API consumers while preserving runtime output and public handler types. Keep Nuxt build tooling on its supported TypeScript 5 compiler.
15
+ - [#11064](https://github.com/scalar/scalar/pull/11064): Balance schema tooltip spacing, prevent clipped text, hide empty tooltip triggers, and display schema type arrays as readable alternatives.
16
+
3
17
  ## 3.26.0
4
18
 
5
19
  ### Minor Changes
package/dist/style.css CHANGED
@@ -749,6 +749,14 @@
749
749
  border-radius: var(--scalar-radius-xl);
750
750
  }
751
751
 
752
+ :where(.scalar-card.p-1 > .scalar-card-header:first-child:not(:last-child)) {
753
+ margin-block: -2px 2px;
754
+ }
755
+
756
+ :where(.scalar-card.p-1 > .scalar-card-footer:last-child:not(:first-child)) {
757
+ margin-block: 2px -2px;
758
+ }
759
+
752
760
  .scalar-app .hljs-regexp, .scalar-app .hljs-string, .scalar-app .hljs-built_in, .scalar-app .hljs-subst, .scalar-app .hljs-name, .scalar-app .hljs-doctag, .scalar-app .hljs-section, .scalar-app .hljs-title {
753
761
  color: var(--scalar-color-blue);
754
762
  }
@@ -1965,17 +1973,17 @@
1965
1973
  border-radius: var(--scalar-radius);
1966
1974
  }
1967
1975
 
1968
- .request-card[data-v-aaf1efda], .request-card[data-v-3954f074] {
1976
+ .request-card[data-v-aaf1efda], .request-card[data-v-8530ae0b] {
1969
1977
  color: var(--scalar-color-1);
1970
1978
  font-size: var(--scalar-font-size-3);
1971
1979
  }
1972
1980
 
1973
- .request-method[data-v-3954f074] {
1981
+ .request-method[data-v-8530ae0b] {
1974
1982
  font-family: var(--scalar-font-code);
1975
1983
  margin-right: 6px;
1976
1984
  }
1977
1985
 
1978
- .request-card-footer[data-v-3954f074] {
1986
+ .request-card-footer[data-v-8530ae0b] {
1979
1987
  flex-shrink: 0;
1980
1988
  justify-content: flex-end;
1981
1989
  padding: 6px;
@@ -1983,34 +1991,36 @@
1983
1991
  position: relative;
1984
1992
  }
1985
1993
 
1986
- .request-card-footer--wraps[data-v-3954f074] {
1994
+ .request-card-footer--wraps[data-v-8530ae0b] {
1987
1995
  flex-wrap: wrap;
1988
1996
  row-gap: 4px;
1989
1997
  }
1990
1998
 
1991
- .request-card-footer-start[data-v-3954f074] {
1999
+ .request-card-footer-start[data-v-8530ae0b] {
1992
2000
  flex: 1 0 auto;
1993
2001
  align-items: center;
1994
2002
  display: flex;
1995
2003
  }
1996
2004
 
1997
- .request-card-footer-addon[data-v-3954f074] {
1998
- flex: 1;
2005
+ .request-card-footer-addon[data-v-8530ae0b] {
2006
+ flex: 7em;
1999
2007
  align-items: center;
2000
2008
  min-width: 0;
2009
+ max-width: max-content;
2010
+ margin-inline-end: auto;
2001
2011
  display: flex;
2002
2012
  }
2003
2013
 
2004
- .request-editor-section[data-v-3954f074] {
2014
+ .request-editor-section[data-v-8530ae0b] {
2005
2015
  flex: 1;
2006
2016
  display: flex;
2007
2017
  }
2008
2018
 
2009
- .code-snippet > .scalar-code-copy[data-v-3954f074] {
2019
+ .code-snippet > .scalar-code-copy[data-v-8530ae0b] {
2010
2020
  background: var(--scalar-card-surface-raised, var(--scalar-background-2));
2011
2021
  }
2012
2022
 
2013
- .request-card-simple[data-v-3954f074] {
2023
+ .request-card-simple[data-v-8530ae0b] {
2014
2024
  font-size: var(--scalar-small);
2015
2025
  flex-wrap: wrap;
2016
2026
  justify-content: space-between;
@@ -2020,17 +2030,17 @@
2020
2030
  display: flex;
2021
2031
  }
2022
2032
 
2023
- .request-header[data-v-3954f074] {
2033
+ .request-header[data-v-8530ae0b] {
2024
2034
  overflow-wrap: anywhere;
2025
2035
  flex: 999 auto;
2026
2036
  min-width: 0;
2027
2037
  }
2028
2038
 
2029
- .request-card-actions[data-v-3954f074] {
2039
+ .request-card-actions[data-v-8530ae0b] {
2030
2040
  flex: 1 0 auto;
2031
2041
  }
2032
2042
 
2033
- .code-snippet[data-v-3954f074] {
2043
+ .code-snippet[data-v-8530ae0b] {
2034
2044
  flex-direction: column;
2035
2045
  width: 100%;
2036
2046
  display: flex;
@@ -3110,6 +3120,10 @@ code.property-detail-value[data-v-8b57daa7] {
3110
3120
  order: 9999;
3111
3121
  }
3112
3122
 
3123
+ .scalar-app .col-span-2 {
3124
+ grid-column: span 2 / span 2;
3125
+ }
3126
+
3113
3127
  .scalar-app .col-span-full {
3114
3128
  grid-column: 1 / -1;
3115
3129
  }
@@ -3683,6 +3697,10 @@ code.property-detail-value[data-v-8b57daa7] {
3683
3697
  height: 24px;
3684
3698
  }
3685
3699
 
3700
+ .scalar-app .h-7 {
3701
+ height: 28px;
3702
+ }
3703
+
3686
3704
  .scalar-app .h-8 {
3687
3705
  height: 32px;
3688
3706
  }
@@ -3775,6 +3793,10 @@ code.property-detail-value[data-v-8b57daa7] {
3775
3793
  max-height: fit-content;
3776
3794
  }
3777
3795
 
3796
+ .scalar-app .max-h-none {
3797
+ max-height: none;
3798
+ }
3799
+
3778
3800
  .scalar-app .max-h-radix-popper {
3779
3801
  max-height: calc(var(--radix-popper-available-height) - 8px);
3780
3802
  }
@@ -4223,6 +4245,10 @@ code.property-detail-value[data-v-8b57daa7] {
4223
4245
  scroll-margin-top: 96px;
4224
4246
  }
4225
4247
 
4248
+ .scalar-app .list-none {
4249
+ list-style-type: none;
4250
+ }
4251
+
4226
4252
  .scalar-app .appearance-none {
4227
4253
  appearance: none;
4228
4254
  }
@@ -5099,10 +5125,6 @@ code.property-detail-value[data-v-8b57daa7] {
5099
5125
  padding-top: 4px;
5100
5126
  }
5101
5127
 
5102
- .scalar-app .pt-2 {
5103
- padding-top: 8px;
5104
- }
5105
-
5106
5128
  .scalar-app .pt-3 {
5107
5129
  padding-top: 12px;
5108
5130
  }
@@ -5441,7 +5463,15 @@ code.property-detail-value[data-v-8b57daa7] {
5441
5463
  text-wrap: pretty;
5442
5464
  }
5443
5465
 
5444
- .scalar-app .break-words, .scalar-app .wrap-break-word {
5466
+ .scalar-app .break-words {
5467
+ overflow-wrap: break-word;
5468
+ }
5469
+
5470
+ .scalar-app .wrap-anywhere {
5471
+ overflow-wrap: anywhere;
5472
+ }
5473
+
5474
+ .scalar-app .wrap-break-word {
5445
5475
  overflow-wrap: break-word;
5446
5476
  }
5447
5477
 
@@ -6573,7 +6603,16 @@ code.property-detail-value[data-v-8b57daa7] {
6573
6603
  opacity: 1;
6574
6604
  }
6575
6605
 
6576
- .scalar-app .has-\[\:focus-visible\]\:outline:has(:focus-visible), .scalar-app .has-\[input\:focus-visible\]\:outline:has(:is(input:focus-visible)) {
6606
+ .scalar-app .has-\[\:focus-visible\]\:outline:has(:focus-visible) {
6607
+ outline-style: var(--tw-outline-style);
6608
+ outline-width: 1px;
6609
+ }
6610
+
6611
+ .scalar-app .has-\[\:focus-visible\]\:outline-c-accent:has(:focus-visible) {
6612
+ outline-color: var(--scalar-color-accent);
6613
+ }
6614
+
6615
+ .scalar-app .has-\[input\:focus-visible\]\:outline:has(:is(input:focus-visible)) {
6577
6616
  outline-style: var(--tw-outline-style);
6578
6617
  outline-width: 1px;
6579
6618
  }
@@ -6915,10 +6954,6 @@ code.property-detail-value[data-v-8b57daa7] {
6915
6954
  rotate: 90deg;
6916
6955
  }
6917
6956
 
6918
- .scalar-app .ui-open\:rotate-180[data-headlessui-state~="open"], :where([data-headlessui-state~="open"]) :is(.scalar-app .ui-open\:rotate-180) {
6919
- rotate: 180deg;
6920
- }
6921
-
6922
6957
  .scalar-app .last\:ui-open\:border-b-0:last-child[data-headlessui-state~="open"], :where([data-headlessui-state~="open"]) :is(.scalar-app .last\:ui-open\:border-b-0:last-child) {
6923
6958
  border-bottom-style: var(--tw-border-style);
6924
6959
  border-bottom-width: 0;
@@ -7835,16 +7870,16 @@ to {
7835
7870
  background: color-mix(in srgb, var(--scalar-background-3), transparent 40%);
7836
7871
  }
7837
7872
 
7838
- [data-v-321c6212] .code-input-lite__editor {
7873
+ [data-v-81035f01] .code-input-lite__editor {
7839
7874
  background-color: transparent;
7840
7875
  font-family: var(--scalar-font);
7841
7876
  font-size: var(--scalar-small);
7842
7877
  padding: 5px 8px;
7843
7878
  }
7844
- [data-v-321c6212] .scalar-pill:not(:last-of-type) {
7879
+ [data-v-81035f01] .scalar-pill:not(:last-of-type) {
7845
7880
  margin-right: 0.15em;
7846
7881
  }
7847
- [data-v-321c6212] .scalar-pill:not(:first-of-type) {
7882
+ [data-v-81035f01] .scalar-pill:not(:first-of-type) {
7848
7883
  margin-left: 0.5px;
7849
7884
  }
7850
7885
 
@@ -1 +1 @@
1
- {"version":3,"file":"RequestBodyForm.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestBodyForm.vue"],"names":[],"mappings":"AA4MA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAWrE,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI,CAAA;IACzC,6FAA6F;IAC7F,UAAU,CAAC,EAAE,YAAY,CAAA;IACzB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAA;IACtC,wFAAwF;IACxF,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7C,mBAAmB,EAAE,MAAM,CAAA;IAC3B,WAAW,EAAE,kBAAkB,CAAA;CAChC,CAAC;AAyPF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"RequestBodyForm.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestBodyForm.vue"],"names":[],"mappings":"AAiVA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAarE,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI,CAAA;IACzC,6FAA6F;IAC7F,UAAU,CAAC,EAAE,YAAY,CAAA;IACzB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAA;IACtC,wFAAwF;IACxF,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7C,mBAAmB,EAAE,MAAM,CAAA;IAC3B,WAAW,EAAE,kBAAkB,CAAA;CAChC,CAAC;AAoYF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"RequestBodyForm.vue.js","names":["_sfc_main"],"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 { 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'\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\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[]) => {\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,\n payload: Partial<{\n name: string\n value: string | File | undefined\n isDisabled: boolean\n }>,\n) => {\n // Add new row\n if (index >= localFormBodyRows.value.length) {\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 (i !== index) {\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/** Delete a row from the table */\nconst handleDeleteRow = (index: number) => {\n localFormBodyRows.value = localFormBodyRows.value.filter(\n (_, i) => i !== index,\n )\n handleUpdateFormValue(localFormBodyRows.value)\n}\n\n/** Handle file upload for a specific row index */\nconst handleFileUpload = (index: number) => {\n const { open } = useFileDialog({\n onChange: (files) => {\n const file = files?.[0]\n\n if (file) {\n const currentRow = localFormBodyRows.value[index]\n handleUpsertRow(index, {\n name: currentRow?.name || file.name,\n value: file,\n })\n }\n },\n multiple: false,\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=\"localFormBodyRows\"\n deferKeyUpdates\n :environment=\"environment\"\n showUploadButton\n @deleteRow=\"handleDeleteRow\"\n @removeFile=\"(index) => handleUpsertRow(index, { value: undefined })\"\n @uploadFile=\"handleFileUpload\"\n @upsertRow=\"handleUpsertRow\" />\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":""}
1
+ {"version":3,"file":"RequestBodyForm.vue.js","names":["_sfc_main"],"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":""}
@@ -1,7 +1,9 @@
1
1
  import { useFileDialog } from "../../../../hooks/use-file-dialog.js";
2
2
  import RequestTable_default from "./RequestTable.vue.js";
3
3
  import { getFormBodyRows, getFormBodyValue } from "../helpers/get-form-body-rows.js";
4
+ import { groupFormBodyFiles } from "../helpers/group-form-body-files.js";
4
5
  import { computed, createBlock, defineComponent, openBlock, ref, watch } from "vue";
6
+ import { isArraySchema } from "@scalar/workspace-store/schemas/v3.2/strict/type-guards";
5
7
  import { isFileSchema } from "@scalar/workspace-store/helpers/is-file-schema";
6
8
  import { resolveFormSchema } from "@scalar/workspace-store/helpers/resolve-form-schema";
7
9
  //#region src/v2/blocks/request-block/components/RequestBodyForm.vue?vue&type=script&setup=true&lang.ts
@@ -20,6 +22,11 @@ var RequestBodyForm_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
20
22
  const emit = __emit;
21
23
  /** Local state for form body rows */
22
24
  const localFormBodyRows = ref([]);
25
+ const formFields = computed(() => __props.selectedContentType === "multipart/form-data" ? groupFormBodyFiles(localFormBodyRows.value) : localFormBodyRows.value.map((data, index) => ({
26
+ data,
27
+ sourceIndices: [index]
28
+ })));
29
+ const displayedRows = computed(() => formFields.value.map((field) => field.data));
23
30
  /** Sync the local form body rows with the example and schema */
24
31
  watch(() => [
25
32
  __props.example,
@@ -47,7 +54,8 @@ var RequestBodyForm_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
47
54
  };
48
55
  /** Update a row in the table, combines with the previous data so we emit a whole row */
49
56
  const handleUpsertRow = (index, payload) => {
50
- if (index >= localFormBodyRows.value.length) {
57
+ const indices = Array.isArray(index) ? index : [index];
58
+ if (indices[0] !== void 0 && indices[0] >= localFormBodyRows.value.length) {
51
59
  localFormBodyRows.value = [...localFormBodyRows.value, {
52
60
  name: "",
53
61
  value: "",
@@ -58,7 +66,7 @@ var RequestBodyForm_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
58
66
  return;
59
67
  }
60
68
  localFormBodyRows.value = localFormBodyRows.value.map((row, i) => {
61
- if (i !== index) return row;
69
+ if (!indices.includes(i)) return row;
62
70
  const valueChanged = "value" in payload && payload.value !== row.value;
63
71
  const disabledChanged = payload.isDisabled !== void 0 && payload.isDisabled !== row.isDisabled;
64
72
  return {
@@ -70,25 +78,89 @@ var RequestBodyForm_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
70
78
  });
71
79
  handleUpdateFormValue(localFormBodyRows.value);
72
80
  };
81
+ /** Remember individual choices while the whole file field is temporarily disabled. */
82
+ const disabledFileChoices = /* @__PURE__ */ new WeakMap();
83
+ /** Apply field edits to all its parts without replacing sibling files with the first file. */
84
+ const handleFieldUpsert = (index, payload) => {
85
+ const field = formFields.value[index];
86
+ if (field?.data.files?.length && payload.isDisabled !== void 0 && payload.isDisabled !== field.data.isDisabled) {
87
+ localFormBodyRows.value = localFormBodyRows.value.map((row, i) => {
88
+ if (!field.sourceIndices.includes(i) || !(row.value instanceof File)) return row;
89
+ if (payload.isDisabled) disabledFileChoices.set(row.value, row.isDisabled ?? false);
90
+ const isDisabled = payload.isDisabled || (disabledFileChoices.get(row.value) ?? false);
91
+ if (!payload.isDisabled) disabledFileChoices.delete(row.value);
92
+ return {
93
+ ...row,
94
+ isDisabled,
95
+ isDisabledByDefault: false
96
+ };
97
+ });
98
+ handleUpdateFormValue(localFormBodyRows.value);
99
+ return;
100
+ }
101
+ handleUpsertRow(field?.sourceIndices ?? localFormBodyRows.value.length, field?.data.files ? {
102
+ ...payload.name !== void 0 ? { name: payload.name } : {},
103
+ ...payload.isDisabled !== void 0 && payload.isDisabled !== field.data.isDisabled ? { isDisabled: payload.isDisabled } : {}
104
+ } : payload);
105
+ };
73
106
  /** Delete a row from the table */
74
107
  const handleDeleteRow = (index) => {
75
- localFormBodyRows.value = localFormBodyRows.value.filter((_, i) => i !== index);
108
+ const indices = formFields.value[index]?.sourceIndices ?? [index];
109
+ localFormBodyRows.value = localFormBodyRows.value.filter((_, i) => !indices.includes(i));
76
110
  handleUpdateFormValue(localFormBodyRows.value);
77
111
  };
112
+ /** Remove a selected file, retaining one empty field after the last file is removed. */
113
+ const handleRemoveFile = (index, fileIndex) => {
114
+ const field = formFields.value[index];
115
+ const sourceIndex = fileIndex ?? field?.sourceIndices[0] ?? index;
116
+ if (field?.data.files) {
117
+ const remaining = localFormBodyRows.value.filter((row, i) => field.sourceIndices.includes(i) && i !== sourceIndex && row.value instanceof File);
118
+ const original = localFormBodyRows.value[sourceIndex];
119
+ if (!original) return;
120
+ const replacement = remaining.length ? remaining : [{
121
+ ...original,
122
+ value: "[]",
123
+ isArray: true
124
+ }];
125
+ localFormBodyRows.value = localFormBodyRows.value.flatMap((row, i) => {
126
+ if (i === field.sourceIndices[0]) return replacement;
127
+ return field.sourceIndices.includes(i) ? [] : [row];
128
+ });
129
+ handleUpdateFormValue(localFormBodyRows.value);
130
+ return;
131
+ }
132
+ handleUpsertRow(sourceIndex, { value: void 0 });
133
+ };
78
134
  /** Handle file upload for a specific row index */
79
135
  const handleFileUpload = (index) => {
136
+ const field = formFields.value[index];
137
+ const sourceIndices = field?.sourceIndices ?? [localFormBodyRows.value.length];
138
+ const sourceIndex = sourceIndices[0] ?? localFormBodyRows.value.length;
139
+ const currentRow = localFormBodyRows.value[sourceIndex];
140
+ const allowMultiple = Boolean(currentRow?.schema && isArraySchema(currentRow.schema));
80
141
  const { open } = useFileDialog({
81
142
  onChange: (files) => {
82
- const file = files?.[0];
83
- if (file) {
84
- const currentRow = localFormBodyRows.value[index];
85
- handleUpsertRow(index, {
86
- name: currentRow?.name || file.name,
87
- value: file
88
- });
89
- }
143
+ const selected = files ? Array.from(files) : [];
144
+ if (selected.length === 0) return;
145
+ const fieldName = currentRow?.name || selected[0]?.name || "";
146
+ const selectedRows = selected.map((file) => ({
147
+ ...currentRow,
148
+ name: fieldName,
149
+ value: file,
150
+ isDisabled: field?.data.isDisabledByDefault ? false : field?.data.isDisabled ?? false,
151
+ isDisabledByDefault: false
152
+ }));
153
+ const existingFiles = field?.data.files ? localFormBodyRows.value.filter((row, i) => sourceIndices.includes(i) && row.value instanceof File) : [];
154
+ const remaining = localFormBodyRows.value.filter((_, i) => !sourceIndices.includes(i));
155
+ localFormBodyRows.value = [
156
+ ...remaining.slice(0, sourceIndex),
157
+ ...existingFiles,
158
+ ...selectedRows,
159
+ ...remaining.slice(sourceIndex)
160
+ ];
161
+ handleUpdateFormValue(localFormBodyRows.value);
90
162
  },
91
- multiple: false,
163
+ multiple: allowMultiple,
92
164
  accept: "*/*"
93
165
  });
94
166
  open();
@@ -97,14 +169,15 @@ var RequestBodyForm_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
97
169
  return __props.selectedContentType === "multipart/form-data" ? (openBlock(), createBlock(RequestTable_default, {
98
170
  key: 0,
99
171
  allowUnknownFileUploads: allowUnknownFileUploads.value,
100
- data: localFormBodyRows.value,
172
+ data: displayedRows.value,
101
173
  deferKeyUpdates: "",
102
174
  environment: __props.environment,
103
175
  showUploadButton: "",
104
176
  onDeleteRow: handleDeleteRow,
105
- onRemoveFile: _cache[0] || (_cache[0] = (index) => handleUpsertRow(index, { value: void 0 })),
177
+ onRemoveFile: handleRemoveFile,
178
+ onUpdateFile: _cache[0] || (_cache[0] = (index, disabled) => handleUpsertRow(index, { isDisabled: disabled })),
106
179
  onUploadFile: handleFileUpload,
107
- onUpsertRow: handleUpsertRow
180
+ onUpsertRow: handleFieldUpsert
108
181
  }, null, 8, [
109
182
  "allowUnknownFileUploads",
110
183
  "data",
@@ -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 { 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'\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\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[]) => {\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,\n payload: Partial<{\n name: string\n value: string | File | undefined\n isDisabled: boolean\n }>,\n) => {\n // Add new row\n if (index >= localFormBodyRows.value.length) {\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 (i !== index) {\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/** Delete a row from the table */\nconst handleDeleteRow = (index: number) => {\n localFormBodyRows.value = localFormBodyRows.value.filter(\n (_, i) => i !== index,\n )\n handleUpdateFormValue(localFormBodyRows.value)\n}\n\n/** Handle file upload for a specific row index */\nconst handleFileUpload = (index: number) => {\n const { open } = useFileDialog({\n onChange: (files) => {\n const file = files?.[0]\n\n if (file) {\n const currentRow = localFormBodyRows.value[index]\n handleUpsertRow(index, {\n name: currentRow?.name || file.name,\n value: file,\n })\n }\n },\n multiple: false,\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=\"localFormBodyRows\"\n deferKeyUpdates\n :environment=\"environment\"\n showUploadButton\n @deleteRow=\"handleDeleteRow\"\n @removeFile=\"(index) => handleUpsertRow(index, { value: undefined })\"\n @uploadFile=\"handleFileUpload\"\n @upsertRow=\"handleUpsertRow\" />\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":";;;;;;;;;;;;;;;;;;;EAuCA,MAAM,OAAO;;EAQb,MAAM,oBAAoB,IAAgB,CAAC,CAAC;;EAG5C,YAEI;GACE,QAAA;GACA,QAAA;GACA,QAAA;GACA,QAAA;GACA,QAAA;EACF,IACD,CAAC,YAAY,QAAQ,aAAa,WAAW,mBAAmB;GAC/D,kBAAkB,QAAQ,gBACxB,YACA,aACA,QACA,WACA,aACF;EACF,GACA,EAAE,WAAW,KAAK,CACpB;;EAGA,MAAM,0BAA0B,eAAwB;GACtD,MAAM,SAAS,kBAAkB,QAAA,YAAY,QAAA,oBAAoB;GACjE,MAAM,aACJ,UAAU,0BAA0B,SAChC,OAAO,uBACP,KAAA;GACN,OAAO,OAAO,eAAe,WACzB,aAAa,kBAAkB,UAAU,KAAK,EAAE,WAAW,GAAG,CAAC,IAC/D,eAAe;EACrB,CAAC;EAED,MAAM,yBAAyB,SAAqB;GAClD,KACE,oBACA,KAAK,KAAK,SAAS;IACjB,MAAM,IAAI;IACV,OACE,QAAA,wBAAwB,wBACpB,iBAAiB,GAAG,IACnB,IAAI;IACX,YAAY,IAAI,cAAc;IAC9B,GAAI,IAAI,sBAAs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,UAAA,GAAAC,YASiCC,sBAAA;;IAR9B,yBAAyB,wBAAA;IACzB,MAAM,kBAAA;IACP,iBAAA;IACC,aAAa,QAAA;IACd,kBAAA;IACC,aAAW;IACX,cAAU,OAAA,OAAA,OAAA,MAAG,UAAU,gBAAgB,OAAK,EAAA,OAAW,KAAA,EAAS,CAAA;IAChE,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 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,kBA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  focusValue: (index: number) => void;
19
19
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
20
+ removeFile: (index: number, fileIndex?: number | undefined) => any;
20
21
  deleteRow: (index: number) => any;
21
22
  navigate: (route: NonNullable<({
22
23
  replace?: boolean;
@@ -43,11 +44,12 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
43
44
  method: string;
44
45
  documentSlug?: string;
45
46
  })) | undefined>) => any;
46
- upsertRow: (index: number, payload: TableRowUpsertPayload) => any;
47
47
  uploadFile: (index: number) => any;
48
- removeFile: (index: number) => any;
48
+ updateFile: (fileIndex: number, isDisabled: boolean) => any;
49
+ upsertRow: (index: number, payload: TableRowUpsertPayload) => any;
49
50
  selectPreset: (index: number, value: string) => any;
50
51
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
52
+ onRemoveFile?: ((index: number, fileIndex?: number | undefined) => any) | undefined;
51
53
  onDeleteRow?: ((index: number) => any) | undefined;
52
54
  onNavigate?: ((route: NonNullable<({
53
55
  replace?: boolean;
@@ -74,9 +76,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
74
76
  method: string;
75
77
  documentSlug?: string;
76
78
  })) | undefined>) => any) | undefined;
77
- onUpsertRow?: ((index: number, payload: TableRowUpsertPayload) => any) | undefined;
78
79
  onUploadFile?: ((index: number) => any) | undefined;
79
- onRemoveFile?: ((index: number) => any) | undefined;
80
+ onUpdateFile?: ((fileIndex: number, isDisabled: boolean) => any) | undefined;
81
+ onUpsertRow?: ((index: number, payload: TableRowUpsertPayload) => any) | undefined;
80
82
  onSelectPreset?: ((index: number, value: string) => any) | undefined;
81
83
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
82
84
  declare const _default: typeof __VLS_export;
@@ -1 +1 @@
1
- {"version":3,"file":"RequestTable.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestTable.vue"],"names":[],"mappings":"AAsPA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AAGnH,OAAwB,EACtB,KAAK,QAAQ,EACb,KAAK,qBAAqB,EAC3B,MAAM,0DAA0D,CAAA;AAQjE,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,QAAQ,EAAE,CAAA;IAChB,uFAAuF;IACvF,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,8BAA8B;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,kFAAkF;IAClF,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,WAAW,EAAE,kBAAkB,CAAA;CAChC,CAAC;AAuWF,QAAA,MAAM,YAAY;wBA1MI,MAAM,KAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kFA8MjC,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"RequestTable.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestTable.vue"],"names":[],"mappings":"AA0PA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AAGnH,OAAwB,EACtB,KAAK,QAAQ,EACb,KAAK,qBAAqB,EAC3B,MAAM,0DAA0D,CAAA;AAQjE,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,QAAQ,EAAE,CAAA;IAChB,uFAAuF;IACvF,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,8BAA8B;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,kFAAkF;IAClF,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,WAAW,EAAE,kBAAkB,CAAA;CAChC,CAAC;AA4WF,QAAA,MAAM,YAAY;wBA9MI,MAAM,KAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kFAkNjC,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -2,7 +2,7 @@ import _plugin_vue_export_helper_default from "../../../../_virtual/_plugin-vue_
2
2
  import RequestTable_vue_vue_type_script_setup_true_lang_default from "./RequestTable.vue_vue_type_script_setup_true_lang.js";
3
3
  /* empty css */
4
4
  //#region src/v2/blocks/request-block/components/RequestTable.vue
5
- var RequestTable_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RequestTable_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-321c6212"]]);
5
+ var RequestTable_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RequestTable_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-81035f01"]]);
6
6
  //#endregion
7
7
  export { RequestTable_default as default };
8
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"RequestTable.vue.js","names":["_sfc_main"],"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":""}
1
+ {"version":3,"file":"RequestTable.vue.js","names":["_sfc_main"],"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":""}
@@ -29,6 +29,7 @@ var RequestTable_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
29
29
  "deleteRow",
30
30
  "uploadFile",
31
31
  "removeFile",
32
+ "updateFile",
32
33
  "navigate",
33
34
  "selectPreset"
34
35
  ],
@@ -152,8 +153,9 @@ var RequestTable_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
152
153
  showUploadButton: __props.showUploadButton,
153
154
  onDeleteRow: ($event) => emit("deleteRow", index),
154
155
  onNavigate: _cache[0] || (_cache[0] = (route) => emit("navigate", route)),
155
- onRemoveFile: ($event) => emit("removeFile", index),
156
+ onRemoveFile: (...args) => emit("removeFile", index, ...args),
156
157
  onSelectPreset: (value) => emit("selectPreset", index, value),
158
+ onUpdateFile: _cache[1] || (_cache[1] = (fileIndex, disabled) => emit("updateFile", fileIndex, disabled)),
157
159
  onUploadFile: ($event) => emit("uploadFile", index),
158
160
  onUpsertRow: (payload) => handleUpsertRow(row, index, payload)
159
161
  }, null, 8, [