@marktiderman/genesis-ui-native 3.5.0 → 3.6.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 +71 -7
- package/dist/{chunk-LBVD7XXL.js → chunk-2Z72MYHB.js} +627 -20
- package/dist/chunk-2Z72MYHB.js.map +1 -0
- package/dist/chunk-4OQOJ2OC.js +80 -0
- package/dist/chunk-4OQOJ2OC.js.map +1 -0
- package/dist/{chunk-6KWEAGRD.js → chunk-6PGLX6ET.js} +101 -6
- package/dist/chunk-6PGLX6ET.js.map +1 -0
- package/dist/{chunk-ONH2PCGH.js → chunk-AGTBABAH.js} +9 -15
- package/dist/chunk-AGTBABAH.js.map +1 -0
- package/dist/{chunk-ABVSSJNT.js → chunk-FUMSL7VZ.js} +198 -168
- package/dist/chunk-FUMSL7VZ.js.map +1 -0
- package/dist/{chunk-GHYUNNNU.js → chunk-NDXNSSM6.js} +175 -93
- package/dist/chunk-NDXNSSM6.js.map +1 -0
- package/dist/chunk-SEJ6RBP7.js +361 -0
- package/dist/chunk-SEJ6RBP7.js.map +1 -0
- package/dist/{chunk-D5RKSPMH.js → chunk-ZRQAFFTN.js} +4 -3
- package/dist/chunk-ZRQAFFTN.js.map +1 -0
- package/dist/components/index.d.ts +331 -4
- package/dist/components/index.js +5 -5
- package/dist/data/index.d.ts +68 -4
- package/dist/data/index.js +235 -31
- package/dist/data/index.js.map +1 -1
- package/dist/hooks/index.d.ts +60 -1
- package/dist/hooks/index.js +2 -3
- package/dist/icons/lucide.d.ts +1 -1
- package/dist/icons/lucide.js +7 -1
- package/dist/icons/lucide.js.map +1 -1
- package/dist/{inbox-page-BEarNEIP.d.ts → inbox-page-B7_Oi2fS.d.ts} +2 -44
- package/dist/index.d.ts +8 -5
- package/dist/index.js +8 -8
- package/dist/layouts/index.d.ts +40 -51
- package/dist/layouts/index.js +5 -4
- package/dist/{native-modules-PwnGltOU.d.ts → native-modules-Cl3zw3kh.d.ts} +27 -1
- package/package.json +78 -4
- package/src/__tests__/doctor-rules.test.ts +60 -0
- package/src/__tests__/native-modules-lists.test.tsx +1 -0
- package/src/components/__tests__/composer-bar.test.tsx +55 -0
- package/src/components/__tests__/gallery-card.test.tsx +59 -0
- package/src/components/__tests__/gallery-grid.test.tsx +160 -0
- package/src/components/__tests__/lightbox-resnap.test.tsx +50 -0
- package/src/components/__tests__/lightbox-zoom.test.ts +33 -0
- package/src/components/__tests__/lightbox.test.tsx +141 -0
- package/src/components/__tests__/live-indicator.test.tsx +72 -0
- package/src/components/__tests__/rating.test.tsx +82 -0
- package/src/components/__tests__/thread-list.test.tsx +156 -0
- package/src/components/composer-bar.tsx +198 -0
- package/src/components/drawer.tsx +15 -9
- package/src/components/gallery-card.tsx +109 -0
- package/src/components/gallery-grid.tsx +285 -0
- package/src/components/gallery-layout.ts +2 -0
- package/src/components/gallery-types.ts +2 -0
- package/src/components/index.ts +44 -0
- package/src/components/lightbox-zoom.tsx +282 -0
- package/src/components/lightbox.tsx +342 -0
- package/src/components/live-indicator.tsx +139 -0
- package/src/components/rating.tsx +128 -0
- package/src/components/skeleton.tsx +9 -4
- package/src/components/thread-list.tsx +427 -0
- package/src/components/toast.tsx +7 -4
- package/src/data/NativeConflictSheet.tsx +181 -0
- package/src/data/NativeResourceForm.tsx +15 -1
- package/src/data/index.ts +2 -0
- package/src/data/resource-view/NativeLinkPicker.tsx +1 -1
- package/src/data/resource-view/NativeRecordView.tsx +85 -8
- package/src/data/resource-view/NativeResourceView.tsx +79 -32
- package/src/data/resource-view/__tests__/native-link-picker.test.tsx +16 -0
- package/src/data/resource-view/__tests__/native-record-view.test.tsx +95 -1
- package/src/data/resource-view/__tests__/native-resource-gallery.test.tsx +125 -0
- package/src/data/resource-view/mapping.ts +3 -0
- package/src/hooks/__tests__/use-motion.test.tsx +106 -0
- package/src/hooks/__tests__/use-thread-jump.test.tsx +88 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/use-motion.ts +128 -0
- package/src/hooks/use-thread-jump.ts +110 -0
- package/src/icon-names.ts +6 -0
- package/src/icons/lucide.ts +12 -0
- package/src/layouts/__tests__/inbox-page.test.tsx +6 -0
- package/src/layouts/__tests__/thread-page.test.tsx +114 -14
- package/src/layouts/inbox-page.tsx +6 -55
- package/src/layouts/index.ts +2 -0
- package/src/layouts/thread-page.tsx +326 -262
- package/src/native-modules.tsx +16 -2
- package/dist/chunk-6KWEAGRD.js.map +0 -1
- package/dist/chunk-7PCWEY6R.js +0 -27
- package/dist/chunk-7PCWEY6R.js.map +0 -1
- package/dist/chunk-ABVSSJNT.js.map +0 -1
- package/dist/chunk-D5RKSPMH.js.map +0 -1
- package/dist/chunk-GHYUNNNU.js.map +0 -1
- package/dist/chunk-LBVD7XXL.js.map +0 -1
- package/dist/chunk-ONH2PCGH.js.map +0 -1
- package/dist/chunk-Z3AQYVUA.js +0 -36
- package/dist/chunk-Z3AQYVUA.js.map +0 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeLiveIndicator — "Live" with a pulsing dot, for a stream or a session
|
|
3
|
+
* that is on right now; the dot goes grey when it is idle and fainter when
|
|
4
|
+
* the source is offline.
|
|
5
|
+
*
|
|
6
|
+
* The pulse is an `Animated` loop that Reduce Motion turns off. Announced as
|
|
7
|
+
* text in a polite live region on Android and through
|
|
8
|
+
* `AccessibilityInfo.announceForAccessibility` on iOS, so a change from live
|
|
9
|
+
* to ended is read without interrupting. Same props as the web `LiveIndicator`.
|
|
10
|
+
*
|
|
11
|
+
* @stability Beta
|
|
12
|
+
*/
|
|
13
|
+
import { useEffect, useRef } from "react";
|
|
14
|
+
import { AccessibilityInfo, Animated, Easing, Text, View } from "react-native";
|
|
15
|
+
import { useReducedMotion } from "../hooks/use-reduced-motion";
|
|
16
|
+
import { cn } from "../utils";
|
|
17
|
+
|
|
18
|
+
export type NativeLiveIndicatorVariant = "pill" | "dot";
|
|
19
|
+
export type NativeLiveIndicatorState = "live" | "idle" | "offline";
|
|
20
|
+
|
|
21
|
+
export interface NativeLiveIndicatorProps {
|
|
22
|
+
/** Default true. `live={false}` is `state="idle"`. */
|
|
23
|
+
live?: boolean;
|
|
24
|
+
/** Overrides `live`: "live", "idle" (grey) or "offline" (faint). */
|
|
25
|
+
state?: NativeLiveIndicatorState;
|
|
26
|
+
/** Visible text and screen-reader label. Default follows the state: "Live", "Idle" or "Offline". */
|
|
27
|
+
label?: string;
|
|
28
|
+
/** After the label ("12 watching", "since 9:00"). */
|
|
29
|
+
detail?: string;
|
|
30
|
+
/** "pill" (default): dot and label on a rounded surface. "dot": the dot alone. */
|
|
31
|
+
variant?: NativeLiveIndicatorVariant;
|
|
32
|
+
className?: string;
|
|
33
|
+
testID?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const DEFAULT_LABEL: Record<NativeLiveIndicatorState, string> = { live: "Live", idle: "Idle", offline: "Offline" };
|
|
37
|
+
|
|
38
|
+
const DOT_CLASS: Record<NativeLiveIndicatorState, string> = {
|
|
39
|
+
live: "bg-destructive",
|
|
40
|
+
idle: "bg-muted-foreground",
|
|
41
|
+
offline: "bg-muted-foreground/50",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export function NativeLiveIndicator({
|
|
45
|
+
live = true,
|
|
46
|
+
state,
|
|
47
|
+
label,
|
|
48
|
+
detail,
|
|
49
|
+
variant = "pill",
|
|
50
|
+
className,
|
|
51
|
+
testID = "native-live-indicator",
|
|
52
|
+
}: NativeLiveIndicatorProps) {
|
|
53
|
+
const resolved: NativeLiveIndicatorState = state ?? (live ? "live" : "idle");
|
|
54
|
+
const isLive = resolved === "live";
|
|
55
|
+
const reducedMotion = useReducedMotion();
|
|
56
|
+
const pulse = useRef(new Animated.Value(1)).current;
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!isLive || reducedMotion) {
|
|
60
|
+
pulse.setValue(1);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const loop = Animated.loop(
|
|
64
|
+
Animated.sequence([
|
|
65
|
+
Animated.timing(pulse, { toValue: 0.3, duration: 700, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),
|
|
66
|
+
Animated.timing(pulse, { toValue: 1, duration: 700, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),
|
|
67
|
+
]),
|
|
68
|
+
);
|
|
69
|
+
loop.start();
|
|
70
|
+
return () => loop.stop();
|
|
71
|
+
}, [isLive, reducedMotion, pulse]);
|
|
72
|
+
|
|
73
|
+
const shown = label ?? DEFAULT_LABEL[resolved];
|
|
74
|
+
const stateText = isLive ? shown : label === undefined ? shown : resolved === "offline" ? `Offline, not ${shown.toLowerCase()}` : `Not ${shown.toLowerCase()}`;
|
|
75
|
+
const a11yLabel = detail ? `${stateText}, ${detail}` : stateText;
|
|
76
|
+
// accessibilityLiveRegion is Android-only: on iOS, announce a state change after mount.
|
|
77
|
+
const announced = useRef<string | null>(null);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const previous = announced.current;
|
|
80
|
+
announced.current = a11yLabel;
|
|
81
|
+
if (previous === null || previous === a11yLabel) return;
|
|
82
|
+
const info = AccessibilityInfo as {
|
|
83
|
+
announceForAccessibilityWithOptions?: (text: string, options: { queue?: boolean }) => void;
|
|
84
|
+
announceForAccessibility?: (text: string) => void;
|
|
85
|
+
};
|
|
86
|
+
if (info.announceForAccessibilityWithOptions) info.announceForAccessibilityWithOptions(a11yLabel, { queue: true });
|
|
87
|
+
else info.announceForAccessibility?.(a11yLabel);
|
|
88
|
+
}, [a11yLabel]);
|
|
89
|
+
const dot = (
|
|
90
|
+
<Animated.View
|
|
91
|
+
testID={`${testID}-dot`}
|
|
92
|
+
className={cn("h-2 w-2 rounded-full", DOT_CLASS[resolved])}
|
|
93
|
+
style={{ opacity: pulse }}
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
if (variant === "dot") {
|
|
98
|
+
return (
|
|
99
|
+
<View
|
|
100
|
+
testID={testID}
|
|
101
|
+
accessible
|
|
102
|
+
accessibilityRole="text"
|
|
103
|
+
accessibilityLabel={a11yLabel}
|
|
104
|
+
accessibilityLiveRegion="polite"
|
|
105
|
+
className={cn("items-center justify-center", className)}
|
|
106
|
+
>
|
|
107
|
+
{dot}
|
|
108
|
+
</View>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<View
|
|
114
|
+
testID={testID}
|
|
115
|
+
accessible
|
|
116
|
+
accessibilityRole="text"
|
|
117
|
+
accessibilityLabel={a11yLabel}
|
|
118
|
+
accessibilityLiveRegion="polite"
|
|
119
|
+
className={cn(
|
|
120
|
+
"flex-row items-center gap-1.5 self-start rounded-full border px-2 py-0.5",
|
|
121
|
+
isLive ? "border-transparent bg-destructive/15" : "border-border bg-muted",
|
|
122
|
+
className,
|
|
123
|
+
)}
|
|
124
|
+
>
|
|
125
|
+
{dot}
|
|
126
|
+
<Text
|
|
127
|
+
testID={`${testID}-label`}
|
|
128
|
+
className={cn("text-xs font-semibold uppercase tracking-wide", isLive ? "text-foreground" : "text-muted-foreground")}
|
|
129
|
+
>
|
|
130
|
+
{shown}
|
|
131
|
+
</Text>
|
|
132
|
+
{detail ? (
|
|
133
|
+
<Text testID={`${testID}-detail`} className="text-xs text-muted-foreground">
|
|
134
|
+
{detail}
|
|
135
|
+
</Text>
|
|
136
|
+
) : null}
|
|
137
|
+
</View>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeRating — a row of stars showing a score out of `max`, read-only or
|
|
3
|
+
* tappable.
|
|
4
|
+
*
|
|
5
|
+
* Without `onChange` (or with `readOnly`) it is one image for screen readers
|
|
6
|
+
* ("3 of 5 stars"). With it, each star is a radio in a radiogroup, so
|
|
7
|
+
* VoiceOver and TalkBack read the chosen one and the rest as options;
|
|
8
|
+
* pressing the current value clears the rating (`nextRating`). Filled stars
|
|
9
|
+
* draw in the `warning` role (what `text-warning` resolves to), empty ones in
|
|
10
|
+
* the muted foreground. Same props as the web `Rating`.
|
|
11
|
+
*
|
|
12
|
+
* @stability Beta
|
|
13
|
+
*/
|
|
14
|
+
import { Platform, Pressable, View } from "react-native";
|
|
15
|
+
import { useThemeRoles } from "../hooks/use-theme-roles";
|
|
16
|
+
import { cn } from "../utils";
|
|
17
|
+
import { useGenesisModules } from "../native-modules";
|
|
18
|
+
import { NativeIcon } from "./icon";
|
|
19
|
+
|
|
20
|
+
export type NativeRatingSize = "sm" | "md" | "lg";
|
|
21
|
+
|
|
22
|
+
export interface NativeRatingProps {
|
|
23
|
+
/** The score, 0..`max`. Fractions round to the nearest star. */
|
|
24
|
+
value: number;
|
|
25
|
+
/** Number of stars. Default 5. */
|
|
26
|
+
max?: number;
|
|
27
|
+
/** Makes the stars tappable; absent, the rating is read-only. */
|
|
28
|
+
onChange?: (value: number) => void;
|
|
29
|
+
/** Read-only even with `onChange`. */
|
|
30
|
+
readOnly?: boolean;
|
|
31
|
+
/** Default "md". */
|
|
32
|
+
size?: NativeRatingSize;
|
|
33
|
+
/** The control's accessible name ("Service rating"): read-only reads "Service rating: 3 of 5 stars". */
|
|
34
|
+
label?: string;
|
|
35
|
+
/** The accessibility text for a value, in place of "N of M stars" (read-only label, each radio's label and value). */
|
|
36
|
+
getLabel?: (value: number, max: number) => string;
|
|
37
|
+
className?: string;
|
|
38
|
+
testID?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const STAR_SIZE: Record<NativeRatingSize, number> = { sm: 14, md: 20, lg: 28 };
|
|
42
|
+
|
|
43
|
+
/** The value after pressing `star`: that star, or 0 when it is the current value (a press clears). */
|
|
44
|
+
export function nextRating(value: number, star: number): number {
|
|
45
|
+
return star === value ? 0 : star;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* One star. On iOS the SF Symbol differs by weight; on the lucide fallback the
|
|
50
|
+
* filled star is solid (`fill`) and the empty one an outline, so the state
|
|
51
|
+
* never rests on colour alone.
|
|
52
|
+
*/
|
|
53
|
+
function Star({ on, size, testID }: { on: boolean; size: number; testID?: string }) {
|
|
54
|
+
const roles = useThemeRoles();
|
|
55
|
+
const { symbol, icons } = useGenesisModules();
|
|
56
|
+
const color = on ? roles.warning : roles.secondaryLabel;
|
|
57
|
+
const Lucide = icons?.star;
|
|
58
|
+
if (!(Platform.OS === "ios" && symbol) && Lucide) {
|
|
59
|
+
return (
|
|
60
|
+
<Lucide size={size} color={color} fill={on ? roles.warning : "none"} strokeWidth={on ? 2 : 1.5} testID={testID} />
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return <NativeIcon name="star" size={size} weight={on ? "bold" : "regular"} color={color} testID={testID} />;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function NativeRating({
|
|
67
|
+
value,
|
|
68
|
+
max = 5,
|
|
69
|
+
onChange,
|
|
70
|
+
readOnly = false,
|
|
71
|
+
size = "md",
|
|
72
|
+
label,
|
|
73
|
+
getLabel,
|
|
74
|
+
className,
|
|
75
|
+
testID = "native-rating",
|
|
76
|
+
}: NativeRatingProps) {
|
|
77
|
+
const count = Math.max(1, Math.floor(max));
|
|
78
|
+
const filled = Math.min(count, Math.max(0, Math.round(Number.isFinite(value) ? value : 0)));
|
|
79
|
+
const px = STAR_SIZE[size];
|
|
80
|
+
const starsText = (n: number) => (getLabel ? getLabel(n, count) : `${n} of ${count} stars`);
|
|
81
|
+
const summary = label ? `${label}: ${starsText(filled)}` : starsText(filled);
|
|
82
|
+
const stars = Array.from({ length: count }, (_, i) => i + 1);
|
|
83
|
+
const interactive = Boolean(onChange) && !readOnly;
|
|
84
|
+
|
|
85
|
+
if (!interactive) {
|
|
86
|
+
return (
|
|
87
|
+
<View
|
|
88
|
+
testID={testID}
|
|
89
|
+
accessible
|
|
90
|
+
accessibilityRole="image"
|
|
91
|
+
accessibilityLabel={summary}
|
|
92
|
+
className={cn("flex-row items-center gap-0.5", className)}
|
|
93
|
+
>
|
|
94
|
+
{stars.map((n) => (
|
|
95
|
+
<Star key={n} on={n <= filled} size={px} testID={`${testID}-star-${n}`} />
|
|
96
|
+
))}
|
|
97
|
+
</View>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<View
|
|
103
|
+
testID={testID}
|
|
104
|
+
accessibilityRole="radiogroup"
|
|
105
|
+
accessibilityLabel={label ?? "Rating"}
|
|
106
|
+
accessibilityValue={{ min: 0, max: count, now: filled, text: summary }}
|
|
107
|
+
className={cn("flex-row items-center gap-0.5", className)}
|
|
108
|
+
>
|
|
109
|
+
{stars.map((n) => {
|
|
110
|
+
const selected = n === filled;
|
|
111
|
+
return (
|
|
112
|
+
<Pressable
|
|
113
|
+
key={n}
|
|
114
|
+
testID={`${testID}-star-${n}`}
|
|
115
|
+
accessibilityRole="radio"
|
|
116
|
+
accessibilityLabel={starsText(n)}
|
|
117
|
+
accessibilityState={{ selected, checked: selected }}
|
|
118
|
+
onPress={() => onChange?.(nextRating(filled, n))}
|
|
119
|
+
hitSlop={4}
|
|
120
|
+
className="p-0.5"
|
|
121
|
+
>
|
|
122
|
+
<Star on={n <= filled} size={px} />
|
|
123
|
+
</Pressable>
|
|
124
|
+
);
|
|
125
|
+
})}
|
|
126
|
+
</View>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { useEffect, useRef } from "react";
|
|
11
11
|
import { Animated, Easing } from "react-native";
|
|
12
12
|
import { cn } from "../utils";
|
|
13
|
-
import {
|
|
13
|
+
import { useMotion } from "../hooks/use-motion";
|
|
14
14
|
import { useGenesisModules, type GenesisReanimatedModule } from "../native-modules";
|
|
15
15
|
|
|
16
16
|
export interface NativeSkeletonProps {
|
|
@@ -27,7 +27,6 @@ export interface NativeSkeletonProps {
|
|
|
27
27
|
testID?: string;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const PULSE_MS = 1000;
|
|
31
30
|
const LOW = 0.3;
|
|
32
31
|
const HIGH = 1;
|
|
33
32
|
// Held still under Reduce Motion (visual-regression flow
|
|
@@ -53,7 +52,10 @@ function NativeSkeleton(props: NativeSkeletonProps) {
|
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
function ReanimatedSkeleton({ reanimated: R, ...props }: NativeSkeletonProps & { reanimated: GenesisReanimatedModule }) {
|
|
56
|
-
|
|
55
|
+
// One pulse cycle from the shared motion tokens; under Reduce Motion it holds still (a zero-length repeat would flash).
|
|
56
|
+
const motion = useMotion();
|
|
57
|
+
const reduceMotion = motion.reduced;
|
|
58
|
+
const PULSE_MS = motion.duration.pulse;
|
|
57
59
|
const opacity = R.useSharedValue(LOW);
|
|
58
60
|
useEffect(() => {
|
|
59
61
|
R.cancelAnimation(opacity);
|
|
@@ -85,7 +87,10 @@ function ReanimatedSkeleton({ reanimated: R, ...props }: NativeSkeletonProps & {
|
|
|
85
87
|
|
|
86
88
|
function AnimatedSkeleton(props: NativeSkeletonProps) {
|
|
87
89
|
const opacity = useRef(new Animated.Value(LOW)).current;
|
|
88
|
-
|
|
90
|
+
// One pulse cycle from the shared motion tokens; under Reduce Motion it holds still (a zero-length repeat would flash).
|
|
91
|
+
const motion = useMotion();
|
|
92
|
+
const reduceMotion = motion.reduced;
|
|
93
|
+
const PULSE_MS = motion.duration.pulse;
|
|
89
94
|
|
|
90
95
|
useEffect(() => {
|
|
91
96
|
if (reduceMotion) {
|