@datagouv/components-next 1.0.2-dev.168 → 1.0.2-dev.169

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-D7EaQcIR.js";
1
+ import { g as Ke } from "./main-DNoYWfit.js";
2
2
  import We from "vue";
3
3
  function Fe($, 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.168",
3
+ "version": "1.0.2-dev.169",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -10,9 +10,7 @@
10
10
  >
11
11
  <div>
12
12
  <div class="text-gray-900">
13
- <slot name="title">
14
- {{ title }}
15
- </slot>
13
+ {{ title }}
16
14
  </div>
17
15
  <div
18
16
  v-if="$slots.default"
@@ -36,9 +34,7 @@ export const bannerActionTypeKey = Symbol() as InjectionKey<'primary' | 'danger'
36
34
  <script setup lang="ts">
37
35
  const props = defineProps<{
38
36
  type: 'primary' | 'danger' | 'warning'
39
- // Optional so the title can be a slot, for instance to make it the toggle of a
40
- // disclosure whose panel lives in the banner
41
- title?: string
37
+ title: string
42
38
  }>()
43
39
 
44
40
  provide(bannerActionTypeKey, props.type)
@@ -8,7 +8,6 @@
8
8
  :placeholder="t('Tous les schémas')"
9
9
  :get-option-id="(s: RegisteredSchema) => s.name"
10
10
  :display-value="(s: RegisteredSchema) => s.name"
11
- :filter="schemaMatchesQuery"
12
11
  :multiple="false"
13
12
  />
14
13
  </template>
@@ -17,7 +16,6 @@
17
16
  import { useTranslation } from '../../composables/useTranslation'
18
17
  import { useSelectModelSync } from '../../composables/useSelectModelSync'
19
18
  import { useFetch } from '../../functions/api'
20
- import { schemaMatchesQuery } from '../../functions/schemas'
21
19
  import type { RegisteredSchema } from '../../types/schemas'
22
20
  import SearchableSelect from './SearchableSelect.vue'
23
21
 
@@ -1,14 +1,8 @@
1
1
  <template>
2
2
  <div
3
- :id
4
3
  class="p-4 relative border bg-white hover:bg-gray-some"
5
- :class="{
6
- 'border-gray-default': !selected && !active,
7
- 'border-datagouv': selected && !active,
8
- 'border-blue-outline': active,
9
- }"
4
+ :class="{ 'border-gray-default': !selected, 'border-datagouv': selected }"
10
5
  :role="selectable ? 'option' : undefined"
11
- :tabindex="selectable ? -1 : undefined"
12
6
  :aria-selected="selectable && selected"
13
7
  >
14
8
  <h3 class="text-base font-bold mb-0 flex items-center gap-1">
@@ -79,10 +73,7 @@ import { useComponentsConfig } from '../config'
79
73
 
80
74
  defineProps<{
81
75
  schema: RegisteredSchema
82
- id?: string
83
76
  selectable?: boolean
84
- // Highlighted by the keyboard inside the listbox, which is not the same as chosen
85
- active?: boolean
86
77
  selected?: boolean
87
78
  showLinks?: boolean
88
79
  }>()
@@ -60,28 +60,23 @@ export function useActiveDescendant<T extends Option>(options: MaybeRefOrGetter<
60
60
 
61
61
  function handleKeyPressForActiveDescendant(key: KeyboardEvent, alreadyMovedDown = false) {
62
62
  switch (key.key as CommonKeyboardKeys) {
63
- // An arrow that moves the active option must not also scroll the page behind it
64
63
  case 'ArrowDown':
65
64
  if (direction === 'vertical' && !alreadyMovedDown && !key.altKey) {
66
- key.preventDefault()
67
65
  activateNextOption()
68
66
  }
69
67
  break
70
68
  case 'ArrowUp':
71
69
  if (direction === 'vertical') {
72
- key.preventDefault()
73
70
  activatePreviousOption()
74
71
  }
75
72
  break
76
73
  case 'ArrowLeft':
77
74
  if (direction === 'horizontal') {
78
- key.preventDefault()
79
75
  activatePreviousOption()
80
76
  }
81
77
  break
82
78
  case 'ArrowRight':
83
79
  if (direction === 'horizontal' && !alreadyMovedDown && !key.altKey) {
84
- key.preventDefault()
85
80
  activateNextOption()
86
81
  }
87
82
  break
@@ -31,33 +31,6 @@ export function getSchemaVersion(schema: RegisteredSchema | null) {
31
31
  }
32
32
  }
33
33
 
34
- // Accents and separators must not stand between a query and a schema: people type
35
- // "lave linge" for « Lave-linge », or « reparabilite » without its accents
36
- function normalizeForSearch(value: string): string {
37
- return value
38
- .toLowerCase()
39
- .normalize('NFD')
40
- .replace(/\p{Diacritic}/gu, '')
41
- .replace(/[^a-z0-9]+/g, ' ')
42
- .trim()
43
- }
44
-
45
- // The name is searched along with the title and the description: it is the identifier
46
- // people know and paste, such as `etalab/indice-durabilite-lave-linge`
47
- const searchableText = (schema: RegisteredSchema) => normalizeForSearch(`${schema.name} ${schema.title ?? ''} ${schema.description ?? ''}`)
48
-
49
- const queryTokens = (query: string) => normalizeForSearch(query).split(' ').filter(Boolean)
50
-
51
- export function schemaMatchesQuery(schema: RegisteredSchema, query: string): boolean {
52
- // A query made only of punctuation holds no word to match. Callers short-circuit the
53
- // empty query, so matching everything here would only ever answer that case.
54
- const tokens = queryTokens(query)
55
- if (!tokens.length) return false
56
-
57
- const haystack = searchableText(schema)
58
- return tokens.every(token => haystack.includes(token))
59
- }
60
-
61
34
  export function findSchemaInCatalog(catalog: Array<RegisteredSchema>, schema: Schema | null): RegisteredSchema | null {
62
35
  if (!schema) return null
63
36
  return catalog.find(registeredSchema => schema.name === registeredSchema.name) || null