finsignal-feed-explore 1.8.0 → 1.9.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.
Files changed (60) hide show
  1. package/README.md +308 -0
  2. package/dist/NewsFeed.d.ts +8 -54
  3. package/dist/NewsFeed.d.ts.map +1 -0
  4. package/dist/NewsFeed.js +120 -324
  5. package/dist/NewsFeed.js.map +1 -0
  6. package/dist/components/Chip.d.ts +9 -0
  7. package/dist/components/Chip.d.ts.map +1 -0
  8. package/dist/components/Chip.js +10 -0
  9. package/dist/components/Chip.js.map +1 -0
  10. package/dist/components/icons.d.ts +23 -0
  11. package/dist/components/icons.d.ts.map +1 -0
  12. package/dist/components/icons.js +22 -0
  13. package/dist/components/icons.js.map +1 -0
  14. package/dist/constants/api.d.ts +2 -0
  15. package/dist/constants/api.d.ts.map +1 -0
  16. package/dist/constants/api.js +2 -0
  17. package/dist/constants/api.js.map +1 -0
  18. package/dist/constants/market-events.d.ts +6 -0
  19. package/dist/constants/market-events.d.ts.map +1 -0
  20. package/dist/constants/market-events.js +28 -0
  21. package/dist/constants/market-events.js.map +1 -0
  22. package/dist/constants/mock-news.d.ts +3 -0
  23. package/dist/constants/mock-news.d.ts.map +1 -0
  24. package/dist/constants/mock-news.js +85 -0
  25. package/dist/constants/mock-news.js.map +1 -0
  26. package/dist/filters/FiltersOverlay.d.ts +13 -0
  27. package/dist/filters/FiltersOverlay.d.ts.map +1 -0
  28. package/dist/filters/FiltersOverlay.js +51 -0
  29. package/dist/filters/FiltersOverlay.js.map +1 -0
  30. package/dist/hooks/useFeedData.d.ts +18 -0
  31. package/dist/hooks/useFeedData.d.ts.map +1 -0
  32. package/dist/hooks/useFeedData.js +86 -0
  33. package/dist/hooks/useFeedData.js.map +1 -0
  34. package/dist/hooks/useFilters.d.ts +11 -0
  35. package/dist/hooks/useFilters.d.ts.map +1 -0
  36. package/dist/hooks/useFilters.js +35 -0
  37. package/dist/hooks/useFilters.js.map +1 -0
  38. package/dist/index.d.ts +17 -2
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +12 -1
  41. package/dist/index.js.map +1 -0
  42. package/dist/newsfeed.css +80 -168
  43. package/dist/snippets/NewsSnippet.d.ts +16 -22
  44. package/dist/snippets/NewsSnippet.d.ts.map +1 -0
  45. package/dist/snippets/NewsSnippet.js +52 -72
  46. package/dist/snippets/NewsSnippet.js.map +1 -0
  47. package/dist/types/index.d.ts +73 -0
  48. package/dist/types/index.d.ts.map +1 -0
  49. package/dist/types/index.js +2 -0
  50. package/dist/types/index.js.map +1 -0
  51. package/dist/utils/formatTimestamp.d.ts +5 -0
  52. package/dist/utils/formatTimestamp.d.ts.map +1 -0
  53. package/dist/utils/formatTimestamp.js +29 -0
  54. package/dist/utils/formatTimestamp.js.map +1 -0
  55. package/dist/utils/theme.d.ts +13 -0
  56. package/dist/utils/theme.d.ts.map +1 -0
  57. package/dist/utils/theme.js +12 -0
  58. package/dist/utils/theme.js.map +1 -0
  59. package/package.json +2 -2
  60. package/LICENSE +0 -22
