@marktiderman/genesis-ui-native 3.7.0 → 3.8.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/README.md +4 -1
- package/dist/{chunk-KH2RVAI5.js → chunk-DHONOH6K.js} +24 -210
- package/dist/chunk-DHONOH6K.js.map +1 -0
- package/dist/{chunk-O4BMDV7I.js → chunk-FGIIBON3.js} +333 -21
- package/dist/chunk-FGIIBON3.js.map +1 -0
- package/dist/{chunk-YWDDDYDI.js → chunk-FOJJB6AB.js} +2 -2
- package/dist/{chunk-YWDDDYDI.js.map → chunk-FOJJB6AB.js.map} +1 -1
- package/dist/{chunk-IXC3LO2K.js → chunk-JZ7RAGDQ.js} +44 -36
- package/dist/chunk-JZ7RAGDQ.js.map +1 -0
- package/dist/{chunk-RTYO24SC.js → chunk-PWS2HLDE.js} +63 -31
- package/dist/chunk-PWS2HLDE.js.map +1 -0
- package/dist/{chunk-3KFUS7O6.js → chunk-PWYMRUAK.js} +43 -30
- package/dist/chunk-PWYMRUAK.js.map +1 -0
- package/dist/{chunk-GBNIBHSU.js → chunk-T7FEVT62.js} +53 -12
- package/dist/chunk-T7FEVT62.js.map +1 -0
- package/dist/{chunk-7NDKIIOT.js → chunk-UZCJDMGE.js} +353 -19
- package/dist/chunk-UZCJDMGE.js.map +1 -0
- package/dist/components/index.d.ts +229 -23
- package/dist/components/index.js +5 -6
- package/dist/data/index.d.ts +2 -1
- package/dist/data/index.js +7 -12
- package/dist/data/index.js.map +1 -1
- package/dist/hooks/index.d.ts +7 -3
- package/dist/hooks/index.js +2 -3
- package/dist/icons/lucide.d.ts +1 -1
- package/dist/icons/lucide.js +13 -3
- package/dist/icons/lucide.js.map +1 -1
- package/dist/{inbox-page-B7_Oi2fS.d.ts → inbox-page-BGqR_cBs.d.ts} +4 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +8 -9
- package/dist/layouts/index.d.ts +12 -3
- package/dist/layouts/index.js +5 -6
- package/dist/{native-modules-DEJJQhDx.d.ts → native-modules-CeAaO2Dh.d.ts} +26 -2
- package/package.json +49 -1
- package/src/__tests__/native-modules-lists.test.tsx +1 -0
- package/src/components/__tests__/bulk-bar.test.tsx +36 -0
- package/src/components/__tests__/button-haptic.test.tsx +22 -0
- package/src/components/__tests__/composer-bar.test.tsx +116 -1
- package/src/components/__tests__/gallery-grid.test.tsx +2 -2
- package/src/components/__tests__/library-round-5.test.tsx +121 -0
- package/src/components/__tests__/share-sheet.test.tsx +47 -0
- package/src/components/__tests__/swipe-row-context-menu.test.tsx +215 -0
- package/src/components/__tests__/tab-bar.test.tsx +43 -0
- package/src/components/__tests__/thread-list.test.tsx +137 -0
- package/src/components/__tests__/tier-badge.test.tsx +57 -0
- package/src/components/__tests__/whats-new-sheet.test.tsx +29 -0
- package/src/components/bulk-bar.tsx +91 -0
- package/src/components/button.tsx +74 -35
- package/src/components/choice-card.tsx +104 -0
- package/src/components/composer-bar.tsx +20 -19
- package/src/components/context-menu.tsx +101 -0
- package/src/components/gallery-grid.tsx +10 -4
- package/src/components/index.ts +18 -1
- package/src/components/inline-alert.tsx +36 -1
- package/src/components/input.tsx +3 -0
- package/src/components/progress.tsx +24 -2
- package/src/components/rating.tsx +35 -16
- package/src/components/share-sheet.tsx +127 -0
- package/src/components/sheet.tsx +9 -1
- package/src/components/swipe-row.tsx +74 -0
- package/src/components/tab-bar.tsx +133 -0
- package/src/components/tabs.tsx +2 -0
- package/src/components/text.tsx +3 -0
- package/src/components/textarea.tsx +3 -0
- package/src/components/thread-list.tsx +48 -23
- package/src/components/tier-badge.tsx +74 -0
- package/src/components/whats-new-sheet.tsx +89 -0
- package/src/data/resource-view/NativeRecordView.tsx +3 -8
- package/src/data/resource-view/use-native-resource-view.ts +2 -2
- package/src/hooks/index.ts +1 -1
- package/src/hooks/use-theme-roles.ts +3 -0
- package/src/icon-names.ts +12 -2
- package/src/icons/lucide.ts +27 -7
- package/src/layouts/__tests__/inbox-page.test.tsx +26 -7
- package/src/layouts/__tests__/thread-page.test.tsx +89 -2
- package/src/layouts/inbox-page.tsx +28 -12
- package/src/layouts/thread-page.tsx +69 -8
- package/src/native-modules.tsx +16 -0
- package/dist/chunk-3KFUS7O6.js.map +0 -1
- package/dist/chunk-7NDKIIOT.js.map +0 -1
- package/dist/chunk-CAI7LGN6.js +0 -39
- package/dist/chunk-CAI7LGN6.js.map +0 -1
- package/dist/chunk-GBNIBHSU.js.map +0 -1
- package/dist/chunk-IXC3LO2K.js.map +0 -1
- package/dist/chunk-KH2RVAI5.js.map +0 -1
- package/dist/chunk-O4BMDV7I.js.map +0 -1
- package/dist/chunk-RTYO24SC.js.map +0 -1
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* `above` (a reply preview, attachments waiting to send), `idleAction` (in
|
|
14
14
|
* Send's place while there's nothing to send: a hold-to-record mic) and
|
|
15
15
|
* `replaceInput` (instead of `leading` and the input: a recording's
|
|
16
|
-
* waveform). Attachments with no text: pass `
|
|
16
|
+
* waveform). Attachments with no text: pass `hasContent`.
|
|
17
17
|
* - **More ways to send:** `sendActions` ("Schedule"). Touch and hold Send:
|
|
18
18
|
* one action runs, several open a menu. Each is also an accessibility
|
|
19
19
|
* action on Send.
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
*
|
|
28
28
|
* @stability Beta
|
|
29
29
|
*/
|
|
30
|
-
import { useEffect, type ReactNode } from "react";
|
|
31
|
-
import { AccessibilityInfo, ActivityIndicator,
|
|
30
|
+
import { useEffect, useState, type ReactNode } from "react";
|
|
31
|
+
import { AccessibilityInfo, ActivityIndicator, Animated, Dimensions, Platform, Pressable, TextInput, View } from "react-native";
|
|
32
32
|
import type { ComposerMode } from "@marktiderman/genesis-core/conversation";
|
|
33
33
|
import { useThemeRoles } from "../hooks/use-theme-roles";
|
|
34
34
|
import { useGenesisModules } from "../native-modules";
|
|
35
35
|
import { usePressFeedback } from "../hooks/use-press-feedback";
|
|
36
|
+
import { NativeContextMenu } from "./context-menu";
|
|
36
37
|
import { NativeIcon } from "./icon";
|
|
37
38
|
import { NativeText } from "./text";
|
|
38
39
|
|
|
@@ -55,6 +56,8 @@ export interface NativeComposerBarProps {
|
|
|
55
56
|
maxLines?: number;
|
|
56
57
|
/** Ways to send ("Reply", "Internal note"). Two or more show the picker. */
|
|
57
58
|
modes?: readonly ComposerMode[];
|
|
59
|
+
/** The picker's name, to VoiceOver. Default "Send as". */
|
|
60
|
+
modesLabel?: string;
|
|
58
61
|
/** The chosen mode's id. Default the first. */
|
|
59
62
|
mode?: string;
|
|
60
63
|
onModeChange?: (id: string) => void;
|
|
@@ -62,10 +65,10 @@ export interface NativeComposerBarProps {
|
|
|
62
65
|
trailing?: ReactNode;
|
|
63
66
|
above?: ReactNode;
|
|
64
67
|
/**
|
|
65
|
-
* Whether there's
|
|
66
|
-
* are waiting and no text is needed.
|
|
68
|
+
* Whether there's something to send. By default, a `value` that isn't blank; pass `true` when
|
|
69
|
+
* attachments are waiting and no text is needed, and `false` while `replaceInput` is showing.
|
|
67
70
|
*/
|
|
68
|
-
|
|
71
|
+
hasContent?: boolean;
|
|
69
72
|
/** Takes Send's place (the same 44pt spot) while there's nothing to send and nothing sending: a hold-to-record mic. */
|
|
70
73
|
idleAction?: ReactNode;
|
|
71
74
|
/** Shown instead of `leading` and the input (a recording in progress). Label it yourself: it's one region to VoiceOver. */
|
|
@@ -78,7 +81,10 @@ export interface NativeComposerBarProps {
|
|
|
78
81
|
sendActionsHint?: string;
|
|
79
82
|
/** Passed to the input (to insert at the cursor, say). */
|
|
80
83
|
onSelectionChange?: (e: { nativeEvent: { selection: { start: number; end: number } } }) => void;
|
|
81
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* The input takes text (default). When false, Send is off and the input reads as disabled.
|
|
86
|
+
* `idleAction` is the app's, so disable it too.
|
|
87
|
+
*/
|
|
82
88
|
editable?: boolean;
|
|
83
89
|
testID?: string;
|
|
84
90
|
}
|
|
@@ -91,14 +97,6 @@ export interface ComposerSendAction {
|
|
|
91
97
|
destructive?: boolean;
|
|
92
98
|
}
|
|
93
99
|
|
|
94
|
-
function openSendActions(actions: readonly ComposerSendAction[], title: string | undefined) {
|
|
95
|
-
if (actions.length === 1) return actions[0]!.onPress();
|
|
96
|
-
Alert.alert(title ?? "", undefined, [
|
|
97
|
-
...actions.map((a) => ({ text: a.label, style: a.destructive ? ("destructive" as const) : ("default" as const), onPress: a.onPress })),
|
|
98
|
-
{ text: "Cancel", style: "cancel" as const },
|
|
99
|
-
]);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
100
|
const LINE = 22;
|
|
103
101
|
const PAD_Y = 8;
|
|
104
102
|
|
|
@@ -114,12 +112,13 @@ export function NativeComposerBar({
|
|
|
114
112
|
maxLength,
|
|
115
113
|
maxLines = 6,
|
|
116
114
|
modes,
|
|
115
|
+
modesLabel = "Send as",
|
|
117
116
|
mode,
|
|
118
117
|
onModeChange,
|
|
119
118
|
leading,
|
|
120
119
|
trailing,
|
|
121
120
|
above,
|
|
122
|
-
|
|
121
|
+
hasContent,
|
|
123
122
|
idleAction,
|
|
124
123
|
replaceInput,
|
|
125
124
|
sendActions,
|
|
@@ -135,9 +134,10 @@ export function NativeComposerBar({
|
|
|
135
134
|
const hasIcon = Boolean(symbol || icons?.["arrow-up"]);
|
|
136
135
|
const current = modes?.find((m) => m.id === mode) ?? modes?.[0];
|
|
137
136
|
const internal = current?.tone === "internal";
|
|
138
|
-
const blank =
|
|
137
|
+
const blank = !(hasContent ?? value.trim().length > 0);
|
|
139
138
|
const canSend = !blank && !disabled && !sending && editable;
|
|
140
139
|
const actions = sendActions?.length ? sendActions : null;
|
|
140
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
141
141
|
const idle = idleAction != null && blank && !sending;
|
|
142
142
|
const sendPress = usePressFeedback({ haptic: "light", scale: 0.9, disabled: !canSend });
|
|
143
143
|
// A multiline input grows with its text by itself; this caps it, after which it scrolls.
|
|
@@ -163,7 +163,7 @@ export function NativeComposerBar({
|
|
|
163
163
|
}}
|
|
164
164
|
>
|
|
165
165
|
{modes && modes.length > 1 ? (
|
|
166
|
-
<View testID={`${testID}-modes`} accessibilityRole="tablist" style={{ flexDirection: "row", gap: 4 }}>
|
|
166
|
+
<View testID={`${testID}-modes`} accessibilityRole="tablist" accessibilityLabel={modesLabel} style={{ flexDirection: "row", gap: 4 }}>
|
|
167
167
|
{modes.map((m) => {
|
|
168
168
|
const on = m.id === current?.id;
|
|
169
169
|
return (
|
|
@@ -250,7 +250,7 @@ export function NativeComposerBar({
|
|
|
250
250
|
accessibilityHint={actions ? sendActionsHint : undefined}
|
|
251
251
|
accessibilityActions={actions && canSend ? actions.map((a) => ({ name: a.id, label: a.label })) : undefined}
|
|
252
252
|
onAccessibilityAction={actions ? (e) => actions.find((a) => a.id === e.nativeEvent.actionName)?.onPress() : undefined}
|
|
253
|
-
onLongPress={actions ? () =>
|
|
253
|
+
onLongPress={actions ? () => (actions.length === 1 ? actions[0]!.onPress() : setMenuOpen(true)) : undefined}
|
|
254
254
|
disabled={!canSend}
|
|
255
255
|
onPressIn={sendPress.onPressIn}
|
|
256
256
|
onPressOut={sendPress.onPressOut}
|
|
@@ -271,6 +271,7 @@ export function NativeComposerBar({
|
|
|
271
271
|
</Animated.View>
|
|
272
272
|
)}
|
|
273
273
|
</View>
|
|
274
|
+
{actions && actions.length > 1 ? <NativeContextMenu open={menuOpen} onOpenChange={setMenuOpen} actions={actions} {...(sendActionsTitle ? { title: sendActionsTitle } : {})} testID={`${testID}-send-menu`} /> : null}
|
|
274
275
|
</View>
|
|
275
276
|
);
|
|
276
277
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeContextMenu — what a long press opens: a short list of actions in a
|
|
3
|
+
* sheet that fits them, with Cancel, instead of the system `Alert`. It's the
|
|
4
|
+
* same on iOS and Android, a row of its own for each action (44pt, a destructive
|
|
5
|
+
* one in the theme's `destructive`), and opening it taps `medium`.
|
|
6
|
+
*
|
|
7
|
+
* Controlled, like `NativeSheet`: keep `open` in your screen and set it from
|
|
8
|
+
* `onLongPress`. Offer the same actions as accessibility actions on the
|
|
9
|
+
* pressable too (`accessibilityActions`), since VoiceOver doesn't long press.
|
|
10
|
+
*
|
|
11
|
+
* An action runs once, and once the sheet has gone: iOS won't present an alert
|
|
12
|
+
* or another modal over one that's still dismissing.
|
|
13
|
+
*
|
|
14
|
+
* @stability Beta
|
|
15
|
+
*/
|
|
16
|
+
import { useEffect, useRef } from "react";
|
|
17
|
+
import { Platform, Pressable, View } from "react-native";
|
|
18
|
+
import { useHaptics } from "../hooks/use-haptics";
|
|
19
|
+
import { useThemeRoles } from "../hooks/use-theme-roles";
|
|
20
|
+
import { NativeSheet } from "./sheet";
|
|
21
|
+
import { NativeText } from "./text";
|
|
22
|
+
|
|
23
|
+
export interface NativeContextMenuAction {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
onPress: () => void;
|
|
27
|
+
destructive?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface NativeContextMenuProps {
|
|
31
|
+
open: boolean;
|
|
32
|
+
onOpenChange: (open: boolean) => void;
|
|
33
|
+
actions: readonly NativeContextMenuAction[];
|
|
34
|
+
/** Over the actions: what they act on. */
|
|
35
|
+
title?: string;
|
|
36
|
+
cancelLabel?: string;
|
|
37
|
+
testID?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** If iOS never says the sheet has gone (Modal's `onDismiss` can be skipped), run the action after this. */
|
|
41
|
+
const IOS_DISMISS_FALLBACK_MS = 600;
|
|
42
|
+
|
|
43
|
+
export function NativeContextMenu({ open, onOpenChange, actions, title, cancelLabel = "Cancel", testID = "context-menu" }: NativeContextMenuProps) {
|
|
44
|
+
const colors = useThemeRoles();
|
|
45
|
+
const play = useHaptics();
|
|
46
|
+
const opened = useRef(false);
|
|
47
|
+
// What was tapped, until the sheet has gone. Taken once: a second tap, or the fallback after onDismiss, finds nothing.
|
|
48
|
+
const tapped = useRef<(() => void) | null>(null);
|
|
49
|
+
const ran = useRef(false);
|
|
50
|
+
const fallback = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (open && !opened.current) {
|
|
53
|
+
play("medium");
|
|
54
|
+
ran.current = false;
|
|
55
|
+
}
|
|
56
|
+
opened.current = open;
|
|
57
|
+
}, [open, play]);
|
|
58
|
+
|
|
59
|
+
const runTapped = () => {
|
|
60
|
+
if (fallback.current) clearTimeout(fallback.current);
|
|
61
|
+
fallback.current = null;
|
|
62
|
+
const action = tapped.current;
|
|
63
|
+
tapped.current = null;
|
|
64
|
+
action?.();
|
|
65
|
+
};
|
|
66
|
+
const run = (action: NativeContextMenuAction) => {
|
|
67
|
+
if (ran.current) return;
|
|
68
|
+
ran.current = true;
|
|
69
|
+
tapped.current = action.onPress;
|
|
70
|
+
onOpenChange(false);
|
|
71
|
+
if (Platform.OS === "ios") fallback.current = setTimeout(runTapped, IOS_DISMISS_FALLBACK_MS);
|
|
72
|
+
else runTapped();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<NativeSheet open={open} onOpenChange={onOpenChange} fitContent onDismissed={runTapped} testID={testID}>
|
|
77
|
+
<View style={{ paddingHorizontal: 16, paddingBottom: 8 }}>
|
|
78
|
+
{title ? (
|
|
79
|
+
<NativeText testID={`${testID}-title`} accessibilityRole="header" numberOfLines={2} style={{ paddingVertical: 8, color: colors.secondaryLabel, fontSize: 13, lineHeight: 18, textAlign: "center" }}>
|
|
80
|
+
{title}
|
|
81
|
+
</NativeText>
|
|
82
|
+
) : null}
|
|
83
|
+
{actions.map((action) => (
|
|
84
|
+
<Pressable
|
|
85
|
+
key={action.id}
|
|
86
|
+
testID={`${testID}-action-${action.id}`}
|
|
87
|
+
accessibilityRole="button"
|
|
88
|
+
accessibilityLabel={action.label}
|
|
89
|
+
onPress={() => run(action)}
|
|
90
|
+
style={{ minHeight: 48, alignItems: "center", justifyContent: "center" }}
|
|
91
|
+
>
|
|
92
|
+
<NativeText style={{ color: action.destructive ? colors.destructive : colors.tint, fontSize: 17, lineHeight: 22 }}>{action.label}</NativeText>
|
|
93
|
+
</Pressable>
|
|
94
|
+
))}
|
|
95
|
+
<Pressable testID={`${testID}-cancel`} accessibilityRole="button" accessibilityLabel={cancelLabel} onPress={() => onOpenChange(false)} style={{ minHeight: 48, alignItems: "center", justifyContent: "center" }}>
|
|
96
|
+
<NativeText style={{ color: colors.label, fontSize: 17, lineHeight: 22, fontWeight: "600" }}>{cancelLabel}</NativeText>
|
|
97
|
+
</Pressable>
|
|
98
|
+
</View>
|
|
99
|
+
</NativeSheet>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* Rows come from the pure `justifyRows`, so the same items pack the same way
|
|
7
7
|
* as the web `GalleryGrid`, with the same defaults (`GALLERY_DEFAULTS`) and
|
|
8
8
|
* the same props, `onItemPress` in place of the web's `onItemClick` (as
|
|
9
|
-
* `NativeResourcePage` pairs with `ResourcePage`). The
|
|
10
|
-
*
|
|
9
|
+
* `NativeResourcePage` pairs with `ResourcePage`). The first paint lays out
|
|
10
|
+
* at the window width, and `onLayout` corrects it to the container's. The rows are a
|
|
11
11
|
* virtualized `FlatList` (the grid scrolls itself; `header` and `footer` go
|
|
12
12
|
* above and below), so a long gallery mounts only what's near the screen and
|
|
13
13
|
* `loadMore` fires when scrolling nears the end, for "load more". Don't put
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* @stability Beta
|
|
27
27
|
*/
|
|
28
28
|
import { useMemo, useState, type ReactNode } from "react";
|
|
29
|
-
import { FlatList, Pressable, Text, View, type LayoutChangeEvent } from "react-native";
|
|
29
|
+
import { Dimensions, FlatList, Pressable, Text, View, type FlatListProps, type LayoutChangeEvent } from "react-native";
|
|
30
30
|
import { cn } from "../utils";
|
|
31
31
|
import { galleryItemRatio, justifyRows } from "./gallery-layout";
|
|
32
32
|
import { GALLERY_DEFAULTS, type GalleryItem, type GalleryTileAspect } from "./gallery-types";
|
|
@@ -67,6 +67,8 @@ export interface NativeGalleryGridProps {
|
|
|
67
67
|
groupBy?: (item: GalleryItem) => string;
|
|
68
68
|
/** @deprecated Use `groupBy`. */
|
|
69
69
|
getGroup?: (item: GalleryItem) => string;
|
|
70
|
+
/** iOS: how the list insets under a large-title or translucent header. Default `"automatic"`, so the first row starts below the header. */
|
|
71
|
+
contentInsetAdjustmentBehavior?: FlatListProps<unknown>["contentInsetAdjustmentBehavior"];
|
|
70
72
|
className?: string;
|
|
71
73
|
testID?: string;
|
|
72
74
|
}
|
|
@@ -116,12 +118,15 @@ export function NativeGalleryGrid({
|
|
|
116
118
|
footer,
|
|
117
119
|
groupBy: groupByProp,
|
|
118
120
|
getGroup,
|
|
121
|
+
contentInsetAdjustmentBehavior = "automatic",
|
|
119
122
|
className,
|
|
120
123
|
testID = "native-gallery-grid",
|
|
121
124
|
}: NativeGalleryGridProps) {
|
|
122
125
|
const loadMore = loadMoreProp ?? onNearEnd;
|
|
123
126
|
const groupBy = groupByProp ?? getGroup;
|
|
124
|
-
|
|
127
|
+
// Start from the window width so the list mounts on the first paint (iOS applies the
|
|
128
|
+
// large-title content inset only to a scroll view present at mount); onLayout corrects it.
|
|
129
|
+
const [width, setWidth] = useState(() => Dimensions.get("window").width);
|
|
125
130
|
const onLayout = (e: LayoutChangeEvent) => {
|
|
126
131
|
const next = e.nativeEvent.layout.width;
|
|
127
132
|
if (next !== width) setWidth(next);
|
|
@@ -269,6 +274,7 @@ export function NativeGalleryGrid({
|
|
|
269
274
|
{width > 0 ? (
|
|
270
275
|
<FlatList
|
|
271
276
|
testID={`${testID}-list`}
|
|
277
|
+
contentInsetAdjustmentBehavior={contentInsetAdjustmentBehavior}
|
|
272
278
|
data={lines}
|
|
273
279
|
keyExtractor={(line) => line.key}
|
|
274
280
|
renderItem={renderLine}
|
package/src/components/index.ts
CHANGED
|
@@ -128,6 +128,8 @@ export type { NativeRefreshControlProps } from "./refresh-control";
|
|
|
128
128
|
|
|
129
129
|
export { NativeBadge, badgeVariants, badgeTextVariants } from "./badge";
|
|
130
130
|
export type { NativeBadgeProps } from "./badge";
|
|
131
|
+
export { NativeTierBadge } from "./tier-badge";
|
|
132
|
+
export type { NativeTierBadgeProps } from "./tier-badge";
|
|
131
133
|
|
|
132
134
|
export { NativeInput } from "./input";
|
|
133
135
|
export type { NativeInputProps } from "./input";
|
|
@@ -197,6 +199,8 @@ export type {
|
|
|
197
199
|
export { NativeLabel } from "./label";
|
|
198
200
|
export type { NativeLabelProps } from "./label";
|
|
199
201
|
|
|
202
|
+
export { NativeChoiceCard } from "./choice-card";
|
|
203
|
+
export type { NativeChoiceCardProps } from "./choice-card";
|
|
200
204
|
export { NativeRadioGroup, NativeRadioGroupItem } from "./radio-group";
|
|
201
205
|
export type {
|
|
202
206
|
NativeRadioGroupProps,
|
|
@@ -307,6 +311,10 @@ export {
|
|
|
307
311
|
export type { NativeThreadListProps, NativeThreadListHandle, ThreadRowInfo } from "./thread-list";
|
|
308
312
|
export { NativeComposerBar } from "./composer-bar";
|
|
309
313
|
export type { NativeComposerBarProps, ComposerMode, ComposerTone, ComposerSendAction } from "./composer-bar";
|
|
314
|
+
export { NativeSwipeRow } from "./swipe-row";
|
|
315
|
+
export type { NativeSwipeRowProps } from "./swipe-row";
|
|
316
|
+
export { NativeContextMenu } from "./context-menu";
|
|
317
|
+
export type { NativeContextMenuProps, NativeContextMenuAction } from "./context-menu";
|
|
310
318
|
|
|
311
319
|
// --- Gallery and media primitives ---
|
|
312
320
|
|
|
@@ -315,7 +323,7 @@ export { justifyRows, galleryItemRatio, DEFAULT_GALLERY_RATIO } from "./gallery-
|
|
|
315
323
|
export type { JustifiedRow, JustifiedTile } from "./gallery-layout";
|
|
316
324
|
|
|
317
325
|
export { NativeRating, nextRating } from "./rating";
|
|
318
|
-
export type { NativeRatingProps, NativeRatingSize } from "./rating";
|
|
326
|
+
export type { NativeRatingProps, NativeRatingSize, NativeRatingTone } from "./rating";
|
|
319
327
|
|
|
320
328
|
export { NativeGalleryGrid } from "./gallery-grid";
|
|
321
329
|
export type { NativeGalleryGridProps, NativeGalleryLayout } from "./gallery-grid";
|
|
@@ -340,3 +348,12 @@ export type { NativeGalleryCardProps } from "./gallery-card";
|
|
|
340
348
|
|
|
341
349
|
export { NativeLiveIndicator } from "./live-indicator";
|
|
342
350
|
export type { NativeLiveIndicatorProps, NativeLiveIndicatorState, NativeLiveIndicatorVariant } from "./live-indicator";
|
|
351
|
+
|
|
352
|
+
export { NativeTabBar } from "./tab-bar";
|
|
353
|
+
export type { NativeTabBarItem, NativeTabBarProps } from "./tab-bar";
|
|
354
|
+
export { NativeBulkBar } from "./bulk-bar";
|
|
355
|
+
export type { NativeBulkAction, NativeBulkBarProps } from "./bulk-bar";
|
|
356
|
+
export { NativeShareSheet } from "./share-sheet";
|
|
357
|
+
export type { NativeShareSheetProps } from "./share-sheet";
|
|
358
|
+
export { NativeWhatsNewSheet } from "./whats-new-sheet";
|
|
359
|
+
export type { NativeWhatsNewNote, NativeWhatsNewSheetProps } from "./whats-new-sheet";
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
* sparingly — for transient confirmation use <NativeToast>; for
|
|
10
10
|
* blocking issues use <NativeDialog>.
|
|
11
11
|
*
|
|
12
|
-
* Both share variants: info / success / warning / destructive.
|
|
12
|
+
* Both share variants: info / success / warning / destructive. Under the
|
|
13
|
+
* description, `children` takes any content (an error summary's list of
|
|
14
|
+
* links, a status line) and `actions` a row of buttons ("Retry", "Review"),
|
|
15
|
+
* so neither has to be drawn by hand around the alert.
|
|
13
16
|
*
|
|
14
17
|
* @stability Beta
|
|
15
18
|
*/
|
|
@@ -30,6 +33,10 @@ interface BaseProps {
|
|
|
30
33
|
icon?: React.ReactNode;
|
|
31
34
|
/** When provided, renders an "✕" dismiss button with this label. */
|
|
32
35
|
onDismiss?: () => void;
|
|
36
|
+
/** Content under the description (a list of the fields to fix, a status line). */
|
|
37
|
+
children?: React.ReactNode;
|
|
38
|
+
/** A row of buttons under the content (NativeButton size="sm"). */
|
|
39
|
+
actions?: React.ReactNode;
|
|
33
40
|
className?: string;
|
|
34
41
|
testID?: string;
|
|
35
42
|
}
|
|
@@ -48,6 +55,24 @@ const titleClasses: Record<NativeInlineAlertVariant, string> = {
|
|
|
48
55
|
destructive: "text-destructive",
|
|
49
56
|
};
|
|
50
57
|
|
|
58
|
+
/** The alert's content and actions slots, under the description. */
|
|
59
|
+
function AlertExtras({ children, actions, testID }: { children?: React.ReactNode; actions?: React.ReactNode; testID?: string | undefined }) {
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
{children ? (
|
|
63
|
+
<View testID={testID ? `${testID}-content` : undefined} className="mt-2">
|
|
64
|
+
{children}
|
|
65
|
+
</View>
|
|
66
|
+
) : null}
|
|
67
|
+
{actions ? (
|
|
68
|
+
<View testID={testID ? `${testID}-actions` : undefined} className="mt-3 flex-row flex-wrap gap-2">
|
|
69
|
+
{actions}
|
|
70
|
+
</View>
|
|
71
|
+
) : null}
|
|
72
|
+
</>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
51
76
|
export interface NativeInlineAlertProps extends BaseProps {}
|
|
52
77
|
|
|
53
78
|
export function NativeInlineAlert({
|
|
@@ -56,6 +81,8 @@ export function NativeInlineAlert({
|
|
|
56
81
|
description,
|
|
57
82
|
icon,
|
|
58
83
|
onDismiss,
|
|
84
|
+
children,
|
|
85
|
+
actions,
|
|
59
86
|
className,
|
|
60
87
|
testID,
|
|
61
88
|
}: NativeInlineAlertProps) {
|
|
@@ -81,6 +108,9 @@ export function NativeInlineAlert({
|
|
|
81
108
|
{description}
|
|
82
109
|
</Text>
|
|
83
110
|
) : null}
|
|
111
|
+
<AlertExtras testID={testID} actions={actions}>
|
|
112
|
+
{children}
|
|
113
|
+
</AlertExtras>
|
|
84
114
|
</View>
|
|
85
115
|
{onDismiss ? (
|
|
86
116
|
<Pressable
|
|
@@ -106,6 +136,8 @@ export function NativeBanner({
|
|
|
106
136
|
description,
|
|
107
137
|
icon,
|
|
108
138
|
onDismiss,
|
|
139
|
+
children,
|
|
140
|
+
actions,
|
|
109
141
|
className,
|
|
110
142
|
testID,
|
|
111
143
|
}: NativeBannerProps) {
|
|
@@ -132,6 +164,9 @@ export function NativeBanner({
|
|
|
132
164
|
{description}
|
|
133
165
|
</Text>
|
|
134
166
|
) : null}
|
|
167
|
+
<AlertExtras testID={testID} actions={actions}>
|
|
168
|
+
{children}
|
|
169
|
+
</AlertExtras>
|
|
135
170
|
</View>
|
|
136
171
|
{onDismiss ? (
|
|
137
172
|
<Pressable
|
package/src/components/input.tsx
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @stability Stable
|
|
5
5
|
*/
|
|
6
|
+
import type { ComponentRef, Ref } from "react";
|
|
6
7
|
import { Text, TextInput, type TextInputProps, View } from "react-native";
|
|
7
8
|
import { nativeColors } from "@marktiderman/genesis-design-system/tokens/native";
|
|
8
9
|
import { cn } from "../utils";
|
|
@@ -12,6 +13,8 @@ export interface NativeInputProps extends TextInputProps {
|
|
|
12
13
|
inputClassName?: string;
|
|
13
14
|
label?: string;
|
|
14
15
|
error?: string;
|
|
16
|
+
/** The underlying TextInput (React 19 passes `ref` as a prop). */
|
|
17
|
+
ref?: Ref<ComponentRef<typeof TextInput>> | undefined;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
function NativeInput({
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Progress — determinate horizontal progress indicator.
|
|
3
3
|
*
|
|
4
|
+
* The fill is `bg-primary` and the track `bg-muted`. `indicatorColor` and
|
|
5
|
+
* `trackColor` take a colour value (a theme role from `useThemeRoles`, a
|
|
6
|
+
* brand's tint) for a package or screen that styles without NativeWind
|
|
7
|
+
* classes; they win over the class props.
|
|
8
|
+
*
|
|
4
9
|
* @stability Stable
|
|
5
10
|
*/
|
|
6
|
-
import { View } from "react-native";
|
|
11
|
+
import { View, type ColorValue, type ViewStyle } from "react-native";
|
|
7
12
|
import { cn } from "../utils";
|
|
8
13
|
|
|
9
14
|
export interface NativeProgressProps {
|
|
@@ -14,6 +19,14 @@ export interface NativeProgressProps {
|
|
|
14
19
|
trackClassName?: string;
|
|
15
20
|
/** Indicator color class. Defaults to bg-primary */
|
|
16
21
|
indicatorClassName?: string;
|
|
22
|
+
/** The fill's colour as a value (a theme role, a brand tint); wins over `indicatorClassName`. */
|
|
23
|
+
indicatorColor?: ColorValue;
|
|
24
|
+
/** The track's colour as a value; wins over `trackClassName`. */
|
|
25
|
+
trackColor?: ColorValue;
|
|
26
|
+
/** Track style, for colors from a theme object rather than classes. Wins over the classes. */
|
|
27
|
+
style?: ViewStyle;
|
|
28
|
+
/** Indicator style, for colors from a theme object rather than classes. Wins over the classes. */
|
|
29
|
+
indicatorStyle?: ViewStyle;
|
|
17
30
|
testID?: string;
|
|
18
31
|
}
|
|
19
32
|
|
|
@@ -22,6 +35,10 @@ function NativeProgress({
|
|
|
22
35
|
value = 0,
|
|
23
36
|
trackClassName,
|
|
24
37
|
indicatorClassName,
|
|
38
|
+
indicatorColor,
|
|
39
|
+
trackColor,
|
|
40
|
+
style,
|
|
41
|
+
indicatorStyle,
|
|
25
42
|
...props
|
|
26
43
|
}: NativeProgressProps) {
|
|
27
44
|
const safeValue = Number.isFinite(value) ? value : 0;
|
|
@@ -38,10 +55,15 @@ function NativeProgress({
|
|
|
38
55
|
accessibilityLabel={`${clampedValue}% complete`}
|
|
39
56
|
accessibilityValue={{ min: 0, max: 100, now: clampedValue }}
|
|
40
57
|
{...props}
|
|
58
|
+
style={trackColor === undefined ? style : { ...style, backgroundColor: trackColor }}
|
|
41
59
|
>
|
|
42
60
|
<View
|
|
43
61
|
className={cn("h-full rounded-full bg-primary", indicatorClassName)}
|
|
44
|
-
style={{
|
|
62
|
+
style={{
|
|
63
|
+
...indicatorStyle,
|
|
64
|
+
width: `${clampedValue}%`,
|
|
65
|
+
...(indicatorColor === undefined ? {} : { backgroundColor: indicatorColor }),
|
|
66
|
+
}}
|
|
45
67
|
/>
|
|
46
68
|
</View>
|
|
47
69
|
);
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* Without `onChange` (or with `readOnly`) it is one image for screen readers
|
|
6
6
|
* ("3 of 5 stars"). With it, each star is a radio in a radiogroup, so
|
|
7
7
|
* VoiceOver and TalkBack read the chosen one and the rest as options;
|
|
8
|
-
* pressing the current value clears the rating (`nextRating`)
|
|
9
|
-
* draw in the `warning` role (what
|
|
10
|
-
*
|
|
8
|
+
* pressing the current value clears the rating (`nextRating`) unless
|
|
9
|
+
* `clearable` is false. Filled stars draw in the `warning` role (what
|
|
10
|
+
* `text-warning` resolves to), or the brand's tint with `tone="primary"`;
|
|
11
|
+
* empty ones in the muted foreground. `size="touch"` gives each star a 44pt
|
|
12
|
+
* target, for a form. Same props as the web `Rating`.
|
|
11
13
|
*
|
|
12
14
|
* @stability Beta
|
|
13
15
|
*/
|
|
@@ -17,7 +19,8 @@ import { cn } from "../utils";
|
|
|
17
19
|
import { useGenesisModules } from "../native-modules";
|
|
18
20
|
import { NativeIcon } from "./icon";
|
|
19
21
|
|
|
20
|
-
export type NativeRatingSize = "sm" | "md" | "lg";
|
|
22
|
+
export type NativeRatingSize = "sm" | "md" | "lg" | "touch";
|
|
23
|
+
export type NativeRatingTone = "warning" | "primary";
|
|
21
24
|
|
|
22
25
|
export interface NativeRatingProps {
|
|
23
26
|
/** The score, 0..`max`. Fractions round to the nearest star. */
|
|
@@ -28,8 +31,14 @@ export interface NativeRatingProps {
|
|
|
28
31
|
onChange?: (value: number) => void;
|
|
29
32
|
/** Read-only even with `onChange`. */
|
|
30
33
|
readOnly?: boolean;
|
|
31
|
-
/** Default "md". */
|
|
34
|
+
/** Default "md". `touch` is a 44pt target around a large star, for a form. */
|
|
32
35
|
size?: NativeRatingSize;
|
|
36
|
+
/** The chosen stars' colour: the `warning` role (default) or the brand's tint. */
|
|
37
|
+
tone?: NativeRatingTone;
|
|
38
|
+
/** Pressing the chosen star clears it to 0. Default true; false for a required answer. */
|
|
39
|
+
clearable?: boolean;
|
|
40
|
+
/** The stars can't be pressed, and read as disabled. */
|
|
41
|
+
disabled?: boolean;
|
|
33
42
|
/** The control's accessible name ("Service rating"): read-only reads "Service rating: 3 of 5 stars". */
|
|
34
43
|
label?: string;
|
|
35
44
|
/** The accessibility text for a value, in place of "N of M stars" (read-only label, each radio's label and value). */
|
|
@@ -38,7 +47,7 @@ export interface NativeRatingProps {
|
|
|
38
47
|
testID?: string;
|
|
39
48
|
}
|
|
40
49
|
|
|
41
|
-
const STAR_SIZE: Record<NativeRatingSize, number> = { sm: 14, md: 20, lg: 28 };
|
|
50
|
+
const STAR_SIZE: Record<NativeRatingSize, number> = { sm: 14, md: 20, lg: 28, touch: 28 };
|
|
42
51
|
|
|
43
52
|
/** The value after pressing `star`: that star, or 0 when it is the current value (a press clears). */
|
|
44
53
|
export function nextRating(value: number, star: number): number {
|
|
@@ -50,14 +59,15 @@ export function nextRating(value: number, star: number): number {
|
|
|
50
59
|
* filled star is solid (`fill`) and the empty one an outline, so the state
|
|
51
60
|
* never rests on colour alone.
|
|
52
61
|
*/
|
|
53
|
-
function Star({ on, size, testID }: { on: boolean; size: number; testID?: string }) {
|
|
62
|
+
function Star({ on, size, tone, testID }: { on: boolean; size: number; tone: NativeRatingTone; testID?: string }) {
|
|
54
63
|
const roles = useThemeRoles();
|
|
55
64
|
const { symbol, icons } = useGenesisModules();
|
|
56
|
-
const
|
|
65
|
+
const onColor = tone === "primary" ? roles.tint : roles.warning;
|
|
66
|
+
const color = on ? onColor : roles.secondaryLabel;
|
|
57
67
|
const Lucide = icons?.star;
|
|
58
68
|
if (!(Platform.OS === "ios" && symbol) && Lucide) {
|
|
59
69
|
return (
|
|
60
|
-
<Lucide size={size} color={color} fill={on ?
|
|
70
|
+
<Lucide size={size} color={color} fill={on ? onColor : "none"} strokeWidth={on ? 2 : 1.5} testID={testID} />
|
|
61
71
|
);
|
|
62
72
|
}
|
|
63
73
|
return <NativeIcon name="star" size={size} weight={on ? "bold" : "regular"} color={color} testID={testID} />;
|
|
@@ -69,6 +79,9 @@ export function NativeRating({
|
|
|
69
79
|
onChange,
|
|
70
80
|
readOnly = false,
|
|
71
81
|
size = "md",
|
|
82
|
+
tone = "warning",
|
|
83
|
+
clearable = true,
|
|
84
|
+
disabled = false,
|
|
72
85
|
label,
|
|
73
86
|
getLabel,
|
|
74
87
|
className,
|
|
@@ -92,7 +105,7 @@ export function NativeRating({
|
|
|
92
105
|
className={cn("flex-row items-center gap-0.5", className)}
|
|
93
106
|
>
|
|
94
107
|
{stars.map((n) => (
|
|
95
|
-
<Star key={n} on={n <= filled} size={px} testID={`${testID}-star-${n}`} />
|
|
108
|
+
<Star key={n} on={n <= filled} size={px} tone={tone} testID={`${testID}-star-${n}`} />
|
|
96
109
|
))}
|
|
97
110
|
</View>
|
|
98
111
|
);
|
|
@@ -104,7 +117,8 @@ export function NativeRating({
|
|
|
104
117
|
accessibilityRole="radiogroup"
|
|
105
118
|
accessibilityLabel={label ?? "Rating"}
|
|
106
119
|
accessibilityValue={{ min: 0, max: count, now: filled, text: summary }}
|
|
107
|
-
|
|
120
|
+
accessibilityState={{ disabled }}
|
|
121
|
+
className={cn("flex-row items-center", size === "touch" ? "flex-wrap gap-1" : "gap-0.5", disabled && "opacity-50", className)}
|
|
108
122
|
>
|
|
109
123
|
{stars.map((n) => {
|
|
110
124
|
const selected = n === filled;
|
|
@@ -114,12 +128,17 @@ export function NativeRating({
|
|
|
114
128
|
testID={`${testID}-star-${n}`}
|
|
115
129
|
accessibilityRole="radio"
|
|
116
130
|
accessibilityLabel={starsText(n)}
|
|
117
|
-
accessibilityState={{ selected, checked: selected }}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
131
|
+
accessibilityState={{ selected, checked: selected, disabled }}
|
|
132
|
+
disabled={disabled}
|
|
133
|
+
onPress={() => {
|
|
134
|
+
const next = nextRating(filled, n);
|
|
135
|
+
if (next === 0 && !clearable) return;
|
|
136
|
+
onChange?.(next);
|
|
137
|
+
}}
|
|
138
|
+
hitSlop={size === "touch" ? 0 : 4}
|
|
139
|
+
className={size === "touch" ? "h-11 w-11 items-center justify-center rounded-md" : "p-0.5"}
|
|
121
140
|
>
|
|
122
|
-
<Star on={n <= filled} size={px} />
|
|
141
|
+
<Star on={n <= filled} size={px} tone={tone} />
|
|
123
142
|
</Pressable>
|
|
124
143
|
);
|
|
125
144
|
})}
|