hocmai-feedback-widget 0.1.14 → 0.2.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/README.md +42 -32
- package/dist/components/FeedbackWidget.d.ts +2 -1
- package/dist/context/FeedbackContext.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/support-feedback-lib.es.js +2155 -1247
- package/dist/support-feedback-lib.umd.js +23 -3
- package/dist/test-mobile-screenshot.html +211 -0
- package/dist/test-simple-capture.html +107 -0
- package/dist/utils/screenshot/background-renderer.d.ts +3 -0
- package/dist/utils/screenshot/canvas-renderer.d.ts +9 -0
- package/dist/utils/screenshot/cleanup.d.ts +3 -0
- package/dist/utils/screenshot/device-detection.d.ts +16 -0
- package/dist/utils/screenshot/element-collector.d.ts +10 -0
- package/dist/utils/screenshot/image-renderer.d.ts +21 -0
- package/dist/utils/screenshot/performance.d.ts +3 -0
- package/dist/utils/screenshot/svg-renderer.d.ts +24 -0
- package/dist/utils/screenshot/text-renderer.d.ts +23 -0
- package/dist/utils/screenshot/types.d.ts +35 -0
- package/dist/utils/screenshot.d.ts +9 -7
- package/package.json +6 -3
- package/src/App.css +42 -0
- package/src/App.tsx +75 -0
- package/src/assets/react.svg +1 -0
- package/src/components/CropOverlay.tsx +174 -0
- package/src/components/FeedbackWidget.tsx +854 -0
- package/src/context/FeedbackContext.tsx +66 -0
- package/src/index.css +68 -0
- package/src/index.ts +7 -0
- package/src/main.tsx +10 -0
- package/src/utils/device.ts +22 -0
- package/src/utils/screenshot/background-renderer.ts +54 -0
- package/src/utils/screenshot/canvas-renderer.ts +343 -0
- package/src/utils/screenshot/cleanup.ts +32 -0
- package/src/utils/screenshot/device-detection.ts +90 -0
- package/src/utils/screenshot/element-collector.ts +134 -0
- package/src/utils/screenshot/image-renderer.ts +148 -0
- package/src/utils/screenshot/performance.ts +57 -0
- package/src/utils/screenshot/svg-renderer.ts +149 -0
- package/src/utils/screenshot/text-renderer.ts +212 -0
- package/src/utils/screenshot/types.ts +40 -0
- package/src/utils/screenshot.ts +83 -0
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ A React library for collecting user feedback with screenshot capabilities, conte
|
|
|
5
5
|
## Features
|
|
6
6
|
- **Context-Aware**: Support for multiple questions/items on a single page.
|
|
7
7
|
- **Screenshot Capture**: Automatic viewport capture with cropping/highlighting.
|
|
8
|
+
- **Auto-Upload**: Screenshots are automatically uploaded to S3 and returned as URLs.
|
|
8
9
|
- **Image Protection**: Prevents right-click/download on sensitive screenshots.
|
|
9
10
|
- **Responsive**: Mobile-friendly "bottom sheet" style on small screens.
|
|
10
11
|
- **Customizable**: Theme colors, context data, and error types.
|
|
@@ -37,13 +38,13 @@ Wrap your root component (or the section of the app that needs feedback) with `F
|
|
|
37
38
|
```tsx
|
|
38
39
|
import { FeedbackProvider, type FeedbackData } from 'hocmai-feedback-widget';
|
|
39
40
|
// If styles are not automatically injected by your bundler, you might need:
|
|
40
|
-
// import '
|
|
41
|
+
// import 'hocmai-feedback-widget/dist/style.css';
|
|
41
42
|
|
|
42
43
|
function App() {
|
|
43
44
|
const handleSubmit = async (data: FeedbackData) => {
|
|
44
45
|
// Send data to your API
|
|
45
46
|
console.log('Feedback submitted:', data);
|
|
46
|
-
// data.
|
|
47
|
+
// data.listImage contains URLs of uploaded images
|
|
47
48
|
// data.deviceInfo contains browser/OS info
|
|
48
49
|
// data.errorType contains the selected category
|
|
49
50
|
};
|
|
@@ -69,7 +70,7 @@ const QuestionItem = ({ id, content }) => {
|
|
|
69
70
|
<div className="card">
|
|
70
71
|
<p>{content}</p>
|
|
71
72
|
<button
|
|
72
|
-
onClick={() => openFeedback(id, {
|
|
73
|
+
onClick={() => openFeedback(id, { questionIdChild: 'optional-child-id', ...otherContext })}
|
|
73
74
|
>
|
|
74
75
|
Report Error
|
|
75
76
|
</button>
|
|
@@ -78,8 +79,8 @@ const QuestionItem = ({ id, content }) => {
|
|
|
78
79
|
};
|
|
79
80
|
```
|
|
80
81
|
|
|
81
|
-
### 3. Standalone Component
|
|
82
|
-
If you
|
|
82
|
+
### 3. Standalone Component
|
|
83
|
+
If you need a single widget instance and manage state manually (legacy mode):
|
|
83
84
|
|
|
84
85
|
```tsx
|
|
85
86
|
import { FeedbackWidget } from 'hocmai-feedback-widget';
|
|
@@ -89,6 +90,8 @@ import { FeedbackWidget } from 'hocmai-feedback-widget';
|
|
|
89
90
|
isOpen={isOpen}
|
|
90
91
|
onClose={() => setIsOpen(false)}
|
|
91
92
|
onSubmit={handleSubmit}
|
|
93
|
+
isEnableCaptureFull={true}
|
|
94
|
+
isEnableCaptureElement={true}
|
|
92
95
|
/>
|
|
93
96
|
```
|
|
94
97
|
|
|
@@ -101,34 +104,41 @@ import { FeedbackWidget } from 'hocmai-feedback-widget';
|
|
|
101
104
|
| `themeColor` | `string` | No | Primary color for buttons/highlights. Default: `#3b82f6`. |
|
|
102
105
|
| `children` | `ReactNode` | Yes | Your application content. |
|
|
103
106
|
|
|
104
|
-
###
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
console.log('Feedback submitted:', data);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<FeedbackProvider onSubmit={handleSubmit}>
|
|
125
|
-
<YourAppContent />
|
|
126
|
-
</FeedbackProvider>
|
|
127
|
-
);
|
|
107
|
+
### FeedbackData Interface
|
|
108
|
+
```ts
|
|
109
|
+
interface FeedbackData {
|
|
110
|
+
idQuestion: string | number;
|
|
111
|
+
idChildQuestion?: string | number;
|
|
112
|
+
errorDescription: string;
|
|
113
|
+
errorType: string;
|
|
114
|
+
listImage: string[]; // Array of image URLs
|
|
115
|
+
deviceInfo: {
|
|
116
|
+
device: string;
|
|
117
|
+
os: string;
|
|
118
|
+
browser: string;
|
|
119
|
+
screen: string;
|
|
120
|
+
userAgent: string;
|
|
121
|
+
};
|
|
122
|
+
contextData?: any;
|
|
128
123
|
}
|
|
129
124
|
```
|
|
130
125
|
|
|
131
|
-
|
|
126
|
+
### useFeedback Hook
|
|
127
|
+
Returns an object with:
|
|
128
|
+
- `openFeedback(questionId: string | number, contextData?: any)`: Opens the form. `contextData` can include `questionIdChild` which will pre-fill the child question ID field.
|
|
129
|
+
- `closeFeedback()`: Closes the form.
|
|
132
130
|
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
### FeedbackWidget Props
|
|
132
|
+
| Prop | Type | Default | Description |
|
|
133
|
+
|------|------|---------|-------------|
|
|
134
|
+
| `questionId` | `string \| number` | Required | Main ID of the item being reported. |
|
|
135
|
+
| `onSubmit` | `function` | Required | Async callback receiving `FeedbackData`. |
|
|
136
|
+
| `contextData` | `object` | - | Additional data passed to `FeedbackData`. |
|
|
137
|
+
| `themeColor` | `string` | `#3b82f6` | Theme color. |
|
|
138
|
+
| `isOpen` | `boolean` | - | Control visibility manually. |
|
|
139
|
+
| `onClose` | `function` | - | Callback when closed. |
|
|
140
|
+
| `isEnableCaptureFull` | `boolean` | `true` | Enable full screen capture button. |
|
|
141
|
+
| `isEnableCaptureElement` | `boolean` | `true` | Enable crop/element capture button. |
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
MIT
|
|
@@ -11,7 +11,6 @@ export interface FeedbackData {
|
|
|
11
11
|
}
|
|
12
12
|
export interface FeedbackProps {
|
|
13
13
|
questionId: string | number;
|
|
14
|
-
questionIdChild?: string | number;
|
|
15
14
|
contextData?: Record<string, any>;
|
|
16
15
|
onSubmit: (data: FeedbackData) => Promise<void>;
|
|
17
16
|
themeColor?: string;
|
|
@@ -19,6 +18,8 @@ export interface FeedbackProps {
|
|
|
19
18
|
isOpen?: boolean;
|
|
20
19
|
onOpen?: () => void;
|
|
21
20
|
onClose?: () => void;
|
|
21
|
+
isEnableCaptureFull?: boolean;
|
|
22
|
+
isEnableCaptureElement?: boolean;
|
|
22
23
|
}
|
|
23
24
|
declare const FeedbackWidget: React.FC<FeedbackProps>;
|
|
24
25
|
export default FeedbackWidget;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React, ReactNode } from 'react';
|
|
2
2
|
import { FeedbackData } from '../components/FeedbackWidget';
|
|
3
3
|
interface FeedbackContextType {
|
|
4
|
-
openFeedback: (questionId: string | number,
|
|
4
|
+
openFeedback: (questionId: string | number, contextData?: any) => void;
|
|
5
5
|
closeFeedback: () => void;
|
|
6
6
|
isOpen: boolean;
|
|
7
7
|
activeQuestionId: string | number | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { default as FeedbackWidget } from './components/FeedbackWidget';
|
|
2
2
|
export type { FeedbackData, FeedbackProps } from './components/FeedbackWidget';
|
|
3
3
|
export { FeedbackProvider, useFeedback } from './context/FeedbackContext';
|
|
4
|
+
export { captureScreenshot } from './utils/screenshot';
|
|
5
|
+
export type { Rect, CaptureProgress } from './utils/screenshot/types';
|