@datagouv/components-next 0.1.1 → 0.1.2

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.
@@ -1,4 +1,4 @@
1
- import { g as Ke } from "./main-CN6IuSUA.js";
1
+ import { g as Ke } from "./main-DP8L5VBL.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": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./src/main.ts",
@@ -117,6 +117,7 @@ import { getLink } from '../../functions/pagination'
117
117
  import type { PaginatedArray } from '../../types/api'
118
118
  import type { Activity } from '../../types/activity'
119
119
  import Avatar from '../Avatar.vue'
120
+ import LoadingBlock from '../LoadingBlock.vue'
120
121
  import Pagination from '../Pagination.vue'
121
122
  import PaddedContainer from '../PaddedContainer.vue'
122
123
 
@@ -165,7 +165,6 @@ import type { Dataset, DatasetV2 } from '../types/datasets'
165
165
  import { summarize } from '../functions/helpers'
166
166
  import { useFormatDate } from '../functions/dates'
167
167
  import { getOwnerName } from '../functions/owned'
168
- import { removeMarkdown } from '../functions/markdown'
169
168
  import { getShortDescription } from '../functions/datasets'
170
169
  import { useComponentsConfig } from '../config'
171
170
  import { useTranslation } from '../composables/useTranslation'
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <div class="relative">
3
+ <div :class="{ 'opacity-50 min-h-64': loading }">
4
+ <slot />
5
+ </div>
6
+ <div
7
+ v-if="loading"
8
+ class="absolute inset-0 flex justify-center items-center min-h-64"
9
+ >
10
+ <AnimatedLoader class="size-24" />
11
+ </div>
12
+ </div>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import { computed } from 'vue'
17
+ import AnimatedLoader from './AnimatedLoader.vue'
18
+
19
+ const props = defineProps<{
20
+ status: string
21
+ }>()
22
+
23
+ const loading = computed(() => {
24
+ return props.status === 'idle' || props.status === 'pending'
25
+ })
26
+ </script>
@@ -61,13 +61,15 @@ import { useComponentsConfig } from '../../config'
61
61
  import { useFormatDate } from '../../functions/dates'
62
62
  import { throwOnNever } from '../../functions/never'
63
63
  import type { Resource } from '../../types/resources'
64
+ import type { Dataset, DatasetV2 } from '../../types/datasets'
64
65
  import BrandedButton from '../BrandedButton.vue'
65
66
  import styleVector from '../../../assets/json/vector.json'
66
67
  import SimpleBanner from '../SimpleBanner.vue'
67
68
  import { useTranslation } from '../../composables/useTranslation'
68
69
  import franceSvg from './france.svg?raw'
70
+ import { getOwnerName, getOwnerPage } from '../../functions/owned'
69
71
 
70
- const props = defineProps<{ resource: Resource }>()
72
+ const props = defineProps<{ resource: Resource, dataset: Dataset | DatasetV2 }>()
71
73
 
72
74
  const { t } = useTranslation()
73
75
  const { formatDate } = useFormatDate()
