spaps-issue-reporting-react 0.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.
- package/CHANGELOG.md +7 -0
- package/README.md +69 -0
- package/dist/index.d.mts +343 -0
- package/dist/index.d.ts +343 -0
- package/dist/index.js +933 -0
- package/dist/index.mjs +894 -0
- package/package.json +75 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default, { ReactNode } from 'react';
|
|
4
|
+
import * as spaps_types from 'spaps-types';
|
|
5
|
+
import { IssueReportStatusResult, IssueReportStatus, IssueReportListResult, IssueReport, CreateIssueReportRequest, UpdateIssueReportRequest, ReplyIssueReportRequest } from 'spaps-types';
|
|
6
|
+
export { CreateIssueReportRequest, IssueReport, IssueReportListResult, IssueReportStatus, IssueReportStatusResult, ReplyIssueReportRequest, UpdateIssueReportRequest } from 'spaps-types';
|
|
7
|
+
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
8
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
9
|
+
|
|
10
|
+
interface IssueReportingClient {
|
|
11
|
+
issueReporting: {
|
|
12
|
+
getStatus: () => Promise<IssueReportStatusResult>;
|
|
13
|
+
list: (params?: {
|
|
14
|
+
status?: IssueReportStatus;
|
|
15
|
+
limit?: number;
|
|
16
|
+
offset?: number;
|
|
17
|
+
}) => Promise<IssueReportListResult>;
|
|
18
|
+
get: (issueReportId: string) => Promise<IssueReport>;
|
|
19
|
+
create: (payload: CreateIssueReportRequest) => Promise<IssueReport>;
|
|
20
|
+
update: (issueReportId: string, payload: UpdateIssueReportRequest) => Promise<IssueReport>;
|
|
21
|
+
reply: (issueReportId: string, payload: ReplyIssueReportRequest) => Promise<IssueReport>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
interface ReportableTargetDescriptor {
|
|
25
|
+
componentKey: string;
|
|
26
|
+
componentLabel?: string;
|
|
27
|
+
surfaceRef?: string | null;
|
|
28
|
+
metadata?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
type ReportableInput = string | ReportableTargetDescriptor;
|
|
31
|
+
type IssueHistoryFilter = "all" | "open" | "closed";
|
|
32
|
+
interface IssueReportingCopy {
|
|
33
|
+
entryAriaLabel: string;
|
|
34
|
+
popoverTitle: string;
|
|
35
|
+
reportNewAction: string;
|
|
36
|
+
filtersAll: string;
|
|
37
|
+
filtersOpen: string;
|
|
38
|
+
filtersClosed: string;
|
|
39
|
+
historyHelpText: string;
|
|
40
|
+
historyLoading: string;
|
|
41
|
+
historyLoadFailed: string;
|
|
42
|
+
emptyAll: string;
|
|
43
|
+
emptyOpen: string;
|
|
44
|
+
emptyClosed: string;
|
|
45
|
+
reportModeTitle: string;
|
|
46
|
+
reportModeDescription: string;
|
|
47
|
+
reportModeCancelAction: string;
|
|
48
|
+
createTitlePrefix: string;
|
|
49
|
+
editTitlePrefix: string;
|
|
50
|
+
replyTitlePrefix: string;
|
|
51
|
+
createDescriptionPrefix: string;
|
|
52
|
+
editDescription: string;
|
|
53
|
+
replyDescription: string;
|
|
54
|
+
notePlaceholder: string;
|
|
55
|
+
noteMinimumSuffix: string;
|
|
56
|
+
keyboardShortcutHint: string;
|
|
57
|
+
originalIssueLabel: string;
|
|
58
|
+
cancelAction: string;
|
|
59
|
+
submitAction: string;
|
|
60
|
+
submittingAction: string;
|
|
61
|
+
editAction: string;
|
|
62
|
+
replyAction: string;
|
|
63
|
+
hydrateLoading: string;
|
|
64
|
+
hydrateFailed: string;
|
|
65
|
+
retryAction: string;
|
|
66
|
+
}
|
|
67
|
+
interface IssueReportingProviderProps {
|
|
68
|
+
client: IssueReportingClient;
|
|
69
|
+
isEligible: boolean;
|
|
70
|
+
reporterRoleHint?: string;
|
|
71
|
+
getPageUrl?: () => string;
|
|
72
|
+
copy?: Partial<IssueReportingCopy>;
|
|
73
|
+
children: ReactNode;
|
|
74
|
+
}
|
|
75
|
+
interface FloatingIssueReportButtonProps {
|
|
76
|
+
className?: string;
|
|
77
|
+
positionClassName?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare function FloatingIssueReportButton({ className, positionClassName, }: FloatingIssueReportButtonProps): react_jsx_runtime.JSX.Element | null;
|
|
81
|
+
declare function ReportableSection({ reportableName, children, className, as: Component, }: {
|
|
82
|
+
reportableName: ReportableInput;
|
|
83
|
+
children: React__default.ReactNode;
|
|
84
|
+
className?: string;
|
|
85
|
+
as?: keyof JSX.IntrinsicElements;
|
|
86
|
+
}): react_jsx_runtime.JSX.Element;
|
|
87
|
+
|
|
88
|
+
type ModalMode = "create" | "edit" | "reply";
|
|
89
|
+
type ResolvedTarget = {
|
|
90
|
+
component_key: string;
|
|
91
|
+
component_label: string;
|
|
92
|
+
page_url: string;
|
|
93
|
+
surface_ref: string | null;
|
|
94
|
+
metadata: Record<string, unknown>;
|
|
95
|
+
};
|
|
96
|
+
type ModalState = {
|
|
97
|
+
isOpen: boolean;
|
|
98
|
+
mode: ModalMode;
|
|
99
|
+
issueReportId: string | null;
|
|
100
|
+
issue: IssueReport | null;
|
|
101
|
+
target: ResolvedTarget | null;
|
|
102
|
+
error: string | null;
|
|
103
|
+
isHydrating: boolean;
|
|
104
|
+
};
|
|
105
|
+
type IssueReportingContextValue = {
|
|
106
|
+
client: IssueReportingProviderProps["client"];
|
|
107
|
+
isEligible: boolean;
|
|
108
|
+
reporterRoleHint?: string;
|
|
109
|
+
copy: IssueReportingCopy;
|
|
110
|
+
isReportMode: boolean;
|
|
111
|
+
enterReportMode: () => void;
|
|
112
|
+
cancelReportMode: () => void;
|
|
113
|
+
selectPanel: (target: ReportableInput) => void;
|
|
114
|
+
isPopoverOpen: boolean;
|
|
115
|
+
openPopover: () => void;
|
|
116
|
+
closePopover: () => void;
|
|
117
|
+
modalState: ModalState;
|
|
118
|
+
closeModal: () => void;
|
|
119
|
+
openExistingIssueModal: (issueReportId: string, mode: Exclude<ModalMode, "create">) => Promise<void>;
|
|
120
|
+
retryModalHydration: () => Promise<void>;
|
|
121
|
+
};
|
|
122
|
+
declare const defaultIssueReportingCopy: IssueReportingCopy;
|
|
123
|
+
declare const issueReportingKeys: {
|
|
124
|
+
all: readonly ["spaps-issue-reporting"];
|
|
125
|
+
status: () => readonly ["spaps-issue-reporting", "status"];
|
|
126
|
+
history: () => readonly ["spaps-issue-reporting", "history"];
|
|
127
|
+
detail: (issueReportId: string) => readonly ["spaps-issue-reporting", "detail", string];
|
|
128
|
+
};
|
|
129
|
+
declare function isOpenIssueStatus(status: IssueReportStatus): boolean;
|
|
130
|
+
declare function isClosedIssueStatus(status: IssueReportStatus): boolean;
|
|
131
|
+
declare function filterIssueReports(issues: IssueReport[], filter: IssueHistoryFilter): IssueReport[];
|
|
132
|
+
declare function getIssueStatusBadgeLabel(status: IssueReportStatus): string;
|
|
133
|
+
declare function getIssueStatusClassName(status: IssueReportStatus): string;
|
|
134
|
+
declare function getEntryPointState(status?: {
|
|
135
|
+
has_open: boolean;
|
|
136
|
+
has_recent_resolved: boolean;
|
|
137
|
+
} | null): "open" | "recent_resolved" | "neutral";
|
|
138
|
+
declare function getEntryPointClassName(state: "open" | "recent_resolved" | "neutral"): string;
|
|
139
|
+
declare function getIssueNoteLengthMessage(note: string, copy: IssueReportingCopy): string;
|
|
140
|
+
declare function useIssueReporting(): IssueReportingContextValue;
|
|
141
|
+
declare function useIssueReportingStatus(): _tanstack_react_query.UseQueryResult<spaps_types.IssueReportStatusResult, Error>;
|
|
142
|
+
declare function useIssueReportingHistory(filter?: IssueHistoryFilter): {
|
|
143
|
+
items: IssueReport[];
|
|
144
|
+
total: number;
|
|
145
|
+
data: spaps_types.IssueReportListResult;
|
|
146
|
+
error: Error;
|
|
147
|
+
isError: true;
|
|
148
|
+
isPending: false;
|
|
149
|
+
isLoading: false;
|
|
150
|
+
isLoadingError: false;
|
|
151
|
+
isRefetchError: true;
|
|
152
|
+
isSuccess: false;
|
|
153
|
+
isPlaceholderData: false;
|
|
154
|
+
status: "error";
|
|
155
|
+
dataUpdatedAt: number;
|
|
156
|
+
errorUpdatedAt: number;
|
|
157
|
+
failureCount: number;
|
|
158
|
+
failureReason: Error | null;
|
|
159
|
+
errorUpdateCount: number;
|
|
160
|
+
isFetched: boolean;
|
|
161
|
+
isFetchedAfterMount: boolean;
|
|
162
|
+
isFetching: boolean;
|
|
163
|
+
isInitialLoading: boolean;
|
|
164
|
+
isPaused: boolean;
|
|
165
|
+
isRefetching: boolean;
|
|
166
|
+
isStale: boolean;
|
|
167
|
+
isEnabled: boolean;
|
|
168
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<spaps_types.IssueReportListResult, Error>>;
|
|
169
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
170
|
+
promise: Promise<spaps_types.IssueReportListResult>;
|
|
171
|
+
} | {
|
|
172
|
+
items: IssueReport[];
|
|
173
|
+
total: number;
|
|
174
|
+
data: spaps_types.IssueReportListResult;
|
|
175
|
+
error: null;
|
|
176
|
+
isError: false;
|
|
177
|
+
isPending: false;
|
|
178
|
+
isLoading: false;
|
|
179
|
+
isLoadingError: false;
|
|
180
|
+
isRefetchError: false;
|
|
181
|
+
isSuccess: true;
|
|
182
|
+
isPlaceholderData: false;
|
|
183
|
+
status: "success";
|
|
184
|
+
dataUpdatedAt: number;
|
|
185
|
+
errorUpdatedAt: number;
|
|
186
|
+
failureCount: number;
|
|
187
|
+
failureReason: Error | null;
|
|
188
|
+
errorUpdateCount: number;
|
|
189
|
+
isFetched: boolean;
|
|
190
|
+
isFetchedAfterMount: boolean;
|
|
191
|
+
isFetching: boolean;
|
|
192
|
+
isInitialLoading: boolean;
|
|
193
|
+
isPaused: boolean;
|
|
194
|
+
isRefetching: boolean;
|
|
195
|
+
isStale: boolean;
|
|
196
|
+
isEnabled: boolean;
|
|
197
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<spaps_types.IssueReportListResult, Error>>;
|
|
198
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
199
|
+
promise: Promise<spaps_types.IssueReportListResult>;
|
|
200
|
+
} | {
|
|
201
|
+
items: IssueReport[];
|
|
202
|
+
total: number;
|
|
203
|
+
data: undefined;
|
|
204
|
+
error: Error;
|
|
205
|
+
isError: true;
|
|
206
|
+
isPending: false;
|
|
207
|
+
isLoading: false;
|
|
208
|
+
isLoadingError: true;
|
|
209
|
+
isRefetchError: false;
|
|
210
|
+
isSuccess: false;
|
|
211
|
+
isPlaceholderData: false;
|
|
212
|
+
status: "error";
|
|
213
|
+
dataUpdatedAt: number;
|
|
214
|
+
errorUpdatedAt: number;
|
|
215
|
+
failureCount: number;
|
|
216
|
+
failureReason: Error | null;
|
|
217
|
+
errorUpdateCount: number;
|
|
218
|
+
isFetched: boolean;
|
|
219
|
+
isFetchedAfterMount: boolean;
|
|
220
|
+
isFetching: boolean;
|
|
221
|
+
isInitialLoading: boolean;
|
|
222
|
+
isPaused: boolean;
|
|
223
|
+
isRefetching: boolean;
|
|
224
|
+
isStale: boolean;
|
|
225
|
+
isEnabled: boolean;
|
|
226
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<spaps_types.IssueReportListResult, Error>>;
|
|
227
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
228
|
+
promise: Promise<spaps_types.IssueReportListResult>;
|
|
229
|
+
} | {
|
|
230
|
+
items: IssueReport[];
|
|
231
|
+
total: number;
|
|
232
|
+
data: undefined;
|
|
233
|
+
error: null;
|
|
234
|
+
isError: false;
|
|
235
|
+
isPending: true;
|
|
236
|
+
isLoading: true;
|
|
237
|
+
isLoadingError: false;
|
|
238
|
+
isRefetchError: false;
|
|
239
|
+
isSuccess: false;
|
|
240
|
+
isPlaceholderData: false;
|
|
241
|
+
status: "pending";
|
|
242
|
+
dataUpdatedAt: number;
|
|
243
|
+
errorUpdatedAt: number;
|
|
244
|
+
failureCount: number;
|
|
245
|
+
failureReason: Error | null;
|
|
246
|
+
errorUpdateCount: number;
|
|
247
|
+
isFetched: boolean;
|
|
248
|
+
isFetchedAfterMount: boolean;
|
|
249
|
+
isFetching: boolean;
|
|
250
|
+
isInitialLoading: boolean;
|
|
251
|
+
isPaused: boolean;
|
|
252
|
+
isRefetching: boolean;
|
|
253
|
+
isStale: boolean;
|
|
254
|
+
isEnabled: boolean;
|
|
255
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<spaps_types.IssueReportListResult, Error>>;
|
|
256
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
257
|
+
promise: Promise<spaps_types.IssueReportListResult>;
|
|
258
|
+
} | {
|
|
259
|
+
items: IssueReport[];
|
|
260
|
+
total: number;
|
|
261
|
+
data: undefined;
|
|
262
|
+
error: null;
|
|
263
|
+
isError: false;
|
|
264
|
+
isPending: true;
|
|
265
|
+
isLoadingError: false;
|
|
266
|
+
isRefetchError: false;
|
|
267
|
+
isSuccess: false;
|
|
268
|
+
isPlaceholderData: false;
|
|
269
|
+
status: "pending";
|
|
270
|
+
dataUpdatedAt: number;
|
|
271
|
+
errorUpdatedAt: number;
|
|
272
|
+
failureCount: number;
|
|
273
|
+
failureReason: Error | null;
|
|
274
|
+
errorUpdateCount: number;
|
|
275
|
+
isFetched: boolean;
|
|
276
|
+
isFetchedAfterMount: boolean;
|
|
277
|
+
isFetching: boolean;
|
|
278
|
+
isLoading: boolean;
|
|
279
|
+
isInitialLoading: boolean;
|
|
280
|
+
isPaused: boolean;
|
|
281
|
+
isRefetching: boolean;
|
|
282
|
+
isStale: boolean;
|
|
283
|
+
isEnabled: boolean;
|
|
284
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<spaps_types.IssueReportListResult, Error>>;
|
|
285
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
286
|
+
promise: Promise<spaps_types.IssueReportListResult>;
|
|
287
|
+
} | {
|
|
288
|
+
items: IssueReport[];
|
|
289
|
+
total: number;
|
|
290
|
+
data: spaps_types.IssueReportListResult;
|
|
291
|
+
isError: false;
|
|
292
|
+
error: null;
|
|
293
|
+
isPending: false;
|
|
294
|
+
isLoading: false;
|
|
295
|
+
isLoadingError: false;
|
|
296
|
+
isRefetchError: false;
|
|
297
|
+
isSuccess: true;
|
|
298
|
+
isPlaceholderData: true;
|
|
299
|
+
status: "success";
|
|
300
|
+
dataUpdatedAt: number;
|
|
301
|
+
errorUpdatedAt: number;
|
|
302
|
+
failureCount: number;
|
|
303
|
+
failureReason: Error | null;
|
|
304
|
+
errorUpdateCount: number;
|
|
305
|
+
isFetched: boolean;
|
|
306
|
+
isFetchedAfterMount: boolean;
|
|
307
|
+
isFetching: boolean;
|
|
308
|
+
isInitialLoading: boolean;
|
|
309
|
+
isPaused: boolean;
|
|
310
|
+
isRefetching: boolean;
|
|
311
|
+
isStale: boolean;
|
|
312
|
+
isEnabled: boolean;
|
|
313
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<spaps_types.IssueReportListResult, Error>>;
|
|
314
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
315
|
+
promise: Promise<spaps_types.IssueReportListResult>;
|
|
316
|
+
};
|
|
317
|
+
declare function useIssueReportingMutations(): {
|
|
318
|
+
createMutation: _tanstack_react_query.UseMutationResult<IssueReport, Error, {
|
|
319
|
+
target: ResolvedTarget;
|
|
320
|
+
note: string;
|
|
321
|
+
reporter_role_hint?: string;
|
|
322
|
+
}, unknown>;
|
|
323
|
+
updateMutation: _tanstack_react_query.UseMutationResult<IssueReport, Error, {
|
|
324
|
+
issueReportId: string;
|
|
325
|
+
note: string;
|
|
326
|
+
}, unknown>;
|
|
327
|
+
replyMutation: _tanstack_react_query.UseMutationResult<IssueReport, Error, {
|
|
328
|
+
issueReportId: string;
|
|
329
|
+
note: string;
|
|
330
|
+
reporterRoleHint?: string;
|
|
331
|
+
}, unknown>;
|
|
332
|
+
};
|
|
333
|
+
declare function IssueReportingProvider({ client, isEligible, reporterRoleHint, getPageUrl, copy, children, }: IssueReportingProviderProps): react_jsx_runtime.JSX.Element;
|
|
334
|
+
|
|
335
|
+
interface ReportModeContextValue {
|
|
336
|
+
isReportMode: boolean;
|
|
337
|
+
selectPanel: (target: ReportableInput) => void;
|
|
338
|
+
cancelReportMode: () => void;
|
|
339
|
+
}
|
|
340
|
+
declare const ReportModeContext: React.Context<ReportModeContextValue | null>;
|
|
341
|
+
declare function useReportMode(): ReportModeContextValue | null;
|
|
342
|
+
|
|
343
|
+
export { FloatingIssueReportButton, type FloatingIssueReportButtonProps, type IssueHistoryFilter, type IssueReportingClient, type IssueReportingCopy, IssueReportingProvider, type IssueReportingProviderProps, ReportModeContext, type ReportModeContextValue, type ReportableInput, ReportableSection, type ReportableTargetDescriptor, defaultIssueReportingCopy, filterIssueReports, getEntryPointClassName, getEntryPointState, getIssueNoteLengthMessage, getIssueStatusBadgeLabel, getIssueStatusClassName, isClosedIssueStatus, isOpenIssueStatus, issueReportingKeys, useIssueReporting, useIssueReportingHistory, useIssueReportingMutations, useIssueReportingStatus, useReportMode };
|