@tekkare/romulus 0.1.264 → 0.1.265

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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "0.1.263",
7
+ "version": "0.1.264",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -3,6 +3,7 @@ import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
3
3
  import { PhCaretDown, PhCheck, PhMagnifyingGlass, PhPlus } from '@phosphor-icons/vue'
4
4
  import type { Component } from 'vue'
5
5
  import { rmPanelOpened, rmPanelRegister } from '../utils/panels'
6
+ import { rmOptionMatches } from '../utils/filterOptions'
6
7
 
7
8
  export interface FilterDropdownOption {
8
9
  label: string
@@ -14,6 +15,13 @@ export interface FilterDropdownOption {
14
15
  * la maille voulue. Sans `group`, la liste reste plate.
15
16
  */
16
17
  group?: string
18
+ /**
19
+ * Noms sous lesquels l'option se cherche sans qu'ils s'affichent : les
20
+ * marques d'une molecule, la molecule d'une marque, un code. Taper
21
+ * « zytiga » dans une liste de molecules doit trouver ABIRATERONE ; sans
22
+ * eux, la recherche ne lit que le libelle.
23
+ */
24
+ keywords?: string[]
17
25
  }
18
26
 
19
27
  /** Une ligne de la liste : un intitule de famille, ou une option. */
@@ -120,8 +128,7 @@ function createOption() {
120
128
 
121
129
  const filteredOptions = computed(() => {
122
130
  if (!hasSearch.value || !search.value.trim()) return props.options
123
- const needle = search.value.trim().toLowerCase()
124
- return props.options.filter(o => o.label.toLowerCase().includes(needle))
131
+ return props.options.filter(o => rmOptionMatches(o, search.value))
125
132
  })
126
133
 
127
134
  /**
@@ -109,3 +109,14 @@ export declare function rmFilterSearchClause(fields: RmFilterSearchField[], inpu
109
109
  should: any[];
110
110
  };
111
111
  };
112
+ /**
113
+ * Une option d'une liste deja chargee repond-elle a la saisie ? Par son
114
+ * libelle, ou par l'un de ses mots-cles : les noms sous lesquels on la cherche
115
+ * sans qu'ils s'affichent (les marques d'une molecule, la molecule d'une
116
+ * marque, un code). C'est la meme regle que plus haut, pour les listes qui ne
117
+ * repassent pas par l'index.
118
+ */
119
+ export declare function rmOptionMatches(option: {
120
+ label: string;
121
+ keywords?: readonly string[];
122
+ }, input: string): boolean;
@@ -67,3 +67,11 @@ export function rmFilterSearchClause(fields, input) {
67
67
  }
68
68
  };
69
69
  }
70
+ function rmFold(value) {
71
+ return value.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
72
+ }
73
+ export function rmOptionMatches(option, input) {
74
+ const needle = rmFold(input.trim());
75
+ if (!needle) return true;
76
+ return [option.label, ...option.keywords ?? []].some((text) => rmFold(String(text ?? "")).includes(needle));
77
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.264",
3
+ "version": "0.1.265",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",