@terreno/ui 0.23.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AiSuggestionBox.d.ts +11 -0
- package/dist/AiSuggestionBox.js +50 -23
- package/dist/AiSuggestionBox.js.map +1 -1
- package/dist/Common.d.ts +9 -1
- package/dist/Common.js.map +1 -1
- package/dist/icons/SparklesIcon.d.ts +7 -0
- package/dist/icons/SparklesIcon.js +32 -0
- package/dist/icons/SparklesIcon.js.map +1 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +1 -0
- package/dist/icons/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ActionSheet.test.tsx +96 -0
- package/src/AiSuggestionBox.test.tsx +184 -15
- package/src/AiSuggestionBox.tsx +72 -55
- package/src/Common.ts +9 -1
- package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +489 -102
- package/src/icons/SparklesIcon.test.tsx +16 -0
- package/src/icons/SparklesIcon.tsx +38 -0
- package/src/icons/__snapshots__/SparklesIcon.test.tsx.snap +47 -0
- package/src/icons/index.ts +1 -0
|
@@ -3,4 +3,15 @@ import type { AiSuggestionProps } from "./Common";
|
|
|
3
3
|
export interface AiSuggestionBoxProps extends AiSuggestionProps {
|
|
4
4
|
testID?: string;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Inline AI suggestion box rendered inside TextField/TextArea via the `aiSuggestion` prop.
|
|
8
|
+
*
|
|
9
|
+
* Expansion is derived from the persisted `status` (`ready` expands; `hidden` and `added`
|
|
10
|
+
* condense into the collapsed header row), but an explicit user Show/Hide toggle always
|
|
11
|
+
* wins — including while a hide/show mutation is still in flight — so a quick
|
|
12
|
+
* Hide-then-Show never snaps back to collapsed when the earlier hide's refetch lands.
|
|
13
|
+
* Hide/Show on a non-`added` suggestion also invoke `onHide`/`onShow` so consumers can
|
|
14
|
+
* persist the choice; toggling an `added` suggestion is purely local so the acceptance
|
|
15
|
+
* record is never reset. "Add to note" stays available after a first add for re-adds.
|
|
16
|
+
*/
|
|
6
17
|
export declare const AiSuggestionBox: FC<AiSuggestionBoxProps>;
|
package/dist/AiSuggestionBox.js
CHANGED
|
@@ -1,18 +1,42 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useState } from "react";
|
|
3
3
|
import { Pressable, View } from "react-native";
|
|
4
|
+
import { Button } from "./Button";
|
|
4
5
|
import { Icon } from "./Icon";
|
|
6
|
+
import { SparklesIcon } from "./icons";
|
|
5
7
|
import { Text } from "./Text";
|
|
6
8
|
import { useTheme } from "./Theme";
|
|
9
|
+
/**
|
|
10
|
+
* Inline AI suggestion box rendered inside TextField/TextArea via the `aiSuggestion` prop.
|
|
11
|
+
*
|
|
12
|
+
* Expansion is derived from the persisted `status` (`ready` expands; `hidden` and `added`
|
|
13
|
+
* condense into the collapsed header row), but an explicit user Show/Hide toggle always
|
|
14
|
+
* wins — including while a hide/show mutation is still in flight — so a quick
|
|
15
|
+
* Hide-then-Show never snaps back to collapsed when the earlier hide's refetch lands.
|
|
16
|
+
* Hide/Show on a non-`added` suggestion also invoke `onHide`/`onShow` so consumers can
|
|
17
|
+
* persist the choice; toggling an `added` suggestion is purely local so the acceptance
|
|
18
|
+
* record is never reset. "Add to note" stays available after a first add for re-adds.
|
|
19
|
+
*/
|
|
7
20
|
export const AiSuggestionBox = ({ status, text, onAdd, onHide, onShow, onFeedback, feedback, notStartedText = "AI note will be generated once the session ends.", generatingText = "AI note generation in progress...", testID, }) => {
|
|
8
21
|
const { theme } = useTheme();
|
|
9
|
-
|
|
10
|
-
//
|
|
22
|
+
// The user's last explicit Show/Hide choice. While set, it overrides the
|
|
23
|
+
// status-derived default so in-flight hide/show mutations can't undo a newer click.
|
|
24
|
+
const [expandedIntent, setExpandedIntent] = useState(null);
|
|
25
|
+
// Reconcile the local intent with persisted status transitions. Accepting a suggestion
|
|
26
|
+
// (`added`) always condenses the box, and once the persisted status agrees with the
|
|
27
|
+
// user's intent the override is dropped so later transitions (e.g. a regenerated
|
|
28
|
+
// suggestion flipping back to `ready`) use their status defaults. An intent that
|
|
29
|
+
// disagrees with the incoming status is kept — that status is a stale in-flight
|
|
30
|
+
// hide/show landing after a newer click, and must not undo it.
|
|
11
31
|
useEffect(() => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
32
|
+
setExpandedIntent((current) => {
|
|
33
|
+
if (current === null || status === "added") {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return current === (status === "ready") ? null : current;
|
|
37
|
+
});
|
|
15
38
|
}, [status]);
|
|
39
|
+
const expanded = expandedIntent !== null && expandedIntent !== void 0 ? expandedIntent : status === "ready";
|
|
16
40
|
const isAdded = status === "added";
|
|
17
41
|
const backgroundColor = isAdded
|
|
18
42
|
? theme.surface.successLight
|
|
@@ -43,13 +67,23 @@ export const AiSuggestionBox = ({ status, text, onAdd, onHide, onShow, onFeedbac
|
|
|
43
67
|
? "AI-generated note"
|
|
44
68
|
: "AI-generated note (hidden)";
|
|
45
69
|
const handleHide = useCallback(() => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
70
|
+
setExpandedIntent(false);
|
|
71
|
+
// Persist the hide for any non-`added` suggestion — even when the status still reads
|
|
72
|
+
// `hidden` locally (an un-hide may be in flight). Hiding an `added` suggestion is a
|
|
73
|
+
// purely local collapse so the acceptance record stays intact.
|
|
74
|
+
if (status !== "added") {
|
|
75
|
+
onHide === null || onHide === void 0 ? void 0 : onHide();
|
|
76
|
+
}
|
|
77
|
+
}, [status, onHide]);
|
|
49
78
|
const handleShow = useCallback(() => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
79
|
+
setExpandedIntent(true);
|
|
80
|
+
// Persist the un-hide for any non-`added` suggestion — even when the status still
|
|
81
|
+
// reads `ready` locally (a hide may be in flight, and this Show must override it).
|
|
82
|
+
// Expanding an `added` suggestion must not reset its status.
|
|
83
|
+
if (status !== "added") {
|
|
84
|
+
onShow === null || onShow === void 0 ? void 0 : onShow();
|
|
85
|
+
}
|
|
86
|
+
}, [status, onShow]);
|
|
53
87
|
const handleThumbsUp = useCallback(() => {
|
|
54
88
|
if (!onFeedback) {
|
|
55
89
|
return;
|
|
@@ -62,26 +96,19 @@ export const AiSuggestionBox = ({ status, text, onAdd, onHide, onShow, onFeedbac
|
|
|
62
96
|
}
|
|
63
97
|
onFeedback(feedback === "dislike" ? null : "dislike");
|
|
64
98
|
}, [onFeedback, feedback]);
|
|
65
|
-
const renderFeedback = () => (_jsxs(View, { style: { alignItems: "center", flexDirection: "row" }, testID: testID ? `${testID}-feedback` : undefined, children: [_jsx(Pressable, { accessibilityLabel: "Thumbs up", accessibilityRole: "button", onPress: handleThumbsUp, style: { alignItems: "center", height: 24, justifyContent: "center", width: 24 }, testID: testID ? `${testID}-thumbs-up` : undefined, children: _jsx(Icon, { color: feedback === "like" ? "secondaryDark" : "secondaryLight", iconName: "thumbs-up", size: "
|
|
99
|
+
const renderFeedback = () => (_jsxs(View, { style: { alignItems: "center", flexDirection: "row" }, testID: testID ? `${testID}-feedback` : undefined, children: [_jsx(Pressable, { accessibilityLabel: "Thumbs up", accessibilityRole: "button", onPress: handleThumbsUp, style: { alignItems: "center", height: 24, justifyContent: "center", width: 24 }, testID: testID ? `${testID}-thumbs-up` : undefined, children: _jsx(Icon, { color: feedback === "like" ? "secondaryDark" : "secondaryLight", iconName: "thumbs-up", size: "md", type: feedback === "like" ? "solid" : "regular" }) }), _jsx(Pressable, { accessibilityLabel: "Thumbs down", accessibilityRole: "button", onPress: handleThumbsDown, style: { alignItems: "center", height: 24, justifyContent: "center", width: 24 }, testID: testID ? `${testID}-thumbs-down` : undefined, children: _jsx(Icon, { color: feedback === "dislike" ? "secondaryDark" : "secondaryLight", iconName: "thumbs-down", size: "md", type: feedback === "dislike" ? "solid" : "regular" }) })] }));
|
|
66
100
|
if (status === "not-started" || status === "generating") {
|
|
67
|
-
return (_jsx(View, { style: containerStyle, testID: testID, children: _jsxs(View, { style: { alignItems: "center", flexDirection: "row", gap: 4, width: "100%" }, children: [_jsx(
|
|
101
|
+
return (_jsx(View, { style: containerStyle, testID: testID, children: _jsxs(View, { style: { alignItems: "center", flexDirection: "row", gap: 4, width: "100%" }, children: [_jsx(SparklesIcon, { fill: theme.text.secondaryDark }), _jsx(View, { style: { flex: 1 }, children: _jsx(Text, { color: "secondaryDark", size: "sm", children: headingText }) })] }) }));
|
|
68
102
|
}
|
|
69
103
|
if (!expanded) {
|
|
70
|
-
return (_jsx(View, { style: Object.assign(Object.assign({}, containerStyle), { flexDirection: "column" }), testID: testID, children: _jsxs(View, { style: { alignItems: "center", flexDirection: "row", gap: 4, width: "100%" }, children: [_jsx(
|
|
104
|
+
return (_jsx(View, { style: Object.assign(Object.assign({}, containerStyle), { flexDirection: "column" }), testID: testID, children: _jsxs(View, { style: { alignItems: "center", flexDirection: "row", gap: 4, width: "100%" }, children: [_jsx(SparklesIcon, { fill: theme.text.secondaryDark }), _jsx(View, { style: { flex: 1 }, children: _jsx(Text, { color: "secondaryDark", size: "sm", children: headingText }) }), _jsxs(View, { style: { alignItems: "center", flexDirection: "row", gap: 4 }, children: [_jsx(Button, { onClick: handleShow, size: "sm", testID: testID ? `${testID}-show` : undefined, text: "Show", variant: "ghost" }), renderFeedback()] })] }) }));
|
|
71
105
|
}
|
|
72
|
-
return (_jsxs(View, { style: Object.assign(Object.assign({}, containerStyle), { alignItems: "flex-end" }), testID: testID, children: [_jsxs(View, { style: { alignItems: "center", flexDirection: "row", gap: 4, width: "100%" }, children: [_jsx(
|
|
106
|
+
return (_jsxs(View, { style: Object.assign(Object.assign({}, containerStyle), { alignItems: "flex-end" }), testID: testID, children: [_jsxs(View, { style: { alignItems: "center", flexDirection: "row", gap: 4, width: "100%" }, children: [_jsx(SparklesIcon, { fill: theme.text.secondaryDark }), _jsx(View, { style: { flex: 1 }, children: _jsx(Text, { color: "secondaryDark", size: "sm", children: headingText }) }), renderFeedback()] }), Boolean(text) && (_jsx(View, { style: { paddingBottom: 4, width: "100%" }, children: _jsx(Text, { size: "md", children: text }) })), _jsxs(View, { style: {
|
|
73
107
|
alignItems: "center",
|
|
74
108
|
flexDirection: "row",
|
|
75
109
|
gap: 8,
|
|
76
110
|
justifyContent: "flex-end",
|
|
77
111
|
width: "100%",
|
|
78
|
-
}, children: [_jsx(
|
|
79
|
-
alignItems: "center",
|
|
80
|
-
backgroundColor: theme.surface.secondaryDark,
|
|
81
|
-
borderRadius: 360,
|
|
82
|
-
height: 28,
|
|
83
|
-
justifyContent: "center",
|
|
84
|
-
paddingHorizontal: 16,
|
|
85
|
-
}, testID: testID ? `${testID}-add` : undefined, children: _jsx(Text, { bold: true, color: "inverted", size: "sm", children: "Add to note" }) })] })] }));
|
|
112
|
+
}, children: [_jsx(Button, { onClick: handleHide, size: "sm", testID: testID ? `${testID}-hide` : undefined, text: "Hide", variant: "ghost" }), Boolean(onAdd) && (_jsx(Button, { onClick: onAdd, size: "sm", testID: testID ? `${testID}-add` : undefined, text: "Add to note", variant: "secondary" }))] })] }));
|
|
86
113
|
};
|
|
87
114
|
//# sourceMappingURL=AiSuggestionBox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiSuggestionBox.js","sourceRoot":"","sources":["../src/AiSuggestionBox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAU,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAChE,OAAO,EAAC,SAAS,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"AiSuggestionBox.js","sourceRoot":"","sources":["../src/AiSuggestionBox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAU,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAChE,OAAO,EAAC,SAAS,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAE7C,OAA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
|
|
582
582
|
export interface AiSuggestionProps {
|
|
583
|
-
|
|
583
|
+
/**
|
|
584
|
+
* Persisted suggestion state. `ready` renders expanded; `hidden` and `added` render
|
|
585
|
+
* condensed into the collapsed header row (re-expandable with "Show") so a hidden or
|
|
586
|
+
* accepted suggestion never disappears entirely.
|
|
587
|
+
*/
|
|
588
|
+
status: "not-started" | "generating" | "ready" | "added" | "hidden";
|
|
584
589
|
text?: string;
|
|
590
|
+
/** Adds the suggestion text to the note. Stays available after adding for re-adds. */
|
|
585
591
|
onAdd?: () => void;
|
|
592
|
+
/** Persists a hide. Called for any non-`added` status when the user presses "Hide". */
|
|
586
593
|
onHide?: () => void;
|
|
594
|
+
/** Persists an un-hide. Called for any non-`added` status when the user presses "Show". */
|
|
587
595
|
onShow?: () => void;
|
|
588
596
|
onFeedback?: (feedback: "like" | "dislike" | null) => void;
|
|
589
597
|
feedback?: "like" | "dislike" | null;
|
package/dist/Common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../src/Common.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,4BAA4B,EAC5B,4BAA4B,EAC5B,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,WAAW,GACZ,MAAM,WAAW,CAAC;AA0ZnB,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;CACP,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAqB,E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AG,CAAC,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,WAAW,CAAC,OAAyB,CAAC,CAAC;AAChD,CAAC,CAAC;AAqBF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAe,EAAE,EAAE;IAClD,OAAO;QACL,KAAK,EAAE,EAAE;QACT,EAAE,EAAE,EAAE;QACN,EAAE,EAAE,EAAE;QACN,EAAE,EAAE,EAAE;QACN,EAAE,EAAE,EAAE;QACN,EAAE,EAAE,CAAC;KACN,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;AAClB,CAAC,CAAC;AAqXF,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,GAAG;IACV,OAAO,EAAE,CAAC;IACV,IAAI,EAAE,EAAE;IACR,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,CAAC;IACL,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,GAAG;IACZ,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,EAAE;CACP,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAkB,EAAE,EAAE;IAChD,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC,CAAC;AAmpEF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;CACV,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import { type SvgProps } from "react-native-svg";
|
|
3
|
+
/**
|
|
4
|
+
* Solid "sparkles" icon (three four-pointed stars). Defaults to 16x16 — pass
|
|
5
|
+
* `height`/`width` to resize and `fill` to recolor.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SparklesIcon: (props: SvgProps) => React.ReactElement;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Svg, { Path } from "react-native-svg";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a four-pointed sparkle path with concave edges, centered at (cx, cy) with
|
|
5
|
+
* outer radius r. FontAwesome 6 free has no standalone `sparkles` glyph (it is a Pro
|
|
6
|
+
* icon), so the glyph is composed locally from three of these sparkle shapes.
|
|
7
|
+
*/
|
|
8
|
+
const sparklePath = (cx, cy, r) => {
|
|
9
|
+
const pinch = r * 0.16;
|
|
10
|
+
return [
|
|
11
|
+
`M ${cx} ${cy - r}`,
|
|
12
|
+
`Q ${cx + pinch} ${cy - pinch} ${cx + r} ${cy}`,
|
|
13
|
+
`Q ${cx + pinch} ${cy + pinch} ${cx} ${cy + r}`,
|
|
14
|
+
`Q ${cx - pinch} ${cy + pinch} ${cx - r} ${cy}`,
|
|
15
|
+
`Q ${cx - pinch} ${cy - pinch} ${cx} ${cy - r}`,
|
|
16
|
+
"Z",
|
|
17
|
+
].join(" ");
|
|
18
|
+
};
|
|
19
|
+
/** One large sparkle with two smaller companions, mirroring Font Awesome's sparkles layout. */
|
|
20
|
+
const SPARKLES_PATH = [
|
|
21
|
+
sparklePath(200, 272, 200),
|
|
22
|
+
sparklePath(420, 92, 88),
|
|
23
|
+
sparklePath(420, 428, 80),
|
|
24
|
+
].join(" ");
|
|
25
|
+
/**
|
|
26
|
+
* Solid "sparkles" icon (three four-pointed stars). Defaults to 16x16 — pass
|
|
27
|
+
* `height`/`width` to resize and `fill` to recolor.
|
|
28
|
+
*/
|
|
29
|
+
export const SparklesIcon = (props) => {
|
|
30
|
+
return (_jsx(Svg, Object.assign({ fill: "currentColor", height: 16, viewBox: "0 0 512 512", width: 16 }, props, { children: _jsx(Path, { d: SPARKLES_PATH }) })));
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=SparklesIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SparklesIcon.js","sourceRoot":"","s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,IAAI,IAAC,CAAC,EAAE,aAAa,GAAI,IACtB,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/icons/index.d.ts
CHANGED
package/dist/icons/index.js
CHANGED
package/dist/icons/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/icons/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/icons/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
|
package/package.json
CHANGED
package/src/ActionSheet.test.tsx
CHANGED
|
@@ -888,4 +888,100 @@ describe("ActionSheet", () => {
|
|
|
888
888
|
await expect((ref.current as any)._onScrollBegin()).resolves.toBeUndefined();
|
|
889
889
|
});
|
|
890
890
|
});
|
|
891
|
+
|
|
892
|
+
describe("handleChildScrollEnd additional coverage", () => {
|
|
893
|
+
it("recoils when within scroll threshold of initial position", async () => {
|
|
894
|
+
const ref = createRef<ActionSheet>();
|
|
895
|
+
render(
|
|
896
|
+
<ThemeProvider>
|
|
897
|
+
<ActionSheet gestureEnabled ref={ref} springOffset={100}>
|
|
898
|
+
<Text>Content</Text>
|
|
899
|
+
</ActionSheet>
|
|
900
|
+
</ThemeProvider>
|
|
901
|
+
);
|
|
902
|
+
const instance = ref.current as any;
|
|
903
|
+
instance.actionSheetHeight = 500;
|
|
904
|
+
instance.prevScroll = 300;
|
|
905
|
+
instance.offsetY = 250;
|
|
906
|
+
instance.isRecoiling = false;
|
|
907
|
+
instance.currentOffsetFromBottom = 1;
|
|
908
|
+
|
|
909
|
+
await act(async () => {
|
|
910
|
+
await instance.handleChildScrollEnd();
|
|
911
|
+
});
|
|
912
|
+
// After recoil, isRecoiling is set true then cleared after timeout
|
|
913
|
+
await act(async () => {
|
|
914
|
+
await new Promise((r) => setTimeout(r, 600));
|
|
915
|
+
});
|
|
916
|
+
expect(instance.isRecoiling).toBe(false);
|
|
917
|
+
});
|
|
918
|
+
|
|
919
|
+
it("hides modal when scrolled far past threshold", async () => {
|
|
920
|
+
const ref = createRef<ActionSheet>();
|
|
921
|
+
const onClose = mock(() => {});
|
|
922
|
+
render(
|
|
923
|
+
<ThemeProvider>
|
|
924
|
+
<ActionSheet gestureEnabled onClose={onClose} ref={ref} springOffset={50}>
|
|
925
|
+
<Text>Content</Text>
|
|
926
|
+
</ActionSheet>
|
|
927
|
+
</ThemeProvider>
|
|
928
|
+
);
|
|
929
|
+
const instance = ref.current as any;
|
|
930
|
+
instance.actionSheetHeight = 500;
|
|
931
|
+
instance.prevScroll = 300;
|
|
932
|
+
instance.offsetY = 100;
|
|
933
|
+
instance.isRecoiling = false;
|
|
934
|
+
instance.isClosing = false;
|
|
935
|
+
|
|
936
|
+
await act(async () => {
|
|
937
|
+
await instance.handleChildScrollEnd();
|
|
938
|
+
});
|
|
939
|
+
expect(instance.isClosing).toBe(true);
|
|
940
|
+
});
|
|
941
|
+
|
|
942
|
+
it("recoils back to previous position when not past threshold", async () => {
|
|
943
|
+
const ref = createRef<ActionSheet>();
|
|
944
|
+
render(
|
|
945
|
+
<ThemeProvider>
|
|
946
|
+
<ActionSheet gestureEnabled ref={ref} springOffset={100}>
|
|
947
|
+
<Text>Content</Text>
|
|
948
|
+
</ActionSheet>
|
|
949
|
+
</ThemeProvider>
|
|
950
|
+
);
|
|
951
|
+
const instance = ref.current as any;
|
|
952
|
+
instance.actionSheetHeight = 500;
|
|
953
|
+
instance.prevScroll = 300;
|
|
954
|
+
instance.offsetY = 290;
|
|
955
|
+
instance.isRecoiling = false;
|
|
956
|
+
|
|
957
|
+
await act(async () => {
|
|
958
|
+
await instance.handleChildScrollEnd();
|
|
959
|
+
});
|
|
960
|
+
await act(async () => {
|
|
961
|
+
await new Promise((r) => setTimeout(r, 600));
|
|
962
|
+
});
|
|
963
|
+
expect(instance.isRecoiling).toBe(false);
|
|
964
|
+
});
|
|
965
|
+
|
|
966
|
+
it("bounces back when scrolling up beyond prevScroll", async () => {
|
|
967
|
+
const ref = createRef<ActionSheet>();
|
|
968
|
+
render(
|
|
969
|
+
<ThemeProvider>
|
|
970
|
+
<ActionSheet gestureEnabled ref={ref}>
|
|
971
|
+
<Text>Content</Text>
|
|
972
|
+
</ActionSheet>
|
|
973
|
+
</ThemeProvider>
|
|
974
|
+
);
|
|
975
|
+
const instance = ref.current as any;
|
|
976
|
+
instance.prevScroll = 200;
|
|
977
|
+
instance.offsetY = 195;
|
|
978
|
+
instance._scrollTo = mock(() => {});
|
|
979
|
+
await instance.handleChildScrollEnd();
|
|
980
|
+
expect(instance.isRecoiling).toBe(true);
|
|
981
|
+
await act(async () => {
|
|
982
|
+
await new Promise((r) => setTimeout(r, 600));
|
|
983
|
+
});
|
|
984
|
+
expect(instance.isRecoiling).toBe(false);
|
|
985
|
+
});
|
|
986
|
+
});
|
|
891
987
|
});
|