@datagouv/components-next 1.0.2-dev.39 → 1.0.2-dev.40

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 { c as Ke } from "./main-AlteMgUe.js";
1
+ import { c as Ke } from "./main-ifX24DGW.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.39",
3
+ "version": "1.0.2-dev.40",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -263,6 +263,14 @@
263
263
  <OrganizationHorizontalCard :organization="(result as Organization)" />
264
264
  </slot>
265
265
  </template>
266
+ <template v-else-if="currentType === 'topics'">
267
+ <slot
268
+ name="topic"
269
+ :topic="result"
270
+ >
271
+ <TopicCard :topic="(result as TopicV2)" />
272
+ </slot>
273
+ </template>
266
274
  </li>
267
275
  </ul>
268
276
  <Pagination
@@ -334,7 +342,7 @@
334
342
  <script setup lang="ts">
335
343
  import { computed, watch, useTemplateRef, type Ref } from 'vue'
336
344
  import { useRouteQuery } from '@vueuse/router'
337
- import { RiBuilding2Line, RiCloseCircleLine, RiDatabase2Line, RiLightbulbLine, RiLineChartLine, RiRssLine, RiTerminalLine } from '@remixicon/vue'
345
+ import { RiBookShelfLine, RiBuilding2Line, RiCloseCircleLine, RiDatabase2Line, RiLightbulbLine, RiLineChartLine, RiRssLine, RiTerminalLine } from '@remixicon/vue'
338
346
  import magnifyingGlassSrc from '../../../assets/illustrations/magnifying_glass.svg?url'
339
347
  import { useTranslation } from '../../composables/useTranslation'
340
348
  import { useDebouncedRef } from '../../composables/useDebouncedRef'
@@ -345,7 +353,8 @@ import type { Dataset } from '../../types/datasets'
345
353
  import type { Dataservice } from '../../types/dataservices'
346
354
  import type { Organization } from '../../types/organizations'
347
355
  import type { Reuse } from '../../types/reuses'
348
- import type { GlobalSearchConfig, SearchType, SortOption, DatasetSearchResponse, DataserviceSearchResponse, ReuseSearchResponse, OrganizationSearchResponse, FacetItem } from '../../types/search'
356
+ import type { TopicV2 } from '../../types/topics'
357
+ import type { GlobalSearchConfig, SearchType, SortOption, DatasetSearchResponse, DataserviceSearchResponse, ReuseSearchResponse, OrganizationSearchResponse, TopicSearchResponse, FacetItem } from '../../types/search'
349
358
  import { getDefaultGlobalSearchConfig } from '../../types/search'
350
359
  import BrandedButton from '../BrandedButton.vue'
351
360
  import LoadingBlock from '../LoadingBlock.vue'
@@ -356,6 +365,7 @@ import DatasetCard from '../DatasetCard.vue'
356
365
  import DataserviceCard from '../DataserviceCard.vue'
357
366
  import OrganizationHorizontalCard from '../OrganizationHorizontalCard.vue'
358
367
  import ReuseHorizontalCard from '../ReuseHorizontalCard.vue'
368
+ import TopicCard from '../TopicCard.vue'
359
369
  import SearchInput from './SearchInput.vue'
360
370
  import Sidemenu from './Sidemenu.vue'
361
371
  import BasicAndAdvancedFilters from './BasicAndAdvancedFilters.vue'
