@robosystems/core 0.5.0 → 0.5.1
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 +1 -1
- package/research/CoverageBrowser.d.ts +19 -0
- package/research/CoverageBrowser.js +35 -0
- package/research/index.d.ts +1 -0
- package/research/index.js +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CoverageItem } from './types';
|
|
2
|
+
export interface CoverageBrowserProps {
|
|
3
|
+
items: CoverageItem[];
|
|
4
|
+
/** Base path for card links, forwarded to the grid (defaults to /research). */
|
|
5
|
+
hrefBase?: string;
|
|
6
|
+
/** Override the search box placeholder. */
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The research listing with a live client-side filter above it. A drop-in
|
|
11
|
+
* replacement for {@link CoverageGrid}: the full grid renders on first paint
|
|
12
|
+
* (so the server-rendered SEO page keeps every card in its HTML), and typing
|
|
13
|
+
* narrows it in the browser. Matches ticker, company, title, and tags —
|
|
14
|
+
* someone who types "Green Thumb" finds GTBIF without knowing the symbol.
|
|
15
|
+
*
|
|
16
|
+
* Filtering the whole in-memory catalog is fine at this scale; when the
|
|
17
|
+
* catalog outgrows a single fetch this is where server-backed search slots in.
|
|
18
|
+
*/
|
|
19
|
+
export declare function CoverageBrowser({ items, hrefBase, placeholder, }: CoverageBrowserProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { TextInput } from 'flowbite-react';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
|
+
import { HiSearch } from 'react-icons/hi';
|
|
6
|
+
import { CoverageGrid } from './CoverageGrid';
|
|
7
|
+
/**
|
|
8
|
+
* The research listing with a live client-side filter above it. A drop-in
|
|
9
|
+
* replacement for {@link CoverageGrid}: the full grid renders on first paint
|
|
10
|
+
* (so the server-rendered SEO page keeps every card in its HTML), and typing
|
|
11
|
+
* narrows it in the browser. Matches ticker, company, title, and tags —
|
|
12
|
+
* someone who types "Green Thumb" finds GTBIF without knowing the symbol.
|
|
13
|
+
*
|
|
14
|
+
* Filtering the whole in-memory catalog is fine at this scale; when the
|
|
15
|
+
* catalog outgrows a single fetch this is where server-backed search slots in.
|
|
16
|
+
*/
|
|
17
|
+
export function CoverageBrowser({ items, hrefBase, placeholder = 'Search by ticker, company, or title…', }) {
|
|
18
|
+
const [query, setQuery] = useState('');
|
|
19
|
+
const filtered = useMemo(() => {
|
|
20
|
+
const term = query.trim().toLowerCase();
|
|
21
|
+
if (!term)
|
|
22
|
+
return items;
|
|
23
|
+
return items.filter((item) => item.ticker.toLowerCase().includes(term) ||
|
|
24
|
+
item.company.toLowerCase().includes(term) ||
|
|
25
|
+
item.title.toLowerCase().includes(term) ||
|
|
26
|
+
item.tags.some((tag) => tag.toLowerCase().includes(term)));
|
|
27
|
+
}, [items, query]);
|
|
28
|
+
// Empty catalog: let the grid render its own "no coverage yet" state, no
|
|
29
|
+
// point showing a search box over nothing.
|
|
30
|
+
if (!items.length) {
|
|
31
|
+
return _jsx(CoverageGrid, { items: items, hrefBase: hrefBase });
|
|
32
|
+
}
|
|
33
|
+
const term = query.trim();
|
|
34
|
+
return (_jsxs("div", { className: "space-y-6", children: [_jsx(TextInput, { icon: HiSearch, type: "search", value: query, onChange: (e) => setQuery(e.target.value), placeholder: placeholder, "aria-label": "Search research" }), term && filtered.length === 0 ? (_jsxs("p", { className: "py-12 text-center text-gray-500 dark:text-gray-400", children: ["No results for \u201C", term, "\u201D."] })) : (_jsx(CoverageGrid, { items: filtered, hrefBase: hrefBase }))] }));
|
|
35
|
+
}
|
package/research/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { CATALOG_URL, fetchBrief, fetchCatalog, getAllCoverage, getCoverage, getCoverageTickers, youtubeId, } from './catalog';
|
|
2
|
+
export { CoverageBrowser, type CoverageBrowserProps } from './CoverageBrowser';
|
|
2
3
|
export { CoverageCard } from './CoverageCard';
|
|
3
4
|
export { CoverageGrid } from './CoverageGrid';
|
|
4
5
|
export { CoverageHistory } from './CoverageHistory';
|
package/research/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// roboinvestor-app (logged-in). Data layer reads the S3 catalog produced by
|
|
3
3
|
// robosystems-content-machine; components render the coverage + continuing-coverage thread.
|
|
4
4
|
export { CATALOG_URL, fetchBrief, fetchCatalog, getAllCoverage, getCoverage, getCoverageTickers, youtubeId, } from './catalog';
|
|
5
|
+
export { CoverageBrowser } from './CoverageBrowser';
|
|
5
6
|
export { CoverageCard } from './CoverageCard';
|
|
6
7
|
export { CoverageGrid } from './CoverageGrid';
|
|
7
8
|
export { CoverageHistory } from './CoverageHistory';
|