@vvedantb/native-ui 0.25.2 → 0.26.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/dist/FloatingTabBar.jsx +66 -56
- package/dist/SheetRow.jsx +102 -101
- package/dist/ai/message-context-menu.jsx +59 -66
- package/dist/ai/message.jsx +5 -4
- package/dist/ai/prompt-input.jsx +76 -38
- package/dist/ai/sources.jsx +37 -37
- package/dist/ai/suggestion.jsx +42 -40
- package/dist/entries/paste-input.js +4 -0
- package/dist/primitives/paste-input.jsx +63 -0
- package/dist/primitives/paste-parts.jsx +18 -0
- package/dist/usePressed.js +38 -0
- package/package.json +12 -3
- package/src/FloatingTabBar.tsx +5 -1
- package/src/SheetRow.tsx +7 -3
- package/src/ai/message-context-menu.tsx +6 -5
- package/src/ai/message.tsx +5 -4
- package/src/ai/prompt-input.tsx +89 -50
- package/src/ai/sources.tsx +7 -3
- package/src/ai/suggestion.tsx +7 -3
- package/src/entries/paste-input.ts +4 -0
- package/src/primitives/paste-input.tsx +29 -0
- package/src/primitives/paste-parts.tsx +27 -0
- package/src/usePressed.ts +13 -0
package/dist/ai/prompt-input.jsx
CHANGED
|
@@ -9,6 +9,7 @@ import { withAlpha } from "../palette";
|
|
|
9
9
|
import { tokens } from "../tokens";
|
|
10
10
|
import { Input as FieldInput } from "../primitives/input";
|
|
11
11
|
import { COMPOSER_INPUT_ID, KeyboardAvoidingView, KeyboardLiftContext } from "../primitives/keyboard-parts";
|
|
12
|
+
import { usePasteParts } from "../primitives/paste-parts";
|
|
12
13
|
import { usePressFeedback } from "../motion";
|
|
13
14
|
import { useControllableState } from "../primitives/use-controllable-state";
|
|
14
15
|
import { useLargerText } from "../theme";
|
|
@@ -381,7 +382,7 @@ const ONE_ROW = Platform.OS === "web" ? 1 : undefined;
|
|
|
381
382
|
* with `KeyboardControllerProvider`, `ChatThread`) it adds no lift of its own.
|
|
382
383
|
*/
|
|
383
384
|
export function PromptInput(t0) {
|
|
384
|
-
const $ = _c(
|
|
385
|
+
const $ = _c(67);
|
|
385
386
|
const {
|
|
386
387
|
value,
|
|
387
388
|
defaultValue: t1,
|
|
@@ -396,6 +397,7 @@ export function PromptInput(t0) {
|
|
|
396
397
|
toolbar,
|
|
397
398
|
footer,
|
|
398
399
|
menu,
|
|
400
|
+
onPasteImages,
|
|
399
401
|
layout: t4,
|
|
400
402
|
shape: t5,
|
|
401
403
|
leading,
|
|
@@ -417,6 +419,8 @@ export function PromptInput(t0) {
|
|
|
417
419
|
const largerText = useLargerText();
|
|
418
420
|
const insets = useSafeAreaInsets();
|
|
419
421
|
const lifted = useContext(KeyboardLiftContext);
|
|
422
|
+
const paste = usePasteParts();
|
|
423
|
+
const pasteTarget = paste && onPasteImages ? paste.Target : null;
|
|
420
424
|
let t9;
|
|
421
425
|
if ($[0] !== defaultValue || $[1] !== onChangeText || $[2] !== value) {
|
|
422
426
|
t9 = {
|
|
@@ -550,7 +554,7 @@ export function PromptInput(t0) {
|
|
|
550
554
|
t21 = $[31];
|
|
551
555
|
}
|
|
552
556
|
let t22;
|
|
553
|
-
if ($[32] !== accessibilityLabel || $[33] !== canSubmit || $[34] !== changeText || $[35] !== disabled || $[36] !== fieldText || $[37] !== growStyle || $[38] !== header || $[39] !== largerText || $[40] !== layout || $[41] !== leading || $[42] !== maxHeight || $[43] !==
|
|
557
|
+
if ($[32] !== accessibilityLabel || $[33] !== canSubmit || $[34] !== changeText || $[35] !== disabled || $[36] !== fieldText || $[37] !== growStyle || $[38] !== header || $[39] !== largerText || $[40] !== layout || $[41] !== leading || $[42] !== maxHeight || $[43] !== onPasteImages || $[44] !== onStop || $[45] !== pasteTarget || $[46] !== pill || $[47] !== placeholder || $[48] !== replyTo || $[49] !== scheme || $[50] !== scrollEnabled || $[51] !== status || $[52] !== submit || $[53] !== testID || $[54] !== text || $[55] !== toolbar) {
|
|
554
558
|
t22 = layout === "inline" ? <View className="border" style={[fieldStyle(scheme), {
|
|
555
559
|
borderRadius: pill ? PILL.radius : INLINE_RADIUS
|
|
556
560
|
}]}>{replyTo ? <View className="px-1.5 pt-1.5">{replyTo}</View> : null}{header ? <View className="flex-row flex-wrap gap-1 px-1.5 pt-1.5">{header}</View> : null}<View className={cn("flex-row items-end gap-1", !pill && "p-1.5")} style={pill ? {
|
|
@@ -558,17 +562,17 @@ export function PromptInput(t0) {
|
|
|
558
562
|
paddingHorizontal: PILL.paddingX
|
|
559
563
|
} : null}>{leading ? <View className="shrink-0 flex-row items-center gap-1" style={pill ? {
|
|
560
564
|
minHeight: PILL.lineHeight
|
|
561
|
-
} : null}>{leading}</View> : null}<FieldInput testID={testID ? `${testID}-input` : undefined} nativeID={COMPOSER_INPUT_ID} multiline={true} numberOfLines={ONE_ROW} value={text} onChangeText={changeText} placeholder={placeholder} placeholderTextColor={pill ? withAlpha(tokens.color.muted[scheme], PILL.placeholderAlpha) : undefined} accessibilityLabel={accessibilityLabel} editable={!disabled} textAlignVertical="center" scrollEnabled={scrollEnabled} onContentSizeChange={e => setContentHeight(e.nativeEvent.contentSize.height)} className={cn("flex-1 border-0 text-sm font-instrument-sans", pill ? "min-h-9 px-1 py-2" : "min-h-8 px-2 py-1", largerText && "min-h-11 py-2 text-xl font-instrument-sans-medium")} style={[fieldTextStyle(scheme), fieldText, largerText ? typeStyle("medium") : null, {
|
|
565
|
+
} : null}>{leading}</View> : null}<PasteTarget target={pasteTarget} onPasteImages={onPasteImages} style={PASTE_TARGET_INLINE}><FieldInput testID={testID ? `${testID}-input` : undefined} nativeID={COMPOSER_INPUT_ID} multiline={true} numberOfLines={ONE_ROW} value={text} onChangeText={changeText} placeholder={placeholder} placeholderTextColor={pill ? withAlpha(tokens.color.muted[scheme], PILL.placeholderAlpha) : undefined} accessibilityLabel={accessibilityLabel} editable={!disabled} textAlignVertical="center" scrollEnabled={scrollEnabled} onContentSizeChange={e => setContentHeight(e.nativeEvent.contentSize.height)} className={cn(pasteTarget ? "border-0 text-sm font-instrument-sans" : "flex-1 border-0 text-sm font-instrument-sans", pill ? "min-h-9 px-1 py-2" : "min-h-8 px-2 py-1", largerText && "min-h-11 py-2 text-xl font-instrument-sans-medium")} style={[fieldTextStyle(scheme), fieldText, largerText ? typeStyle("medium") : null, {
|
|
566
|
+
backgroundColor: "transparent",
|
|
567
|
+
maxHeight,
|
|
568
|
+
...growStyle
|
|
569
|
+
}]} /></PasteTarget><View className="shrink-0 flex-row items-center gap-1" style={pill ? {
|
|
570
|
+
minHeight: PILL.lineHeight
|
|
571
|
+
} : null}>{toolbar}<PromptInputSubmit status={status} onSubmit={submit} onStop={onStop} canSubmit={canSubmit} size={pill ? "md" : undefined} /></View></View></View> : <View className="border" style={fieldStyle(scheme)}>{replyTo ? <View className="px-2 pt-2">{replyTo}</View> : null}{header ? <View className="flex-row flex-wrap gap-1 px-2 pt-2">{header}</View> : null}<PasteTarget target={pasteTarget} onPasteImages={onPasteImages}><FieldInput testID={testID ? `${testID}-input` : undefined} nativeID={COMPOSER_INPUT_ID} multiline={true} numberOfLines={ONE_ROW} value={text} onChangeText={changeText} placeholder={placeholder} accessibilityLabel={accessibilityLabel} editable={!disabled} textAlignVertical="top" scrollEnabled={scrollEnabled} onContentSizeChange={e_0 => setContentHeight(e_0.nativeEvent.contentSize.height)} className={cn("min-h-11 border-0 px-3.5 py-2.5 text-base font-instrument-sans", largerText && "min-h-14 px-4 py-3 text-xl font-instrument-sans-medium")} style={[fieldTextStyle(scheme), fieldText, largerText ? typeStyle("medium") : null, {
|
|
562
572
|
backgroundColor: "transparent",
|
|
563
573
|
maxHeight,
|
|
564
574
|
...growStyle
|
|
565
|
-
}]}
|
|
566
|
-
minHeight: PILL.lineHeight
|
|
567
|
-
} : null}>{toolbar}<PromptInputSubmit status={status} onSubmit={submit} onStop={onStop} canSubmit={canSubmit} size={pill ? "md" : undefined} /></View></View></View> : <View className="border" style={fieldStyle(scheme)}>{replyTo ? <View className="px-2 pt-2">{replyTo}</View> : null}{header ? <View className="flex-row flex-wrap gap-1 px-2 pt-2">{header}</View> : null}<FieldInput testID={testID ? `${testID}-input` : undefined} nativeID={COMPOSER_INPUT_ID} multiline={true} numberOfLines={ONE_ROW} value={text} onChangeText={changeText} placeholder={placeholder} accessibilityLabel={accessibilityLabel} editable={!disabled} textAlignVertical="top" scrollEnabled={scrollEnabled} onContentSizeChange={e_0 => setContentHeight(e_0.nativeEvent.contentSize.height)} className={cn("min-h-11 border-0 px-3.5 py-2.5 text-base font-instrument-sans", largerText && "min-h-14 px-4 py-3 text-xl font-instrument-sans-medium")} style={[fieldTextStyle(scheme), fieldText, largerText ? typeStyle("medium") : null, {
|
|
568
|
-
backgroundColor: "transparent",
|
|
569
|
-
maxHeight,
|
|
570
|
-
...growStyle
|
|
571
|
-
}]} /><View className="flex-row items-center justify-between gap-1 px-2 pb-2"><View className="min-w-0 shrink flex-row items-center gap-1">{toolbar}</View><PromptInputSubmit status={status} onSubmit={submit} onStop={onStop} canSubmit={canSubmit} /></View></View>;
|
|
575
|
+
}]} /></PasteTarget><View className="flex-row items-center justify-between gap-1 px-2 pb-2"><View className="min-w-0 shrink flex-row items-center gap-1">{toolbar}</View><PromptInputSubmit status={status} onSubmit={submit} onStop={onStop} canSubmit={canSubmit} /></View></View>;
|
|
572
576
|
$[32] = accessibilityLabel;
|
|
573
577
|
$[33] = canSubmit;
|
|
574
578
|
$[34] = changeText;
|
|
@@ -580,33 +584,35 @@ export function PromptInput(t0) {
|
|
|
580
584
|
$[40] = layout;
|
|
581
585
|
$[41] = leading;
|
|
582
586
|
$[42] = maxHeight;
|
|
583
|
-
$[43] =
|
|
584
|
-
$[44] =
|
|
585
|
-
$[45] =
|
|
586
|
-
$[46] =
|
|
587
|
-
$[47] =
|
|
588
|
-
$[48] =
|
|
589
|
-
$[49] =
|
|
590
|
-
$[50] =
|
|
591
|
-
$[51] =
|
|
592
|
-
$[52] =
|
|
593
|
-
$[53] =
|
|
594
|
-
$[54] =
|
|
595
|
-
|
|
596
|
-
|
|
587
|
+
$[43] = onPasteImages;
|
|
588
|
+
$[44] = onStop;
|
|
589
|
+
$[45] = pasteTarget;
|
|
590
|
+
$[46] = pill;
|
|
591
|
+
$[47] = placeholder;
|
|
592
|
+
$[48] = replyTo;
|
|
593
|
+
$[49] = scheme;
|
|
594
|
+
$[50] = scrollEnabled;
|
|
595
|
+
$[51] = status;
|
|
596
|
+
$[52] = submit;
|
|
597
|
+
$[53] = testID;
|
|
598
|
+
$[54] = text;
|
|
599
|
+
$[55] = toolbar;
|
|
600
|
+
$[56] = t22;
|
|
601
|
+
} else {
|
|
602
|
+
t22 = $[56];
|
|
597
603
|
}
|
|
598
604
|
let t23;
|
|
599
|
-
if ($[
|
|
605
|
+
if ($[57] !== footer || $[58] !== t16 || $[59] !== t20 || $[60] !== t21 || $[61] !== t22 || $[62] !== testID) {
|
|
600
606
|
t23 = <View testID={testID} className={t16} style={t20}>{t21}{t22}{footer}</View>;
|
|
601
|
-
$[
|
|
602
|
-
$[
|
|
603
|
-
$[
|
|
604
|
-
$[
|
|
605
|
-
$[
|
|
606
|
-
$[
|
|
607
|
-
$[
|
|
607
|
+
$[57] = footer;
|
|
608
|
+
$[58] = t16;
|
|
609
|
+
$[59] = t20;
|
|
610
|
+
$[60] = t21;
|
|
611
|
+
$[61] = t22;
|
|
612
|
+
$[62] = testID;
|
|
613
|
+
$[63] = t23;
|
|
608
614
|
} else {
|
|
609
|
-
t23 = $[
|
|
615
|
+
t23 = $[63];
|
|
610
616
|
}
|
|
611
617
|
const composer = t23;
|
|
612
618
|
if (lifted) {
|
|
@@ -614,13 +620,45 @@ export function PromptInput(t0) {
|
|
|
614
620
|
}
|
|
615
621
|
const t24 = keyboardVerticalOffset - bottom;
|
|
616
622
|
let t25;
|
|
617
|
-
if ($[
|
|
623
|
+
if ($[64] !== composer || $[65] !== t24) {
|
|
618
624
|
t25 = <KeyboardAvoidingView keyboardVerticalOffset={t24}>{composer}</KeyboardAvoidingView>;
|
|
619
|
-
$[
|
|
620
|
-
$[
|
|
621
|
-
$[
|
|
625
|
+
$[64] = composer;
|
|
626
|
+
$[65] = t24;
|
|
627
|
+
$[66] = t25;
|
|
622
628
|
} else {
|
|
623
|
-
t25 = $[
|
|
629
|
+
t25 = $[66];
|
|
624
630
|
}
|
|
625
631
|
return t25;
|
|
626
632
|
}
|
|
633
|
+
|
|
634
|
+
/** In the inline row the paste target takes the field's place: it grows across, and the field fills it. */
|
|
635
|
+
const PASTE_TARGET_INLINE = {
|
|
636
|
+
flex: 1,
|
|
637
|
+
minWidth: 0
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
/** The field inside the app's paste target (`PasteInputProvider`), or the field alone. */
|
|
641
|
+
function PasteTarget(t0) {
|
|
642
|
+
const $ = _c(5);
|
|
643
|
+
const {
|
|
644
|
+
target: Target,
|
|
645
|
+
onPasteImages,
|
|
646
|
+
style,
|
|
647
|
+
children
|
|
648
|
+
} = t0;
|
|
649
|
+
if (!Target || !onPasteImages) {
|
|
650
|
+
return children;
|
|
651
|
+
}
|
|
652
|
+
let t1;
|
|
653
|
+
if ($[0] !== Target || $[1] !== children || $[2] !== onPasteImages || $[3] !== style) {
|
|
654
|
+
t1 = <Target onPasteImages={onPasteImages} style={style}>{children}</Target>;
|
|
655
|
+
$[0] = Target;
|
|
656
|
+
$[1] = children;
|
|
657
|
+
$[2] = onPasteImages;
|
|
658
|
+
$[3] = style;
|
|
659
|
+
$[4] = t1;
|
|
660
|
+
} else {
|
|
661
|
+
t1 = $[4];
|
|
662
|
+
}
|
|
663
|
+
return t1;
|
|
664
|
+
}
|
package/dist/ai/sources.jsx
CHANGED
|
@@ -8,6 +8,7 @@ import { tokens } from "../tokens";
|
|
|
8
8
|
import { useScheme } from "../useScheme";
|
|
9
9
|
import { Collapsible, CollapsibleChevron, CollapsibleContent, CollapsibleTrigger, useCollapsible } from "./collapsible";
|
|
10
10
|
import { ResponseText } from "./response-text";
|
|
11
|
+
import { usePressed } from "../usePressed";
|
|
11
12
|
|
|
12
13
|
/** The sources a reply used, folded (default closed). */
|
|
13
14
|
export function Sources(t0) {
|
|
@@ -182,13 +183,14 @@ const ROW_HEIGHT = 36;
|
|
|
182
183
|
* Pressed, it takes the web hover fill (`bg-surface-secondary`).
|
|
183
184
|
*/
|
|
184
185
|
export function Source(t0) {
|
|
185
|
-
const $ = _c(
|
|
186
|
+
const $ = _c(20);
|
|
186
187
|
const {
|
|
187
188
|
href,
|
|
188
189
|
title,
|
|
189
190
|
onPress,
|
|
190
191
|
testID
|
|
191
192
|
} = t0;
|
|
193
|
+
const press = usePressed();
|
|
192
194
|
const scheme = useScheme();
|
|
193
195
|
const largerText = useLargerText();
|
|
194
196
|
const label = title ?? href;
|
|
@@ -208,53 +210,51 @@ export function Source(t0) {
|
|
|
208
210
|
} else {
|
|
209
211
|
t2 = $[3];
|
|
210
212
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return {
|
|
218
|
-
borderRadius: tokens.radius.md,
|
|
219
|
-
backgroundColor: pressed ? tokens.color.surfaceSecondary[scheme] : "transparent"
|
|
220
|
-
};
|
|
213
|
+
const t3 = press.pressed ? tokens.color.surfaceSecondary[scheme] : "transparent";
|
|
214
|
+
let t4;
|
|
215
|
+
if ($[4] !== t3) {
|
|
216
|
+
t4 = {
|
|
217
|
+
borderRadius: tokens.radius.md,
|
|
218
|
+
backgroundColor: t3
|
|
221
219
|
};
|
|
222
|
-
$[4] =
|
|
223
|
-
$[5] =
|
|
220
|
+
$[4] = t3;
|
|
221
|
+
$[5] = t4;
|
|
224
222
|
} else {
|
|
225
|
-
|
|
223
|
+
t4 = $[5];
|
|
226
224
|
}
|
|
227
|
-
let
|
|
225
|
+
let t5;
|
|
228
226
|
if ($[6] !== label) {
|
|
229
|
-
|
|
227
|
+
t5 = <ResponseText size="small" tone="muted" selectable={false} numberOfLines={1} className="shrink">{label}</ResponseText>;
|
|
230
228
|
$[6] = label;
|
|
231
|
-
$[7] =
|
|
229
|
+
$[7] = t5;
|
|
232
230
|
} else {
|
|
233
|
-
|
|
231
|
+
t5 = $[7];
|
|
234
232
|
}
|
|
235
|
-
const
|
|
236
|
-
const
|
|
237
|
-
let
|
|
238
|
-
if ($[8] !==
|
|
239
|
-
|
|
240
|
-
$[8] =
|
|
241
|
-
$[9] =
|
|
242
|
-
$[10] =
|
|
233
|
+
const t6 = largerText ? 18 : 14;
|
|
234
|
+
const t7 = tokens.color.muted[scheme];
|
|
235
|
+
let t8;
|
|
236
|
+
if ($[8] !== t6 || $[9] !== t7) {
|
|
237
|
+
t8 = <IconBook size={t6} color={t7} strokeWidth={1.5} />;
|
|
238
|
+
$[8] = t6;
|
|
239
|
+
$[9] = t7;
|
|
240
|
+
$[10] = t8;
|
|
243
241
|
} else {
|
|
244
|
-
|
|
242
|
+
t8 = $[10];
|
|
245
243
|
}
|
|
246
|
-
let
|
|
247
|
-
if ($[11] !== label || $[12] !==
|
|
248
|
-
|
|
244
|
+
let t9;
|
|
245
|
+
if ($[11] !== label || $[12] !== press.onPressIn || $[13] !== press.onPressOut || $[14] !== t2 || $[15] !== t4 || $[16] !== t5 || $[17] !== t8 || $[18] !== testID) {
|
|
246
|
+
t9 = <Pressable testID={testID} accessibilityRole="link" accessibilityLabel={label} hitSlop={t1} onPress={t2} onPressIn={press.onPressIn} onPressOut={press.onPressOut} className="flex-row items-center justify-between gap-2 px-3 py-2" style={t4}>{t5}{t8}</Pressable>;
|
|
249
247
|
$[11] = label;
|
|
250
|
-
$[12] =
|
|
251
|
-
$[13] =
|
|
252
|
-
$[14] =
|
|
253
|
-
$[15] =
|
|
254
|
-
$[16] =
|
|
248
|
+
$[12] = press.onPressIn;
|
|
249
|
+
$[13] = press.onPressOut;
|
|
250
|
+
$[14] = t2;
|
|
251
|
+
$[15] = t4;
|
|
252
|
+
$[16] = t5;
|
|
255
253
|
$[17] = t8;
|
|
254
|
+
$[18] = testID;
|
|
255
|
+
$[19] = t9;
|
|
256
256
|
} else {
|
|
257
|
-
|
|
257
|
+
t9 = $[19];
|
|
258
258
|
}
|
|
259
|
-
return
|
|
259
|
+
return t9;
|
|
260
260
|
}
|
package/dist/ai/suggestion.jsx
CHANGED
|
@@ -7,6 +7,7 @@ import { useLargerText } from "../theme";
|
|
|
7
7
|
import { tokens } from "../tokens";
|
|
8
8
|
import { useScheme } from "../useScheme";
|
|
9
9
|
import { chatTextSize } from "./chat-text";
|
|
10
|
+
import { usePressed } from "../usePressed";
|
|
10
11
|
/**
|
|
11
12
|
* Prompt suggestions. Horizontal is a `ScrollView` with no scroll bar (the web
|
|
12
13
|
* row with its scroll arrows; a phone swipes instead).
|
|
@@ -77,7 +78,7 @@ const CHIP_HEIGHT = 32;
|
|
|
77
78
|
* it takes the web hover (`bg-surface-tertiary text-foreground`).
|
|
78
79
|
*/
|
|
79
80
|
export function Suggestion(t0) {
|
|
80
|
-
const $ = _c(
|
|
81
|
+
const $ = _c(30);
|
|
81
82
|
const {
|
|
82
83
|
suggestion,
|
|
83
84
|
onPress,
|
|
@@ -85,6 +86,7 @@ export function Suggestion(t0) {
|
|
|
85
86
|
disabled,
|
|
86
87
|
testID
|
|
87
88
|
} = t0;
|
|
89
|
+
const press = usePressed();
|
|
88
90
|
const scheme = useScheme();
|
|
89
91
|
const largerText = useLargerText();
|
|
90
92
|
let t1;
|
|
@@ -134,53 +136,53 @@ export function Suggestion(t0) {
|
|
|
134
136
|
} else {
|
|
135
137
|
t8 = $[10];
|
|
136
138
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
borderColor: tokens.color.border[scheme],
|
|
146
|
-
backgroundColor: pressed ? palette.surfaceTertiary[scheme] : tokens.color.surfaceSecondary[scheme]
|
|
147
|
-
};
|
|
139
|
+
const t9 = tokens.color.border[scheme];
|
|
140
|
+
const t10 = press.pressed ? palette.surfaceTertiary[scheme] : tokens.color.surfaceSecondary[scheme];
|
|
141
|
+
let t11;
|
|
142
|
+
if ($[11] !== t10 || $[12] !== t9) {
|
|
143
|
+
t11 = {
|
|
144
|
+
borderRadius: tokens.radius.pill,
|
|
145
|
+
borderColor: t9,
|
|
146
|
+
backgroundColor: t10
|
|
148
147
|
};
|
|
149
|
-
$[11] =
|
|
148
|
+
$[11] = t10;
|
|
150
149
|
$[12] = t9;
|
|
150
|
+
$[13] = t11;
|
|
151
151
|
} else {
|
|
152
|
-
|
|
152
|
+
t11 = $[13];
|
|
153
153
|
}
|
|
154
|
-
let
|
|
155
|
-
if ($[
|
|
156
|
-
|
|
154
|
+
let t12;
|
|
155
|
+
if ($[14] !== children || $[15] !== scheme || $[16] !== size || $[17] !== suggestion) {
|
|
156
|
+
t12 = t13 => {
|
|
157
157
|
const {
|
|
158
|
-
pressed
|
|
159
|
-
} =
|
|
160
|
-
return <Text className={cn(size, "font-instrument-sans")} style={[sizeStyle(size), textStyle(
|
|
158
|
+
pressed
|
|
159
|
+
} = t13;
|
|
160
|
+
return <Text className={cn(size, "font-instrument-sans")} style={[sizeStyle(size), textStyle(pressed ? "foreground" : "muted", scheme)]}>{children ?? suggestion}</Text>;
|
|
161
161
|
};
|
|
162
|
-
$[
|
|
163
|
-
$[
|
|
164
|
-
$[
|
|
165
|
-
$[
|
|
166
|
-
$[
|
|
162
|
+
$[14] = children;
|
|
163
|
+
$[15] = scheme;
|
|
164
|
+
$[16] = size;
|
|
165
|
+
$[17] = suggestion;
|
|
166
|
+
$[18] = t12;
|
|
167
167
|
} else {
|
|
168
|
-
|
|
168
|
+
t12 = $[18];
|
|
169
169
|
}
|
|
170
|
-
let
|
|
171
|
-
if ($[
|
|
172
|
-
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
175
|
-
$[
|
|
176
|
-
$[
|
|
177
|
-
$[
|
|
178
|
-
$[
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
170
|
+
let t13;
|
|
171
|
+
if ($[19] !== disabled || $[20] !== press.onPressIn || $[21] !== press.onPressOut || $[22] !== suggestion || $[23] !== t11 || $[24] !== t12 || $[25] !== t3 || $[26] !== t5 || $[27] !== t8 || $[28] !== testID) {
|
|
172
|
+
t13 = <Pressable testID={testID} accessibilityRole="button" accessibilityLabel={suggestion} accessibilityState={t3} disabled={disabled} hitSlop={t4} onPress={t5} className={t8} onPressIn={press.onPressIn} onPressOut={press.onPressOut} style={t11}>{t12}</Pressable>;
|
|
173
|
+
$[19] = disabled;
|
|
174
|
+
$[20] = press.onPressIn;
|
|
175
|
+
$[21] = press.onPressOut;
|
|
176
|
+
$[22] = suggestion;
|
|
177
|
+
$[23] = t11;
|
|
178
|
+
$[24] = t12;
|
|
179
|
+
$[25] = t3;
|
|
180
|
+
$[26] = t5;
|
|
181
|
+
$[27] = t8;
|
|
182
|
+
$[28] = testID;
|
|
183
|
+
$[29] = t13;
|
|
182
184
|
} else {
|
|
183
|
-
|
|
185
|
+
t13 = $[29];
|
|
184
186
|
}
|
|
185
|
-
return
|
|
187
|
+
return t13;
|
|
186
188
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { TextInputWrapper } from "expo-paste-input";
|
|
3
|
+
import { PastePartsContext } from "./paste-parts";
|
|
4
|
+
|
|
5
|
+
// The image paste on `expo-paste-input`: on Android an `OnReceiveContentListener`
|
|
6
|
+
// on the wrapped field (Paste, and the keyboard's image insert), on iOS the
|
|
7
|
+
// field's `paste(_:)` and keyboard stickers. Text paste stays the field's own.
|
|
8
|
+
|
|
9
|
+
const Target = t0 => {
|
|
10
|
+
const $ = _c(6);
|
|
11
|
+
const {
|
|
12
|
+
onPasteImages,
|
|
13
|
+
style,
|
|
14
|
+
children
|
|
15
|
+
} = t0;
|
|
16
|
+
let t1;
|
|
17
|
+
if ($[0] !== onPasteImages) {
|
|
18
|
+
t1 = payload => {
|
|
19
|
+
if (payload.type === "images" && payload.uris.length > 0) {
|
|
20
|
+
onPasteImages(payload.uris);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
$[0] = onPasteImages;
|
|
24
|
+
$[1] = t1;
|
|
25
|
+
} else {
|
|
26
|
+
t1 = $[1];
|
|
27
|
+
}
|
|
28
|
+
let t2;
|
|
29
|
+
if ($[2] !== children || $[3] !== style || $[4] !== t1) {
|
|
30
|
+
t2 = <TextInputWrapper style={style} onPaste={t1}>{children}</TextInputWrapper>;
|
|
31
|
+
$[2] = children;
|
|
32
|
+
$[3] = style;
|
|
33
|
+
$[4] = t1;
|
|
34
|
+
$[5] = t2;
|
|
35
|
+
} else {
|
|
36
|
+
t2 = $[5];
|
|
37
|
+
}
|
|
38
|
+
return t2;
|
|
39
|
+
};
|
|
40
|
+
const PARTS = {
|
|
41
|
+
Target
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Image paste for the kit's text fields (`PromptInput` `onPasteImages`). Wrap
|
|
46
|
+
* the app once, under `ThemeProvider`. Needs `expo-paste-input` and a native
|
|
47
|
+
* build (not Expo Go); on the web it does nothing.
|
|
48
|
+
*/
|
|
49
|
+
export function PasteInputProvider(t0) {
|
|
50
|
+
const $ = _c(2);
|
|
51
|
+
const {
|
|
52
|
+
children
|
|
53
|
+
} = t0;
|
|
54
|
+
let t1;
|
|
55
|
+
if ($[0] !== children) {
|
|
56
|
+
t1 = <PastePartsContext.Provider value={PARTS}>{children}</PastePartsContext.Provider>;
|
|
57
|
+
$[0] = children;
|
|
58
|
+
$[1] = t1;
|
|
59
|
+
} else {
|
|
60
|
+
t1 = $[1];
|
|
61
|
+
}
|
|
62
|
+
return t1;
|
|
63
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `expo-paste-input` build of a text field's image paste, from
|
|
5
|
+
* `@vvedantb/native-ui/paste-input`. React Native's `TextInput` takes no
|
|
6
|
+
* pasted image: the long-press Paste and the keyboard's image insert (Gboard's
|
|
7
|
+
* clipboard, stickers) do nothing. `Target` wraps a field so they hand the
|
|
8
|
+
* images over as local file URIs. Without it (the peer is optional, and needs
|
|
9
|
+
* a native build) a field keeps text paste only. A context, so only that entry
|
|
10
|
+
* imports the peer and an app without it bundles as before.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const PastePartsContext = createContext(null);
|
|
14
|
+
|
|
15
|
+
/** The image paste parts from `PasteInputProvider`, or null without it. */
|
|
16
|
+
export function usePasteParts() {
|
|
17
|
+
return useContext(PastePartsContext);
|
|
18
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Whether a `Pressable` is held down, as state, for a pressed look. With a
|
|
6
|
+
* `className`, NativeWind drops a `Pressable` style function (`({ pressed })
|
|
7
|
+
* => ...`), and with it the radius, border and fill it sets; so a pressable
|
|
8
|
+
* with classes reads `pressed` from here and passes a plain style. Spread
|
|
9
|
+
* `onPressIn` and `onPressOut` on the `Pressable`.
|
|
10
|
+
*/
|
|
11
|
+
export function usePressed() {
|
|
12
|
+
const $ = _c(4);
|
|
13
|
+
const [pressed, setPressed] = useState(false);
|
|
14
|
+
let t0;
|
|
15
|
+
let t1;
|
|
16
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
17
|
+
t0 = () => setPressed(true);
|
|
18
|
+
t1 = () => setPressed(false);
|
|
19
|
+
$[0] = t0;
|
|
20
|
+
$[1] = t1;
|
|
21
|
+
} else {
|
|
22
|
+
t0 = $[0];
|
|
23
|
+
t1 = $[1];
|
|
24
|
+
}
|
|
25
|
+
let t2;
|
|
26
|
+
if ($[2] !== pressed) {
|
|
27
|
+
t2 = {
|
|
28
|
+
pressed,
|
|
29
|
+
onPressIn: t0,
|
|
30
|
+
onPressOut: t1
|
|
31
|
+
};
|
|
32
|
+
$[2] = pressed;
|
|
33
|
+
$[3] = t2;
|
|
34
|
+
} else {
|
|
35
|
+
t2 = $[3];
|
|
36
|
+
}
|
|
37
|
+
return t2;
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/native-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
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",
|
|
@@ -99,6 +99,11 @@
|
|
|
99
99
|
"source": "./src/entries/keyboard-controller.ts",
|
|
100
100
|
"default": "./dist/entries/keyboard-controller.js"
|
|
101
101
|
},
|
|
102
|
+
"./paste-input": {
|
|
103
|
+
"types": "./src/entries/paste-input.ts",
|
|
104
|
+
"source": "./src/entries/paste-input.ts",
|
|
105
|
+
"default": "./dist/entries/paste-input.js"
|
|
106
|
+
},
|
|
102
107
|
"./video": {
|
|
103
108
|
"types": "./src/entries/video.ts",
|
|
104
109
|
"source": "./src/entries/video.ts",
|
|
@@ -184,6 +189,7 @@
|
|
|
184
189
|
],
|
|
185
190
|
"sideEffects": false,
|
|
186
191
|
"peerDependencies": {
|
|
192
|
+
"expo-paste-input": ">=0.2.0",
|
|
187
193
|
"@clerk/clerk-expo": "*",
|
|
188
194
|
"@expo/vector-icons": "*",
|
|
189
195
|
"@json-render/core": ">=0.21.0",
|
|
@@ -225,6 +231,9 @@
|
|
|
225
231
|
"tailwind-merge": ">=2.0.0"
|
|
226
232
|
},
|
|
227
233
|
"peerDependenciesMeta": {
|
|
234
|
+
"expo-paste-input": {
|
|
235
|
+
"optional": true
|
|
236
|
+
},
|
|
228
237
|
"@clerk/clerk-expo": {
|
|
229
238
|
"optional": true
|
|
230
239
|
},
|
|
@@ -310,8 +319,8 @@
|
|
|
310
319
|
"check:exports": "node scripts/check-exports.mjs",
|
|
311
320
|
"check:hermes": "node scripts/check-hermes-compat.mjs",
|
|
312
321
|
"test": "vitest run",
|
|
313
|
-
"typecheck": "
|
|
314
|
-
"typecheck:consumer": "
|
|
322
|
+
"typecheck": "tsrs --noEmit --fast -p tsconfig.typecheck.json && pnpm run typecheck:consumer",
|
|
323
|
+
"typecheck:consumer": "tsrs --noEmit --fast -p tsconfig.consumer.json",
|
|
315
324
|
"build:baseline": "node scripts/build-dist.mjs --update"
|
|
316
325
|
}
|
|
317
326
|
}
|
package/src/FloatingTabBar.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import { useLargerText } from "./theme";
|
|
|
15
15
|
import { useReduceMotion } from "./useReduceMotion";
|
|
16
16
|
import { useScheme } from "./useScheme";
|
|
17
17
|
import { FLOATING_PILL_RADIUS, tabBarHeight, tabBarSlotStyle } from "./floating";
|
|
18
|
+
import { usePressed } from "./usePressed";
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Space between the bar edge and the tabs, on every side of the active pill,
|
|
@@ -158,6 +159,7 @@ function TabBarItem({
|
|
|
158
159
|
testID,
|
|
159
160
|
accessibilityLabel,
|
|
160
161
|
}: TabBarItemProps) {
|
|
162
|
+
const press = usePressed();
|
|
161
163
|
const onPress = () => {
|
|
162
164
|
const event = navigation.emit({
|
|
163
165
|
type: "tabPress",
|
|
@@ -177,8 +179,10 @@ function TabBarItem({
|
|
|
177
179
|
accessibilityState={{ selected: focused }}
|
|
178
180
|
accessibilityLabel={accessibilityLabel}
|
|
179
181
|
onPress={onPress}
|
|
182
|
+
onPressIn={press.onPressIn}
|
|
183
|
+
onPressOut={press.onPressOut}
|
|
180
184
|
className="min-h-12 min-w-12 flex-1 items-center justify-center gap-1"
|
|
181
|
-
style={
|
|
185
|
+
style={{ opacity: press.pressed ? 0.7 : 1 }}
|
|
182
186
|
>
|
|
183
187
|
{renderIcon ? renderIcon({ focused, color, size: largerText ? 28 : 24 }) : null}
|
|
184
188
|
<Text
|
package/src/SheetRow.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import { palette } from "./palette";
|
|
|
7
7
|
import { useLargerText } from "./theme";
|
|
8
8
|
import { tokens } from "./tokens";
|
|
9
9
|
import { useScheme } from "./useScheme";
|
|
10
|
+
import { usePressed } from "./usePressed";
|
|
10
11
|
|
|
11
12
|
export type SheetRowProps = {
|
|
12
13
|
/** A Tabler icon at the start. */
|
|
@@ -55,6 +56,7 @@ export function SheetRow({
|
|
|
55
56
|
onPress,
|
|
56
57
|
testID,
|
|
57
58
|
}: SheetRowProps) {
|
|
59
|
+
const press = usePressed();
|
|
58
60
|
const scheme = useScheme();
|
|
59
61
|
const largerText = useLargerText();
|
|
60
62
|
const color = danger
|
|
@@ -79,10 +81,12 @@ export function SheetRow({
|
|
|
79
81
|
largerText ? "min-h-16" : "min-h-14",
|
|
80
82
|
disabled && "opacity-50",
|
|
81
83
|
)}
|
|
82
|
-
|
|
84
|
+
onPressIn={press.onPressIn}
|
|
85
|
+
onPressOut={press.onPressOut}
|
|
86
|
+
style={{
|
|
83
87
|
borderRadius: tokens.radius.sm,
|
|
84
|
-
backgroundColor: pressed && !disabled ? palette.default[scheme] : "transparent",
|
|
85
|
-
}
|
|
88
|
+
backgroundColor: press.pressed && !disabled ? palette.default[scheme] : "transparent",
|
|
89
|
+
}}
|
|
86
90
|
>
|
|
87
91
|
{leading ?? (Icon ? <Icon size={iconSize} color={color} /> : null)}
|
|
88
92
|
<View className="min-w-0 flex-1">
|