@@ -498,6 +508,7 @@ const datasetsEnabled = computed(() => props.config.some(c => c.class === 'datas
498
508
  const dataservicesEnabled = computed(() => props.config.some(c => c.class === 'dataservices'))
499
509
  const reusesEnabled = computed(() => props.config.some(c => c.class === 'reuses'))
500
510
  const organizationsEnabled = computed(() => props.config.some(c => c.class === 'organizations'))
511
+ const topicsEnabled = computed(() => props.config.some(c => c.class === 'topics'))
501
512
 
502
513
  // Create stable params for each type
503
514
  const stableParamsOptions = {
@@ -524,12 +535,17 @@ const organizationsParams = useStableQueryParams({
524
535
  ...stableParamsOptions,
525
536
  typeConfig: props.config.find(c => c.class === 'organizations'),
526
537
  })
538
+ const topicsParams = useStableQueryParams({
539
+ ...stableParamsOptions,
540
+ typeConfig: props.config.find(c => c.class === 'topics'),
541
+ })
527
542
 
528
543
  // URLs that return null when type is not enabled
529
544
  const datasetsUrl = computed(() => datasetsEnabled.value ? '/api/2/datasets/search/' : null)
530
545
  const dataservicesUrl = computed(() => dataservicesEnabled.value ? '/api/2/dataservices/search/' : null)
531
546
  const reusesUrl = computed(() => reusesEnabled.value ? '/api/2/reuses/search/' : null)
532
547
  const organizationsUrl = computed(() => organizationsEnabled.value ? '/api/2/organizations/search/' : null)
548
+ const topicsUrl = computed(() => topicsEnabled.value ? '/api/2/topics/search/' : null)
533
549
 
534
550
  // Reset page on filter/sort change
535
551
  const filtersForReset = computed(() => ({
@@ -613,6 +629,10 @@ const { data: organizationsResults, status: organizationsStatus } = await useFet
613
629
  organizationsUrl,
614
630
  { params: organizationsParams, lazy: true, server: initialType === 'organizations' },
615
631
  )
632
+ const { data: topicsResults, status: topicsStatus } = await useFetch<TopicSearchResponse<TopicV2>>(
633
+ topicsUrl,
634
+ { params: topicsParams, lazy: true, server: initialType === 'topics' },
635
+ )
616
636
 
617
637
  const typesMeta = {
618
638
  datasets: {
@@ -643,6 +663,13 @@ const typesMeta = {
643
663
  results: organizationsResults,
644
664
  status: organizationsStatus,
645
665
  },
666
+ topics: {
667
+ icon: RiBookShelfLine,
668
+ name: t('Thématiques'),
669
+ placeholder: t('Rechercher une thématique'),
670
+ results: topicsResults,
671
+ status: topicsStatus,
672
+ },
646
673
  } as const
647
674
 
648
675
  const searchResults = computed(() => typesMeta[currentType.value].results.value)
package/src/main.ts CHANGED
@@ -24,7 +24,7 @@ import type { Weight, WellType } from './types/ui'
24
24
  import type { User, UserReference } from './types/users'
25
25
  import type { Report, ReportSubject, ReportReason } from './types/reports'
26
26
  import type { GlobalSearchConfig, SearchType, SortOption } from './types/search'
27
- import { getDefaultDatasetConfig, getDefaultDataserviceConfig, getDefaultReuseConfig, getDefaultOrganizationConfig, getDefaultGlobalSearchConfig, defaultDatasetSortOptions, defaultDataserviceSortOptions, defaultReuseSortOptions, defaultOrganizationSortOptions } from './types/search'
27
+ import { getDefaultDatasetConfig, getDefaultDataserviceConfig, getDefaultReuseConfig, getDefaultOrganizationConfig, getDefaultTopicConfig, getDefaultGlobalSearchConfig, defaultDatasetSortOptions, defaultDataserviceSortOptions, defaultReuseSortOptions, defaultOrganizationSortOptions } from './types/search'
28
28
 
29
29
  import ActivityList from './components/ActivityList/ActivityList.vue'
30
30
  import UserActivityList from './components/ActivityList/UserActivityList.vue'
@@ -224,6 +224,7 @@ export {
224
224
  getDefaultDataserviceConfig,
225
225
  getDefaultReuseConfig,
226
226
  getDefaultOrganizationConfig,
227
+ getDefaultTopicConfig,
227
228
  getDefaultGlobalSearchConfig,
228
229
  defaultDatasetSortOptions,
229
230
  defaultDataserviceSortOptions,
@@ -325,7 +325,16 @@ export type OrganizationSearchConfig = {
325
325
  sortOptions?: SortOption<OrganizationSearchSort>[]
326
326
  }
327
327
 
328
- export type SearchTypeConfig = DatasetSearchConfig | DataserviceSearchConfig | ReuseSearchConfig | OrganizationSearchConfig
328
+ export type TopicSearchConfig = {
329
+ class: 'topics'
330
+ name?: string
331
+ hiddenFilters?: HiddenFilter<TopicSearchFilters>[]
332
+ basicFilters?: (keyof TopicSearchFilters)[]
333
+ advancedFilters?: (keyof TopicSearchFilters)[]
334
+ sortOptions?: SortOption<TopicSearchSort>[]
335
+ }
336
+
337
+ export type SearchTypeConfig = DatasetSearchConfig | DataserviceSearchConfig | ReuseSearchConfig | OrganizationSearchConfig | TopicSearchConfig
329
338
 
330
339
  export type SearchType = SearchTypeConfig['class']
331
340
 
@@ -397,11 +406,27 @@ export function getDefaultOrganizationConfig(overrides?: Partial<Omit<Organizati
397
406
  }
398
407
  }
399
408
 
409
+ export const defaultTopicSortOptions: SortOption<TopicSearchSort>[] = [
410
+ { value: '-created', label: 'Date de création' },
411
+ { value: '-last_modified', label: 'Dernière mise à jour' },
412
+ ]
413
+
414
+ export function getDefaultTopicConfig(overrides?: Partial<Omit<TopicSearchConfig, 'class'>>): TopicSearchConfig {
415
+ return {
416
+ class: 'topics',
417
+ basicFilters: ['last_update_range', 'producer_type'],
418
+ advancedFilters: ['organization', 'tag'],
419
+ sortOptions: defaultTopicSortOptions,
420
+ ...overrides,
421
+ }
422
+ }
423
+
400
424
  export function getDefaultGlobalSearchConfig(): GlobalSearchConfig {
401
425
  return [
402
426
  getDefaultDatasetConfig(),
403
427
  getDefaultDataserviceConfig(),
404
428
  getDefaultReuseConfig(),
405
429
  getDefaultOrganizationConfig(),
430
+ getDefaultTopicConfig(),
406
431
  ]
407
432
  }
@@ -1,4 +0,0 @@
1
- import { j as f } from "./main-AlteMgUe.js";
2
- export {
3
- f as default
4
- };