@kendew-agency/react-feedback-layer 0.4.0-rc.0 → 0.4.0-rc.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 +123 -47
- package/dist/index.cjs +170 -127
- package/dist/index.d.cts +12 -13
- package/dist/index.d.ts +12 -13
- package/dist/index.js +179 -135
- package/dist/types.d.cts +477 -4
- package/dist/types.d.ts +477 -4
- package/package.json +2 -1
- package/dist/use-session-events-DFksOgVA.d.cts +0 -464
- package/dist/use-session-events-DFksOgVA.d.ts +0 -464
package/dist/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
|
|
7
7
|
// src/contexts/comment-context.tsx
|
|
8
8
|
import {
|
|
9
|
-
createContext as
|
|
10
|
-
useContext as
|
|
9
|
+
createContext as createContext2,
|
|
10
|
+
useContext as useContext2,
|
|
11
11
|
useEffect as useEffect2,
|
|
12
12
|
useId,
|
|
13
13
|
useReducer as useReducer2,
|
|
@@ -145,37 +145,89 @@ var useCommentEvents = () => {
|
|
|
145
145
|
|
|
146
146
|
// src/utils/select-visible-comments.ts
|
|
147
147
|
var normalizeDraftVisibility = (value) => value === "hidden" ? "hidden" : "visible";
|
|
148
|
+
var isLocated = (comment) => typeof comment.locationId === "string" && comment.locationId.length > 0;
|
|
149
|
+
var normalizeLocationId = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
150
|
+
var applyDraftFilter = (comments, session, draftVisibility, currentUserId) => {
|
|
151
|
+
if (session.status !== "draft" || normalizeDraftVisibility(draftVisibility) !== "hidden") {
|
|
152
|
+
return comments;
|
|
153
|
+
}
|
|
154
|
+
return comments.filter((comment) => {
|
|
155
|
+
if (comment.status === "draft") {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
const authorId = comment.user?.id;
|
|
159
|
+
return authorId === void 0 || authorId === currentUserId;
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
var selectCommentsByLocation = ({
|
|
163
|
+
comments,
|
|
164
|
+
locationId
|
|
165
|
+
}) => {
|
|
166
|
+
const location = normalizeLocationId(locationId);
|
|
167
|
+
if (location === void 0) {
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
return comments.filter(
|
|
171
|
+
(comment) => isLocated(comment) && comment.locationId === location
|
|
172
|
+
);
|
|
173
|
+
};
|
|
148
174
|
var selectVisibleComments = ({
|
|
149
175
|
comments,
|
|
150
176
|
session,
|
|
177
|
+
locationId,
|
|
151
178
|
draftVisibility = "visible",
|
|
152
179
|
currentUserId
|
|
153
180
|
}) => {
|
|
154
181
|
if (session === null) {
|
|
155
182
|
return [];
|
|
156
183
|
}
|
|
157
|
-
const inSession = comments.filter(
|
|
184
|
+
const inSession = selectCommentsByLocation({ comments, locationId }).filter(
|
|
158
185
|
(comment) => comment.sessionId === session.id
|
|
159
186
|
);
|
|
160
|
-
|
|
161
|
-
|
|
187
|
+
return applyDraftFilter(inSession, session, draftVisibility, currentUserId);
|
|
188
|
+
};
|
|
189
|
+
var selectCommentsBySession = ({
|
|
190
|
+
comments,
|
|
191
|
+
locationId,
|
|
192
|
+
session,
|
|
193
|
+
draftVisibility = "visible",
|
|
194
|
+
currentUserId
|
|
195
|
+
}) => {
|
|
196
|
+
const grouped = {};
|
|
197
|
+
for (const comment of selectCommentsByLocation({ comments, locationId })) {
|
|
198
|
+
const list = grouped[comment.sessionId];
|
|
199
|
+
if (list) {
|
|
200
|
+
list.push(comment);
|
|
201
|
+
} else {
|
|
202
|
+
grouped[comment.sessionId] = [comment];
|
|
203
|
+
}
|
|
162
204
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
205
|
+
if (session !== null) {
|
|
206
|
+
const active = grouped[session.id];
|
|
207
|
+
if (active) {
|
|
208
|
+
const filtered = applyDraftFilter(
|
|
209
|
+
active,
|
|
210
|
+
session,
|
|
211
|
+
draftVisibility,
|
|
212
|
+
currentUserId
|
|
213
|
+
);
|
|
214
|
+
if (filtered.length === 0) {
|
|
215
|
+
delete grouped[session.id];
|
|
216
|
+
} else {
|
|
217
|
+
grouped[session.id] = filtered;
|
|
218
|
+
}
|
|
166
219
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
});
|
|
220
|
+
}
|
|
221
|
+
return grouped;
|
|
170
222
|
};
|
|
171
223
|
|
|
172
224
|
// src/contexts/feedback-session-context.tsx
|
|
173
225
|
import {
|
|
174
|
-
createContext
|
|
226
|
+
createContext,
|
|
175
227
|
useCallback as useCallback3,
|
|
176
|
-
useContext
|
|
228
|
+
useContext,
|
|
177
229
|
useEffect,
|
|
178
|
-
useMemo
|
|
230
|
+
useMemo,
|
|
179
231
|
useReducer,
|
|
180
232
|
useRef as useRef3
|
|
181
233
|
} from "react";
|
|
@@ -215,6 +267,45 @@ var useSessionEvents = () => {
|
|
|
215
267
|
return { events, emit };
|
|
216
268
|
};
|
|
217
269
|
|
|
270
|
+
// src/utils/session-type.ts
|
|
271
|
+
var SESSION_TYPES = ["feedback"];
|
|
272
|
+
var isSessionType = (value) => SESSION_TYPES.includes(value);
|
|
273
|
+
var SESSION_STATUSES = [
|
|
274
|
+
"draft",
|
|
275
|
+
"confirmed",
|
|
276
|
+
"resolving",
|
|
277
|
+
"resolved"
|
|
278
|
+
];
|
|
279
|
+
var parseInitialSession = (value) => {
|
|
280
|
+
if (value === null || typeof value !== "object") return null;
|
|
281
|
+
const status = value.status;
|
|
282
|
+
if (!SESSION_STATUSES.includes(status)) return null;
|
|
283
|
+
const session = value;
|
|
284
|
+
return {
|
|
285
|
+
...value,
|
|
286
|
+
comments: session.comments ?? []
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
// src/utils/session-guards.ts
|
|
291
|
+
var locatedComments = (session) => session.comments.filter(isLocated);
|
|
292
|
+
var confirmRefusal = (session, localDrafts) => {
|
|
293
|
+
if (!session || session.status !== "draft") return "session is not a draft";
|
|
294
|
+
if (localDrafts > 0) return "a local draft comment exists";
|
|
295
|
+
if (locatedComments(session).length === 0) return "session has no comments";
|
|
296
|
+
if (!isSessionType(session.type)) return "unknown session type";
|
|
297
|
+
return null;
|
|
298
|
+
};
|
|
299
|
+
var resolveRefusal = (session) => {
|
|
300
|
+
if (session?.status !== "resolving") return "session is not resolving";
|
|
301
|
+
return locatedComments(session).some((c) => c.status === "published") ? "a comment is still published" : null;
|
|
302
|
+
};
|
|
303
|
+
var sumCounts = (counts) => {
|
|
304
|
+
let total = 0;
|
|
305
|
+
for (const count of counts.values()) total += count;
|
|
306
|
+
return total;
|
|
307
|
+
};
|
|
308
|
+
|
|
218
309
|
// src/utils/session-reducer.ts
|
|
219
310
|
var initialSessionReducerState = {
|
|
220
311
|
session: null,
|
|
@@ -307,61 +398,17 @@ var sessionReducer = (state, action) => {
|
|
|
307
398
|
}
|
|
308
399
|
};
|
|
309
400
|
|
|
310
|
-
// src/utils/session-type.ts
|
|
311
|
-
var SESSION_TYPES = ["feedback"];
|
|
312
|
-
var isSessionType = (value) => SESSION_TYPES.includes(value);
|
|
313
|
-
var SESSION_STATUSES = [
|
|
314
|
-
"draft",
|
|
315
|
-
"confirmed",
|
|
316
|
-
"resolving",
|
|
317
|
-
"resolved"
|
|
318
|
-
];
|
|
319
|
-
var parseInitialSession = (value) => {
|
|
320
|
-
if (value === null || typeof value !== "object") return null;
|
|
321
|
-
const status = value.status;
|
|
322
|
-
if (!SESSION_STATUSES.includes(status)) return null;
|
|
323
|
-
const session = value;
|
|
324
|
-
return {
|
|
325
|
-
...value,
|
|
326
|
-
comments: session.comments ?? []
|
|
327
|
-
};
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
// src/contexts/user-context.tsx
|
|
331
|
-
import * as React from "react";
|
|
332
|
-
import { jsx } from "react/jsx-runtime";
|
|
333
|
-
var UserContext = React.createContext(
|
|
334
|
-
void 0
|
|
335
|
-
);
|
|
336
|
-
var UserProvider = ({ user, children }) => {
|
|
337
|
-
const value = React.useMemo(
|
|
338
|
-
() => ({ currentUser: user }),
|
|
339
|
-
[user]
|
|
340
|
-
);
|
|
341
|
-
return /* @__PURE__ */ jsx(UserContext.Provider, { value, children });
|
|
342
|
-
};
|
|
343
|
-
var useCurrentUser = () => {
|
|
344
|
-
const ctx = React.useContext(UserContext);
|
|
345
|
-
if (!ctx) {
|
|
346
|
-
throw new Error("useCurrentUser must be used within <UserProvider />");
|
|
347
|
-
}
|
|
348
|
-
return ctx.currentUser;
|
|
349
|
-
};
|
|
350
|
-
var useOptionalCurrentUser = () => {
|
|
351
|
-
const ctx = React.useContext(UserContext);
|
|
352
|
-
return ctx ? ctx.currentUser : void 0;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
401
|
// src/contexts/feedback-session-context.tsx
|
|
356
|
-
import { jsx
|
|
357
|
-
var FeedbackSessionContext =
|
|
402
|
+
import { jsx } from "react/jsx-runtime";
|
|
403
|
+
var FeedbackSessionContext = createContext(
|
|
358
404
|
null
|
|
359
405
|
);
|
|
360
|
-
var SessionBridgeContext =
|
|
406
|
+
var SessionBridgeContext = createContext(null);
|
|
361
407
|
var MAX_PROJECT_ID_LENGTH = 128;
|
|
362
408
|
var isValidProjectId = (projectId) => projectId === void 0 || typeof projectId === "string" && projectId.length >= 1 && projectId.length <= MAX_PROJECT_ID_LENGTH;
|
|
363
409
|
var pick = (value, fallback) => value !== void 0 ? value : fallback;
|
|
364
|
-
var createRefusal = (type, projectId, inFlight, session, hasCallback) => {
|
|
410
|
+
var createRefusal = (type, projectId, inFlight, session, hasCallback, user) => {
|
|
411
|
+
if (!user) return "user is required";
|
|
365
412
|
if (!isSessionType(type)) return "unknown session type";
|
|
366
413
|
if (!isValidProjectId(projectId)) {
|
|
367
414
|
return "projectId must be 1 to 128 characters";
|
|
@@ -371,18 +418,6 @@ var createRefusal = (type, projectId, inFlight, session, hasCallback) => {
|
|
|
371
418
|
if (!hasCallback) return "onCreateSession is not provided";
|
|
372
419
|
return null;
|
|
373
420
|
};
|
|
374
|
-
var confirmRefusal = (session, localDrafts) => {
|
|
375
|
-
if (!session || session.status !== "draft") return "session is not a draft";
|
|
376
|
-
if (localDrafts > 0) return "a local draft comment exists";
|
|
377
|
-
if (session.comments.length === 0) return "session has no comments";
|
|
378
|
-
if (!isSessionType(session.type)) return "unknown session type";
|
|
379
|
-
return null;
|
|
380
|
-
};
|
|
381
|
-
var sumCounts = (counts) => {
|
|
382
|
-
let total = 0;
|
|
383
|
-
for (const count of counts.values()) total += count;
|
|
384
|
-
return total;
|
|
385
|
-
};
|
|
386
421
|
var FeedbackSessionProvider = ({
|
|
387
422
|
children,
|
|
388
423
|
initialSession,
|
|
@@ -394,7 +429,6 @@ var FeedbackSessionProvider = ({
|
|
|
394
429
|
onResolveSession,
|
|
395
430
|
onError
|
|
396
431
|
}) => {
|
|
397
|
-
const contextUser = useOptionalCurrentUser();
|
|
398
432
|
const initialParsedRef = useRef3(
|
|
399
433
|
void 0
|
|
400
434
|
);
|
|
@@ -435,14 +469,15 @@ var FeedbackSessionProvider = ({
|
|
|
435
469
|
const createSession = useCallback3(
|
|
436
470
|
async (options) => {
|
|
437
471
|
const type = options?.type ?? "feedback";
|
|
438
|
-
const user =
|
|
472
|
+
const user = options?.user;
|
|
439
473
|
const sessionProjectId = pick(options?.projectId, projectId);
|
|
440
474
|
const refusal = createRefusal(
|
|
441
475
|
type,
|
|
442
476
|
sessionProjectId,
|
|
443
477
|
inFlightRef.current,
|
|
444
478
|
stateRef.current.session,
|
|
445
|
-
onCreateSession !== void 0
|
|
479
|
+
onCreateSession !== void 0,
|
|
480
|
+
user
|
|
446
481
|
);
|
|
447
482
|
if (refusal !== null || !onCreateSession) {
|
|
448
483
|
const error = new SessionCreateError(refusal ?? void 0);
|
|
@@ -454,7 +489,7 @@ var FeedbackSessionProvider = ({
|
|
|
454
489
|
try {
|
|
455
490
|
const input = {
|
|
456
491
|
type,
|
|
457
|
-
user
|
|
492
|
+
user,
|
|
458
493
|
projectId: sessionProjectId
|
|
459
494
|
};
|
|
460
495
|
const { data, error } = await tx.executeAsync(
|
|
@@ -477,7 +512,7 @@ var FeedbackSessionProvider = ({
|
|
|
477
512
|
apply({ type: "SET_OPERATION_STATE", to: "idle" });
|
|
478
513
|
}
|
|
479
514
|
},
|
|
480
|
-
[apply,
|
|
515
|
+
[apply, emit, onCreateSession, projectId, report]
|
|
481
516
|
);
|
|
482
517
|
const confirmSession = useCallback3(async () => {
|
|
483
518
|
if (inFlightRef.current === "confirming") return { error: null };
|
|
@@ -563,11 +598,7 @@ var FeedbackSessionProvider = ({
|
|
|
563
598
|
const resolveSession = useCallback3(
|
|
564
599
|
() => runTransition({
|
|
565
600
|
pending: "completingResolution",
|
|
566
|
-
guard:
|
|
567
|
-
if (session?.status !== "resolving")
|
|
568
|
-
return "session is not resolving";
|
|
569
|
-
return session.comments.some((c) => c.status === "published") ? "a comment is still published" : null;
|
|
570
|
-
},
|
|
601
|
+
guard: resolveRefusal,
|
|
571
602
|
call: onResolveSession,
|
|
572
603
|
failure: SessionResolveError,
|
|
573
604
|
commit: () => {
|
|
@@ -597,7 +628,7 @@ var FeedbackSessionProvider = ({
|
|
|
597
628
|
},
|
|
598
629
|
[]
|
|
599
630
|
);
|
|
600
|
-
const bridge =
|
|
631
|
+
const bridge = useMemo(
|
|
601
632
|
() => ({
|
|
602
633
|
session: state.session,
|
|
603
634
|
canResolve: canResolveSession,
|
|
@@ -625,10 +656,10 @@ var FeedbackSessionProvider = ({
|
|
|
625
656
|
resolveSession,
|
|
626
657
|
events
|
|
627
658
|
};
|
|
628
|
-
return /* @__PURE__ */
|
|
659
|
+
return /* @__PURE__ */ jsx(FeedbackSessionContext.Provider, { value, children: /* @__PURE__ */ jsx(SessionBridgeContext.Provider, { value: bridge, children }) });
|
|
629
660
|
};
|
|
630
661
|
var useFeedbackSession = () => {
|
|
631
|
-
const context =
|
|
662
|
+
const context = useContext(FeedbackSessionContext);
|
|
632
663
|
if (!context) {
|
|
633
664
|
throw new Error(
|
|
634
665
|
"useFeedbackSession must be used within a FeedbackSessionProvider"
|
|
@@ -637,7 +668,7 @@ var useFeedbackSession = () => {
|
|
|
637
668
|
return context;
|
|
638
669
|
};
|
|
639
670
|
var useSessionBridge = () => {
|
|
640
|
-
const bridge =
|
|
671
|
+
const bridge = useContext(SessionBridgeContext);
|
|
641
672
|
if (!bridge) {
|
|
642
673
|
throw new Error(
|
|
643
674
|
"CommentContextProvider must be used within a FeedbackSessionProvider"
|
|
@@ -647,8 +678,8 @@ var useSessionBridge = () => {
|
|
|
647
678
|
};
|
|
648
679
|
|
|
649
680
|
// src/contexts/comment-context.tsx
|
|
650
|
-
import { jsx as
|
|
651
|
-
var CommentContext =
|
|
681
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
682
|
+
var CommentContext = createContext2(null);
|
|
652
683
|
var commentReducer = (state, action) => {
|
|
653
684
|
switch (action.type) {
|
|
654
685
|
case "REGISTER": {
|
|
@@ -662,6 +693,7 @@ var commentReducer = (state, action) => {
|
|
|
662
693
|
{
|
|
663
694
|
id: newId,
|
|
664
695
|
sessionId: action.sessionId,
|
|
696
|
+
locationId: action.locationId,
|
|
665
697
|
projectId: state.projectId,
|
|
666
698
|
user: state.currentUser,
|
|
667
699
|
position: {
|
|
@@ -771,6 +803,7 @@ var CommentContextProvider = ({
|
|
|
771
803
|
}
|
|
772
804
|
},
|
|
773
805
|
projectId,
|
|
806
|
+
locationId: locationIdProp,
|
|
774
807
|
onError,
|
|
775
808
|
onAdd,
|
|
776
809
|
onEdit,
|
|
@@ -778,6 +811,9 @@ var CommentContextProvider = ({
|
|
|
778
811
|
onResolve,
|
|
779
812
|
onReopen
|
|
780
813
|
}) => {
|
|
814
|
+
const locationId = normalizeLocationId(locationIdProp);
|
|
815
|
+
const locationIdRef = useRef4(locationId);
|
|
816
|
+
locationIdRef.current = locationId;
|
|
781
817
|
const hostRef = useRef4({ onAdd, onEdit, onDelete, onResolve, onReopen });
|
|
782
818
|
hostRef.current = { onAdd, onEdit, onDelete, onResolve, onReopen };
|
|
783
819
|
const bridge = useSessionBridge();
|
|
@@ -785,8 +821,7 @@ var CommentContextProvider = ({
|
|
|
785
821
|
bridgeRef.current = bridge;
|
|
786
822
|
const canResolveRef = useRef4(bridge.canResolve);
|
|
787
823
|
canResolveRef.current = bridge.canResolve;
|
|
788
|
-
const
|
|
789
|
-
const currentUser = contextUser !== void 0 ? contextUser : currentUserProp ?? null;
|
|
824
|
+
const currentUser = currentUserProp ?? null;
|
|
790
825
|
const currentUserRef = useRef4(currentUser);
|
|
791
826
|
currentUserRef.current = currentUser;
|
|
792
827
|
const [state, dispatch] = useReducer2(
|
|
@@ -830,9 +865,15 @@ var CommentContextProvider = ({
|
|
|
830
865
|
onError?.(new SessionStateError());
|
|
831
866
|
return;
|
|
832
867
|
}
|
|
868
|
+
const currentLocationId = locationIdRef.current;
|
|
869
|
+
if (currentLocationId === void 0) {
|
|
870
|
+
onError?.(new AddError("locationId is missing"));
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
833
873
|
dispatch({
|
|
834
874
|
type: "REGISTER",
|
|
835
875
|
sessionId: session.id,
|
|
876
|
+
locationId: currentLocationId,
|
|
836
877
|
position,
|
|
837
878
|
indicatorPosition: indicatorPosition || null
|
|
838
879
|
});
|
|
@@ -1006,9 +1047,18 @@ var CommentContextProvider = ({
|
|
|
1006
1047
|
const toggleOverlay = () => {
|
|
1007
1048
|
dispatch({ type: "TOGGLE_OVERLAY" });
|
|
1008
1049
|
};
|
|
1050
|
+
const activeSession = bridge.session ? { id: bridge.session.id, status: bridge.session.status } : null;
|
|
1009
1051
|
const visibleComments = selectVisibleComments({
|
|
1010
1052
|
comments: state.comments,
|
|
1011
|
-
session:
|
|
1053
|
+
session: activeSession,
|
|
1054
|
+
locationId,
|
|
1055
|
+
draftVisibility: state.config?.draftVisibility,
|
|
1056
|
+
currentUserId: currentUser?.id
|
|
1057
|
+
});
|
|
1058
|
+
const commentsBySession = selectCommentsBySession({
|
|
1059
|
+
comments: state.comments,
|
|
1060
|
+
locationId,
|
|
1061
|
+
session: activeSession,
|
|
1012
1062
|
draftVisibility: state.config?.draftVisibility,
|
|
1013
1063
|
currentUserId: currentUser?.id
|
|
1014
1064
|
});
|
|
@@ -1023,7 +1073,7 @@ var CommentContextProvider = ({
|
|
|
1023
1073
|
onError(error);
|
|
1024
1074
|
}
|
|
1025
1075
|
};
|
|
1026
|
-
return /* @__PURE__ */
|
|
1076
|
+
return /* @__PURE__ */ jsx2(
|
|
1027
1077
|
CommentContext.Provider,
|
|
1028
1078
|
{
|
|
1029
1079
|
value: {
|
|
@@ -1031,6 +1081,7 @@ var CommentContextProvider = ({
|
|
|
1031
1081
|
comments: visibleComments.filter(hasStatus("published")),
|
|
1032
1082
|
resolvedComments: visibleComments.filter(hasStatus("resolved")),
|
|
1033
1083
|
allComments: visibleComments,
|
|
1084
|
+
commentsBySession,
|
|
1034
1085
|
config: state.config,
|
|
1035
1086
|
changeOverlayState,
|
|
1036
1087
|
overlayState: state.overlayState,
|
|
@@ -1054,7 +1105,7 @@ var CommentContextProvider = ({
|
|
|
1054
1105
|
};
|
|
1055
1106
|
var useComments = () => {
|
|
1056
1107
|
useSessionBridge();
|
|
1057
|
-
const context =
|
|
1108
|
+
const context = useContext2(CommentContext);
|
|
1058
1109
|
if (!context) {
|
|
1059
1110
|
throw new Error("useComments must be used within a CommentContextProvider");
|
|
1060
1111
|
}
|
|
@@ -1075,7 +1126,7 @@ var normalizeRect = (a, b) => {
|
|
|
1075
1126
|
};
|
|
1076
1127
|
|
|
1077
1128
|
// src/components/comment-overlay.tsx
|
|
1078
|
-
import { jsx as
|
|
1129
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
1079
1130
|
var DRAG_THRESHOLD = 4;
|
|
1080
1131
|
var CommentOverlay = ({ children, ...rest }) => {
|
|
1081
1132
|
const {
|
|
@@ -1151,7 +1202,7 @@ var CommentOverlay = ({ children, ...rest }) => {
|
|
|
1151
1202
|
};
|
|
1152
1203
|
if (overlayState === "inactive") return children;
|
|
1153
1204
|
return /* @__PURE__ */ jsxs("div", { "data-overlay": true, style: { position: "relative", ...rest.style }, ...rest, children: [
|
|
1154
|
-
/* @__PURE__ */
|
|
1205
|
+
/* @__PURE__ */ jsx3(
|
|
1155
1206
|
"div",
|
|
1156
1207
|
{
|
|
1157
1208
|
ref: overlayRef,
|
|
@@ -1165,7 +1216,7 @@ var CommentOverlay = ({ children, ...rest }) => {
|
|
|
1165
1216
|
}
|
|
1166
1217
|
),
|
|
1167
1218
|
getActiveComment() && // biome-ignore lint: This element should only handle clicks as a guard
|
|
1168
|
-
/* @__PURE__ */
|
|
1219
|
+
/* @__PURE__ */ jsx3(
|
|
1169
1220
|
"div",
|
|
1170
1221
|
{
|
|
1171
1222
|
"data-comment-guard": true,
|
|
@@ -1191,7 +1242,7 @@ var CommentOverlay = ({ children, ...rest }) => {
|
|
|
1191
1242
|
}
|
|
1192
1243
|
}
|
|
1193
1244
|
),
|
|
1194
|
-
preview && /* @__PURE__ */
|
|
1245
|
+
preview && /* @__PURE__ */ jsx3(
|
|
1195
1246
|
"div",
|
|
1196
1247
|
{
|
|
1197
1248
|
style: {
|
|
@@ -1223,41 +1274,35 @@ var EDITING_STYLES = {
|
|
|
1223
1274
|
};
|
|
1224
1275
|
|
|
1225
1276
|
// src/components/comment-renderer.tsx
|
|
1226
|
-
import { Fragment, jsx as
|
|
1277
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1227
1278
|
var CommentRenderer = ({
|
|
1228
1279
|
Comment: Comment2,
|
|
1229
1280
|
DraftComment,
|
|
1230
1281
|
ResolvedComment
|
|
1231
1282
|
}) => {
|
|
1232
|
-
const {
|
|
1233
|
-
comments,
|
|
1234
|
-
draftComments,
|
|
1235
|
-
overlayState,
|
|
1236
|
-
resolvedComments,
|
|
1237
|
-
config
|
|
1238
|
-
} = useComments();
|
|
1283
|
+
const { comments, draftComments, overlayState, resolvedComments, config } = useComments();
|
|
1239
1284
|
if (overlayState === "inactive") return null;
|
|
1240
1285
|
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
1241
1286
|
draftComments.map((comment) => {
|
|
1242
|
-
return /* @__PURE__ */
|
|
1287
|
+
return /* @__PURE__ */ jsx4(DraftComment, { comment }, comment.id);
|
|
1243
1288
|
}),
|
|
1244
1289
|
comments.map((comment) => {
|
|
1245
|
-
return /* @__PURE__ */
|
|
1290
|
+
return /* @__PURE__ */ jsx4(Comment2, { comment }, comment.id);
|
|
1246
1291
|
}),
|
|
1247
1292
|
resolvedComments.map((comment) => {
|
|
1248
1293
|
if (config?.commentVisibility?.hideResolved) return null;
|
|
1249
|
-
return /* @__PURE__ */
|
|
1294
|
+
return /* @__PURE__ */ jsx4(ResolvedComment, { comment }, comment.id);
|
|
1250
1295
|
})
|
|
1251
1296
|
] });
|
|
1252
1297
|
};
|
|
1253
1298
|
|
|
1254
1299
|
// src/components/comment-actions.tsx
|
|
1255
1300
|
import { Slot } from "@radix-ui/react-slot";
|
|
1256
|
-
import { jsx as
|
|
1301
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1257
1302
|
var ToggleOverlayButton = ({ asChild, ...rest }) => {
|
|
1258
1303
|
const { toggleOverlay, overlayState } = useComments();
|
|
1259
1304
|
const Comp = asChild ? Slot : "button";
|
|
1260
|
-
return /* @__PURE__ */
|
|
1305
|
+
return /* @__PURE__ */ jsx5(
|
|
1261
1306
|
Comp,
|
|
1262
1307
|
{
|
|
1263
1308
|
"data-active": overlayState !== "inactive",
|
|
@@ -1277,12 +1322,12 @@ import {
|
|
|
1277
1322
|
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
1278
1323
|
|
|
1279
1324
|
// src/contexts/scoped-comment.tsx
|
|
1280
|
-
import * as
|
|
1281
|
-
var CommentScopeContext =
|
|
1325
|
+
import * as React from "react";
|
|
1326
|
+
var CommentScopeContext = React.createContext(
|
|
1282
1327
|
null
|
|
1283
1328
|
);
|
|
1284
1329
|
function useCommentScope() {
|
|
1285
|
-
const ctx =
|
|
1330
|
+
const ctx = React.useContext(CommentScopeContext);
|
|
1286
1331
|
if (!ctx) {
|
|
1287
1332
|
throw new Error("Comment.* must be used within <Comment.Root />");
|
|
1288
1333
|
}
|
|
@@ -1290,7 +1335,7 @@ function useCommentScope() {
|
|
|
1290
1335
|
}
|
|
1291
1336
|
|
|
1292
1337
|
// src/components/comment.tsx
|
|
1293
|
-
import { jsx as
|
|
1338
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1294
1339
|
var CommentRoot = ({
|
|
1295
1340
|
comment,
|
|
1296
1341
|
defaultDraft,
|
|
@@ -1306,11 +1351,11 @@ var CommentRoot = ({
|
|
|
1306
1351
|
top: comment.position.y,
|
|
1307
1352
|
left: comment.position.x
|
|
1308
1353
|
};
|
|
1309
|
-
return /* @__PURE__ */
|
|
1354
|
+
return /* @__PURE__ */ jsx6(
|
|
1310
1355
|
CommentScopeContext.Provider,
|
|
1311
1356
|
{
|
|
1312
1357
|
value: { comment, isActive, draft, setDraft },
|
|
1313
|
-
children: /* @__PURE__ */
|
|
1358
|
+
children: /* @__PURE__ */ jsx6(
|
|
1314
1359
|
"div",
|
|
1315
1360
|
{
|
|
1316
1361
|
...rest,
|
|
@@ -1332,7 +1377,7 @@ var CommentIndicator = ({ ...rest }) => {
|
|
|
1332
1377
|
const { config } = useComments();
|
|
1333
1378
|
if (!comment.indicator) return null;
|
|
1334
1379
|
if (config?.indicatorVisibility === "active" && !isActive) return null;
|
|
1335
|
-
return /* @__PURE__ */
|
|
1380
|
+
return /* @__PURE__ */ jsx6(
|
|
1336
1381
|
"div",
|
|
1337
1382
|
{
|
|
1338
1383
|
...rest,
|
|
@@ -1354,12 +1399,12 @@ var CommentIndicator = ({ ...rest }) => {
|
|
|
1354
1399
|
var CommentContent = ({ asChild, ...rest }) => {
|
|
1355
1400
|
const { draft } = useCommentScope();
|
|
1356
1401
|
const Comp = asChild ? Slot2 : "p";
|
|
1357
|
-
return /* @__PURE__ */
|
|
1402
|
+
return /* @__PURE__ */ jsx6(Comp, { ...rest, children: draft });
|
|
1358
1403
|
};
|
|
1359
1404
|
var CommentEdit = ({ asChild, ...rest }) => {
|
|
1360
1405
|
const { draft, setDraft } = useCommentScope();
|
|
1361
1406
|
const Comp = asChild ? Slot2 : "textarea";
|
|
1362
|
-
return /* @__PURE__ */
|
|
1407
|
+
return /* @__PURE__ */ jsx6(
|
|
1363
1408
|
Comp,
|
|
1364
1409
|
{
|
|
1365
1410
|
...rest,
|
|
@@ -1377,7 +1422,7 @@ var CommentConfirm = ({ asChild, ...rest }) => {
|
|
|
1377
1422
|
const { updateComment } = useComments();
|
|
1378
1423
|
const { comment, draft } = useCommentScope();
|
|
1379
1424
|
const Comp = asChild ? Slot2 : "button";
|
|
1380
|
-
return /* @__PURE__ */
|
|
1425
|
+
return /* @__PURE__ */ jsx6(
|
|
1381
1426
|
Comp,
|
|
1382
1427
|
{
|
|
1383
1428
|
...rest,
|
|
@@ -1393,7 +1438,7 @@ var CommentDelete = ({ asChild, ...rest }) => {
|
|
|
1393
1438
|
const { deleteComment } = useComments();
|
|
1394
1439
|
const { comment } = useCommentScope();
|
|
1395
1440
|
const Comp = asChild ? Slot2 : "button";
|
|
1396
|
-
return /* @__PURE__ */
|
|
1441
|
+
return /* @__PURE__ */ jsx6(
|
|
1397
1442
|
Comp,
|
|
1398
1443
|
{
|
|
1399
1444
|
...rest,
|
|
@@ -1420,7 +1465,7 @@ var CommentResolve = ({ asChild, ...rest }) => {
|
|
|
1420
1465
|
);
|
|
1421
1466
|
return null;
|
|
1422
1467
|
}
|
|
1423
|
-
return /* @__PURE__ */
|
|
1468
|
+
return /* @__PURE__ */ jsx6(
|
|
1424
1469
|
Comp,
|
|
1425
1470
|
{
|
|
1426
1471
|
...rest,
|
|
@@ -1447,7 +1492,7 @@ var CommentReopen = ({ asChild, ...rest }) => {
|
|
|
1447
1492
|
);
|
|
1448
1493
|
return null;
|
|
1449
1494
|
}
|
|
1450
|
-
return /* @__PURE__ */
|
|
1495
|
+
return /* @__PURE__ */ jsx6(
|
|
1451
1496
|
Comp,
|
|
1452
1497
|
{
|
|
1453
1498
|
...rest,
|
|
@@ -1527,16 +1572,16 @@ var Comment = {
|
|
|
1527
1572
|
|
|
1528
1573
|
// src/components/session-actions.tsx
|
|
1529
1574
|
import { Slot as Slot3 } from "@radix-ui/react-slot";
|
|
1530
|
-
import { jsx as
|
|
1531
|
-
var CreateSession = ({ asChild, ...rest }) => {
|
|
1575
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1576
|
+
var CreateSession = ({ asChild, user, ...rest }) => {
|
|
1532
1577
|
const { createSession } = useFeedbackSession();
|
|
1533
1578
|
const Comp = asChild ? Slot3 : "button";
|
|
1534
|
-
return /* @__PURE__ */
|
|
1579
|
+
return /* @__PURE__ */ jsx7(
|
|
1535
1580
|
Comp,
|
|
1536
1581
|
{
|
|
1537
1582
|
...rest,
|
|
1538
1583
|
onClick: (e) => {
|
|
1539
|
-
void createSession();
|
|
1584
|
+
void createSession({ user });
|
|
1540
1585
|
rest.onClick?.(e);
|
|
1541
1586
|
}
|
|
1542
1587
|
}
|
|
@@ -1545,7 +1590,7 @@ var CreateSession = ({ asChild, ...rest }) => {
|
|
|
1545
1590
|
var ConfirmSession = ({ asChild, ...rest }) => {
|
|
1546
1591
|
const { confirmSession } = useFeedbackSession();
|
|
1547
1592
|
const Comp = asChild ? Slot3 : "button";
|
|
1548
|
-
return /* @__PURE__ */
|
|
1593
|
+
return /* @__PURE__ */ jsx7(
|
|
1549
1594
|
Comp,
|
|
1550
1595
|
{
|
|
1551
1596
|
...rest,
|
|
@@ -1559,7 +1604,7 @@ var ConfirmSession = ({ asChild, ...rest }) => {
|
|
|
1559
1604
|
var StartResolving = ({ asChild, ...rest }) => {
|
|
1560
1605
|
const { startResolving } = useFeedbackSession();
|
|
1561
1606
|
const Comp = asChild ? Slot3 : "button";
|
|
1562
|
-
return /* @__PURE__ */
|
|
1607
|
+
return /* @__PURE__ */ jsx7(
|
|
1563
1608
|
Comp,
|
|
1564
1609
|
{
|
|
1565
1610
|
...rest,
|
|
@@ -1573,7 +1618,7 @@ var StartResolving = ({ asChild, ...rest }) => {
|
|
|
1573
1618
|
var ResolveSession = ({ asChild, ...rest }) => {
|
|
1574
1619
|
const { resolveSession } = useFeedbackSession();
|
|
1575
1620
|
const Comp = asChild ? Slot3 : "button";
|
|
1576
|
-
return /* @__PURE__ */
|
|
1621
|
+
return /* @__PURE__ */ jsx7(
|
|
1577
1622
|
Comp,
|
|
1578
1623
|
{
|
|
1579
1624
|
...rest,
|
|
@@ -1596,9 +1641,8 @@ export {
|
|
|
1596
1641
|
ResolveSession,
|
|
1597
1642
|
StartResolving,
|
|
1598
1643
|
ToggleOverlayButton,
|
|
1599
|
-
|
|
1644
|
+
commentReducer,
|
|
1600
1645
|
useCommentScope,
|
|
1601
1646
|
useComments,
|
|
1602
|
-
useCurrentUser,
|
|
1603
1647
|
useFeedbackSession
|
|
1604
1648
|
};
|