@unif/react-native-design 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -10
- package/lib/module/components/ui/Toast/ToastHost.js +23 -3
- package/lib/module/components/ui/Toast/ToastHost.js.map +1 -1
- package/lib/module/components/ui/Toast/styles.js +1 -1
- package/lib/module/components/ui/Toast/styles.js.map +1 -1
- package/lib/module/components/ui/Toast/toast.js +4 -2
- package/lib/module/components/ui/Toast/toast.js.map +1 -1
- package/lib/module/components/ui/index.js +0 -2
- package/lib/module/components/ui/index.js.map +1 -1
- package/lib/typescript/src/components/ui/Input/Input.d.ts +3 -3
- package/lib/typescript/src/components/ui/Search/Search.d.ts +3 -3
- package/lib/typescript/src/components/ui/TextField/TextFieldBase.d.ts +3 -3
- package/lib/typescript/src/components/ui/Textarea/Textarea.d.ts +3 -3
- package/lib/typescript/src/components/ui/Toast/ToastHost.d.ts +3 -0
- package/lib/typescript/src/components/ui/Toast/ToastHost.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Toast/index.d.ts +1 -1
- package/lib/typescript/src/components/ui/Toast/index.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Toast/styles.d.ts +0 -1
- package/lib/typescript/src/components/ui/Toast/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Toast/toast.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Toast/types.d.ts +9 -3
- package/lib/typescript/src/components/ui/Toast/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/index.d.ts +1 -5
- package/lib/typescript/src/components/ui/index.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/components/ui/Toast/ToastHost.tsx +20 -3
- package/src/components/ui/Toast/index.ts +1 -0
- package/src/components/ui/Toast/styles.ts +1 -1
- package/src/components/ui/Toast/toast.ts +2 -1
- package/src/components/ui/Toast/types.ts +10 -3
- package/src/components/ui/index.ts +1 -4
- package/lib/module/components/ui/BottomSheet/BottomSheet.js +0 -104
- package/lib/module/components/ui/BottomSheet/BottomSheet.js.map +0 -1
- package/lib/module/components/ui/BottomSheet/index.js +0 -4
- package/lib/module/components/ui/BottomSheet/index.js.map +0 -1
- package/lib/module/components/ui/BottomSheet/styles.js +0 -26
- package/lib/module/components/ui/BottomSheet/styles.js.map +0 -1
- package/lib/module/components/ui/BottomSheet/types.js +0 -4
- package/lib/module/components/ui/BottomSheet/types.js.map +0 -1
- package/lib/module/components/ui/Confirm/ConfirmHost.js +0 -111
- package/lib/module/components/ui/Confirm/ConfirmHost.js.map +0 -1
- package/lib/module/components/ui/Confirm/confirm.js +0 -51
- package/lib/module/components/ui/Confirm/confirm.js.map +0 -1
- package/lib/module/components/ui/Confirm/index.js +0 -5
- package/lib/module/components/ui/Confirm/index.js.map +0 -1
- package/lib/module/components/ui/Confirm/styles.js +0 -35
- package/lib/module/components/ui/Confirm/styles.js.map +0 -1
- package/lib/module/components/ui/Confirm/types.js +0 -2
- package/lib/module/components/ui/Confirm/types.js.map +0 -1
- package/lib/typescript/src/components/ui/BottomSheet/BottomSheet.d.ts +0 -4
- package/lib/typescript/src/components/ui/BottomSheet/BottomSheet.d.ts.map +0 -1
- package/lib/typescript/src/components/ui/BottomSheet/index.d.ts +0 -3
- package/lib/typescript/src/components/ui/BottomSheet/index.d.ts.map +0 -1
- package/lib/typescript/src/components/ui/BottomSheet/styles.d.ts +0 -23
- package/lib/typescript/src/components/ui/BottomSheet/styles.d.ts.map +0 -1
- package/lib/typescript/src/components/ui/BottomSheet/types.d.ts +0 -26
- package/lib/typescript/src/components/ui/BottomSheet/types.d.ts.map +0 -1
- package/lib/typescript/src/components/ui/Confirm/ConfirmHost.d.ts +0 -9
- package/lib/typescript/src/components/ui/Confirm/ConfirmHost.d.ts.map +0 -1
- package/lib/typescript/src/components/ui/Confirm/confirm.d.ts +0 -20
- package/lib/typescript/src/components/ui/Confirm/confirm.d.ts.map +0 -1
- package/lib/typescript/src/components/ui/Confirm/index.d.ts +0 -4
- package/lib/typescript/src/components/ui/Confirm/index.d.ts.map +0 -1
- package/lib/typescript/src/components/ui/Confirm/styles.d.ts +0 -32
- package/lib/typescript/src/components/ui/Confirm/styles.d.ts.map +0 -1
- package/lib/typescript/src/components/ui/Confirm/types.d.ts +0 -21
- package/lib/typescript/src/components/ui/Confirm/types.d.ts.map +0 -1
- package/src/components/ui/BottomSheet/BottomSheet.tsx +0 -117
- package/src/components/ui/BottomSheet/index.ts +0 -2
- package/src/components/ui/BottomSheet/styles.ts +0 -20
- package/src/components/ui/BottomSheet/types.ts +0 -26
- package/src/components/ui/Confirm/ConfirmHost.tsx +0 -134
- package/src/components/ui/Confirm/confirm.ts +0 -53
- package/src/components/ui/Confirm/index.ts +0 -3
- package/src/components/ui/Confirm/styles.ts +0 -35
- package/src/components/ui/Confirm/types.ts +0 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;A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aAAa,CAAC;AACxC,YAAY,EACV,cAAc,EACd,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EACV,UAAU,EACV,cAAc,EACd,UAAU,EACV,SAAS,EACT,aAAa,GACd,MAAM,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unif/react-native-design",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Unif 设计系统:theme + icons + utils + components",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -66,7 +66,6 @@
|
|
|
66
66
|
"@eslint/compat": "^2.0.3",
|
|
67
67
|
"@eslint/eslintrc": "^3.3.5",
|
|
68
68
|
"@eslint/js": "^10.0.1",
|
|
69
|
-
"@gorhom/bottom-sheet": "^5.2.14",
|
|
70
69
|
"@jest/globals": "^30.0.0",
|
|
71
70
|
"@react-native/babel-preset": "0.85.3",
|
|
72
71
|
"@react-native/eslint-config": "0.85.3",
|
|
@@ -97,7 +96,6 @@
|
|
|
97
96
|
"typescript": "^6.0.2"
|
|
98
97
|
},
|
|
99
98
|
"peerDependencies": {
|
|
100
|
-
"@gorhom/bottom-sheet": ">=5",
|
|
101
99
|
"@sbaiahmed1/react-native-blur": ">=4",
|
|
102
100
|
"react": "*",
|
|
103
101
|
"react-native": "*",
|
|
@@ -144,6 +142,11 @@
|
|
|
144
142
|
"modulePathIgnorePatterns": [
|
|
145
143
|
"<rootDir>/example/node_modules",
|
|
146
144
|
"<rootDir>/lib/"
|
|
145
|
+
],
|
|
146
|
+
"testPathIgnorePatterns": [
|
|
147
|
+
"/node_modules/",
|
|
148
|
+
"<rootDir>/website/",
|
|
149
|
+
"<rootDir>/example/"
|
|
147
150
|
]
|
|
148
151
|
},
|
|
149
152
|
"commitlint": {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { Text, View } from 'react-native';
|
|
3
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
3
4
|
import Animated, {
|
|
4
5
|
cancelAnimation,
|
|
5
6
|
runOnJS,
|
|
@@ -7,7 +8,7 @@ import Animated, {
|
|
|
7
8
|
useSharedValue,
|
|
8
9
|
withTiming,
|
|
9
10
|
} from 'react-native-reanimated';
|
|
10
|
-
import { useColors, useThemedStyles, motion } from '../../../theme';
|
|
11
|
+
import { useColors, useThemedStyles, motion, space } from '../../../theme';
|
|
11
12
|
import { dotColorFor, makeStyles } from './styles';
|
|
12
13
|
import { _subs } from './toast';
|
|
13
14
|
import type { Subscriber, ToastEntry, ToastHostProps } from './types';
|
|
@@ -15,12 +16,16 @@ import type { Subscriber, ToastEntry, ToastHostProps } from './types';
|
|
|
15
16
|
/**
|
|
16
17
|
* 在根附近挂一次。监听 toast() 调用并渲染当前 toast。
|
|
17
18
|
* 同一时间只显示一条 —— 新的会替换旧的。
|
|
19
|
+
*
|
|
20
|
+
* 位置由 `entry.position`('top' / 'bottom' / 'center')决定,top/bottom 自动避让
|
|
21
|
+
* safe-area;进入动画方向随位置(top 从上滑、bottom/center 从下滑)。
|
|
18
22
|
*/
|
|
19
23
|
export function ToastHost({
|
|
20
24
|
testID,
|
|
21
25
|
}: ToastHostProps = {}): React.JSX.Element | null {
|
|
22
26
|
const c = useColors();
|
|
23
27
|
const styles = useThemedStyles(makeStyles);
|
|
28
|
+
const insets = useSafeAreaInsets();
|
|
24
29
|
const [entry, setEntry] = useState<ToastEntry | null>(null);
|
|
25
30
|
const op = useSharedValue(0);
|
|
26
31
|
const ty = useSharedValue(8);
|
|
@@ -39,14 +44,18 @@ export function ToastHost({
|
|
|
39
44
|
|
|
40
45
|
useEffect(() => {
|
|
41
46
|
if (!entry) return;
|
|
47
|
+
// 进入方向:top 从上(-8)滑入,bottom / center 从下(8)滑入
|
|
48
|
+
const from = entry.position === 'top' ? -8 : 8;
|
|
42
49
|
cancelAnimation(op);
|
|
43
50
|
cancelAnimation(ty);
|
|
51
|
+
op.value = 0;
|
|
52
|
+
ty.value = from;
|
|
44
53
|
op.value = withTiming(1, { duration: motion.base });
|
|
45
54
|
ty.value = withTiming(0, { duration: motion.base });
|
|
46
55
|
|
|
47
56
|
dismissTimer.current = setTimeout(() => {
|
|
48
57
|
op.value = withTiming(0, { duration: motion.base });
|
|
49
|
-
ty.value = withTiming(
|
|
58
|
+
ty.value = withTiming(from, { duration: motion.base }, (finished) => {
|
|
50
59
|
if (finished) runOnJS(setEntry)(null);
|
|
51
60
|
});
|
|
52
61
|
}, entry.duration);
|
|
@@ -65,10 +74,18 @@ export function ToastHost({
|
|
|
65
74
|
|
|
66
75
|
if (!entry) return null;
|
|
67
76
|
|
|
77
|
+
// 位置:top=顶部(safe-area + 间距)/ center=屏幕居中 / bottom=底部(默认)
|
|
78
|
+
const posStyle =
|
|
79
|
+
entry.position === 'top'
|
|
80
|
+
? { top: insets.top + space[10] }
|
|
81
|
+
: entry.position === 'center'
|
|
82
|
+
? { top: 0, bottom: 0, justifyContent: 'center' as const }
|
|
83
|
+
: { bottom: insets.bottom + space[10] };
|
|
84
|
+
|
|
68
85
|
const dotColor = dotColorFor(entry.kind, c);
|
|
69
86
|
|
|
70
87
|
return (
|
|
71
|
-
<View style={styles.host} pointerEvents="none" testID={testID}>
|
|
88
|
+
<View style={[styles.host, posStyle]} pointerEvents="none" testID={testID}>
|
|
72
89
|
<Animated.View style={[styles.toast, animatedStyle]}>
|
|
73
90
|
{dotColor ? (
|
|
74
91
|
<View style={[styles.dot, { backgroundColor: dotColor }]} />
|
|
@@ -6,10 +6,10 @@ import type { ToastKind } from './types';
|
|
|
6
6
|
export const makeStyles = (c: ColorTokens) =>
|
|
7
7
|
StyleSheet.create({
|
|
8
8
|
host: {
|
|
9
|
+
// 定位(top/bottom/center)由 ToastHost 按 entry.position 注入,这里只留通用
|
|
9
10
|
position: 'absolute',
|
|
10
11
|
left: 0,
|
|
11
12
|
right: 0,
|
|
12
|
-
bottom: space[10],
|
|
13
13
|
alignItems: 'center',
|
|
14
14
|
// zIndex: toast 浮层 —— 盖在 Screen 内容之上(navigator / overlay 之下)。
|
|
15
15
|
// 同级兄弟节点无 z 顺序需求,但作为 absolute 浮岛对其他屏内 absolute 节点
|
|
@@ -11,12 +11,13 @@ export const _subs = new Set<Subscriber>();
|
|
|
11
11
|
function emit(input: ToastInput, kind: ToastKind = 'info') {
|
|
12
12
|
const entry: ToastEntry =
|
|
13
13
|
typeof input === 'string'
|
|
14
|
-
? { id: ++_id, message: input, kind, duration: 3000 }
|
|
14
|
+
? { id: ++_id, message: input, kind, duration: 3000, position: 'bottom' }
|
|
15
15
|
: {
|
|
16
16
|
id: ++_id,
|
|
17
17
|
message: input.message,
|
|
18
18
|
kind: input.kind ?? kind,
|
|
19
19
|
duration: input.duration ?? 3000,
|
|
20
|
+
position: input.position ?? 'bottom',
|
|
20
21
|
};
|
|
21
22
|
_subs.forEach((s) => s(entry));
|
|
22
23
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/** Toast 类型:info=灰点 / success=绿点 / error=红点 */
|
|
2
2
|
export type ToastKind = 'info' | 'success' | 'error';
|
|
3
3
|
|
|
4
|
+
/** Toast 显示位置:top=顶部 / bottom=底部(默认) / center=屏幕居中 */
|
|
5
|
+
export type ToastPosition = 'top' | 'bottom' | 'center';
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* `toast(...)` 调用入参:
|
|
6
|
-
* - 字符串简写:默认 info kind
|
|
7
|
-
* - 对象形式:可指定 kind
|
|
9
|
+
* - 字符串简写:默认 info kind、bottom 位置、3000ms duration
|
|
10
|
+
* - 对象形式:可指定 kind / duration / position
|
|
8
11
|
*/
|
|
9
12
|
export type ToastInput =
|
|
10
13
|
| string
|
|
@@ -13,8 +16,10 @@ export type ToastInput =
|
|
|
13
16
|
message: string;
|
|
14
17
|
/** Toast 类型,默认 'info' */
|
|
15
18
|
kind?: ToastKind;
|
|
16
|
-
/** 自动消失毫秒数,默认
|
|
19
|
+
/** 自动消失毫秒数,默认 3000 */
|
|
17
20
|
duration?: number;
|
|
21
|
+
/** 显示位置,默认 'bottom' */
|
|
22
|
+
position?: ToastPosition;
|
|
18
23
|
};
|
|
19
24
|
|
|
20
25
|
export type ToastEntry = {
|
|
@@ -26,6 +31,8 @@ export type ToastEntry = {
|
|
|
26
31
|
kind: ToastKind;
|
|
27
32
|
/** 显示毫秒数 */
|
|
28
33
|
duration: number;
|
|
34
|
+
/** 显示位置 */
|
|
35
|
+
position: ToastPosition;
|
|
29
36
|
};
|
|
30
37
|
|
|
31
38
|
/** Toast 订阅者函数签名(ToastHost 内部用) */
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export { Avatar } from './Avatar';
|
|
2
2
|
export type { AvatarProps, AvatarSize, AvatarVariant } from './Avatar';
|
|
3
|
-
export { BottomSheet } from './BottomSheet';
|
|
4
|
-
export type { BottomSheetProps } from './BottomSheet';
|
|
5
3
|
export { BlurLayer } from './BlurLayer';
|
|
6
4
|
export type { BlurLayerProps } from './BlurLayer';
|
|
7
5
|
export { Button } from './Button';
|
|
@@ -16,8 +14,6 @@ export { Checkbox } from './Checkbox';
|
|
|
16
14
|
export type { CheckboxProps } from './Checkbox';
|
|
17
15
|
export { Chip } from './Chip';
|
|
18
16
|
export type { ChipProps } from './Chip';
|
|
19
|
-
export { confirm, ConfirmHost } from './Confirm';
|
|
20
|
-
export type { ConfirmOptions } from './Confirm';
|
|
21
17
|
export { DrawerHeader } from './DrawerHeader';
|
|
22
18
|
export type { DrawerHeaderProps } from './DrawerHeader';
|
|
23
19
|
export { Empty } from './Empty';
|
|
@@ -80,4 +76,5 @@ export type {
|
|
|
80
76
|
ToastHostProps,
|
|
81
77
|
ToastInput,
|
|
82
78
|
ToastKind,
|
|
79
|
+
ToastPosition,
|
|
83
80
|
} from './Toast';
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React, { useCallback, useMemo } from 'react';
|
|
4
|
-
import { View } from 'react-native';
|
|
5
|
-
import GorhomBottomSheet, { BottomSheetBackdrop, BottomSheetScrollView } from '@gorhom/bottom-sheet';
|
|
6
|
-
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
7
|
-
import { useThemedStyles } from "../../../theme/index.js";
|
|
8
|
-
import { BlurLayer } from "../BlurLayer/index.js";
|
|
9
|
-
import { makeStyles } from "./styles.js";
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
/** 底部 sheet —— @gorhom/bottom-sheet 的薄壳层。
|
|
12
|
-
*
|
|
13
|
-
* 适合 navigation `presentation: 'transparentModal'` 屏内 root 用法:mount 时
|
|
14
|
-
* 默认 animateOnMount=true 从 -1 动画到 index=0,goBack() 自然关闭。
|
|
15
|
-
* state-driven sheet 应用 @gorhom 原生 `<BottomSheetModal>`,本 wrapper 不覆盖。
|
|
16
|
-
*
|
|
17
|
-
* - `snapPoints` 必传(`['50%']` / `['50%', '90%']` 等)
|
|
18
|
-
* - `backdrop` 三档:`'scrim'` / `'blur'`(BlurLayer)/ `'none'` */
|
|
19
|
-
// 默认 30% / 60% / 95%,模块顶层 const 引用稳定。
|
|
20
|
-
const DEFAULT_SNAP_POINTS = ['30%', '60%', '95%'];
|
|
21
|
-
export function BottomSheet({
|
|
22
|
-
snapPoints = DEFAULT_SNAP_POINTS,
|
|
23
|
-
children,
|
|
24
|
-
sheetStyle,
|
|
25
|
-
backdrop = 'scrim',
|
|
26
|
-
grabber = true,
|
|
27
|
-
onClose,
|
|
28
|
-
testID
|
|
29
|
-
}) {
|
|
30
|
-
const styles = useThemedStyles(makeStyles);
|
|
31
|
-
|
|
32
|
-
/** BlurView backdrop —— 复用 @gorhom BottomSheetBackdrop 的手势 + animatedIndex
|
|
33
|
-
* 插值,opacity=1 + bg=transparent 让 backdrop 本身不画 scrim,只画 BlurLayer。
|
|
34
|
-
* tap-to-close + opacity 淡入 / pointer-events disable 全部继承自 @gorhom 内核。
|
|
35
|
-
*
|
|
36
|
-
* useCallback + styles dep 保引用稳定(主题切换时才重建),避免每次渲染新引用让
|
|
37
|
-
* @gorhom 内部 memo 失效 / remount backdrop 树。 */
|
|
38
|
-
const BlurBackdrop = useCallback(props => /*#__PURE__*/_jsx(BottomSheetBackdrop, {
|
|
39
|
-
...props,
|
|
40
|
-
appearsOnIndex: 0,
|
|
41
|
-
disappearsOnIndex: -1,
|
|
42
|
-
opacity: 1,
|
|
43
|
-
style: [props.style, styles.backdropTransparent],
|
|
44
|
-
children: /*#__PURE__*/_jsx(BlurLayer, {
|
|
45
|
-
intensity: "strong"
|
|
46
|
-
})
|
|
47
|
-
}), [styles.backdropTransparent]);
|
|
48
|
-
|
|
49
|
-
/** Scrim backdrop —— 走 c.scrim token(亮 rgba(0,0,0,0.5) / 暗 0.7),opacity=1
|
|
50
|
-
* 让 @gorhom 只跑透明度淡入动画,scrim 实色由 token 决定 → 暗色自动加深。 */
|
|
51
|
-
const ScrimBackdrop = useCallback(props => /*#__PURE__*/_jsx(BottomSheetBackdrop, {
|
|
52
|
-
...props,
|
|
53
|
-
appearsOnIndex: 0,
|
|
54
|
-
disappearsOnIndex: -1,
|
|
55
|
-
opacity: 1,
|
|
56
|
-
style: [props.style, styles.scrimBackdrop]
|
|
57
|
-
}), [styles.scrimBackdrop]);
|
|
58
|
-
const renderBackdrop = useMemo(() => {
|
|
59
|
-
switch (backdrop) {
|
|
60
|
-
case 'none':
|
|
61
|
-
return undefined;
|
|
62
|
-
case 'blur':
|
|
63
|
-
return BlurBackdrop;
|
|
64
|
-
case 'scrim':
|
|
65
|
-
return ScrimBackdrop;
|
|
66
|
-
}
|
|
67
|
-
}, [backdrop, BlurBackdrop, ScrimBackdrop]);
|
|
68
|
-
|
|
69
|
-
// @gorhom onChange:index === -1 即关闭。配合 transparentModal route 必传
|
|
70
|
-
// caller 的 onClose → navigation.goBack(),否则路由 stack 不 pop,native overlay 继续吞触摸。
|
|
71
|
-
const onChange = index => {
|
|
72
|
-
if (index === -1) onClose?.();
|
|
73
|
-
};
|
|
74
|
-
return /*#__PURE__*/_jsx(GestureHandlerRootView, {
|
|
75
|
-
style: styles.root,
|
|
76
|
-
children: /*#__PURE__*/_jsx(GorhomBottomSheet, {
|
|
77
|
-
snapPoints: snapPoints,
|
|
78
|
-
index: 0,
|
|
79
|
-
backdropComponent: renderBackdrop,
|
|
80
|
-
handleComponent: grabber ? undefined : null,
|
|
81
|
-
backgroundStyle: styles.sheet,
|
|
82
|
-
onChange: onChange
|
|
83
|
-
// enableDynamicSizing=false 关键 —— @gorhom v5 默认 true 会让 sheet 跟内容
|
|
84
|
-
// 自动撑高忽略 snapPoints max,设 false 强制按 snapPoints 锁高度(gorhom#1783 / #918)
|
|
85
|
-
,
|
|
86
|
-
enableDynamicSizing: false,
|
|
87
|
-
enableOverDrag: false
|
|
88
|
-
// @gorhom 默认 false:user 下拉到底部 snap 后不会关闭 sheet,只是 bounce
|
|
89
|
-
// (BottomSheetScrollView 在 scrollOffset=0 时下拉看着像下拉刷新效果)。
|
|
90
|
-
// 设 true 后超过最低 snap 阈值直接 dismiss → 走 onChange(-1) → onClose。
|
|
91
|
-
,
|
|
92
|
-
enablePanDownToClose: true,
|
|
93
|
-
children: /*#__PURE__*/_jsx(BottomSheetScrollView, {
|
|
94
|
-
testID: testID,
|
|
95
|
-
showsVerticalScrollIndicator: false,
|
|
96
|
-
children: /*#__PURE__*/_jsx(View, {
|
|
97
|
-
style: sheetStyle,
|
|
98
|
-
children: children
|
|
99
|
-
})
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=BottomSheet.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useMemo","View","GorhomBottomSheet","BottomSheetBackdrop","BottomSheetScrollView","GestureHandlerRootView","useThemedStyles","BlurLayer","makeStyles","jsx","_jsx","DEFAULT_SNAP_POINTS","BottomSheet","snapPoints","children","sheetStyle","backdrop","grabber","onClose","testID","styles","BlurBackdrop","props","appearsOnIndex","disappearsOnIndex","opacity","style","backdropTransparent","intensity","ScrimBackdrop","scrimBackdrop","renderBackdrop","undefined","onChange","index","root","backdropComponent","handleComponent","backgroundStyle","sheet","enableDynamicSizing","enableOverDrag","enablePanDownToClose","showsVerticalScrollIndicator"],"sourceRoot":"../../../../../src","sources":["components/ui/BottomSheet/BottomSheet.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACnD,SAASC,IAAI,QAAQ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AAK,CAACI,KAAK,EAAEN,MAAM,CAACU,aAAa;EAAE,CAC5C,CACF,EACD,CAACV,MAAM,CAACU,aAAa,CACvB,CAAC;EAED,MAAMC,cAAc,GAAG/B,OAAO,CAAC,MAAM;IACnC,QAAQgB,QAAQ;MACd,KAAK,MAAM;QACT,OAAOgB,SAAS;MAClB,KAAK,MAAM;QACT,OAAOX,YAAY;MACrB,KAAK,OAAO;QACV,OAAOQ,aAAa;IACxB;EACF,CAAC,EAAE,CAACb,QAAQ,EAAEK,YAAY,EAAEQ,aAAa,CAAC,CAAC;;EAE3C;EACA;EACA,MAAMI,QAAQ,GAAIC,KAAa,IAAK;IAClC,IAAIA,KAAK,KAAK,CAAC,CAAC,EAAEhB,OAAO,GAAG,CAAC;EAC/B,CAAC;EAED,oBACER,IAAA,CAACL,sBAAsB;IAACqB,KAAK,EAAEN,MAAM,CAACe,IAAK;IAAArB,QAAA,eACzCJ,IAAA,CAACR,iBAAiB;MAChBW,UAAU,EAAEA,UAAW;MACvBqB,KAAK,EAAE,CAAE;MACTE,iBAAiB,EAAEL,cAAe;MAClCM,eAAe,EAAEpB,OAAO,GAAGe,SAAS,GAAG,IAAK;MAC5CM,eAAe,EAAElB,MAAM,CAACmB,KAAM;MAC9BN,QAAQ,EAAEA;MACV;MACA;MAAA;MACAO,mBAAmB,EAAE,KAAM;MAC3BC,cAAc,EAAE;MAChB;MACA;MACA;MAAA;MACAC,oBAAoB;MAAA5B,QAAA,eAEpBJ,IAAA,CAACN,qBAAqB;QACpBe,MAAM,EAAEA,MAAO;QACfwB,4BAA4B,EAAE,KAAM;QAAA7B,QAAA,eAGpCJ,IAAA,CAACT,IAAI;UAACyB,KAAK,EAAEX,UAAW;UAAAD,QAAA,EAAEA;QAAQ,CAAO;MAAC,CACrB;IAAC,CACP;EAAC,CACE,CAAC;AAE7B","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["BottomSheet"],"sourceRoot":"../../../../../src","sources":["components/ui/BottomSheet/index.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,kBAAe","ignoreList":[]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { StyleSheet } from 'react-native';
|
|
4
|
-
import { space } from "../../../theme/index.js";
|
|
5
|
-
/** @gorhom 接管动画 / handle / scrim,这里只控 root flex + sheet bg + 顶部圆角 24
|
|
6
|
-
* + scrim/blur backdrop 背景色(走 c.scrim token,亮 rgba(0,0,0,0.5) / 暗 0.7)。 */
|
|
7
|
-
export const makeStyles = c => StyleSheet.create({
|
|
8
|
-
root: {
|
|
9
|
-
flex: 1
|
|
10
|
-
},
|
|
11
|
-
sheet: {
|
|
12
|
-
backgroundColor: c.surface,
|
|
13
|
-
borderTopLeftRadius: space['9'],
|
|
14
|
-
borderTopRightRadius: space['9']
|
|
15
|
-
},
|
|
16
|
-
/** Scrim backdrop:c.scrim token,亮暗自动切换(亮 0.5 / 暗 0.7 alpha)。
|
|
17
|
-
* 与 @gorhom 默认 backgroundColor:'black' + opacity 0.5 等价但走 token。 */
|
|
18
|
-
scrimBackdrop: {
|
|
19
|
-
backgroundColor: c.scrim
|
|
20
|
-
},
|
|
21
|
-
/** Blur backdrop:bg 透明,由 BlurLayer child 接管视觉。 */
|
|
22
|
-
backdropTransparent: {
|
|
23
|
-
backgroundColor: 'transparent'
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSheet","space","makeStyles","c","create","root","flex","sheet","backgroundColor","surface","borderTopLeftRadius","borderTopRightRadius","scrimBackdrop","scrim","backdropTransparent"],"sourceRoot":"../../../../../src","sources":["components/ui/BottomSheet/styles.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,KAAK,QAAQ,yBAAgB;AAGtC;AACA;AACA,OAAO,MAAMC,UAAU,GAAIC,CAAc,IACvCH,UAAU,CAACI,MAAM,CAAC;EAChBC,IAAI,EAAE;IAAEC,IAAI,EAAE;EAAE,CAAC;EACjBC,KAAK,EAAE;IACLC,eAAe,EAAEL,CAAC,CAACM,OAAO;IAC1BC,mBAAmB,EAAET,KAAK,CAAC,GAAG,CAAC;IAC/BU,oBAAoB,EAAEV,KAAK,CAAC,GAAG;EACjC,CAAC;EACD;AACJ;EACIW,aAAa,EAAE;IAAEJ,eAAe,EAAEL,CAAC,CAACU;EAAM,CAAC;EAC3C;EACAC,mBAAmB,EAAE;IAAEN,eAAe,EAAE;EAAc;AACxD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["components/ui/BottomSheet/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
-
import { Text, View } from 'react-native';
|
|
5
|
-
import { BottomSheetBackdrop, BottomSheetFooter, BottomSheetModal, BottomSheetView } from '@gorhom/bottom-sheet';
|
|
6
|
-
import { useThemedStyles } from "../../../theme/index.js";
|
|
7
|
-
import { Button } from "../Button/index.js";
|
|
8
|
-
import { _subs } from "./confirm.js";
|
|
9
|
-
import { makeStyles } from "./styles.js";
|
|
10
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
-
/** Scrim backdrop —— 单色半透黑 opacity 0.5 */
|
|
12
|
-
function ScrimBackdrop(props) {
|
|
13
|
-
return /*#__PURE__*/_jsx(BottomSheetBackdrop, {
|
|
14
|
-
...props,
|
|
15
|
-
appearsOnIndex: 0,
|
|
16
|
-
disappearsOnIndex: -1,
|
|
17
|
-
opacity: 0.5
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Confirm 对话框 Portal —— App 根挂一次,监听 `confirm()` 调用并渲染。
|
|
23
|
-
*
|
|
24
|
-
* 走 `<BottomSheetModal>` + `<BottomSheetModalProvider>`,通过 Provider Portal
|
|
25
|
-
* 自动渲染到 App 顶层 —— 整屏 backdrop + 不受 React tree 位置影响。
|
|
26
|
-
*/
|
|
27
|
-
export function ConfirmHost() {
|
|
28
|
-
const styles = useThemedStyles(makeStyles);
|
|
29
|
-
const modalRef = useRef(null);
|
|
30
|
-
const [entry, setEntry] = useState(null);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
const sub = next => {
|
|
33
|
-
setEntry(next);
|
|
34
|
-
if (next) {
|
|
35
|
-
modalRef.current?.present();
|
|
36
|
-
} else {
|
|
37
|
-
modalRef.current?.dismiss();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
_subs.add(sub);
|
|
41
|
-
return () => {
|
|
42
|
-
_subs.delete(sub);
|
|
43
|
-
};
|
|
44
|
-
}, []);
|
|
45
|
-
|
|
46
|
-
// onDismiss:drag-to-close / backdrop tap / 程序 dismiss 都触发,entry 还在视为取消
|
|
47
|
-
// 三个 handler 都用 useCallback + [entry] deps —— 让 renderFooter 的 useCallback
|
|
48
|
-
// deps 能正确锁定它们,引用稳定 = @gorhom 不会因 backdrop 重生成而抖动。
|
|
49
|
-
const handleDismiss = useCallback(() => {
|
|
50
|
-
if (entry) {
|
|
51
|
-
entry.resolve(false);
|
|
52
|
-
setEntry(null);
|
|
53
|
-
}
|
|
54
|
-
}, [entry]);
|
|
55
|
-
const handleConfirm = useCallback(() => {
|
|
56
|
-
entry?.resolve(true);
|
|
57
|
-
modalRef.current?.dismiss();
|
|
58
|
-
}, [entry]);
|
|
59
|
-
const handleCancel = useCallback(() => {
|
|
60
|
-
entry?.resolve(false);
|
|
61
|
-
modalRef.current?.dismiss();
|
|
62
|
-
}, [entry]);
|
|
63
|
-
const snapPoints = useMemo(() => ['30%'], []);
|
|
64
|
-
|
|
65
|
-
// 用 BottomSheetFooter 浮按钮:BottomSheetView 内部 absolute top/left/right 无 bottom,
|
|
66
|
-
// flex marginTop:auto 推不动按钮,所以必须走 footer + bottomInset 自动避让键盘。
|
|
67
|
-
const renderFooter = useCallback(props => entry ? /*#__PURE__*/_jsx(BottomSheetFooter, {
|
|
68
|
-
...props,
|
|
69
|
-
bottomInset: 0,
|
|
70
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
71
|
-
style: styles.actions,
|
|
72
|
-
children: [/*#__PURE__*/_jsx(Button, {
|
|
73
|
-
testID: "confirm-cancel",
|
|
74
|
-
label: entry.cancelLabel ?? '取消',
|
|
75
|
-
variant: "secondary",
|
|
76
|
-
block: true,
|
|
77
|
-
onPress: handleCancel
|
|
78
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
79
|
-
testID: "confirm-ok",
|
|
80
|
-
label: entry.confirmLabel ?? '确认',
|
|
81
|
-
variant: entry.destructive ? 'danger' : 'primary',
|
|
82
|
-
block: true,
|
|
83
|
-
onPress: handleConfirm
|
|
84
|
-
})]
|
|
85
|
-
})
|
|
86
|
-
}) : null, [entry, styles.actions, handleCancel, handleConfirm]);
|
|
87
|
-
return /*#__PURE__*/_jsx(BottomSheetModal, {
|
|
88
|
-
ref: modalRef,
|
|
89
|
-
snapPoints: snapPoints,
|
|
90
|
-
index: 0,
|
|
91
|
-
enableDynamicSizing: false,
|
|
92
|
-
enableOverDrag: false,
|
|
93
|
-
backdropComponent: ScrimBackdrop,
|
|
94
|
-
backgroundStyle: styles.sheetBackground,
|
|
95
|
-
footerComponent: renderFooter,
|
|
96
|
-
onDismiss: handleDismiss,
|
|
97
|
-
children: /*#__PURE__*/_jsx(BottomSheetView, {
|
|
98
|
-
style: styles.sheet,
|
|
99
|
-
children: entry ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
100
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
101
|
-
style: styles.title,
|
|
102
|
-
children: entry.title
|
|
103
|
-
}), entry.message ? /*#__PURE__*/_jsx(Text, {
|
|
104
|
-
style: styles.message,
|
|
105
|
-
children: entry.message
|
|
106
|
-
}) : null]
|
|
107
|
-
}) : null
|
|
108
|
-
})
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=ConfirmHost.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","useMemo","useRef","useState","Text","View","BottomSheetBackdrop","BottomSheetFooter","BottomSheetModal","BottomSheetView","useThemedStyles","Button","_subs","makeStyles","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","ScrimBackdrop","props","appearsOnIndex","disappearsOnIndex","opacity","ConfirmHost","styles","modalRef","entry","setEntry","sub","next","current","present","dismiss","add","delete","handleDismiss","resolve","handleConfirm","handleCancel","snapPoints","renderFooter","bottomInset","children","style","actions","testID","label","cancelLabel","variant","block","onPress","confirmLabel","destructive","ref","index","enableDynamicSizing","enableOverDrag","backdropComponent","backgroundStyle","sheetBackground","footerComponent","onDismiss","sheet","title","message"],"sourceRoot":"../../../../../src","sources":["components/ui/Confirm/ConfirmHost.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SAASC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AACzC,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,gBAAgB,EAChBC,eAAe,QAGV,sBAAsB;AAC7B,SAASC,eAAe,QAAQ,yBAAgB;AAChD,SAASC,MAAM,QAAQ,oBAAW;AAClC,SAASC,KAAK,QAAQ,cAAW;AACjC,SAASC,UAAU,QAAQ,aAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAGtC;AACA,SAASC,aAAaA,CAACC,KAA+B,EAAE;EACtD,oBACEN,IAAA,CAACT,mBAAmB;IAAA,GACde,KAAK;IACTC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AAa;IAC9BqB,SAAS,EAAE1B,aAAc;IAAAO,QAAA,eAEzB7B,IAAA,CAACN,eAAe;MAACoC,KAAK,EAAEnB,MAAM,CAACsC,KAAM;MAAApB,QAAA,EAClChB,KAAK,gBACJX,KAAA,CAAAE,SAAA;QAAAyB,QAAA,gBACE7B,IAAA,CAACX,IAAI;UAACyC,KAAK,EAAEnB,MAAM,CAACuC,KAAM;UAAArB,QAAA,EAAEhB,KAAK,CAACqC;QAAK,CAAO,CAAC,EAC9CrC,KAAK,CAACsC,OAAO,gBACZnD,IAAA,CAACX,IAAI;UAACyC,KAAK,EAAEnB,MAAM,CAACwC,OAAQ;UAAAtB,QAAA,EAAEhB,KAAK,CAACsC;QAAO,CAAO,CAAC,GACjD,IAAI;MAAA,CACR,CAAC,GACD;IAAI,CACO;EAAC,CACF,CAAC;AAEvB","ignoreList":[]}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 命令式 `confirm()` API —— 跟 `<ConfirmHost />` 配对使用。
|
|
5
|
-
*
|
|
6
|
-
* 业务任意位置 `const ok = await confirm({title, message, ...})`,
|
|
7
|
-
* 不用维护 useState / open / onClose。
|
|
8
|
-
*
|
|
9
|
-
* 同一时间只允许 1 个 confirm 活跃;若已有正在显示,新请求立即 resolve(false) 并 warn。
|
|
10
|
-
*/
|
|
11
|
-
import { createLogger } from "../../../utils/logger/index.js";
|
|
12
|
-
const log = createLogger('confirm');
|
|
13
|
-
let _id = 0;
|
|
14
|
-
let _activeEntry = null;
|
|
15
|
-
export const _subs = new Set();
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 弹出确认对话框,返回 Promise<boolean>。
|
|
19
|
-
* - 用户点确认 → resolve(true)
|
|
20
|
-
* - 用户点取消 / 点 backdrop / 拖关闭 → resolve(false)
|
|
21
|
-
*
|
|
22
|
-
* 示例:
|
|
23
|
-
* ```ts
|
|
24
|
-
* const ok = await confirm({
|
|
25
|
-
* title: '确认注销账号?',
|
|
26
|
-
* message: '注销后所有数据删除,无法恢复',
|
|
27
|
-
* confirmLabel: '确认注销',
|
|
28
|
-
* destructive: true,
|
|
29
|
-
* });
|
|
30
|
-
* if (ok) doLogout();
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export function confirm(options) {
|
|
34
|
-
if (_activeEntry) {
|
|
35
|
-
log.warn('confirm() 已有一个对话框在显示,新请求被拒绝(同一时间只 1 个,避免叠加)。');
|
|
36
|
-
return Promise.resolve(false);
|
|
37
|
-
}
|
|
38
|
-
return new Promise(resolve => {
|
|
39
|
-
const entry = {
|
|
40
|
-
id: ++_id,
|
|
41
|
-
...options,
|
|
42
|
-
resolve: confirmed => {
|
|
43
|
-
_activeEntry = null;
|
|
44
|
-
resolve(confirmed);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
_activeEntry = entry;
|
|
48
|
-
_subs.forEach(s => s(entry));
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=confirm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createLogger","log","_id","_activeEntry","_subs","Set","confirm","options","warn","Promise","resolve","entry","id","confirmed","forEach","s"],"sourceRoot":"../../../../../src","sources":["components/ui/Confirm/confirm.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,gCAAuB;AAGpD,MAAMC,GAAG,GAAGD,YAAY,CAAC,SAAS,CAAC;AAEnC,IAAIE,GAAG,GAAG,CAAC;AACX,IAAIC,YAAiC,GAAG,IAAI;AAC5C,OAAO,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAa,CAAC;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAOA,CAACC,OAAuB,EAAoB;EACjE,IAAIJ,YAAY,EAAE;IAChBF,GAAG,CAACO,IAAI,CACN,8CACF,CAAC;IACD,OAAOC,OAAO,CAACC,OAAO,CAAC,KAAK,CAAC;EAC/B;EACA,OAAO,IAAID,OAAO,CAAWC,OAAO,IAAK;IACvC,MAAMC,KAAmB,GAAG;MAC1BC,EAAE,EAAE,EAAEV,GAAG;MACT,GAAGK,OAAO;MACVG,OAAO,EAAGG,SAAkB,IAAK;QAC/BV,YAAY,GAAG,IAAI;QACnBO,OAAO,CAACG,SAAS,CAAC;MACpB;IACF,CAAC;IACDV,YAAY,GAAGQ,KAAK;IACpBP,KAAK,CAACU,OAAO,CAAEC,CAAC,IAAKA,CAAC,CAACJ,KAAK,CAAC,CAAC;EAChC,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["confirm","ConfirmHost"],"sourceRoot":"../../../../../src","sources":["components/ui/Confirm/index.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,cAAW;AACnC,SAASC,WAAW,QAAQ,kBAAe","ignoreList":[]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { StyleSheet } from 'react-native';
|
|
4
|
-
import { fw, space, type as t } from "../../../theme/index.js";
|
|
5
|
-
/** Confirm 对话框 styles —— title/message 走 BottomSheetView 顶部段,
|
|
6
|
-
* actions 走 BottomSheetFooter 自动浮到 sheet 底部。 */
|
|
7
|
-
export const makeStyles = c => StyleSheet.create({
|
|
8
|
-
sheetBackground: {
|
|
9
|
-
backgroundColor: c.surface
|
|
10
|
-
},
|
|
11
|
-
sheet: {
|
|
12
|
-
paddingHorizontal: space['9'],
|
|
13
|
-
paddingTop: space['4'],
|
|
14
|
-
gap: space['5']
|
|
15
|
-
},
|
|
16
|
-
title: {
|
|
17
|
-
fontSize: t.heroSm,
|
|
18
|
-
fontWeight: fw.semi,
|
|
19
|
-
color: c.foreground,
|
|
20
|
-
letterSpacing: -0.2
|
|
21
|
-
},
|
|
22
|
-
message: {
|
|
23
|
-
fontSize: t.body,
|
|
24
|
-
color: c.foregroundMuted,
|
|
25
|
-
lineHeight: t.body * 1.45
|
|
26
|
-
},
|
|
27
|
-
actions: {
|
|
28
|
-
flexDirection: 'row',
|
|
29
|
-
gap: space['4'],
|
|
30
|
-
paddingHorizontal: space['9'],
|
|
31
|
-
paddingTop: space['5'],
|
|
32
|
-
paddingBottom: space['7']
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSheet","fw","space","type","t","makeStyles","c","create","sheetBackground","backgroundColor","surface","sheet","paddingHorizontal","paddingTop","gap","title","fontSize","heroSm","fontWeight","semi","color","foreground","letterSpacing","message","body","foregroundMuted","lineHeight","actions","flexDirection","paddingBottom"],"sourceRoot":"../../../../../src","sources":["components/ui/Confirm/styles.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,EAAE,EAAEC,KAAK,EAAEC,IAAI,IAAIC,CAAC,QAAQ,yBAAgB;AAGrD;AACA;AACA,OAAO,MAAMC,UAAU,GAAIC,CAAc,IACvCN,UAAU,CAACO,MAAM,CAAC;EAChBC,eAAe,EAAE;IACfC,eAAe,EAAEH,CAAC,CAACI;EACrB,CAAC;EACDC,KAAK,EAAE;IACLC,iBAAiB,EAAEV,KAAK,CAAC,GAAG,CAAC;IAC7BW,UAAU,EAAEX,KAAK,CAAC,GAAG,CAAC;IACtBY,GAAG,EAAEZ,KAAK,CAAC,GAAG;EAChB,CAAC;EACDa,KAAK,EAAE;IACLC,QAAQ,EAAEZ,CAAC,CAACa,MAAM;IAClBC,UAAU,EAAEjB,EAAE,CAACkB,IAAI;IACnBC,KAAK,EAAEd,CAAC,CAACe,UAAU;IACnBC,aAAa,EAAE,CAAC;EAClB,CAAC;EACDC,OAAO,EAAE;IACPP,QAAQ,EAAEZ,CAAC,CAACoB,IAAI;IAChBJ,KAAK,EAAEd,CAAC,CAACmB,eAAe;IACxBC,UAAU,EAAEtB,CAAC,CAACoB,IAAI,GAAG;EACvB,CAAC;EACDG,OAAO,EAAE;IACPC,aAAa,EAAE,KAAK;IACpBd,GAAG,EAAEZ,KAAK,CAAC,GAAG,CAAC;IACfU,iBAAiB,EAAEV,KAAK,CAAC,GAAG,CAAC;IAC7BW,UAAU,EAAEX,KAAK,CAAC,GAAG,CAAC;IACtB2B,aAAa,EAAE3B,KAAK,CAAC,GAAG;EAC1B;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["components/ui/Confirm/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheet.d.ts","sourceRoot":"","sources":["../../../../../../src/components/ui/BottomSheet/BottomSheet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,CAAC;AAWpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAahD,wBAAgB,WAAW,CAAC,EAC1B,UAAgC,EAChC,QAAQ,EACR,UAAU,EACV,QAAkB,EAClB,OAAc,EACd,OAAO,EACP,MAAM,GACP,EAAE,gBAAgB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAoFtC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/ui/BottomSheet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|