@datagouv/components-next 1.0.2-dev.215 → 1.0.2-dev.216

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 (22) hide show
  1. package/dist/{Datafair.client-d3BYHNiH.js → Datafair.client-BVpfACK-.js} +1 -1
  2. package/dist/{ImagePreview.client-BK7Bro_1.js → ImagePreview.client-nLAcUFCK.js} +1 -1
  3. package/dist/{JsonPreview.client-oVSo5Xoc.js → JsonPreview.client-0RKlVJUM.js} +2 -2
  4. package/dist/{MapContainer.client-Djkm7Ffx.js → MapContainer.client-RG-g7iMI.js} +2 -2
  5. package/dist/{PdfPreview.client--SRpDOiB.js → PdfPreview.client-Cp9DmCPs.js} +2 -2
  6. package/dist/{Pmtiles.client-B0pvBTZA.js → Pmtiles.client-CdBmoD2F.js} +1 -1
  7. package/dist/{PreviewWrapper.vue_vue_type_script_setup_true_lang-38X8Egf9.js → PreviewWrapper.vue_vue_type_script_setup_true_lang-6L3T6Rvt.js} +1 -1
  8. package/dist/{XmlPreview.client-DoPp78zs.js → XmlPreview.client-CKcoUjVC.js} +3 -3
  9. package/dist/components-next.css +1 -1
  10. package/dist/components-next.js +40 -39
  11. package/dist/{index-WbWNwOZz.js → index-OjaQe5MK.js} +1 -1
  12. package/dist/{leaflet-src-Dwr0MQKJ.js → leaflet-src-2J947JAL.js} +1 -1
  13. package/dist/{main-DmYsCy8b.js → main-CWNJSmLw.js} +2154 -2142
  14. package/dist/{vue3-xml-viewer.common-Cpgf1TpW.js → vue3-xml-viewer.common-BpEt29zW.js} +1 -1
  15. package/package.json +1 -1
  16. package/src/components/ResourceAccordion/ResourceAccordion.vue +5 -3
  17. package/src/components/ResourceExplorer/ResourceExplorer.vue +4 -0
  18. package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +3 -0
  19. package/src/components/ResourceExplorer/ResourceViewerHeader.vue +5 -3
  20. package/src/components/ResourceExplorer/ResourceViewerSkeleton.vue +2 -0
  21. package/src/config.ts +0 -8
  22. package/src/functions/resources.ts +8 -3
@@ -1,4 +1,4 @@
1
- import { g as Ke } from "./main-DmYsCy8b.js";
1
+ import { g as Ke } from "./main-CWNJSmLw.js";
2
2
  import We from "vue";
