@terreno/ui 0.28.0 → 0.30.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.
Files changed (40) hide show
  1. package/dist/AiSuggestionBox.js +7 -12
  2. package/dist/AiSuggestionBox.js.map +1 -1
  3. package/dist/Common.d.ts +115 -0
  4. package/dist/Common.js.map +1 -1
  5. package/dist/Signature.d.ts +3 -1
  6. package/dist/Signature.js +4 -3
  7. package/dist/Signature.js.map +1 -1
  8. package/dist/Signature.native.d.ts +2 -0
  9. package/dist/Signature.native.js +2 -2
  10. package/dist/Signature.native.js.map +1 -1
  11. package/dist/SignatureCaptureField.d.ts +13 -0
  12. package/dist/SignatureCaptureField.js +69 -0
  13. package/dist/SignatureCaptureField.js.map +1 -0
  14. package/dist/ThumbsUpDownFeedback.d.ts +8 -0
  15. package/dist/ThumbsUpDownFeedback.js +60 -0
  16. package/dist/ThumbsUpDownFeedback.js.map +1 -0
  17. package/dist/TypedSignatureField.d.ts +18 -0
  18. package/dist/TypedSignatureField.js +102 -0
  19. package/dist/TypedSignatureField.js.map +1 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.js +3 -0
  22. package/dist/index.js.map +1 -1
  23. package/package.json +5 -1
  24. package/src/AiSuggestionBox.test.tsx +2 -2
  25. package/src/AiSuggestionBox.tsx +17 -48
  26. package/src/Common.ts +125 -0
  27. package/src/ConsentHistory.test.tsx +161 -0
  28. package/src/Signature.native.tsx +10 -2
  29. package/src/Signature.tsx +5 -0
  30. package/src/SignatureCaptureField.test.tsx +165 -0
  31. package/src/SignatureCaptureField.tsx +172 -0
  32. package/src/ThumbsUpDownFeedback.test.tsx +100 -0
  33. package/src/ThumbsUpDownFeedback.tsx +118 -0
  34. package/src/TypedSignatureField.test.tsx +113 -0
  35. package/src/TypedSignatureField.tsx +181 -0
  36. package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +108 -30
  37. package/src/__snapshots__/SignatureCaptureField.test.tsx.snap +96 -0
  38. package/src/__snapshots__/TypedSignatureField.test.tsx.snap +372 -0
  39. package/src/bunSetup.ts +33 -0
  40. package/src/index.tsx +3 -0
