@feedlog-ai/react 0.0.3 → 0.0.5

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 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",
3
+ "version": "0.0.5",
4
4
  "description": "React bindings for Feedlog Toolkit Web Components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "react-dom": ">=17.0.0"
29
29
  },
30
30
  "dependencies": {
31
- "@feedlog-ai/webcomponents": "*"
31
+ "@feedlog-ai/webcomponents": "workspace:*"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@jest/test-sequencer": "^29.7.0",
@@ -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
  }
package/dist/index.d.ts DELETED
@@ -1,39 +0,0 @@
1
- /**
2
- * React bindings for Feedlog Toolkit Web Components
3
- *
4
- * This package provides React components that wrap the Stencil web components.
5
- * Components are manually created to avoid Stencil generation issues.
6
- */
7
- import React from 'react';
8
- import { FeedlogIssue } from '@feedlog-ai/core';
9
- export declare const FeedlogBadge: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
10
- variant?: string;
11
- } & React.RefAttributes<HTMLElement>>;
12
- export declare const FeedlogButton: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
13
- size?: string;
14
- variant?: string;
15
- disabled?: boolean;
16
- type?: string;
17
- onFeedlogClick?: (event: CustomEvent<MouseEvent>) => void;
18
- } & React.RefAttributes<HTMLElement>>;
19
- export declare const FeedlogCard: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>;
20
- export declare const FeedlogGithubIssues: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
21
- issues?: FeedlogIssue[];
22
- theme?: string;
23
- loading?: boolean;
24
- onFeedlogUpvote?: (event: CustomEvent<{
25
- issueId: string;
26
- currentUpvoted: boolean;
27
- currentCount: number;
28
- }>) => void;
29
- } & React.RefAttributes<HTMLElement>>;
30
- export declare const FeedlogGithubIssuesClient: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>;
31
- export declare const FeedlogIssuesList: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
32
- issues?: FeedlogIssue[];
33
- onFeedlogUpvote?: (event: CustomEvent<{
34
- issueId: string;
35
- currentUpvoted: boolean;
36
- currentCount: number;
37
- }>) => void;
38
- } & React.RefAttributes<HTMLElement>>;
39
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,eAAO,MAAM,YAAY;cAEyB,MAAM;qCAGvD,CAAC;AAGF,eAAO,MAAM,aAAa;WAGf,MAAM;cACH,MAAM;eACL,OAAO;WACX,MAAM;qBACI,CAAC,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC,KAAK,IAAI;qCAI5D,CAAC;AAGF,eAAO,MAAM,WAAW,uGAEvB,CAAC;AAGF,eAAO,MAAM,mBAAmB;aAGnB,YAAY,EAAE;YACf,MAAM;cACJ,OAAO;sBACC,CAChB,KAAK,EAAE,WAAW,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,OAAO,CAAC;QACxB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC,KACC,IAAI;qCAIZ,CAAC;AAGF,eAAO,MAAM,yBAAyB,uGAKrC,CAAC;AAGF,eAAO,MAAM,iBAAiB;aAGjB,YAAY,EAAE;sBACL,CAChB,KAAK,EAAE,WAAW,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,OAAO,CAAC;QACxB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC,KACC,IAAI;qCAIZ,CAAC"}
package/dist/index.js DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * React bindings for Feedlog Toolkit Web Components
3
- *
4
- * This package provides React components that wrap the Stencil web components.
5
- * Components are manually created to avoid Stencil generation issues.
6
- */
7
- import React from 'react';
8
- import { defineCustomElements } from '@feedlog-ai/webcomponents/loader';
9
- // Simple React wrappers for web components
10
- export const FeedlogBadge = React.forwardRef(({ children, ...props }, ref) => React.createElement('feedlog-badge', { ...props, ref }, children));
11
- FeedlogBadge.displayName = 'FeedlogBadge';
12
- export const FeedlogButton = React.forwardRef(({ children, ...props }, ref) => React.createElement('feedlog-button', { ...props, ref }, children));
13
- FeedlogButton.displayName = 'FeedlogButton';
14
- export const FeedlogCard = React.forwardRef(({ children, ...props }, ref) => React.createElement('feedlog-card', { ...props, ref }, children));
15
- FeedlogCard.displayName = 'FeedlogCard';
16
- export const FeedlogGithubIssues = React.forwardRef(({ children, ...props }, ref) => React.createElement('feedlog-github-issues', { ...props, ref }, children));
17
- FeedlogGithubIssues.displayName = 'FeedlogGithubIssues';
18
- export const FeedlogGithubIssuesClient = React.forwardRef(({ children, ...props }, ref) => React.createElement('feedlog-github-issues-client', { ...props, ref }, children));
19
- FeedlogGithubIssuesClient.displayName = 'FeedlogGithubIssuesClient';
20
- export const FeedlogIssuesList = React.forwardRef(({ children, ...props }, ref) => React.createElement('feedlog-issues-list', { ...props, ref }, children));
21
- FeedlogIssuesList.displayName = 'FeedlogIssuesList';
22
- // Auto-define custom elements when this module is imported
23
- if (typeof window !== 'undefined') {
24
- defineCustomElements();
25
- }
26
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,2CAA2C;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC,UAAU,CAG1C,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAChC,KAAK,CAAC,aAAa,CAAC,eAAe,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,EAAE,QAAQ,CAAC,CAClE,CAAC;AACF,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAE1C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CAS3C,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAChC,KAAK,CAAC,aAAa,CAAC,gBAAgB,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,EAAE,QAAQ,CAAC,CACnE,CAAC;AACF,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC;AAE5C,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CACzC,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,cAAc,EAAE,EAAE,GAAG,KAAK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