3
3
  function Fe(I, K) {
4
4
  for (var V = 0; V < K.length; V++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datagouv/components-next",
3
- "version": "1.0.2-dev.215",
3
+ "version": "1.0.2-dev.216",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -47,7 +47,7 @@
47
47
  <CopyButton
48
48
  :label="t('Copier le lien')"
49
49
  :copied-label="t('Lien copié !')"
50
- :text="resourceExternalUrl"
50
+ :text="externalUrl"
51
51
  class="z-2"
52
52
  />
53
53
  </div>
@@ -327,7 +327,7 @@ import { trackEvent } from '../../functions/matomo'
327
327
  import CopyButton from '../CopyButton.vue'
328
328
  import { useComponentsConfig } from '../../config'
329
329
  import { getOwnerName } from '../../functions/owned'
330
- import { getResourceFormatIcon, getResourceTitleId, detectOgcService, getResourceExternalUrl, getResourceFilesize, isImagePreviewFormat } from '../../functions/resources'
330
+ import { getResourceFormatIcon, getResourceTitleId, detectOgcService, getResourceFilesize, isImagePreviewFormat, resolveResourceExternalUrl } from '../../functions/resources'
331
331
  import BrandedButton from '../BrandedButton.vue'
332
332
  import { useTranslation } from '../../composables/useTranslation'
333
333
  import { useHasTabularData } from '../../composables/useHasTabularData'
@@ -349,6 +349,8 @@ const props = withDefaults(defineProps<{
349
349
  isCommunityResource?: boolean
350
350
  resource: Resource | CommunityResource
351
351
  canEdit?: boolean
352
+ // Overrides the "Copier le lien" target.
353
+ resourceExternalUrl?: (resource: Resource | CommunityResource) => string
352
354
  }>(), {
353
355
  expandedOnMount: false,
354
356
  isCommunityResource: false,
@@ -468,7 +470,7 @@ const resourceFilesize = computed(() => getResourceFilesize(props.resource))
468
470
  const unavailable = availabilityChecked && props.resource.extras['check:available'] === false
469
471
  const downloadButtonTitle = unavailable ? t(`Le robot de {certifier} n'a pas pu accéder à ce fichier - Télécharger le fichier en {format}`, { certifier: config.name, format: format.value }) : t(`Télécharger le fichier en {format}`, { format: format.value })
470
472
 
471
- const resourceExternalUrl = computed(() => getResourceExternalUrl(props.dataset, props.resource))
473
+ const externalUrl = computed(() => resolveResourceExternalUrl(props.dataset, props.resource, props.resourceExternalUrl))
472
474
 
473
475
  const resourceContentId = 'resource-' + props.resource.id
474
476
  const resourceHeaderId = 'resource-' + props.resource.id + '-header'
@@ -49,6 +49,7 @@
49
49
  :resources="flatResources"
50
50
  :resource-to="resourceTo"
51
51
  :explore-to="exploreTo"
52
+ :resource-external-url="resourceExternalUrl"
52
53
  replace
53
54
  :fullscreen
54
55
  />
@@ -59,6 +60,7 @@
59
60
  :resources="flatResources"
60
61
  :resource-to="resourceTo"
61
62
  :explore-to="exploreTo"
63
+ :resource-external-url="resourceExternalUrl"
62
64
  replace
63
65
  :fullscreen
64
66
  />
@@ -122,6 +124,8 @@ const props = withDefaults(defineProps<{
122
124
  // Inline mode only: link builder for the "Explorer" button in the viewer header
123
125
  // that opens the fullscreen explorer on the current resource.
124
126
  exploreTo?: (resource: Resource) => string
127
+ // Overrides the "Copier le lien" target.
128
+ resourceExternalUrl?: (resource: Resource) => string
125
129
  }>(), {
126
130
  noResultsImage: '',
127
131
  fullscreen: false,
@@ -6,6 +6,7 @@
6
6
  :resources
7
7
  :resource-to
8
8
  :explore-to="exploreTo"
9
+ :resource-external-url="resourceExternalUrl"
9
10
  :replace
10
11
  :fullscreen
11
12
  />
@@ -217,6 +218,8 @@ const props = withDefaults(defineProps<{
217
218
  // When provided (inline mode), shows an "Explorer" button next to the download
218
219
  // action that opens the fullscreen explorer on the current resource.
219
220
  exploreTo?: (resource: Resource) => string
221
+ // Overrides the "Copier le lien" target.
222
+ resourceExternalUrl?: (resource: Resource) => string
220
223
  replace?: boolean
221
224
  // Fullscreen mode: make the viewer a flex column so the table fills down to the
222
225
  // bottom, and hide the inline download/visit/copy actions — they're shown in the
@@ -53,7 +53,7 @@
53
53
  <CopyButton
54
54
  :label="t('Copier le lien')"
55
55
  :copied-label="t('Lien copié !')"
56
- :text="resourceExternalUrl"
56
+ :text="externalUrl"
57
57
  icon-only
58
58
  class="hidden shrink-0 md:inline-flex"
59
59
  />
@@ -94,7 +94,7 @@ import ResourceMainAction from './ResourceMainAction.vue'
94
94
  import FormattedDate from '../FormattedDate.vue'
95
95
  import TranslationT from '../TranslationT.vue'
96
96
  import { filesize, summarize } from '../../functions/helpers'
97
- import { getResourceExternalUrl, getResourceFilesize } from '../../functions/resources'
97
+ import { getResourceFilesize, resolveResourceExternalUrl } from '../../functions/resources'
98
98
  import { trackEvent } from '../../functions/matomo'
99
99
  import { useTranslation } from '../../composables/useTranslation'
100
100
  import type { RouteLocationRaw } from 'vue-router'
@@ -110,6 +110,8 @@ const props = defineProps<{
110
110
  resources?: Resource[]
111
111
  resourceTo?: (resource: Resource) => RouteLocationRaw
112
112
  exploreTo?: (resource: Resource) => string
113
+ // Overrides the "Copier le lien" target.
114
+ resourceExternalUrl?: (resource: Resource) => string
113
115
  replace?: boolean
114
116
  // Fullscreen mode hides the inline actions — they live in the dataset context bar above.
115
117
  fullscreen?: boolean
@@ -118,5 +120,5 @@ const props = defineProps<{
118
120
  const { t } = useTranslation()
119
121
 
120
122
  const resourceFilesize = computed(() => getResourceFilesize(props.resource))
121
- const resourceExternalUrl = computed(() => getResourceExternalUrl(props.dataset, props.resource))
123
+ const externalUrl = computed(() => resolveResourceExternalUrl(props.dataset, props.resource, props.resourceExternalUrl))
122
124
  </script>
@@ -9,6 +9,7 @@
9
9
  :resources
10
10
  :resource-to
11
11
  :explore-to="exploreTo"
12
+ :resource-external-url="resourceExternalUrl"
12
13
  :replace
13
14
  :fullscreen
14
15
  />
@@ -80,6 +81,7 @@ const props = defineProps<{
80
81
  resources?: Resource[]
81
82
  resourceTo?: (resource: Resource) => RouteLocationRaw
82
83
  exploreTo?: (resource: Resource) => string
84
+ resourceExternalUrl?: (resource: Resource) => string
83
85
  replace?: boolean
84
86
  fullscreen?: boolean
85
87
  }>()
package/src/config.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import { inject, type Component, type InjectionKey } from 'vue'
2
2
  import type { UseFetchFunction } from './functions/api.types'
3
3
  import type { $Fetch, FetchOptions } from 'ofetch'
4
- import type { Dataset, DatasetV2 } from './types/datasets'
5
- import type { CommunityResource, Resource } from './types/resources'
6
4
 
7
5
  export type PluginConfig = {
8
6
  name: string // Name of the application (ex: data.gouv.fr)
@@ -47,12 +45,6 @@ export type PluginConfig = {
47
45
  clientOnly?: Component | null
48
46
  searchDebounce?: number
49
47
  forumUrl?: string
50
- /**
51
- * Overrides the "Copier le lien" target built by `getResourceExternalUrl`.
52
- * Must return an absolute URL: it is copied to the clipboard and used as an
53
- * external, `_blank` link target.
54
- */
55
- getResourceExternalUrl?: (dataset: Dataset | DatasetV2 | Omit<Dataset, 'resources' | 'community_resources'>, resource: Resource | CommunityResource) => string
56
48
  }
57
49
 
58
50
  export const configKey = Symbol() as InjectionKey<PluginConfig>
@@ -176,12 +176,17 @@ export function isCommunityResource(resource: Resource | CommunityResource): boo
176
176
  }
177
177
 
178
178
  export function getResourceExternalUrl(dataset: Dataset | DatasetV2 | Omit<Dataset, 'resources' | 'community_resources'>, resource: Resource | CommunityResource): string {
179
- const config = useComponentsConfig()
180
- if (config.getResourceExternalUrl) return config.getResourceExternalUrl(dataset, resource)
181
-
182
179
  return `${dataset.page}${isCommunityResource(resource) ? '/community-resources' : ''}?resource_id=${resource.id}`
183
180
  }
184
181
 
182
+ export function resolveResourceExternalUrl<R extends Resource | CommunityResource>(
183
+ dataset: Dataset | DatasetV2 | Omit<Dataset, 'resources' | 'community_resources'>,
184
+ resource: R,
185
+ override?: (resource: R) => string,
186
+ ): string {
187
+ return override ? override(resource) : getResourceExternalUrl(dataset, resource)
188
+ }
189
+
185
190
  export function getResourceFilesize(resource: Resource): null | number {
186
191
  if (resource.filesize) return resource.filesize
187
192
  if ('analysis:content-length' in resource.extras) return resource.extras['analysis:content-length'] as number