@@ -0,0 +1,102 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Caveat_400Regular } from "@expo-google-fonts/caveat";
3
+ import { DancingScript_400Regular } from "@expo-google-fonts/dancing-script";
4
+ import { GreatVibes_400Regular } from "@expo-google-fonts/great-vibes";
5
+ import { Sacramento_400Regular } from "@expo-google-fonts/sacramento";
6
+ import { useFonts } from "expo-font";
7
+ import { Text as NativeText, Pressable, View } from "react-native";
8
+ import { FieldError } from "./fieldElements/FieldError";
9
+ import { FieldHelperText } from "./fieldElements/FieldHelperText";
10
+ import { FieldTitle } from "./fieldElements/FieldTitle";
11
+ import { TextField } from "./TextField";
12
+ import { useTheme } from "./Theme";
13
+ import { resolveFieldTestIDsFromProps } from "./testing/resolveTestId";
14
+ /**
15
+ * Font families registered by this component via expo-font. Prefixed with "signature-" to
16
+ * avoid colliding with the app's text/heading font families.
17
+ */
18
+ const SIGNATURE_FONT_MODULES = {
19
+ "signature-caveat": Caveat_400Regular,
20
+ "signature-dancing-script": DancingScript_400Regular,
21
+ "signature-great-vibes": GreatVibes_400Regular,
22
+ "signature-sacramento": Sacramento_400Regular,
23
+ };
24
+ /**
25
+ * The default set of signature typefaces bundled with the library. Consumers persist the
26
+ * `key`; the `fontFamily` values match the families loaded by this component.
27
+ */
28
+ export const DEFAULT_SIGNATURE_FONTS = [
29
+ { fontFamily: "signature-dancing-script", key: "dancing-script", label: "Dancing Script" },
30
+ { fontFamily: "signature-great-vibes", key: "great-vibes", label: "Great Vibes" },
31
+ { fontFamily: "signature-sacramento", key: "sacramento", label: "Sacramento" },
32
+ { fontFamily: "signature-caveat", key: "caveat", label: "Caveat" },
33
+ ];
34
+ /**
35
+ * Resolves the currently selected font from the value, falling back to the first font when
36
+ * the stored `fontKey` is unknown (e.g. a font was removed) or no value is set yet.
37
+ */
38
+ const resolveSelectedFont = (fonts, fontKey) => {
39
+ var _a;
40
+ return (_a = fonts.find((font) => font.key === fontKey)) !== null && _a !== void 0 ? _a : fonts[0];
41
+ };
42
+ /**
43
+ * A cross-platform typed signature field. The signer types their name and picks a font from a
44
+ * live-previewing picker; the same UI and output are produced on web and native. Emits a
45
+ * {@link TypedSignatureValue} (typed name + font key) on every change so parents can gate
46
+ * "signature required" and persist the result directly.
47
+ *
48
+ * Font fidelity depends on the chosen font families being loaded. The bundled default fonts
49
+ * are loaded by this component; when a custom `fonts` list is supplied the consumer must load
50
+ * those families themselves.
51
+ */
52
+ export const TypedSignatureField = ({ title = "Signature", value, onChange, fonts = DEFAULT_SIGNATURE_FONTS, nameLabel = "Full name", placeholder = "Type your full name", helperText, errorText, disabled = false, testID, testIDs, }) => {
53
+ var _a;
54
+ const { theme } = useTheme();
55
+ // Load the bundled signature fonts. Rendering is not blocked on load — previews fall back to
56
+ // the system font briefly, then re-render once the families are available.
57
+ useFonts(SIGNATURE_FONT_MODULES);
58
+ const fieldTestIDs = resolveFieldTestIDsFromProps({ testID, testIDs });
59
+ // Guard against an empty `fonts` list: `fonts` is a public prop, so a caller can legitimately
60
+ // pass `[]`. Fall back to the bundled defaults so the field always has a usable font rather
61
+ // than dereferencing `undefined` on the first render.
62
+ const resolvedFonts = fonts.length > 0 ? fonts : DEFAULT_SIGNATURE_FONTS;
63
+ const typedName = (_a = value === null || value === void 0 ? void 0 : value.typedName) !== null && _a !== void 0 ? _a : "";
64
+ const selectedFont = resolveSelectedFont(resolvedFonts, value === null || value === void 0 ? void 0 : value.fontKey);
65
+ const hasName = typedName.trim().length > 0;
66
+ const emitChange = (next) => {
67
+ var _a, _b;
68
+ onChange({
69
+ fontKey: (_a = next.fontKey) !== null && _a !== void 0 ? _a : selectedFont.key,
70
+ typedName: (_b = next.typedName) !== null && _b !== void 0 ? _b : typedName,
71
+ });
72
+ };
73
+ return (_jsxs(View, Object.assign({ style: { flexDirection: "column", width: "100%" } }, (testID ? { testID } : {}), { children: [Boolean(title) && _jsx(FieldTitle, { testID: fieldTestIDs.label, text: title }), Boolean(errorText) && _jsx(FieldError, { testID: fieldTestIDs.error, text: errorText }), _jsx(View, { style: { marginTop: 8 }, children: _jsx(TextField, { disabled: disabled, onChange: (nextName) => emitChange({ typedName: nextName }), placeholder: placeholder, testID: fieldTestIDs.input, title: nameLabel, type: "text", value: typedName }) }), _jsx(View, { style: { flexDirection: "row", flexWrap: "wrap", gap: 8, marginTop: 12 }, children: resolvedFonts.map((font) => {
74
+ const isSelected = font.key === selectedFont.key;
75
+ return (_jsx(Pressable, { accessibilityHint: "Sets the style of your signature", accessibilityLabel: `Signature font ${font.label}`, accessibilityState: { disabled, selected: isSelected }, "aria-role": "button", disabled: disabled, hitSlop: 8, onPress: () => emitChange({ fontKey: font.key }), style: {
76
+ backgroundColor: isSelected ? theme.surface.neutralLight : theme.surface.base,
77
+ borderColor: isSelected ? theme.border.activeAccent : theme.border.default,
78
+ borderRadius: 8,
79
+ borderWidth: isSelected ? 2 : 1,
80
+ minWidth: 96,
81
+ opacity: disabled ? 0.5 : 1,
82
+ paddingHorizontal: 12,
83
+ paddingVertical: 8,
84
+ }, children: _jsx(NativeText, { numberOfLines: 1, style: { color: theme.text.primary, fontFamily: font.fontFamily, fontSize: 22 }, children: font.label }) }, font.key));
85
+ }) }), _jsx(View, { style: {
86
+ alignItems: "center",
87
+ backgroundColor: theme.surface.base,
88
+ borderColor: theme.border.dark,
89
+ borderRadius: 4,
90
+ borderWidth: 1,
91
+ justifyContent: "center",
92
+ marginTop: 12,
93
+ minHeight: 96,
94
+ paddingHorizontal: 16,
95
+ paddingVertical: 12,
96
+ }, testID: fieldTestIDs.helper ? `${fieldTestIDs.helper}-preview` : undefined, children: _jsx(NativeText, { numberOfLines: 1, style: {
97
+ color: hasName ? theme.text.primary : theme.text.secondaryLight,
98
+ fontFamily: selectedFont.fontFamily,
99
+ fontSize: 40,
100
+ }, children: hasName ? typedName : placeholder }) }), Boolean(helperText) && _jsx(FieldHelperText, { testID: fieldTestIDs.helper, text: helperText })] })));
101
+ };
102
+ //# sourceMappingURL=TypedSignatureField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypedSignatureField.js","sourceRoot":"","sources":["../src/TypedSignatureField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAC,wBAAwB,EAAC,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAC,IAAI,IAAI,UAAU,EAAE,SAAS,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAGjE,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACjC,OAAO,EAAC,4BAA4B,EAAC,MAAM,yBAAyB,CAAC;AAErE;;;GAGG;AACH,MAAM,sBAAsB,GAAG;IAC7B,kBAAkB,EAAE,iBAAiB;IACrC,0BAA0B,EAAE,wBAAwB;IACpD,uBAAuB,EAAE,qBAAqB;IAC9C,sBAAsB,EAAE,qBAAqB;CACrC,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAoB;IACtD,EAAC,UAAU,EAAE,0BAA0B,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,gBAAgB,EAAC;IACxF,EAAC,UAAU,EAAE,uBAAuB,EAAE,GAAG,EAAE,aAAa,EAAE,KAA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AAC,KAAK,GACA,IAlBR,IAAI,CAAC,GAAG,CAmBH,CACb,CAAC;gBACJ,CAAC,CAAC,GACG,EAGP,KAAC,IAAI,IACH,KAAK,EAAE;oBACL,UAAU,EAAE,QAAQ;oBACpB,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;oBACnC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI;oBAC9B,YAAY,EAAE,CAAC;oBACf,WAAW,EAAE,CAAC;oBACd,cAAc,EAAE,QAAQ;oBACxB,SAAS,EAAE,EAAE;oBACb,SAAS,EAAE,EAAE;oBACb,iBAAiB,EAAE,EAAE;oBACrB,eAAe,EAAE,EAAE;iBACpB,EACD,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,MAAM,UAAU,CAAC,CAAC,CAAC,SAAS,YAE1E,KAAC,UAAU,IACT,aAAa,EAAE,CAAC,EAChB,KAAK,EAAE;wBACL,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc;wBAC/D,UAAU,EAAE,YAAY,CAAC,UAAU;wBACnC,QAAQ,EAAE,EAAE;qBACb,YAEA,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,GACvB,GACR,EAEN,OAAO,CAAC,UAAU,CAAC,IAAI,KAAC,eAAe,IAAC,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,IAAI,EAAE,UAAW,GAAI,KACtF,CACR,CAAC;AACJ,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -75,6 +75,7 @@ export * from "./SelectField";
75
75
  export * from "./SidebarNavigation";
