@feedlog-ai/react 0.0.1 → 0.0.4
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/README.md +238 -0
- package/package.json +5 -2
package/README.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# @feedlog-ai/react
|
|
2
|
+
|
|
3
|
+
React bindings for Feedlog Toolkit web components. Auto-generated from Stencil components with full TypeScript support.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **React Components**: Native React components with JSX support
|
|
8
|
+
- **TypeScript Support**: Full type safety with TypeScript definitions
|
|
9
|
+
- **Auto-generated**: Generated from Stencil web components for consistency
|
|
10
|
+
- **Event Handling**: React-friendly event handling with proper typing
|
|
11
|
+
- **Peer Dependencies**: React >=17.0.0 and React DOM >=17.0.0
|
|
12
|
+
- **Tree Shakeable**: Only import the components you need
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @feedlog-ai/react
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Components
|
|
21
|
+
|
|
22
|
+
### FeedlogGithubIssuesClient
|
|
23
|
+
|
|
24
|
+
The main component for displaying GitHub issues with built-in SDK integration.
|
|
25
|
+
|
|
26
|
+
**Props:**
|
|
27
|
+
|
|
28
|
+
- `apiKey`: API key for Feedlog authentication (required)
|
|
29
|
+
- `type?`: Filter by issue type - `'bug'` or `'enhancement'`
|
|
30
|
+
- `limit?`: Maximum issues to fetch (1-100, default: 10)
|
|
31
|
+
- `endpoint?`: Custom API endpoint
|
|
32
|
+
- `maxWidth?`: Container max width (default: `'42rem'`)
|
|
33
|
+
- `theme?`: Theme variant - `'light'` or `'dark'` (default: `'light'`)
|
|
34
|
+
- `showThemeToggle?`: Show theme toggle button (default: `true`)
|
|
35
|
+
|
|
36
|
+
**Events:**
|
|
37
|
+
|
|
38
|
+
- `onFeedlogUpvote`: Called when an issue is upvoted
|
|
39
|
+
- `onFeedlogThemeChange`: Called when theme changes
|
|
40
|
+
- `onFeedlogError`: Called on errors
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import React from 'react';
|
|
46
|
+
import { FeedlogGithubIssuesClient } from '@feedlog-ai/react';
|
|
47
|
+
|
|
48
|
+
function App() {
|
|
49
|
+
return (
|
|
50
|
+
<div>
|
|
51
|
+
<FeedlogGithubIssuesClient
|
|
52
|
+
apiKey="your-api-key"
|
|
53
|
+
type="bug"
|
|
54
|
+
limit={10}
|
|
55
|
+
theme="light"
|
|
56
|
+
maxWidth="42rem"
|
|
57
|
+
onFeedlogUpvote={event => {
|
|
58
|
+
console.log('Issue upvoted:', event.detail);
|
|
59
|
+
// event.detail contains: { issueId, upvoted, upvoteCount }
|
|
60
|
+
}}
|
|
61
|
+
onFeedlogThemeChange={event => {
|
|
62
|
+
console.log('Theme changed to:', event.detail); // 'light' or 'dark'
|
|
63
|
+
}}
|
|
64
|
+
onFeedlogError={event => {
|
|
65
|
+
console.error('Error occurred:', event.detail);
|
|
66
|
+
// event.detail contains: { error, code? }
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default App;
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Event Handling
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import React, { useCallback } from 'react';
|
|
80
|
+
import { FeedlogGithubIssuesClient } from '@feedlog-ai/react';
|
|
81
|
+
|
|
82
|
+
function IssuesComponent() {
|
|
83
|
+
const handleUpvote = useCallback((event: CustomEvent) => {
|
|
84
|
+
const { issueId, upvoted, upvoteCount } = event.detail;
|
|
85
|
+
console.log(`Issue ${issueId} ${upvoted ? 'upvoted' : 'unvoted'}`);
|
|
86
|
+
console.log(`New upvote count: ${upvoteCount}`);
|
|
87
|
+
}, []);
|
|
88
|
+
|
|
89
|
+
const handleThemeChange = useCallback((event: CustomEvent<'light' | 'dark'>) => {
|
|
90
|
+
console.log(`Theme changed to: ${event.detail}`);
|
|
91
|
+
// Update your app's theme state here
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
const handleError = useCallback((event: CustomEvent) => {
|
|
95
|
+
const { error, code } = event.detail;
|
|
96
|
+
console.error(`Feedlog error (${code}):`, error);
|
|
97
|
+
// Handle error in your UI
|
|
98
|
+
}, []);
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<FeedlogGithubIssuesClient
|
|
102
|
+
apiKey="your-api-key"
|
|
103
|
+
onFeedlogUpvote={handleUpvote}
|
|
104
|
+
onFeedlogThemeChange={handleThemeChange}
|
|
105
|
+
onFeedlogError={handleError}
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### With State Management
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
import React, { useState, useCallback } from 'react';
|
|
115
|
+
import { FeedlogGithubIssuesClient } from '@feedlog-ai/react';
|
|
116
|
+
|
|
117
|
+
function IssuesWithState() {
|
|
118
|
+
const [theme, setTheme] = useState<'light' | 'dark'>('light');
|
|
119
|
+
const [error, setError] = useState<string | null>(null);
|
|
120
|
+
|
|
121
|
+
const handleThemeChange = useCallback((event: CustomEvent<'light' | 'dark'>) => {
|
|
122
|
+
setTheme(event.detail);
|
|
123
|
+
}, []);
|
|
124
|
+
|
|
125
|
+
const handleError = useCallback((event: CustomEvent) => {
|
|
126
|
+
setError(event.detail.error);
|
|
127
|
+
// Clear error after 5 seconds
|
|
128
|
+
setTimeout(() => setError(null), 5000);
|
|
129
|
+
}, []);
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<div>
|
|
133
|
+
{error && <div className="error-banner">Error: {error}</div>}
|
|
134
|
+
|
|
135
|
+
<FeedlogGithubIssuesClient
|
|
136
|
+
apiKey="your-api-key"
|
|
137
|
+
theme={theme}
|
|
138
|
+
onFeedlogThemeChange={handleThemeChange}
|
|
139
|
+
onFeedlogError={handleError}
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Other Components
|
|
147
|
+
|
|
148
|
+
The package also includes React bindings for additional UI components:
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import {
|
|
152
|
+
FeedlogBadge,
|
|
153
|
+
FeedlogButton,
|
|
154
|
+
FeedlogCard,
|
|
155
|
+
FeedlogGithubIssues,
|
|
156
|
+
FeedlogIssuesList
|
|
157
|
+
} from '@feedlog-ai/react';
|
|
158
|
+
|
|
159
|
+
// Badge component
|
|
160
|
+
<FeedlogBadge variant="primary" text="New" />
|
|
161
|
+
|
|
162
|
+
// Button component
|
|
163
|
+
<FeedlogButton variant="primary" size="lg" onFeedlogClick={handleClick}>
|
|
164
|
+
Click me
|
|
165
|
+
</FeedlogButton>
|
|
166
|
+
|
|
167
|
+
// Card component
|
|
168
|
+
<FeedlogCard>
|
|
169
|
+
<h3>Card Title</h3>
|
|
170
|
+
<p>Card content</p>
|
|
171
|
+
</FeedlogCard>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## TypeScript Support
|
|
175
|
+
|
|
176
|
+
All components are fully typed. Import types from the core package if needed:
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
import { FeedlogIssue } from '@feedlog-ai/core';
|
|
180
|
+
import { FeedlogGithubIssuesClient } from '@feedlog-ai/react';
|
|
181
|
+
|
|
182
|
+
// Type-safe event handling
|
|
183
|
+
const handleUpvote = (
|
|
184
|
+
event: CustomEvent<{
|
|
185
|
+
issueId: string;
|
|
186
|
+
upvoted: boolean;
|
|
187
|
+
upvoteCount: number;
|
|
188
|
+
}>
|
|
189
|
+
) => {
|
|
190
|
+
// Fully typed event detail
|
|
191
|
+
console.log(event.detail.issueId);
|
|
192
|
+
console.log(event.detail.upvoted);
|
|
193
|
+
console.log(event.detail.upvoteCount);
|
|
194
|
+
};
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Requirements
|
|
198
|
+
|
|
199
|
+
- React >= 17.0.0
|
|
200
|
+
- React DOM >= 17.0.0
|
|
201
|
+
- Modern browsers with Web Components support
|
|
202
|
+
|
|
203
|
+
## Browser Support
|
|
204
|
+
|
|
205
|
+
Same as the underlying web components:
|
|
206
|
+
|
|
207
|
+
- Chrome 61+
|
|
208
|
+
- Firefox 63+
|
|
209
|
+
- Safari 11+
|
|
210
|
+
- Edge 79+
|
|
211
|
+
|
|
212
|
+
## Migration from Direct Web Components
|
|
213
|
+
|
|
214
|
+
If you're migrating from using web components directly:
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
// Before (direct web component)
|
|
218
|
+
<feedlog-github-issues-client
|
|
219
|
+
api-key="key"
|
|
220
|
+
onFeedlogUpvote={(e) => console.log(e.detail)}
|
|
221
|
+
/>
|
|
222
|
+
|
|
223
|
+
// After (React component)
|
|
224
|
+
<FeedlogGithubIssuesClient
|
|
225
|
+
apiKey="key"
|
|
226
|
+
onFeedlogUpvote={(e) => console.log(e.detail)}
|
|
227
|
+
/>
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Key differences:**
|
|
231
|
+
|
|
232
|
+
- `api-key` → `apiKey` (camelCase)
|
|
233
|
+
- Event handlers follow React conventions
|
|
234
|
+
- All props are properly typed
|
|
235
|
+
|
|
236
|
+
## License
|
|
237
|
+
|
|
238
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feedlog-ai/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "React bindings for Feedlog Toolkit Web Components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -51,5 +51,8 @@
|
|
|
51
51
|
"components",
|
|
52
52
|
"data-visualization"
|
|
53
53
|
],
|
|
54
|
-
"license": "MIT"
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
}
|
|
55
58
|
}
|