@datagouv/components-next 1.0.2-dev.63 → 1.0.2-dev.65

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-BcqenM8i.js";
1
+ import { c as Ke } from "./main-BoFCVekJ.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.63",
3
+ "version": "1.0.2-dev.65",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -1,4 +1,5 @@
1
1
  import { type InjectionKey, type Ref, inject, onMounted, onScopeDispose } from 'vue'
2
+ import { useRoute, useRouter } from 'vue-router'
2
3
  import { useRouteQuery } from '@vueuse/router'
3
4
 
4
5
  export interface CustomFilterEntry {
@@ -69,6 +70,8 @@ export function useSearchFilter(
69
70
 
70
71
  const { apiParam = urlParam, defaultValue = undefined } = options
71
72
 
73
+ const route = useRoute()
74
+ const router = useRouter()
72
75
  const value = useRouteQuery<string | undefined>(urlParam, defaultValue)
73
76
 
74
77
  // Register in onMounted to avoid SSR/hydration mismatch: the registry must be
@@ -82,7 +85,19 @@ export function useSearchFilter(
82
85
  // own `watch(currentType)` logic that drops built-in filters which don't
83
86
  // apply to the new type: a custom filter's applicability is signalled
84
87
  // by the consumer via `v-if`, so its unmount is the equivalent signal.
85
- value.value = defaultValue
88
+ //
89
+ // We cannot use `value.value = defaultValue` here because VueUse's
90
+ // useRouteQuery registers its own tryOnScopeDispose cleanup that zeroes
91
+ // the internal `query` variable to undefined (FIFO order, it runs first).
92
+ // The setter then sees `query === v` and early-returns without ever
93
+ // calling router.replace(). Instead we read the live route.query directly
94
+ // (which is router state, not affected by that cleanup) and push the update.
95
+ if (route.query[urlParam] !== undefined) {
96
+ const { [urlParam]: _removed, ...restQuery } = route.query
97
+ router.replace({
98
+ query: defaultValue === undefined ? restQuery : { ...restQuery, [urlParam]: String(defaultValue) },
99
+ })
100
+ }
86
101
  context.unregister(urlParam)
87
102
  })
88
103
 
package/src/main.ts CHANGED
@@ -23,7 +23,7 @@ import type { Site } from './types/site'
23
23
  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
- import type { GlobalSearchConfig, SearchType, SortOption } from './types/search'
26
+ import type { GlobalSearchConfig, SearchType, SearchTypeConfig, SortOption, HiddenFilter, BuiltInFilterKey, DatasetSearchConfig, DatasetSearchFilters, DataserviceSearchConfig, DataserviceSearchFilters, ReuseSearchConfig, ReuseSearchFilters, OrganizationSearchConfig, OrganizationSearchFilters, TopicSearchConfig, TopicSearchFilters } from './types/search'
27
27
  import { getDefaultDatasetConfig, getDefaultDataserviceConfig, getDefaultReuseConfig, getDefaultOrganizationConfig, getDefaultTopicConfig, getDefaultGlobalSearchConfig, defaultDatasetSortOptions, defaultDataserviceSortOptions, defaultReuseSortOptions, defaultOrganizationSortOptions } from './types/search'
28
28
  import { useSearchFilter } from './composables/useSearchFilter'
29
29
  import type { UseSearchFilterOptions } from './composables/useSearchFilter'
@@ -130,7 +130,20 @@ export * from './types/access_types'
130
130
  export type {
131
131
  GlobalSearchConfig,
132
132
  SearchType,
133
+ SearchTypeConfig,
133
134
  SortOption,
135
+ HiddenFilter,
136
+ BuiltInFilterKey,
137
+ DatasetSearchConfig,
138
+ DatasetSearchFilters,
139
+ DataserviceSearchConfig,
140
+ DataserviceSearchFilters,
141
+ ReuseSearchConfig,
142
+ ReuseSearchFilters,
143
+ OrganizationSearchConfig,
144
+ OrganizationSearchFilters,
145
+ TopicSearchConfig,
146
+ TopicSearchFilters,
134
147
  UseSearchFilterOptions,
135
148
  UseFetchFunction,
136
149
  AccessType,
@@ -351,6 +351,8 @@ export type TopicSearchConfig = {
351
351
 
352
352
  export type SearchTypeConfig = DatasetSearchConfig | DataserviceSearchConfig | ReuseSearchConfig | OrganizationSearchConfig | TopicSearchConfig
353
353
 
354
+ export type BuiltInFilterKey = keyof DatasetSearchFilters | keyof DataserviceSearchFilters | keyof ReuseSearchFilters | keyof OrganizationSearchFilters | keyof TopicSearchFilters
355
+
354
356
  export type SearchType = SearchTypeConfig['class']
355
357
 
356
358
  export type GlobalSearchConfig = SearchTypeConfig[]