@admin-layout/gluestack-ui-mobile 10.0.9-alpha.9 → 10.1.1-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/CHANGELOG.md +2 -6
  2. package/lib/components/ui/accordion/index.web.d.ts +209 -0
  3. package/lib/components/ui/accordion/index.web.js +156 -0
  4. package/lib/components/ui/accordion/index.web.js.map +1 -0
  5. package/lib/components/ui/actionsheet/index.web.d.ts +872 -0
  6. package/lib/components/ui/actionsheet/index.web.js +286 -0
  7. package/lib/components/ui/actionsheet/index.web.js.map +1 -0
  8. package/lib/components/ui/alert/index.web.d.ts +135 -0
  9. package/lib/components/ui/alert/index.web.js +38 -0
  10. package/lib/components/ui/alert/index.web.js.map +1 -0
  11. package/lib/components/ui/alert-dialog/index.web.d.ts +64 -0
  12. package/lib/components/ui/alert-dialog/index.web.js +139 -0
  13. package/lib/components/ui/alert-dialog/index.web.js.map +1 -0
  14. package/lib/components/ui/avatar/index.web.d.ts +21 -0
  15. package/lib/components/ui/avatar/index.web.js +92 -0
  16. package/lib/components/ui/avatar/index.web.js.map +1 -0
  17. package/lib/components/ui/badge/index.web.d.ts +382 -0
  18. package/lib/components/ui/badge/index.web.js +138 -0
  19. package/lib/components/ui/badge/index.web.js.map +1 -0
  20. package/lib/components/ui/button/index.web.d.ts +247 -0
  21. package/lib/components/ui/button/index.web.js +57 -0
  22. package/lib/components/ui/button/index.web.js.map +1 -0
  23. package/lib/components/ui/checkbox/index.web.d.ts +265 -0
  24. package/lib/components/ui/checkbox/index.web.js +77 -0
  25. package/lib/components/ui/checkbox/index.web.js.map +1 -0
  26. package/lib/components/ui/divider/index.web.d.ts +53 -0
  27. package/lib/components/ui/divider/index.web.js +21 -0
  28. package/lib/components/ui/divider/index.web.js.map +1 -0
  29. package/lib/components/ui/drawer/index.web.d.ts +174 -0
  30. package/lib/components/ui/drawer/index.web.js +65 -0
  31. package/lib/components/ui/drawer/index.web.js.map +1 -0
  32. package/lib/components/ui/fab/index.web.d.ts +520 -0
  33. package/lib/components/ui/fab/index.web.js +146 -0
  34. package/lib/components/ui/fab/index.web.js.map +1 -0
  35. package/lib/components/ui/flat-list/index.web.d.ts +21 -0
  36. package/lib/components/ui/flat-list/index.web.js +41 -0
  37. package/lib/components/ui/flat-list/index.web.js.map +1 -0
  38. package/lib/components/ui/form-control/index.web.d.ts +2071 -0
  39. package/lib/components/ui/form-control/index.web.js +290 -0
  40. package/lib/components/ui/form-control/index.web.js.map +1 -0
  41. package/lib/components/ui/image/index.web.d.ts +142 -0
  42. package/lib/components/ui/image/index.web.js +29 -0
  43. package/lib/components/ui/image/index.web.js.map +1 -0
  44. package/lib/components/ui/image-background/index.web.d.ts +8 -0
  45. package/lib/components/ui/image-background/index.web.js +23 -0
  46. package/lib/components/ui/image-background/index.web.js.map +1 -0
  47. package/lib/components/ui/input/index.web.d.ts +163 -0
  48. package/lib/components/ui/input/index.web.js +50 -0
  49. package/lib/components/ui/input/index.web.js.map +1 -0
  50. package/lib/components/ui/input-accessory-view/index.web.d.ts +9 -0
  51. package/lib/components/ui/input-accessory-view/index.web.js +16 -0
  52. package/lib/components/ui/input-accessory-view/index.web.js.map +1 -0
  53. package/lib/components/ui/keyboard-avoiding-view/index.web.d.ts +9 -0
  54. package/lib/components/ui/keyboard-avoiding-view/index.web.js +8 -0
  55. package/lib/components/ui/keyboard-avoiding-view/index.web.js.map +1 -0
  56. package/lib/components/ui/link/index.web.d.ts +365 -0
  57. package/lib/components/ui/link/index.web.js +70 -0
  58. package/lib/components/ui/link/index.web.js.map +1 -0
  59. package/lib/components/ui/menu/index.web.d.ts +142 -0
  60. package/lib/components/ui/menu/index.web.js +83 -0
  61. package/lib/components/ui/menu/index.web.js.map +1 -0
  62. package/lib/components/ui/modal/index.web.d.ts +111 -0
  63. package/lib/components/ui/modal/index.web.js +58 -0
  64. package/lib/components/ui/modal/index.web.js.map +1 -0
  65. package/lib/components/ui/popover/index.web.d.ts +309 -0
  66. package/lib/components/ui/popover/index.web.js +184 -0
  67. package/lib/components/ui/popover/index.web.js.map +1 -0
  68. package/lib/components/ui/portal/index.web.d.ts +9 -0
  69. package/lib/components/ui/portal/index.web.js +16 -0
  70. package/lib/components/ui/portal/index.web.js.map +1 -0
  71. package/lib/components/ui/pressable/index.web.d.ts +8 -0
  72. package/lib/components/ui/pressable/index.web.js +44 -0
  73. package/lib/components/ui/pressable/index.web.js.map +1 -0
  74. package/lib/components/ui/progress/index.web.d.ts +237 -0
  75. package/lib/components/ui/progress/index.web.js +73 -0
  76. package/lib/components/ui/progress/index.web.js.map +1 -0
  77. package/lib/components/ui/radio/index.web.d.ts +224 -0
  78. package/lib/components/ui/radio/index.web.js +69 -0
  79. package/lib/components/ui/radio/index.web.js.map +1 -0
  80. package/lib/components/ui/refresh-control/index.web.d.ts +14 -0
  81. package/lib/components/ui/refresh-control/index.web.js +69 -0
  82. package/lib/components/ui/refresh-control/index.web.js.map +1 -0
  83. package/lib/components/ui/safe-area-view/index.web.d.ts +6 -0
  84. package/lib/components/ui/safe-area-view/index.web.js +10 -0
  85. package/lib/components/ui/safe-area-view/index.web.js.map +1 -0
  86. package/lib/components/ui/scroll-view/index.web.d.ts +44 -0
  87. package/lib/components/ui/scroll-view/index.web.js +41 -0
  88. package/lib/components/ui/scroll-view/index.web.js.map +1 -0
  89. package/lib/components/ui/section-list/index.web.d.ts +26 -0
  90. package/lib/components/ui/section-list/index.web.js +35 -0
  91. package/lib/components/ui/section-list/index.web.js.map +1 -0
  92. package/lib/components/ui/select/index.web.d.ts +162 -0
  93. package/lib/components/ui/select/index.web.js +51 -0
  94. package/lib/components/ui/select/index.web.js.map +1 -0
  95. package/lib/components/ui/slider/index.web.d.ts +223 -0
  96. package/lib/components/ui/slider/index.web.js +189 -0
  97. package/lib/components/ui/slider/index.web.js.map +1 -0
  98. package/lib/components/ui/spinner/index.web.d.ts +176 -0
  99. package/lib/components/ui/spinner/index.web.js +55 -0
  100. package/lib/components/ui/spinner/index.web.js.map +1 -0
  101. package/lib/components/ui/status-bar/index.web.d.ts +14 -0
  102. package/lib/components/ui/status-bar/index.web.js +7 -0
  103. package/lib/components/ui/status-bar/index.web.js.map +1 -0
  104. package/lib/components/ui/switch/index.web.d.ts +71 -0
  105. package/lib/components/ui/switch/index.web.js +27 -0
  106. package/lib/components/ui/switch/index.web.js.map +1 -0
  107. package/lib/components/ui/tabs/index.web.d.ts +351 -0
  108. package/lib/components/ui/tabs/index.web.js +120 -0
  109. package/lib/components/ui/tabs/index.web.js.map +1 -0
  110. package/lib/components/ui/textarea/index.web.d.ts +162 -0
  111. package/lib/components/ui/textarea/index.web.js +50 -0
  112. package/lib/components/ui/textarea/index.web.js.map +1 -0
  113. package/lib/components/ui/toast/index.web.d.ts +225 -0
  114. package/lib/components/ui/toast/index.web.js +80 -0
  115. package/lib/components/ui/toast/index.web.js.map +1 -0
  116. package/lib/components/ui/tooltip/index.web.d.ts +86 -0
  117. package/lib/components/ui/tooltip/index.web.js +110 -0
  118. package/lib/components/ui/tooltip/index.web.js.map +1 -0
  119. package/lib/components/ui/view/index.web.d.ts +2 -0
  120. package/lib/components/ui/view/index.web.js +7 -0
  121. package/lib/components/ui/view/index.web.js.map +1 -0
  122. package/lib/components/ui/virtualized-list/index.web.d.ts +19 -0
  123. package/lib/components/ui/virtualized-list/index.web.js +30 -0
  124. package/lib/components/ui/virtualized-list/index.web.js.map +1 -0
  125. package/lib/components/usePermissionAutoFetch.d.ts +7 -19
  126. package/lib/containers/layout/DrawerBottomNavigationConfig.d.ts +47 -47
  127. package/lib/containers/layout/DrawerConfig.d.ts +31 -31
  128. package/lib/redux/settings.d.ts +3 -9
  129. package/package.json +9 -5
  130. package/src/components/ui/accordion/index.web.tsx +294 -0
  131. package/src/components/ui/actionsheet/index.web.tsx +555 -0
  132. package/src/components/ui/alert/index.web.tsx +71 -0
  133. package/src/components/ui/alert-dialog/index.web.tsx +241 -0
  134. package/src/components/ui/avatar/index.web.tsx +150 -0
  135. package/src/components/ui/badge/index.web.tsx +188 -0
  136. package/src/components/ui/button/index.web.tsx +86 -0
  137. package/src/components/ui/checkbox/index.web.tsx +151 -0
  138. package/src/components/ui/divider/index.web.tsx +37 -0
  139. package/src/components/ui/drawer/index.web.tsx +144 -0
  140. package/src/components/ui/fab/index.web.tsx +201 -0
  141. package/src/components/ui/flat-list/index.web.tsx +89 -0
  142. package/src/components/ui/form-control/index.web.tsx +451 -0
  143. package/src/components/ui/image/index.web.tsx +43 -0
  144. package/src/components/ui/image-background/index.web.tsx +43 -0
  145. package/src/components/ui/input/index.web.tsx +80 -0
  146. package/src/components/ui/input-accessory-view/index.web.tsx +31 -0
  147. package/src/components/ui/keyboard-avoiding-view/index.web.tsx +23 -0
  148. package/src/components/ui/link/index.web.tsx +103 -0
  149. package/src/components/ui/menu/index.web.tsx +159 -0
  150. package/src/components/ui/modal/index.web.tsx +135 -0
  151. package/src/components/ui/popover/index.web.tsx +326 -0
  152. package/src/components/ui/portal/index.web.tsx +34 -0
  153. package/src/components/ui/pressable/index.web.tsx +73 -0
  154. package/src/components/ui/progress/index.web.tsx +123 -0
  155. package/src/components/ui/radio/index.web.tsx +130 -0
  156. package/src/components/ui/refresh-control/index.web.tsx +104 -0
  157. package/src/components/ui/safe-area-view/index.web.tsx +24 -0
  158. package/src/components/ui/scroll-view/index.web.tsx +142 -0
  159. package/src/components/ui/section-list/index.web.tsx +93 -0
  160. package/src/components/ui/select/index.web.tsx +83 -0
  161. package/src/components/ui/slider/index.web.tsx +283 -0
  162. package/src/components/ui/spinner/index.web.tsx +81 -0
  163. package/src/components/ui/status-bar/index.web.tsx +20 -0
  164. package/src/components/ui/switch/index.web.tsx +44 -0
  165. package/src/components/ui/tabs/index.web.tsx +205 -0
  166. package/src/components/ui/textarea/index.web.tsx +86 -0
  167. package/src/components/ui/toast/index.web.tsx +132 -0
  168. package/src/components/ui/tooltip/index.web.tsx +155 -0
  169. package/src/components/ui/view/index.web.tsx +15 -0
  170. package/src/components/ui/virtualized-list/index.web.tsx +84 -0
