@kendew-agency/react-feedback-layer 0.1.2 → 0.2.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/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?: Suscription;
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
- type Suscription = {
119
- subscribe: (update: unknown) => void;
120
- unsubscribe: () => void;
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?: Suscription;
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
- type Suscription = {
119
- subscribe: (update: unknown) => void;
120
- unsubscribe: () => void;
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((update) => {
224
- dispatch({ type: "UPDATE_COMMENTS", comments: update });
228
+ subscription.subscribe((data) => {
229
+ dispatch({ type: "APPEND_COMMENT", comment: data });
225
230
  });
226
231
  return () => {
227
232
  subscription.unsubscribe();
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { ReactNode, ElementType, ButtonHTMLAttributes, HTMLProps } from 'react';
4
- import { C as CommentType, a as CommentOverlayProps, b as CommentContext } from './comment.types-CfEOrU1d.cjs';
4
+ import { C as CommentType, a as CommentOverlayProps, b as CommentContext } from './comment.types-CSGuc1D_.cjs';
5
5
 
6
6
  declare const CommentOverlay: ({ children }: {
7
7
  children: ReactNode;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { ReactNode, ElementType, ButtonHTMLAttributes, HTMLProps } from 'react';
4
- import { C as CommentType, a as CommentOverlayProps, b as CommentContext } from './comment.types-CfEOrU1d.js';
4
+ import { C as CommentType, a as CommentOverlayProps, b as CommentContext } from './comment.types-CSGuc1D_.js';
5
5
 
6
6
  declare const CommentOverlay: ({ children }: {
7
7
  children: ReactNode;
package/dist/index.js CHANGED
@@ -73,6 +73,11 @@ var commentReducer = (state, action) => {
73
73
  comments: action.comments
74
74
  };
75
75
  }
76
+ case "APPEND_COMMENT":
77
+ return {
78
+ ...state,
79
+ comments: [...state.comments, action.comment]
80
+ };
76
81
  case "DELETE":
77
82
  return {
78
83
  ...state,
@@ -175,8 +180,8 @@ var CommentContextProvider = ({
175
180
  });
176
181
  useEffect(() => {
177
182
  if (!subscription) return;
178
- subscription.subscribe((update) => {
179
- dispatch({ type: "UPDATE_COMMENTS", comments: update });
183
+ subscription.subscribe((data) => {
184
+ dispatch({ type: "APPEND_COMMENT", comment: data });
180
185
  });
181
186
  return () => {
182
187
  subscription.unsubscribe();
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-CfEOrU1d.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, S as Status, U as User } from './comment.types-CfEOrU1d.cjs';
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-CfEOrU1d.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, S as Status, U as User } from './comment.types-CfEOrU1d.js';
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kendew-agency/react-feedback-layer",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Drop-in React feedback layer for collecting contextual user feedback",
5
5
  "license": "MIT",
6
6
  "author": "Kendew Agency",