@datagouv/components-next 1.0.2-dev.66 → 1.0.2-dev.67
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-BnNkCqxw.js → Datafair.client-mCVEbSye.js} +1 -1
- package/dist/{JsonPreview.client-BEq_U7f_.js → JsonPreview.client-D2-QXKW9.js} +2 -2
- package/dist/{MapContainer.client-B2EsRCfa.js → MapContainer.client-fG7SH8SY.js} +2 -2
- package/dist/{PdfPreview.client-Bel2iTRr.js → PdfPreview.client-BD2LoeWd.js} +2 -2
- package/dist/{Pmtiles.client-ryGUyCdX.js → Pmtiles.client-BoISUK3N.js} +1 -1
- package/dist/{PreviewWrapper.vue_vue_type_script_setup_true_lang-DIxBiils.js → PreviewWrapper.vue_vue_type_script_setup_true_lang-BRkoVZX6.js} +1 -1
- package/dist/{XmlPreview.client-nRFzEkZD.js → XmlPreview.client-D4beM-9H.js} +3 -3
- package/dist/components-next.js +1 -1
- package/dist/{index-CoxMW-DG.js → index-CHqTMS42.js} +1 -1
- package/dist/{main-BoFCVekJ.js → main-vXPsdhWv.js} +11646 -11642
- package/dist/{vue3-xml-viewer.common-DtXMtQDT.js → vue3-xml-viewer.common-S2fcy_RO.js} +1 -1
- package/package.json +1 -1
- package/src/components/Search/GlobalSearch.vue +3 -5
- package/src/composables/useSearchFilter.ts +15 -2
- package/src/composables/useStableQueryParams.ts +5 -2
package/package.json
CHANGED
|
@@ -356,7 +356,7 @@ import { RiBookShelfLine, RiBuilding2Line, RiCloseCircleLine, RiDatabase2Line, R
|
|
|
356
356
|
import magnifyingGlassSrc from '../../../assets/illustrations/magnifying_glass.svg?url'
|
|
357
357
|
import { useTranslation } from '../../composables/useTranslation'
|
|
358
358
|
import { useDebouncedRef } from '../../composables/useDebouncedRef'
|
|
359
|
-
import { forEachActiveCustomFilter, isCustomFilterActive, searchFilterContextKey, type CustomFilterEntry } from '../../composables/useSearchFilter'
|
|
359
|
+
import { configKey, forEachActiveCustomFilter, isCustomFilterActive, searchFilterContextKey, type CustomFilterEntry } from '../../composables/useSearchFilter'
|
|
360
360
|
import { useStableQueryParams } from '../../composables/useStableQueryParams'
|
|
361
361
|
import { useComponentsConfig } from '../../config'
|
|
362
362
|
import { useFetch } from '../../functions/api'
|
|
@@ -366,7 +366,7 @@ import type { Dataservice } from '../../types/dataservices'
|
|
|
366
366
|
import type { Organization } from '../../types/organizations'
|
|
367
367
|
import type { Reuse } from '../../types/reuses'
|
|
368
368
|
import type { TopicV2 } from '../../types/topics'
|
|
369
|
-
import type { GlobalSearchConfig, SearchResponseByClass, SearchType,
|
|
369
|
+
import type { GlobalSearchConfig, SearchResponseByClass, SearchType, SortOption, FacetItem } from '../../types/search'
|
|
370
370
|
import { getDefaultGlobalSearchConfig } from '../../types/search'
|
|
371
371
|
import BrandedButton from '../BrandedButton.vue'
|
|
372
372
|
import LoadingBlock from '../LoadingBlock.vue'
|
|
@@ -406,8 +406,6 @@ const props = withDefaults(defineProps<{
|
|
|
406
406
|
hideSearchInput: false,
|
|
407
407
|
})
|
|
408
408
|
|
|
409
|
-
const configKey = (c: SearchTypeConfig) => c.key ?? c.class
|
|
410
|
-
|
|
411
409
|
// defineModel's default is static and can't depend on props, so we cast and initialize manually
|
|
412
410
|
const currentType = defineModel<string>('type') as Ref<string>
|
|
413
411
|
if (!currentType.value) currentType.value = configKey(props.config[0] ?? { class: 'datasets' })
|
|
@@ -742,7 +740,7 @@ const rssUrl = computed(() => {
|
|
|
742
740
|
|
|
743
741
|
forEachActiveCustomFilter(customFilterRegistry, (apiParam, value) => {
|
|
744
742
|
params.set(apiParam, value)
|
|
745
|
-
})
|
|
743
|
+
}, currentTypeConfig.value ? configKey(currentTypeConfig.value) : undefined)
|
|
746
744
|
|
|
747
745
|
// Add sort if set
|
|
748
746
|
if (sort.value) params.set('sort', sort.value)
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { type InjectionKey, type Ref, inject, onMounted, onScopeDispose } from 'vue'
|
|
2
2
|
import { useRoute, useRouter } from 'vue-router'
|
|
3
3
|
import { useRouteQuery } from '@vueuse/router'
|
|
4
|
+
import type { SearchTypeConfig } from '../types/search'
|
|
5
|
+
|
|
6
|
+
export function configKey(c: SearchTypeConfig): string {
|
|
7
|
+
return c.key ?? c.class
|
|
8
|
+
}
|
|
4
9
|
|
|
5
10
|
export interface CustomFilterEntry {
|
|
6
11
|
apiParam: string
|
|
7
12
|
ref: Ref<string | undefined>
|
|
8
13
|
defaultValue: string | undefined
|
|
14
|
+
typeKeys?: string[] // undefined = applies to all types
|
|
9
15
|
}
|
|
10
16
|
|
|
11
17
|
export interface SearchFilterContext {
|
|
@@ -21,9 +27,11 @@ export function isCustomFilterActive(entry: CustomFilterEntry): boolean {
|
|
|
21
27
|
export function forEachActiveCustomFilter(
|
|
22
28
|
registry: Map<string, CustomFilterEntry>,
|
|
23
29
|
apply: (apiParam: string, value: string) => void,
|
|
30
|
+
typeKey?: string,
|
|
24
31
|
): void {
|
|
25
32
|
for (const entry of registry.values()) {
|
|
26
33
|
if (!isCustomFilterActive(entry)) continue
|
|
34
|
+
if (typeKey && entry.typeKeys && !entry.typeKeys.includes(typeKey)) continue
|
|
27
35
|
apply(entry.apiParam, String(entry.ref.value))
|
|
28
36
|
}
|
|
29
37
|
}
|
|
@@ -36,6 +44,8 @@ export interface UseSearchFilterOptions {
|
|
|
36
44
|
apiParam?: string
|
|
37
45
|
/** Default value when not present in URL. Defaults to undefined. */
|
|
38
46
|
defaultValue?: string
|
|
47
|
+
/** One or more type config keys this filter applies to. Undefined means all types. */
|
|
48
|
+
typeKeys?: string | string[]
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
/**
|
|
@@ -68,7 +78,10 @@ export function useSearchFilter(
|
|
|
68
78
|
)
|
|
69
79
|
}
|
|
70
80
|
|
|
71
|
-
const { apiParam = urlParam, defaultValue = undefined } = options
|
|
81
|
+
const { apiParam = urlParam, defaultValue = undefined, typeKeys } = options
|
|
82
|
+
const normalizedTypeKeys = typeKeys
|
|
83
|
+
? (Array.isArray(typeKeys) ? typeKeys : [typeKeys])
|
|
84
|
+
: undefined
|
|
72
85
|
|
|
73
86
|
const route = useRoute()
|
|
74
87
|
const router = useRouter()
|
|
@@ -77,7 +90,7 @@ export function useSearchFilter(
|
|
|
77
90
|
// Register in onMounted to avoid SSR/hydration mismatch: the registry must be
|
|
78
91
|
// empty during SSR so server and client produce the same initial HTML.
|
|
79
92
|
onMounted(() => {
|
|
80
|
-
context.register(urlParam, { apiParam, ref: value, defaultValue })
|
|
93
|
+
context.register(urlParam, { apiParam, ref: value, defaultValue, typeKeys: normalizedTypeKeys })
|
|
81
94
|
})
|
|
82
95
|
|
|
83
96
|
onScopeDispose(() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, ref, watch, type Ref } from 'vue'
|
|
2
2
|
import type { SearchTypeConfig } from '../types/search'
|
|
3
|
-
import { forEachActiveCustomFilter, type CustomFilterEntry } from './useSearchFilter'
|
|
3
|
+
import { configKey, forEachActiveCustomFilter, type CustomFilterEntry } from './useSearchFilter'
|
|
4
4
|
|
|
5
5
|
type FilterRefs = Record<string, Ref<unknown>>
|
|
6
6
|
|
|
@@ -55,6 +55,9 @@ export function useStableQueryParams(options: StableQueryParamsOptions) {
|
|
|
55
55
|
// 3.5. Apply custom filter values. Concatenate into an array on collision
|
|
56
56
|
// so a custom filter mapped onto a built-in apiParam (e.g. theme → tag)
|
|
57
57
|
// combines with an existing built-in value instead of overwriting it.
|
|
58
|
+
// Pass the current type key so filters scoped to specific types are excluded
|
|
59
|
+
// from background fetches for other types.
|
|
60
|
+
const currentTypeKey = typeConfig ? configKey(typeConfig) : undefined
|
|
58
61
|
forEachActiveCustomFilter(customFilterRegistry, (apiParam, value) => {
|
|
59
62
|
const existing = params[apiParam]
|
|
60
63
|
if (existing === undefined) {
|
|
@@ -63,7 +66,7 @@ export function useStableQueryParams(options: StableQueryParamsOptions) {
|
|
|
63
66
|
else {
|
|
64
67
|
params[apiParam] = Array.isArray(existing) ? [...existing, value] : [existing, value]
|
|
65
68
|
}
|
|
66
|
-
})
|
|
69
|
+
}, currentTypeKey)
|
|
67
70
|
|
|
68
71
|
// 4. Always include q, sort (if valid for this type), page, page_size
|
|
69
72
|
if (q.value) {
|