@kendew-agency/react-feedback-layer 0.3.1 → 0.3.2

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
@@ -267,8 +267,9 @@ Container for a single comment with positioning and active state management.
267
267
  ```tsx
268
268
  interface CommentRootProps extends HTMLProps<HTMLDivElement> {
269
269
  comment: CommentType;
270
- children?: ReactNode;
271
270
  defaultDraft?: string; // Initial draft content
271
+ withPosition?: boolean; // Apply absolute positioning from comment.position (default: true)
272
+ children?: ReactNode;
272
273
  }
273
274
  ```
274
275
 
@@ -280,6 +281,16 @@ interface CommentRootProps extends HTMLProps<HTMLDivElement> {
280
281
  </Comment.Root>
281
282
  ```
282
283
 
284
+ **Rendering without positioning (e.g. in a list):**
285
+
286
+ Set `withPosition={false}` to skip the `position`, `top` and `left` styles derived from `comment.position`. Styles passed via `style` are still applied.
287
+
288
+ ```tsx
289
+ <Comment.Root comment={comment} withPosition={false}>
290
+ {/* Sub-components */}
291
+ </Comment.Root>
292
+ ```
293
+
283
294
  ##### `Comment.Indicator`
284
295
 
285
296
  Visual indicator showing the area a comment refers to (when created via drag).
@@ -1339,6 +1350,9 @@ MIT © [Kendew Agency](https://github.com/Kendew-Agency)
1339
1350
 
1340
1351
  A list if breaking changes that could impact the way you configured the package
1341
1352
 
1353
+ ### 0.3.2
1354
+ - Added `withPosition` prop to `Comment.Root`. It defaults to `true`, so existing behavior is unchanged. Set it to `false` to skip the absolute positioning styles (`position`, `top`, `left`), for example when rendering comments in a list.
1355
+
1342
1356
  ### 0.3.1
1343
1357
  - Added `events` to the `useComments()` hook. You can now subscribe to comment lifecycle events such as `onFocusChange`, `onCommentsConfirmed`, `onCommentsResolved`, `onCommentDeleted`, and `onCommentRegistered`. Each event method returns an unsubscribe function for easy cleanup.
1344
1358
  - New types exported: `CommentEvents`, `CommentEventMap`, `Unsubscribe`.
package/dist/index.cjs CHANGED
@@ -711,13 +711,19 @@ function useCommentScope() {
711
711
  var import_jsx_runtime5 = require("react/jsx-runtime");
712
712
  var CommentRoot = ({
713
713
  comment,
714
- children,
715
714
  defaultDraft,
715
+ withPosition = true,
716
+ children,
716
717
  ...rest
717
718
  }) => {
718
719
  const { getActiveComment } = useComments();
719
720
  const isActive = getActiveComment()?.id === comment.id;
720
721
  const [draft, setDraft] = (0, import_react4.useState)(defaultDraft ?? comment.content ?? "");
722
+ const positionStyles = {
723
+ position: "absolute",
724
+ top: comment.position.y,
725
+ left: comment.position.x
726
+ };
721
727
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
722
728
  CommentScopeContext.Provider,
723
729
  {
@@ -729,10 +735,8 @@ var CommentRoot = ({
729
735
  "data-comment": comment.id,
730
736
  "data-active": isActive,
731
737
  style: {
732
- top: comment.position.y,
733
- left: comment.position.x,
734
- position: "absolute",
735
738
  zIndex: isActive ? 40 : 30,
739
+ ...withPosition ? positionStyles : {},
736
740
  ...rest.style ?? {}
737
741
  },
738
742
  children
@@ -846,18 +850,60 @@ var CommentResolve = ({ asChild, ...rest }) => {
846
850
  );
847
851
  };
848
852
  var Comment = {
853
+ /**
854
+ * The root component for a comment, must be used to wrap all other comment components.
855
+ *
856
+ * @param comment as the current comment from the comments array
857
+ * @param defaultDraft as the optional initial value for the comment edit state
858
+ * @param withPosition as whether to inject positioning styles from the comment's position. Disable if you want to display the comment in a list. Defaults to true
859
+ */
849
860
  // biome-ignore lint/style/useNamingConvention: Modular export
850
861
  Root: CommentRoot,
862
+ /**
863
+ * The comment indicator
864
+ *
865
+ * @description Shows a dashed line that indicates a section this comment relates to
866
+ */
851
867
  // biome-ignore lint/style/useNamingConvention: Modular export
852
868
  Indicator: CommentIndicator,
869
+ /**
870
+ * The comment's static safed content
871
+ *
872
+ * @description Displays the comment's content as a `<p>` tag
873
+ * @param asChild as whether to use the child as the base element instead of the default `<p>` tag. This allows for more flexibility
874
+ */
853
875
  // biome-ignore lint/style/useNamingConvention: Modular export
854
876
  Content: CommentContent,
877
+ /**
878
+ * The comment's editable content
879
+ *
880
+ * @description A textarea to edit the comment's content
881
+ * @param asChild as whether to use the child as the base element instead of the default `<textarea>` tag. This allows for more flexibility
882
+ */
855
883
  // biome-ignore lint/style/useNamingConvention: Modular export
856
884
  Edit: CommentEdit,
885
+ /**
886
+ * Confirms the changes made to a comment
887
+ *
888
+ * @description Updates the comment's content with the current draft
889
+ * @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
890
+ */
857
891
  // biome-ignore lint/style/useNamingConvention: Modular export
858
892
  Confirm: CommentConfirm,
893
+ /**
894
+ * Deletes a comment
895
+ *
896
+ * @description Removes the comment from the comment list
897
+ * @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
898
+ */
859
899
  // biome-ignore lint/style/useNamingConvention: Modular export
860
900
  Delete: CommentDelete,
901
+ /**
902
+ * Toggles the resolving status of a comment
903
+ *
904
+ * @description Toggles the comment's resolving status, which will show a different UI state
905
+ * @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
906
+ */
861
907
  // biome-ignore lint/style/useNamingConvention: Modular export
862
908
  Resolve: CommentResolve
863
909
  };
package/dist/index.d.cts CHANGED
@@ -23,9 +23,26 @@ type CommentRendererProps = {
23
23
  }>;
24
24
  };
25
25
  /**
26
+ * Comment rendering component
27
+ * @remarks
28
+ * This component is used to render all comments based on their state.
29
+ * This component is optional and the samen could be built using the `useComments()` hook
26
30
  *
27
- * @param
28
- * @returns
31
+ * @param Comment - Component for all open comments
32
+ * @param DraftComment - Component for all draft comments
33
+ * @param ResolvingComment - Component for all resolving comments
34
+ * @param ResolvedComment - Component for all resolved comments
35
+ * @returns mapped arrays of all comment types
36
+ * @description This component is used to render all comments based on their type
37
+ * @example
38
+ * ```tsx
39
+ * <CommentRenderer
40
+ * Comment={MyCommentComponent}
41
+ * DraftComment={MyDraftCommentComponent}
42
+ * ResolvingComment={MyResolvingCommentComponent}
43
+ * ResolvedComment={MyResolvedCommentComponent}
44
+ * />
45
+ * ```
29
46
  */
30
47
  declare const CommentRenderer: ({ Comment, DraftComment, ResolvingComment, ResolvedComment, }: CommentRendererProps) => react_jsx_runtime.JSX.Element | null;
31
48
 
@@ -38,8 +55,9 @@ declare const ResolveComments: ({ asChild, ...rest }: CommentButtonProps) => rea
38
55
 
39
56
  interface CommentRootProps extends HTMLProps<HTMLDivElement> {
40
57
  comment: CommentType;
41
- children?: ReactNode;
42
58
  defaultDraft?: string;
59
+ withPosition?: boolean;
60
+ children?: ReactNode;
43
61
  }
44
62
  interface CommentIndicatorProps extends HTMLProps<HTMLDivElement> {
45
63
  }
@@ -59,12 +77,54 @@ interface CommentResolveProps extends ButtonHTMLAttributes<HTMLButtonElement> {
59
77
  asChild?: boolean;
60
78
  }
61
79
  declare const Comment: {
62
- Root: ({ comment, children, defaultDraft, ...rest }: CommentRootProps) => react_jsx_runtime.JSX.Element;
80
+ /**
81
+ * The root component for a comment, must be used to wrap all other comment components.
82
+ *
83
+ * @param comment as the current comment from the comments array
84
+ * @param defaultDraft as the optional initial value for the comment edit state
85
+ * @param withPosition as whether to inject positioning styles from the comment's position. Disable if you want to display the comment in a list. Defaults to true
86
+ */
87
+ Root: ({ comment, defaultDraft, withPosition, children, ...rest }: CommentRootProps) => react_jsx_runtime.JSX.Element;
88
+ /**
89
+ * The comment indicator
90
+ *
91
+ * @description Shows a dashed line that indicates a section this comment relates to
92
+ */
63
93
  Indicator: ({ ...rest }: CommentIndicatorProps) => react_jsx_runtime.JSX.Element | null;
94
+ /**
95
+ * The comment's static safed content
96
+ *
97
+ * @description Displays the comment's content as a `<p>` tag
98
+ * @param asChild as whether to use the child as the base element instead of the default `<p>` tag. This allows for more flexibility
99
+ */
64
100
  Content: ({ asChild, ...rest }: CommentContentProps) => react_jsx_runtime.JSX.Element;
101
+ /**
102
+ * The comment's editable content
103
+ *
104
+ * @description A textarea to edit the comment's content
105
+ * @param asChild as whether to use the child as the base element instead of the default `<textarea>` tag. This allows for more flexibility
106
+ */
65
107
  Edit: ({ asChild, ...rest }: CommentEditProps) => react_jsx_runtime.JSX.Element;
108
+ /**
109
+ * Confirms the changes made to a comment
110
+ *
111
+ * @description Updates the comment's content with the current draft
112
+ * @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
113
+ */
66
114
  Confirm: ({ asChild, ...rest }: CommentConfirmProps) => react_jsx_runtime.JSX.Element;
115
+ /**
116
+ * Deletes a comment
117
+ *
118
+ * @description Removes the comment from the comment list
119
+ * @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
120
+ */
67
121
  Delete: ({ asChild, ...rest }: CommentDeleteProps) => react_jsx_runtime.JSX.Element;
122
+ /**
123
+ * Toggles the resolving status of a comment
124
+ *
125
+ * @description Toggles the comment's resolving status, which will show a different UI state
126
+ * @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
127
+ */
68
128
  Resolve: ({ asChild, ...rest }: CommentResolveProps) => react_jsx_runtime.JSX.Element | null;
69
129
  };
70
130
 
package/dist/index.d.ts CHANGED
@@ -23,9 +23,26 @@ type CommentRendererProps = {
23
23
  }>;
24
24
  };
25
25
  /**
26
+ * Comment rendering component
27
+ * @remarks
28
+ * This component is used to render all comments based on their state.
29
+ * This component is optional and the samen could be built using the `useComments()` hook
26
30
  *
27
- * @param
28
- * @returns
31
+ * @param Comment - Component for all open comments
32
+ * @param DraftComment - Component for all draft comments
33
+ * @param ResolvingComment - Component for all resolving comments
34
+ * @param ResolvedComment - Component for all resolved comments
35
+ * @returns mapped arrays of all comment types
36
+ * @description This component is used to render all comments based on their type
37
+ * @example
38
+ * ```tsx
39
+ * <CommentRenderer
40
+ * Comment={MyCommentComponent}
41
+ * DraftComment={MyDraftCommentComponent}
42
+ * ResolvingComment={MyResolvingCommentComponent}
43
+ * ResolvedComment={MyResolvedCommentComponent}
44
+ * />
45
+ * ```
29
46
  */
30
47
  declare const CommentRenderer: ({ Comment, DraftComment, ResolvingComment, ResolvedComment, }: CommentRendererProps) => react_jsx_runtime.JSX.Element | null;
31
48
 
@@ -38,8 +55,9 @@ declare const ResolveComments: ({ asChild, ...rest }: CommentButtonProps) => rea
38
55
 
39
56
  interface CommentRootProps extends HTMLProps<HTMLDivElement> {
40
57
  comment: CommentType;
41
- children?: ReactNode;
42
58
  defaultDraft?: string;
59
+ withPosition?: boolean;
60
+ children?: ReactNode;
43
61
  }
44
62
  interface CommentIndicatorProps extends HTMLProps<HTMLDivElement> {
45
63
  }
@@ -59,12 +77,54 @@ interface CommentResolveProps extends ButtonHTMLAttributes<HTMLButtonElement> {
59
77
  asChild?: boolean;
60
78
  }
61
79
  declare const Comment: {
62
- Root: ({ comment, children, defaultDraft, ...rest }: CommentRootProps) => react_jsx_runtime.JSX.Element;
80
+ /**
81
+ * The root component for a comment, must be used to wrap all other comment components.
82
+ *
83
+ * @param comment as the current comment from the comments array
84
+ * @param defaultDraft as the optional initial value for the comment edit state
85
+ * @param withPosition as whether to inject positioning styles from the comment's position. Disable if you want to display the comment in a list. Defaults to true
86
+ */
87
+ Root: ({ comment, defaultDraft, withPosition, children, ...rest }: CommentRootProps) => react_jsx_runtime.JSX.Element;
88
+ /**
89
+ * The comment indicator
90
+ *
91
+ * @description Shows a dashed line that indicates a section this comment relates to
92
+ */
63
93
  Indicator: ({ ...rest }: CommentIndicatorProps) => react_jsx_runtime.JSX.Element | null;
94
+ /**
95
+ * The comment's static safed content
96
+ *
97
+ * @description Displays the comment's content as a `<p>` tag
98
+ * @param asChild as whether to use the child as the base element instead of the default `<p>` tag. This allows for more flexibility
99
+ */
64
100
  Content: ({ asChild, ...rest }: CommentContentProps) => react_jsx_runtime.JSX.Element;
101
+ /**
102
+ * The comment's editable content
103
+ *
104
+ * @description A textarea to edit the comment's content
105
+ * @param asChild as whether to use the child as the base element instead of the default `<textarea>` tag. This allows for more flexibility
106
+ */
65
107
  Edit: ({ asChild, ...rest }: CommentEditProps) => react_jsx_runtime.JSX.Element;
108
+ /**
109
+ * Confirms the changes made to a comment
110
+ *
111
+ * @description Updates the comment's content with the current draft
112
+ * @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
113
+ */
66
114
  Confirm: ({ asChild, ...rest }: CommentConfirmProps) => react_jsx_runtime.JSX.Element;
115
+ /**
116
+ * Deletes a comment
117
+ *
118
+ * @description Removes the comment from the comment list
119
+ * @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
120
+ */
67
121
  Delete: ({ asChild, ...rest }: CommentDeleteProps) => react_jsx_runtime.JSX.Element;
122
+ /**
123
+ * Toggles the resolving status of a comment
124
+ *
125
+ * @description Toggles the comment's resolving status, which will show a different UI state
126
+ * @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
127
+ */
68
128
  Resolve: ({ asChild, ...rest }: CommentResolveProps) => react_jsx_runtime.JSX.Element | null;
69
129
  };
70
130
 
package/dist/index.js CHANGED
@@ -677,13 +677,19 @@ function useCommentScope() {
677
677
  import { jsx as jsx5 } from "react/jsx-runtime";
678
678
  var CommentRoot = ({
679
679
  comment,
680
- children,
681
680
  defaultDraft,
681
+ withPosition = true,
682
+ children,
682
683
  ...rest
683
684
  }) => {
684
685
  const { getActiveComment } = useComments();
685
686
  const isActive = getActiveComment()?.id === comment.id;
686
687
  const [draft, setDraft] = useState2(defaultDraft ?? comment.content ?? "");
688
+ const positionStyles = {
689
+ position: "absolute",
690
+ top: comment.position.y,
691
+ left: comment.position.x
692
+ };
687
693
  return /* @__PURE__ */ jsx5(
688
694
  CommentScopeContext.Provider,
689
695
  {
@@ -695,10 +701,8 @@ var CommentRoot = ({
695
701
  "data-comment": comment.id,
696
702
  "data-active": isActive,
697
703
  style: {
698
- top: comment.position.y,
699
- left: comment.position.x,
700
- position: "absolute",
701
704
  zIndex: isActive ? 40 : 30,
705
+ ...withPosition ? positionStyles : {},
702
706
  ...rest.style ?? {}
703
707
  },
704
708
  children
@@ -812,18 +816,60 @@ var CommentResolve = ({ asChild, ...rest }) => {
812
816
  );
813
817
  };
814
818
  var Comment = {
819
+ /**
820
+ * The root component for a comment, must be used to wrap all other comment components.
821
+ *
822
+ * @param comment as the current comment from the comments array
823
+ * @param defaultDraft as the optional initial value for the comment edit state
824
+ * @param withPosition as whether to inject positioning styles from the comment's position. Disable if you want to display the comment in a list. Defaults to true
825
+ */
815
826
  // biome-ignore lint/style/useNamingConvention: Modular export
816
827
  Root: CommentRoot,
828
+ /**
829
+ * The comment indicator
830
+ *
831
+ * @description Shows a dashed line that indicates a section this comment relates to
832
+ */
817
833
  // biome-ignore lint/style/useNamingConvention: Modular export
818
834
  Indicator: CommentIndicator,
835
+ /**
836
+ * The comment's static safed content
837
+ *
838
+ * @description Displays the comment's content as a `<p>` tag
839
+ * @param asChild as whether to use the child as the base element instead of the default `<p>` tag. This allows for more flexibility
840
+ */
819
841
  // biome-ignore lint/style/useNamingConvention: Modular export
820
842
  Content: CommentContent,
843
+ /**
844
+ * The comment's editable content
845
+ *
846
+ * @description A textarea to edit the comment's content
847
+ * @param asChild as whether to use the child as the base element instead of the default `<textarea>` tag. This allows for more flexibility
848
+ */
821
849
  // biome-ignore lint/style/useNamingConvention: Modular export
822
850
  Edit: CommentEdit,
851
+ /**
852
+ * Confirms the changes made to a comment
853
+ *
854
+ * @description Updates the comment's content with the current draft
855
+ * @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
856
+ */
823
857
  // biome-ignore lint/style/useNamingConvention: Modular export
824
858
  Confirm: CommentConfirm,
859
+ /**
860
+ * Deletes a comment
861
+ *
862
+ * @description Removes the comment from the comment list
863
+ * @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
864
+ */
825
865
  // biome-ignore lint/style/useNamingConvention: Modular export
826
866
  Delete: CommentDelete,
867
+ /**
868
+ * Toggles the resolving status of a comment
869
+ *
870
+ * @description Toggles the comment's resolving status, which will show a different UI state
871
+ * @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
872
+ */
827
873
  // biome-ignore lint/style/useNamingConvention: Modular export
828
874
  Resolve: CommentResolve
829
875
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kendew-agency/react-feedback-layer",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Drop-in React feedback layer for collecting contextual user feedback",
5
5
  "license": "MIT",
6
6
  "author": "Kendew Agency",