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

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 (28) hide show
  1. package/dist/{Datafair.client-d3BYHNiH.js → Datafair.client-BvMcdrbK.js} +1 -1
  2. package/dist/{ImagePreview.client-BK7Bro_1.js → ImagePreview.client-Cio--Qu5.js} +1 -1
  3. package/dist/{JsonPreview.client-oVSo5Xoc.js → JsonPreview.client-BlV_YzS0.js} +2 -2
  4. package/dist/{MapContainer.client-Djkm7Ffx.js → MapContainer.client-D75Y6Cgo.js} +2 -2
  5. package/dist/{PdfPreview.client--SRpDOiB.js → PdfPreview.client-Bb8GFhVj.js} +2 -2
  6. package/dist/{Pmtiles.client-B0pvBTZA.js → Pmtiles.client-Dh0kfu2W.js} +1 -1
  7. package/dist/{PreviewWrapper.vue_vue_type_script_setup_true_lang-38X8Egf9.js → PreviewWrapper.vue_vue_type_script_setup_true_lang-DtHTULUf.js} +1 -1
  8. package/dist/{XmlPreview.client-DoPp78zs.js → XmlPreview.client-DVI6hHVe.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-CaaH94Ot.js} +1 -1
  12. package/dist/{leaflet-src-Dwr0MQKJ.js → leaflet-src-CCCMNTu8.js} +1 -1
  13. package/dist/{main-DmYsCy8b.js → main-hDFmYneb.js} +4618 -4594
  14. package/dist/{vue3-xml-viewer.common-Cpgf1TpW.js → vue3-xml-viewer.common-BdDsD8kK.js} +1 -1
  15. package/package.json +1 -1
  16. package/src/components/DataserviceCard.vue +2 -1
  17. package/src/components/DatasetCard.vue +2 -1
  18. package/src/components/ObjectCardOwner.vue +13 -1
  19. package/src/components/ResourceAccordion/ResourceAccordion.vue +5 -3
  20. package/src/components/ResourceExplorer/ResourceExplorer.vue +4 -0
  21. package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +3 -0
  22. package/src/components/ResourceExplorer/ResourceViewerHeader.vue +5 -3
  23. package/src/components/ResourceExplorer/ResourceViewerSkeleton.vue +2 -0
  24. package/src/components/ReuseCard.vue +2 -1
  25. package/src/components/ReuseHorizontalCard.vue +2 -1
  26. package/src/components/TopicCard.vue +2 -0
  27. package/src/config.ts +0 -8
  28. 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-hDFmYneb.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.217",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -147,7 +147,8 @@ import TranslationT from './TranslationT.vue'
147
147
  type Props = {
148
148
  dataservice: Dataservice
149
149
  dataserviceUrl?: RouteLocationRaw
150
- organizationUrl?: RouteLocationRaw
150
+ // undefined falls back to the organization's data.gouv.fr page; pass null to render plain, non-linked text
151
+ organizationUrl?: RouteLocationRaw | null
151
152
  showDescription?: boolean
152
153
  titleTag?: TitleTag
153
154
  }
@@ -150,7 +150,8 @@ type Props = {
150
150
  dataset: Dataset | DatasetV2
151
151
  datasetUrl?: RouteLocationRaw
152
152
  datasetUrlInNewTab?: boolean
153
- organizationUrl?: RouteLocationRaw
153
+ // undefined falls back to the organization's data.gouv.fr page; pass null to render plain, non-linked text
154
+ organizationUrl?: RouteLocationRaw | null
154
155
  showDescriptionShort?: boolean
155
156
  titleTag?: TitleTag
156
157
  }
@@ -4,6 +4,7 @@
4
4
  class="-mr-0.5 flex-initial truncate"
5
5
  >
6
6
  <AppLink
7
+ v-if="organizationUrl !== null"
7
8
  class="link text-sm overflow-hidden flex items-center relative z-[2] truncate"
8
9
  :to="organizationUrl || organization.page"
9
10
  >
@@ -12,6 +13,16 @@
12
13
  size="sm"
13
14
  />
14
15
  </AppLink>
16
+ <span
17
+ v-else
18
+ class="text-sm overflow-hidden flex items-center truncate"
19
+ >
20
+ <OrganizationNameWithCertificate
21
+ :organization
22
+ size="sm"
23
+ color-class="text-gray-title"
24
+ />
25
+ </span>
15
26
  </div>
16
27
  <div
17
28
  v-else-if="ownerName"
@@ -33,7 +44,8 @@ import OrganizationNameWithCertificate from './OrganizationNameWithCertificate.v
33
44
  const props = defineProps<{
34
45
  organization?: OrganizationReference | null
35
46
  owner?: UserReference | null
36
- organizationUrl?: RouteLocationRaw
47
+ // undefined falls back to organization.page; pass null to render plain, non-linked text
48
+ organizationUrl?: RouteLocationRaw | null
37
49
  }>()
38
50
 
39
51
  const ownerName = computed(() => {
@@ -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
  }>()
@@ -100,8 +100,9 @@ const props = withDefaults(defineProps<{
100
100
  /**
101
101
  * The organizationUrl is an optional route location object to allow Vue Router to navigate to the details of the organization linked to tha reuse.
102
102
  * It is used as a separate prop to allow other sites using the package to define their own organization pages.
103
+ * Pass null instead of a route to render the organization name as plain, non-linked text.
103
104
  */
104
- organizationUrl?: RouteLocationRaw
105
+ organizationUrl?: RouteLocationRaw | null
105
106
 
106
107
  titleTag?: TitleTag
107
108
  }>(), {
@@ -73,7 +73,8 @@ import ObjectCardBadge from './ObjectCardBadge.vue'
73
73
  defineProps<{
74
74
  reuse: Reuse | ReuseV2
75
75
  reuseUrl?: RouteLocationRaw
76
- organizationUrl?: RouteLocationRaw
76
+ // undefined falls back to the organization's data.gouv.fr page; pass null to render plain, non-linked text
77
+ organizationUrl?: RouteLocationRaw | null
77
78
  }>()
78
79
 
79
80
  const { t } = useTranslation()
@@ -35,6 +35,7 @@
35
35
  <ObjectCardOwner
36
36
  :organization="topic.organization"
37
37
  :owner="topic.owner"
38
+ :organization-url="organizationUrl"
38
39
  />
39
40
  <RiSubtractLine
40
41
  v-if="(topic.organization || topic.owner) && topic.last_modified"
@@ -124,6 +125,7 @@ type TopicWithStats = TopicV2 & {
124
125
  withDefaults(defineProps<{
125
126
  topic: TopicWithStats
126
127
  topicUrl?: RouteLocationRaw
128
+ organizationUrl?: RouteLocationRaw | null
127
129
  showLogo?: boolean
128
130
  showStats?: boolean
129
131
  }>(), {
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