kempo-ui 0.1.2 → 0.1.3

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/bin/icon.js CHANGED
@@ -58,13 +58,19 @@ const matchesQuery = (name, query) => {
58
58
  return (tagMap[name] || []).some(t => t.includes(query));
59
59
  };
60
60
 
61
+ const rankMatch = (name, query) => {
62
+ if(name === query) return 0;
63
+ if(name.startsWith(query)) return 1;
64
+ return 2;
65
+ };
66
+
61
67
  const iconName = await search({
62
68
  message: 'Search for an icon',
63
69
  source: (query) => {
64
70
  if(!query) return [];
65
71
  return cache.icons
66
72
  .filter(name => matchesQuery(name, query))
67
- .slice(0, 20)
73
+ .sort((a, b) => rankMatch(a, query) - rankMatch(b, query))
68
74
  .map(name => ({ name, value: name }));
69
75
  }
70
76
  });
package/bin/list_icons.js CHANGED
@@ -61,7 +61,13 @@ const matchesQuery = (name) => {
61
61
  return (tagMap[name] || []).some(t => t.includes(query));
62
62
  };
63
63
 
64
- const results = cache.icons.filter(matchesQuery);
64
+ const rankMatch = (name) => {
65
+ if(name === query) return 0;
66
+ if(name.startsWith(query)) return 1;
67
+ return 2;
68
+ };
69
+
70
+ const results = cache.icons.filter(matchesQuery).sort((a, b) => rankMatch(a) - rankMatch(b));
65
71
 
66
72
  if(results.length === 0){
67
73
  console.log(`No icons found matching "${query}"`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kempo-ui",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "A Lit based web-component library",
6
6
  "main": "index.js",