@admin-layout/gluestack-ui-mobile 11.0.4-alpha.0 → 12.0.16-alpha.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/CHANGELOG.md +60 -4
- package/lib/__tests__/prolayout-layout-feature.test.js +1 -1
- package/lib/__tests__/prolayout-layout-feature.test.js.map +1 -1
- package/lib/components/AuthWrapper.js +5 -3
- package/lib/components/AuthWrapper.js.map +1 -1
- package/lib/components/ErrorBounday.js.map +1 -1
- package/lib/components/NavigationComponent.js.map +1 -1
- package/lib/components/UnAuthenticatedComponent.js.map +1 -1
- package/lib/components/WithConfiguration.js +4 -4
- package/lib/components/WithConfiguration.js.map +1 -1
- package/lib/components/WithPermission.js +1 -1
- package/lib/components/WithPermission.js.map +1 -1
- package/lib/components/WithPolicy.js +2 -2
- package/lib/components/WithPolicy.js.map +1 -1
- package/lib/components/ui/accordion/index.web.d.ts +209 -0
- package/lib/components/ui/accordion/index.web.js +156 -0
- package/lib/components/ui/accordion/index.web.js.map +1 -0
- package/lib/components/ui/actionsheet/index.web.d.ts +872 -0
- package/lib/components/ui/actionsheet/index.web.js +286 -0
- package/lib/components/ui/actionsheet/index.web.js.map +1 -0
- package/lib/components/ui/alert/index.web.d.ts +135 -0
- package/lib/components/ui/alert/index.web.js +38 -0
- package/lib/components/ui/alert/index.web.js.map +1 -0
- package/lib/components/ui/alert-dialog/index.web.d.ts +64 -0
- package/lib/components/ui/alert-dialog/index.web.js +139 -0
- package/lib/components/ui/alert-dialog/index.web.js.map +1 -0
- package/lib/components/ui/avatar/index.web.d.ts +21 -0
- package/lib/components/ui/avatar/index.web.js +92 -0
- package/lib/components/ui/avatar/index.web.js.map +1 -0
- package/lib/components/ui/badge/index.web.d.ts +382 -0
- package/lib/components/ui/badge/index.web.js +138 -0
- package/lib/components/ui/badge/index.web.js.map +1 -0
- package/lib/components/ui/button/index.web.d.ts +247 -0
- package/lib/components/ui/button/index.web.js +57 -0
- package/lib/components/ui/button/index.web.js.map +1 -0
- package/lib/components/ui/checkbox/index.web.d.ts +265 -0
- package/lib/components/ui/checkbox/index.web.js +77 -0
- package/lib/components/ui/checkbox/index.web.js.map +1 -0
- package/lib/components/ui/divider/index.web.d.ts +53 -0
- package/lib/components/ui/divider/index.web.js +21 -0
- package/lib/components/ui/divider/index.web.js.map +1 -0
- package/lib/components/ui/drawer/index.web.d.ts +174 -0
- package/lib/components/ui/drawer/index.web.js +65 -0
- package/lib/components/ui/drawer/index.web.js.map +1 -0
- package/lib/components/ui/fab/index.web.d.ts +520 -0
- package/lib/components/ui/fab/index.web.js +146 -0
- package/lib/components/ui/fab/index.web.js.map +1 -0
- package/lib/components/ui/flat-list/index.web.d.ts +21 -0
- package/lib/components/ui/flat-list/index.web.js +41 -0
- package/lib/components/ui/flat-list/index.web.js.map +1 -0
- package/lib/components/ui/form-control/index.web.d.ts +2071 -0
- package/lib/components/ui/form-control/index.web.js +290 -0
- package/lib/components/ui/form-control/index.web.js.map +1 -0
- package/lib/components/ui/image/index.web.d.ts +142 -0
- package/lib/components/ui/image/index.web.js +29 -0
- package/lib/components/ui/image/index.web.js.map +1 -0
- package/lib/components/ui/image-background/index.web.d.ts +8 -0
- package/lib/components/ui/image-background/index.web.js +23 -0
- package/lib/components/ui/image-background/index.web.js.map +1 -0
- package/lib/components/ui/input/index.web.d.ts +163 -0
- package/lib/components/ui/input/index.web.js +50 -0
- package/lib/components/ui/input/index.web.js.map +1 -0
- package/lib/components/ui/input-accessory-view/index.web.d.ts +9 -0
- package/lib/components/ui/input-accessory-view/index.web.js +16 -0
- package/lib/components/ui/input-accessory-view/index.web.js.map +1 -0
- package/lib/components/ui/keyboard-avoiding-view/index.web.d.ts +9 -0
- package/lib/components/ui/keyboard-avoiding-view/index.web.js +8 -0
- package/lib/components/ui/keyboard-avoiding-view/index.web.js.map +1 -0
- package/lib/components/ui/link/index.web.d.ts +365 -0
- package/lib/components/ui/link/index.web.js +70 -0
- package/lib/components/ui/link/index.web.js.map +1 -0
- package/lib/components/ui/menu/index.web.d.ts +142 -0
- package/lib/components/ui/menu/index.web.js +83 -0
- package/lib/components/ui/menu/index.web.js.map +1 -0
- package/lib/components/ui/modal/index.web.d.ts +111 -0
- package/lib/components/ui/modal/index.web.js +58 -0
- package/lib/components/ui/modal/index.web.js.map +1 -0
- package/lib/components/ui/popover/index.web.d.ts +309 -0
- package/lib/components/ui/popover/index.web.js +184 -0
- package/lib/components/ui/popover/index.web.js.map +1 -0
- package/lib/components/ui/portal/index.web.d.ts +9 -0
- package/lib/components/ui/portal/index.web.js +16 -0
- package/lib/components/ui/portal/index.web.js.map +1 -0
- package/lib/components/ui/pressable/index.web.d.ts +8 -0
- package/lib/components/ui/pressable/index.web.js +44 -0
- package/lib/components/ui/pressable/index.web.js.map +1 -0
- package/lib/components/ui/progress/index.web.d.ts +237 -0
- package/lib/components/ui/progress/index.web.js +73 -0
- package/lib/components/ui/progress/index.web.js.map +1 -0
- package/lib/components/ui/radio/index.web.d.ts +224 -0
- package/lib/components/ui/radio/index.web.js +69 -0
- package/lib/components/ui/radio/index.web.js.map +1 -0
- package/lib/components/ui/refresh-control/index.web.d.ts +14 -0
- package/lib/components/ui/refresh-control/index.web.js +69 -0
- package/lib/components/ui/refresh-control/index.web.js.map +1 -0
- package/lib/components/ui/safe-area-view/index.web.d.ts +6 -0
- package/lib/components/ui/safe-area-view/index.web.js +10 -0
- package/lib/components/ui/safe-area-view/index.web.js.map +1 -0
- package/lib/components/ui/scroll-view/index.web.d.ts +44 -0
- package/lib/components/ui/scroll-view/index.web.js +41 -0
- package/lib/components/ui/scroll-view/index.web.js.map +1 -0
- package/lib/components/ui/section-list/index.web.d.ts +26 -0
- package/lib/components/ui/section-list/index.web.js +35 -0
- package/lib/components/ui/section-list/index.web.js.map +1 -0
- package/lib/components/ui/select/index.web.d.ts +162 -0
- package/lib/components/ui/select/index.web.js +51 -0
- package/lib/components/ui/select/index.web.js.map +1 -0
- package/lib/components/ui/slider/index.web.d.ts +223 -0
- package/lib/components/ui/slider/index.web.js +189 -0
- package/lib/components/ui/slider/index.web.js.map +1 -0
- package/lib/components/ui/spinner/index.web.d.ts +176 -0
- package/lib/components/ui/spinner/index.web.js +55 -0
- package/lib/components/ui/spinner/index.web.js.map +1 -0
- package/lib/components/ui/status-bar/index.web.d.ts +14 -0
- package/lib/components/ui/status-bar/index.web.js +7 -0
- package/lib/components/ui/status-bar/index.web.js.map +1 -0
- package/lib/components/ui/switch/index.web.d.ts +71 -0
- package/lib/components/ui/switch/index.web.js +27 -0
- package/lib/components/ui/switch/index.web.js.map +1 -0
- package/lib/components/ui/tabs/index.web.d.ts +351 -0
- package/lib/components/ui/tabs/index.web.js +120 -0
- package/lib/components/ui/tabs/index.web.js.map +1 -0
- package/lib/components/ui/textarea/index.web.d.ts +162 -0
- package/lib/components/ui/textarea/index.web.js +50 -0
- package/lib/components/ui/textarea/index.web.js.map +1 -0
- package/lib/components/ui/toast/index.web.d.ts +225 -0
- package/lib/components/ui/toast/index.web.js +80 -0
- package/lib/components/ui/toast/index.web.js.map +1 -0
- package/lib/components/ui/tooltip/index.web.d.ts +86 -0
- package/lib/components/ui/tooltip/index.web.js +110 -0
- package/lib/components/ui/tooltip/index.web.js.map +1 -0
- package/lib/components/ui/view/index.web.d.ts +2 -0
- package/lib/components/ui/view/index.web.js +7 -0
- package/lib/components/ui/view/index.web.js.map +1 -0
- package/lib/components/ui/virtualized-list/index.web.d.ts +19 -0
- package/lib/components/ui/virtualized-list/index.web.js +30 -0
- package/lib/components/ui/virtualized-list/index.web.js.map +1 -0
- package/lib/components/usePermissionAutoFetch.d.ts +7 -19
- package/lib/components/with-interactions-lifecycle-managed.js.map +1 -1
- package/lib/components/with-interactions-managed.js +2 -3
- package/lib/components/with-interactions-managed.js.map +1 -1
- package/lib/containers/layout/DrawerBottomNavigationConfig.d.ts +47 -47
- package/lib/containers/layout/DrawerConfig.d.ts +31 -31
- package/lib/containers/layout/module.js +1 -1
- package/lib/containers/layout/module.js.map +1 -1
- package/lib/interfaces/settings.d.ts +1 -0
- package/lib/redux/settings.d.ts +4 -9
- package/lib/utils/routeConfigKeyReplace.test.js +1 -1
- package/lib/utils/routeConfigKeyReplace.test.js.map +1 -1
- package/package.json +7 -4
- package/src/__tests__/prolayout-layout-feature.test.tsx +2 -2
- package/src/components/AuthWrapper.tsx +6 -3
- package/src/components/ErrorBounday.tsx +18 -19
- package/src/components/NavigationComponent.tsx +1 -1
- package/src/components/UnAuthenticatedComponent.tsx +1 -3
- package/src/components/WithConfiguration.tsx +5 -8
- package/src/components/WithPermission.tsx +1 -1
- package/src/components/WithPolicy.tsx +4 -3
- package/src/components/ui/accordion/index.web.tsx +294 -0
- package/src/components/ui/actionsheet/index.web.tsx +555 -0
- package/src/components/ui/alert/index.web.tsx +71 -0
- package/src/components/ui/alert-dialog/index.web.tsx +241 -0
- package/src/components/ui/avatar/index.web.tsx +150 -0
- package/src/components/ui/badge/index.web.tsx +188 -0
- package/src/components/ui/button/index.web.tsx +86 -0
- package/src/components/ui/checkbox/index.web.tsx +151 -0
- package/src/components/ui/divider/index.web.tsx +37 -0
- package/src/components/ui/drawer/index.web.tsx +144 -0
- package/src/components/ui/fab/index.web.tsx +201 -0
- package/src/components/ui/flat-list/index.web.tsx +89 -0
- package/src/components/ui/form-control/index.web.tsx +451 -0
- package/src/components/ui/image/index.web.tsx +43 -0
- package/src/components/ui/image-background/index.web.tsx +43 -0
- package/src/components/ui/input/index.web.tsx +80 -0
- package/src/components/ui/input-accessory-view/index.web.tsx +31 -0
- package/src/components/ui/keyboard-avoiding-view/index.web.tsx +23 -0
- package/src/components/ui/link/index.web.tsx +103 -0
- package/src/components/ui/menu/index.web.tsx +159 -0
- package/src/components/ui/modal/index.web.tsx +135 -0
- package/src/components/ui/popover/index.web.tsx +326 -0
- package/src/components/ui/portal/index.web.tsx +34 -0
- package/src/components/ui/pressable/index.web.tsx +73 -0
- package/src/components/ui/progress/index.web.tsx +123 -0
- package/src/components/ui/radio/index.web.tsx +130 -0
- package/src/components/ui/refresh-control/index.web.tsx +104 -0
- package/src/components/ui/safe-area-view/index.web.tsx +24 -0
- package/src/components/ui/scroll-view/index.web.tsx +142 -0
- package/src/components/ui/section-list/index.web.tsx +93 -0
- package/src/components/ui/select/index.web.tsx +83 -0
- package/src/components/ui/slider/index.web.tsx +283 -0
- package/src/components/ui/spinner/index.web.tsx +81 -0
- package/src/components/ui/status-bar/index.web.tsx +20 -0
- package/src/components/ui/switch/index.web.tsx +44 -0
- package/src/components/ui/tabs/index.web.tsx +205 -0
- package/src/components/ui/textarea/index.web.tsx +86 -0
- package/src/components/ui/toast/index.web.tsx +132 -0
- package/src/components/ui/tooltip/index.web.tsx +155 -0
- package/src/components/ui/view/index.web.tsx +15 -0
- package/src/components/ui/virtualized-list/index.web.tsx +84 -0
- package/src/components/with-interactions-lifecycle-managed.tsx +0 -4
- package/src/components/with-interactions-managed.tsx +3 -4
- package/src/containers/layout/module.ts +1 -1
- package/src/interfaces/settings.ts +1 -0
- package/src/utils/routeConfigKeyReplace.test.ts +4 -4
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
interface RefreshControlProps {
|
|
6
|
+
refreshing?: boolean;
|
|
7
|
+
onRefresh?: () => void;
|
|
8
|
+
progressViewOffset?: number;
|
|
9
|
+
tintColor?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
titleColor?: string;
|
|
12
|
+
colors?: string[];
|
|
13
|
+
enabled?: boolean;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const RefreshControl: React.FC<RefreshControlProps> = ({ refreshing = false, onRefresh, style, ...props }) => {
|
|
18
|
+
const [startY, setStartY] = useState(0);
|
|
19
|
+
const [pulling, setPulling] = useState(false);
|
|
20
|
+
const [pullDistance, setPullDistance] = useState(0);
|
|
21
|
+
const threshold = 100; // Minimum pull distance to trigger refresh
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!refreshing) {
|
|
25
|
+
setPullDistance(0);
|
|
26
|
+
setPulling(false);
|
|
27
|
+
}
|
|
28
|
+
}, [refreshing]);
|
|
29
|
+
|
|
30
|
+
const handleTouchStart = (e: React.TouchEvent) => {
|
|
31
|
+
if (window.scrollY === 0) {
|
|
32
|
+
setStartY(e.touches[0].clientY);
|
|
33
|
+
setPulling(true);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const handleTouchMove = (e: React.TouchEvent) => {
|
|
38
|
+
if (pulling && !refreshing) {
|
|
39
|
+
const currentY = e.touches[0].clientY;
|
|
40
|
+
const distance = Math.max(0, currentY - startY);
|
|
41
|
+
setPullDistance(Math.min(distance * 0.5, threshold * 1.5)); // Add resistance
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const handleTouchEnd = () => {
|
|
46
|
+
if (pulling && pullDistance >= threshold && onRefresh) {
|
|
47
|
+
onRefresh();
|
|
48
|
+
}
|
|
49
|
+
if (!refreshing) {
|
|
50
|
+
setPullDistance(0);
|
|
51
|
+
}
|
|
52
|
+
setPulling(false);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div
|
|
57
|
+
style={{
|
|
58
|
+
position: 'relative',
|
|
59
|
+
width: '100%',
|
|
60
|
+
...style,
|
|
61
|
+
}}
|
|
62
|
+
onTouchStart={handleTouchStart}
|
|
63
|
+
onTouchMove={handleTouchMove}
|
|
64
|
+
onTouchEnd={handleTouchEnd}
|
|
65
|
+
>
|
|
66
|
+
{(pulling || refreshing) && (
|
|
67
|
+
<div
|
|
68
|
+
style={{
|
|
69
|
+
position: 'absolute',
|
|
70
|
+
top: 0,
|
|
71
|
+
left: 0,
|
|
72
|
+
right: 0,
|
|
73
|
+
display: 'flex',
|
|
74
|
+
justifyContent: 'center',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
height: Math.max(pullDistance, refreshing ? 50 : 0),
|
|
77
|
+
transition: pulling ? 'none' : 'height 0.2s ease-out',
|
|
78
|
+
overflow: 'hidden',
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<div
|
|
82
|
+
style={{
|
|
83
|
+
width: '20px',
|
|
84
|
+
height: '20px',
|
|
85
|
+
border: '2px solid #ccc',
|
|
86
|
+
borderTopColor: props.tintColor || '#000',
|
|
87
|
+
borderRadius: '50%',
|
|
88
|
+
animation: refreshing ? 'spin 1s linear infinite' : 'none',
|
|
89
|
+
transform: !refreshing ? `rotate(${(pullDistance / threshold) * 360}deg)` : undefined,
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
<style>
|
|
95
|
+
{`
|
|
96
|
+
@keyframes spin {
|
|
97
|
+
0% { transform: rotate(0deg); }
|
|
98
|
+
100% { transform: rotate(360deg); }
|
|
99
|
+
}
|
|
100
|
+
`}
|
|
101
|
+
</style>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { safeAreaStyle } from './styles';
|
|
6
|
+
|
|
7
|
+
type ISafeAreaProps = React.HTMLAttributes<HTMLDivElement> &
|
|
8
|
+
VariantProps<typeof safeAreaStyle> & {
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const StyledSafeAreaView = forwardRef<HTMLDivElement, ISafeAreaProps>(
|
|
13
|
+
({ className, children, ...props }, ref) => {
|
|
14
|
+
return (
|
|
15
|
+
<div {...props} ref={ref} className={safeAreaStyle({ class: clsx(className) })}>
|
|
16
|
+
{children}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
StyledSafeAreaView.displayName = 'StyledSafeAreaView';
|
|
23
|
+
|
|
24
|
+
export { StyledSafeAreaView as SafeAreaView };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
|
|
6
|
+
// Styles for scroll containers
|
|
7
|
+
const scrollContainerStyle = tva({
|
|
8
|
+
base: 'overflow-auto',
|
|
9
|
+
variants: {
|
|
10
|
+
horizontal: {
|
|
11
|
+
true: 'overflow-x-auto overflow-y-hidden whitespace-nowrap',
|
|
12
|
+
},
|
|
13
|
+
vertical: {
|
|
14
|
+
true: 'overflow-y-auto overflow-x-hidden',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
type ScrollViewProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
20
|
+
horizontal?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
contentContainerStyle?: React.CSSProperties;
|
|
23
|
+
showsHorizontalScrollIndicator?: boolean;
|
|
24
|
+
showsVerticalScrollIndicator?: boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const ScrollView = forwardRef<HTMLDivElement, ScrollViewProps>(
|
|
28
|
+
(
|
|
29
|
+
{
|
|
30
|
+
horizontal,
|
|
31
|
+
className,
|
|
32
|
+
contentContainerStyle,
|
|
33
|
+
showsHorizontalScrollIndicator = true,
|
|
34
|
+
showsVerticalScrollIndicator = true,
|
|
35
|
+
children,
|
|
36
|
+
style,
|
|
37
|
+
...props
|
|
38
|
+
},
|
|
39
|
+
ref,
|
|
40
|
+
) => {
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
ref={ref}
|
|
44
|
+
className={scrollContainerStyle({
|
|
45
|
+
horizontal,
|
|
46
|
+
vertical: !horizontal,
|
|
47
|
+
class: clsx(className),
|
|
48
|
+
})}
|
|
49
|
+
style={{
|
|
50
|
+
...style,
|
|
51
|
+
overflowX: !showsHorizontalScrollIndicator ? 'hidden' : undefined,
|
|
52
|
+
overflowY: !showsVerticalScrollIndicator ? 'hidden' : undefined,
|
|
53
|
+
}}
|
|
54
|
+
{...props}
|
|
55
|
+
>
|
|
56
|
+
<div style={contentContainerStyle}>{children}</div>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
ScrollView.displayName = 'ScrollView';
|
|
63
|
+
|
|
64
|
+
// FlatList implementation
|
|
65
|
+
type FlatListProps<T> = {
|
|
66
|
+
data: T[];
|
|
67
|
+
renderItem: ({ item, index }: { item: T; index: number }) => React.ReactNode;
|
|
68
|
+
keyExtractor?: (item: T, index: number) => string;
|
|
69
|
+
horizontal?: boolean;
|
|
70
|
+
className?: string;
|
|
71
|
+
contentContainerStyle?: React.CSSProperties;
|
|
72
|
+
showsHorizontalScrollIndicator?: boolean;
|
|
73
|
+
showsVerticalScrollIndicator?: boolean;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export function FlatList<T>({
|
|
77
|
+
data,
|
|
78
|
+
renderItem,
|
|
79
|
+
keyExtractor,
|
|
80
|
+
horizontal,
|
|
81
|
+
className,
|
|
82
|
+
contentContainerStyle,
|
|
83
|
+
showsHorizontalScrollIndicator,
|
|
84
|
+
showsVerticalScrollIndicator,
|
|
85
|
+
...props
|
|
86
|
+
}: FlatListProps<T>) {
|
|
87
|
+
return (
|
|
88
|
+
<ScrollView
|
|
89
|
+
horizontal={horizontal}
|
|
90
|
+
className={className}
|
|
91
|
+
contentContainerStyle={contentContainerStyle}
|
|
92
|
+
showsHorizontalScrollIndicator={showsHorizontalScrollIndicator}
|
|
93
|
+
showsVerticalScrollIndicator={showsVerticalScrollIndicator}
|
|
94
|
+
{...props}
|
|
95
|
+
>
|
|
96
|
+
{data.map((item, index) => (
|
|
97
|
+
<React.Fragment key={keyExtractor ? keyExtractor(item, index) : index}>
|
|
98
|
+
{renderItem({ item, index })}
|
|
99
|
+
</React.Fragment>
|
|
100
|
+
))}
|
|
101
|
+
</ScrollView>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// SectionList implementation
|
|
106
|
+
type SectionListProps<T, S> = {
|
|
107
|
+
sections: Array<{ title: string; data: T[] }>;
|
|
108
|
+
renderItem: ({ item, index }: { item: T; index: number }) => React.ReactNode;
|
|
109
|
+
renderSectionHeader?: ({ section }: { section: { title: string; data: T[] } }) => React.ReactNode;
|
|
110
|
+
keyExtractor?: (item: T, index: number) => string;
|
|
111
|
+
className?: string;
|
|
112
|
+
contentContainerStyle?: React.CSSProperties;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export function SectionList<T, S>({
|
|
116
|
+
sections,
|
|
117
|
+
renderItem,
|
|
118
|
+
renderSectionHeader,
|
|
119
|
+
keyExtractor,
|
|
120
|
+
className,
|
|
121
|
+
contentContainerStyle,
|
|
122
|
+
...props
|
|
123
|
+
}: SectionListProps<T, S>) {
|
|
124
|
+
return (
|
|
125
|
+
<ScrollView className={className} contentContainerStyle={contentContainerStyle} {...props}>
|
|
126
|
+
{sections.map((section, sectionIndex) => (
|
|
127
|
+
<React.Fragment key={`section-${sectionIndex}`}>
|
|
128
|
+
{renderSectionHeader?.({ section })}
|
|
129
|
+
{section.data.map((item, index) => (
|
|
130
|
+
<React.Fragment key={keyExtractor ? keyExtractor(item, index) : index}>
|
|
131
|
+
{renderItem({ item, index })}
|
|
132
|
+
</React.Fragment>
|
|
133
|
+
))}
|
|
134
|
+
</React.Fragment>
|
|
135
|
+
))}
|
|
136
|
+
</ScrollView>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// VirtualizedList is an alias for FlatList in web implementation
|
|
141
|
+
// since we're not implementing actual virtualization in this basic version
|
|
142
|
+
export const VirtualizedList = FlatList;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
|
4
|
+
import { withStyleContext } from '@gluestack-ui/nativewind-utils/withStyleContext';
|
|
5
|
+
import { cssInterop } from 'nativewind';
|
|
6
|
+
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
|
7
|
+
import { ScrollView } from '../scroll-view/index.web';
|
|
8
|
+
|
|
9
|
+
const sectionListStyle = tva({
|
|
10
|
+
base: 'flex flex-col',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const sectionHeaderStyle = tva({
|
|
14
|
+
base: 'font-bold text-lg py-2 bg-gray-100',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
interface SectionBase {
|
|
18
|
+
title: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface SectionListProps<ItemT, SectionT extends SectionBase> {
|
|
22
|
+
sections: ReadonlyArray<SectionT & { data: ReadonlyArray<ItemT> }>;
|
|
23
|
+
renderItem: ({ item, index }: { item: ItemT; index: number }) => React.ReactElement;
|
|
24
|
+
renderSectionHeader?: ({ section }: { section: SectionT }) => React.ReactElement;
|
|
25
|
+
keyExtractor?: (item: ItemT, index: number) => string;
|
|
26
|
+
className?: string;
|
|
27
|
+
contentContainerStyle?: React.CSSProperties;
|
|
28
|
+
onEndReached?: () => void;
|
|
29
|
+
onEndReachedThreshold?: number;
|
|
30
|
+
stickySectionHeadersEnabled?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function SectionListComponent<ItemT, SectionT extends SectionBase>(
|
|
34
|
+
{
|
|
35
|
+
sections,
|
|
36
|
+
renderItem,
|
|
37
|
+
renderSectionHeader,
|
|
38
|
+
keyExtractor,
|
|
39
|
+
className,
|
|
40
|
+
contentContainerStyle,
|
|
41
|
+
onEndReached,
|
|
42
|
+
onEndReachedThreshold = 0.5,
|
|
43
|
+
stickySectionHeadersEnabled = false,
|
|
44
|
+
...props
|
|
45
|
+
}: SectionListProps<ItemT, SectionT>,
|
|
46
|
+
ref: React.Ref<HTMLDivElement>,
|
|
47
|
+
) {
|
|
48
|
+
const handleScroll = (event: React.UIEvent<HTMLDivElement>) => {
|
|
49
|
+
if (!onEndReached) return;
|
|
50
|
+
|
|
51
|
+
const target = event.target as HTMLDivElement;
|
|
52
|
+
const scrollPosition = target.scrollTop + target.clientHeight;
|
|
53
|
+
const scrollSize = target.scrollHeight;
|
|
54
|
+
const threshold = scrollSize * onEndReachedThreshold;
|
|
55
|
+
|
|
56
|
+
if (scrollSize - scrollPosition <= threshold) {
|
|
57
|
+
onEndReached();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const defaultSectionHeader = (section: SectionT) => <div className={sectionHeaderStyle()}>{section.title}</div>;
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<ScrollView ref={ref} className={className} onScroll={handleScroll} {...props}>
|
|
65
|
+
<div className={sectionListStyle()} style={contentContainerStyle}>
|
|
66
|
+
{sections.map((section, sectionIndex) => (
|
|
67
|
+
<div key={`section-${sectionIndex}`}>
|
|
68
|
+
<div
|
|
69
|
+
style={{
|
|
70
|
+
position: stickySectionHeadersEnabled ? 'sticky' : 'relative',
|
|
71
|
+
top: stickySectionHeadersEnabled ? 0 : undefined,
|
|
72
|
+
zIndex: stickySectionHeadersEnabled ? 1 : undefined,
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
{renderSectionHeader ? renderSectionHeader({ section }) : defaultSectionHeader(section)}
|
|
76
|
+
</div>
|
|
77
|
+
{section.data.map((item, index) => (
|
|
78
|
+
<React.Fragment key={keyExtractor ? keyExtractor(item, index) : `${sectionIndex}-${index}`}>
|
|
79
|
+
{renderItem({ item, index })}
|
|
80
|
+
</React.Fragment>
|
|
81
|
+
))}
|
|
82
|
+
</div>
|
|
83
|
+
))}
|
|
84
|
+
</div>
|
|
85
|
+
</ScrollView>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const SectionList = React.forwardRef(SectionListComponent) as <ItemT, SectionT extends SectionBase>(
|
|
90
|
+
props: SectionListProps<ItemT, SectionT> & { ref?: React.Ref<HTMLDivElement> },
|
|
91
|
+
) => React.ReactElement;
|
|
92
|
+
|
|
93
|
+
export { SectionList };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { createSelect } from '@gluestack-ui/select';
|
|
4
|
+
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
|
5
|
+
import { withStyleContext } from '@gluestack-ui/nativewind-utils/withStyleContext';
|
|
6
|
+
import { cssInterop } from 'nativewind';
|
|
7
|
+
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
|
8
|
+
|
|
9
|
+
const SCOPE = 'SELECT';
|
|
10
|
+
|
|
11
|
+
const StyledSelect = forwardRef<HTMLSelectElement, any>(
|
|
12
|
+
({ onValueChange, onChange, placeholder, children, ...props }, ref) => {
|
|
13
|
+
const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
14
|
+
if (onChange) {
|
|
15
|
+
onChange(e);
|
|
16
|
+
}
|
|
17
|
+
if (onValueChange) {
|
|
18
|
+
onValueChange(e.target.value);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<select ref={ref} onChange={handleChange} {...props}>
|
|
24
|
+
{placeholder && (
|
|
25
|
+
<option value="" disabled>
|
|
26
|
+
{placeholder}
|
|
27
|
+
</option>
|
|
28
|
+
)}
|
|
29
|
+
{children}
|
|
30
|
+
</select>
|
|
31
|
+
);
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
StyledSelect.displayName = 'StyledSelect';
|
|
36
|
+
|
|
37
|
+
const selectStyle = tva({
|
|
38
|
+
base: 'px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent appearance-none bg-white',
|
|
39
|
+
variants: {
|
|
40
|
+
size: {
|
|
41
|
+
sm: 'text-sm h-8',
|
|
42
|
+
md: 'text-base h-10',
|
|
43
|
+
lg: 'text-lg h-12',
|
|
44
|
+
},
|
|
45
|
+
variant: {
|
|
46
|
+
outline: 'bg-transparent',
|
|
47
|
+
filled: 'bg-gray-100',
|
|
48
|
+
unstyled: '',
|
|
49
|
+
},
|
|
50
|
+
state: {
|
|
51
|
+
error: 'border-red-500 focus:ring-red-500',
|
|
52
|
+
success: 'border-green-500 focus:ring-green-500',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
defaultVariants: {
|
|
56
|
+
size: 'md',
|
|
57
|
+
variant: 'outline',
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const SelectOption = forwardRef<HTMLOptionElement, React.ComponentProps<'option'>>((props, ref) => {
|
|
62
|
+
return <option ref={ref} {...props} />;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
SelectOption.displayName = 'SelectOption';
|
|
66
|
+
|
|
67
|
+
type ISelectProps = React.ComponentProps<typeof StyledSelect> &
|
|
68
|
+
VariantProps<typeof selectStyle> & {
|
|
69
|
+
className?: string;
|
|
70
|
+
onValueChange?: (value: string) => void;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const Select = React.forwardRef<HTMLSelectElement, ISelectProps>(
|
|
74
|
+
({ className, size, variant, state, ...props }, ref) => {
|
|
75
|
+
return (
|
|
76
|
+
<StyledSelect ref={ref} className={selectStyle({ size, variant, state, class: className })} {...props} />
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
Select.displayName = 'Select';
|
|
82
|
+
|
|
83
|
+
export { Select };
|