@@ -0,0 +1,86 @@
1
+ 'use client';
2
+ import React, { forwardRef } from 'react';
3
+ import { createTextarea } from '@gluestack-ui/textarea';
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 = 'TEXTAREA';
10
+
11
+ const StyledTextarea = forwardRef<HTMLTextAreaElement, any>(
12
+ ({ onChangeText, onChange, placeholder, placeholderTextColor, ...props }, ref) => {
13
+ const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
14
+ if (onChange) {
15
+ onChange(e);
16
+ }
17
+ if (onChangeText) {
18
+ onChangeText(e.target.value);
19
+ }
20
+ };
21
+
22
+ return (
23
+ <textarea
24
+ ref={ref}
25
+ placeholder={placeholder}
26
+ onChange={handleChange}
27
+ style={{
28
+ ...props.style,
29
+ '::placeholder': {
30
+ color: placeholderTextColor,
31
+ },
32
+ }}
33
+ {...props}
34
+ />
35
+ );
36
+ },
37
+ );
38
+
39
+ StyledTextarea.displayName = 'StyledTextarea';
40
+
41
+ const textareaStyle = tva({
42
+ base: 'px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent',
43
+ variants: {
44
+ size: {
45
+ sm: 'text-sm min-h-[80px]',
46
+ md: 'text-base min-h-[100px]',
47
+ lg: 'text-lg min-h-[120px]',
48
+ },
49
+ variant: {
50
+ outline: 'bg-transparent',
51
+ filled: 'bg-gray-100',
52
+ unstyled: '',
53
+ },
54
+ state: {
55
+ error: 'border-red-500 focus:ring-red-500',
56
+ success: 'border-green-500 focus:ring-green-500',
57
+ },
58
+ },
59
+ defaultVariants: {
60
+ size: 'md',
61
+ variant: 'outline',
62
+ },
63
+ });
64
+
65
+ type ITextareaProps = React.ComponentProps<typeof StyledTextarea> &
66
+ VariantProps<typeof textareaStyle> & {
67
+ className?: string;
68
+ onChangeText?: (text: string) => void;
69
+ placeholderTextColor?: string;
70
+ };
71
+
72
+ const Textarea = React.forwardRef<HTMLTextAreaElement, ITextareaProps>(
73
+ ({ className, size, variant, state, ...props }, ref) => {
74
+ return (
75
+ <StyledTextarea
76
+ ref={ref}
77
+ className={textareaStyle({ size, variant, state, class: className })}
78
+ {...props}
79
+ />
80
+ );
81
+ },
82
+ );
83
+
84
+ Textarea.displayName = 'Textarea';
85
+
86
+ export { Textarea };
@@ -0,0 +1,132 @@
1
+ 'use client';
2
+ import React, { forwardRef, useEffect, useState } from 'react';
3
+ import { createToast } from '@gluestack-ui/toast';
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
+ import { createPortal } from 'react-dom';
9
+
10
+ const SCOPE = 'TOAST';
11
+
12
+ const toastStyle = tva({
13
+ base: 'fixed flex items-center p-4 mb-4 rounded-lg shadow-lg transition-all duration-300 ease-in-out',
14
+ variants: {
15
+ variant: {
16
+ solid: 'bg-gray-800 text-white',
17
+ outline: 'bg-white border border-gray-300',
18
+ accent: 'border-l-4 border-blue-500 bg-white',
19
+ },
20
+ position: {
21
+ top: 'top-4 left-1/2 -translate-x-1/2',
22
+ 'top-right': 'top-4 right-4',
23
+ 'top-left': 'top-4 left-4',
24
+ bottom: 'bottom-4 left-1/2 -translate-x-1/2',
25
+ 'bottom-right': 'bottom-4 right-4',
26
+ 'bottom-left': 'bottom-4 left-4',
27
+ },
28
+ status: {
29
+ info: 'bg-blue-500 text-white',
30
+ success: 'bg-green-500 text-white',
31
+ warning: 'bg-yellow-500 text-white',
32
+ error: 'bg-red-500 text-white',
33
+ },
34
+ },
35
+ defaultVariants: {
36
+ variant: 'solid',
37
+ position: 'bottom',
38
+ status: 'info',
39
+ },
40
+ });
41
+
42
+ export const ToastTitle = forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(({ className, ...props }, ref) => (
43
+ <div ref={ref} className={`font-semibold ${className || ''}`} {...props} />
44
+ ));
45
+
46
+ ToastTitle.displayName = 'ToastTitle';
47
+
48
+ export const ToastDescription = forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
49
+ ({ className, ...props }, ref) => <div ref={ref} className={`mt-1 ${className || ''}`} {...props} />,
50
+ );
51
+
52
+ ToastDescription.displayName = 'ToastDescription';
53
+
54
+ type IToastProps = {
55
+ id?: string;
56
+ title?: string;
57
+ description?: string;
58
+ duration?: number;
59
+ onClose?: () => void;
60
+ isOpen?: boolean;
61
+ className?: string;
62
+ variant?: VariantProps<typeof toastStyle>['variant'];
63
+ position?: VariantProps<typeof toastStyle>['position'];
64
+ status?: VariantProps<typeof toastStyle>['status'];
65
+ };
66
+
67
+ const Toast = forwardRef<HTMLDivElement, IToastProps>(
68
+ (
69
+ { id, title, description, duration = 5000, onClose, isOpen, className, variant, position, status, ...props },
70
+ ref,
71
+ ) => {
72
+ const [isVisible, setIsVisible] = useState(isOpen);
73
+ const [isExiting, setIsExiting] = useState(false);
74
+
75
+ useEffect(() => {
76
+ setIsVisible(isOpen);
77
+ if (isOpen) {
78
+ const timer = setTimeout(() => {
79
+ setIsExiting(true);
80
+ setTimeout(() => {
81
+ setIsVisible(false);
82
+ setIsExiting(false);
83
+ if (onClose) onClose();
84
+ }, 300);
85
+ }, duration);
86
+
87
+ return () => clearTimeout(timer);
88
+ }
89
+ }, [isOpen, duration, onClose]);
90
+
91
+ if (!isVisible) return null;
92
+
93
+ return createPortal(
94
+ <div
95
+ ref={ref}
96
+ role="alert"
97
+ aria-live="polite"
98
+ className={toastStyle({
99
+ variant,
100
+ position,
101
+ status,
102
+ class: `${className || ''} ${isExiting ? 'opacity-0' : 'opacity-100'}`,
103
+ })}
104
+ {...props}
105
+ >
106
+ <div>
107
+ {title && <ToastTitle>{title}</ToastTitle>}
108
+ {description && <ToastDescription>{description}</ToastDescription>}
109
+ </div>
110
+ <button
111
+ onClick={() => {
112
+ setIsExiting(true);
113
+ setTimeout(() => {
114
+ setIsVisible(false);
115
+ setIsExiting(false);
116
+ if (onClose) onClose();
117
+ }, 300);
118
+ }}
119
+ className="ml-4 text-current opacity-70 hover:opacity-100"
120
+ aria-label="Close toast"
121
+ >
122
+ ×
123
+ </button>
124
+ </div>,
125
+ document.body,
126
+ );
127
+ },
128
+ );
129
+
130
+ Toast.displayName = 'Toast';
131
+
132
+ export { Toast };
@@ -0,0 +1,155 @@
1
+ 'use client';
2
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
3
+ import { createTooltip } from '@gluestack-ui/tooltip';
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
+ import { createPortal } from 'react-dom';
9
+
10
+ const SCOPE = 'TOOLTIP';
11
+
12
+ const tooltipStyle = tva({
13
+ base: 'absolute z-50 px-3 py-2 text-sm text-white bg-gray-900 rounded-md shadow-sm max-w-xs',
14
+ variants: {
15
+ placement: {
16
+ top: 'bottom-full mb-2',
17
+ bottom: 'top-full mt-2',
18
+ left: 'right-full mr-2',
19
+ right: 'left-full ml-2',
20
+ },
21
+ },
22
+ defaultVariants: {
23
+ placement: 'top',
24
+ },
25
+ });
26
+
27
+ type ITooltipProps = {
28
+ label: string;
29
+ children: React.ReactElement;
30
+ placement?: VariantProps<typeof tooltipStyle>['placement'];
31
+ className?: string;
32
+ delay?: number;
33
+ isOpen?: boolean;
34
+ onOpen?: () => void;
35
+ onClose?: () => void;
36
+ };
37
+
38
+ const Tooltip = forwardRef<HTMLDivElement, ITooltipProps>(
39
+ (
40
+ { label, children, placement, className, delay = 0, isOpen: controlledIsOpen, onOpen, onClose, ...props },
41
+ ref,
42
+ ) => {
43
+ const [isOpen, setIsOpen] = useState(controlledIsOpen || false);
44
+ const [position, setPosition] = useState({ top: 0, left: 0 });
45
+ const triggerRef = useRef<HTMLDivElement>(null);
46
+ const tooltipRef = useRef<HTMLDivElement>(null);
47
+ const timeoutRef = useRef<NodeJS.Timeout>();
48
+
49
+ const updatePosition = () => {
50
+ if (triggerRef.current && tooltipRef.current) {
51
+ const triggerRect = triggerRef.current.getBoundingClientRect();
52
+ const tooltipRect = tooltipRef.current.getBoundingClientRect();
53
+ let top = 0;
54
+ let left = 0;
55
+
56
+ switch (placement) {
57
+ case 'top':
58
+ top = triggerRect.top - tooltipRect.height - 8;
59
+ left = triggerRect.left + (triggerRect.width - tooltipRect.width) / 2;
60
+ break;
61
+ case 'bottom':
62
+ top = triggerRect.bottom + 8;
63
+ left = triggerRect.left + (triggerRect.width - tooltipRect.width) / 2;
64
+ break;
65
+ case 'left':
66
+ top = triggerRect.top + (triggerRect.height - tooltipRect.height) / 2;
67
+ left = triggerRect.left - tooltipRect.width - 8;
68
+ break;
69
+ case 'right':
70
+ top = triggerRect.top + (triggerRect.height - tooltipRect.height) / 2;
71
+ left = triggerRect.right + 8;
72
+ break;
73
+ }
74
+
75
+ setPosition({ top, left });
76
+ }
77
+ };
78
+
79
+ const handleOpen = () => {
80
+ if (delay) {
81
+ timeoutRef.current = setTimeout(() => {
82
+ setIsOpen(true);
83
+ if (onOpen) onOpen();
84
+ }, delay);
85
+ } else {
86
+ setIsOpen(true);
87
+ if (onOpen) onOpen();
88
+ }
89
+ };
90
+
91
+ const handleClose = () => {
92
+ if (timeoutRef.current) {
93
+ clearTimeout(timeoutRef.current);
94
+ }
95
+ setIsOpen(false);
96
+ if (onClose) onClose();
97
+ };
98
+
99
+ useEffect(() => {
100
+ if (controlledIsOpen !== undefined) {
101
+ setIsOpen(controlledIsOpen);
102
+ }
103
+ }, [controlledIsOpen]);
104
+
105
+ useEffect(() => {
106
+ if (isOpen) {
107
+ updatePosition();
108
+ window.addEventListener('scroll', updatePosition);
109
+ window.addEventListener('resize', updatePosition);
110
+ }
111
+
112
+ return () => {
113
+ window.removeEventListener('scroll', updatePosition);
114
+ window.removeEventListener('resize', updatePosition);
115
+ };
116
+ }, [isOpen]);
117
+
118
+ const trigger = React.cloneElement(children, {
119
+ ref: triggerRef,
120
+ onMouseEnter: handleOpen,
121
+ onMouseLeave: handleClose,
122
+ onFocus: handleOpen,
123
+ onBlur: handleClose,
124
+ 'aria-describedby': isOpen ? 'tooltip' : undefined,
125
+ });
126
+
127
+ return (
128
+ <>
129
+ {trigger}
130
+ {isOpen &&
131
+ createPortal(
132
+ <div
133
+ ref={tooltipRef}
134
+ id="tooltip"
135
+ role="tooltip"
136
+ className={tooltipStyle({ placement, class: className })}
137
+ style={{
138
+ position: 'fixed',
139
+ top: `${position.top}px`,
140
+ left: `${position.left}px`,
141
+ }}
142
+ {...props}
143
+ >
144
+ {label}
145
+ </div>,
146
+ document.body,
147
+ )}
148
+ </>
149
+ );
150
+ },
151
+ );
152
+
153
+ Tooltip.displayName = 'Tooltip';
154
+
155
+ export { Tooltip };
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+
5
+ export const View = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
6
+ ({ children, style, ...props }, ref) => {
7
+ return (
8
+ <div ref={ref} style={style} {...props}>
9
+ {children}
10
+ </div>
11
+ );
12
+ },
13
+ );
14
+
15
+ View.displayName = 'View';
@@ -0,0 +1,84 @@
1
+ 'use client';
2
+ import React, { forwardRef } from 'react';
3
+ import { FixedSizeList, ListChildComponentProps } from 'react-window';
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 virtualizedListStyle = tva({
10
+ base: 'overflow-auto',
11
+ variants: {
12
+ horizontal: {
13
+ true: 'flex-row',
14
+ false: 'flex-col',
15
+ },
16
+ },
17
+ defaultVariants: {
18
+ horizontal: false,
19
+ },
20
+ });
21
+
22
+ interface VirtualizedListProps<T> {
23
+ data: ReadonlyArray<T>;
24
+ renderItem: ({ item, index }: { item: T; index: number }) => React.ReactElement;
25
+ itemSize: number;
26
+ horizontal?: boolean;
27
+ className?: string;
28
+ height: number;
29
+ width: number;
30
+ overscanCount?: number;
31
+ }
32
+
33
+ interface ItemData<T> {
34
+ data: ReadonlyArray<T>;
35
+ renderItem: ({ item, index }: { item: T; index: number }) => React.ReactElement;
36
+ }
37
+
38
+ function VirtualizedListComponent<T>(
39
+ {
40
+ data,
41
+ renderItem,
42
+ itemSize,
43
+ horizontal = false,
44
+ className,
45
+ height,
46
+ width,
47
+ overscanCount = 2,
48
+ ...props
49
+ }: VirtualizedListProps<T>,
50
+ ref: React.Ref<FixedSizeList>,
51
+ ) {
52
+ const itemData: ItemData<T> = {
53
+ data,
54
+ renderItem,
55
+ };
56
+
57
+ const Row = ({ index, style }: ListChildComponentProps) => {
58
+ const item = data[index];
59
+ return <div style={style}>{renderItem({ item, index })}</div>;
60
+ };
61
+
62
+ return (
63
+ <FixedSizeList
64
+ outerRef={ref}
65
+ className={virtualizedListStyle({ horizontal, class: className })}
66
+ height={height}
67
+ width={width}
68
+ itemCount={data.length}
69
+ itemSize={itemSize}
70
+ layout={horizontal ? 'horizontal' : 'vertical'}
71
+ overscanCount={overscanCount}
72
+ itemData={itemData}
73
+ {...props}
74
+ >
75
+ {Row}
76
+ </FixedSizeList>
77
+ );
78
+ }
79
+
80
+ const VirtualizedList = React.forwardRef(VirtualizedListComponent) as <T>(
81
+ props: VirtualizedListProps<T> & { ref?: React.Ref<FixedSizeList> },
82
+ ) => React.ReactElement;
83
+
84
+ export { VirtualizedList };