package/README.md ADDED
@@ -0,0 +1,308 @@
1
+ # finsignal-feed-explore
2
+
3
+ News feed explorer components for React web applications. A comprehensive library for displaying and interacting with financial news feeds.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install finsignal-feed-explore
9
+ # or
10
+ yarn add finsignal-feed-explore
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```tsx
16
+ import { NewsFeed } from 'finsignal-feed-explore';
17
+ import 'finsignal-feed-explore/dist/newsfeed.css';
18
+
19
+ function App() {
20
+ return (
21
+ <NewsFeed
22
+ onNewsClick={(news) => console.log('Clicked:', news)}
23
+ onFiltersApply={(filters) => console.log('Filters:', filters)}
24
+ />
25
+ );
26
+ }
27
+ ```
28
+
29
+ > **Note:** `apiUrl` is optional. If not provided, the component will use the default API URL: `https://explore-gateway.changesandbox.ru/`
30
+
31
+ ## Main Components
32
+
33
+ ### NewsFeed
34
+
35
+ The main component for displaying a news feed with filtering, infinite scroll, and interactive actions.
36
+
37
+ ```tsx
38
+ import { NewsFeed } from 'finsignal-feed-explore';
39
+ import 'finsignal-feed-explore/dist/newsfeed.css';
40
+
41
+ <NewsFeed
42
+ onNewsClick={(news) => handleNewsClick(news)}
43
+ onShowFilter={() => console.log('Filter button clicked')}
44
+ initialFilters={['earnings', 'ipo']}
45
+ enableInfiniteScroll={true}
46
+ />
47
+ ```
48
+
49
+ ### NewsSnippet
50
+
51
+ Individual news item component that can be used standalone.
52
+
53
+ ```tsx
54
+ import { NewsSnippet } from 'finsignal-feed-explore';
55
+
56
+ <NewsSnippet
57
+ news={newsItem}
58
+ onShareClick={() => {}}
59
+ onBookmarkClick={() => {}}
60
+ showShareIcon={true}
61
+ showBookmarkIcon={true}
62
+ />
63
+ ```
64
+
65
+ ### FiltersOverlay
66
+
67
+ Filter overlay component for market events selection.
68
+
69
+ ```tsx
70
+ import { FiltersOverlay } from 'finsignal-feed-explore';
71
+
72
+ <FiltersOverlay
73
+ isOpen={isOpen}
74
+ selectedFilters={filters}
75
+ onClose={() => setIsOpen(false)}
76
+ onApply={(filters) => handleFiltersApply(filters)}
77
+ />
78
+ ```
79
+
80
+ ## Features
81
+
82
+ - ✅ Beautiful news snippets based on modern design system
83
+ - ✅ Filter news by market events (earnings, IPO, M&A, etc.)
84
+ - ✅ Configurable action buttons (share, bookmark, like, dislike, AI)
85
+ - ✅ Callbacks for all user interactions
86
+ - ✅ API integration with `/api/v1/content/search` endpoint
87
+ - ✅ **Mock data fallback** - Shows 3 example news items when API is unavailable
88
+ - ✅ Infinite scroll support
89
+ - ✅ Light theme (web optimized)
90
+ - ✅ Responsive design
91
+ - ✅ TypeScript support
92
+ - ✅ React Native Web compatible
93
+
94
+ ## API Reference
95
+
96
+ ### NewsFeed Props
97
+
98
+ | Prop | Type | Required | Description |
99
+ |------|------|----------|-------------|
100
+ | `apiUrl` | `string` | No | Base API URL for fetching news (default: `https://explore-gateway.changesandbox.ru/`) |
101
+ | `onNewsClick` | `(news: NewsItem) => void` | No | Called when news item is clicked |
102
+ | `onShareClick` | `(news: NewsItem) => void` | No | Called when share button is clicked |
103
+ | `onBookmarkClick` | `(news: NewsItem) => void` | No | Called when bookmark button is clicked |
104
+ | `onLikeClick` | `(news: NewsItem) => void` | No | Called when like button is clicked |
105
+ | `onDislikeClick` | `(news: NewsItem) => void` | No | Called when dislike button is clicked |
106
+ | `onAIClick` | `(news: NewsItem) => void` | No | Called when AI button is clicked |
107
+ | `onFiltersOpen` | `() => void` | No | Called when filters overlay opens |
108
+ | `onFiltersClose` | `() => void` | No | Called when filters overlay closes |
109
+ | `onFiltersApply` | `(filters: string[]) => void` | No | Called when filters are applied |
110
+ | `onShowFilter` | `() => void` | No | Called when filter button is clicked (before opening internal overlay) |
111
+ | `showShareIcon` | `boolean` | No | Show/hide share button (default: true) |
112
+ | `showBookmarkIcon` | `boolean` | No | Show/hide bookmark button (default: true) |
113
+ | `showLikeIcon` | `boolean` | No | Show/hide like button (default: true) |
114
+ | `showDislikeIcon` | `boolean` | No | Show/hide dislike button (default: true) |
115
+ | `showAIIcon` | `boolean` | No | Show/hide AI button (default: true) |
116
+ | `showFilterIcon` | `boolean` | No | Show/hide filter button (default: true) |
117
+ | `initialFilters` | `string[]` | No | Initial market events filters |
118
+ | `enableInfiniteScroll` | `boolean` | No | Enable/disable infinite scroll (default: true) |
119
+ | `marketEventsTaxonomy` | `MarketEventTaxonomyItem[]` | No | Custom market events taxonomy |
120
+
121
+ ## Types
122
+
123
+ ### NewsItem
124
+
125
+ ```typescript
126
+ interface NewsItem {
127
+ id: string;
128
+ title: string;
129
+ content: string;
130
+ source?: string;
131
+ sourceUrl?: string;
132
+ sources?: Array<{
133
+ name: string;
134
+ url?: string;
135
+ logo?: string;
136
+ }>;
137
+ timestamp?: string;
138
+ cover?: string;
139
+ recommendation?: {
140
+ text: string;
141
+ priceRange?: string;
142
+ };
143
+ stocks?: Array<{
144
+ symbol: string;
145
+ price: string;
146
+ change: string;
147
+ changeType: 'positive' | 'negative';
148
+ logo?: string;
149
+ }>;
150
+ summary?: string;
151
+ tags?: string[];
152
+ personalizedKeyPoints?: string[];
153
+ market_events?: string[];
154
+ }
155
+ ```
156
+
157
+ ## Hooks
158
+
159
+ ### useFeedData
160
+
161
+ Hook for fetching and managing feed data.
162
+
163
+ ```tsx
164
+ import { useFeedData } from 'finsignal-feed-explore';
165
+
166
+ const { items, isLoading, hasMore, loadMore, refresh } = useFeedData({
167
+ filters: ['earnings'],
168
+ limit: 20
169
+ });
170
+ ```
171
+
172
+ ### useFilters
173
+
174
+ Hook for managing filter state.
175
+
176
+ ```tsx
177
+ import { useFilters } from 'finsignal-feed-explore';
178
+
179
+ const {
180
+ selectedMarketEvents,
181
+ isOpen,
182
+ toggleFilter,
183
+ clearFilters,
184
+ setFilters,
185
+ openFilters,
186
+ closeFilters
187
+ } = useFilters(['earnings']);
188
+ ```
189
+
190
+ ## Constants
191
+
192
+ ### MARKET_EVENT_TAXONOMY
193
+
194
+ Default market events taxonomy with categories like earnings, IPO, M&A, etc.
195
+
196
+ ```tsx
197
+ import { MARKET_EVENT_TAXONOMY } from 'finsignal-feed-explore';
198
+ ```
199
+
200
+ ### MOCK_NEWS
201
+
202
+ Mock news data for development and fallback scenarios.
203
+
204
+ ```tsx
205
+ import { MOCK_NEWS } from 'finsignal-feed-explore';
206
+
207
+ // Array of 3 example news items
208
+ console.log(MOCK_NEWS);
209
+ ```
210
+
211
+ ### DEFAULT_API_URL
212
+
213
+ Default API URL used when `apiUrl` is not provided.
214
+
215
+ ```tsx
216
+ import { DEFAULT_API_URL } from 'finsignal-feed-explore';
217
+
218
+ console.log(DEFAULT_API_URL); // 'https://explore-gateway.changesandbox.ru/'
219
+ ```
220
+
221
+ ## Utilities
222
+
223
+ ### formatTimestamp
224
+
225
+ Utility function for formatting timestamps.
226
+
227
+ ```tsx
228
+ import { formatTimestamp } from 'finsignal-feed-explore';
229
+
230
+ const formatted = formatTimestamp('2024-01-15T10:30:00Z');
231
+ ```
232
+
233
+ ### theme
234
+
235
+ Theme configuration object.
236
+
237
+ ```tsx
238
+ import { theme } from 'finsignal-feed-explore';
239
+
240
+ // Access theme colors, spacing, etc.
241
+ console.log(theme.colors);
242
+ ```
243
+
244
+ ## API Integration
245
+
246
+ The component expects the API to follow this structure:
247
+
248
+ **Default API URL:** `https://explore-gateway.changesandbox.ru/`
249
+
250
+ **Endpoint:** `POST {apiUrl}/api/v1/content/search`
251
+
252
+ **Request:**
253
+ ```json
254
+ {
255
+ "limit": 20,
256
+ "offset": 0,
257
+ "market_events": ["earnings", "ipo"]
258
+ }
259
+ ```
260
+
261
+ **Response:**
262
+ ```json
263
+ {
264
+ "items": [...],
265
+ "next_offset": 20,
266
+ "total": 100,
267
+ "offset": 0,
268
+ "limit": 20
269
+ }
270
+ ```
271
+
272
+ ## Mock Data
273
+
274
+ The widget automatically displays 3 example news items when:
275
+ - API is unavailable or returns an error
276
+ - No real news data is loaded yet
277
+
278
+ This ensures users always see content, even during development or API downtime.
279
+
280
+ ## Development
281
+
282
+ ```bash
283
+ # Install dependencies
284
+ npm install
285
+
286
+ # Build
287
+ npm run build
288
+
289
+ # The build will automatically run before publishing
290
+ npm publish
291
+ ```
292
+
293
+ ## Peer Dependencies
294
+
295
+ - `react`: >=18.0.0
296
+
297
+ ## Dependencies
298
+
299
+ - `lucide-react`: ^0.544.0 (for icons)
300
+ - `react-native-web`: ^0.20.0 (for cross-platform compatibility)
301
+
302
+ ## License
303
+
304
+ MIT
305
+
306
+ ## Repository
307
+
308
+ [GitHub Repository](https://github.com/finsignal/segment-control)
@@ -1,55 +1,9 @@
1
- import './newsfeed.css';
2
- export interface FeedItem {
3
- content_id: string;
4
- author_id?: string | null;
5
- title?: string | null;
6
- body?: string | null;
7
- type: 'post' | 'signal' | 'news' | 'strategies' | 'trigger' | 'market_vibe' | 'guides';
8
- source: 'user' | 'provider' | 'api';
9
- created_at: string;
10
- score: number;
11
- thumbnail_url?: string | null;
12
- metadata: {
13
- ai_processed?: boolean;
14
- processing_status?: string;
15
- ai_processing?: {
16
- status: string;
17
- message: string;
18
- };
19
- news?: {
20
- recommendation?: {
21
- text: string;
22
- priceRange: string;
23
- };
24
- stocks?: Array<{
25
- symbol: string;
26
- price: string;
27
- change: string;
28
- changeType: 'positive' | 'negative';
29
- }>;
30
- };
31
- signal?: {
32
- symbol: string;
33
- companyName: string;
34
- metrics: {
35
- buy: string;
36
- entry: string;
37
- takeProfit: string;
38
- stopLoss: string;
39
- };
40
- };
41
- ai_categorization?: {
42
- primaryCategory: string;
43
- tags: string[];
44
- };
45
- };
1
+ import React from 'react';
2
+ import { WidgetConfig } from './types';
3
+ import './NewsFeed.css';
4
+ export interface NewsFeedProps extends WidgetConfig {
5
+ initialFilters?: string[];
6
+ enableInfiniteScroll?: boolean;
46
7
  }
47
- export interface FeedListProps {
48
- feedType?: 'trending' | 'personal' | 'hot';
49
- items?: FeedItem[];
50
- onItemClick?: (item: FeedItem) => void;
51
- className?: string;
52
- feedApiUrl?: string;
53
- useMockData?: boolean;
54
- }
55
- export declare function FeedList({ feedType, items: itemsProp, onItemClick, className, feedApiUrl, useMockData }: FeedListProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare const NewsFeed: React.FC<NewsFeedProps>;
9
+ //# sourceMappingURL=NewsFeed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NewsFeed.d.ts","sourceRoot":"","sources":["../src/NewsFeed.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAMxE,OAAO,EAAE,YAAY,EAAY,MAAM,SAAS,CAAC;AAIjD,OAAO,gBAAgB,CAAC;AAExB,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA8O5C,CAAC"}