76
76
  export * from "./SideDrawer";
77
77
  export * from "./Signature";
78
+ export * from "./SignatureCaptureField";
78
79
  export * from "./SignatureField";
79
80
  export * from "./Slider";
80
81
  export * from "./SocialLoginButton";
@@ -92,8 +93,10 @@ export * from "./Text";
92
93
  export * from "./TextArea";
93
94
  export * from "./TextField";
94
95
  export * from "./Theme";
96
+ export * from "./ThumbsUpDownFeedback";
95
97
  export * from "./Toast";
96
98
  export { Tooltip } from "./Tooltip";
99
+ export * from "./TypedSignatureField";
97
100
  export * from "./table/Table";
98
101
  export * from "./table/Table";
99
102
  export * from "./table/TableBadge";
package/dist/index.js CHANGED
@@ -73,6 +73,7 @@ export * from "./SelectField";
73
73
  export * from "./SidebarNavigation";
74
74
  export * from "./SideDrawer";
75
75
  export * from "./Signature";
76
+ export * from "./SignatureCaptureField";
76
77
  export * from "./SignatureField";
77
78
  export * from "./Slider";
78
79
  export * from "./SocialLoginButton";
@@ -89,8 +90,10 @@ export * from "./Text";
89
90
  export * from "./TextArea";
