convex-feedback-ui 0.1.2 → 0.1.3
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 +115 -18
- package/dist/.tsbuildinfo +1 -1
- package/dist/native/expo/ExpoFeedbackBody.d.ts +4 -0
- package/dist/native/expo/ExpoFeedbackBody.d.ts.map +1 -0
- package/dist/native/expo/ExpoFeedbackBody.js +26 -0
- package/dist/native/expo/ExpoFeedbackBody.js.map +1 -0
- package/dist/native/expo/FeedbackScreen.d.ts +3 -0
- package/dist/native/expo/FeedbackScreen.d.ts.map +1 -0
- package/dist/native/expo/FeedbackScreen.js +9 -0
- package/dist/native/expo/FeedbackScreen.js.map +1 -0
- package/dist/native/expo/FeedbackStack.d.ts +3 -0
- package/dist/native/expo/FeedbackStack.d.ts.map +1 -0
- package/dist/native/expo/FeedbackStack.js +41 -0
- package/dist/native/expo/FeedbackStack.js.map +1 -0
- package/dist/native/expo/index.d.ts +9 -0
- package/dist/native/expo/index.d.ts.map +1 -0
- package/dist/native/expo/index.js +7 -0
- package/dist/native/expo/index.js.map +1 -0
- package/dist/native/expo/types.d.ts +20 -0
- package/dist/native/expo/types.d.ts.map +1 -0
- package/dist/native/expo/types.js +2 -0
- package/dist/native/expo/types.js.map +1 -0
- package/dist/native/native/FeedbackScreen.d.ts +3 -0
- package/dist/native/native/FeedbackScreen.d.ts.map +1 -0
- package/dist/native/native/FeedbackScreen.js +9 -0
- package/dist/native/native/FeedbackScreen.js.map +1 -0
- package/dist/native/native/index.d.ts +8 -0
- package/dist/native/native/index.d.ts.map +1 -0
- package/dist/native/native/index.js +7 -0
- package/dist/native/native/index.js.map +1 -0
- package/dist/native/shared/helpers.d.ts +3 -0
- package/dist/native/shared/helpers.d.ts.map +1 -0
- package/dist/native/shared/helpers.js +4 -0
- package/dist/native/shared/helpers.js.map +1 -0
- package/dist/native/shared/ui/BodyContent.d.ts +3 -0
- package/dist/native/shared/ui/BodyContent.d.ts.map +1 -0
- package/dist/native/shared/ui/BodyContent.js +18 -0
- package/dist/native/shared/ui/BodyContent.js.map +1 -0
- package/dist/native/shared/ui/Button.d.ts +5 -0
- package/dist/native/shared/ui/Button.d.ts.map +1 -0
- package/dist/native/shared/ui/Button.js +15 -0
- package/dist/native/shared/ui/Button.js.map +1 -0
- package/dist/native/shared/ui/CommentBranch.d.ts +3 -0
- package/dist/native/shared/ui/CommentBranch.d.ts.map +1 -0
- package/dist/native/shared/ui/CommentBranch.js +35 -0
- package/dist/native/shared/ui/CommentBranch.js.map +1 -0
- package/dist/native/shared/ui/EntryCard.d.ts +3 -0
- package/dist/native/shared/ui/EntryCard.d.ts.map +1 -0
- package/dist/native/shared/ui/EntryCard.js +13 -0
- package/dist/native/shared/ui/EntryCard.js.map +1 -0
- package/dist/native/shared/ui/EntryDetail.d.ts +3 -0
- package/dist/native/shared/ui/EntryDetail.d.ts.map +1 -0
- package/dist/native/shared/ui/EntryDetail.js +37 -0
- package/dist/native/shared/ui/EntryDetail.js.map +1 -0
- package/dist/native/shared/ui/FeedbackScreenHeader.d.ts +2 -0
- package/dist/native/shared/ui/FeedbackScreenHeader.d.ts.map +1 -0
- package/dist/native/shared/ui/FeedbackScreenHeader.js +20 -0
- package/dist/native/shared/ui/FeedbackScreenHeader.js.map +1 -0
- package/dist/native/shared/ui/FeedbackScreenList.d.ts +3 -0
- package/dist/native/shared/ui/FeedbackScreenList.d.ts.map +1 -0
- package/dist/native/shared/ui/FeedbackScreenList.js +19 -0
- package/dist/native/shared/ui/FeedbackScreenList.js.map +1 -0
- package/dist/native/shared/ui/NewEntry.d.ts +5 -0
- package/dist/native/shared/ui/NewEntry.d.ts.map +1 -0
- package/dist/native/shared/ui/NewEntry.js +158 -0
- package/dist/native/shared/ui/NewEntry.js.map +1 -0
- package/dist/native/shared/ui/ReplyList.d.ts +3 -0
- package/dist/native/shared/ui/ReplyList.d.ts.map +1 -0
- package/dist/native/shared/ui/ReplyList.js +19 -0
- package/dist/native/shared/ui/ReplyList.js.map +1 -0
- package/dist/native/{primitives.d.ts → shared/ui/primitives.d.ts} +10 -12
- package/dist/native/shared/ui/primitives.d.ts.map +1 -0
- package/dist/native/{primitives.js → shared/ui/primitives.js} +19 -25
- package/dist/native/shared/ui/primitives.js.map +1 -0
- package/dist/react/{context.d.ts → css.d.ts} +2 -4
- package/dist/react/css.d.ts.map +1 -0
- package/dist/react/css.js +18 -0
- package/dist/react/css.js.map +1 -0
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/primitives.d.ts.map +1 -1
- package/dist/react/primitives.js +2 -1
- package/dist/react/primitives.js.map +1 -1
- package/dist/react/screen.d.ts +3 -3
- package/dist/react/screen.d.ts.map +1 -1
- package/dist/react/screen.js +25 -22
- package/dist/react/screen.js.map +1 -1
- package/dist/shared/context/FeedbackBodyProvider.d.ts +5 -0
- package/dist/shared/context/FeedbackBodyProvider.d.ts.map +1 -0
- package/dist/shared/context/FeedbackBodyProvider.js +43 -0
- package/dist/shared/context/FeedbackBodyProvider.js.map +1 -0
- package/dist/{native/context.d.ts → shared/context/FeedbackProvider.d.ts} +2 -2
- package/dist/shared/context/FeedbackProvider.d.ts.map +1 -0
- package/dist/{native/context.js → shared/context/FeedbackProvider.js} +3 -3
- package/dist/shared/context/FeedbackProvider.js.map +1 -0
- package/dist/shared/helpers.d.ts +7 -0
- package/dist/shared/helpers.d.ts.map +1 -0
- package/dist/shared/helpers.js +24 -0
- package/dist/shared/helpers.js.map +1 -0
- package/dist/shared/messages.d.ts.map +1 -1
- package/dist/shared/messages.js +23 -14
- package/dist/shared/messages.js.map +1 -1
- package/dist/shared/theme.d.ts.map +1 -1
- package/dist/shared/theme.js +1 -0
- package/dist/shared/theme.js.map +1 -1
- package/dist/shared/types/context.d.ts +4 -0
- package/dist/shared/types/context.d.ts.map +1 -1
- package/dist/shared/types/messages.d.ts +12 -1
- package/dist/shared/types/messages.d.ts.map +1 -1
- package/dist/shared/types/screen.d.ts +55 -18
- package/dist/shared/types/screen.d.ts.map +1 -1
- package/dist/shared/types/theme.d.ts +4 -0
- package/dist/shared/types/theme.d.ts.map +1 -1
- package/package.json +27 -12
- package/src/native/expo/ExpoFeedbackBody.tsx +48 -0
- package/src/native/expo/FeedbackScreen.tsx +37 -0
- package/src/native/expo/FeedbackStack.tsx +99 -0
- package/src/native/expo/README.md +17 -0
- package/src/native/expo/index.ts +8 -0
- package/src/native/expo/types.ts +23 -0
- package/src/native/native/FeedbackScreen.tsx +37 -0
- package/src/native/native/index.ts +7 -0
- package/src/native/shared/helpers.ts +9 -0
- package/src/native/shared/ui/BodyContent.tsx +43 -0
- package/src/native/shared/ui/Button.tsx +29 -0
- package/src/native/shared/ui/CommentBranch.tsx +88 -0
- package/src/native/shared/ui/EntryCard.tsx +37 -0
- package/src/native/shared/ui/EntryDetail.tsx +103 -0
- package/src/native/shared/ui/FeedbackScreenHeader.tsx +40 -0
- package/src/native/shared/ui/FeedbackScreenList.tsx +61 -0
- package/src/native/shared/ui/NewEntry.tsx +375 -0
- package/src/native/shared/ui/ReplyList.tsx +41 -0
- package/src/native/{primitives.tsx → shared/ui/primitives.tsx} +84 -92
- package/src/react/{context.tsx → css.tsx} +2 -44
- package/src/react/index.ts +1 -1
- package/src/react/primitives.tsx +2 -1
- package/src/react/screen.tsx +67 -123
- package/src/shared/context/FeedbackBodyProvider.tsx +82 -0
- package/src/{native/context.tsx → shared/context/FeedbackProvider.tsx} +3 -3
- package/src/shared/helpers.ts +33 -0
- package/src/shared/messages.ts +23 -22
- package/src/shared/theme.ts +1 -0
- package/src/shared/types/context.ts +5 -0
- package/src/shared/types/messages.ts +16 -1
- package/src/shared/types/screen.ts +69 -23
- package/src/shared/types/theme.ts +5 -0
- package/dist/native/context.d.ts.map +0 -1
- package/dist/native/context.js.map +0 -1
- package/dist/native/index.d.ts +0 -7
- package/dist/native/index.d.ts.map +0 -1
- package/dist/native/index.js +0 -6
- package/dist/native/index.js.map +0 -1
- package/dist/native/primitives.d.ts.map +0 -1
- package/dist/native/primitives.js.map +0 -1
- package/dist/native/screen.d.ts +0 -3
- package/dist/native/screen.d.ts.map +0 -1
- package/dist/native/screen.js +0 -284
- package/dist/native/screen.js.map +0 -1
- package/dist/react/context.d.ts.map +0 -1
- package/dist/react/context.js +0 -41
- package/dist/react/context.js.map +0 -1
- package/src/native/index.ts +0 -6
- package/src/native/screen.tsx +0 -831
- /package/src/native/{README.md → native/README.md} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
|
|
3
|
+
import { useFeedbackBody } from "../../../shared/context/FeedbackBodyProvider";
|
|
4
|
+
import { useFeedbackUi } from "../../../shared/context/FeedbackProvider";
|
|
5
|
+
import type { FeedbackScreenReplyListProps } from "../../../shared/types";
|
|
6
|
+
import { Button } from "./Button";
|
|
7
|
+
import { CommentBranch } from "./CommentBranch";
|
|
8
|
+
import { Comment } from "./primitives";
|
|
9
|
+
|
|
10
|
+
export function ReplyList({
|
|
11
|
+
entryId,
|
|
12
|
+
parentCommentId,
|
|
13
|
+
}: FeedbackScreenReplyListProps) {
|
|
14
|
+
const { hooks, commentSort, transformComments } = useFeedbackBody();
|
|
15
|
+
const { messages } = useFeedbackUi();
|
|
16
|
+
|
|
17
|
+
const replies = hooks.useComments({
|
|
18
|
+
entryId,
|
|
19
|
+
parentCommentId,
|
|
20
|
+
sort: commentSort,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const visible = useMemo(
|
|
24
|
+
() => transformComments?.(replies.results) ?? replies.results,
|
|
25
|
+
[replies.results, transformComments],
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Comment.Children>
|
|
30
|
+
{visible.map((reply) => (
|
|
31
|
+
<CommentBranch key={reply.id} comment={reply} entryId={entryId} />
|
|
32
|
+
))}
|
|
33
|
+
{replies.status === "CanLoadMore" && (
|
|
34
|
+
<Button
|
|
35
|
+
label={messages.comments.loadMore}
|
|
36
|
+
onPress={() => replies.loadMore(hooks.pageSizes.replies)}
|
|
37
|
+
/>
|
|
38
|
+
)}
|
|
39
|
+
</Comment.Children>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -2,7 +2,13 @@ import type {
|
|
|
2
2
|
FeedbackComment,
|
|
3
3
|
FeedbackEntry as FeedbackEntryData,
|
|
4
4
|
} from "convex-feedback";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createContext,
|
|
7
|
+
forwardRef,
|
|
8
|
+
useContext,
|
|
9
|
+
useMemo,
|
|
10
|
+
type PropsWithChildren,
|
|
11
|
+
} from "react";
|
|
6
12
|
import {
|
|
7
13
|
Pressable,
|
|
8
14
|
ScrollView,
|
|
@@ -18,11 +24,11 @@ import {
|
|
|
18
24
|
type ViewProps,
|
|
19
25
|
type ViewStyle,
|
|
20
26
|
} from "react-native";
|
|
21
|
-
import {
|
|
22
|
-
SafeAreaView,
|
|
23
|
-
type SafeAreaViewProps,
|
|
24
|
-
} from "react-native-safe-area-context";
|
|
25
27
|
|
|
28
|
+
import {
|
|
29
|
+
FeedbackNativeThemeScope,
|
|
30
|
+
useFeedbackUi,
|
|
31
|
+
} from "../../../shared/context/FeedbackProvider.js";
|
|
26
32
|
import type {
|
|
27
33
|
BoardSearchBaseProps,
|
|
28
34
|
BoardSearchState,
|
|
@@ -37,21 +43,13 @@ import type {
|
|
|
37
43
|
FormSubmitBaseProps,
|
|
38
44
|
FormSubmitState,
|
|
39
45
|
RepliesButtonBaseProps,
|
|
40
|
-
} from "
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
function combineStyle<T>(
|
|
44
|
-
enabled: boolean,
|
|
45
|
-
fallback: StyleProp<T>,
|
|
46
|
-
style: StyleProp<T>,
|
|
47
|
-
): StyleProp<T> {
|
|
48
|
-
return enabled ? [fallback, style] : style;
|
|
49
|
-
}
|
|
46
|
+
} from "../../../shared/types";
|
|
47
|
+
import { combineStyle } from "../helpers.js";
|
|
50
48
|
|
|
51
49
|
/**
|
|
52
50
|
* Props for `FeedbackBoard.Root`.
|
|
53
51
|
*/
|
|
54
|
-
export
|
|
52
|
+
export type BoardRootProps = PropsWithChildren<FeedbackColorProps>;
|
|
55
53
|
|
|
56
54
|
function BoardRoot({
|
|
57
55
|
primaryColor,
|
|
@@ -62,10 +60,7 @@ function BoardRoot({
|
|
|
62
60
|
borderColor,
|
|
63
61
|
dangerColor,
|
|
64
62
|
children,
|
|
65
|
-
style,
|
|
66
|
-
...props
|
|
67
63
|
}: BoardRootProps) {
|
|
68
|
-
const { theme, unstyled } = useFeedbackUi();
|
|
69
64
|
const colorOverrides = useMemo(
|
|
70
65
|
() => ({
|
|
71
66
|
...(primaryColor === undefined ? {} : { primary: primaryColor }),
|
|
@@ -86,25 +81,10 @@ function BoardRoot({
|
|
|
86
81
|
textColor,
|
|
87
82
|
],
|
|
88
83
|
);
|
|
89
|
-
const background = backgroundColor ?? theme.colors.background;
|
|
90
84
|
|
|
91
85
|
return (
|
|
92
86
|
<FeedbackNativeThemeScope colors={colorOverrides}>
|
|
93
|
-
|
|
94
|
-
{...props}
|
|
95
|
-
style={combineStyle<ViewStyle>(
|
|
96
|
-
!unstyled,
|
|
97
|
-
{
|
|
98
|
-
flex: 1,
|
|
99
|
-
gap: theme.spacing,
|
|
100
|
-
padding: theme.spacing,
|
|
101
|
-
backgroundColor: background,
|
|
102
|
-
},
|
|
103
|
-
style,
|
|
104
|
-
)}
|
|
105
|
-
>
|
|
106
|
-
{children}
|
|
107
|
-
</SafeAreaView>
|
|
87
|
+
{children}
|
|
108
88
|
</FeedbackNativeThemeScope>
|
|
109
89
|
);
|
|
110
90
|
}
|
|
@@ -114,7 +94,11 @@ function BoardHeader({ style, ...props }: ViewProps) {
|
|
|
114
94
|
return (
|
|
115
95
|
<View
|
|
116
96
|
{...props}
|
|
117
|
-
style={combineStyle<ViewStyle>(
|
|
97
|
+
style={combineStyle<ViewStyle>(
|
|
98
|
+
!unstyled,
|
|
99
|
+
{ gap: theme.spacing, backgroundColor: theme.colors.background },
|
|
100
|
+
style,
|
|
101
|
+
)}
|
|
118
102
|
/>
|
|
119
103
|
);
|
|
120
104
|
}
|
|
@@ -143,59 +127,60 @@ export interface BoardSearchProps
|
|
|
143
127
|
Omit<TextInputProps, "children" | "value" | "onChangeText">,
|
|
144
128
|
BoardSearchBaseProps {}
|
|
145
129
|
|
|
146
|
-
|
|
147
|
-
value,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
);
|
|
180
|
-
}
|
|
130
|
+
const BoardSearch = forwardRef<TextInput, BoardSearchProps>(
|
|
131
|
+
({ value, onValueChange, children, style, ...props }, ref) => {
|
|
132
|
+
const { messages, theme, unstyled } = useFeedbackUi();
|
|
133
|
+
const state: BoardSearchState = { value, setValue: onValueChange };
|
|
134
|
+
if (typeof children === "function") return <>{children(state)}</>;
|
|
135
|
+
return (
|
|
136
|
+
<TextInput
|
|
137
|
+
ref={ref}
|
|
138
|
+
{...props}
|
|
139
|
+
value={value}
|
|
140
|
+
onChangeText={onValueChange}
|
|
141
|
+
placeholder={props.placeholder ?? messages.board.searchPlaceholder}
|
|
142
|
+
placeholderTextColor={
|
|
143
|
+
props.placeholderTextColor ?? theme.colors.mutedText
|
|
144
|
+
}
|
|
145
|
+
style={combineStyle<TextStyle>(
|
|
146
|
+
!unstyled,
|
|
147
|
+
{
|
|
148
|
+
color: theme.colors.text,
|
|
149
|
+
borderWidth: 1,
|
|
150
|
+
borderColor: theme.colors.border,
|
|
151
|
+
borderRadius: Math.max(8, theme.radius - 2),
|
|
152
|
+
paddingHorizontal: 12,
|
|
153
|
+
paddingVertical: 10,
|
|
154
|
+
backgroundColor: theme.colors.surface,
|
|
155
|
+
},
|
|
156
|
+
style,
|
|
157
|
+
)}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
// change to forwardRef
|
|
181
163
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
{
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
164
|
+
const BoardList = forwardRef<ScrollView, ScrollViewProps>(
|
|
165
|
+
({ style, ...props }, ref) => {
|
|
166
|
+
const { theme, unstyled } = useFeedbackUi();
|
|
167
|
+
return (
|
|
168
|
+
<ScrollView
|
|
169
|
+
ref={ref}
|
|
170
|
+
keyboardShouldPersistTaps="handled"
|
|
171
|
+
contentInsetAdjustmentBehavior="automatic"
|
|
172
|
+
automaticallyAdjustKeyboardInsets
|
|
173
|
+
style={{ flex: 1 }}
|
|
174
|
+
{...props}
|
|
175
|
+
contentContainerStyle={combineStyle<ViewStyle>(
|
|
176
|
+
!unstyled,
|
|
177
|
+
{ gap: Math.max(8, theme.spacing - 2) },
|
|
178
|
+
style,
|
|
179
|
+
)}
|
|
180
|
+
/>
|
|
181
|
+
);
|
|
182
|
+
},
|
|
183
|
+
);
|
|
199
184
|
|
|
200
185
|
export const FeedbackBoard = {
|
|
201
186
|
Root: BoardRoot,
|
|
@@ -684,13 +669,15 @@ function FormTextarea({ style, ...props }: TextInputProps) {
|
|
|
684
669
|
|
|
685
670
|
export interface FormSubmitProps
|
|
686
671
|
extends Omit<PressableProps, "children" | "style">, FormSubmitBaseProps {
|
|
687
|
-
|
|
672
|
+
backgroundColor?: string;
|
|
673
|
+
color?: string;
|
|
688
674
|
style?: StyleProp<ViewStyle>;
|
|
689
675
|
}
|
|
690
676
|
function FormSubmit({
|
|
691
677
|
submitting = false,
|
|
692
678
|
children,
|
|
693
|
-
|
|
679
|
+
backgroundColor,
|
|
680
|
+
color,
|
|
694
681
|
disabled,
|
|
695
682
|
style,
|
|
696
683
|
...props
|
|
@@ -710,13 +697,18 @@ function FormSubmit({
|
|
|
710
697
|
justifyContent: "center",
|
|
711
698
|
borderRadius: Math.max(8, theme.radius - 2),
|
|
712
699
|
paddingHorizontal: 12,
|
|
713
|
-
backgroundColor:
|
|
700
|
+
backgroundColor: backgroundColor ?? theme.colors.primary,
|
|
714
701
|
opacity: (disabled ?? submitting) ? 0.55 : 1,
|
|
715
702
|
},
|
|
716
703
|
style,
|
|
717
704
|
)}
|
|
718
705
|
>
|
|
719
|
-
<Text
|
|
706
|
+
<Text
|
|
707
|
+
style={{
|
|
708
|
+
color: color ?? theme.colors.primaryForeground,
|
|
709
|
+
fontWeight: "700",
|
|
710
|
+
}}
|
|
711
|
+
>
|
|
720
712
|
{children ?? messages.form.submit}
|
|
721
713
|
</Text>
|
|
722
714
|
</Pressable>
|
|
@@ -1,50 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { type CSSProperties } from "react";
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { mergeFeedbackTheme } from "../shared/theme.js";
|
|
7
|
-
import type {
|
|
8
|
-
FeedbackColorProps,
|
|
9
|
-
FeedbackProviderProps,
|
|
10
|
-
FeedbackTheme,
|
|
11
|
-
FeedbackUiContextValue,
|
|
12
|
-
} from "../shared/types";
|
|
13
|
-
|
|
14
|
-
const FeedbackUiContext = createContext<FeedbackUiContextValue | null>(null);
|
|
15
|
-
|
|
16
|
-
export function FeedbackProvider({
|
|
17
|
-
children,
|
|
18
|
-
messages,
|
|
19
|
-
theme,
|
|
20
|
-
unstyled = false,
|
|
21
|
-
}: FeedbackProviderProps) {
|
|
22
|
-
const value = useMemo<FeedbackUiContextValue>(
|
|
23
|
-
() => ({
|
|
24
|
-
messages: mergeFeedbackMessages(messages),
|
|
25
|
-
theme: mergeFeedbackTheme(theme),
|
|
26
|
-
unstyled,
|
|
27
|
-
}),
|
|
28
|
-
[messages, theme, unstyled],
|
|
29
|
-
);
|
|
30
|
-
return (
|
|
31
|
-
<FeedbackUiContext.Provider value={value}>
|
|
32
|
-
{children}
|
|
33
|
-
</FeedbackUiContext.Provider>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function useFeedbackUi(): FeedbackUiContextValue {
|
|
38
|
-
const context = useContext(FeedbackUiContext);
|
|
39
|
-
if (context === null) {
|
|
40
|
-
return {
|
|
41
|
-
messages: mergeFeedbackMessages(),
|
|
42
|
-
theme: mergeFeedbackTheme(),
|
|
43
|
-
unstyled: false,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return context;
|
|
47
|
-
}
|
|
5
|
+
import type { FeedbackColorProps, FeedbackTheme } from "../shared/types";
|
|
48
6
|
|
|
49
7
|
/**
|
|
50
8
|
* CSS custom properties produced for a feedback board.
|
package/src/react/index.ts
CHANGED
package/src/react/primitives.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
type TextareaHTMLAttributes,
|
|
16
16
|
} from "react";
|
|
17
17
|
|
|
18
|
+
import { useFeedbackUi } from "../shared/context/FeedbackProvider";
|
|
18
19
|
import type {
|
|
19
20
|
BoardRootBaseProps,
|
|
20
21
|
BoardSearchBaseProps,
|
|
@@ -32,7 +33,7 @@ import type {
|
|
|
32
33
|
RepliesButtonBaseProps,
|
|
33
34
|
RepliesButtonState,
|
|
34
35
|
} from "../shared/types";
|
|
35
|
-
import { feedbackCssVariables
|
|
36
|
+
import { feedbackCssVariables } from "./css.js";
|
|
36
37
|
|
|
37
38
|
function classes(
|
|
38
39
|
unstyled: boolean,
|