@hgdc/docs 0.4.0 → 0.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hgdc/docs",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Modèle de site de HGDC Docs : documentation MDX (docs.json) construite avec Astro Starlight, recherche, versions, llms.txt et assistant.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -24,7 +24,7 @@ const assistant = assistantEnabled(data.config)
24
24
  <div class="hd-palette__field">
25
25
  <Icon name="search" />
26
26
  <input
27
- type="search"
27
+ type="text"
28
28
  data-input
29
29
  placeholder="Rechercher dans la documentation"
30
30
  autocomplete="off"
@@ -26,7 +26,7 @@ const choices = [
26
26
  ) : (
27
27
  <div class="hd-theme-choice" role="radiogroup" aria-label="Thème">
28
28
  {choices.map((choice) => (
29
- <button type="button" role="radio" aria-checked="false" data-hd-theme={choice.value} aria-label={choice.label} title={choice.label}>
29
+ <button type="button" role="radio" aria-checked="false" data-hd-theme-choice={choice.value} aria-label={choice.label} title={choice.label}>
30
30
  <Icon name={choice.icon} size={16} />
31
31
  </button>
32
32
  ))}
@@ -60,8 +60,8 @@ const choices = [
60
60
  const dark = document.documentElement.dataset.theme === "dark"
61
61
  for (const button of document.querySelectorAll<HTMLButtonElement>("[data-hd-theme-toggle]"))
62
62
  button.setAttribute("aria-label", dark ? "Passer au thème clair" : "Passer au thème sombre")
63
- for (const radio of document.querySelectorAll<HTMLButtonElement>("[data-hd-theme]")) {
64
- const checked = radio.dataset.hdTheme === choice
63
+ for (const radio of document.querySelectorAll<HTMLButtonElement>("[data-hd-theme-choice]")) {
64
+ const checked = radio.dataset.hdThemeChoice === choice
65
65
  radio.setAttribute("aria-checked", String(checked))
66
66
  radio.tabIndex = checked ? 0 : -1
67
67
  }
@@ -70,8 +70,8 @@ const choices = [
70
70
  for (const button of document.querySelectorAll<HTMLButtonElement>("[data-hd-theme-toggle]"))
71
71
  button.addEventListener("click", () => apply(document.documentElement.dataset.theme === "dark" ? "light" : "dark"))
72
72
  for (const group of document.querySelectorAll<HTMLElement>(".hd-theme-choice")) {
73
- const radios = [...group.querySelectorAll<HTMLButtonElement>("[data-hd-theme]")]
74
- for (const radio of radios) radio.addEventListener("click", () => apply(radio.dataset.hdTheme!))
73
+ const radios = [...group.querySelectorAll<HTMLButtonElement>("[data-hd-theme-choice]")]
74
+ for (const radio of radios) radio.addEventListener("click", () => apply(radio.dataset.hdThemeChoice!))
75
75
  // Groupe de boutons radio : les flèches déplacent le choix, Tab sort du groupe.
76
76
  group.addEventListener("keydown", (event) => {
77
77
  const step = event.key === "ArrowRight" || event.key === "ArrowDown" ? 1 : event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 0
@@ -79,7 +79,7 @@ const choices = [
79
79
  event.preventDefault()
80
80
  const index = radios.findIndex((radio) => radio.getAttribute("aria-checked") === "true")
81
81
  const next = radios[(index + step + radios.length) % radios.length]!
82
- apply(next.dataset.hdTheme!)
82
+ apply(next.dataset.hdThemeChoice!)
83
83
  next.focus()
84
84
  })
85
85
  }
@@ -199,7 +199,11 @@ class Search extends HTMLElement {
199
199
  }
200
200
 
201
201
  private keydown(event: KeyboardEvent): void {
202
- if (event.key === "ArrowDown" || event.key === "ArrowUp") {
202
+ // Échap ferme d'un coup, même avec du texte dans le champ.
203
+ if (event.key === "Escape") {
204
+ event.preventDefault()
205
+ this.dialog.close()
206
+ } else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
203
207
  event.preventDefault()
204
208
  this.highlight(this.active + (event.key === "ArrowDown" ? 1 : -1))
205
209
  } else if (event.key === "Enter") {