90
91
  export * from "./TextField";
91
92
  export * from "./Theme";
93
+ export * from "./ThumbsUpDownFeedback";
92
94
  export * from "./Toast";
93
95
  export { Tooltip } from "./Tooltip";
96
+ export * from "./TypedSignatureField";
94
97
  export * from "./table/Table";
95
98
  export * from "./table/Table";
96
99
  export * from "./table/TableBadge";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;A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cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -17,7 +17,11 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
+ "@expo-google-fonts/caveat": "^0.4.2",
21
+ "@expo-google-fonts/dancing-script": "^0.4.2",
22
+ "@expo-google-fonts/great-vibes": "^0.4.1",
20
23
  "@expo-google-fonts/nunito": "^0.4.2",
24
+ "@expo-google-fonts/sacramento": "^0.4.1",
21
25
  "@expo-google-fonts/titillium-web": "^0.4.1",
22
26
  "@expo/vector-icons": "^15.0.3",
23
27
  "@react-native-async-storage/async-storage": "2.2.0",
@@ -137,5 +141,5 @@
137
141
  "test:coverage": "TZ=America/New_York bun run ../scripts/check-coverage.ts",
138
142
  "types": "bun typedoc"
139
143
  },
140
- "version": "0.28.0"
144
+ "version": "0.30.0"
141
145
  }
@@ -458,8 +458,8 @@ describe("AiSuggestionBox in TextArea", () => {
458
458
  );
459
459
 
460
460
  expect(getByTestId("notes-ai-suggestion")).toBeTruthy();
461
- expect(getByTestId("notes-ai-suggestion-thumbs-up")).toBeTruthy();
462
- expect(getByTestId("notes-ai-suggestion-thumbs-down")).toBeTruthy();
461
+ expect(getByTestId("notes-ai-suggestion-feedback-positive")).toBeTruthy();
462
+ expect(getByTestId("notes-ai-suggestion-feedback-negative")).toBeTruthy();
463
463
  expect(getByTestId("notes-ai-suggestion-hide")).toBeTruthy();
464
464
  expect(getByTestId("notes-ai-suggestion-add")).toBeTruthy();
465
465
  });
@@ -1,12 +1,12 @@
1
1
  import {type FC, useCallback, useEffect, useState} from "react";
2
- import {Pressable, View} from "react-native";
2
+ import {View} from "react-native";
3
3
 
4
4
  import {Button} from "./Button";
5
- import type {AiSuggestionProps} from "./Common";
6
- import {Icon} from "./Icon";
5
+ import type {AiSuggestionProps, ThumbsUpDownFeedbackValue} from "./Common";
7
6
  import {SparklesIcon} from "./icons/SparklesIcon";
8
7
  import {Text} from "./Text";
9
8
  import {useTheme} from "./Theme";
9
+ import {ThumbsUpDownFeedback} from "./ThumbsUpDownFeedback";
10
10
 
11
11
  export interface AiSuggestionBoxProps extends AiSuggestionProps {
12
12
  testID?: string;
@@ -111,54 +111,23 @@ export const AiSuggestionBox: FC<AiSuggestionBoxProps> = ({
111
111
  }
112
112
  }, [status, onShow]);
113
113
 
114
- const handleThumbsUp = useCallback(() => {
115
- if (!onFeedback) {
116
- return;
117
- }
118
- onFeedback(feedback === "like" ? null : "like");
119
- }, [onFeedback, feedback]);
120
-
121
- const handleThumbsDown = useCallback(() => {
122
- if (!onFeedback) {
123
- return;
124
- }
125
- onFeedback(feedback === "dislike" ? null : "dislike");
126
- }, [onFeedback, feedback]);
114
+ const handleFeedbackChange = useCallback(
115
+ (nextValue?: ThumbsUpDownFeedbackValue) => {
116
+ if (!onFeedback) {
117
+ return;
118
+ }
119
+ // ThumbsUpDownFeedback already clears a repeated selection, so undefined means "no feedback".
120
+ onFeedback(nextValue === undefined ? null : nextValue === "positive" ? "like" : "dislike");
121
+ },
122
+ [onFeedback]
123
+ );
127
124
 
