@datagouv/components-next 1.0.2-dev.11 → 1.0.2-dev.111
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.
- package/assets/main.css +4 -0
- package/dist/{Control-DuZJdKV_.js → Control-ZFh5ta_U.js} +1 -1
- package/dist/{Datafair.client-8haHXl47.js → Datafair.client-CKB2P_X1.js} +1 -1
- package/dist/{Event--kp8kMdJ.js → Event-DSQcW7OF.js} +24 -24
- package/dist/{Image-34hvypZI.js → Image-BijNEG0p.js} +6 -6
- package/dist/JsonPreview.client-Bx11-jfT.js +40 -0
- package/dist/{Map-BjUnLyj8.js → Map-BUtPf5GN.js} +756 -756
- package/dist/{MapContainer.client-l6HuXTHR.js → MapContainer.client-CdZSeT_L.js} +37 -38
- package/dist/{OSM-s40W6sQ2.js → OSM-D4MTdBtk.js} +2 -2
- package/dist/{PdfPreview.client-4OueK-2Z.js → PdfPreview.client-Bh9lP-qU.js} +822 -850
- package/dist/{Pmtiles.client-4j3VTYkz.js → Pmtiles.client-Bi46wN14.js} +1 -1
- package/dist/PreviewWrapper.vue_vue_type_script_setup_true_lang-BnC7vWGP.js +61 -0
- package/dist/{ScaleLine-KW-nXqp3.js → ScaleLine-hJQIqcZm.js} +2 -2
- package/dist/{Tile-DbNFNPfU.js → Tile-Dcl7oIVu.js} +35 -35
- package/dist/{TileImage-BsXBxMtq.js → TileImage-BJeHipMX.js} +4 -4
- package/dist/{View-BR92hTWP.js → View-xp_P_OHw.js} +412 -401
- package/dist/XmlPreview.client-oFAOv828.js +34 -0
- package/dist/{common-PJfpC179.js → common-BjQlan3k.js} +36 -36
- package/dist/components-next.css +6 -6
- package/dist/components-next.js +165 -142
- package/dist/components.css +1 -1
- package/dist/{index-CVTIoZQ0.js → index-CxCuKQ81.js} +32886 -27183
- package/dist/main-CQ9ZQG7n.js +73607 -0
- package/dist/{proj-DsetBcW7.js → proj-CsNo9yH1.js} +532 -512
- package/dist/{tilecoord-Db24Px13.js → tilecoord-A0fLnBZr.js} +28 -28
- package/dist/{vue3-xml-viewer.common-CWer_T5-.js → vue3-xml-viewer.common-B9qp90K_.js} +1 -1
- package/package.json +25 -11
- package/src/chart.ts +5 -0
- package/src/components/ActivityList/ActivityList.vue +3 -2
- package/src/components/Chart/ChartViewer.vue +226 -0
- package/src/components/Chart/ChartViewerWrapper.vue +170 -0
- package/src/components/DataserviceCard.vue +3 -0
- package/src/components/DatasetCard.vue +9 -4
- package/src/components/Form/Listbox.vue +101 -0
- package/src/components/Form/SearchableSelect.vue +2 -1
- package/src/components/InfiniteLoader.vue +53 -0
- package/src/components/ObjectCardHeader.vue +11 -4
- package/src/components/OpenApiViewer/ContentTypeSelect.vue +48 -0
- package/src/components/OpenApiViewer/EndpointRequest.vue +164 -0
- package/src/components/OpenApiViewer/EndpointResponses.vue +149 -0
- package/src/components/OpenApiViewer/OpenApiViewer.vue +308 -0
- package/src/components/OpenApiViewer/SchemaPanel.vue +53 -0
- package/src/components/OpenApiViewer/SchemaTree.vue +77 -0
- package/src/components/OpenApiViewer/openapi.ts +150 -0
- package/src/components/OrganizationNameWithCertificate.vue +3 -2
- package/src/components/Pagination.vue +8 -5
- package/src/components/RadioInput.vue +7 -2
- package/src/components/ReadMore.vue +1 -1
- package/src/components/ResourceAccordion/DataStructure.vue +11 -33
- package/src/components/ResourceAccordion/Downloads.vue +160 -0
- package/src/components/ResourceAccordion/JsonPreview.client.vue +23 -104
- package/src/components/ResourceAccordion/MapContainer.client.vue +1 -3
- package/src/components/ResourceAccordion/Metadata.vue +1 -2
- package/src/components/ResourceAccordion/PdfPreview.client.vue +24 -87
- package/src/components/ResourceAccordion/Preview.vue +11 -11
- package/src/components/ResourceAccordion/PreviewWrapper.vue +82 -0
- package/src/components/ResourceAccordion/ResourceAccordion.vue +11 -110
- package/src/components/ResourceAccordion/XmlPreview.client.vue +16 -98
- package/src/components/ResourceExplorer/ResourceExplorer.vue +14 -10
- package/src/components/ResourceExplorer/ResourceExplorerSidebar.vue +2 -2
- package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +50 -148
- package/src/components/ResourceExplorer/ResourceSelector.vue +113 -0
- package/src/components/ReuseCard.vue +12 -4
- package/src/components/Search/GlobalSearch.vue +201 -113
- package/src/components/Search/SearchInput.vue +5 -4
- package/src/components/TabularExplorer/TabularCell.vue +51 -0
- package/src/components/TabularExplorer/TabularCellPopover.vue +170 -0
- package/src/components/TabularExplorer/TabularExplorer.vue +973 -0
- package/src/components/TabularExplorer/TabularFilterContent.vue +351 -0
- package/src/components/TabularExplorer/TabularFilterPopover.vue +111 -0
- package/src/components/TabularExplorer/types.ts +83 -0
- package/src/composables/useHasTabularData.ts +13 -0
- package/src/composables/useMetrics.ts +1 -1
- package/src/composables/useResourceCapabilities.ts +1 -1
- package/src/composables/useSearchFilter.ts +118 -0
- package/src/composables/useStableQueryParams.ts +38 -6
- package/src/composables/useTabularProfile.ts +70 -0
- package/src/config.ts +20 -3
- package/src/functions/activities.ts +3 -3
- package/src/functions/api.ts +9 -37
- package/src/functions/api.types.ts +1 -0
- package/src/functions/charts.ts +68 -0
- package/src/functions/datasets.ts +0 -17
- package/src/functions/metrics.ts +6 -4
- package/src/functions/resources.ts +56 -1
- package/src/functions/tabular.ts +60 -0
- package/src/functions/tabularApi.ts +138 -11
- package/src/main.ts +90 -9
- package/src/types/dataservices.ts +2 -0
- package/src/types/pages.ts +0 -5
- package/src/types/posts.ts +2 -2
- package/src/types/reports.ts +5 -1
- package/src/types/search.ts +63 -1
- package/src/types/site.ts +5 -3
- package/src/types/ui.ts +2 -0
- package/src/types/users.ts +2 -1
- package/src/types/visualizations.ts +89 -0
- package/assets/swagger-themes/newspaper.css +0 -1670
- package/dist/JsonPreview.client-D53pj9Cw.js +0 -72
- package/dist/Swagger.client-DPBmsH9q.js +0 -4
- package/dist/XmlPreview.client-XElkoA4F.js +0 -64
- package/dist/main-BbT-LUXy.js +0 -105854
- package/src/components/ResourceAccordion/Swagger.client.vue +0 -48
- package/src/functions/pagination.ts +0 -9
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
:icon="RiDatabase2Line"
|
|
37
37
|
:url="datasetUrl || dataset.page"
|
|
38
38
|
:target="datasetUrlInNewTab ? '_blank' : undefined"
|
|
39
|
+
:title-tag="titleTag"
|
|
39
40
|
>
|
|
40
41
|
{{ dataset.title }}
|
|
41
42
|
<template
|
|
@@ -106,10 +107,12 @@
|
|
|
106
107
|
</p>
|
|
107
108
|
</div>
|
|
108
109
|
</div>
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
<slot>
|
|
111
|
+
<ObjectCardShortDescription
|
|
112
|
+
v-if="showDescriptionShort"
|
|
113
|
+
:text="getDescriptionShort(props.dataset)"
|
|
114
|
+
/>
|
|
115
|
+
</slot>
|
|
113
116
|
</ObjectCard>
|
|
114
117
|
</template>
|
|
115
118
|
|
|
@@ -117,6 +120,7 @@
|
|
|
117
120
|
import type { RouteLocationRaw } from 'vue-router'
|
|
118
121
|
import { RiArchiveLine, RiDatabase2Line, RiDownloadLine, RiEyeLine, RiLineChartLine, RiLockLine, RiStarLine, RiSubtractLine } from '@remixicon/vue'
|
|
119
122
|
import type { Dataset, DatasetV2 } from '../types/datasets'
|
|
123
|
+
import type { TitleTag } from '../types/ui'
|
|
120
124
|
import { summarize } from '../functions/helpers'
|
|
121
125
|
import { useFormatDate } from '../functions/dates'
|
|
122
126
|
import { getDescriptionShort } from '../functions/description'
|
|
@@ -137,6 +141,7 @@ type Props = {
|
|
|
137
141
|
datasetUrlInNewTab?: boolean
|
|
138
142
|
organizationUrl?: RouteLocationRaw
|
|
139
143
|
showDescriptionShort?: boolean
|
|
144
|
+
titleTag?: TitleTag
|
|
140
145
|
}
|
|
141
146
|
|
|
142
147
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Listbox v-model="model">
|
|
3
|
+
<div class="relative min-w-0">
|
|
4
|
+
<div
|
|
5
|
+
ref="floatingReference"
|
|
6
|
+
class="relative w-full cursor-default overflow-hidden bg-white text-left shadow-md focus:outline-none focus-visible:ring-2 focus-visible:ring-white/75 focus-visible:ring-offset-2 focus-visible:ring-offset-teal-300 sm:text-sm"
|
|
7
|
+
>
|
|
8
|
+
<ListboxButton class="input shadow-input text-sm flex items-center gap-2">
|
|
9
|
+
<slot name="button">
|
|
10
|
+
<div class="w-full flex items-center justify-between gap-2">
|
|
11
|
+
<div
|
|
12
|
+
class="truncate"
|
|
13
|
+
:class="{ 'text-new-disabled-text': isDisabled(model) }"
|
|
14
|
+
>
|
|
15
|
+
{{ displayValue(model) }}
|
|
16
|
+
</div>
|
|
17
|
+
<RiArrowDownSLine class="flex-none size-4 justify-self-end" />
|
|
18
|
+
</div>
|
|
19
|
+
</slot>
|
|
20
|
+
</ListboxButton>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<ListboxOptions
|
|
24
|
+
ref="popover"
|
|
25
|
+
:style="floatingStyles"
|
|
26
|
+
class="z-10 mt-1 absolute max-h-60 min-w-80 w-full overflow-auto rounded-md bg-white text-base shadow-lg ring-1 ring-black/5 focus:outline-none sm:text-sm pl-0"
|
|
27
|
+
>
|
|
28
|
+
<ListboxOption
|
|
29
|
+
v-for="option in options"
|
|
30
|
+
:key="getOptionId(toValue(option))"
|
|
31
|
+
v-slot="{ active, selected }"
|
|
32
|
+
as="template"
|
|
33
|
+
:value="option"
|
|
34
|
+
>
|
|
35
|
+
<li
|
|
36
|
+
class="relative cursor-default select-none py-2 pr-4 list-none flex items-center gap-2 text-gray-900"
|
|
37
|
+
:class="{
|
|
38
|
+
'bg-gray-lower': active && !isDisabled(toValue(option)),
|
|
39
|
+
'text-new-disabled-text': isDisabled(toValue(option)),
|
|
40
|
+
'pl-2': selected,
|
|
41
|
+
'pl-6': !selected,
|
|
42
|
+
}"
|
|
43
|
+
>
|
|
44
|
+
<div class="flex items-center justify-center aspect-square">
|
|
45
|
+
<RiCheckLine
|
|
46
|
+
v-if="selected"
|
|
47
|
+
class="size-4"
|
|
48
|
+
:class="isDisabled(toValue(option)) ?' text-new-disabled-text' : 'text-new-primary'"
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
<slot
|
|
52
|
+
name="option"
|
|
53
|
+
v-bind="{ option, active }"
|
|
54
|
+
>
|
|
55
|
+
{{ displayValue(option) }}
|
|
56
|
+
</slot>
|
|
57
|
+
</li>
|
|
58
|
+
</ListboxOption>
|
|
59
|
+
</ListboxOptions>
|
|
60
|
+
</div>
|
|
61
|
+
</Listbox>
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<script setup lang="ts" generic="T extends string | number | object">
|
|
65
|
+
import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from '@headlessui/vue'
|
|
66
|
+
import { useFloating, autoUpdate, autoPlacement } from '@floating-ui/vue'
|
|
67
|
+
import { toValue, useTemplateRef } from 'vue'
|
|
68
|
+
import { RiArrowDownSLine, RiCheckLine } from '@remixicon/vue'
|
|
69
|
+
|
|
70
|
+
withDefaults(defineProps<{
|
|
71
|
+
options?: Array<T>
|
|
72
|
+
getOptionId?: (option: T) => string | number
|
|
73
|
+
displayValue: (option: T | null) => string
|
|
74
|
+
isDisabled?: (option: T | null) => boolean
|
|
75
|
+
}>(), {
|
|
76
|
+
getOptionId: (option: T): string | number => {
|
|
77
|
+
if (typeof option === 'string') return option
|
|
78
|
+
if (typeof option === 'number') return option
|
|
79
|
+
if (typeof option === 'object' && 'id' in option) return option.id as string
|
|
80
|
+
|
|
81
|
+
throw new Error('Please set getOptionId()')
|
|
82
|
+
},
|
|
83
|
+
isDisabled: (option: T | null): boolean => {
|
|
84
|
+
if (option && typeof option === 'object' && 'disabled' in option) return option.disabled as boolean
|
|
85
|
+
|
|
86
|
+
return false
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const model = defineModel<T | null>({ required: true })
|
|
91
|
+
|
|
92
|
+
const referenceRef = useTemplateRef('floatingReference')
|
|
93
|
+
const floatingRef = useTemplateRef<InstanceType<typeof ListboxOptions>>('popover')
|
|
94
|
+
const { floatingStyles } = useFloating(referenceRef, floatingRef, {
|
|
95
|
+
middleware: [autoPlacement({
|
|
96
|
+
allowedPlacements: ['bottom-start', 'bottom', 'bottom-end'],
|
|
97
|
+
crossAxis: true,
|
|
98
|
+
})],
|
|
99
|
+
whileElementsMounted: autoUpdate,
|
|
100
|
+
})
|
|
101
|
+
</script>
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
:class="{ 'sr-only': hideLabel }"
|
|
11
11
|
>
|
|
12
12
|
{{ label }}
|
|
13
|
+
<!-- $props needed: in generic components, vue-tsc resolves `required` to the Nuxt auto-imported function instead of the prop -->
|
|
13
14
|
<span
|
|
14
|
-
v-if="required"
|
|
15
|
+
v-if="$props.required"
|
|
15
16
|
class="text-new-primary"
|
|
16
17
|
>*</span>
|
|
17
18
|
<span
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="sentinel">
|
|
3
|
+
<slot>
|
|
4
|
+
<div class="flex items-center justify-center p-4">
|
|
5
|
+
<span class="inline-flex items-center gap-2 text-xs text-gray-medium">
|
|
6
|
+
<RiLoader4Line
|
|
7
|
+
class="size-4 animate-spin"
|
|
8
|
+
aria-hidden="true"
|
|
9
|
+
/>
|
|
10
|
+
{{ t('Chargement…') }}
|
|
11
|
+
</span>
|
|
12
|
+
</div>
|
|
13
|
+
</slot>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import { onMounted, onUnmounted, useTemplateRef, watch } from 'vue'
|
|
19
|
+
import { RiLoader4Line } from '@remixicon/vue'
|
|
20
|
+
import { useTranslation } from '../composables/useTranslation'
|
|
21
|
+
|
|
22
|
+
const props = defineProps<{
|
|
23
|
+
root?: HTMLElement | null
|
|
24
|
+
}>()
|
|
25
|
+
|
|
26
|
+
const emit = defineEmits<{
|
|
27
|
+
intersect: []
|
|
28
|
+
}>()
|
|
29
|
+
|
|
30
|
+
const { t } = useTranslation()
|
|
31
|
+
|
|
32
|
+
const sentinelRef = useTemplateRef<HTMLElement>('sentinel')
|
|
33
|
+
let observer: IntersectionObserver | null = null
|
|
34
|
+
|
|
35
|
+
function setupObserver() {
|
|
36
|
+
observer?.disconnect()
|
|
37
|
+
const el = sentinelRef.value
|
|
38
|
+
if (!el) return
|
|
39
|
+
observer = new IntersectionObserver(
|
|
40
|
+
(entries) => {
|
|
41
|
+
if (entries[0]?.isIntersecting) {
|
|
42
|
+
emit('intersect')
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{ root: props.root ?? null, rootMargin: '200px' },
|
|
46
|
+
)
|
|
47
|
+
observer.observe(el)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
onMounted(setupObserver)
|
|
51
|
+
watch([sentinelRef, () => props.root], setupObserver)
|
|
52
|
+
onUnmounted(() => observer?.disconnect())
|
|
53
|
+
</script>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<component
|
|
3
|
+
:is="titleTag"
|
|
4
|
+
class="w-full text-base font-bold flex"
|
|
5
|
+
>
|
|
3
6
|
<AppLink
|
|
4
7
|
:to="url"
|
|
5
8
|
class="text-gray-title text-base bg-none flex items-center w-full truncate gap-1"
|
|
@@ -19,17 +22,21 @@
|
|
|
19
22
|
<slot name="extra" />
|
|
20
23
|
<span class="absolute inset-0" />
|
|
21
24
|
</AppLink>
|
|
22
|
-
</
|
|
25
|
+
</component>
|
|
23
26
|
</template>
|
|
24
27
|
|
|
25
28
|
<script setup lang="ts">
|
|
26
29
|
import type { Component } from 'vue'
|
|
27
30
|
import type { RouteLocationRaw } from 'vue-router'
|
|
31
|
+
import type { TitleTag } from '../types/ui'
|
|
28
32
|
import AppLink from './AppLink.vue'
|
|
29
33
|
|
|
30
|
-
defineProps<{
|
|
34
|
+
withDefaults(defineProps<{
|
|
31
35
|
icon: Component
|
|
32
36
|
url: RouteLocationRaw
|
|
33
37
|
target?: string
|
|
34
|
-
|
|
38
|
+
titleTag?: TitleTag
|
|
39
|
+
}>(), {
|
|
40
|
+
titleTag: 'h3',
|
|
41
|
+
})
|
|
35
42
|
</script>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Tooltip v-if="contentTypes.length > 1">
|
|
3
|
+
<div class="relative shrink-0">
|
|
4
|
+
<select
|
|
5
|
+
:value="modelValue"
|
|
6
|
+
class="appearance-none text-xs font-mono bg-white border border-gray-default rounded pl-2 pr-6 py-1 text-gray-medium cursor-pointer hover:border-gray-400 transition-colors"
|
|
7
|
+
@change="$emit('update:modelValue', ($event.target as HTMLSelectElement).value)"
|
|
8
|
+
>
|
|
9
|
+
<option
|
|
10
|
+
v-for="ct in contentTypes"
|
|
11
|
+
:key="ct"
|
|
12
|
+
:value="ct"
|
|
13
|
+
>
|
|
14
|
+
{{ contentTypeLabel(ct) }}
|
|
15
|
+
</option>
|
|
16
|
+
</select>
|
|
17
|
+
<RiArrowDownSLine class="pointer-events-none absolute right-1 top-1/2 -translate-y-1/2 size-3.5 text-gray-medium" />
|
|
18
|
+
</div>
|
|
19
|
+
<template #tooltip>
|
|
20
|
+
{{ modelValue }}
|
|
21
|
+
</template>
|
|
22
|
+
</Tooltip>
|
|
23
|
+
<Tooltip v-else-if="contentTypes.length === 1">
|
|
24
|
+
<span
|
|
25
|
+
class="text-xs font-mono bg-white border border-gray-default rounded px-2 py-1 text-gray-medium shrink-0"
|
|
26
|
+
>
|
|
27
|
+
{{ contentTypeLabel(contentTypes[0]!) }}
|
|
28
|
+
</span>
|
|
29
|
+
<template #tooltip>
|
|
30
|
+
{{ contentTypes[0] }}
|
|
31
|
+
</template>
|
|
32
|
+
</Tooltip>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup lang="ts">
|
|
36
|
+
import { RiArrowDownSLine } from '@remixicon/vue'
|
|
37
|
+
import Tooltip from '../Tooltip.vue'
|
|
38
|
+
import { contentTypeLabel } from './openapi'
|
|
39
|
+
|
|
40
|
+
defineProps<{
|
|
41
|
+
contentTypes: string[]
|
|
42
|
+
modelValue: string
|
|
43
|
+
}>()
|
|
44
|
+
|
|
45
|
+
defineEmits<{
|
|
46
|
+
'update:modelValue': [value: string]
|
|
47
|
+
}>()
|
|
48
|
+
</script>
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="border border-gray-default rounded">
|
|
3
|
+
<div
|
|
4
|
+
v-if="!tabs.length"
|
|
5
|
+
class="p-3 text-xs text-gray-medium"
|
|
6
|
+
>
|
|
7
|
+
{{ t("Aucun paramètre de requête") }}
|
|
8
|
+
</div>
|
|
9
|
+
<TabGroup
|
|
10
|
+
v-else
|
|
11
|
+
size="sm"
|
|
12
|
+
@change="onTabChange"
|
|
13
|
+
>
|
|
14
|
+
<div class="bg-gray-100 px-3 py-2 border-b border-gray-default flex items-center justify-between gap-2">
|
|
15
|
+
<TabList>
|
|
16
|
+
<Tab
|
|
17
|
+
v-for="tab in tabs"
|
|
18
|
+
:key="tab.key"
|
|
19
|
+
>
|
|
20
|
+
{{ tab.label }}
|
|
21
|
+
</Tab>
|
|
22
|
+
</TabList>
|
|
23
|
+
<ContentTypeSelect
|
|
24
|
+
v-if="activeTab === 'body' && bodyContentTypes.length"
|
|
25
|
+
:content-types="bodyContentTypes"
|
|
26
|
+
:model-value="selectedBodyContentType"
|
|
27
|
+
@update:model-value="selectedBodyContentType = $event"
|
|
28
|
+
/>
|
|
29
|
+
</div>
|
|
30
|
+
<TabPanels>
|
|
31
|
+
<TabPanel
|
|
32
|
+
v-for="tab in tabs"
|
|
33
|
+
:key="tab.key"
|
|
34
|
+
>
|
|
35
|
+
<div
|
|
36
|
+
v-if="tab.key === 'query'"
|
|
37
|
+
class="p-3"
|
|
38
|
+
>
|
|
39
|
+
<div class="space-y-0 divide-y divide-gray-100">
|
|
40
|
+
<div
|
|
41
|
+
v-for="param in queryParams"
|
|
42
|
+
:key="param.name"
|
|
43
|
+
class="py-2"
|
|
44
|
+
>
|
|
45
|
+
<div class="flex items-baseline gap-2">
|
|
46
|
+
<span class="font-mono text-xs text-gray-title">
|
|
47
|
+
{{ param.name }}
|
|
48
|
+
<span
|
|
49
|
+
v-if="param.required"
|
|
50
|
+
class="text-red-600"
|
|
51
|
+
>*</span>
|
|
52
|
+
</span>
|
|
53
|
+
<span class="font-mono text-xs text-gray-medium">{{ getSchemaType(endpoint.spec, param.schema) }}</span>
|
|
54
|
+
</div>
|
|
55
|
+
<p
|
|
56
|
+
v-if="param.description"
|
|
57
|
+
class="text-xs text-gray-medium mt-0.5 mb-0"
|
|
58
|
+
>
|
|
59
|
+
{{ param.description }}
|
|
60
|
+
</p>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
<div
|
|
65
|
+
v-if="tab.key === 'path'"
|
|
66
|
+
class="p-3"
|
|
67
|
+
>
|
|
68
|
+
<div class="space-y-0 divide-y divide-gray-100">
|
|
69
|
+
<div
|
|
70
|
+
v-for="param in pathParams"
|
|
71
|
+
:key="param.name"
|
|
72
|
+
class="py-2"
|
|
73
|
+
>
|
|
74
|
+
<div class="flex items-baseline gap-2">
|
|
75
|
+
<span class="font-mono text-xs text-gray-title">
|
|
76
|
+
{{ param.name }}
|
|
77
|
+
<span class="text-red-600">*</span>
|
|
78
|
+
</span>
|
|
79
|
+
<span class="font-mono text-xs text-gray-medium">{{ getSchemaType(endpoint.spec, param.schema) }}</span>
|
|
80
|
+
</div>
|
|
81
|
+
<p
|
|
82
|
+
v-if="param.description"
|
|
83
|
+
class="text-xs text-gray-medium mt-0.5 mb-0"
|
|
84
|
+
>
|
|
85
|
+
{{ param.description }}
|
|
86
|
+
</p>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
<div
|
|
91
|
+
v-if="tab.key === 'body'"
|
|
92
|
+
class="p-3"
|
|
93
|
+
>
|
|
94
|
+
<SchemaPanel
|
|
95
|
+
v-if="currentBodyMediaType?.schema"
|
|
96
|
+
:spec="endpoint.spec"
|
|
97
|
+
:schema="currentBodyMediaType.schema"
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
</TabPanel>
|
|
101
|
+
</TabPanels>
|
|
102
|
+
</TabGroup>
|
|
103
|
+
</div>
|
|
104
|
+
</template>
|
|
105
|
+
|
|
106
|
+
<script setup lang="ts">
|
|
107
|
+
import { computed, ref, watch } from 'vue'
|
|
108
|
+
import TabGroup from '../Tabs/TabGroup.vue'
|
|
109
|
+
import TabList from '../Tabs/TabList.vue'
|
|
110
|
+
import Tab from '../Tabs/Tab.vue'
|
|
111
|
+
import TabPanels from '../Tabs/TabPanels.vue'
|
|
112
|
+
import TabPanel from '../Tabs/TabPanel.vue'
|
|
113
|
+
import ContentTypeSelect from './ContentTypeSelect.vue'
|
|
114
|
+
import { useTranslation } from '../../composables/useTranslation'
|
|
115
|
+
import SchemaPanel from './SchemaPanel.vue'
|
|
116
|
+
import { getSchemaType, type Endpoint } from './openapi'
|
|
117
|
+
|
|
118
|
+
const props = defineProps<{
|
|
119
|
+
endpoint: Endpoint
|
|
120
|
+
}>()
|
|
121
|
+
|
|
122
|
+
const { t } = useTranslation()
|
|
123
|
+
|
|
124
|
+
const queryParams = computed(() => props.endpoint.parameters.filter(p => p.in === 'query'))
|
|
125
|
+
const pathParams = computed(() => props.endpoint.parameters.filter(p => p.in === 'path'))
|
|
126
|
+
|
|
127
|
+
const tabs = computed(() => {
|
|
128
|
+
const result: { key: string, label: string }[] = []
|
|
129
|
+
if (pathParams.value.length) {
|
|
130
|
+
result.push({ key: 'path', label: t('Path') })
|
|
131
|
+
}
|
|
132
|
+
if (queryParams.value.length) {
|
|
133
|
+
result.push({ key: 'query', label: t('Query') })
|
|
134
|
+
}
|
|
135
|
+
if (props.endpoint.requestBody) {
|
|
136
|
+
result.push({ key: 'body', label: t('Body') })
|
|
137
|
+
}
|
|
138
|
+
return result
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
const activeTabIndex = ref(0)
|
|
142
|
+
const activeTab = computed(() => tabs.value[activeTabIndex.value]?.key || '')
|
|
143
|
+
const selectedBodyContentType = ref('')
|
|
144
|
+
|
|
145
|
+
const bodyContentTypes = computed(() => {
|
|
146
|
+
if (!props.endpoint.requestBody?.content) return []
|
|
147
|
+
return Object.keys(props.endpoint.requestBody.content)
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
const currentBodyMediaType = computed(() => {
|
|
151
|
+
if (!props.endpoint.requestBody?.content) return null
|
|
152
|
+
const ct = selectedBodyContentType.value || bodyContentTypes.value[0]
|
|
153
|
+
if (!ct) return null
|
|
154
|
+
return props.endpoint.requestBody.content[ct] || null
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
watch(bodyContentTypes, (types) => {
|
|
158
|
+
selectedBodyContentType.value = types[0] || ''
|
|
159
|
+
}, { immediate: true })
|
|
160
|
+
|
|
161
|
+
function onTabChange(index: number) {
|
|
162
|
+
activeTabIndex.value = index
|
|
163
|
+
}
|
|
164
|
+
</script>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="border border-gray-default rounded">
|
|
3
|
+
<TabGroup
|
|
4
|
+
size="sm"
|
|
5
|
+
@change="onTabChange"
|
|
6
|
+
>
|
|
7
|
+
<div class="bg-gray-100 px-3 py-2 border-b border-gray-default flex items-center gap-4">
|
|
8
|
+
<div
|
|
9
|
+
ref="tabListContainer"
|
|
10
|
+
class="overflow-x-auto flex-1 min-w-0"
|
|
11
|
+
:class="{ 'scroll-fade': canScrollRight }"
|
|
12
|
+
@scroll="onScroll"
|
|
13
|
+
>
|
|
14
|
+
<TabList>
|
|
15
|
+
<Tab
|
|
16
|
+
v-for="tab in tabs"
|
|
17
|
+
:key="tab.code"
|
|
18
|
+
>
|
|
19
|
+
<span
|
|
20
|
+
class="inline-block w-2 h-2 rounded-full mr-1.5"
|
|
21
|
+
:class="statusDotColor(tab.code)"
|
|
22
|
+
/>
|
|
23
|
+
{{ tab.code }}
|
|
24
|
+
</Tab>
|
|
25
|
+
</TabList>
|
|
26
|
+
</div>
|
|
27
|
+
<ContentTypeSelect
|
|
28
|
+
v-if="currentContentTypes.length"
|
|
29
|
+
:content-types="currentContentTypes"
|
|
30
|
+
:model-value="selectedContentType"
|
|
31
|
+
@update:model-value="selectedContentType = $event"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
<TabPanels>
|
|
35
|
+
<TabPanel
|
|
36
|
+
v-for="tab in tabs"
|
|
37
|
+
:key="tab.code"
|
|
38
|
+
>
|
|
39
|
+
<div class="p-3 space-y-3">
|
|
40
|
+
<p
|
|
41
|
+
v-if="tab.response.description"
|
|
42
|
+
class="text-xs text-gray-medium mb-0 pb-3 border-b border-gray-100"
|
|
43
|
+
>
|
|
44
|
+
{{ tab.response.description }}
|
|
45
|
+
</p>
|
|
46
|
+
<template v-if="currentMediaType?.schema">
|
|
47
|
+
<SchemaPanel
|
|
48
|
+
:spec="spec"
|
|
49
|
+
:schema="currentMediaType.schema"
|
|
50
|
+
/>
|
|
51
|
+
</template>
|
|
52
|
+
<p
|
|
53
|
+
v-else-if="!tab.response.content"
|
|
54
|
+
class="text-xs text-gray-medium mb-0"
|
|
55
|
+
>
|
|
56
|
+
{{ t("Pas de contenu") }}
|
|
57
|
+
</p>
|
|
58
|
+
</div>
|
|
59
|
+
</TabPanel>
|
|
60
|
+
</TabPanels>
|
|
61
|
+
</TabGroup>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<script setup lang="ts">
|
|
66
|
+
import { computed, ref, watch, useTemplateRef, onMounted, nextTick } from 'vue'
|
|
67
|
+
import TabGroup from '../Tabs/TabGroup.vue'
|
|
68
|
+
import TabList from '../Tabs/TabList.vue'
|
|
69
|
+
import Tab from '../Tabs/Tab.vue'
|
|
70
|
+
import TabPanels from '../Tabs/TabPanels.vue'
|
|
71
|
+
import TabPanel from '../Tabs/TabPanel.vue'
|
|
72
|
+
import ContentTypeSelect from './ContentTypeSelect.vue'
|
|
73
|
+
import { useTranslation } from '../../composables/useTranslation'
|
|
74
|
+
import SchemaPanel from './SchemaPanel.vue'
|
|
75
|
+
import type { OpenAPIV3 } from 'openapi-types'
|
|
76
|
+
|
|
77
|
+
const props = defineProps<{
|
|
78
|
+
responses: Record<string, OpenAPIV3.ResponseObject>
|
|
79
|
+
spec: OpenAPIV3.Document
|
|
80
|
+
}>()
|
|
81
|
+
|
|
82
|
+
const { t } = useTranslation()
|
|
83
|
+
|
|
84
|
+
const tabListContainer = useTemplateRef('tabListContainer')
|
|
85
|
+
const canScrollRight = ref(false)
|
|
86
|
+
|
|
87
|
+
function checkOverflow() {
|
|
88
|
+
const el = tabListContainer.value
|
|
89
|
+
if (!el) return
|
|
90
|
+
canScrollRight.value = el.scrollLeft + el.clientWidth < el.scrollWidth - 1
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function onScroll() {
|
|
94
|
+
checkOverflow()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
onMounted(checkOverflow)
|
|
98
|
+
|
|
99
|
+
const tabs = computed(() =>
|
|
100
|
+
Object.entries(props.responses).map(([code, response]) => ({ code, response })),
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
watch(tabs, () => {
|
|
104
|
+
nextTick(checkOverflow)
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
const activeTabIndex = ref(0)
|
|
108
|
+
const selectedContentType = ref('')
|
|
109
|
+
|
|
110
|
+
const currentContentTypes = computed(() => {
|
|
111
|
+
const tab = tabs.value[activeTabIndex.value]
|
|
112
|
+
if (!tab?.response.content) return []
|
|
113
|
+
return Object.keys(tab.response.content)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const currentMediaType = computed(() => {
|
|
117
|
+
const tab = tabs.value[activeTabIndex.value]
|
|
118
|
+
if (!tab?.response.content) return null
|
|
119
|
+
const ct = selectedContentType.value || currentContentTypes.value[0]
|
|
120
|
+
if (!ct) return null
|
|
121
|
+
return tab.response.content[ct] || null
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
watch(currentContentTypes, (types) => {
|
|
125
|
+
selectedContentType.value = types[0] || ''
|
|
126
|
+
}, { immediate: true })
|
|
127
|
+
|
|
128
|
+
function onTabChange(index: number) {
|
|
129
|
+
activeTabIndex.value = index
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function statusDotColor(code: string): string {
|
|
133
|
+
if (code.startsWith('2')) return 'bg-green-600'
|
|
134
|
+
if (code.startsWith('3')) return 'bg-blue-600'
|
|
135
|
+
if (code.startsWith('4')) return 'bg-orange-500'
|
|
136
|
+
if (code.startsWith('5')) return 'bg-red-600'
|
|
137
|
+
return 'bg-gray-400'
|
|
138
|
+
}
|
|
139
|
+
</script>
|
|
140
|
+
|
|
141
|
+
<style scoped>
|
|
142
|
+
.scroll-fade {
|
|
143
|
+
mask-image: linear-gradient(to right, black calc(100% - 60px), transparent);
|
|
144
|
+
mask-size: 100% 100%;
|
|
145
|
+
mask-position: center;
|
|
146
|
+
padding-block: 4px;
|
|
147
|
+
margin-block: -4px;
|
|
148
|
+
}
|
|
149
|
+
</style>
|