@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.
- package/dist/{Datafair.client-P2fVHPsE.js → Datafair.client-BnNkCqxw.js} +1 -1
- package/dist/{JsonPreview.client-BQG4CJTf.js → JsonPreview.client-BEq_U7f_.js} +2 -2
- package/dist/{MapContainer.client-BKlK14EZ.js → MapContainer.client-B2EsRCfa.js} +2 -2
- package/dist/{PdfPreview.client-C6LIukqm.js → PdfPreview.client-Bel2iTRr.js} +2 -2
- package/dist/{Pmtiles.client-B8A2CXdm.js → Pmtiles.client-ryGUyCdX.js} +1 -1
- package/dist/{PreviewWrapper.vue_vue_type_script_setup_true_lang-CwP0rK2R.js → PreviewWrapper.vue_vue_type_script_setup_true_lang-DIxBiils.js} +1 -1
- package/dist/{XmlPreview.client-C3CQUdEa.js → XmlPreview.client-nRFzEkZD.js} +3 -3
- package/dist/components-next.js +1 -1
- package/dist/{index-C68_gb_d.js → index-CoxMW-DG.js} +1 -1
- package/dist/{main-BcqenM8i.js → main-BoFCVekJ.js} +1989 -1982
- package/dist/{vue3-xml-viewer.common-BS7y248F.js → vue3-xml-viewer.common-DtXMtQDT.js} +1 -1
- package/package.json +1 -1
- package/src/composables/useSearchFilter.ts +16 -1
- package/src/main.ts +14 -1
- package/src/types/search.ts +2 -0
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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,
|
package/src/types/search.ts
CHANGED
|
@@ -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[]
|