128
125
  const renderFeedback = () => (
129
- <View
130
- style={{alignItems: "center", flexDirection: "row"}}
126
+ <ThumbsUpDownFeedback
127
+ onChange={handleFeedbackChange}
131
128
  testID={testID ? `${testID}-feedback` : undefined}
132
- >
133
- <Pressable
134
- accessibilityLabel="Thumbs up"
135
- accessibilityRole="button"
136
- onPress={handleThumbsUp}
137
- style={{alignItems: "center", height: 24, justifyContent: "center", width: 24}}
138
- testID={testID ? `${testID}-thumbs-up` : undefined}
139
- >
140
- <Icon
141
- color={feedback === "like" ? "secondaryDark" : "secondaryLight"}
142
- iconName="thumbs-up"
143
- size="md"
144
- type={feedback === "like" ? "solid" : "regular"}
145
- />
146
- </Pressable>
147
- <Pressable
148
- accessibilityLabel="Thumbs down"
149
- accessibilityRole="button"
150
- onPress={handleThumbsDown}
151
- style={{alignItems: "center", height: 24, justifyContent: "center", width: 24}}
152
- testID={testID ? `${testID}-thumbs-down` : undefined}
153
- >
154
- <Icon
155
- color={feedback === "dislike" ? "secondaryDark" : "secondaryLight"}
156
- iconName="thumbs-down"
157
- size="md"
158
- type={feedback === "dislike" ? "solid" : "regular"}
159
- />
160
- </Pressable>
161
- </View>
129
+ value={feedback === "like" ? "positive" : feedback === "dislike" ? "negative" : undefined}
130
+ />
162
131
  );
163
132
 
