@umituz/web-dashboard 7.3.0 → 7.4.0

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": "@umituz/web-dashboard",
3
- "version": "7.3.0",
3
+ "version": "7.4.0",
4
4
  "description": "Installable app skeleton for the fleet — layouts, analytics (dependency-free SVG charts), calendar, onboarding flow permissions/module registry; udb-* stylesheet on design-system tokens",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -0,0 +1,39 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { hitsToCommandItems } from './hitsToCommandItems';
3
+ import type { SearchHit } from './searchItems';
4
+
5
+ const HITS: SearchHit[] = [
6
+ { id: 'c2', title: 'IELTS reading sprint', subtitle: 'Skimming strategies', category: 'C1', to: '/courses/c2' },
7
+ { id: 'c1', title: 'Present perfect workshop', subtitle: 'Have you ever…', category: 'B1', to: '/courses/c1' },
8
+ ];
9
+
10
+ describe('hitsToCommandItems', () => {
11
+ it('maps hits to palette entries with title as label and category as hint', () => {
12
+ const items = hitsToCommandItems(HITS, vi.fn());
13
+ expect(items).toHaveLength(2);
14
+ expect(items[0]).toMatchObject({ id: 'c2', label: 'IELTS reading sprint', hint: 'C1' });
15
+ });
16
+
17
+ it('carries subtitle+category as keywords so body-only matches survive the palette filter', () => {
18
+ const items = hitsToCommandItems(HITS, vi.fn());
19
+ expect(items[0]?.keywords).toBe('Skimming strategies C1');
20
+ });
21
+
22
+ it('navigates to the hit route on select', () => {
23
+ const navigate = vi.fn();
24
+ const items = hitsToCommandItems(HITS, navigate);
25
+ items[1]?.onSelect();
26
+ expect(navigate).toHaveBeenCalledWith('/courses/c1');
27
+ });
28
+
29
+ it('omits the hint when the category is blank', () => {
30
+ const hits: SearchHit[] = [{ id: 'x', title: 'Note', subtitle: 'Body', category: '', to: '/notes/x' }];
31
+ const items = hitsToCommandItems(hits, vi.fn());
32
+ expect(items[0]?.hint).toBeUndefined();
33
+ expect(items[0]?.keywords).toBe('Body');
34
+ });
35
+
36
+ it('returns an empty array for empty hits', () => {
37
+ expect(hitsToCommandItems([], vi.fn())).toEqual([]);
38
+ });
39
+ });
@@ -0,0 +1,14 @@
1
+ import type { CommandItem } from '@umituz/web-design-system/organisms';
2
+ import type { SearchHit } from './searchItems';
3
+
4
+ export type NavigateFn = (to: string) => void;
5
+
6
+ export function hitsToCommandItems(hits: readonly SearchHit[], navigate: NavigateFn): CommandItem[] {
7
+ return hits.map((hit) => ({
8
+ id: hit.id,
9
+ label: hit.title,
10
+ hint: hit.category || undefined,
11
+ keywords: `${hit.subtitle} ${hit.category}`.trim(),
12
+ onSelect: () => navigate(hit.to),
13
+ }));
14
+ }
@@ -1,2 +1,4 @@
1
1
  export { searchItems } from './searchItems';
2
2
  export type { SearchHit } from './searchItems';
3
+ export { hitsToCommandItems } from './hitsToCommandItems';
4
+ export type { NavigateFn } from './hitsToCommandItems';