@appsupportkit/support-sdk 0.1.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 (87) hide show
  1. package/lib/commonjs/api.js +93 -0
  2. package/lib/commonjs/api.js.map +1 -0
  3. package/lib/commonjs/components/BottomSheet.js +158 -0
  4. package/lib/commonjs/components/BottomSheet.js.map +1 -0
  5. package/lib/commonjs/components/SupportButton.js +244 -0
  6. package/lib/commonjs/components/SupportButton.js.map +1 -0
  7. package/lib/commonjs/components/icons.js +236 -0
  8. package/lib/commonjs/components/icons.js.map +1 -0
  9. package/lib/commonjs/components/primitives.js +284 -0
  10. package/lib/commonjs/components/primitives.js.map +1 -0
  11. package/lib/commonjs/components/screens/ComposeScreen.js +171 -0
  12. package/lib/commonjs/components/screens/ComposeScreen.js.map +1 -0
  13. package/lib/commonjs/components/screens/HomeScreen.js +227 -0
  14. package/lib/commonjs/components/screens/HomeScreen.js.map +1 -0
  15. package/lib/commonjs/components/screens/ThreadScreen.js +213 -0
  16. package/lib/commonjs/components/screens/ThreadScreen.js.map +1 -0
  17. package/lib/commonjs/index.js +58 -0
  18. package/lib/commonjs/index.js.map +1 -0
  19. package/lib/commonjs/package.json +1 -0
  20. package/lib/commonjs/theme.js +29 -0
  21. package/lib/commonjs/theme.js.map +1 -0
  22. package/lib/commonjs/types.js +14 -0
  23. package/lib/commonjs/types.js.map +1 -0
  24. package/lib/commonjs/utils.js +63 -0
  25. package/lib/commonjs/utils.js.map +1 -0
  26. package/lib/module/api.js +84 -0
  27. package/lib/module/api.js.map +1 -0
  28. package/lib/module/components/BottomSheet.js +153 -0
  29. package/lib/module/components/BottomSheet.js.map +1 -0
  30. package/lib/module/components/SupportButton.js +240 -0
  31. package/lib/module/components/SupportButton.js.map +1 -0
  32. package/lib/module/components/icons.js +225 -0
  33. package/lib/module/components/icons.js.map +1 -0
  34. package/lib/module/components/primitives.js +270 -0
  35. package/lib/module/components/primitives.js.map +1 -0
  36. package/lib/module/components/screens/ComposeScreen.js +167 -0
  37. package/lib/module/components/screens/ComposeScreen.js.map +1 -0
  38. package/lib/module/components/screens/HomeScreen.js +223 -0
  39. package/lib/module/components/screens/HomeScreen.js.map +1 -0
  40. package/lib/module/components/screens/ThreadScreen.js +209 -0
  41. package/lib/module/components/screens/ThreadScreen.js.map +1 -0
  42. package/lib/module/index.js +7 -0
  43. package/lib/module/index.js.map +1 -0
  44. package/lib/module/package.json +1 -0
  45. package/lib/module/theme.js +23 -0
  46. package/lib/module/theme.js.map +1 -0
  47. package/lib/module/types.js +10 -0
  48. package/lib/module/types.js.map +1 -0
  49. package/lib/module/utils.js +57 -0
  50. package/lib/module/utils.js.map +1 -0
  51. package/lib/typescript/api.d.ts +37 -0
  52. package/lib/typescript/api.d.ts.map +1 -0
  53. package/lib/typescript/components/BottomSheet.d.ts +9 -0
  54. package/lib/typescript/components/BottomSheet.d.ts.map +1 -0
  55. package/lib/typescript/components/SupportButton.d.ts +8 -0
  56. package/lib/typescript/components/SupportButton.d.ts.map +1 -0
  57. package/lib/typescript/components/icons.d.ts +32 -0
  58. package/lib/typescript/components/icons.d.ts.map +1 -0
  59. package/lib/typescript/components/primitives.d.ts +60 -0
  60. package/lib/typescript/components/primitives.d.ts.map +1 -0
  61. package/lib/typescript/components/screens/ComposeScreen.d.ts +10 -0
  62. package/lib/typescript/components/screens/ComposeScreen.d.ts.map +1 -0
  63. package/lib/typescript/components/screens/HomeScreen.d.ts +13 -0
  64. package/lib/typescript/components/screens/HomeScreen.d.ts.map +1 -0
  65. package/lib/typescript/components/screens/ThreadScreen.d.ts +10 -0
  66. package/lib/typescript/components/screens/ThreadScreen.d.ts.map +1 -0
  67. package/lib/typescript/index.d.ts +6 -0
  68. package/lib/typescript/index.d.ts.map +1 -0
  69. package/lib/typescript/theme.d.ts +13 -0
  70. package/lib/typescript/theme.d.ts.map +1 -0
  71. package/lib/typescript/types.d.ts +61 -0
  72. package/lib/typescript/types.d.ts.map +1 -0
  73. package/lib/typescript/utils.d.ts +11 -0
  74. package/lib/typescript/utils.d.ts.map +1 -0
  75. package/package.json +51 -0
  76. package/src/api.ts +125 -0
  77. package/src/components/BottomSheet.tsx +173 -0
  78. package/src/components/SupportButton.tsx +265 -0
  79. package/src/components/icons.tsx +189 -0
  80. package/src/components/primitives.tsx +298 -0
  81. package/src/components/screens/ComposeScreen.tsx +163 -0
  82. package/src/components/screens/HomeScreen.tsx +234 -0
  83. package/src/components/screens/ThreadScreen.tsx +227 -0
  84. package/src/index.tsx +24 -0
  85. package/src/theme.ts +39 -0
  86. package/src/types.ts +71 -0
  87. package/src/utils.ts +63 -0
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "QUERY_TYPE_LABEL", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _types.QUERY_TYPE_LABEL;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "SupportApiError", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _api.SupportApiError;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "SupportButton", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _SupportButton.SupportButton;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "USER_MESSAGE_MAX", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _types.USER_MESSAGE_MAX;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "USER_MESSAGE_MIN", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _types.USER_MESSAGE_MIN;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "resolveTheme", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _theme.resolveTheme;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "supportDarkTheme", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _theme.supportDarkTheme;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "supportLightTheme", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _theme.supportLightTheme;
52
+ }
53
+ });
54
+ var _SupportButton = require("./components/SupportButton");
55
+ var _theme = require("./theme");
56
+ var _api = require("./api");
57
+ var _types = require("./types");
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_SupportButton","require","_theme","_api","_types"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAMA,IAAAE,IAAA,GAAAF,OAAA;AAYA,IAAAG,MAAA,GAAAH,OAAA","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveTheme = resolveTheme;
7
+ exports.supportLightTheme = exports.supportDarkTheme = void 0;
8
+ var _designTokens = require("@appsupportkit/design-tokens");
9
+ // The SDK consumes the same design tokens as the admin dashboard, so both
10
+ // surfaces look like one product.
11
+
12
+ const supportDarkTheme = exports.supportDarkTheme = {
13
+ name: 'dark',
14
+ colors: _designTokens.darkColors,
15
+ spacing: _designTokens.spacing,
16
+ radii: _designTokens.radii,
17
+ motion: _designTokens.motion
18
+ };
19
+ const supportLightTheme = exports.supportLightTheme = {
20
+ name: 'light',
21
+ colors: _designTokens.lightColors,
22
+ spacing: _designTokens.spacing,
23
+ radii: _designTokens.radii,
24
+ motion: _designTokens.motion
25
+ };
26
+ function resolveTheme(name) {
27
+ return name === 'light' ? supportLightTheme : supportDarkTheme;
28
+ }
29
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_designTokens","require","supportDarkTheme","exports","name","colors","darkColors","spacing","radii","motion","supportLightTheme","lightColors","resolveTheme"],"sourceRoot":"../../src","sources":["theme.ts"],"mappings":";;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AAFA;AACA;;AAmBO,MAAMC,gBAA8B,GAAAC,OAAA,CAAAD,gBAAA,GAAG;EAC5CE,IAAI,EAAE,MAAM;EACZC,MAAM,EAAEC,wBAAU;EAClBC,OAAO,EAAPA,qBAAO;EACPC,KAAK,EAALA,mBAAK;EACLC,MAAM,EAANA;AACF,CAAC;AAEM,MAAMC,iBAA+B,GAAAP,OAAA,CAAAO,iBAAA,GAAG;EAC7CN,IAAI,EAAE,OAAO;EACbC,MAAM,EAAEM,yBAAW;EACnBJ,OAAO,EAAPA,qBAAO;EACPC,KAAK,EAALA,mBAAK;EACLC,MAAM,EAANA;AACF,CAAC;AAEM,SAASG,YAAYA,CAACR,IAA2B,EAAgB;EACtE,OAAOA,IAAI,KAAK,OAAO,GAAGM,iBAAiB,GAAGR,gBAAgB;AAChE","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.USER_MESSAGE_MIN = exports.USER_MESSAGE_MAX = exports.QUERY_TYPE_LABEL = void 0;
7
+ const QUERY_TYPE_LABEL = exports.QUERY_TYPE_LABEL = {
8
+ feedback: 'Feedback',
9
+ feature_request: 'Feature request',
10
+ bug_report: 'Bug report'
11
+ };
12
+ const USER_MESSAGE_MIN = exports.USER_MESSAGE_MIN = 10;
13
+ const USER_MESSAGE_MAX = exports.USER_MESSAGE_MAX = 300;
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["QUERY_TYPE_LABEL","exports","feedback","feature_request","bug_report","USER_MESSAGE_MIN","USER_MESSAGE_MAX"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;;;;;AA+DO,MAAMA,gBAA2C,GAAAC,OAAA,CAAAD,gBAAA,GAAG;EACzDE,QAAQ,EAAE,UAAU;EACpBC,eAAe,EAAE,iBAAiB;EAClCC,UAAU,EAAE;AACd,CAAC;AAEM,MAAMC,gBAAgB,GAAAJ,OAAA,CAAAI,gBAAA,GAAG,EAAE;AAC3B,MAAMC,gBAAgB,GAAAL,OAAA,CAAAK,gBAAA,GAAG,GAAG","ignoreList":[]}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatDate = formatDate;
7
+ exports.relativeTime = relativeTime;
8
+ exports.validateProps = validateProps;
9
+ /** "2h ago" relative time — mirrors the web dashboard's formatting. */
10
+ function relativeTime(iso) {
11
+ const then = new Date(iso).getTime();
12
+ const seconds = Math.max(0, Math.floor((Date.now() - then) / 1000));
13
+ if (seconds < 60) return 'just now';
14
+ const minutes = Math.floor(seconds / 60);
15
+ if (minutes < 60) return `${minutes}m ago`;
16
+ const hours = Math.floor(minutes / 60);
17
+ if (hours < 24) return `${hours}h ago`;
18
+ const days = Math.floor(hours / 24);
19
+ if (days < 7) return `${days}d ago`;
20
+ const weeks = Math.floor(days / 7);
21
+ if (weeks < 5) return `${weeks}w ago`;
22
+ const months = Math.floor(days / 30);
23
+ if (months < 12) return `${months}mo ago`;
24
+ return `${Math.floor(days / 365)}y ago`;
25
+ }
26
+ function formatDate(iso) {
27
+ return new Date(iso).toLocaleDateString(undefined, {
28
+ year: 'numeric',
29
+ month: 'short',
30
+ day: 'numeric'
31
+ });
32
+ }
33
+
34
+ /** Dev-mode prop validation with actionable messages. */
35
+ function validateProps(props) {
36
+ if (typeof props.appName !== 'string' || props.appName.length === 0) {
37
+ return 'SupportButton: `appName` is required — the app name registered in the admin dashboard.';
38
+ }
39
+ if (typeof props.apiKey !== 'string' || props.apiKey.length === 0) {
40
+ return 'SupportButton: `apiKey` is required — the key shown once when the app was registered.';
41
+ }
42
+ if (typeof props.supabaseUrl !== 'string' || !/^https?:\/\//.test(props.supabaseUrl)) {
43
+ return 'SupportButton: `supabaseUrl` is required — your Supabase project URL, e.g. "https://abcd1234.supabase.co".';
44
+ }
45
+ const user = props.user;
46
+ if (!user || typeof user !== 'object') {
47
+ return 'SupportButton: `user` is required — { name, isPaid, revenuecatId, appVersion }.';
48
+ }
49
+ if (typeof user.name !== 'string' || user.name.length === 0) {
50
+ return 'SupportButton: `user.name` is required (string).';
51
+ }
52
+ if (typeof user.isPaid !== 'boolean') {
53
+ return 'SupportButton: `user.isPaid` is required (boolean).';
54
+ }
55
+ if (typeof user.revenuecatId !== 'string' || user.revenuecatId.length === 0) {
56
+ return 'SupportButton: `user.revenuecatId` is required (string) — the RevenueCat app user id.';
57
+ }
58
+ if (typeof user.appVersion !== 'string' || user.appVersion.length === 0) {
59
+ return 'SupportButton: `user.appVersion` is required (string), e.g. "2.4.1".';
60
+ }
61
+ return null;
62
+ }
63
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["relativeTime","iso","then","Date","getTime","seconds","Math","max","floor","now","minutes","hours","days","weeks","months","formatDate","toLocaleDateString","undefined","year","month","day","validateProps","props","appName","length","apiKey","supabaseUrl","test","user","name","isPaid","revenuecatId","appVersion"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;;;;;;;AAAA;AACO,SAASA,YAAYA,CAACC,GAAW,EAAU;EAChD,MAAMC,IAAI,GAAG,IAAIC,IAAI,CAACF,GAAG,CAAC,CAACG,OAAO,CAAC,CAAC;EACpC,MAAMC,OAAO,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,KAAK,CAAC,CAACL,IAAI,CAACM,GAAG,CAAC,CAAC,GAAGP,IAAI,IAAI,IAAI,CAAC,CAAC;EACnE,IAAIG,OAAO,GAAG,EAAE,EAAE,OAAO,UAAU;EACnC,MAAMK,OAAO,GAAGJ,IAAI,CAACE,KAAK,CAACH,OAAO,GAAG,EAAE,CAAC;EACxC,IAAIK,OAAO,GAAG,EAAE,EAAE,OAAO,GAAGA,OAAO,OAAO;EAC1C,MAAMC,KAAK,GAAGL,IAAI,CAACE,KAAK,CAACE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EACA,MAAME,IAAI,GAAGN,KAAK,CAACM,IAA2C;EAC9D,IAAI,CAACA,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IACrC,OAAO,iFAAiF;EAC1F;EACA,IAAI,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,IAAID,IAAI,CAACC,IAAI,CAACL,MAAM,KAAK,CAAC,EAAE;IAC3D,OAAO,kDAAkD;EAC3D;EACA,IAAI,OAAOI,IAAI,CAACE,MAAM,KAAK,SAAS,EAAE;IACpC,OAAO,qDAAqD;EAC9D;EACA,IAAI,OAAOF,IAAI,CAACG,YAAY,KAAK,QAAQ,IAAIH,IAAI,CAACG,YAAY,CAACP,MAAM,KAAK,CAAC,EAAE;IAC3E,OAAO,uFAAuF;EAChG;EACA,IAAI,OAAOI,IAAI,CAACI,UAAU,KAAK,QAAQ,IAAIJ,IAAI,CAACI,UAAU,CAACR,MAAM,KAAK,CAAC,EAAE;IACvE,OAAO,sEAAsE;EAC/E;EACA,OAAO,IAAI;AACb","ignoreList":[]}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ // Thin client for the Supabase Edge Functions. Every call authenticates with
4
+ // the per-app x-api-key header; no Supabase JS client is needed on-device.
5
+
6
+ export class SupportApiError extends Error {
7
+ /** True for network-level failures (likely offline). */
8
+
9
+ constructor(message, status, offline = false) {
10
+ super(message);
11
+ this.name = 'SupportApiError';
12
+ this.status = status;
13
+ this.offline = offline;
14
+ }
15
+ }
16
+ async function request(config, path, init) {
17
+ const url = `${config.supabaseUrl.replace(/\/$/, '')}/functions/v1/${path}`;
18
+ let response;
19
+ try {
20
+ response = await fetch(url, {
21
+ ...init,
22
+ headers: {
23
+ 'Content-Type': 'application/json',
24
+ 'x-api-key': config.apiKey,
25
+ ...init.headers
26
+ }
27
+ });
28
+ } catch {
29
+ throw new SupportApiError('Network request failed', null, true);
30
+ }
31
+ let payload = null;
32
+ try {
33
+ payload = await response.json();
34
+ } catch {
35
+ // Non-JSON error body — fall through with status only.
36
+ }
37
+ if (!response.ok) {
38
+ const message = payload !== null && typeof payload === 'object' && 'error' in payload && typeof payload.error === 'string' ? payload.error : `Request failed (${response.status})`;
39
+ throw new SupportApiError(message, response.status);
40
+ }
41
+ return payload;
42
+ }
43
+ export function getThreads(config, revenuecatId) {
44
+ const params = new URLSearchParams({
45
+ revenuecat_id: revenuecatId
46
+ });
47
+ return request(config, `get-threads?${params.toString()}`, {
48
+ method: 'GET'
49
+ });
50
+ }
51
+ export function submitQuery(config, input) {
52
+ return request(config, 'submit-query', {
53
+ method: 'POST',
54
+ body: JSON.stringify({
55
+ app_name: config.appName,
56
+ query_type: input.queryType,
57
+ message: input.message,
58
+ user_name: input.userName,
59
+ is_paid: input.isPaid,
60
+ revenuecat_id: input.revenuecatId,
61
+ app_version: input.appVersion
62
+ })
63
+ });
64
+ }
65
+ export function postMessage(config, input) {
66
+ return request(config, 'post-message', {
67
+ method: 'POST',
68
+ body: JSON.stringify({
69
+ query_id: input.queryId,
70
+ revenuecat_id: input.revenuecatId,
71
+ message: input.message
72
+ })
73
+ });
74
+ }
75
+ export function markRead(config, input) {
76
+ return request(config, 'mark-read', {
77
+ method: 'POST',
78
+ body: JSON.stringify({
79
+ query_id: input.queryId,
80
+ revenuecat_id: input.revenuecatId
81
+ })
82
+ });
83
+ }
84
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SupportApiError","Error","constructor","message","status","offline","name","request","config","path","init","url","supabaseUrl","replace","response","fetch","headers","apiKey","payload","json","ok","error","getThreads","revenuecatId","params","URLSearchParams","revenuecat_id","toString","method","submitQuery","input","body","JSON","stringify","app_name","appName","query_type","queryType","user_name","userName","is_paid","isPaid","app_version","appVersion","postMessage","query_id","queryId","markRead"],"sourceRoot":"../../src","sources":["api.ts"],"mappings":";;AAAA;AACA;;AASA,OAAO,MAAMA,eAAe,SAASC,KAAK,CAAC;EAEzC;;EAGAC,WAAWA,CAACC,OAAe,EAAEC,MAAqB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G,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;MACnBY,QAAQ,EAAEf,KAAK,CAACgB,OAAO;MACvBpB,aAAa,EAAEI,KAAK,CAACP;IACvB,CAAC;EACH,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+
3
+ // Bottom sheet built on the built-in Modal + Animated APIs.
4
+ //
5
+ // Why no sheet library: the SDK needs exactly one detent, a drag handle, a
6
+ // backdrop fade, and a 180ms ease-out slide — all achievable with core APIs.
7
+ // Skipping reanimated/gesture-handler keeps the package free of native
8
+ // dependencies and install friction for consumers.
9
+ import { useCallback, useEffect, useRef } from 'react';
10
+ import { Animated, Easing, Modal, PanResponder, Pressable, useWindowDimensions, View } from 'react-native';
11
+ import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ const SLIDE_MS = 180; // motion.slow — ease-out, no springs, no bounce.
14
+
15
+ export function BottomSheet({
16
+ visible,
17
+ onClose,
18
+ theme,
19
+ children
20
+ }) {
21
+ const {
22
+ height: windowHeight
23
+ } = useWindowDimensions();
24
+ const sheetHeight = Math.min(windowHeight * 0.82, 640);
25
+ const translateY = useRef(new Animated.Value(sheetHeight)).current;
26
+ const backdrop = useRef(new Animated.Value(0)).current;
27
+ const animateIn = useCallback(() => {
28
+ Animated.parallel([Animated.timing(translateY, {
29
+ toValue: 0,
30
+ duration: SLIDE_MS,
31
+ easing: Easing.out(Easing.cubic),
32
+ useNativeDriver: true
33
+ }), Animated.timing(backdrop, {
34
+ toValue: 1,
35
+ duration: SLIDE_MS,
36
+ easing: Easing.out(Easing.cubic),
37
+ useNativeDriver: true
38
+ })]).start();
39
+ }, [translateY, backdrop]);
40
+ const animateOut = useCallback(done => {
41
+ Animated.parallel([Animated.timing(translateY, {
42
+ toValue: sheetHeight,
43
+ duration: SLIDE_MS,
44
+ easing: Easing.out(Easing.cubic),
45
+ useNativeDriver: true
46
+ }), Animated.timing(backdrop, {
47
+ toValue: 0,
48
+ duration: SLIDE_MS,
49
+ easing: Easing.out(Easing.cubic),
50
+ useNativeDriver: true
51
+ })]).start(({
52
+ finished
53
+ }) => {
54
+ if (finished) done();
55
+ });
56
+ }, [translateY, backdrop, sheetHeight]);
57
+ useEffect(() => {
58
+ if (visible) animateIn();
59
+ }, [visible, animateIn]);
60
+ const requestClose = useCallback(() => {
61
+ animateOut(onClose);
62
+ }, [animateOut, onClose]);
63
+
64
+ // Drag handle: follow the finger downward; past 25% (or a flick), dismiss.
65
+ const panResponder = useRef(PanResponder.create({
66
+ onStartShouldSetPanResponder: () => true,
67
+ onMoveShouldSetPanResponder: (_e, g) => Math.abs(g.dy) > 4,
68
+ onPanResponderMove: (_e, g) => {
69
+ if (g.dy > 0) translateY.setValue(g.dy);
70
+ },
71
+ onPanResponderRelease: (_e, g) => {
72
+ if (g.dy > sheetHeight * 0.25 || g.vy > 1.2) {
73
+ requestClose();
74
+ } else {
75
+ Animated.timing(translateY, {
76
+ toValue: 0,
77
+ duration: SLIDE_MS,
78
+ easing: Easing.out(Easing.cubic),
79
+ useNativeDriver: true
80
+ }).start();
81
+ }
82
+ }
83
+ })).current;
84
+ if (!visible) return null;
85
+ return /*#__PURE__*/_jsx(Modal, {
86
+ visible: true,
87
+ transparent: true,
88
+ animationType: "none",
89
+ onRequestClose: requestClose,
90
+ statusBarTranslucent: true,
91
+ children: /*#__PURE__*/_jsx(SafeAreaProvider, {
92
+ children: /*#__PURE__*/_jsxs(View, {
93
+ style: {
94
+ flex: 1,
95
+ justifyContent: 'flex-end'
96
+ },
97
+ children: [/*#__PURE__*/_jsx(Animated.View, {
98
+ style: {
99
+ position: 'absolute',
100
+ top: 0,
101
+ right: 0,
102
+ bottom: 0,
103
+ left: 0,
104
+ backgroundColor: 'rgba(0,0,0,0.5)',
105
+ opacity: backdrop
106
+ },
107
+ children: /*#__PURE__*/_jsx(Pressable, {
108
+ style: {
109
+ flex: 1
110
+ },
111
+ onPress: requestClose,
112
+ accessibilityLabel: "Close support"
113
+ })
114
+ }), /*#__PURE__*/_jsxs(Animated.View, {
115
+ style: {
116
+ height: sheetHeight,
117
+ backgroundColor: theme.colors.overlay,
118
+ borderTopLeftRadius: theme.radii.sheet,
119
+ borderTopRightRadius: theme.radii.sheet,
120
+ borderWidth: 1,
121
+ borderBottomWidth: 0,
122
+ borderColor: theme.colors.border,
123
+ transform: [{
124
+ translateY
125
+ }]
126
+ },
127
+ children: [/*#__PURE__*/_jsx(View, {
128
+ ...panResponder.panHandlers,
129
+ style: {
130
+ alignItems: 'center',
131
+ paddingVertical: 10
132
+ },
133
+ children: /*#__PURE__*/_jsx(View, {
134
+ style: {
135
+ width: 32,
136
+ height: 4,
137
+ borderRadius: 2,
138
+ backgroundColor: theme.colors.borderStrong
139
+ }
140
+ })
141
+ }), /*#__PURE__*/_jsx(SafeAreaView, {
142
+ edges: ['bottom'],
143
+ style: {
144
+ flex: 1
145
+ },
146
+ children: children
147
+ })]
148
+ })]
149
+ })
150
+ })
151
+ });
152
+ }
153
+ //# sourceMappingURL=BottomSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useEffect","useRef","Animated","Easing","Modal","PanResponder","Pressable","useWindowDimensions","View","SafeAreaProvider","SafeAreaView","jsx","_jsx","jsxs","_jsxs","SLIDE_MS","BottomSheet","visible","onClose","theme","children","height","windowHeight","sheetHeight","Math","min","translateY","Value","current","backdrop","animateIn","parallel","timing","toValue","duration","easing","out","cubic","useNativeDriver","start","animateOut","done","finished","requestClose","panResponder","create","onStartShouldSetPanResponder","onMoveShouldSetPanResponder","_e","g","abs","dy","onPanResponderMove","setValue","onPanResponderRelease","vy","transparent","animationType","onRequestClose","statusBarTranslucent","style","flex","justifyContent","position","top","right","bottom","left","backgroundColor","opacity","onPress","accessibilityLabel","colors","overlay","borderTopLeftRadius","radii","sheet","borderTopRightRadius","borderWidth","borderBottomWidth","borderColor","border","transform","panHandlers","alignItems","paddingVertical","width","borderRadius","borderStrong","edges"],"sourceRoot":"../../../src","sources":["components/BottomSheet.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAwB,OAAO;AACtE,SACEC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,YAAY,EACZC,SAAS,EACTC,mBAAmB,EACnBC,IAAI,QACC,cAAc;AACrB,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,gCAAgC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAGhF,MAAMC,QAAQ,GAAG,GAAG,CAAC,CAAC;;AAEtB,OAAO,SAASC,WAAWA,CAAC;EAC1BC,OAAO;EACPC,OAAO;EACPC,KAAK;EACLC;AAMF,CAAC,EAAE;EACD,MAAM;IAAEC,MAAM,EAAEC;EAAa,CAAC,GAAGf,mBAAmB,CAAC,CAAC;EACtD,MAAMgB,WAAW,GAAGC,IAAI,CAACC,GAAG,CAACH,YAAY,GAAG,IAAI,EAAE,GAAG,CAAC;EAEtD,MAAMI,UAAU,GAAGzB,MAAM,CAAC,IAAIC,QAAQ,CAACyB,KAAK,CAACJ,WAAW,CAAC,CAAC,CAACK,OAAO;EAClE,MAAMC,QAAQ,GAAG5B,MAAM,CAAC,IAAIC,QAAQ,CAACyB,KAAK,CAAC,CAAC,CAAC,CAAC,CAACC,OAAO;EAEtD,MAAME,SAAS,GAAG/B,WAAW,CAAC,MAAM;IAClCG,QAAQ,CAAC6B,QAAQ,CAAC,CAChB7B,QAAQ,CAAC8B,MAAM,CAACN,UAAU,EAAE;MAC1BO,OAAO,EAAE,CAAC;MACVC,QAAQ,EAAEnB,QAAQ;MAClBoB,MAAM,EAAEhC,MAAM,CAACiC,GAAG,CAACjC,MAAM,CAACkC,KAAK,CAAC;MAChCC,eAAe,EAAE;IACnB,CAAC,CAAC,EACFpC,QAAQ,CAAC8B,MAAM,CAACH,QAAQ,EAA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