164
133
  if (status === "not-started" || status === "generating") {
package/src/Common.ts CHANGED
@@ -1521,6 +1521,34 @@ export interface BadgeProps extends WithTestID {
1521
1521
  variant?: "iconOnly" | "numberOnly";
1522
1522
  }
1523
1523
 
1524
+ export type ThumbsUpDownFeedbackValue = "positive" | "negative";
1525
+
1526
+ export interface ThumbsUpDownFeedbackProps extends WithTestID {
1527
+ /**
1528
+ * If true, both options are non-interactive and rendered in a muted color.
1529
+ * @default false
1530
+ */
1531
+ disabled?: boolean;
1532
+ /**
1533
+ * Accessibility label for the negative (thumbs down) option.
1534
+ * @default "Thumbs down"
1535
+ */
1536
+ negativeAccessibilityLabel?: string;
1537
+ /**
1538
+ * Called with the newly selected value, or undefined when the current value is deselected.
1539
+ */
1540
+ onChange: (value?: ThumbsUpDownFeedbackValue) => void | Promise<void>;
1541
+ /**
1542
+ * Accessibility label for the positive (thumbs up) option.
1543
+ * @default "Thumbs up"
1544
+ */
1545
+ positiveAccessibilityLabel?: string;
1546
+ /**
1547
+ * The currently selected feedback. Leave undefined for no selection.
1548
+ */
1549
+ value?: ThumbsUpDownFeedbackValue;
1550
+ }
1551
+
1524
1552
  export interface SelectBadgeProps {
1525
1553
  /**
1526
1554
  * When status is "custom", determines the badge's background color.
@@ -2145,6 +2173,103 @@ export interface SignatureFieldProps {
2145
2173
  fullWidth?: boolean;
2146
2174
  }
2147
2175
 
2176
+ /**
2177
+ * A selectable signature typeface. `key` is the stable identifier consumers persist
2178
+ * (so a stored signature keeps rendering in the same style even if `fontFamily` or
2179
+ * `label` are later renamed); `fontFamily` is the loaded font family used for rendering;
2180
+ * `label` is the human-readable name shown in the font picker.
2181
+ */
2182
+ export interface SignatureFont {
2183
+ key: string;
2184
+ label: string;
2185
+ fontFamily: string;
2186
+ }
2187
+
2188
+ /**
2189
+ * The persisted value of a typed signature: the name the signer typed and the `key` of
2190
+ * the font they chose. Kept minimal so consumers can store it directly and re-render the
2191
+ * signature deterministically.
2192
+ */
2193
+ export interface TypedSignatureValue {
2194
+ typedName: string;
2195
+ fontKey: string;
2196
+ }
2197
+
2198
+ export interface TypedSignatureFieldProps extends WithTestID {
2199
+ testIDs?: FieldTestIDs;
2200
+ /** Section title rendered above the field. Defaults to "Signature". */
2201
+ title?: string;
2202
+ /** Controlled value. When omitted the field starts empty with the first font selected. */
2203
+ value?: TypedSignatureValue;
2204
+ onChange: (value: TypedSignatureValue) => void;
2205
+ /**
2206
+ * Selectable fonts. Defaults to the library's bundled signature fonts. When supplying a
2207
+ * custom list, the consumer is responsible for loading those font families (e.g. via
2208
+ * expo-font) so the preview renders correctly.
2209
+ */
2210
+ fonts?: SignatureFont[];
2211
+ /** Label for the name input. Defaults to "Full name". */
2212
+ nameLabel?: string;
2213
+ /** Placeholder for the name input. Defaults to "Type your full name". */
2214
+ placeholder?: string;
2215
+ helperText?: string;
2216
+ errorText?: string;
2217
+ disabled?: boolean; // default false
2218
+ }
2219
+
2220
+ /** Which capture method the signer is using in a {@link SignatureCaptureFieldProps} field. */
2221
+ export type SignatureMode = "draw" | "type";
2222
+
2223
+ /** A signature captured by drawing: a base64 PNG data URL. */
2224
+ export interface DrawnSignatureValue {
2225
+ mode: "draw";
2226
+ image: string;
2227
+ }
2228
+
2229
+ /** A signature captured by typing: a name plus the chosen font key. */
2230
+ export interface TypedSignatureCaptureValue extends TypedSignatureValue {
2231
+ mode: "type";
2232
+ }
2233
+
2234
+ /**
2235
+ * The persisted value of a signature capture field. The `mode` discriminant tells consumers
2236
+ * how to render it: `draw` carries a base64 PNG `image`; `type` carries a `typedName` and
2237
+ * `fontKey`.
2238
+ */
2239
+ export type SignatureCaptureValue = DrawnSignatureValue | TypedSignatureCaptureValue;
2240
+
2241
+ export interface SignatureCaptureFieldProps extends WithTestID {
2242
+ testIDs?: FieldTestIDs;
2243
+ /** Section title rendered above the field. Defaults to "Signature". */
2244
+ title?: string;
2245
+ /** Controlled value. When omitted the field starts empty in `defaultMode`. */
2246
+ value?: SignatureCaptureValue;
2247
+ onChange: (value: SignatureCaptureValue) => void;
2248
+ /**
2249
+ * Which capture method is shown first when the field is empty. Ignored once `value` has a
2250
+ * mode. Defaults to "type".
2251
+ */
2252
+ defaultMode?: SignatureMode;
2253
+ /**
2254
+ * Fonts offered in "type" mode. Defaults to the library's bundled signature fonts. When
2255
+ * supplying a custom list, the consumer must load those font families themselves.
2256
+ */
2257
+ fonts?: SignatureFont[];
2258
+ /** Label for the typed name input. Defaults to "Full name". */
2259
+ nameLabel?: string;
2260
+ /** Placeholder for the typed name input. Defaults to "Type your full name". */
2261
+ placeholder?: string;
2262
+ /** Stretches the draw pad to the full available width. */
2263
+ fullWidth?: boolean;
2264
+ /** Fired when the signer starts drawing — use to disable a parent ScrollView. */
2265
+ onStart?: () => void;
2266
+ /** Fired when the signer stops drawing — use to re-enable a parent ScrollView. */
2267
+ onEnd?: () => void;
2268
+ helperText?: string;
2269
+ errorText?: string;
2270
+ disabled?: boolean; // default false
2271
+ }
2272
+
2148
2273
  export interface SideDrawerProps {
2149
2274
  // Position of the drawer relative to the child
2150
2275
  position?: "right" | "left";
@@ -0,0 +1,161 @@
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import {act, fireEvent, waitFor} from "@testing-library/react-native";
3
+
4
+ import {ConsentHistory} from "./ConsentHistory";
5
+ import {renderWithTheme} from "./test-utils";
6
+ import type {ConsentHistoryEntry} from "./useConsentHistory";
7
+
8
+ type ConsentHistoryApi = Parameters<typeof ConsentHistory>[0]["api"];
9
+
10
+ const makeEntry = (overrides: Partial<ConsentHistoryEntry> = {}): ConsentHistoryEntry => ({
11
+ _id: "entry-1",
12
+ agreed: true,
13
+ agreedAt: "2026-01-02T03:04:05.000Z",
14
+ form: {
15
+ captureSignature: true,
16
+ checkboxes: [{label: "I have read the terms", required: true}],
17
+ slug: "tos",
18
+ title: "Terms of Service",
19
+ type: "terms",
20
+ version: 3,
21
+ },
22
+ ...overrides,
23
+ });
24
+
25
+ const createApi = (state: {
26
+ data?: unknown;
27
+ error?: unknown;
28
+ isLoading?: boolean;
29
+ refetch?: () => void;
30
+ }): ConsentHistoryApi => {
31
+ const api = {
32
+ enhanceEndpoints: () => ({
33
+ injectEndpoints: () => ({
34
+ useGetMyConsentsQuery: () => ({
35
+ data: state.data,
36
+ error: state.error,
37
+ isLoading: state.isLoading ?? false,
38
+ refetch: state.refetch ?? (() => {}),
39
+ }),
40
+ }),
41
+ }),
42
+ };
43
+ return api as unknown as ConsentHistoryApi;
44
+ };
45
+
46
+ describe("ConsentHistory", () => {
47
+ it("renders a spinner while loading", () => {
48
+ const {queryByTestId} = renderWithTheme(
49
+ <ConsentHistory api={createApi({isLoading: true})} title="History" />
50
+ );
51
+ expect(queryByTestId("consent-history-list")).toBeNull();
52
+ });
53
+
54
+ it("renders an error state with a retry button", async () => {
55
+ const refetch = mock(() => {});
56
+ const {getByText} = renderWithTheme(
57
+ <ConsentHistory api={createApi({error: new Error("boom"), refetch})} />
58
+ );
59
+ expect(getByText("Failed to load consent history")).toBeTruthy();
60
+
61
+ await act(async () => {
62
+ fireEvent.press(getByText("Retry"));
63
+ // Button debounces presses.
64
+ await new Promise((resolve) => setTimeout(resolve, 100));
65
+ });
66
+
67
+ await waitFor(() => {
68
+ expect(refetch).toHaveBeenCalled();
69
+ });
70
+ });
71
+
72
+ it("renders an empty state when there are no entries", () => {
73
+ const {getByText} = renderWithTheme(<ConsentHistory api={createApi({data: []})} />);
74
+ expect(getByText("No consent records found.")).toBeTruthy();
75
+ });
76
+
77
+ it("renders each entry with its form title, type and agreed badge", () => {
78
+ const {getByTestId, getByText} = renderWithTheme(
79
+ <ConsentHistory api={createApi({data: [makeEntry()]})} />
80
+ );
81
+ expect(getByTestId("consent-history-list")).toBeTruthy();
82
+ expect(getByText("Terms of Service")).toBeTruthy();
83
+ expect(getByText("terms")).toBeTruthy();
84
+ expect(getByText("Agreed")).toBeTruthy();
85
+ });
86
+
87
+ it("falls back to placeholder text when the form is missing and shows declined entries", () => {
88
+ const {getByText} = renderWithTheme(
89
+ <ConsentHistory api={createApi({data: [makeEntry({agreed: false, form: null})]})} />
90
+ );
91
+ expect(getByText("Unknown Form")).toBeTruthy();
92
+ expect(getByText("Declined")).toBeTruthy();
93
+ });
94
+
95
+ it("expands and collapses the entry details when pressed", () => {
96
+ const {getByTestId, queryByTestId} = renderWithTheme(
97
+ <ConsentHistory api={createApi({data: [makeEntry()]})} />
98
+ );
99
+ expect(queryByTestId("consent-history-item-details-entry-1")).toBeNull();
100
+ fireEvent.press(getByTestId("consent-history-item-toggle-entry-1"));
101
+ expect(getByTestId("consent-history-item-details-entry-1")).toBeTruthy();
102
+ fireEvent.press(getByTestId("consent-history-item-toggle-entry-1"));
103
+ expect(queryByTestId("consent-history-item-details-entry-1")).toBeNull();
104
+ });
105
+
106
+ it("shows every optional detail when expanded", () => {
107
+ const entry = makeEntry({
108
+ checkboxValues: {"0": true, "1": false},
109
+ contentSnapshot: "# Snapshot",
110
+ ipAddress: "10.0.0.1",
111
+ locale: "en-US",
112
+ signature: "data:image/png;base64,abc",
113
+ signedAt: "2026-01-02T03:05:00.000Z",
114
+ });
115
+ const {getByTestId, getByText} = renderWithTheme(
116
+ <ConsentHistory api={createApi({data: [entry]})} />
117
+ );
118
+ fireEvent.press(getByTestId("consent-history-item-toggle-entry-1"));
119
+
120
+ expect(getByText("Version:")).toBeTruthy();
121
+ expect(getByText("3")).toBeTruthy();
122
+ expect(getByText("Locale:")).toBeTruthy();
123
+ expect(getByText("en-US")).toBeTruthy();
124
+ expect(getByText("Signed:")).toBeTruthy();
125
+ expect(getByText("IP Address:")).toBeTruthy();
126
+ expect(getByText("10.0.0.1")).toBeTruthy();
127
+ expect(getByText("Checkboxes")).toBeTruthy();
128
+ // Labelled from the form for index 0, generic fallback for index 1.
129
+ expect(getByText("I have read the terms")).toBeTruthy();
130
+ expect(getByText("Checkbox 1")).toBeTruthy();
131
+ expect(getByText("Yes")).toBeTruthy();
132
+ expect(getByText("No")).toBeTruthy();
133
+ expect(getByTestId("consent-history-signature-entry-1")).toBeTruthy();
134
+ expect(getByText("Form Content")).toBeTruthy();
135
+ });
136
+
137
+ it("renders raw date values that cannot be parsed and skips empty ones", () => {
138
+ const {getByTestId, getByText, queryByText} = renderWithTheme(
139
+ <ConsentHistory
140
+ api={createApi({data: [makeEntry({agreedAt: "not-a-date", signedAt: undefined})]})}
141
+ />
142
+ );
143
+ expect(getByText("not-a-date")).toBeTruthy();
144
+ fireEvent.press(getByTestId("consent-history-item-toggle-entry-1"));
145
+ expect(queryByText("Signed:")).toBeNull();
146
+ });
147
+
148
+ it("renders nothing for a blank date", () => {
149
+ const {getByTestId} = renderWithTheme(
150
+ <ConsentHistory api={createApi({data: [makeEntry({agreedAt: ""})]})} />
151
+ );
152
+ expect(getByTestId("consent-history-item-entry-1")).toBeTruthy();
153
+ });
154
+
155
+ it("unwraps a paginated response body", () => {
156
+ const {getByTestId} = renderWithTheme(
157
+ <ConsentHistory api={createApi({data: {data: [makeEntry()]}})} />
158
+ );
159
+ expect(getByTestId("consent-history-item-entry-1")).toBeTruthy();
160
+ });
161
+ });
@@ -11,6 +11,8 @@ interface Props {
11
11
  onStart?: () => void;
12
12
  onEnd?: () => void;
13
13
  fullWidth?: boolean;
14
+ /** Test id applied to the drawing surface. */
15
+ testID?: string;
14
16
  }
15
17
 
16
18
  const STROKE_WIDTH_PX = 2.5;
@@ -32,7 +34,13 @@ const SNAPSHOT_DELAY_MS = 60;
32
34
  * Reports the signature to the parent as a base64 PNG data URL via onChange,
33
35
  * and pushes "" on clear so "signature required" gating resets immediately.
34
36
  */
35
- export const Signature: FC<Props> = ({fullWidth = false, onChange, onStart, onEnd}: Props) => {
37
+ export const Signature: FC<Props> = ({
38
+ fullWidth = false,
39
+ onChange,
40
+ onStart,
41
+ onEnd,
42
+ testID,
43
+ }: Props) => {
36
44
  const {theme} = useTheme();
37
45
  const canvasRef = useCanvasRef();
38
46
  const signaturePadHeight = getSignaturePadHeight(Platform.OS);
@@ -140,7 +148,7 @@ export const Signature: FC<Props> = ({fullWidth = false, onChange, onStart, onEn
140
148
  }, [clearSnapshotTimer, onChange]);
141
149
 
142
150
  return (
143
- <View style={{minWidth: 220, width: fullWidth ? "100%" : undefined}}>
151
+ <View style={{minWidth: 220, width: fullWidth ? "100%" : undefined}} testID={testID}>
144
152
  <GestureDetector gesture={panGesture}>
145
153
  <View
146
154
  style={{
package/src/Signature.tsx CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  import {Text, View} from "react-native";
9
9
 
10
10
  import {useTheme} from "./Theme";
11
+ import {toDomTestProps} from "./testing/resolveTestId";
11
12
 
12
13
  export interface SignatureProps {
13
14
  onChange: (signature: string) => void;
@@ -15,6 +16,8 @@ export interface SignatureProps {
15
16
  onEnd?: () => void;
16
17
  fullWidth?: boolean;
17
18
  value?: string; // note this
19
+ /** Test id applied to the drawing surface (the canvas on web). */
20
+ testID?: string;
18
21
  }
19
22
 
20
23
  const SIGNATURE_WIDTH_PX = 300;
@@ -40,6 +43,7 @@ export const Signature = ({
40
43
  onChange,
41
44
  onStart,
42
45
  onEnd,
46
+ testID,
43
47
  }: SignatureProps): ReactElement => {
44
48
  const {theme} = useTheme();
45
49
  const canvasRef = useRef<HTMLCanvasElement | null>(null);
@@ -168,6 +172,7 @@ export const Signature = ({
168
172
  }}
169
173
  >
170
174
  <canvas
175
+ {...toDomTestProps(testID)}
171
176
  height={SIGNATURE_HEIGHT_PX}
172
177
  onPointerDown={handlePointerDown}
173
178
  onPointerLeave={handlePointerUp}