@vvedantb/native-ui 0.24.2 → 0.25.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/dist/MenuSheet.jsx +164 -0
- package/dist/ReactionRow.jsx +84 -0
- package/dist/ai/index.js +2 -0
- package/dist/ai/message-context-menu.jsx +390 -0
- package/dist/ai/message-menu-layout.js +46 -0
- package/dist/ai/message.jsx +114 -69
- package/dist/entries/primitives.js +2 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
- package/src/MenuSheet.tsx +80 -0
- package/src/ReactionRow.tsx +70 -0
- package/src/ai/index.ts +3 -0
- package/src/ai/message-action-sheet.tsx +2 -0
- package/src/ai/message-context-menu.tsx +186 -0
- package/src/ai/message-menu-layout.ts +44 -0
- package/src/ai/message.tsx +56 -6
- package/src/entries/primitives.ts +4 -0
- package/src/index.ts +4 -0
package/dist/ai/message.jsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
|
-
import { createContext, useContext, useEffect, useState } from "react";
|
|
2
|
+
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { Pressable, StyleSheet, Text, View } from "react-native";
|
|
4
4
|
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
5
5
|
import { IconArrowBackUp, IconCopy, IconRefresh, IconThumbDown, IconThumbUp } from "@tabler/icons-react-native";
|
|
6
6
|
import { cn } from "../cn";
|
|
7
|
+
import { impactHaptic } from "../haptics";
|
|
7
8
|
import { sizeStyle, typeStyle } from "../controlStyles";
|
|
8
9
|
import { palette, withAlpha } from "../palette";
|
|
9
10
|
import { useLargerText } from "../theme";
|
|
@@ -13,6 +14,7 @@ import { useScheme } from "../useScheme";
|
|
|
13
14
|
import { META_TEXT_STYLE, chatTextSize } from "./chat-text";
|
|
14
15
|
import { ChatIconButton } from "./icon-button";
|
|
15
16
|
import { MESSAGE_ACTIONS_TITLE, MessageActionSheet } from "./message-action-sheet";
|
|
17
|
+
import { MessageContextMenu } from "./message-context-menu";
|
|
16
18
|
import { ChatTextColorContext, ResponseText } from "./response-text";
|
|
17
19
|
const MessageContext = createContext("assistant");
|
|
18
20
|
|
|
@@ -104,19 +106,31 @@ function MessageHighlight() {
|
|
|
104
106
|
* at the start, its parts full width.
|
|
105
107
|
*
|
|
106
108
|
* With `onLongPress` or `actions` the message is a `Pressable` (same layout,
|
|
107
|
-
* `className`, `style` and view props)
|
|
109
|
+
* `className`, `style` and view props): a 350 ms hold dims it a little,
|
|
110
|
+
* fires a medium haptic, runs `onLongPress` and opens the
|
|
108
111
|
* `MessageActionSheet`; TalkBack reaches it as the `longpress` action. It stays
|
|
109
112
|
* a non-accessible container so its buttons and links keep their own focus:
|
|
110
113
|
* also offer the actions in a `MessageActionsBar` for screen reader users. `highlighted` draws the quote-jump highlight.
|
|
111
114
|
*/
|
|
115
|
+
/** How long a hold takes, in ms: shorter than React Native's 500, as iMessage. */
|
|
116
|
+
const HOLD_DELAY_MS = 350;
|
|
117
|
+
/**
|
|
118
|
+
* A held message dims a little. It does not shrink: the hold menu measures the
|
|
119
|
+
* message while it is held, and a scaled box would draw the lifted copy smaller
|
|
120
|
+
* (and could wrap its text differently).
|
|
121
|
+
*/
|
|
122
|
+
const HELD_STYLE = {
|
|
123
|
+
opacity: 0.9
|
|
124
|
+
};
|
|
112
125
|
export function Message(t0) {
|
|
113
|
-
const $ = _c(
|
|
126
|
+
const $ = _c(52);
|
|
114
127
|
let actionSheetTitle;
|
|
115
128
|
let actions;
|
|
116
129
|
let bot;
|
|
117
130
|
let children;
|
|
118
131
|
let className;
|
|
119
132
|
let from;
|
|
133
|
+
let menu;
|
|
120
134
|
let onLongPress;
|
|
121
135
|
let props;
|
|
122
136
|
let style;
|
|
@@ -127,6 +141,7 @@ export function Message(t0) {
|
|
|
127
141
|
className,
|
|
128
142
|
style,
|
|
129
143
|
onLongPress,
|
|
144
|
+
menu,
|
|
130
145
|
actions,
|
|
131
146
|
actionSheetTitle,
|
|
132
147
|
highlighted: t1,
|
|
@@ -141,10 +156,11 @@ export function Message(t0) {
|
|
|
141
156
|
$[4] = children;
|
|
142
157
|
$[5] = className;
|
|
143
158
|
$[6] = from;
|
|
144
|
-
$[7] =
|
|
145
|
-
$[8] =
|
|
146
|
-
$[9] =
|
|
147
|
-
$[10] =
|
|
159
|
+
$[7] = menu;
|
|
160
|
+
$[8] = onLongPress;
|
|
161
|
+
$[9] = props;
|
|
162
|
+
$[10] = style;
|
|
163
|
+
$[11] = t1;
|
|
148
164
|
} else {
|
|
149
165
|
actionSheetTitle = $[1];
|
|
150
166
|
actions = $[2];
|
|
@@ -152,124 +168,153 @@ export function Message(t0) {
|
|
|
152
168
|
children = $[4];
|
|
153
169
|
className = $[5];
|
|
154
170
|
from = $[6];
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
171
|
+
menu = $[7];
|
|
172
|
+
onLongPress = $[8];
|
|
173
|
+
props = $[9];
|
|
174
|
+
style = $[10];
|
|
175
|
+
t1 = $[11];
|
|
159
176
|
}
|
|
160
177
|
const highlighted = t1 === undefined ? false : t1;
|
|
161
178
|
const user = from === "user";
|
|
162
179
|
const [sheetOpen, setSheetOpen] = useState(false);
|
|
180
|
+
const [pressing, setPressing] = useState(false);
|
|
181
|
+
const [held, setHeld] = useState(null);
|
|
182
|
+
const pressable = useRef(null);
|
|
163
183
|
const hasActions = actions != null && actions.length > 0;
|
|
164
|
-
const longPressable = onLongPress != null || hasActions;
|
|
184
|
+
const longPressable = onLongPress != null || hasActions || menu != null;
|
|
165
185
|
let t2;
|
|
166
|
-
if ($[
|
|
186
|
+
if ($[12] !== hasActions || $[13] !== menu || $[14] !== onLongPress) {
|
|
167
187
|
t2 = () => {
|
|
188
|
+
impactHaptic("medium");
|
|
168
189
|
onLongPress?.();
|
|
169
|
-
if (
|
|
170
|
-
|
|
190
|
+
if (menu) {
|
|
191
|
+
const built = menu();
|
|
192
|
+
pressable.current?.measureInWindow((x, y, width, height) => setHeld({
|
|
193
|
+
anchor: {
|
|
194
|
+
x,
|
|
195
|
+
y,
|
|
196
|
+
width,
|
|
197
|
+
height
|
|
198
|
+
},
|
|
199
|
+
menu: built
|
|
200
|
+
}));
|
|
201
|
+
} else {
|
|
202
|
+
if (hasActions) {
|
|
203
|
+
setSheetOpen(true);
|
|
204
|
+
}
|
|
171
205
|
}
|
|
172
206
|
};
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
175
|
-
$[
|
|
207
|
+
$[12] = hasActions;
|
|
208
|
+
$[13] = menu;
|
|
209
|
+
$[14] = onLongPress;
|
|
210
|
+
$[15] = t2;
|
|
176
211
|
} else {
|
|
177
|
-
t2 = $[
|
|
212
|
+
t2 = $[15];
|
|
178
213
|
}
|
|
179
214
|
const longPress = t2;
|
|
180
215
|
const t3 = user ? "flex-end" : "flex-start";
|
|
181
216
|
const t4 = user ? "flex-end" : "stretch";
|
|
182
217
|
let t5;
|
|
183
|
-
if ($[
|
|
218
|
+
if ($[16] !== t3 || $[17] !== t4) {
|
|
184
219
|
t5 = {
|
|
185
220
|
alignSelf: t3,
|
|
186
221
|
alignItems: t4
|
|
187
222
|
};
|
|
188
|
-
$[
|
|
189
|
-
$[
|
|
190
|
-
$[
|
|
223
|
+
$[16] = t3;
|
|
224
|
+
$[17] = t4;
|
|
225
|
+
$[18] = t5;
|
|
191
226
|
} else {
|
|
192
|
-
t5 = $[
|
|
227
|
+
t5 = $[18];
|
|
193
228
|
}
|
|
194
229
|
let t6;
|
|
195
|
-
if ($[
|
|
230
|
+
if ($[19] !== style || $[20] !== t5) {
|
|
196
231
|
t6 = [t5, style];
|
|
197
|
-
$[
|
|
198
|
-
$[
|
|
199
|
-
$[
|
|
232
|
+
$[19] = style;
|
|
233
|
+
$[20] = t5;
|
|
234
|
+
$[21] = t6;
|
|
200
235
|
} else {
|
|
201
|
-
t6 = $[
|
|
236
|
+
t6 = $[21];
|
|
202
237
|
}
|
|
203
238
|
const layout = t6;
|
|
204
239
|
let t7;
|
|
205
|
-
if ($[
|
|
240
|
+
if ($[22] !== className) {
|
|
206
241
|
t7 = cn("w-full max-w-[95%] gap-2", className);
|
|
207
|
-
$[
|
|
208
|
-
$[
|
|
242
|
+
$[22] = className;
|
|
243
|
+
$[23] = t7;
|
|
209
244
|
} else {
|
|
210
|
-
t7 = $[
|
|
245
|
+
t7 = $[23];
|
|
211
246
|
}
|
|
212
247
|
const merged = t7;
|
|
213
248
|
let t8;
|
|
214
|
-
if ($[
|
|
249
|
+
if ($[24] !== bot || $[25] !== user) {
|
|
215
250
|
t8 = bot && !user ? <MessageBotLabel name={bot.name} avatar={bot.avatar} /> : null;
|
|
216
|
-
$[
|
|
217
|
-
$[
|
|
218
|
-
$[
|
|
251
|
+
$[24] = bot;
|
|
252
|
+
$[25] = user;
|
|
253
|
+
$[26] = t8;
|
|
219
254
|
} else {
|
|
220
|
-
t8 = $[
|
|
255
|
+
t8 = $[26];
|
|
221
256
|
}
|
|
222
257
|
let t9;
|
|
223
|
-
if ($[
|
|
258
|
+
if ($[27] !== highlighted) {
|
|
224
259
|
t9 = highlighted ? <MessageHighlight /> : null;
|
|
225
|
-
$[
|
|
226
|
-
$[
|
|
260
|
+
$[27] = highlighted;
|
|
261
|
+
$[28] = t9;
|
|
227
262
|
} else {
|
|
228
|
-
t9 = $[
|
|
263
|
+
t9 = $[28];
|
|
229
264
|
}
|
|
230
265
|
let t10;
|
|
231
|
-
if ($[
|
|
266
|
+
if ($[29] !== children || $[30] !== t8 || $[31] !== t9) {
|
|
232
267
|
t10 = <>{t8}{children}{t9}</>;
|
|
233
|
-
$[
|
|
234
|
-
$[
|
|
235
|
-
$[
|
|
236
|
-
$[
|
|
268
|
+
$[29] = children;
|
|
269
|
+
$[30] = t8;
|
|
270
|
+
$[31] = t9;
|
|
271
|
+
$[32] = t10;
|
|
237
272
|
} else {
|
|
238
|
-
t10 = $[
|
|
273
|
+
t10 = $[32];
|
|
239
274
|
}
|
|
240
275
|
const parts = t10;
|
|
241
276
|
let t11;
|
|
242
|
-
if ($[
|
|
243
|
-
t11 = longPressable ? <><Pressable accessible={false} className={merged} style={layout} onLongPress={longPress} accessibilityActions={[{
|
|
277
|
+
if ($[33] !== actionSheetTitle || $[34] !== actions || $[35] !== from || $[36] !== hasActions || $[37] !== held || $[38] !== layout || $[39] !== longPress || $[40] !== longPressable || $[41] !== menu || $[42] !== merged || $[43] !== parts || $[44] !== pressing || $[45] !== props || $[46] !== sheetOpen || $[47] !== user) {
|
|
278
|
+
t11 = longPressable ? <><Pressable ref={pressable} accessible={false} className={merged} style={[layout, pressing ? HELD_STYLE : null]} onPressIn={() => setPressing(true)} onPressOut={() => setPressing(false)} onLongPress={longPress} delayLongPress={HOLD_DELAY_MS} accessibilityActions={[{
|
|
244
279
|
name: "longpress",
|
|
245
280
|
label: actionSheetTitle ?? MESSAGE_ACTIONS_TITLE
|
|
246
281
|
}]} onAccessibilityAction={event => {
|
|
247
282
|
if (event.nativeEvent.actionName === "longpress") {
|
|
248
283
|
longPress();
|
|
249
284
|
}
|
|
250
|
-
}} {...props}>{parts}</Pressable>{
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
$[
|
|
257
|
-
$[
|
|
258
|
-
$[
|
|
259
|
-
$[
|
|
260
|
-
$[
|
|
261
|
-
$[
|
|
262
|
-
|
|
263
|
-
|
|
285
|
+
}} {...props}>{parts}</Pressable>{menu ? <MessageContextMenu open={held !== null} onClose={() => setHeld(null)} anchor={held?.anchor ?? null} align={user ? "end" : "start"} preview={<MessageContext.Provider value={from}><View className={merged} style={[layout, {
|
|
286
|
+
maxWidth: "100%",
|
|
287
|
+
width: "100%"
|
|
288
|
+
}]}>{parts}</View></MessageContext.Provider>} menu={held?.menu ?? {
|
|
289
|
+
actions: []
|
|
290
|
+
}} /> : hasActions ? <MessageActionSheet open={sheetOpen} onClose={() => setSheetOpen(false)} actions={actions} title={actionSheetTitle} /> : null}</> : <View className={merged} style={layout} {...props}>{parts}</View>;
|
|
291
|
+
$[33] = actionSheetTitle;
|
|
292
|
+
$[34] = actions;
|
|
293
|
+
$[35] = from;
|
|
294
|
+
$[36] = hasActions;
|
|
295
|
+
$[37] = held;
|
|
296
|
+
$[38] = layout;
|
|
297
|
+
$[39] = longPress;
|
|
298
|
+
$[40] = longPressable;
|
|
299
|
+
$[41] = menu;
|
|
300
|
+
$[42] = merged;
|
|
301
|
+
$[43] = parts;
|
|
302
|
+
$[44] = pressing;
|
|
303
|
+
$[45] = props;
|
|
304
|
+
$[46] = sheetOpen;
|
|
305
|
+
$[47] = user;
|
|
306
|
+
$[48] = t11;
|
|
307
|
+
} else {
|
|
308
|
+
t11 = $[48];
|
|
264
309
|
}
|
|
265
310
|
let t12;
|
|
266
|
-
if ($[
|
|
311
|
+
if ($[49] !== from || $[50] !== t11) {
|
|
267
312
|
t12 = <MessageContext.Provider value={from}>{t11}</MessageContext.Provider>;
|
|
268
|
-
$[
|
|
269
|
-
$[
|
|
270
|
-
$[
|
|
313
|
+
$[49] = from;
|
|
314
|
+
$[50] = t11;
|
|
315
|
+
$[51] = t12;
|
|
271
316
|
} else {
|
|
272
|
-
t12 = $[
|
|
317
|
+
t12 = $[51];
|
|
273
318
|
}
|
|
274
319
|
return t12;
|
|
275
320
|
}
|
|
@@ -19,6 +19,8 @@ export { ColorSwatches } from "../ColorSwatches";
|
|
|
19
19
|
export { StatGrid } from "../StatGrid";
|
|
20
20
|
export { SectionLabel } from "../SectionLabel";
|
|
21
21
|
export { SheetRow } from "../SheetRow";
|
|
22
|
+
export { MenuSheet, SubmenuRow, MenuDivider } from "../MenuSheet";
|
|
23
|
+
export { ReactionRow } from "../ReactionRow";
|
|
22
24
|
export { PageIndicator } from "../PageIndicator";
|
|
23
25
|
export { IconButton } from "../IconButton";
|
|
24
26
|
export { Stepper } from "../Stepper";
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,8 @@ export { ColorSwatches } from "./ColorSwatches";
|
|
|
27
27
|
export { StatGrid } from "./StatGrid";
|
|
28
28
|
export { SectionLabel } from "./SectionLabel";
|
|
29
29
|
export { SheetRow } from "./SheetRow";
|
|
30
|
+
export { MenuSheet, SubmenuRow, MenuDivider } from "./MenuSheet";
|
|
31
|
+
export { ReactionRow } from "./ReactionRow";
|
|
30
32
|
export { PageIndicator } from "./PageIndicator";
|
|
31
33
|
export { IconButton } from "./IconButton";
|
|
32
34
|
export { Stepper } from "./Stepper";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/native-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React Native / Expo UI primitives. Floating surfaces, forms, overlays, toasts, settings chrome, tab bar, AI chat parts, the family app marks, a NativeWind preset, the Expo web root and Clerk + Convex auth screens.",
|
|
6
6
|
"type": "module",
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from "react";
|
|
2
|
+
import { Pressable, View } from "react-native";
|
|
3
|
+
import { IconChevronLeft, IconChevronRight, type IconProps } from "@tabler/icons-react-native";
|
|
4
|
+
import { Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle } from "./Sheet";
|
|
5
|
+
import { SheetRow } from "./SheetRow";
|
|
6
|
+
import { tokens } from "./tokens";
|
|
7
|
+
import { useScheme } from "./useScheme";
|
|
8
|
+
|
|
9
|
+
export type MenuSheetProps = {
|
|
10
|
+
open: boolean;
|
|
11
|
+
onOpenChange: (open: boolean) => void;
|
|
12
|
+
title: string;
|
|
13
|
+
/** Set on a submenu page: the header gets a 44 back button to the root page. */
|
|
14
|
+
onBack?: () => void;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
testID?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A dropdown or context menu as one bottom sheet: a title, then `SheetRow`s
|
|
21
|
+
* with no gap between them, `MenuDivider`s between groups. With submenus, the
|
|
22
|
+
* root page lists the items, a `SubmenuRow` swaps the sheet to its page, and
|
|
23
|
+
* that page's header has a back button (`onBack`) to the root.
|
|
24
|
+
*/
|
|
25
|
+
export function MenuSheet({ open, onOpenChange, title, onBack, children, testID }: MenuSheetProps) {
|
|
26
|
+
const muted = tokens.color.muted[useScheme()];
|
|
27
|
+
return (
|
|
28
|
+
<Sheet open={open} onOpenChange={onOpenChange}>
|
|
29
|
+
<SheetContent className="gap-3 px-3" testID={testID}>
|
|
30
|
+
<SheetHeader className="min-h-11 flex-row items-center gap-1 px-2">
|
|
31
|
+
{onBack ? (
|
|
32
|
+
<Pressable
|
|
33
|
+
accessibilityRole="button"
|
|
34
|
+
accessibilityLabel="Back"
|
|
35
|
+
onPress={onBack}
|
|
36
|
+
className="-ml-2 h-11 w-11 items-center justify-center rounded-lg active:opacity-70"
|
|
37
|
+
>
|
|
38
|
+
<IconChevronLeft size={20} color={muted} />
|
|
39
|
+
</Pressable>
|
|
40
|
+
) : null}
|
|
41
|
+
<SheetTitle numberOfLines={1} className="min-w-0 flex-1">
|
|
42
|
+
{title}
|
|
43
|
+
</SheetTitle>
|
|
44
|
+
</SheetHeader>
|
|
45
|
+
<SheetBody>{children}</SheetBody>
|
|
46
|
+
</SheetContent>
|
|
47
|
+
</Sheet>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type SubmenuRowProps = {
|
|
52
|
+
icon?: ComponentType<IconProps>;
|
|
53
|
+
/** At the start in place of `icon`, such as a coloured status mark. */
|
|
54
|
+
leading?: ReactNode;
|
|
55
|
+
title: string;
|
|
56
|
+
detail?: string;
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
onPress: () => void;
|
|
59
|
+
testID?: string;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** A root-page item that opens a submenu: a `SheetRow` with a chevron at the end. */
|
|
63
|
+
export function SubmenuRow({ icon, leading, title, detail, disabled, onPress, testID }: SubmenuRowProps) {
|
|
64
|
+
const muted = tokens.color.muted[useScheme()];
|
|
65
|
+
return (
|
|
66
|
+
<View className="flex-row items-center">
|
|
67
|
+
<View className="min-w-0 flex-1">
|
|
68
|
+
<SheetRow icon={icon} leading={leading} title={title} detail={detail} disabled={disabled} onPress={onPress} testID={testID} />
|
|
69
|
+
</View>
|
|
70
|
+
<View className="absolute right-4" style={{ pointerEvents: "none", opacity: disabled ? 0.5 : 1 }}>
|
|
71
|
+
<IconChevronRight size={16} color={muted} />
|
|
72
|
+
</View>
|
|
73
|
+
</View>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The web `DropdownMenuSeparator` between groups of menu rows. */
|
|
78
|
+
export function MenuDivider() {
|
|
79
|
+
return <View className="mx-4 my-1 h-px" style={{ backgroundColor: tokens.color.border[useScheme()] }} />;
|
|
80
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { Pressable, View } from "react-native";
|
|
3
|
+
import { palette, withAlpha } from "./palette";
|
|
4
|
+
import { useScheme } from "./useScheme";
|
|
5
|
+
|
|
6
|
+
/** One round toggle: its key, its screen-reader label, its content (an emoji `Text` or an icon) and whether it is on. */
|
|
7
|
+
export type ReactionRowItem = {
|
|
8
|
+
key: string;
|
|
9
|
+
label: string;
|
|
10
|
+
selected?: boolean;
|
|
11
|
+
/** The content, given whether it is on, so an icon can switch to its filled form or colour. */
|
|
12
|
+
render: (selected: boolean) => ReactNode;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type ReactionRowProps = {
|
|
16
|
+
items: readonly ReactionRowItem[];
|
|
17
|
+
onPress: (key: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* How an item that is on looks. `"tint"` (default): the primary at 12%,
|
|
20
|
+
* for emoji, which a dark fill would hide. `"solid"`: the primary fill,
|
|
21
|
+
* for icons, whose colour the caller sets with `render`.
|
|
22
|
+
*/
|
|
23
|
+
selectedStyle?: "tint" | "solid";
|
|
24
|
+
/** `"spread"` (default) shares the width, as a reaction bar; `"start"` packs them at the start. */
|
|
25
|
+
layout?: "spread" | "start";
|
|
26
|
+
/** After the items: a round button with the same look, such as "More reactions". */
|
|
27
|
+
trailing?: { label: string; icon: ReactNode; onPress: () => void };
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The quick reactions at the top of a hold menu (`MenuSheet`): round 44
|
|
32
|
+
* toggles, each one on or off. Emoji reactions use the tint, a reply's
|
|
33
|
+
* thumbs the solid fill.
|
|
34
|
+
*/
|
|
35
|
+
export function ReactionRow({ items, onPress, selectedStyle = "tint", layout = "spread", trailing }: ReactionRowProps) {
|
|
36
|
+
const scheme = useScheme();
|
|
37
|
+
const fill = (selected: boolean) =>
|
|
38
|
+
!selected ? palette.default[scheme] : selectedStyle === "solid" ? palette.primary[scheme] : withAlpha(palette.primary[scheme], 0.12);
|
|
39
|
+
return (
|
|
40
|
+
<View className={layout === "spread" ? "flex-row justify-between px-2 pb-2" : "flex-row gap-3 px-4 py-2"}>
|
|
41
|
+
{items.map((item) => {
|
|
42
|
+
const selected = item.selected === true;
|
|
43
|
+
return (
|
|
44
|
+
<Pressable
|
|
45
|
+
key={item.key}
|
|
46
|
+
accessibilityRole="button"
|
|
47
|
+
accessibilityLabel={item.label}
|
|
48
|
+
accessibilityState={{ selected }}
|
|
49
|
+
onPress={() => onPress(item.key)}
|
|
50
|
+
className="size-11 items-center justify-center rounded-full active:opacity-70"
|
|
51
|
+
style={{ backgroundColor: fill(selected) }}
|
|
52
|
+
>
|
|
53
|
+
{item.render(selected)}
|
|
54
|
+
</Pressable>
|
|
55
|
+
);
|
|
56
|
+
})}
|
|
57
|
+
{trailing ? (
|
|
58
|
+
<Pressable
|
|
59
|
+
accessibilityRole="button"
|
|
60
|
+
accessibilityLabel={trailing.label}
|
|
61
|
+
onPress={trailing.onPress}
|
|
62
|
+
className="size-11 items-center justify-center rounded-full active:opacity-70"
|
|
63
|
+
style={{ backgroundColor: fill(false) }}
|
|
64
|
+
>
|
|
65
|
+
{trailing.icon}
|
|
66
|
+
</Pressable>
|
|
67
|
+
) : null}
|
|
68
|
+
</View>
|
|
69
|
+
);
|
|
70
|
+
}
|
package/src/ai/index.ts
CHANGED
|
@@ -60,6 +60,9 @@ export type {
|
|
|
60
60
|
} from "./message";
|
|
61
61
|
export { MessageActionSheet } from "./message-action-sheet";
|
|
62
62
|
export type { MessageActionSheetProps, MessageSheetAction } from "./message-action-sheet";
|
|
63
|
+
export { MessageContextMenu } from "./message-context-menu";
|
|
64
|
+
export { messageContextMenuLayout, MESSAGE_MENU } from "./message-menu-layout";
|
|
65
|
+
export type { MessageMenu, MessageMenuRect } from "./message-menu-layout";
|
|
63
66
|
export { ReplyQuoteChip } from "./reply-quote-chip";
|
|
64
67
|
export type { ReplyQuoteChipProps } from "./reply-quote-chip";
|
|
65
68
|
export { MessageQuote, QUOTE_MAX_LINES } from "./message-quote";
|
|
@@ -20,6 +20,8 @@ export type MessageSheetAction = {
|
|
|
20
20
|
icon?: ComponentType<IconProps>;
|
|
21
21
|
/** Draws the row in the danger colour, such as Delete. */
|
|
22
22
|
destructive?: boolean;
|
|
23
|
+
/** Dims the row and ignores presses (the context menu's rows; the sheet leaves a disabled action out). */
|
|
24
|
+
disabled?: boolean;
|
|
23
25
|
onPress: () => void;
|
|
24
26
|
};
|
|
25
27
|
|