@marktiderman/genesis-ui-native 3.5.1 → 3.7.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 +115 -7
- package/dist/{chunk-ONH2PCGH.js → chunk-3KFUS7O6.js} +9 -15
- package/dist/chunk-3KFUS7O6.js.map +1 -0
- package/dist/{chunk-LBVD7XXL.js → chunk-7NDKIIOT.js} +627 -20
- package/dist/chunk-7NDKIIOT.js.map +1 -0
- package/dist/chunk-CAI7LGN6.js +39 -0
- package/dist/chunk-CAI7LGN6.js.map +1 -0
- package/dist/{chunk-ABVSSJNT.js → chunk-GBNIBHSU.js} +198 -168
- package/dist/chunk-GBNIBHSU.js.map +1 -0
- package/dist/chunk-IXC3LO2K.js +410 -0
- package/dist/chunk-IXC3LO2K.js.map +1 -0
- package/dist/{chunk-GHYUNNNU.js → chunk-KH2RVAI5.js} +174 -93
- package/dist/chunk-KH2RVAI5.js.map +1 -0
- package/dist/{chunk-6KWEAGRD.js → chunk-O4BMDV7I.js} +110 -17
- package/dist/chunk-O4BMDV7I.js.map +1 -0
- package/dist/chunk-RTYO24SC.js +105 -0
- package/dist/chunk-RTYO24SC.js.map +1 -0
- package/dist/{chunk-D5RKSPMH.js → chunk-YWDDDYDI.js} +4 -3
- package/dist/chunk-YWDDDYDI.js.map +1 -0
- package/dist/components/index.d.ts +382 -10
- package/dist/components/index.js +6 -5
- package/dist/data/index.d.ts +68 -4
- package/dist/data/index.js +231 -30
- package/dist/data/index.js.map +1 -1
- package/dist/hooks/index.d.ts +90 -2
- package/dist/hooks/index.js +3 -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 +9 -8
- package/dist/layouts/index.d.ts +40 -51
- package/dist/layouts/index.js +6 -4
- package/dist/{native-modules-PwnGltOU.d.ts → native-modules-DEJJQhDx.d.ts} +55 -1
- package/package.json +101 -4
- package/src/__tests__/doctor-rules.test.ts +87 -0
- package/src/__tests__/native-modules-lists.test.tsx +1 -0
- package/src/components/__tests__/button-haptic.test.tsx +52 -0
- package/src/components/__tests__/composer-bar.test.tsx +79 -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 +219 -0
- package/src/components/button.tsx +18 -1
- package/src/components/composer-bar.tsx +276 -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 +457 -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/NativeRecordView.tsx +85 -8
- package/src/data/resource-view/NativeResourceView.tsx +79 -32
- 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/hooks/__tests__/use-haptics.test.tsx +146 -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 +5 -0
- package/src/hooks/use-haptics.ts +64 -0
- package/src/hooks/use-motion.ts +128 -0
- package/src/hooks/use-press-feedback.ts +87 -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 +20 -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
|
@@ -2,6 +2,32 @@ import * as react from 'react';
|
|
|
2
2
|
import { ComponentType, ReactNode } from 'react';
|
|
3
3
|
import { ColorValue } from 'react-native';
|
|
4
4
|
|
|
5
|
+
/** What a haptic says. */
|
|
6
|
+
type HapticKind = "light" | "medium" | "heavy" | "select" | "success" | "warning" | "error";
|
|
7
|
+
/**
|
|
8
|
+
* `import * as Haptics from "expo-haptics"`: the parts Genesis calls, written structurally (the
|
|
9
|
+
* same shape as genesis-chat's `HapticsLike`, so one module serves both).
|
|
10
|
+
*/
|
|
11
|
+
interface GenesisHapticsModule {
|
|
12
|
+
impactAsync(style?: never): Promise<void>;
|
|
13
|
+
selectionAsync(): Promise<void>;
|
|
14
|
+
notificationAsync(type?: never): Promise<void>;
|
|
15
|
+
ImpactFeedbackStyle: {
|
|
16
|
+
Light: unknown;
|
|
17
|
+
Medium: unknown;
|
|
18
|
+
Heavy?: unknown;
|
|
19
|
+
};
|
|
20
|
+
NotificationFeedbackType: {
|
|
21
|
+
Success: unknown;
|
|
22
|
+
Warning: unknown;
|
|
23
|
+
Error: unknown;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Plays a haptic on the module given; never throws and never rejects. No module, no haptic. */
|
|
27
|
+
declare function playHaptic(haptics: GenesisHapticsModule | undefined, kind: HapticKind): void;
|
|
28
|
+
/** A function that plays a haptic through the app's `GenesisModules.haptics`. Stable across renders. */
|
|
29
|
+
declare function useHaptics(): (kind: HapticKind) => void;
|
|
30
|
+
|
|
5
31
|
/**
|
|
6
32
|
* The semantic icon names Genesis components ask for, and the SF Symbol each
|
|
7
33
|
* one draws on iOS. Components say "settings" or "bell", never a library's
|
|
@@ -13,11 +39,13 @@ import { ColorValue } from 'react-native';
|
|
|
13
39
|
declare const SF_SYMBOLS: {
|
|
14
40
|
readonly "arrow-left": "arrow.left";
|
|
15
41
|
readonly "arrow-up": "arrow.up";
|
|
42
|
+
readonly aperture: "camera.aperture";
|
|
16
43
|
readonly bell: "bell";
|
|
17
44
|
readonly calendar: "calendar";
|
|
18
45
|
readonly camera: "camera";
|
|
19
46
|
readonly "camera-flip": "arrow.triangle.2.circlepath.camera";
|
|
20
47
|
readonly check: "checkmark";
|
|
48
|
+
readonly clapperboard: "movieclapper";
|
|
21
49
|
readonly "chevron-down": "chevron.down";
|
|
22
50
|
readonly "chevron-left": "chevron.left";
|
|
23
51
|
readonly "chevron-right": "chevron.right";
|
|
@@ -33,6 +61,7 @@ declare const SF_SYMBOLS: {
|
|
|
33
61
|
readonly "external-link": "arrow.up.right.square";
|
|
34
62
|
readonly file: "doc";
|
|
35
63
|
readonly filter: "line.3.horizontal.decrease";
|
|
64
|
+
readonly "folder-plus": "folder.badge.plus";
|
|
36
65
|
readonly heart: "heart";
|
|
37
66
|
readonly home: "house";
|
|
38
67
|
readonly image: "photo";
|
|
@@ -40,6 +69,7 @@ declare const SF_SYMBOLS: {
|
|
|
40
69
|
readonly lock: "lock";
|
|
41
70
|
readonly "log-out": "rectangle.portrait.and.arrow.right";
|
|
42
71
|
readonly mail: "envelope";
|
|
72
|
+
readonly maximize: "arrow.up.left.and.arrow.down.right";
|
|
43
73
|
readonly menu: "line.3.horizontal";
|
|
44
74
|
readonly message: "bubble.left";
|
|
45
75
|
readonly mic: "mic";
|
|
@@ -50,10 +80,12 @@ declare const SF_SYMBOLS: {
|
|
|
50
80
|
readonly pin: "pin";
|
|
51
81
|
readonly play: "play.fill";
|
|
52
82
|
readonly plus: "plus";
|
|
83
|
+
readonly radio: "dot.radiowaves.left.and.right";
|
|
53
84
|
readonly refresh: "arrow.clockwise";
|
|
54
85
|
readonly reply: "arrowshape.turn.up.left";
|
|
55
86
|
readonly search: "magnifyingglass";
|
|
56
87
|
readonly settings: "gearshape";
|
|
88
|
+
readonly "settings-2": "slider.horizontal.3";
|
|
57
89
|
readonly share: "square.and.arrow.up";
|
|
58
90
|
readonly smile: "face.smiling";
|
|
59
91
|
readonly star: "star";
|
|
@@ -130,6 +162,14 @@ interface GenesisReanimatedModule {
|
|
|
130
162
|
easing?: unknown;
|
|
131
163
|
reduceMotion?: unknown;
|
|
132
164
|
}, callback?: (finished?: boolean) => void) => number;
|
|
165
|
+
/** Optional so older injected modules and test fakes still fit; `animateMotion` falls back to `withTiming`. */
|
|
166
|
+
withSpring?: (toValue: number, config?: {
|
|
167
|
+
damping?: number;
|
|
168
|
+
stiffness?: number;
|
|
169
|
+
mass?: number;
|
|
170
|
+
velocity?: number;
|
|
171
|
+
reduceMotion?: unknown;
|
|
172
|
+
}, callback?: (finished?: boolean) => void) => number;
|
|
133
173
|
withRepeat: (animation: number, numberOfReps?: number, reverse?: boolean, callback?: unknown, reduceMotion?: unknown) => number;
|
|
134
174
|
cancelAnimation: (value: {
|
|
135
175
|
value: unknown;
|
|
@@ -139,6 +179,7 @@ interface GenesisReanimatedModule {
|
|
|
139
179
|
ease: unknown;
|
|
140
180
|
out: (easing: unknown) => unknown;
|
|
141
181
|
cubic: unknown;
|
|
182
|
+
bezier?: (x1: number, y1: number, x2: number, y2: number) => unknown;
|
|
142
183
|
};
|
|
143
184
|
ReduceMotion?: {
|
|
144
185
|
System: unknown;
|
|
@@ -180,6 +221,7 @@ type GenesisSymbolComponent = ComponentType<GenesisSymbolProps>;
|
|
|
180
221
|
type GenesisIconComponent = ComponentType<{
|
|
181
222
|
size?: number;
|
|
182
223
|
color?: ColorValue;
|
|
224
|
+
fill?: ColorValue;
|
|
183
225
|
strokeWidth?: number;
|
|
184
226
|
testID?: string;
|
|
185
227
|
}>;
|
|
@@ -225,6 +267,14 @@ interface GenesisNavigationModule {
|
|
|
225
267
|
DarkTheme: GenesisNavigationTheme;
|
|
226
268
|
}
|
|
227
269
|
/** Every optional native module Genesis components can use. Each is optional on its own. */
|
|
270
|
+
/** react-native-keyboard-controller's `KeyboardAvoidingView`, written structurally (the same shape as genesis-chat's). */
|
|
271
|
+
type KeyboardAvoidingLike = ComponentType<{
|
|
272
|
+
behavior?: "height" | "padding" | "position" | "translate-with-padding";
|
|
273
|
+
keyboardVerticalOffset?: number;
|
|
274
|
+
automaticOffset?: boolean;
|
|
275
|
+
children?: ReactNode;
|
|
276
|
+
testID?: string;
|
|
277
|
+
}>;
|
|
228
278
|
interface GenesisModules {
|
|
229
279
|
list?: GenesisListComponent;
|
|
230
280
|
image?: GenesisImageComponent;
|
|
@@ -234,6 +284,10 @@ interface GenesisModules {
|
|
|
234
284
|
icons?: GenesisIconSet;
|
|
235
285
|
datePicker?: GenesisDatePickerComponent;
|
|
236
286
|
navigation?: GenesisNavigationModule;
|
|
287
|
+
/** react-native-keyboard-controller's `KeyboardAvoidingView` (it takes `behavior: "translate-with-padding"`). */
|
|
288
|
+
keyboardAvoidingView?: KeyboardAvoidingLike;
|
|
289
|
+
/** expo-haptics (`import * as Haptics from "expo-haptics"`): `useHaptics`, `usePressFeedback`, and the primitives that answer a touch. Without it, no haptics. */
|
|
290
|
+
haptics?: GenesisHapticsModule;
|
|
237
291
|
}
|
|
238
292
|
interface GenesisModulesProviderProps {
|
|
239
293
|
modules: GenesisModules;
|
|
@@ -250,4 +304,4 @@ declare function GenesisModulesProvider({ modules, children }: GenesisModulesPro
|
|
|
250
304
|
/** The modules given to the nearest `GenesisModulesProvider`; `{}` without one. */
|
|
251
305
|
declare function useGenesisModules(): GenesisModules;
|
|
252
306
|
|
|
253
|
-
export { type GenesisDatePickerComponent as G, NATIVE_ICON_NAMES as N, SF_SYMBOLS as S, type GenesisDatePickerProps as a, type GenesisGlassModule as b, type
|
|
307
|
+
export { type GenesisDatePickerComponent as G, type HapticKind as H, type KeyboardAvoidingLike as K, NATIVE_ICON_NAMES as N, SF_SYMBOLS as S, type GenesisDatePickerProps as a, type GenesisGlassModule as b, type GenesisHapticsModule as c, type GenesisIconComponent as d, type GenesisIconSet as e, type GenesisImageComponent as f, type GenesisImageProps as g, type GenesisListComponent as h, type GenesisListProps as i, type GenesisModules as j, GenesisModulesProvider as k, type GenesisModulesProviderProps as l, type GenesisNavigationModule as m, type GenesisNavigationTheme as n, type GenesisReanimatedModule as o, type GenesisSymbolComponent as p, type GenesisSymbolProps as q, type NativeIconName as r, playHaptic as s, useHaptics as t, useGenesisModules as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marktiderman/genesis-ui-native",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"@expo/ui": ">=58.0.0",
|
|
84
84
|
"@gorhom/bottom-sheet": ">=5.0.0",
|
|
85
85
|
"@hookform/resolvers": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0",
|
|
86
|
-
"@marktiderman/genesis-core": "^2.
|
|
87
|
-
"@marktiderman/genesis-design-system": "^1.
|
|
86
|
+
"@marktiderman/genesis-core": "^2.12.0",
|
|
87
|
+
"@marktiderman/genesis-design-system": "^1.8.0",
|
|
88
88
|
"@react-native-community/datetimepicker": ">=8.0.0",
|
|
89
89
|
"@shopify/flash-list": ">=2.0.0",
|
|
90
90
|
"@tanstack/react-query": "^5.0.0",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"react-hook-form": "^7.0.0",
|
|
100
100
|
"react-native": ">=0.76.0",
|
|
101
101
|
"react-native-gesture-handler": ">=2.0.0",
|
|
102
|
-
"react-native-keyboard-controller": ">=1.
|
|
102
|
+
"react-native-keyboard-controller": ">=1.21.0",
|
|
103
103
|
"react-native-reanimated": ">=3.0.0",
|
|
104
104
|
"react-native-safe-area-context": ">=4.0.0",
|
|
105
105
|
"tailwind-merge": "^3.0.0",
|
|
@@ -150,6 +150,7 @@
|
|
|
150
150
|
"class-variance-authority": "^0.7.1"
|
|
151
151
|
},
|
|
152
152
|
"devDependencies": {
|
|
153
|
+
"@tanstack/react-query": "^5.105.0",
|
|
153
154
|
"@testing-library/react": "^16.3.2",
|
|
154
155
|
"@types/react": "^19.2.14",
|
|
155
156
|
"@vitest/coverage-v8": "^5.0.5",
|
|
@@ -195,6 +196,72 @@
|
|
|
195
196
|
"import": "@marktiderman/genesis-ui-native/data",
|
|
196
197
|
"docs": "https://github.com/marktiderman/genesis/blob/main/docs/RESOURCE-VIEW.md#native",
|
|
197
198
|
"why": "The phone list comes from the same view as the web list: one description, two surfaces, no second set of helpers."
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"id": "motion-uses-tokens",
|
|
202
|
+
"need": "an animation on the phone",
|
|
203
|
+
"level": "warn",
|
|
204
|
+
"platform": "native",
|
|
205
|
+
"newOnly": true,
|
|
206
|
+
"files": [
|
|
207
|
+
"**/*.tsx",
|
|
208
|
+
"**/*.ts"
|
|
209
|
+
],
|
|
210
|
+
"forbid": {
|
|
211
|
+
"pattern": "(?:\\bwith(?:Timing|Spring)\\(\\s*[^,()]+,\\s*\\{[^}]*\\b(?:duration|damping|stiffness)\\s*:\\s*(?:0?\\.\\d*[1-9]|[1-9])|\\bAnimated\\.(?:timing|spring)\\(\\s*[^,()]+,\\s*\\{[^}]*\\b(?:duration|bounciness|speed|damping|stiffness)\\s*:\\s*(?:0?\\.\\d*[1-9]|[1-9])|\\b(?:FadeIn|FadeOut|Slide|Zoom|Bounce|Flip|Stretch|Roll|Rotate|Pinwheel|LightSpeed|Layout|LinearTransition|SequencedTransition|FadingTransition|JumpingTransition|CurvedTransition|EntryExitTransition)\\w*(?:\\.\\w+\\([^()]*\\))*\\.(?:duration|damping|stiffness)\\(\\s*(?:0?\\.\\d*[1-9]|[1-9]))"
|
|
212
|
+
},
|
|
213
|
+
"use": "useMotion() with animateMotion on the JS thread, or motionSpring / motionTiming inside a worklet: the shared motion tokens",
|
|
214
|
+
"import": "@marktiderman/genesis-ui-native",
|
|
215
|
+
"docs": "https://github.com/marktiderman/genesis/blob/main/packages/ui-native/README.md#motion",
|
|
216
|
+
"why": "Motion is defined once, and Reduce Motion is honoured in one place; a duration or spring written as a number drifts from the rest of the app."
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"id": "haptics-use-genesis",
|
|
220
|
+
"need": "a haptic on the phone",
|
|
221
|
+
"level": "warn",
|
|
222
|
+
"platform": "native",
|
|
223
|
+
"newOnly": true,
|
|
224
|
+
"files": [
|
|
225
|
+
"**/*.tsx",
|
|
226
|
+
"**/*.ts"
|
|
227
|
+
],
|
|
228
|
+
"exclude": [
|
|
229
|
+
"**/__tests__/**",
|
|
230
|
+
"**/*.test.ts",
|
|
231
|
+
"**/*.test.tsx"
|
|
232
|
+
],
|
|
233
|
+
"forbid": {
|
|
234
|
+
"pattern": "(?:\\bimport\\s*\\*\\s*as\\s+(\\w+)\\s+from\\s*[\"']expo-haptics[\"'][\\s\\S]*?\\b\\1\\??\\.(?:impactAsync|selectionAsync|notificationAsync)\\(|\\bHaptics\\??\\.(?:impactAsync|selectionAsync|notificationAsync)\\(|\\bimport\\s*\\{[^}]*\\b(?:impactAsync|selectionAsync|notificationAsync)\\b[^}]*\\}\\s*from\\s*[\"']expo-haptics[\"'])"
|
|
235
|
+
},
|
|
236
|
+
"use": "useHaptics() (or a NativeButton's `haptic`, usePressFeedback for a pressable of your own), with expo-haptics passed once as GenesisModules.haptics",
|
|
237
|
+
"import": "@marktiderman/genesis-ui-native",
|
|
238
|
+
"docs": "https://github.com/marktiderman/genesis/blob/main/packages/ui-native/README.md#haptics-and-press-feedback",
|
|
239
|
+
"why": "Haptics are named once (light, select, success…) and go through one module that never throws; a direct expo-haptics call picks its own styles and breaks where the module isn't installed."
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"id": "threads-use-thread-list",
|
|
243
|
+
"need": "a conversation's message list on the phone",
|
|
244
|
+
"level": "warn",
|
|
245
|
+
"platform": "native",
|
|
246
|
+
"newOnly": true,
|
|
247
|
+
"files": [
|
|
248
|
+
"**/*.tsx",
|
|
249
|
+
"**/*.jsx"
|
|
250
|
+
],
|
|
251
|
+
"forbid": {
|
|
252
|
+
"pattern": "(?:<(?:FlatList|FlashList)\\b[\\s\\S]{0,400}?\\binverted\\b(?!\\s*=\\s*\\{\\s*false\\s*\\})|\\bstartRenderingFromBottom\\s*:\\s*true)"
|
|
253
|
+
},
|
|
254
|
+
"unless": {
|
|
255
|
+
"renders": [
|
|
256
|
+
"ThreadPage",
|
|
257
|
+
"NativeThreadList",
|
|
258
|
+
"ChatThreadScreen"
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
"use": "ThreadPage, or NativeThreadList for a thread of your own (bottom-anchored, holds its place on load, jumps to a message)",
|
|
262
|
+
"import": "@marktiderman/genesis-ui-native",
|
|
263
|
+
"docs": "https://github.com/marktiderman/genesis/blob/main/packages/ui-native/README.md#inbox-and-thread-inboxpage-and-threadpage",
|
|
264
|
+
"why": "A hand-built inverted or bottom-started list recreates what NativeThreadList already does (G5), usually without holding its place, VoiceOver order or the jump."
|
|
198
265
|
}
|
|
199
266
|
],
|
|
200
267
|
"primitives": [
|
|
@@ -209,6 +276,36 @@
|
|
|
209
276
|
"use": "NativeRecordView",
|
|
210
277
|
"import": "@marktiderman/genesis-ui-native/data",
|
|
211
278
|
"docs": "https://github.com/marktiderman/genesis/blob/main/docs/RESOURCE-VIEW.md#recordview"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"need": "a conversation on the phone: messages, a composer",
|
|
282
|
+
"use": "ThreadPage (slots, modes, events), or NativeThreadList and NativeComposerBar to build your own",
|
|
283
|
+
"import": "@marktiderman/genesis-ui-native",
|
|
284
|
+
"docs": "https://github.com/marktiderman/genesis/blob/main/packages/ui-native/README.md#inbox-and-thread-inboxpage-and-threadpage"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"need": "a photo gallery on the phone",
|
|
288
|
+
"use": "NativeGalleryGrid, with NativeGalleryCard for media-first cards",
|
|
289
|
+
"import": "@marktiderman/genesis-ui-native/components",
|
|
290
|
+
"docs": "https://github.com/marktiderman/genesis/blob/main/packages/ui-native/README.md"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"need": "a full-screen photo viewer on the phone (zoom, swipe down to close)",
|
|
294
|
+
"use": "NativeLightbox",
|
|
295
|
+
"import": "@marktiderman/genesis-ui-native/components",
|
|
296
|
+
"docs": "https://github.com/marktiderman/genesis/blob/main/packages/ui-native/README.md"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"need": "a star rating on the phone",
|
|
300
|
+
"use": "NativeRating",
|
|
301
|
+
"import": "@marktiderman/genesis-ui-native/components",
|
|
302
|
+
"docs": "https://github.com/marktiderman/genesis/blob/main/packages/ui-native/README.md"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"need": "a photo gallery over a list (a photo per record, in justified rows)",
|
|
306
|
+
"use": "the view's gallery block (defineView) rendered by <NativeResourceView mode=\"grid\">; NativeGalleryGrid for photos that aren't records (attachments, uploads)",
|
|
307
|
+
"import": "@marktiderman/genesis-ui-native",
|
|
308
|
+
"docs": "https://github.com/marktiderman/genesis/blob/main/docs/RESOURCE-VIEW.md#gallery"
|
|
212
309
|
}
|
|
213
310
|
]
|
|
214
311
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// The doctor rules ui-native declares (package.json, genesis.doctor): their patterns, held to
|
|
2
|
+
// fixtures so a change that widens or narrows one shows here.
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import pkgJson from "../../package.json";
|
|
5
|
+
|
|
6
|
+
const pkg = pkgJson as unknown as {
|
|
7
|
+
genesis: { doctor: { prefer: { id: string; forbid: { pattern?: string }; unless?: unknown }[] } };
|
|
8
|
+
};
|
|
9
|
+
const rule = (id: string) => {
|
|
10
|
+
const found = pkg.genesis.doctor.prefer.find((r) => r.id === id);
|
|
11
|
+
if (!found?.forbid.pattern) throw new Error(`no pattern for ${id}`);
|
|
12
|
+
return { ...found, re: new RegExp(found.forbid.pattern) };
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe("motion-uses-tokens", () => {
|
|
16
|
+
const { re, unless } = rule("motion-uses-tokens");
|
|
17
|
+
|
|
18
|
+
it.each([
|
|
19
|
+
["withTiming(1, { duration: 300 })"],
|
|
20
|
+
["R.withSpring(target, { damping: 20 })"],
|
|
21
|
+
["withSpring(x, {\n damping: 20,\n})"],
|
|
22
|
+
["withTiming(0, {\n easing: Easing.out(Easing.cubic),\n duration: .3,\n})"],
|
|
23
|
+
["withTiming(1, { duration: 0.3 })"],
|
|
24
|
+
["Animated.timing(v, { toValue: 1, duration: 220, useNativeDriver: true })"],
|
|
25
|
+
["Animated.spring(v, { toValue: 0, bounciness: 6 })"],
|
|
26
|
+
["FadeIn.duration(300)"],
|
|
27
|
+
["FadeInDown.springify().damping(15)"],
|
|
28
|
+
["LinearTransition.duration(250)"],
|
|
29
|
+
])("flags %s", (code) => expect(re.test(code)).toBe(true));
|
|
30
|
+
|
|
31
|
+
it.each([
|
|
32
|
+
["withTiming(1, motionTiming(motion, 'fast', Easing))"],
|
|
33
|
+
["withSpring(0, motionSpring(motion, 'snappy', velocity))"],
|
|
34
|
+
["animateMotion(R, motion, 0, { spring: 'snappy' })"],
|
|
35
|
+
["withTiming(1);\ntoast.show({ title: 'Saved', duration: 3000 })"],
|
|
36
|
+
["dayjs.duration(5, 'minutes')"],
|
|
37
|
+
["moment.duration(30)"],
|
|
38
|
+
["withTiming(0, { duration: 0 })"],
|
|
39
|
+
["Animated.timing(v, cfg).start(); const t = { duration: 1000 }"],
|
|
40
|
+
])("leaves %s alone", (code) => expect(re.test(code)).toBe(false));
|
|
41
|
+
|
|
42
|
+
it("checks every file: a token call elsewhere in it doesn't exempt a literal", () => {
|
|
43
|
+
expect(unless).toBeUndefined();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("threads-use-thread-list", () => {
|
|
48
|
+
const { re } = rule("threads-use-thread-list");
|
|
49
|
+
|
|
50
|
+
it.each([
|
|
51
|
+
["<FlatList inverted data={m} />"],
|
|
52
|
+
["<FlatList renderItem={({ item }) => <Row item={item} />} inverted />"],
|
|
53
|
+
["<FlatList data={m} inverted={true} />"],
|
|
54
|
+
["<FlashList data={m} maintainVisibleContentPosition={{ startRenderingFromBottom: true }} />"],
|
|
55
|
+
])("flags %s", (code) => expect(re.test(code)).toBe(true));
|
|
56
|
+
it.each([["<FlatList data={rows} />"], ["<FlatList data={rows} inverted={false} />"], ["<FlatList data={rows} inverted={ false } />"]])(
|
|
57
|
+
"leaves %s alone",
|
|
58
|
+
(code) => expect(re.test(code)).toBe(false),
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe("haptics-use-genesis", () => {
|
|
63
|
+
const { re, exclude } = rule("haptics-use-genesis") as ReturnType<typeof rule> & { exclude?: string[] };
|
|
64
|
+
|
|
65
|
+
it("leaves tests alone (a mock of expo-haptics calls it)", () => {
|
|
66
|
+
expect(exclude).toEqual(expect.arrayContaining(["**/__tests__/**"]));
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it.each([
|
|
70
|
+
["Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light)"],
|
|
71
|
+
["void Haptics.selectionAsync()"],
|
|
72
|
+
["await Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success)"],
|
|
73
|
+
['import { impactAsync, ImpactFeedbackStyle } from "expo-haptics";'],
|
|
74
|
+
["import {\n selectionAsync,\n} from 'expo-haptics'"],
|
|
75
|
+
['import * as H from "expo-haptics";\nfunction tap() {\n void H.impactAsync(H.ImpactFeedbackStyle.Light);\n}'],
|
|
76
|
+
["Haptics?.selectionAsync()"],
|
|
77
|
+
])("flags %s", (code) => expect(re.test(code)).toBe(true));
|
|
78
|
+
|
|
79
|
+
it.each([
|
|
80
|
+
['import * as Haptics from "expo-haptics";\nconst modules = { haptics: Haptics };'],
|
|
81
|
+
["haptics.impactAsync(as(styles.Light))"],
|
|
82
|
+
['const play = useHaptics(); play("light")'],
|
|
83
|
+
['<NativeButton haptic="success" onPress={save}>Save</NativeButton>'],
|
|
84
|
+
['import { impactAsync } from "./my-haptics";'],
|
|
85
|
+
['import * as H from "expo-haptics";\nconst modules = { haptics: H };\nvideo.impactAsync()'],
|
|
86
|
+
])("leaves %s alone", (code) => expect(re.test(code)).toBe(false));
|
|
87
|
+
});
|
|
@@ -31,6 +31,7 @@ vi.mock("lucide-react-native", () => {
|
|
|
31
31
|
"Minus", "Pencil", "Plus", "RefreshCw", "Search", "Settings", "Share", "Star", "Trash2", "TriangleAlert", "User", "X",
|
|
32
32
|
"ArrowUp", "Camera", "Copy", "File", "Image", "MessageCircle", "Mic", "Paperclip", "Pause", "Pin", "Play", "Reply", "SquarePen",
|
|
33
33
|
"Download", "Smile", "Maximize2", "Square", "SwitchCamera", "Video", "Volume2", "VolumeX",
|
|
34
|
+
"Aperture", "Clapperboard", "FolderPlus", "Maximize", "Radio", "Settings2",
|
|
34
35
|
];
|
|
35
36
|
return Object.fromEntries(names.map((n) => [n, icon(n)]));
|
|
36
37
|
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { GenesisModulesProvider } from "../../native-modules";
|
|
4
|
+
import { NativeButton } from "../button";
|
|
5
|
+
|
|
6
|
+
const fake = () => ({
|
|
7
|
+
impactAsync: vi.fn(() => Promise.resolve()),
|
|
8
|
+
selectionAsync: vi.fn(() => Promise.resolve()),
|
|
9
|
+
notificationAsync: vi.fn(() => Promise.resolve()),
|
|
10
|
+
ImpactFeedbackStyle: { Light: "light", Medium: "medium" },
|
|
11
|
+
NotificationFeedbackType: { Success: "success", Warning: "warning", Error: "error" },
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe("NativeButton haptic", () => {
|
|
15
|
+
it("plays its haptic, then presses", () => {
|
|
16
|
+
const haptics = fake();
|
|
17
|
+
const onPress = vi.fn();
|
|
18
|
+
render(
|
|
19
|
+
<GenesisModulesProvider modules={{ haptics }}>
|
|
20
|
+
<NativeButton testID="b" haptic="success" onPress={onPress}>Save</NativeButton>
|
|
21
|
+
</GenesisModulesProvider>,
|
|
22
|
+
);
|
|
23
|
+
fireEvent.click(screen.getByTestId("b"));
|
|
24
|
+
expect(haptics.notificationAsync).toHaveBeenCalledWith("success");
|
|
25
|
+
expect(onPress).toHaveBeenCalledTimes(1);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("ticks select on press-in, as usePressFeedback does", () => {
|
|
29
|
+
const haptics = fake();
|
|
30
|
+
render(
|
|
31
|
+
<GenesisModulesProvider modules={{ haptics }}>
|
|
32
|
+
<NativeButton testID="b" haptic="select" onPress={() => {}}>Week</NativeButton>
|
|
33
|
+
</GenesisModulesProvider>,
|
|
34
|
+
);
|
|
35
|
+
fireEvent.pointerDown(screen.getByTestId("b"));
|
|
36
|
+
expect(haptics.selectionAsync).toHaveBeenCalledTimes(1);
|
|
37
|
+
fireEvent.click(screen.getByTestId("b"));
|
|
38
|
+
expect(haptics.selectionAsync).toHaveBeenCalledTimes(1);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("plays none without the prop", () => {
|
|
42
|
+
const haptics = fake();
|
|
43
|
+
render(
|
|
44
|
+
<GenesisModulesProvider modules={{ haptics }}>
|
|
45
|
+
<NativeButton testID="b" onPress={() => {}}>Save</NativeButton>
|
|
46
|
+
</GenesisModulesProvider>,
|
|
47
|
+
);
|
|
48
|
+
fireEvent.click(screen.getByTestId("b"));
|
|
49
|
+
expect(haptics.impactAsync).not.toHaveBeenCalled();
|
|
50
|
+
expect(haptics.notificationAsync).not.toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// @feat:inbox-thread
|
|
2
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
3
|
+
import { describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { GenesisModulesProvider } from "../../native-modules";
|
|
5
|
+
import { NativeComposerBar } from "../composer-bar";
|
|
6
|
+
import { fakeIcon } from "../../__tests__/fake-modules";
|
|
7
|
+
|
|
8
|
+
const base = { value: "", onChangeText: vi.fn(), onSend: vi.fn() };
|
|
9
|
+
|
|
10
|
+
describe("NativeComposerBar", () => {
|
|
11
|
+
it("won't send a blank message, and sends a written one", () => {
|
|
12
|
+
const onSend = vi.fn();
|
|
13
|
+
const { rerender } = render(<NativeComposerBar {...base} onSend={onSend} value=" " testID="c" />);
|
|
14
|
+
expect(screen.getByTestId("c-send").getAttribute("aria-disabled")).toBe("true");
|
|
15
|
+
rerender(<NativeComposerBar {...base} onSend={onSend} value="Hi" testID="c" />);
|
|
16
|
+
fireEvent.click(screen.getByTestId("c-send"));
|
|
17
|
+
expect(onSend).toHaveBeenCalledTimes(1);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("taps a light haptic when a message sends, and none when it can't", () => {
|
|
21
|
+
const haptics = {
|
|
22
|
+
impactAsync: vi.fn(() => Promise.resolve()),
|
|
23
|
+
selectionAsync: vi.fn(() => Promise.resolve()),
|
|
24
|
+
notificationAsync: vi.fn(() => Promise.resolve()),
|
|
25
|
+
ImpactFeedbackStyle: { Light: "light", Medium: "medium" },
|
|
26
|
+
NotificationFeedbackType: { Success: "s", Warning: "w", Error: "e" },
|
|
27
|
+
};
|
|
28
|
+
const { rerender } = render(
|
|
29
|
+
<GenesisModulesProvider modules={{ haptics }}>
|
|
30
|
+
<NativeComposerBar {...base} value=" " testID="c" />
|
|
31
|
+
</GenesisModulesProvider>,
|
|
32
|
+
);
|
|
33
|
+
fireEvent.click(screen.getByTestId("c-send"));
|
|
34
|
+
expect(haptics.impactAsync).not.toHaveBeenCalled();
|
|
35
|
+
rerender(
|
|
36
|
+
<GenesisModulesProvider modules={{ haptics }}>
|
|
37
|
+
<NativeComposerBar {...base} value="Hi" testID="c" />
|
|
38
|
+
</GenesisModulesProvider>,
|
|
39
|
+
);
|
|
40
|
+
fireEvent.click(screen.getByTestId("c-send"));
|
|
41
|
+
expect(haptics.impactAsync).toHaveBeenCalledWith("light");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("spins instead of sending twice", () => {
|
|
45
|
+
render(<NativeComposerBar {...base} value="Hi" sending testID="c" />);
|
|
46
|
+
expect(screen.getByTestId("c-sending").getAttribute("aria-label")).toBe("Sending");
|
|
47
|
+
expect(screen.queryByTestId("c-send")).toBeNull();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("draws the arrow with an icon module, and says Send without one", () => {
|
|
51
|
+
const { unmount } = render(<NativeComposerBar {...base} value="Hi" testID="c" />);
|
|
52
|
+
expect(screen.getByTestId("c-send").textContent).toBe("Send");
|
|
53
|
+
unmount();
|
|
54
|
+
render(
|
|
55
|
+
<GenesisModulesProvider modules={{ icons: { "arrow-up": fakeIcon("arrow-up") } }}>
|
|
56
|
+
<NativeComposerBar {...base} value="Hi" testID="c" />
|
|
57
|
+
</GenesisModulesProvider>,
|
|
58
|
+
);
|
|
59
|
+
expect(screen.getByTestId("c-send").querySelector('[data-lucide="arrow-up"]')).toBeTruthy();
|
|
60
|
+
expect(screen.getByTestId("c-send").getAttribute("aria-label")).toBe("Send");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("shows the mode picker only with two or more modes, and switches", () => {
|
|
64
|
+
const onModeChange = vi.fn();
|
|
65
|
+
const { rerender } = render(<NativeComposerBar {...base} modes={[{ id: "reply", label: "Reply" }]} testID="c" />);
|
|
66
|
+
expect(screen.queryByTestId("c-modes")).toBeNull();
|
|
67
|
+
rerender(
|
|
68
|
+
<NativeComposerBar {...base} modes={[{ id: "reply", label: "Reply" }, { id: "note", label: "Internal note", tone: "internal" }]} onModeChange={onModeChange} testID="c" />,
|
|
69
|
+
);
|
|
70
|
+
expect(screen.getByTestId("c-mode-reply").getAttribute("aria-selected")).toBe("true");
|
|
71
|
+
fireEvent.click(screen.getByTestId("c-mode-note"));
|
|
72
|
+
expect(onModeChange).toHaveBeenCalledWith("note");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("fills its slots", () => {
|
|
76
|
+
render(<NativeComposerBar {...base} leading={<i data-testid="attach" />} trailing={<i data-testid="mic" />} above={<i data-testid="reply-to" />} testID="c" />);
|
|
77
|
+
for (const id of ["attach", "mic", "reply-to"]) expect(screen.getByTestId(id)).toBeTruthy();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** NativeGalleryCard: cover at a ratio, overlays, footer, button with onPress. */
|
|
2
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
3
|
+
import { describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { NativeGalleryCard } from "../gallery-card";
|
|
5
|
+
|
|
6
|
+
describe("NativeGalleryCard", () => {
|
|
7
|
+
it("draws the cover at the ratio with title, subtitle, badges and actions", () => {
|
|
8
|
+
render(
|
|
9
|
+
<NativeGalleryCard
|
|
10
|
+
src="https://example.test/cover.jpg"
|
|
11
|
+
alt="A cover"
|
|
12
|
+
title="Morning session"
|
|
13
|
+
subtitle="12 photos"
|
|
14
|
+
ratio={16 / 9}
|
|
15
|
+
badges={<span data-testid="badge">New</span>}
|
|
16
|
+
actions={<span data-testid="action">…</span>}
|
|
17
|
+
testID="c"
|
|
18
|
+
/>,
|
|
19
|
+
);
|
|
20
|
+
expect(screen.getByTestId("c").getAttribute("role")).toBeNull();
|
|
21
|
+
expect(JSON.parse((screen.getByTestId("c-cover") as HTMLElement).dataset.style!).aspectRatio).toBeCloseTo(16 / 9, 5);
|
|
22
|
+
expect(screen.getByTestId("c-title").textContent).toBe("Morning session");
|
|
23
|
+
expect(screen.getByTestId("c-subtitle").textContent).toBe("12 photos");
|
|
24
|
+
expect(screen.getByTestId("c-badges").contains(screen.getByTestId("badge"))).toBe(true);
|
|
25
|
+
expect(screen.getByTestId("c-actions").contains(screen.getByTestId("action"))).toBe(true);
|
|
26
|
+
expect(screen.getByLabelText("A cover")).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("defaults to 4:3 and no footer", () => {
|
|
30
|
+
render(<NativeGalleryCard src="https://example.test/cover.jpg" testID="c" />);
|
|
31
|
+
expect(JSON.parse((screen.getByTestId("c-cover") as HTMLElement).dataset.style!).aspectRatio).toBeCloseTo(4 / 3, 5);
|
|
32
|
+
expect(screen.queryByTestId("c-footer")).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("is a button with onPress", () => {
|
|
36
|
+
const onPress = vi.fn();
|
|
37
|
+
render(<NativeGalleryCard src="https://example.test/cover.jpg" title="Tap" onPress={onPress} testID="c" />);
|
|
38
|
+
const card = screen.getByTestId("c");
|
|
39
|
+
expect(card.getAttribute("role")).toBe("button");
|
|
40
|
+
expect(card.getAttribute("aria-label")).toBe("Tap");
|
|
41
|
+
fireEvent.click(card);
|
|
42
|
+
expect(onPress).toHaveBeenCalledTimes(1);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe("NativeGalleryCard additions", () => {
|
|
47
|
+
it("draws a skeleton cover without src", () => {
|
|
48
|
+
render(<NativeGalleryCard title="Pending" testID="c" />);
|
|
49
|
+
expect(screen.getByTestId("c-skeleton")).toBeTruthy();
|
|
50
|
+
expect(screen.queryByRole("img")).toBeNull();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("draws a skeleton cover while loading, and is busy", () => {
|
|
54
|
+
render(<NativeGalleryCard src="https://example.test/cover.jpg" alt="A cover" loading testID="c" />);
|
|
55
|
+
expect(screen.getByTestId("c-skeleton")).toBeTruthy();
|
|
56
|
+
expect(screen.queryByLabelText("A cover")).toBeNull();
|
|
57
|
+
expect(screen.getByTestId("c").getAttribute("aria-busy")).toBe("true");
|
|
58
|
+
});
|
|
59
|
+
});
|