@matija2209/payload-plugin-admin-feedback 1.0.0 → 1.0.3

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.
@@ -0,0 +1,54 @@
1
+ import { Config } from 'payload';
2
+
3
+ type FrontendDisplayConfig = {
4
+ enabled?: boolean;
5
+ include?: string[];
6
+ };
7
+ type ScreenshotConfig = {
8
+ enabled?: boolean;
9
+ maxFileSizeBytes?: number;
10
+ allowedMimeTypes?: string[];
11
+ capturePolicy?: 'current-tab-first' | 'strict-current-tab' | 'any-surface';
12
+ };
13
+ type AdminFeedbackPluginOptions = {
14
+ enabled?: boolean;
15
+ emailTo: string | string[];
16
+ fromLabel?: string;
17
+ fromName?: string;
18
+ fromAddress?: string;
19
+ email?: Config['email'];
20
+ allowScreenshotUpload?: boolean;
21
+ maxMessageLength?: number;
22
+ mediaCollectionSlug?: string;
23
+ strictMediaCollection?: boolean;
24
+ screenshot?: ScreenshotConfig;
25
+ frontend?: FrontendDisplayConfig;
26
+ frontendRouteMatcher?: (pathname: string) => boolean;
27
+ };
28
+ type FeedbackStatus = 'new' | 'triaged' | 'resolved';
29
+ type FeedbackScreenshotInfo = {
30
+ id: number;
31
+ url?: string;
32
+ filename?: string;
33
+ alt?: string;
34
+ };
35
+ type FeedbackCreatedByInfo = {
36
+ id: number;
37
+ email?: string;
38
+ };
39
+ type FeedbackListItem = {
40
+ id: number;
41
+ message: string;
42
+ pagePath: string;
43
+ selector?: string | null;
44
+ selectedText?: string | null;
45
+ status: FeedbackStatus;
46
+ createdAt: string;
47
+ updatedAt: string;
48
+ createdBy?: FeedbackCreatedByInfo | number | null;
49
+ screenshot?: FeedbackScreenshotInfo | number | null;
50
+ };
51
+
52
+ declare const pathMatchesAllowlist: (pathname: string, patterns: string[]) => boolean;
53
+
54
+ export { type AdminFeedbackPluginOptions as A, type FeedbackListItem as F, pathMatchesAllowlist as p };
package/package.json CHANGED
@@ -1,7 +1,20 @@
1
1
  {
2
2
  "name": "@matija2209/payload-plugin-admin-feedback",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "Floating admin feedback widget plugin for Payload CMS.",
5
+ "files": [
6
+ "dist",
7
+ "README.md",
8
+ "public"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/matija2209/payload-plugin-admin-feedback.git"
13
+ },
14
+ "homepage": "https://github.com/matija2209/payload-plugin-admin-feedback#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/matija2209/payload-plugin-admin-feedback/issues"
17
+ },
5
18
  "license": "MIT",
6
19
  "type": "module",
7
20
  "main": "./dist/index.js",
@@ -18,12 +31,19 @@
18
31
  "require": "./dist/client/index.cjs"
19
32
  }
20
33
  },
21
- "scripts": {
22
- "build": "tsup src/index.ts src/client/index.ts --format cjs,esm --dts --clean --minify",
23
- "dev": "tsup src/index.ts src/client/index.ts --format cjs,esm --dts --watch"
34
+ "devDependencies": {
35
+ "tsup": "^8.5.0",
36
+ "typescript": "^5.9.3"
24
37
  },
25
38
  "peerDependencies": {
26
39
  "payload": "^3.84.1",
27
40
  "react": "^19.0.0"
41
+ },
42
+ "dependencies": {
43
+ "lucide-react": "^0.511.0"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup",
47
+ "dev": "tsup --watch"
28
48
  }
29
- }
49
+ }
@@ -1,63 +0,0 @@
1
- 'use client';
2
-
3
- import React from 'react';
4
-
5
- import { FeedbackWidget } from './FeedbackWidget';
6
-
7
- export function AdminFeedbackWidget() {
8
- return (
9
- <FeedbackWidget
10
- title="Admin feedback"
11
- submitLabel="Send"
12
- uploadLabel="Upload image"
13
- allowScreenshotUpload
14
- onSubmit={async (payload) => {
15
- const response = await fetch('/api/admin-feedback/submit', {
16
- method: 'POST',
17
- credentials: 'include',
18
- headers: { 'content-type': 'application/json' },
19
- body: JSON.stringify(payload),
20
- });
21
-
22
- const result = (await response.json()) as { success: boolean; error?: string };
23
- if (!result.success) {
24
- return { success: false as const, error: result.error || 'Submit failed.' };
25
- }
26
-
27
- return { success: true as const };
28
- }}
29
- onUpload={async (formData) => {
30
- const response = await fetch('/api/admin-feedback/upload', {
31
- method: 'POST',
32
- credentials: 'include',
33
- body: formData,
34
- });
35
-
36
- const result = (await response.json()) as {
37
- success: boolean;
38
- error?: string;
39
- mediaId?: number;
40
- };
41
-
42
- if (!result.success || typeof result.mediaId !== 'number') {
43
- return { success: false as const, error: result.error || 'Upload failed.' };
44
- }
45
-
46
- return { success: true as const, mediaId: result.mediaId };
47
- }}
48
- onDeleteScreenshot={async (mediaId) => {
49
- const response = await fetch(`/api/admin-feedback/upload/${mediaId}`, {
50
- method: 'DELETE',
51
- credentials: 'include',
52
- });
53
-
54
- const result = (await response.json()) as { success: boolean; error?: string };
55
- if (!result.success) {
56
- return { success: false as const, error: result.error || 'Delete failed.' };
57
- }
58
-
59
- return { success: true as const };
60
- }}
61
- />
62
- );
63
- }