@@ -84,6 +86,12 @@ const lastUpdate = computed(() => formatDate(props.resource.extras['analysis:par
84
86
 
85
87
  const container = useTemplateRef('containerRef')
86
88
 
89
+ const attributions = computed(() => {
90
+ if (!props.dataset.organization && !props.dataset.owner)
91
+ return ''
92
+ return `© <a href="${getOwnerPage(props.dataset)}" target="_blank">${getOwnerName(props.dataset)}</a>`
93
+ })
94
+
87
95
  async function displayMap() {
88
96
  await import('maplibre-gl/dist/maplibre-gl.css')
89
97
 
@@ -103,6 +111,15 @@ async function displayMap() {
103
111
  center: [h.centerLon, h.centerLat],
104
112
  })
105
113
  map.addControl(new maplibregl.NavigationControl())
114
+ map.addControl(
115
+ new maplibregl.GeolocateControl({
116
+ positionOptions: {
117
+ enableHighAccuracy: true,
118
+ },
119
+ trackUserLocation: true,
120
+ showAccuracyCircle: false,
121
+ }),
122
+ )
106
123
 
107
124
  const popup = new maplibregl.Popup({
108
125
  closeButton: false,
@@ -127,7 +144,7 @@ async function displayMap() {
127
144
  map.addSource('pmtiles_source', {
128
145
  type: 'vector',
129
146
  url: `pmtiles://${pmtilesUrl.value}`,
130
- attribution: '© <a href="https://openstreetmap.org">OpenStreetMap</a>',
147
+ attribution: attributions.value,
131
148
  })
132
149
  // @ts-expect-error not typed from library
133
150
  metadata.tilestats.layers.forEach((layer) => {
@@ -186,6 +186,7 @@
186
186
  <Pmtiles
187
187
  v-if="hasPmtiles"
188
188
  :resource="resource"
189
+ :dataset="dataset"
189
190
  />
190
191
  <MapContainer
191
192
  v-if="ogcWms"
@@ -1,4 +1,4 @@
1
- import { ref, toValue, watchEffect, type ComputedRef, type Ref } from 'vue'
1
+ import { reactive, ref, toValue, watchEffect, type ComputedRef, type Ref } from 'vue'
2
2
  import { ofetch } from 'ofetch'
3
3
  import { useComponentsConfig } from '../config'
4
4
  import { useTranslation } from '../composables/useTranslation'
@@ -23,6 +23,7 @@ export async function useFetch<DataT, ErrorT = never>(
23
23
  const execute = async (_opts?: AsyncDataExecuteOptions) => {
24
24
  const urlValue = toValue(url)
25
25
  if (!urlValue) return
26
+ const fetchOptions = reactive(options ?? {})
26
27
  status.value = 'pending'
27
28
  try {
28
29
  data.value = await ofetch(urlValue, {
@@ -66,7 +67,7 @@ export async function useFetch<DataT, ErrorT = never>(
66
67
  // TODO Toast outside Nuxt
67
68
  // toast.error(message)
68
69
  },
69
- ...options,
70
+ ...fetchOptions,
70
71
  })
71
72
  status.value = 'success'
72
73
  }
@@ -9,3 +9,13 @@ export function getOwnerName(owned: Owned): string {
9
9
  }
10
10
  return '' // Not supposed to exist but it does...
11
11
  }
12
+
13
+ export function getOwnerPage(owned: Owned): string | null {
14
+ if (owned.organization) {
15
+ return owned.organization.page
16
+ }
17
+ else if (owned.owner) {
18
+ return owned.owner.page
19
+ }
20
+ return null // Not supposed to exist but it does...
21
+ }
package/src/main.ts CHANGED
@@ -38,6 +38,7 @@ import DatasetQualityScore from './components/DatasetQualityScore.vue'
38
38
  import DatasetQualityTooltipContent from './components/DatasetQualityTooltipContent.vue'
39
39
  import ExtraAccordion from './components/ExtraAccordion.vue'
40
40
  import LabelTag from './components/DatasetLabelTag.vue'
41
+ import LoadingBlock from './components/LoadingBlock.vue'
41
42
  import OrganizationCard from './components/OrganizationCard.vue'
42
43
  import OrganizationNameWithCertificate from './components/OrganizationNameWithCertificate.vue'
43
44
  import OwnerType from './components/OwnerType.vue'
@@ -170,6 +171,7 @@ export {
170
171
  DateRangeDetails,
171
172
  ExtraAccordion,
172
173
  LabelTag,
174
+ LoadingBlock,
173
175
  OrganizationCard,
174
176
  OrganizationNameWithCertificate,
175
177
  OwnerType,
@@ -1,4 +0,0 @@
1
- import { _ as f } from "./main-CN6IuSUA.js";
2
- export {
3
- f as default
4
- };