@kendew-agency/react-feedback-layer 0.3.2 → 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 +772 -451
- package/dist/index.cjs +981 -224
- package/dist/index.d.cts +69 -13
- package/dist/index.d.ts +69 -13
- package/dist/index.js +981 -220
- package/dist/types.d.cts +481 -7
- package/dist/types.d.ts +481 -7
- package/package.json +9 -3
- package/dist/comment.types-C0m3sQ_Q.d.cts +0 -322
- package/dist/comment.types-C0m3sQ_Q.d.ts +0 -322
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 { HTMLProps, ReactNode, ElementType, ButtonHTMLAttributes } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { CommentType, CommentState, CommentAction, CommentOverlayProps as CommentOverlayProps$1, CommentContext, User, InitialFeedbackSession, CreateSessionInput, FeedbackSession, SessionType, KnownError, ActiveFeedbackSession, SessionOperationState, SessionEvents } from './types.cjs';
|
|
5
5
|
|
|
6
6
|
interface CommentOverlayProps extends HTMLProps<HTMLDivElement> {
|
|
7
7
|
children: ReactNode;
|
|
@@ -15,9 +15,6 @@ type CommentRendererProps = {
|
|
|
15
15
|
DraftComment: ElementType<{
|
|
16
16
|
comment: CommentType;
|
|
17
17
|
}>;
|
|
18
|
-
ResolvingComment: ElementType<{
|
|
19
|
-
comment: CommentType;
|
|
20
|
-
}>;
|
|
21
18
|
ResolvedComment: ElementType<{
|
|
22
19
|
comment: CommentType;
|
|
23
20
|
}>;
|
|
@@ -30,7 +27,6 @@ type CommentRendererProps = {
|
|
|
30
27
|
*
|
|
31
28
|
* @param Comment - Component for all open comments
|
|
32
29
|
* @param DraftComment - Component for all draft comments
|
|
33
|
-
* @param ResolvingComment - Component for all resolving comments
|
|
34
30
|
* @param ResolvedComment - Component for all resolved comments
|
|
35
31
|
* @returns mapped arrays of all comment types
|
|
36
32
|
* @description This component is used to render all comments based on their type
|
|
@@ -39,19 +35,16 @@ type CommentRendererProps = {
|
|
|
39
35
|
* <CommentRenderer
|
|
40
36
|
* Comment={MyCommentComponent}
|
|
41
37
|
* DraftComment={MyDraftCommentComponent}
|
|
42
|
-
* ResolvingComment={MyResolvingCommentComponent}
|
|
43
38
|
* ResolvedComment={MyResolvedCommentComponent}
|
|
44
39
|
* />
|
|
45
40
|
* ```
|
|
46
41
|
*/
|
|
47
|
-
declare const CommentRenderer: ({ Comment, DraftComment,
|
|
42
|
+
declare const CommentRenderer: ({ Comment, DraftComment, ResolvedComment, }: CommentRendererProps) => react_jsx_runtime.JSX.Element | null;
|
|
48
43
|
|
|
49
44
|
interface CommentButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
50
45
|
asChild?: boolean;
|
|
51
46
|
}
|
|
52
47
|
declare const ToggleOverlayButton: ({ asChild, ...rest }: CommentButtonProps) => react_jsx_runtime.JSX.Element;
|
|
53
|
-
declare const ConfirmComments: ({ asChild, ...rest }: CommentButtonProps) => react_jsx_runtime.JSX.Element;
|
|
54
|
-
declare const ResolveComments: ({ asChild, ...rest }: CommentButtonProps) => react_jsx_runtime.JSX.Element;
|
|
55
48
|
|
|
56
49
|
interface CommentRootProps extends HTMLProps<HTMLDivElement> {
|
|
57
50
|
comment: CommentType;
|
|
@@ -76,6 +69,9 @@ interface CommentDeleteProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
76
69
|
interface CommentResolveProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
77
70
|
asChild?: boolean;
|
|
78
71
|
}
|
|
72
|
+
interface CommentReopenProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
73
|
+
asChild?: boolean;
|
|
74
|
+
}
|
|
79
75
|
declare const Comment: {
|
|
80
76
|
/**
|
|
81
77
|
* The root component for a comment, must be used to wrap all other comment components.
|
|
@@ -120,20 +116,28 @@ declare const Comment: {
|
|
|
120
116
|
*/
|
|
121
117
|
Delete: ({ asChild, ...rest }: CommentDeleteProps) => react_jsx_runtime.JSX.Element;
|
|
122
118
|
/**
|
|
123
|
-
*
|
|
119
|
+
* Resolves a comment
|
|
124
120
|
*
|
|
125
|
-
* @description
|
|
121
|
+
* @description Calls `resolveComment` for this comment. Renders nothing (and logs an error) for draft and resolved comments
|
|
126
122
|
* @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
|
|
127
123
|
*/
|
|
128
124
|
Resolve: ({ asChild, ...rest }: CommentResolveProps) => react_jsx_runtime.JSX.Element | null;
|
|
125
|
+
/**
|
|
126
|
+
* Reopens a resolved comment
|
|
127
|
+
*
|
|
128
|
+
* @description Calls `reopenComment` for this comment. Renders nothing (and logs an error) for draft and published comments
|
|
129
|
+
* @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
|
|
130
|
+
*/
|
|
131
|
+
Reopen: ({ asChild, ...rest }: CommentReopenProps) => react_jsx_runtime.JSX.Element | null;
|
|
129
132
|
};
|
|
130
133
|
|
|
134
|
+
declare const commentReducer: (state: CommentState, action: CommentAction) => CommentState;
|
|
131
135
|
/**
|
|
132
136
|
* Comment context provider to provide the comments to the children components
|
|
133
137
|
*
|
|
134
138
|
* @param initialComments as the initial comments from the document
|
|
135
139
|
*/
|
|
136
|
-
declare const CommentContextProvider: ({ children, initialComments, initialOverlayState,
|
|
140
|
+
declare const CommentContextProvider: ({ children, initialComments, initialOverlayState, currentUser: currentUserProp, subscription, config, projectId, locationId: locationIdProp, onError, onAdd, onEdit, onDelete, onResolve, onReopen, }: CommentOverlayProps$1) => react_jsx_runtime.JSX.Element;
|
|
137
141
|
declare const useComments: () => CommentContext;
|
|
138
142
|
|
|
139
143
|
type CommentScope = {
|
|
@@ -145,4 +149,56 @@ type CommentScope = {
|
|
|
145
149
|
declare const CommentScopeContext: React.Context<CommentScope | null>;
|
|
146
150
|
declare function useCommentScope(): CommentScope;
|
|
147
151
|
|
|
148
|
-
|
|
152
|
+
interface SessionButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
153
|
+
asChild?: boolean;
|
|
154
|
+
}
|
|
155
|
+
interface CreateSessionProps extends SessionButtonProps {
|
|
156
|
+
/** The user creating the session */
|
|
157
|
+
user: User;
|
|
158
|
+
}
|
|
159
|
+
declare const CreateSession: ({ asChild, user, ...rest }: CreateSessionProps) => react_jsx_runtime.JSX.Element;
|
|
160
|
+
declare const ConfirmSession: ({ asChild, ...rest }: SessionButtonProps) => react_jsx_runtime.JSX.Element;
|
|
161
|
+
declare const StartResolving: ({ asChild, ...rest }: SessionButtonProps) => react_jsx_runtime.JSX.Element;
|
|
162
|
+
declare const ResolveSession: ({ asChild, ...rest }: SessionButtonProps) => react_jsx_runtime.JSX.Element;
|
|
163
|
+
|
|
164
|
+
type FeedbackSessionProviderProps = {
|
|
165
|
+
children: ReactNode;
|
|
166
|
+
/** Resume a session, for example after a reload */
|
|
167
|
+
initialSession?: InitialFeedbackSession;
|
|
168
|
+
/** Default project id sent to onCreateSession */
|
|
169
|
+
projectId?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Whether the current user may start the resolution of a session, resolve a
|
|
172
|
+
* session, and resolve and reopen comments.
|
|
173
|
+
* @default false
|
|
174
|
+
*/
|
|
175
|
+
canResolveSession?: boolean;
|
|
176
|
+
onCreateSession?: (input: CreateSessionInput) => Promise<FeedbackSession>;
|
|
177
|
+
onConfirmSession?: (sessionId: string, type: SessionType) => Promise<void>;
|
|
178
|
+
onStartResolving?: (sessionId: string) => Promise<void>;
|
|
179
|
+
onResolveSession?: (sessionId: string) => Promise<void>;
|
|
180
|
+
onError?: (error: KnownError) => void;
|
|
181
|
+
};
|
|
182
|
+
type ActionResult = {
|
|
183
|
+
error: KnownError | null;
|
|
184
|
+
};
|
|
185
|
+
type FeedbackSessionContextType = {
|
|
186
|
+
session: ActiveFeedbackSession | null;
|
|
187
|
+
sessionState: SessionOperationState;
|
|
188
|
+
/** Mirrors the canResolveSession prop */
|
|
189
|
+
canResolve: boolean;
|
|
190
|
+
createSession: (options: {
|
|
191
|
+
/** The user creating the session. Required, a missing user is refused */
|
|
192
|
+
user: User;
|
|
193
|
+
type?: SessionType;
|
|
194
|
+
projectId?: string;
|
|
195
|
+
}) => Promise<ActionResult>;
|
|
196
|
+
confirmSession: () => Promise<ActionResult>;
|
|
197
|
+
startResolving: () => Promise<ActionResult>;
|
|
198
|
+
resolveSession: () => Promise<ActionResult>;
|
|
199
|
+
events: SessionEvents;
|
|
200
|
+
};
|
|
201
|
+
declare const FeedbackSessionProvider: ({ children, initialSession, projectId, canResolveSession, onCreateSession, onConfirmSession, onStartResolving, onResolveSession, onError, }: FeedbackSessionProviderProps) => react_jsx_runtime.JSX.Element;
|
|
202
|
+
declare const useFeedbackSession: () => FeedbackSessionContextType;
|
|
203
|
+
|
|
204
|
+
export { Comment, CommentContextProvider, CommentOverlay, CommentRenderer, CommentScopeContext, ConfirmSession, CreateSession, type FeedbackSessionContextType, FeedbackSessionProvider, type FeedbackSessionProviderProps, ResolveSession, StartResolving, ToggleOverlayButton, commentReducer, useCommentScope, useComments, useFeedbackSession };
|
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 { HTMLProps, ReactNode, ElementType, ButtonHTMLAttributes } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { CommentType, CommentState, CommentAction, CommentOverlayProps as CommentOverlayProps$1, CommentContext, User, InitialFeedbackSession, CreateSessionInput, FeedbackSession, SessionType, KnownError, ActiveFeedbackSession, SessionOperationState, SessionEvents } from './types.js';
|
|
5
5
|
|
|
6
6
|
interface CommentOverlayProps extends HTMLProps<HTMLDivElement> {
|
|
7
7
|
children: ReactNode;
|
|
@@ -15,9 +15,6 @@ type CommentRendererProps = {
|
|
|
15
15
|
DraftComment: ElementType<{
|
|
16
16
|
comment: CommentType;
|
|
17
17
|
}>;
|
|
18
|
-
ResolvingComment: ElementType<{
|
|
19
|
-
comment: CommentType;
|
|
20
|
-
}>;
|
|
21
18
|
ResolvedComment: ElementType<{
|
|
22
19
|
comment: CommentType;
|
|
23
20
|
}>;
|
|
@@ -30,7 +27,6 @@ type CommentRendererProps = {
|
|
|
30
27
|
*
|
|
31
28
|
* @param Comment - Component for all open comments
|
|
32
29
|
* @param DraftComment - Component for all draft comments
|
|
33
|
-
* @param ResolvingComment - Component for all resolving comments
|
|
34
30
|
* @param ResolvedComment - Component for all resolved comments
|
|
35
31
|
* @returns mapped arrays of all comment types
|
|
36
32
|
* @description This component is used to render all comments based on their type
|
|
@@ -39,19 +35,16 @@ type CommentRendererProps = {
|
|
|
39
35
|
* <CommentRenderer
|
|
40
36
|
* Comment={MyCommentComponent}
|
|
41
37
|
* DraftComment={MyDraftCommentComponent}
|
|
42
|
-
* ResolvingComment={MyResolvingCommentComponent}
|
|
43
38
|
* ResolvedComment={MyResolvedCommentComponent}
|
|
44
39
|
* />
|
|
45
40
|
* ```
|
|
46
41
|
*/
|
|
47
|
-
declare const CommentRenderer: ({ Comment, DraftComment,
|
|
42
|
+
declare const CommentRenderer: ({ Comment, DraftComment, ResolvedComment, }: CommentRendererProps) => react_jsx_runtime.JSX.Element | null;
|
|
48
43
|
|
|
49
44
|
interface CommentButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
50
45
|
asChild?: boolean;
|
|
51
46
|
}
|
|
52
47
|
declare const ToggleOverlayButton: ({ asChild, ...rest }: CommentButtonProps) => react_jsx_runtime.JSX.Element;
|
|
53
|
-
declare const ConfirmComments: ({ asChild, ...rest }: CommentButtonProps) => react_jsx_runtime.JSX.Element;
|
|
54
|
-
declare const ResolveComments: ({ asChild, ...rest }: CommentButtonProps) => react_jsx_runtime.JSX.Element;
|
|
55
48
|
|
|
56
49
|
interface CommentRootProps extends HTMLProps<HTMLDivElement> {
|
|
57
50
|
comment: CommentType;
|
|
@@ -76,6 +69,9 @@ interface CommentDeleteProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
76
69
|
interface CommentResolveProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
77
70
|
asChild?: boolean;
|
|
78
71
|
}
|
|
72
|
+
interface CommentReopenProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
73
|
+
asChild?: boolean;
|
|
74
|
+
}
|
|
79
75
|
declare const Comment: {
|
|
80
76
|
/**
|
|
81
77
|
* The root component for a comment, must be used to wrap all other comment components.
|
|
@@ -120,20 +116,28 @@ declare const Comment: {
|
|
|
120
116
|
*/
|
|
121
117
|
Delete: ({ asChild, ...rest }: CommentDeleteProps) => react_jsx_runtime.JSX.Element;
|
|
122
118
|
/**
|
|
123
|
-
*
|
|
119
|
+
* Resolves a comment
|
|
124
120
|
*
|
|
125
|
-
* @description
|
|
121
|
+
* @description Calls `resolveComment` for this comment. Renders nothing (and logs an error) for draft and resolved comments
|
|
126
122
|
* @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
|
|
127
123
|
*/
|
|
128
124
|
Resolve: ({ asChild, ...rest }: CommentResolveProps) => react_jsx_runtime.JSX.Element | null;
|
|
125
|
+
/**
|
|
126
|
+
* Reopens a resolved comment
|
|
127
|
+
*
|
|
128
|
+
* @description Calls `reopenComment` for this comment. Renders nothing (and logs an error) for draft and published comments
|
|
129
|
+
* @param asChild as whether to use the child as the base element instead of the default `<button>` tag. This allows for more flexibility
|
|
130
|
+
*/
|
|
131
|
+
Reopen: ({ asChild, ...rest }: CommentReopenProps) => react_jsx_runtime.JSX.Element | null;
|
|
129
132
|
};
|
|
130
133
|
|
|
134
|
+
declare const commentReducer: (state: CommentState, action: CommentAction) => CommentState;
|
|
131
135
|
/**
|
|
132
136
|
* Comment context provider to provide the comments to the children components
|
|
133
137
|
*
|
|
134
138
|
* @param initialComments as the initial comments from the document
|
|
135
139
|
*/
|
|
136
|
-
declare const CommentContextProvider: ({ children, initialComments, initialOverlayState,
|
|
140
|
+
declare const CommentContextProvider: ({ children, initialComments, initialOverlayState, currentUser: currentUserProp, subscription, config, projectId, locationId: locationIdProp, onError, onAdd, onEdit, onDelete, onResolve, onReopen, }: CommentOverlayProps$1) => react_jsx_runtime.JSX.Element;
|
|
137
141
|
declare const useComments: () => CommentContext;
|
|
138
142
|
|
|
139
143
|
type CommentScope = {
|
|
@@ -145,4 +149,56 @@ type CommentScope = {
|
|
|
145
149
|
declare const CommentScopeContext: React.Context<CommentScope | null>;
|
|
146
150
|
declare function useCommentScope(): CommentScope;
|
|
147
151
|
|
|
148
|
-
|
|
152
|
+
interface SessionButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
153
|
+
asChild?: boolean;
|
|
154
|
+
}
|
|
155
|
+
interface CreateSessionProps extends SessionButtonProps {
|
|
156
|
+
/** The user creating the session */
|
|
157
|
+
user: User;
|
|
158
|
+
}
|
|
159
|
+
declare const CreateSession: ({ asChild, user, ...rest }: CreateSessionProps) => react_jsx_runtime.JSX.Element;
|
|
160
|
+
declare const ConfirmSession: ({ asChild, ...rest }: SessionButtonProps) => react_jsx_runtime.JSX.Element;
|
|
161
|
+
declare const StartResolving: ({ asChild, ...rest }: SessionButtonProps) => react_jsx_runtime.JSX.Element;
|
|
162
|
+
declare const ResolveSession: ({ asChild, ...rest }: SessionButtonProps) => react_jsx_runtime.JSX.Element;
|
|
163
|
+
|
|
164
|
+
type FeedbackSessionProviderProps = {
|
|
165
|
+
children: ReactNode;
|
|
166
|
+
/** Resume a session, for example after a reload */
|
|
167
|
+
initialSession?: InitialFeedbackSession;
|
|
168
|
+
/** Default project id sent to onCreateSession */
|
|
169
|
+
projectId?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Whether the current user may start the resolution of a session, resolve a
|
|
172
|
+
* session, and resolve and reopen comments.
|
|
173
|
+
* @default false
|
|
174
|
+
*/
|
|
175
|
+
canResolveSession?: boolean;
|
|
176
|
+
onCreateSession?: (input: CreateSessionInput) => Promise<FeedbackSession>;
|
|
177
|
+
onConfirmSession?: (sessionId: string, type: SessionType) => Promise<void>;
|
|
178
|
+
onStartResolving?: (sessionId: string) => Promise<void>;
|
|
179
|
+
onResolveSession?: (sessionId: string) => Promise<void>;
|
|
180
|
+
onError?: (error: KnownError) => void;
|
|
181
|
+
};
|
|
182
|
+
type ActionResult = {
|
|
183
|
+
error: KnownError | null;
|
|
184
|
+
};
|
|
185
|
+
type FeedbackSessionContextType = {
|
|
186
|
+
session: ActiveFeedbackSession | null;
|
|
187
|
+
sessionState: SessionOperationState;
|
|
188
|
+
/** Mirrors the canResolveSession prop */
|
|
189
|
+
canResolve: boolean;
|
|
190
|
+
createSession: (options: {
|
|
191
|
+
/** The user creating the session. Required, a missing user is refused */
|
|
192
|
+
user: User;
|
|
193
|
+
type?: SessionType;
|
|
194
|
+
projectId?: string;
|
|
195
|
+
}) => Promise<ActionResult>;
|
|
196
|
+
confirmSession: () => Promise<ActionResult>;
|
|
197
|
+
startResolving: () => Promise<ActionResult>;
|
|
198
|
+
resolveSession: () => Promise<ActionResult>;
|
|
199
|
+
events: SessionEvents;
|
|
200
|
+
};
|
|
201
|
+
declare const FeedbackSessionProvider: ({ children, initialSession, projectId, canResolveSession, onCreateSession, onConfirmSession, onStartResolving, onResolveSession, onError, }: FeedbackSessionProviderProps) => react_jsx_runtime.JSX.Element;
|
|
202
|
+
declare const useFeedbackSession: () => FeedbackSessionContextType;
|
|
203
|
+
|
|
204
|
+
export { Comment, CommentContextProvider, CommentOverlay, CommentRenderer, CommentScopeContext, ConfirmSession, CreateSession, type FeedbackSessionContextType, FeedbackSessionProvider, type FeedbackSessionProviderProps, ResolveSession, StartResolving, ToggleOverlayButton, commentReducer, useCommentScope, useComments, useFeedbackSession };
|