@flipova/foundation 1.14.0 → 2.0.5
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/CHANGELOG.md +181 -0
- package/README.md +53 -178
- package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +162 -0
- package/components/ui/accordion/AccordionAnimatedHeight.tsx +56 -0
- package/components/ui/accordion/AccordionAnimatedIcon.tsx +41 -0
- package/components/ui/accordion/AnimatedHeight.tsx +56 -0
- package/components/ui/accordion/AnimatedIcon.tsx +41 -0
- package/components/ui/accordion/MIGRATION_SUMMARY.md +250 -0
- package/components/ui/accordion/USAGE_EXAMPLE.tsx +179 -0
- package/components/ui/accordion/animation-config.ts +32 -0
- package/components/ui/accordion/index.tsx +253 -0
- package/components/ui/actionsheet/index.tsx +511 -0
- package/components/ui/alert/index.tsx +158 -0
- package/components/ui/alert-dialog/index.tsx +254 -0
- package/components/ui/avatar/index.tsx +139 -0
- package/components/ui/badge/index.tsx +163 -0
- package/components/ui/bottomsheet/index.tsx +477 -0
- package/components/ui/box/index.tsx +19 -0
- package/components/ui/box/index.web.tsx +19 -0
- package/components/ui/box/styles.tsx +10 -0
- package/components/ui/button/index.tsx +264 -0
- package/components/ui/calendar/creator.tsx +366 -0
- package/components/ui/calendar/index.tsx +462 -0
- package/components/ui/calendar/styles.tsx +140 -0
- package/components/ui/card/index.tsx +23 -0
- package/components/ui/card/index.web.tsx +26 -0
- package/components/ui/card/styles.tsx +16 -0
- package/components/ui/center/index.tsx +22 -0
- package/components/ui/center/index.web.tsx +20 -0
- package/components/ui/center/styles.tsx +8 -0
- package/components/ui/checkbox/index.tsx +184 -0
- package/components/ui/date-time-picker/creator.tsx +109 -0
- package/components/ui/date-time-picker/index.tsx +585 -0
- package/components/ui/date-time-picker/index.web.tsx +217 -0
- package/components/ui/date-time-picker/styles.tsx +56 -0
- package/components/ui/divider/index.tsx +40 -0
- package/components/ui/drawer/index.tsx +362 -0
- package/components/ui/fab/index.tsx +215 -0
- package/components/ui/flat-list/index.tsx +21 -0
- package/components/ui/form-control/index.tsx +352 -0
- package/components/ui/gluestack-ui-provider/config.ts +72 -0
- package/components/ui/gluestack-ui-provider/index.tsx +47 -0
- package/components/ui/gluestack-ui-provider/index.web.tsx +96 -0
- package/components/ui/gluestack-ui-provider/script.ts +19 -0
- package/components/ui/gluestack-ui-provider/tokens.d.ts +17 -0
- package/components/ui/gluestack-ui-provider/tokens.js +188 -0
- package/components/ui/gluestack-ui-provider/useGluestackColors.ts +82 -0
- package/components/ui/grid/index.tsx +283 -0
- package/components/ui/grid/index.web.tsx +66 -0
- package/components/ui/grid/styles.tsx +15 -0
- package/components/ui/heading/index.tsx +220 -0
- package/components/ui/heading/index.web.tsx +202 -0
- package/components/ui/heading/styles.tsx +43 -0
- package/components/ui/hstack/index.tsx +27 -0
- package/components/ui/hstack/index.web.tsx +26 -0
- package/components/ui/hstack/styles.tsx +25 -0
- package/components/ui/icon/index.tsx +1588 -0
- package/components/ui/icon/index.web.tsx +1573 -0
- package/components/ui/image/index.tsx +48 -0
- package/components/ui/image-background/index.tsx +25 -0
- package/components/ui/image-viewer/index.tsx +743 -0
- package/components/ui/image-viewer/index.web.tsx +302 -0
- package/components/ui/index.ts +58 -0
- package/components/ui/input/index.tsx +125 -0
- package/components/ui/input-accessory-view/index.tsx +2 -0
- package/components/ui/keyboard-avoiding-view/index.tsx +2 -0
- package/components/ui/link/index.tsx +102 -0
- package/components/ui/liquid-glass/index.tsx +74 -0
- package/components/ui/menu/index.tsx +186 -0
- package/components/ui/modal/index.tsx +237 -0
- package/components/ui/popover/index.tsx +272 -0
- package/components/ui/portal/index.tsx +17 -0
- package/components/ui/pressable/index.tsx +39 -0
- package/components/ui/progress/index.tsx +83 -0
- package/components/ui/radio/index.tsx +217 -0
- package/components/ui/refresh-control/index.tsx +2 -0
- package/components/ui/safe-area-view/index.tsx +2 -0
- package/components/ui/scroll-view/index.tsx +2 -0
- package/components/ui/section-list/index.tsx +2 -0
- package/components/ui/select/index.tsx +277 -0
- package/components/ui/select/select-actionsheet.tsx +562 -0
- package/components/ui/skeleton/index.tsx +105 -0
- package/components/ui/skeleton/index.web.tsx +103 -0
- package/components/ui/skeleton/styles.tsx +35 -0
- package/components/ui/slider/index.tsx +181 -0
- package/components/ui/spinner/index.tsx +40 -0
- package/components/ui/status-bar/index.tsx +2 -0
- package/components/ui/switch/index.tsx +41 -0
- package/components/ui/table/index.tsx +210 -0
- package/components/ui/table/index.web.tsx +157 -0
- package/components/ui/table/styles.tsx +44 -0
- package/components/ui/tabs/TabsAnimatedIndicator.tsx +160 -0
- package/components/ui/tabs/animation-config.ts +3 -0
- package/components/ui/tabs/creator.tsx +206 -0
- package/components/ui/tabs/index.tsx +484 -0
- package/components/ui/text/index.tsx +48 -0
- package/components/ui/text/index.web.tsx +45 -0
- package/components/ui/text/styles.tsx +47 -0
- package/components/ui/textarea/index.tsx +94 -0
- package/components/ui/toast/index.tsx +252 -0
- package/components/ui/tooltip/index.tsx +131 -0
- package/components/ui/view/index.tsx +2 -0
- package/components/ui/virtualized-list/index.tsx +2 -0
- package/components/ui/vstack/index.tsx +28 -0
- package/components/ui/vstack/index.web.tsx +27 -0
- package/components/ui/vstack/styles.tsx +25 -0
- package/design/canonical.index.txt +53 -0
- package/design/documentation.xml +519 -0
- package/design/manifest.xml +90 -0
- package/design/schema.xsd +639 -0
- package/design/themes.xml +204 -0
- package/design/tokens.xml +510 -0
- package/design/tools/design.js +165 -0
- package/design/tools/npm.js +65 -0
- package/design/tools/requirements.txt +35 -0
- package/design/tools/sources/.checker/__init__.py +81 -0
- package/design/tools/sources/.checker/checks.py +198 -0
- package/design/tools/sources/.checker/cli.py +154 -0
- package/design/tools/sources/.checker/io.py +242 -0
- package/design/tools/sources/.checker/model.py +144 -0
- package/design/tools/sources/.checker/registry.py +115 -0
- package/design/tools/sources/.checker/report.py +21 -0
- package/design/tools/sources/.docgen/__init__.py +45 -0
- package/design/tools/sources/.docgen/cli.py +101 -0
- package/design/tools/sources/.docgen/model.py +147 -0
- package/design/tools/sources/.docgen/reference.py +97 -0
- package/design/tools/sources/.docgen/site.py +145 -0
- package/design/tools/sources/.docgen/xsddoc.py +329 -0
- package/design/tools/sources/.generate/__init__.py +35 -0
- package/design/tools/sources/.generate/cli.py +76 -0
- package/design/tools/sources/.generate/common.py +33 -0
- package/design/tools/sources/.generate/config.py +119 -0
- package/design/tools/sources/.generate/model.py +51 -0
- package/design/tools/sources/.generate/tokens.py +141 -0
- package/design/tools/sources/.linter/__init__.py +9 -0
- package/design/tools/sources/.linter/cli.py +44 -0
- package/design/tools/sources/.linter/discovery.py +30 -0
- package/design/tools/sources/.linter/errors.py +45 -0
- package/design/tools/sources/.linter/linter.py +68 -0
- package/design/tools/sources/.xmleditor/__init__.py +74 -0
- package/design/tools/sources/.xmleditor/blocks.py +185 -0
- package/design/tools/sources/.xmleditor/cli.py +141 -0
- package/design/tools/sources/.xmleditor/editor.py +906 -0
- package/design/tools/sources/.xmleditor/model.py +708 -0
- package/design/tools/sources/.xmleditor/widgets.py +1832 -0
- package/design/tools/sources/.xmleditor/xsdmodel.py +753 -0
- package/design/tools/sources/checker.py +55 -0
- package/design/tools/sources/docgen.py +66 -0
- package/design/tools/sources/generate.py +48 -0
- package/design/tools/sources/linter.py +54 -0
- package/design/tools/sources/ruff.toml +12 -0
- package/design/tools/sources/xmleditor.py +62 -0
- package/design/tools/unix/_venv_python.sh +16 -0
- package/design/tools/unix/check.sh +13 -0
- package/design/tools/unix/doc.sh +14 -0
- package/design/tools/unix/gen.sh +14 -0
- package/design/tools/unix/lint.sh +10 -0
- package/design/tools/unix/run.sh +20 -0
- package/design/tools/unix/verify.sh +12 -0
- package/design/tools/unix/xmledit.sh +12 -0
- package/design/tools/windows/check.cmd +12 -0
- package/design/tools/windows/doc.cmd +12 -0
- package/design/tools/windows/gen.cmd +11 -0
- package/design/tools/windows/lint.cmd +9 -0
- package/design/tools/windows/run.cmd +26 -0
- package/design/tools/windows/verify.cmd +10 -0
- package/design/tools/windows/xmledit.cmd +10 -0
- package/dist/chunk-LV4UIEQN.js +9730 -0
- package/dist/chunk-LV4UIEQN.js.map +1 -0
- package/dist/chunk-WNVU3BM2.mjs +9401 -0
- package/dist/chunk-WNVU3BM2.mjs.map +1 -0
- package/dist/index.d.mts +40 -10
- package/dist/index.d.ts +40 -10
- package/dist/index.js +726 -414
- package/dist/index.mjs +1 -5
- package/dist/ui/index.d.mts +6931 -3070
- package/dist/ui/index.d.ts +6931 -3070
- package/dist/ui/index.js +779 -352
- package/dist/ui/index.mjs +1 -2
- package/package.json +66 -149
- package/dist/chunk-2XORADW6.js +0 -24552
- package/dist/chunk-2XORADW6.js.map +0 -1
- package/dist/chunk-52BHHF5M.js +0 -46
- package/dist/chunk-52BHHF5M.js.map +0 -1
- package/dist/chunk-5647JY7Z.mjs +0 -100
- package/dist/chunk-5647JY7Z.mjs.map +0 -1
- package/dist/chunk-5N5HC4ZA.mjs +0 -3
- package/dist/chunk-5N5HC4ZA.mjs.map +0 -1
- package/dist/chunk-7QFZMGL6.js +0 -8583
- package/dist/chunk-7QFZMGL6.js.map +0 -1
- package/dist/chunk-ASZEP37D.js +0 -423
- package/dist/chunk-ASZEP37D.js.map +0 -1
- package/dist/chunk-BH5SU2JQ.mjs +0 -8282
- package/dist/chunk-BH5SU2JQ.mjs.map +0 -1
- package/dist/chunk-BO65GO53.mjs +0 -422
- package/dist/chunk-BO65GO53.mjs.map +0 -1
- package/dist/chunk-BSVXX52E.mjs +0 -413
- package/dist/chunk-BSVXX52E.mjs.map +0 -1
- package/dist/chunk-DNV5UBNF.mjs +0 -3
- package/dist/chunk-DNV5UBNF.mjs.map +0 -1
- package/dist/chunk-EDTAMUO2.js +0 -8310
- package/dist/chunk-EDTAMUO2.js.map +0 -1
- package/dist/chunk-IJTI6EX4.js +0 -4
- package/dist/chunk-IJTI6EX4.js.map +0 -1
- package/dist/chunk-M3YLASM2.js +0 -428
- package/dist/chunk-M3YLASM2.js.map +0 -1
- package/dist/chunk-OXKOGLXE.js +0 -4
- package/dist/chunk-OXKOGLXE.js.map +0 -1
- package/dist/chunk-RQXQK3ZO.mjs +0 -8486
- package/dist/chunk-RQXQK3ZO.mjs.map +0 -1
- package/dist/chunk-SR25V4EA.mjs +0 -40
- package/dist/chunk-SR25V4EA.mjs.map +0 -1
- package/dist/chunk-UB34WFEQ.js +0 -106
- package/dist/chunk-UB34WFEQ.js.map +0 -1
- package/dist/chunk-ZBRWXKDF.mjs +0 -24431
- package/dist/chunk-ZBRWXKDF.mjs.map +0 -1
- package/dist/cli/ds.d.mts +0 -1
- package/dist/cli/ds.d.ts +0 -1
- package/dist/cli/ds.js +0 -602
- package/dist/cli/ds.js.map +0 -1
- package/dist/cli/ds.mjs +0 -579
- package/dist/cli/ds.mjs.map +0 -1
- package/dist/cli/flipova.d.mts +0 -1
- package/dist/cli/flipova.d.ts +0 -1
- package/dist/cli/flipova.js +0 -161
- package/dist/cli/flipova.js.map +0 -1
- package/dist/cli/flipova.mjs +0 -154
- package/dist/cli/flipova.mjs.map +0 -1
- package/dist/config/index.d.mts +0 -123
- package/dist/config/index.d.ts +0 -123
- package/dist/config/index.js +0 -28
- package/dist/config/index.js.map +0 -1
- package/dist/config/index.mjs +0 -3
- package/dist/config/index.mjs.map +0 -1
- package/dist/createTheme-DQeX3s0I.d.mts +0 -78
- package/dist/createTheme-Y4jfz4-u.d.ts +0 -78
- package/dist/index-CuaJA3gM.d.mts +0 -78
- package/dist/index-CuaJA3gM.d.ts +0 -78
- package/dist/registry/index.d.mts +0 -10160
- package/dist/registry/index.d.ts +0 -10160
- package/dist/registry/index.js +0 -392
- package/dist/registry/index.js.map +0 -1
- package/dist/registry/index.mjs +0 -3
- package/dist/registry/index.mjs.map +0 -1
- package/dist/theme/index.d.mts +0 -35
- package/dist/theme/index.d.ts +0 -35
- package/dist/theme/index.js +0 -28
- package/dist/theme/index.js.map +0 -1
- package/dist/theme/index.mjs +0 -3
- package/dist/theme/index.mjs.map +0 -1
- package/dist/tokens/index.d.mts +0 -423
- package/dist/tokens/index.d.ts +0 -423
- package/dist/tokens/index.js +0 -44
- package/dist/tokens/index.js.map +0 -1
- package/dist/tokens/index.mjs +0 -3
- package/dist/tokens/index.mjs.map +0 -1
- package/dist/types/index.d.mts +0 -202
- package/dist/types/index.d.ts +0 -202
- package/dist/types/index.js +0 -4
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -3
- package/dist/types/index.mjs.map +0 -1
- package/dist/web/index.d.mts +0 -316
- package/dist/web/index.d.ts +0 -316
- package/dist/web/index.js +0 -1500
- package/dist/web/index.js.map +0 -1
- package/dist/web/index.mjs +0 -1396
- package/dist/web/index.mjs.map +0 -1
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { FocusScope } from '@gluestack-ui/utils/aria';
|
|
3
|
+
import { tva } from '@gluestack-ui/utils/nativewind-utils';
|
|
4
|
+
import GorhomBottomSheet, {
|
|
5
|
+
BottomSheetBackdrop as GorhomBottomSheetBackdrop,
|
|
6
|
+
BottomSheetFlatList as GorhomBottomSheetFlatList,
|
|
7
|
+
BottomSheetFooter as GorhomBottomSheetFooter,
|
|
8
|
+
BottomSheetHandle as GorhomBottomSheetHandle,
|
|
9
|
+
BottomSheetTextInput as GorhomBottomSheetInput,
|
|
10
|
+
BottomSheetScrollView as GorhomBottomSheetScrollView,
|
|
11
|
+
BottomSheetSectionList as GorhomBottomSheetSectionList,
|
|
12
|
+
BottomSheetView as GorhomBottomSheetView,
|
|
13
|
+
type BottomSheetBackdropProps,
|
|
14
|
+
} from '@gorhom/bottom-sheet';
|
|
15
|
+
import { cssInterop } from 'nativewind';
|
|
16
|
+
import React, {
|
|
17
|
+
createContext,
|
|
18
|
+
forwardRef,
|
|
19
|
+
useCallback,
|
|
20
|
+
useContext,
|
|
21
|
+
useImperativeHandle,
|
|
22
|
+
useMemo,
|
|
23
|
+
useRef,
|
|
24
|
+
useState,
|
|
25
|
+
} from 'react';
|
|
26
|
+
import type { PressableProps, TextInputProps, TextProps } from 'react-native';
|
|
27
|
+
import { Keyboard, Platform, Pressable, Text, View } from 'react-native';
|
|
28
|
+
|
|
29
|
+
const bottomSheetBackdropStyle = tva({
|
|
30
|
+
base: 'absolute inset-0 bg-black/50',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const bottomSheetContentStyle = tva({
|
|
34
|
+
base: 'px-4 gap-2',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const bottomSheetTriggerStyle = tva({
|
|
38
|
+
base: 'p-4 rounded-lg border border-border/90',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const bottomSheetHandleStyle = tva({
|
|
42
|
+
base: 'py-3 w-full items-center rounded-t-xl',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const bottomSheetItemStyle = tva({
|
|
46
|
+
base: 'p-3 flex-row items-center rounded-sm w-full disabled:opacity-40 web:pointer-events-auto disabled:cursor-not-allowed hover:bg-background/90 active:bg-background/80 focus:bg-background/90 web:focus-visible:bg-background/90',
|
|
47
|
+
});
|
|
48
|
+
const bottomSheetItemTextStyle = tva({
|
|
49
|
+
base: 'text-foreground font-normal text-sm',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const bottomSheetFooterStyle = tva({
|
|
53
|
+
base: 'p-4 border-t border-border/90',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const bottomSheetTextInputStyle = tva({
|
|
57
|
+
base: 'flex-1 text-foreground text-sm md:text-sm py-1 placeholder:text-muted-foreground web:outline-none ios:leading-[0px] web:cursor-text h-9 w-full flex-row items-center rounded-md border border-border dark:bg-input/30 bg-transparent shadow-xs transition-[color,box-shadow] overflow-hidden px-3 gap-2',
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
type BottomSheetContextValue = {
|
|
61
|
+
visible: boolean;
|
|
62
|
+
bottomSheetRef: React.RefObject<GorhomBottomSheet | null>;
|
|
63
|
+
handleClose: () => void;
|
|
64
|
+
handleNaturalClose: () => void;
|
|
65
|
+
handleOpen: (index?: number) => void;
|
|
66
|
+
snapToIndex: (index: number) => void;
|
|
67
|
+
currentIndex: number;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const BottomSheetContext = createContext<BottomSheetContextValue>({
|
|
71
|
+
visible: false,
|
|
72
|
+
bottomSheetRef: { current: null! },
|
|
73
|
+
handleClose: () => { },
|
|
74
|
+
handleNaturalClose: () => { },
|
|
75
|
+
handleOpen: () => { },
|
|
76
|
+
snapToIndex: () => { },
|
|
77
|
+
currentIndex: -1,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export type BottomSheetRef = {
|
|
81
|
+
open: (index?: number) => void;
|
|
82
|
+
close: () => void;
|
|
83
|
+
snapToIndex: (index: number) => void;
|
|
84
|
+
expand: () => void;
|
|
85
|
+
collapse: () => void;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
type IBottomSheetRootProps = {
|
|
89
|
+
defaultSnapIndex?: number;
|
|
90
|
+
children?: React.ReactNode;
|
|
91
|
+
onOpen?: () => void;
|
|
92
|
+
onClose?: () => void;
|
|
93
|
+
onChange?: (index: number) => void;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const BottomSheet = forwardRef<BottomSheetRef, IBottomSheetRootProps>(
|
|
97
|
+
({ defaultSnapIndex = 0, onOpen, onClose, onChange, children }, ref) => {
|
|
98
|
+
const bottomSheetRef = useRef<GorhomBottomSheet>(null);
|
|
99
|
+
const [visible, setVisible] = useState(false);
|
|
100
|
+
const [currentIndex, setCurrentIndex] = useState(-1);
|
|
101
|
+
|
|
102
|
+
const handleOpen = useCallback(
|
|
103
|
+
(index?: number) => {
|
|
104
|
+
const targetIndex = index ?? defaultSnapIndex;
|
|
105
|
+
bottomSheetRef.current?.snapToIndex(targetIndex);
|
|
106
|
+
setVisible(true);
|
|
107
|
+
setCurrentIndex(targetIndex);
|
|
108
|
+
onOpen?.();
|
|
109
|
+
},
|
|
110
|
+
[defaultSnapIndex, onOpen]
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// Triggers the close animation only — state updates happen via onChange chain
|
|
114
|
+
const handleClose = useCallback(() => {
|
|
115
|
+
Keyboard.dismiss();
|
|
116
|
+
bottomSheetRef.current?.close();
|
|
117
|
+
}, []);
|
|
118
|
+
|
|
119
|
+
// Updates React state after sheet has naturally closed (index reached -1)
|
|
120
|
+
const handleNaturalClose = useCallback(() => {
|
|
121
|
+
Keyboard.dismiss();
|
|
122
|
+
setVisible(false);
|
|
123
|
+
setCurrentIndex(-1);
|
|
124
|
+
onClose?.();
|
|
125
|
+
}, [onClose]);
|
|
126
|
+
|
|
127
|
+
const snapToIndex = useCallback((index: number) => {
|
|
128
|
+
bottomSheetRef.current?.snapToIndex(index);
|
|
129
|
+
setCurrentIndex(index);
|
|
130
|
+
}, []);
|
|
131
|
+
|
|
132
|
+
const expand = useCallback(() => {
|
|
133
|
+
bottomSheetRef.current?.expand();
|
|
134
|
+
}, []);
|
|
135
|
+
|
|
136
|
+
const collapse = useCallback(() => {
|
|
137
|
+
bottomSheetRef.current?.collapse();
|
|
138
|
+
}, []);
|
|
139
|
+
|
|
140
|
+
useImperativeHandle(
|
|
141
|
+
ref,
|
|
142
|
+
() => ({
|
|
143
|
+
open: handleOpen,
|
|
144
|
+
close: handleClose,
|
|
145
|
+
snapToIndex,
|
|
146
|
+
expand,
|
|
147
|
+
collapse,
|
|
148
|
+
}),
|
|
149
|
+
[handleOpen, handleClose, snapToIndex, expand, collapse]
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const contextValue = useMemo(
|
|
153
|
+
() => ({
|
|
154
|
+
visible,
|
|
155
|
+
bottomSheetRef,
|
|
156
|
+
handleClose,
|
|
157
|
+
handleNaturalClose,
|
|
158
|
+
handleOpen,
|
|
159
|
+
snapToIndex,
|
|
160
|
+
currentIndex,
|
|
161
|
+
}),
|
|
162
|
+
[visible, handleClose, handleNaturalClose, handleOpen, snapToIndex, currentIndex]
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<BottomSheetContext.Provider value={contextValue}>
|
|
167
|
+
{children}
|
|
168
|
+
</BottomSheetContext.Provider>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
BottomSheet.displayName = 'BottomSheet';
|
|
174
|
+
|
|
175
|
+
type IBottomSheetPortalProps = Omit<
|
|
176
|
+
React.ComponentProps<typeof GorhomBottomSheet>,
|
|
177
|
+
'ref'
|
|
178
|
+
> & {
|
|
179
|
+
snapPoints: (string | number)[];
|
|
180
|
+
className?: string;
|
|
181
|
+
backgroundClassName?: string;
|
|
182
|
+
handleIndicatorClassName?: string;
|
|
183
|
+
enableDynamicSizing?: boolean;
|
|
184
|
+
closeOnBackdropPress?: boolean;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const BottomSheetPortal = ({
|
|
188
|
+
snapPoints,
|
|
189
|
+
handleComponent,
|
|
190
|
+
backdropComponent,
|
|
191
|
+
footerComponent,
|
|
192
|
+
className,
|
|
193
|
+
backgroundClassName,
|
|
194
|
+
handleIndicatorClassName,
|
|
195
|
+
index = -1,
|
|
196
|
+
enablePanDownToClose = true,
|
|
197
|
+
enableDynamicSizing = false,
|
|
198
|
+
closeOnBackdropPress = true,
|
|
199
|
+
onChange,
|
|
200
|
+
...props
|
|
201
|
+
}: IBottomSheetPortalProps) => {
|
|
202
|
+
const { bottomSheetRef, handleNaturalClose } = useContext(BottomSheetContext);
|
|
203
|
+
|
|
204
|
+
const handleSheetChanges = useCallback(
|
|
205
|
+
(idx: number) => {
|
|
206
|
+
(onChange as ((index: number) => void) | undefined)?.(idx);
|
|
207
|
+
// Sheet reached closed position naturally — update React state
|
|
208
|
+
if (idx === -1) {
|
|
209
|
+
handleNaturalClose();
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
[handleNaturalClose, onChange]
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<GorhomBottomSheet
|
|
217
|
+
ref={bottomSheetRef}
|
|
218
|
+
snapPoints={snapPoints}
|
|
219
|
+
index={index}
|
|
220
|
+
backdropComponent={backdropComponent}
|
|
221
|
+
handleComponent={handleComponent}
|
|
222
|
+
footerComponent={footerComponent}
|
|
223
|
+
onChange={handleSheetChanges}
|
|
224
|
+
enablePanDownToClose={enablePanDownToClose}
|
|
225
|
+
enableDynamicSizing={enableDynamicSizing}
|
|
226
|
+
// @ts-ignore - className support via cssInterop
|
|
227
|
+
backgroundClassName={`${backgroundClassName} bg-background border border-border/90 rounded-xl`}
|
|
228
|
+
// @ts-ignore
|
|
229
|
+
handleIndicatorClassName={`${handleIndicatorClassName} bg-primary`}
|
|
230
|
+
{...props}
|
|
231
|
+
>
|
|
232
|
+
{props.children}
|
|
233
|
+
</GorhomBottomSheet>
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export const BottomSheetTrigger = ({
|
|
238
|
+
className,
|
|
239
|
+
index,
|
|
240
|
+
onPress,
|
|
241
|
+
...props
|
|
242
|
+
}: PressableProps & { className?: string; index?: number }) => {
|
|
243
|
+
const { handleOpen } = useContext(BottomSheetContext);
|
|
244
|
+
return (
|
|
245
|
+
<Pressable
|
|
246
|
+
{...props}
|
|
247
|
+
onPress={(e) => {
|
|
248
|
+
onPress?.(e);
|
|
249
|
+
handleOpen(index);
|
|
250
|
+
}}
|
|
251
|
+
className={bottomSheetTriggerStyle({ className })}
|
|
252
|
+
>
|
|
253
|
+
{props.children}
|
|
254
|
+
</Pressable>
|
|
255
|
+
);
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
type IBottomSheetBackdropProps = BottomSheetBackdropProps & {
|
|
259
|
+
className?: string;
|
|
260
|
+
opacity?: number;
|
|
261
|
+
appearsOnIndex?: number;
|
|
262
|
+
disappearsOnIndex?: number;
|
|
263
|
+
pressBehavior?: 'none' | 'close' | 'collapse' | number;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
export const BottomSheetBackdrop = ({
|
|
267
|
+
disappearsOnIndex = -1,
|
|
268
|
+
appearsOnIndex = 0,
|
|
269
|
+
opacity = 0.5,
|
|
270
|
+
className,
|
|
271
|
+
pressBehavior = 'close',
|
|
272
|
+
...props
|
|
273
|
+
}: Partial<IBottomSheetBackdropProps>) => {
|
|
274
|
+
return (
|
|
275
|
+
<GorhomBottomSheetBackdrop
|
|
276
|
+
// @ts-ignore
|
|
277
|
+
className={bottomSheetBackdropStyle({ className })}
|
|
278
|
+
disappearsOnIndex={disappearsOnIndex}
|
|
279
|
+
appearsOnIndex={appearsOnIndex}
|
|
280
|
+
opacity={opacity}
|
|
281
|
+
pressBehavior={pressBehavior}
|
|
282
|
+
{...props}
|
|
283
|
+
/>
|
|
284
|
+
);
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
type IBottomSheetHandleProps = React.ComponentProps<
|
|
288
|
+
typeof GorhomBottomSheetHandle
|
|
289
|
+
> & {
|
|
290
|
+
className?: string;
|
|
291
|
+
indicatorClassName?: string;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export const BottomSheetDragIndicator = ({
|
|
295
|
+
children,
|
|
296
|
+
className,
|
|
297
|
+
indicatorClassName,
|
|
298
|
+
...props
|
|
299
|
+
}: Partial<IBottomSheetHandleProps>) => {
|
|
300
|
+
return (
|
|
301
|
+
<GorhomBottomSheetHandle
|
|
302
|
+
{...props}
|
|
303
|
+
// @ts-ignore
|
|
304
|
+
className={bottomSheetHandleStyle({ className })}
|
|
305
|
+
>
|
|
306
|
+
{children}
|
|
307
|
+
</GorhomBottomSheetHandle>
|
|
308
|
+
);
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
type IBottomSheetContentProps = React.ComponentProps<
|
|
312
|
+
typeof GorhomBottomSheetView
|
|
313
|
+
> & {
|
|
314
|
+
className?: string;
|
|
315
|
+
focusScope?: boolean;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export const BottomSheetContent = ({
|
|
319
|
+
className,
|
|
320
|
+
focusScope = true,
|
|
321
|
+
...props
|
|
322
|
+
}: IBottomSheetContentProps) => {
|
|
323
|
+
const { handleClose, visible } = useContext(BottomSheetContext);
|
|
324
|
+
|
|
325
|
+
const keyDownHandlers = useMemo(() => {
|
|
326
|
+
if (Platform.OS !== 'web') return {};
|
|
327
|
+
return {
|
|
328
|
+
onKeyDown: (e: React.KeyboardEvent) => {
|
|
329
|
+
if (e.key === 'Escape') {
|
|
330
|
+
e.preventDefault();
|
|
331
|
+
handleClose();
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
}, [handleClose]);
|
|
336
|
+
|
|
337
|
+
const content = props.children;
|
|
338
|
+
const wrappedContent =
|
|
339
|
+
Platform.OS === 'web' && visible && focusScope ? (
|
|
340
|
+
<FocusScope contain={visible} autoFocus restoreFocus>
|
|
341
|
+
{content}
|
|
342
|
+
</FocusScope>
|
|
343
|
+
) : (
|
|
344
|
+
content
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
return (
|
|
348
|
+
<GorhomBottomSheetView
|
|
349
|
+
{...props}
|
|
350
|
+
// @ts-ignore
|
|
351
|
+
{...keyDownHandlers}
|
|
352
|
+
// @ts-ignore
|
|
353
|
+
className={bottomSheetContentStyle({ className })}
|
|
354
|
+
>
|
|
355
|
+
{wrappedContent}
|
|
356
|
+
</GorhomBottomSheetView>
|
|
357
|
+
);
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
type IBottomSheetFooterProps = React.ComponentProps<
|
|
361
|
+
typeof GorhomBottomSheetFooter
|
|
362
|
+
> & {
|
|
363
|
+
className?: string;
|
|
364
|
+
children?: React.ReactNode;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
export const BottomSheetFooter = ({
|
|
368
|
+
className,
|
|
369
|
+
children,
|
|
370
|
+
...props
|
|
371
|
+
}: IBottomSheetFooterProps) => {
|
|
372
|
+
return (
|
|
373
|
+
<GorhomBottomSheetFooter {...props}>
|
|
374
|
+
<View
|
|
375
|
+
// @ts-ignore
|
|
376
|
+
className={bottomSheetFooterStyle({ className })}
|
|
377
|
+
>
|
|
378
|
+
{children}
|
|
379
|
+
</View>
|
|
380
|
+
</GorhomBottomSheetFooter>
|
|
381
|
+
);
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
type IBottomSheetItemProps = PressableProps & {
|
|
385
|
+
className?: string;
|
|
386
|
+
closeOnSelect?: boolean;
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
export const BottomSheetItem = ({
|
|
390
|
+
children,
|
|
391
|
+
className,
|
|
392
|
+
closeOnSelect = true,
|
|
393
|
+
...props
|
|
394
|
+
}: IBottomSheetItemProps) => {
|
|
395
|
+
const { handleClose } = useContext(BottomSheetContext);
|
|
396
|
+
|
|
397
|
+
return (
|
|
398
|
+
<Pressable
|
|
399
|
+
{...props}
|
|
400
|
+
className={bottomSheetItemStyle({ className })}
|
|
401
|
+
onPress={(e) => {
|
|
402
|
+
props.onPress?.(e);
|
|
403
|
+
if (closeOnSelect) {
|
|
404
|
+
handleClose();
|
|
405
|
+
}
|
|
406
|
+
}}
|
|
407
|
+
role="button"
|
|
408
|
+
accessibilityRole="button"
|
|
409
|
+
>
|
|
410
|
+
{children}
|
|
411
|
+
</Pressable>
|
|
412
|
+
);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
type IBottomSheetItemTextProps = TextProps & {
|
|
416
|
+
className?: string;
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
export const BottomSheetItemText = ({
|
|
420
|
+
className,
|
|
421
|
+
...props
|
|
422
|
+
}: IBottomSheetItemTextProps) => {
|
|
423
|
+
return <Text {...props} className={bottomSheetItemTextStyle({ className })} />;
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
export const BottomSheetTextInput = ({
|
|
427
|
+
className,
|
|
428
|
+
...props
|
|
429
|
+
}: TextInputProps) => {
|
|
430
|
+
return <GorhomBottomSheetInput {...props} className={bottomSheetTextInputStyle({ className })} />;
|
|
431
|
+
};
|
|
432
|
+
// Scrollable components with className support
|
|
433
|
+
export const BottomSheetScrollView = GorhomBottomSheetScrollView;
|
|
434
|
+
export const BottomSheetFlatList = GorhomBottomSheetFlatList;
|
|
435
|
+
export const BottomSheetSectionList = GorhomBottomSheetSectionList;
|
|
436
|
+
|
|
437
|
+
// Configure cssInterop for all Gorhom components to support className
|
|
438
|
+
cssInterop(GorhomBottomSheet, {
|
|
439
|
+
className: 'style',
|
|
440
|
+
backgroundClassName: 'backgroundStyle',
|
|
441
|
+
handleIndicatorClassName: 'handleIndicatorStyle',
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
cssInterop(GorhomBottomSheetBackdrop, {
|
|
445
|
+
className: 'style',
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
cssInterop(GorhomBottomSheetHandle, {
|
|
449
|
+
className: 'style',
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
cssInterop(GorhomBottomSheetView, {
|
|
453
|
+
className: 'style',
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
cssInterop(GorhomBottomSheetFooter, {
|
|
457
|
+
className: 'style',
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
cssInterop(GorhomBottomSheetScrollView, {
|
|
461
|
+
className: 'style',
|
|
462
|
+
contentContainerClassName: 'contentContainerStyle',
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
cssInterop(GorhomBottomSheetFlatList, {
|
|
466
|
+
className: 'style',
|
|
467
|
+
contentContainerClassName: 'contentContainerStyle',
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
cssInterop(GorhomBottomSheetSectionList, {
|
|
471
|
+
className: 'style',
|
|
472
|
+
contentContainerClassName: 'contentContainerStyle',
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
cssInterop(GorhomBottomSheetInput, {
|
|
476
|
+
className: 'style',
|
|
477
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
|
|
5
|
+
import { boxStyle } from './styles';
|
|
6
|
+
|
|
7
|
+
type IBoxProps = ViewProps &
|
|
8
|
+
VariantProps<typeof boxStyle> & { className?: string };
|
|
9
|
+
|
|
10
|
+
const Box = React.forwardRef<React.ComponentRef<typeof View>, IBoxProps>(
|
|
11
|
+
function Box({ className, ...props }, ref) {
|
|
12
|
+
return (
|
|
13
|
+
<View ref={ref} {...props} className={boxStyle({ class: className })} />
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
Box.displayName = 'Box';
|
|
19
|
+
export { Box };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { boxStyle } from './styles';
|
|
3
|
+
|
|
4
|
+
import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
|
|
5
|
+
|
|
6
|
+
type IBoxProps = React.ComponentPropsWithoutRef<'div'> &
|
|
7
|
+
VariantProps<typeof boxStyle> & { className?: string };
|
|
8
|
+
|
|
9
|
+
const Box = React.forwardRef<HTMLDivElement, IBoxProps>(function Box(
|
|
10
|
+
{ className, ...props },
|
|
11
|
+
ref
|
|
12
|
+
) {
|
|
13
|
+
return (
|
|
14
|
+
<div ref={ref} className={boxStyle({ class: className })} {...props} />
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
Box.displayName = 'Box';
|
|
19
|
+
export { Box };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { tva } from '@gluestack-ui/utils/nativewind-utils';
|
|
2
|
+
import { isWeb } from '@gluestack-ui/utils/nativewind-utils';
|
|
3
|
+
|
|
4
|
+
const baseStyle = isWeb
|
|
5
|
+
? 'flex flex-col relative z-0 box-border border-0 list-none min-w-0 min-h-0 bg-transparent items-stretch m-0 p-0 text-decoration-none'
|
|
6
|
+
: '';
|
|
7
|
+
|
|
8
|
+
export const boxStyle = tva({
|
|
9
|
+
base: baseStyle,
|
|
10
|
+
});
|