@kendew-agency/react-feedback-layer 0.1.2 → 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 +12 -1
- package/dist/{comment.types-CfEOrU1d.d.cts → comment.types-CSGuc1D_.d.cts} +8 -7
- package/dist/{comment.types-CfEOrU1d.d.ts → comment.types-CSGuc1D_.d.ts} +8 -7
- package/dist/index.cjs +9 -4
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +13 -5
- package/dist/types.d.cts +5 -2
- package/dist/types.d.ts +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @kendew-agency/react-feedback-layer
|
|
2
2
|
|
|
3
|
-
A drop-in React feedback layer for collecting contextual user feedback through interactive comments and annotations. Perfect for design review tools, bug reporting systems, and collaborative annotation platforms.
|
|
3
|
+
A drop-in React feedback layer for collecting contextual user feedback through interactive comments and annotations. Perfect for design review tools, bug reporting systems, and collaborative annotation platforms.
|
|
4
|
+
|
|
5
|
+
Have a look at the [changelog](#changelog) when updating the package.
|
|
4
6
|
|
|
5
7
|
## Features
|
|
6
8
|
|
|
@@ -1169,3 +1171,12 @@ MIT © [Kendew Agency](https://github.com/Kendew-Agency)
|
|
|
1169
1171
|
- [GitHub Repository](https://github.com/Kendew-Agency/react-feedback-layer)
|
|
1170
1172
|
- [Issue Tracker](https://github.com/Kendew-Agency/react-feedback-layer/issues)
|
|
1171
1173
|
- [NPM Package](https://www.npmjs.com/package/@kendew-agency/react-feedback-layer)
|
|
1174
|
+
|
|
1175
|
+
## Changelog
|
|
1176
|
+
|
|
1177
|
+
A list if breaking changes that could impact the way you configured the package
|
|
1178
|
+
|
|
1179
|
+
### 0.2.0
|
|
1180
|
+
- Reworked the subscription system. The system remains in beta and may change in the future. Configurations made with version 0.1.2 or older will need adjustment after updating.
|
|
1181
|
+
- `mode` was defined twice in props. It has been removed as a root prop and is now only part of the config.
|
|
1182
|
+
|
|
@@ -89,9 +89,10 @@ type CommentOverlayProps = {
|
|
|
89
89
|
initialOverlayState?: CommentOverlayState;
|
|
90
90
|
/**
|
|
91
91
|
* Realtime subscription if supported by you DB
|
|
92
|
+
* @description You can use this feature with a realtime DB or a websocket
|
|
93
|
+
* @beta this featue is not yet fully tested and is subject to change
|
|
92
94
|
*/
|
|
93
|
-
subscription?:
|
|
94
|
-
mode?: "onConfirm";
|
|
95
|
+
subscription?: RealtimeSubscription<CommentType>;
|
|
95
96
|
/**
|
|
96
97
|
* Callback with all newly confirmed comments
|
|
97
98
|
*
|
|
@@ -115,10 +116,10 @@ type CommentOverlayProps = {
|
|
|
115
116
|
*/
|
|
116
117
|
config?: Config;
|
|
117
118
|
};
|
|
118
|
-
|
|
119
|
-
subscribe: (
|
|
120
|
-
unsubscribe
|
|
121
|
-
}
|
|
119
|
+
interface RealtimeSubscription<T> {
|
|
120
|
+
subscribe(onUpdate: (data: T) => void): void;
|
|
121
|
+
unsubscribe(): void;
|
|
122
|
+
}
|
|
122
123
|
type Config = {
|
|
123
124
|
/**
|
|
124
125
|
* A custom prefix for the comment ids
|
|
@@ -252,4 +253,4 @@ type CommentWithStatus<T extends Status> = Omit<CommentType, "status"> & {
|
|
|
252
253
|
status: T;
|
|
253
254
|
};
|
|
254
255
|
|
|
255
|
-
export type { CommentType as C, Indicator as I, KnownError as K, OverlayErrorCode as O, Position as P, Status as S, User as U, CommentOverlayProps as a, CommentContext as b, CommentOverlayState as c, CommentVisibility as d, ConfirmedStatus as e, ConfirmedComment as f, CommentWithStatus as g, CommentState as h, Config as i };
|
|
256
|
+
export type { CommentType as C, Indicator as I, KnownError as K, OverlayErrorCode as O, Position as P, RealtimeSubscription as R, Status as S, User as U, CommentOverlayProps as a, CommentContext as b, CommentOverlayState as c, CommentVisibility as d, ConfirmedStatus as e, ConfirmedComment as f, CommentWithStatus as g, CommentState as h, Config as i };
|
|
@@ -89,9 +89,10 @@ type CommentOverlayProps = {
|
|
|
89
89
|
initialOverlayState?: CommentOverlayState;
|
|
90
90
|
/**
|
|
91
91
|
* Realtime subscription if supported by you DB
|
|
92
|
+
* @description You can use this feature with a realtime DB or a websocket
|
|
93
|
+
* @beta this featue is not yet fully tested and is subject to change
|
|
92
94
|
*/
|
|
93
|
-
subscription?:
|
|
94
|
-
mode?: "onConfirm";
|
|
95
|
+
subscription?: RealtimeSubscription<CommentType>;
|
|
95
96
|
/**
|
|
96
97
|
* Callback with all newly confirmed comments
|
|
97
98
|
*
|
|
@@ -115,10 +116,10 @@ type CommentOverlayProps = {
|
|
|
115
116
|
*/
|
|
116
117
|
config?: Config;
|
|
117
118
|
};
|
|
118
|
-
|
|
119
|
-
subscribe: (
|
|
120
|
-
unsubscribe
|
|
121
|
-
}
|
|
119
|
+
interface RealtimeSubscription<T> {
|
|
120
|
+
subscribe(onUpdate: (data: T) => void): void;
|
|
121
|
+
unsubscribe(): void;
|
|
122
|
+
}
|
|
122
123
|
type Config = {
|
|
123
124
|
/**
|
|
124
125
|
* A custom prefix for the comment ids
|
|
@@ -252,4 +253,4 @@ type CommentWithStatus<T extends Status> = Omit<CommentType, "status"> & {
|
|
|
252
253
|
status: T;
|
|
253
254
|
};
|
|
254
255
|
|
|
255
|
-
export type { CommentType as C, Indicator as I, KnownError as K, OverlayErrorCode as O, Position as P, Status as S, User as U, CommentOverlayProps as a, CommentContext as b, CommentOverlayState as c, CommentVisibility as d, ConfirmedStatus as e, ConfirmedComment as f, CommentWithStatus as g, CommentState as h, Config as i };
|
|
256
|
+
export type { CommentType as C, Indicator as I, KnownError as K, OverlayErrorCode as O, Position as P, RealtimeSubscription as R, Status as S, User as U, CommentOverlayProps as a, CommentContext as b, CommentOverlayState as c, CommentVisibility as d, ConfirmedStatus as e, ConfirmedComment as f, CommentWithStatus as g, CommentState as h, Config as i };
|
package/dist/index.cjs
CHANGED
|
@@ -118,6 +118,11 @@ var commentReducer = (state, action) => {
|
|
|
118
118
|
comments: action.comments
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
+
case "APPEND_COMMENT":
|
|
122
|
+
return {
|
|
123
|
+
...state,
|
|
124
|
+
comments: [...state.comments, action.comment]
|
|
125
|
+
};
|
|
121
126
|
case "DELETE":
|
|
122
127
|
return {
|
|
123
128
|
...state,
|
|
@@ -220,8 +225,8 @@ var CommentContextProvider = ({
|
|
|
220
225
|
});
|
|
221
226
|
(0, import_react.useEffect)(() => {
|
|
222
227
|
if (!subscription) return;
|
|
223
|
-
subscription.subscribe((
|
|
224
|
-
dispatch({ type: "
|
|
228
|
+
subscription.subscribe((data) => {
|
|
229
|
+
dispatch({ type: "APPEND_COMMENT", comment: data });
|
|
225
230
|
});
|
|
226
231
|
return () => {
|
|
227
232
|
subscription.unsubscribe();
|
|
@@ -373,7 +378,7 @@ var normalizeRect = (a, b) => {
|
|
|
373
378
|
// src/components/comment-overlay.tsx
|
|
374
379
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
375
380
|
var DRAG_THRESHOLD = 4;
|
|
376
|
-
var CommentOverlay = ({ children }) => {
|
|
381
|
+
var CommentOverlay = ({ children, ...rest }) => {
|
|
377
382
|
const {
|
|
378
383
|
overlayState,
|
|
379
384
|
registerComment,
|
|
@@ -443,7 +448,7 @@ var CommentOverlay = ({ children }) => {
|
|
|
443
448
|
setPreview(null);
|
|
444
449
|
};
|
|
445
450
|
if (overlayState === "inactive") return children;
|
|
446
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-overlay": true, style: { position: "relative" }, children: [
|
|
451
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-overlay": true, style: { position: "relative", ...rest.style }, ...rest, children: [
|
|
447
452
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
448
453
|
"div",
|
|
449
454
|
{
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { ReactNode, ElementType, ButtonHTMLAttributes
|
|
4
|
-
import { C as CommentType, a as CommentOverlayProps, b as CommentContext } from './comment.types-
|
|
3
|
+
import { HTMLProps, ReactNode, ElementType, ButtonHTMLAttributes } from 'react';
|
|
4
|
+
import { C as CommentType, a as CommentOverlayProps$1, b as CommentContext } from './comment.types-CSGuc1D_.cjs';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
interface CommentOverlayProps extends HTMLProps<HTMLDivElement> {
|
|
7
7
|
children: ReactNode;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
|
+
declare const CommentOverlay: ({ children, ...rest }: CommentOverlayProps) => string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
9
10
|
|
|
10
11
|
type CommentRendererProps = {
|
|
11
12
|
Comment: ElementType<{
|
|
@@ -72,7 +73,7 @@ declare const Comment: {
|
|
|
72
73
|
*
|
|
73
74
|
* @param initialComments as the initial comments from the document
|
|
74
75
|
*/
|
|
75
|
-
declare const CommentContextProvider: ({ children, initialComments, initialOverlayState, onConfirm, onResolve, currentUser, subscription, config, onError, }: CommentOverlayProps) => react_jsx_runtime.JSX.Element;
|
|
76
|
+
declare const CommentContextProvider: ({ children, initialComments, initialOverlayState, onConfirm, onResolve, currentUser, subscription, config, onError, }: CommentOverlayProps$1) => react_jsx_runtime.JSX.Element;
|
|
76
77
|
declare const useComments: () => CommentContext;
|
|
77
78
|
|
|
78
79
|
type CommentScope = {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { ReactNode, ElementType, ButtonHTMLAttributes
|
|
4
|
-
import { C as CommentType, a as CommentOverlayProps, b as CommentContext } from './comment.types-
|
|
3
|
+
import { HTMLProps, ReactNode, ElementType, ButtonHTMLAttributes } from 'react';
|
|
4
|
+
import { C as CommentType, a as CommentOverlayProps$1, b as CommentContext } from './comment.types-CSGuc1D_.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
interface CommentOverlayProps extends HTMLProps<HTMLDivElement> {
|
|
7
7
|
children: ReactNode;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
|
+
declare const CommentOverlay: ({ children, ...rest }: CommentOverlayProps) => string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
9
10
|
|
|
10
11
|
type CommentRendererProps = {
|
|
11
12
|
Comment: ElementType<{
|
|
@@ -72,7 +73,7 @@ declare const Comment: {
|
|
|
72
73
|
*
|
|
73
74
|
* @param initialComments as the initial comments from the document
|
|
74
75
|
*/
|
|
75
|
-
declare const CommentContextProvider: ({ children, initialComments, initialOverlayState, onConfirm, onResolve, currentUser, subscription, config, onError, }: CommentOverlayProps) => react_jsx_runtime.JSX.Element;
|
|
76
|
+
declare const CommentContextProvider: ({ children, initialComments, initialOverlayState, onConfirm, onResolve, currentUser, subscription, config, onError, }: CommentOverlayProps$1) => react_jsx_runtime.JSX.Element;
|
|
76
77
|
declare const useComments: () => CommentContext;
|
|
77
78
|
|
|
78
79
|
type CommentScope = {
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// src/components/comment-overlay.tsx
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
useRef,
|
|
4
|
+
useState
|
|
5
|
+
} from "react";
|
|
3
6
|
|
|
4
7
|
// src/contexts/comment-context.tsx
|
|
5
8
|
import { createContext, useContext, useEffect, useReducer } from "react";
|
|
@@ -73,6 +76,11 @@ var commentReducer = (state, action) => {
|
|
|
73
76
|
comments: action.comments
|
|
74
77
|
};
|
|
75
78
|
}
|
|
79
|
+
case "APPEND_COMMENT":
|
|
80
|
+
return {
|
|
81
|
+
...state,
|
|
82
|
+
comments: [...state.comments, action.comment]
|
|
83
|
+
};
|
|
76
84
|
case "DELETE":
|
|
77
85
|
return {
|
|
78
86
|
...state,
|
|
@@ -175,8 +183,8 @@ var CommentContextProvider = ({
|
|
|
175
183
|
});
|
|
176
184
|
useEffect(() => {
|
|
177
185
|
if (!subscription) return;
|
|
178
|
-
subscription.subscribe((
|
|
179
|
-
dispatch({ type: "
|
|
186
|
+
subscription.subscribe((data) => {
|
|
187
|
+
dispatch({ type: "APPEND_COMMENT", comment: data });
|
|
180
188
|
});
|
|
181
189
|
return () => {
|
|
182
190
|
subscription.unsubscribe();
|
|
@@ -328,7 +336,7 @@ var normalizeRect = (a, b) => {
|
|
|
328
336
|
// src/components/comment-overlay.tsx
|
|
329
337
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
330
338
|
var DRAG_THRESHOLD = 4;
|
|
331
|
-
var CommentOverlay = ({ children }) => {
|
|
339
|
+
var CommentOverlay = ({ children, ...rest }) => {
|
|
332
340
|
const {
|
|
333
341
|
overlayState,
|
|
334
342
|
registerComment,
|
|
@@ -398,7 +406,7 @@ var CommentOverlay = ({ children }) => {
|
|
|
398
406
|
setPreview(null);
|
|
399
407
|
};
|
|
400
408
|
if (overlayState === "inactive") return children;
|
|
401
|
-
return /* @__PURE__ */ jsxs("div", { "data-overlay": true, style: { position: "relative" }, children: [
|
|
409
|
+
return /* @__PURE__ */ jsxs("div", { "data-overlay": true, style: { position: "relative", ...rest.style }, ...rest, children: [
|
|
402
410
|
/* @__PURE__ */ jsx2(
|
|
403
411
|
"div",
|
|
404
412
|
{
|
package/dist/types.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CommentType, P as Position, I as Indicator, c as CommentOverlayState, d as CommentVisibility } from './comment.types-
|
|
2
|
-
export { b as CommentContext, a as CommentOverlayProps, h as CommentState, g as CommentWithStatus, i as Config, f as ConfirmedComment, e as ConfirmedStatus, K as KnownError, O as OverlayErrorCode, S as Status, U as User } from './comment.types-
|
|
1
|
+
import { C as CommentType, P as Position, I as Indicator, c as CommentOverlayState, d as CommentVisibility } from './comment.types-CSGuc1D_.cjs';
|
|
2
|
+
export { b as CommentContext, a as CommentOverlayProps, h as CommentState, g as CommentWithStatus, i as Config, f as ConfirmedComment, e as ConfirmedStatus, K as KnownError, O as OverlayErrorCode, R as RealtimeSubscription, S as Status, U as User } from './comment.types-CSGuc1D_.cjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -11,6 +11,9 @@ type CommentAction = {
|
|
|
11
11
|
} | {
|
|
12
12
|
type: "UPDATE_COMMENTS";
|
|
13
13
|
comments: CommentType[];
|
|
14
|
+
} | {
|
|
15
|
+
type: "APPEND_COMMENT";
|
|
16
|
+
comment: CommentType;
|
|
14
17
|
} | {
|
|
15
18
|
type: "EDIT";
|
|
16
19
|
id: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CommentType, P as Position, I as Indicator, c as CommentOverlayState, d as CommentVisibility } from './comment.types-
|
|
2
|
-
export { b as CommentContext, a as CommentOverlayProps, h as CommentState, g as CommentWithStatus, i as Config, f as ConfirmedComment, e as ConfirmedStatus, K as KnownError, O as OverlayErrorCode, S as Status, U as User } from './comment.types-
|
|
1
|
+
import { C as CommentType, P as Position, I as Indicator, c as CommentOverlayState, d as CommentVisibility } from './comment.types-CSGuc1D_.js';
|
|
2
|
+
export { b as CommentContext, a as CommentOverlayProps, h as CommentState, g as CommentWithStatus, i as Config, f as ConfirmedComment, e as ConfirmedStatus, K as KnownError, O as OverlayErrorCode, R as RealtimeSubscription, S as Status, U as User } from './comment.types-CSGuc1D_.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -11,6 +11,9 @@ type CommentAction = {
|
|
|
11
11
|
} | {
|
|
12
12
|
type: "UPDATE_COMMENTS";
|
|
13
13
|
comments: CommentType[];
|
|
14
|
+
} | {
|
|
15
|
+
type: "APPEND_COMMENT";
|
|
16
|
+
comment: CommentType;
|
|
14
17
|
} | {
|
|
15
18
|
type: "EDIT";
|
|
16
19
|
id: string;
|