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

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.
@@ -1,7 +1,4 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { F as FeedbackListItem } from '../routeMatcher-CmCMn_gT.cjs';
3
- export { p as pathMatchesAllowlist } from '../routeMatcher-CmCMn_gT.cjs';
4
- import 'payload';
1
+ import React from 'react';
5
2
 
6
3
  type CapturePolicy = 'current-tab-first' | 'strict-current-tab' | 'any-surface';
7
4
  type SubmitPayload = {
@@ -35,12 +32,6 @@ type DeleteResult = {
35
32
  success: false;
36
33
  error: string;
37
34
  };
38
- type DeleteFeedbackResult = {
39
- success: true;
40
- } | {
41
- success: false;
42
- error: string;
43
- };
44
35
  type FeedbackWidgetProps = {
45
36
  title?: string;
46
37
  submitLabel?: string;
@@ -52,89 +43,48 @@ type FeedbackWidgetProps = {
52
43
  onSubmit: (payload: SubmitPayload) => Promise<SubmitResult>;
53
44
  onUpload?: (formData: FormData) => Promise<UploadResult>;
54
45
  onDeleteScreenshot?: (mediaId: number) => Promise<DeleteResult>;
55
- onDeleteFeedback?: (id: number) => Promise<DeleteFeedbackResult>;
56
- showHistory?: boolean;
57
- currentUserId?: number | null;
58
- onUpdateFeedback?: (id: number, data: {
59
- message?: string;
60
- screenshotId?: number | null;
61
- }) => Promise<boolean>;
62
- history?: {
63
- feedbacks: FeedbackListItem[];
64
- totalPages: number;
65
- currentPage: number;
66
- loading: boolean;
67
- error: string | null;
68
- refetch: () => void;
69
- onPageChange: (page: number) => void;
70
- };
71
46
  };
72
- declare function FeedbackWidget({ title, submitLabel, uploadLabel, allowScreenshotUpload, screenshotMaxFileSizeBytes, screenshotAllowedMimeTypes, capturePolicy, onSubmit, onUpload, onDeleteScreenshot, onDeleteFeedback, showHistory, currentUserId, onUpdateFeedback, history, }: FeedbackWidgetProps): react_jsx_runtime.JSX.Element;
73
-
74
- declare function AdminFeedbackWidget(): react_jsx_runtime.JSX.Element;
47
+ declare function FeedbackWidget({ title, submitLabel, uploadLabel, allowScreenshotUpload, screenshotMaxFileSizeBytes, screenshotAllowedMimeTypes, capturePolicy, onSubmit, onUpload, onDeleteScreenshot, }: FeedbackWidgetProps): React.JSX.Element;
75
48
 
76
- type FrontendFeedbackWidgetProps = {
77
- include: string[];
78
- locales?: string[];
49
+ type AdminFeedbackWidgetProps = {
79
50
  title?: string;
80
51
  submitLabel?: string;
81
52
  uploadLabel?: string;
82
- showIndicators?: boolean;
83
- showHistory?: boolean;
84
- };
85
- declare function FrontendFeedbackWidget({ include, locales, title, submitLabel, uploadLabel, showIndicators, showHistory, }: FrontendFeedbackWidgetProps): react_jsx_runtime.JSX.Element | null;
86
-
87
- type FeedbackDetailProps = {
88
- feedback: FeedbackListItem;
89
- currentUserId: number | null;
90
- capturePolicy: CapturePolicy;
91
- onBack: () => void;
92
- onUpdate: (id: number, data: {
93
- message?: string;
94
- screenshotId?: number | null;
95
- }) => Promise<boolean>;
96
- onDelete: (id: number) => Promise<boolean>;
97
- onUpload: (formData: FormData) => Promise<UploadResult>;
98
- onDeleteScreenshot: (mediaId: number) => Promise<DeleteResult>;
99
- };
100
- declare function FeedbackDetail({ feedback, currentUserId, capturePolicy: _capturePolicy, onBack, onUpdate, onDelete, onUpload, onDeleteScreenshot, }: FeedbackDetailProps): react_jsx_runtime.JSX.Element;
101
-
102
- type FeedbackHistoryProps = {
103
- feedbacks: FeedbackListItem[];
104
- totalPages: number;
105
- currentPage: number;
106
- loading: boolean;
107
- error: string | null;
108
- currentUserId: number | null;
109
- onSelectFeedback: (id: number) => void;
110
- onPageChange: (page: number) => void;
111
- onRefetch: () => void;
53
+ allowScreenshotUpload?: boolean;
54
+ screenshotMaxFileSizeBytes?: number;
55
+ screenshotAllowedMimeTypes?: string[];
56
+ capturePolicy?: 'current-tab-first' | 'strict-current-tab' | 'any-surface';
57
+ /** Payload REST base path (`config.routes.api`), default `/api`. */
58
+ apiRoute?: string;
112
59
  };
113
- declare function FeedbackHistory({ feedbacks, totalPages, currentPage, loading, error, currentUserId, onSelectFeedback, onPageChange, onRefetch, }: FeedbackHistoryProps): react_jsx_runtime.JSX.Element;
60
+ declare function AdminFeedbackWidget({ title, submitLabel, uploadLabel, allowScreenshotUpload, screenshotMaxFileSizeBytes, screenshotAllowedMimeTypes, capturePolicy, apiRoute, }: AdminFeedbackWidgetProps): React.JSX.Element;
114
61
 
115
- type FeedbackIndicatorsProps = {
116
- pagePath?: string;
62
+ type AdminFeedbackProviderProps = Omit<AdminFeedbackWidgetProps, 'apiRoute'> & {
63
+ children?: React.ReactNode;
64
+ /** Collection slug whose `create` permission decides whether the widget shows. */
65
+ collectionSlug?: string;
117
66
  };
118
- declare function FeedbackIndicators({ pagePath }: FeedbackIndicatorsProps): null;
67
+ /**
68
+ * Admin provider the plugin registers in `admin.components.providers` when
69
+ * `adminWidget.enabled` is set. It renders the widget only for a signed-in user
70
+ * whose permissions allow creating feedback, so the login screen and accounts
71
+ * without access never see a button that would fail.
72
+ */
73
+ declare function AdminFeedbackProvider({ children, collectionSlug, ...widgetProps }: AdminFeedbackProviderProps): React.JSX.Element;
119
74
 
120
- type UseFeedbackQueryParams = {
121
- pagePath?: string;
122
- page?: number;
123
- limit?: number;
124
- };
125
- type UseFeedbackQueryResult = {
126
- feedbacks: FeedbackListItem[];
127
- totalPages: number;
128
- currentPage: number;
129
- loading: boolean;
130
- error: string | null;
131
- refetch: () => void;
132
- };
133
- declare function useFeedbackQuery(params: UseFeedbackQueryParams): UseFeedbackQueryResult;
134
- type UseCurrentUserResult = {
135
- userId: number | null;
136
- loading: boolean;
75
+ type FrontendFeedbackWidgetProps = {
76
+ include: string[];
77
+ locales?: string[];
78
+ title?: string;
79
+ submitLabel?: string;
80
+ uploadLabel?: string;
81
+ /** URL markers (`pisarna`, `narocilnica`, …) — tenant slug is the segment before the marker. */
82
+ tenantPathMarkers?: string[];
83
+ /** FormData key for tenant slug on upload (default `tenant`). */
84
+ tenantFormDataKey?: string;
85
+ /** Payload REST base path (`config.routes.api`), default `/api`. */
86
+ apiRoute?: string;
137
87
  };
138
- declare function useCurrentUser(): UseCurrentUserResult;
88
+ declare function FrontendFeedbackWidget({ include, locales, title, submitLabel, uploadLabel, tenantPathMarkers, tenantFormDataKey, apiRoute, }: FrontendFeedbackWidgetProps): React.JSX.Element | null;
139
89
 
140
- export { AdminFeedbackWidget, type CapturePolicy, type DeleteResult, FeedbackDetail, FeedbackHistory, FeedbackIndicators, FeedbackWidget, FrontendFeedbackWidget, type UploadResult, useCurrentUser, useFeedbackQuery };
90
+ export { AdminFeedbackProvider, AdminFeedbackWidget, type AdminFeedbackWidgetProps, FeedbackWidget, FrontendFeedbackWidget };
@@ -1,7 +1,4 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { F as FeedbackListItem } from '../routeMatcher-CmCMn_gT.js';
3
- export { p as pathMatchesAllowlist } from '../routeMatcher-CmCMn_gT.js';
4
- import 'payload';
1
+ import React from 'react';
5
2
 
6
3
  type CapturePolicy = 'current-tab-first' | 'strict-current-tab' | 'any-surface';
7
4
  type SubmitPayload = {
@@ -35,12 +32,6 @@ type DeleteResult = {
35
32
  success: false;
36
33
  error: string;
37
34
  };
38
- type DeleteFeedbackResult = {
39
- success: true;
40
- } | {
41
- success: false;
42
- error: string;
43
- };
44
35
  type FeedbackWidgetProps = {
45
36
  title?: string;
46
37
  submitLabel?: string;
@@ -52,89 +43,48 @@ type FeedbackWidgetProps = {
52
43
  onSubmit: (payload: SubmitPayload) => Promise<SubmitResult>;
53
44
  onUpload?: (formData: FormData) => Promise<UploadResult>;
54
45
  onDeleteScreenshot?: (mediaId: number) => Promise<DeleteResult>;
55
- onDeleteFeedback?: (id: number) => Promise<DeleteFeedbackResult>;
56
- showHistory?: boolean;
57
- currentUserId?: number | null;
58
- onUpdateFeedback?: (id: number, data: {
59
- message?: string;
60
- screenshotId?: number | null;
61
- }) => Promise<boolean>;
62
- history?: {
63
- feedbacks: FeedbackListItem[];
64
- totalPages: number;
65
- currentPage: number;
66
- loading: boolean;
67
- error: string | null;
68
- refetch: () => void;
69
- onPageChange: (page: number) => void;
70
- };
71
46
  };
72
- declare function FeedbackWidget({ title, submitLabel, uploadLabel, allowScreenshotUpload, screenshotMaxFileSizeBytes, screenshotAllowedMimeTypes, capturePolicy, onSubmit, onUpload, onDeleteScreenshot, onDeleteFeedback, showHistory, currentUserId, onUpdateFeedback, history, }: FeedbackWidgetProps): react_jsx_runtime.JSX.Element;
73
-
74
- declare function AdminFeedbackWidget(): react_jsx_runtime.JSX.Element;
47
+ declare function FeedbackWidget({ title, submitLabel, uploadLabel, allowScreenshotUpload, screenshotMaxFileSizeBytes, screenshotAllowedMimeTypes, capturePolicy, onSubmit, onUpload, onDeleteScreenshot, }: FeedbackWidgetProps): React.JSX.Element;
75
48
 
76
- type FrontendFeedbackWidgetProps = {
77
- include: string[];
78
- locales?: string[];
49
+ type AdminFeedbackWidgetProps = {
79
50
  title?: string;
80
51
  submitLabel?: string;
81
52
  uploadLabel?: string;
82
- showIndicators?: boolean;
83
- showHistory?: boolean;
84
- };
85
- declare function FrontendFeedbackWidget({ include, locales, title, submitLabel, uploadLabel, showIndicators, showHistory, }: FrontendFeedbackWidgetProps): react_jsx_runtime.JSX.Element | null;
86
-
87
- type FeedbackDetailProps = {
88
- feedback: FeedbackListItem;
89
- currentUserId: number | null;
90
- capturePolicy: CapturePolicy;
91
- onBack: () => void;
92
- onUpdate: (id: number, data: {
93
- message?: string;
94
- screenshotId?: number | null;
95
- }) => Promise<boolean>;
96
- onDelete: (id: number) => Promise<boolean>;
97
- onUpload: (formData: FormData) => Promise<UploadResult>;
98
- onDeleteScreenshot: (mediaId: number) => Promise<DeleteResult>;
99
- };
100
- declare function FeedbackDetail({ feedback, currentUserId, capturePolicy: _capturePolicy, onBack, onUpdate, onDelete, onUpload, onDeleteScreenshot, }: FeedbackDetailProps): react_jsx_runtime.JSX.Element;
101
-
102
- type FeedbackHistoryProps = {
103
- feedbacks: FeedbackListItem[];
104
- totalPages: number;
105
- currentPage: number;
106
- loading: boolean;
107
- error: string | null;
108
- currentUserId: number | null;
109
- onSelectFeedback: (id: number) => void;
110
- onPageChange: (page: number) => void;
111
- onRefetch: () => void;
53
+ allowScreenshotUpload?: boolean;
54
+ screenshotMaxFileSizeBytes?: number;
55
+ screenshotAllowedMimeTypes?: string[];
56
+ capturePolicy?: 'current-tab-first' | 'strict-current-tab' | 'any-surface';
57
+ /** Payload REST base path (`config.routes.api`), default `/api`. */
58
+ apiRoute?: string;
112
59
  };
113
- declare function FeedbackHistory({ feedbacks, totalPages, currentPage, loading, error, currentUserId, onSelectFeedback, onPageChange, onRefetch, }: FeedbackHistoryProps): react_jsx_runtime.JSX.Element;
60
+ declare function AdminFeedbackWidget({ title, submitLabel, uploadLabel, allowScreenshotUpload, screenshotMaxFileSizeBytes, screenshotAllowedMimeTypes, capturePolicy, apiRoute, }: AdminFeedbackWidgetProps): React.JSX.Element;
114
61
 
115
- type FeedbackIndicatorsProps = {
116
- pagePath?: string;
62
+ type AdminFeedbackProviderProps = Omit<AdminFeedbackWidgetProps, 'apiRoute'> & {
63
+ children?: React.ReactNode;
64
+ /** Collection slug whose `create` permission decides whether the widget shows. */
65
+ collectionSlug?: string;
117
66
  };
118
- declare function FeedbackIndicators({ pagePath }: FeedbackIndicatorsProps): null;
67
+ /**
68
+ * Admin provider the plugin registers in `admin.components.providers` when
69
+ * `adminWidget.enabled` is set. It renders the widget only for a signed-in user
70
+ * whose permissions allow creating feedback, so the login screen and accounts
71
+ * without access never see a button that would fail.
72
+ */
73
+ declare function AdminFeedbackProvider({ children, collectionSlug, ...widgetProps }: AdminFeedbackProviderProps): React.JSX.Element;
119
74
 
120
- type UseFeedbackQueryParams = {
121
- pagePath?: string;
122
- page?: number;
123
- limit?: number;
124
- };
125
- type UseFeedbackQueryResult = {
126
- feedbacks: FeedbackListItem[];
127
- totalPages: number;
128
- currentPage: number;
129
- loading: boolean;
130
- error: string | null;
131
- refetch: () => void;
132
- };
133
- declare function useFeedbackQuery(params: UseFeedbackQueryParams): UseFeedbackQueryResult;
134
- type UseCurrentUserResult = {
135
- userId: number | null;
136
- loading: boolean;
75
+ type FrontendFeedbackWidgetProps = {
76
+ include: string[];
77
+ locales?: string[];
78
+ title?: string;
79
+ submitLabel?: string;
80
+ uploadLabel?: string;
81
+ /** URL markers (`pisarna`, `narocilnica`, …) — tenant slug is the segment before the marker. */
82
+ tenantPathMarkers?: string[];
83
+ /** FormData key for tenant slug on upload (default `tenant`). */
84
+ tenantFormDataKey?: string;
85
+ /** Payload REST base path (`config.routes.api`), default `/api`. */
86
+ apiRoute?: string;
137
87
  };
138
- declare function useCurrentUser(): UseCurrentUserResult;
88
+ declare function FrontendFeedbackWidget({ include, locales, title, submitLabel, uploadLabel, tenantPathMarkers, tenantFormDataKey, apiRoute, }: FrontendFeedbackWidgetProps): React.JSX.Element | null;
139
89
 
140
- export { AdminFeedbackWidget, type CapturePolicy, type DeleteResult, FeedbackDetail, FeedbackHistory, FeedbackIndicators, FeedbackWidget, FrontendFeedbackWidget, type UploadResult, useCurrentUser, useFeedbackQuery };
90
+ export { AdminFeedbackProvider, AdminFeedbackWidget, type AdminFeedbackWidgetProps, FeedbackWidget, FrontendFeedbackWidget };