@flipova/foundation 2.3.0 → 2.4.0-beta.1

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 (98) hide show
  1. package/README.md +157 -156
  2. package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +16 -7
  3. package/components/ui/accordion/AccordionAnimatedHeight.tsx +3 -15
  4. package/components/ui/accordion/AccordionAnimatedIcon.tsx +2 -9
  5. package/components/ui/accordion/AnimatedHeight.tsx +3 -15
  6. package/components/ui/accordion/AnimatedIcon.tsx +2 -9
  7. package/components/ui/accordion/MIGRATION_SUMMARY.md +22 -11
  8. package/components/ui/accordion/USAGE_EXAMPLE.tsx +10 -25
  9. package/components/ui/accordion/index.tsx +71 -139
  10. package/components/ui/actionsheet/index.tsx +63 -105
  11. package/components/ui/alert/index.tsx +20 -50
  12. package/components/ui/alert-dialog/index.tsx +23 -48
  13. package/components/ui/avatar/index.tsx +32 -68
  14. package/components/ui/badge/index.tsx +18 -49
  15. package/components/ui/bottomsheet/index.tsx +20 -52
  16. package/components/ui/box/index.tsx +4 -9
  17. package/components/ui/box/index.web.tsx +3 -9
  18. package/components/ui/button/index.tsx +73 -109
  19. package/components/ui/calendar/creator.tsx +69 -30
  20. package/components/ui/calendar/index.tsx +81 -159
  21. package/components/ui/calendar/styles.tsx +10 -10
  22. package/components/ui/card/index.tsx +8 -9
  23. package/components/ui/card/index.web.tsx +4 -10
  24. package/components/ui/center/index.tsx +6 -11
  25. package/components/ui/center/index.web.tsx +3 -9
  26. package/components/ui/checkbox/index.tsx +46 -107
  27. package/components/ui/date-time-picker/creator.tsx +14 -1
  28. package/components/ui/date-time-picker/index.tsx +107 -156
  29. package/components/ui/date-time-picker/index.web.tsx +11 -33
  30. package/components/ui/date-time-picker/styles.tsx +5 -5
  31. package/components/ui/divider/index.tsx +5 -6
  32. package/components/ui/drawer/index.tsx +108 -128
  33. package/components/ui/fab/index.tsx +25 -68
  34. package/components/ui/flat-list/index.tsx +11 -8
  35. package/components/ui/form-control/index.tsx +49 -90
  36. package/components/ui/gluestack-ui-provider/index.tsx +4 -18
  37. package/components/ui/gluestack-ui-provider/index.web.tsx +10 -11
  38. package/components/ui/gluestack-ui-provider/script.ts +1 -3
  39. package/components/ui/gluestack-ui-provider/theme-context.ts +2 -2
  40. package/components/ui/gluestack-ui-provider/useGluestackColors.ts +2 -6
  41. package/components/ui/grid/index.tsx +128 -165
  42. package/components/ui/grid/index.web.tsx +17 -19
  43. package/components/ui/grid/styles.tsx +1 -3
  44. package/components/ui/heading/index.tsx +146 -169
  45. package/components/ui/heading/index.web.tsx +7 -28
  46. package/components/ui/heading/styles.tsx +5 -5
  47. package/components/ui/hstack/index.tsx +16 -15
  48. package/components/ui/hstack/index.web.tsx +17 -17
  49. package/components/ui/hstack/styles.tsx +5 -5
  50. package/components/ui/icon/index.tsx +95 -486
  51. package/components/ui/icon/index.web.tsx +79 -439
  52. package/components/ui/image/index.tsx +13 -18
  53. package/components/ui/image-viewer/index.tsx +149 -221
  54. package/components/ui/image-viewer/index.web.tsx +88 -113
  55. package/components/ui/input/index.tsx +20 -33
  56. package/components/ui/link/index.tsx +16 -22
  57. package/components/ui/liquid-glass/index.tsx +19 -25
  58. package/components/ui/menu/index.tsx +44 -66
  59. package/components/ui/modal/index.tsx +70 -91
  60. package/components/ui/popover/index.tsx +102 -121
  61. package/components/ui/portal/index.tsx +5 -6
  62. package/components/ui/pressable/index.tsx +5 -9
  63. package/components/ui/progress/index.tsx +4 -11
  64. package/components/ui/radio/index.tsx +47 -83
  65. package/components/ui/select/index.tsx +38 -59
  66. package/components/ui/select/select-actionsheet.tsx +61 -108
  67. package/components/ui/skeleton/index.tsx +22 -43
  68. package/components/ui/skeleton/index.web.tsx +63 -75
  69. package/components/ui/slider/index.tsx +36 -56
  70. package/components/ui/spinner/index.tsx +1 -10
  71. package/components/ui/switch/index.tsx +6 -13
  72. package/components/ui/table/index.tsx +39 -102
  73. package/components/ui/table/index.web.tsx +41 -79
  74. package/components/ui/tabs/TabsAnimatedIndicator.tsx +10 -38
  75. package/components/ui/tabs/creator.tsx +32 -24
  76. package/components/ui/tabs/index.tsx +253 -309
  77. package/components/ui/text/index.tsx +23 -37
  78. package/components/ui/text/index.web.tsx +33 -35
  79. package/components/ui/text/styles.tsx +5 -5
  80. package/components/ui/textarea/index.tsx +24 -38
  81. package/components/ui/toast/index.tsx +47 -52
  82. package/components/ui/tooltip/index.tsx +12 -28
  83. package/components/ui/vstack/index.tsx +17 -17
  84. package/components/ui/vstack/index.web.tsx +17 -17
  85. package/components/ui/vstack/styles.tsx +5 -5
  86. package/design/tools/design.js +15 -12
  87. package/design/tools/npm.js +4 -3
  88. package/dist/{chunk-B277QSR5.mjs → chunk-2R66P5X5.mjs} +1816 -3124
  89. package/dist/chunk-2R66P5X5.mjs.map +1 -0
  90. package/dist/{chunk-GD37RFBR.js → chunk-LCTFQJZM.js} +1816 -3124
  91. package/dist/chunk-LCTFQJZM.js.map +1 -0
  92. package/dist/index.js +294 -294
  93. package/dist/index.mjs +1 -1
  94. package/dist/ui/index.js +294 -294
  95. package/dist/ui/index.mjs +1 -1
  96. package/package.json +12 -7
  97. package/dist/chunk-B277QSR5.mjs.map +0 -1
  98. package/dist/chunk-GD37RFBR.js.map +0 -1
@@ -2,12 +2,7 @@
2
2
  import React, { useEffect, useRef, useCallback, useMemo } from 'react';
3
3
  import { createTabs, TabsContext } from './creator';
4
4
  import { PrimitiveIcon, UIIcon } from '@gluestack-ui/core/icon/creator';
5
- import {
6
- tva,
7
- withStyleContext,
8
- useStyleContext,
9
- type VariantProps,
10
- } from '@gluestack-ui/utils/nativewind-utils';
5
+ import { tva, withStyleContext, useStyleContext, type VariantProps } from '@gluestack-ui/utils/nativewind-utils';
11
6
  import { cssInterop } from 'nativewind';
12
7
  import { Pressable, Text, View, FlatList, Platform } from 'react-native';
13
8
  import Animated, {
@@ -22,7 +17,7 @@ import { TabsAnimatedIndicator } from './TabsAnimatedIndicator';
22
17
  const SCOPE = 'TABS';
23
18
  const AnimatedView = Animated.createAnimatedComponent(View);
24
19
  const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
25
- Platform.OS === 'web' ? cssInterop(AnimatedView,{className:{target:'style'}}) : AnimatedView
20
+ Platform.OS === 'web' ? cssInterop(AnimatedView, { className: { target: 'style' } }) : AnimatedView;
26
21
  /** Styles */
27
22
 
28
23
  const tabsStyle = tva({
@@ -51,12 +46,10 @@ const tabsTriggerStyle = tva({
51
46
 
52
47
  const tabsTriggerTextStyle = tva({
53
48
  base: 'text-foreground/70 data-[selected=true]:text-foreground font-medium data-[hover=true]:text-foreground/90 ',
54
-
55
49
  });
56
50
 
57
51
  const tabsTriggerIconStyle = tva({
58
52
  base: 'h-4 w-4 fill-none pointer-events-none shrink-0 text-foreground/70 data-[selected=true]:text-foreground',
59
-
60
53
  });
61
54
 
62
55
  const tabsContentStyle = tva({
@@ -110,7 +103,6 @@ cssInterop(PrimitiveIcon, {
110
103
  type ITabsProps = React.ComponentPropsWithoutRef<typeof UITabs> &
111
104
  VariantProps<typeof tabsStyle> & {
112
105
  variant?: 'underlined' | 'filled';
113
-
114
106
  };
115
107
 
116
108
  type ITabsListProps = React.ComponentPropsWithoutRef<typeof UITabs.List>;
@@ -119,23 +111,15 @@ type ITabsTriggerProps = React.ComponentPropsWithoutRef<typeof UITabs.Trigger>;
119
111
 
120
112
  type ITabsContentProps = React.ComponentPropsWithoutRef<typeof UITabs.Content>;
121
113
 
122
- type ITabsContentWrapperProps = React.ComponentPropsWithoutRef<
123
- typeof UITabs.ContentWrapper
124
- >;
114
+ type ITabsContentWrapperProps = React.ComponentPropsWithoutRef<typeof UITabs.ContentWrapper>;
125
115
 
126
- type ITabsTriggerTextProps = React.ComponentPropsWithoutRef<
127
- typeof UITabs.TriggerText
128
- >;
116
+ type ITabsTriggerTextProps = React.ComponentPropsWithoutRef<typeof UITabs.TriggerText>;
129
117
 
130
- type ITabsTriggerIconProps = React.ComponentPropsWithoutRef<
131
- typeof UITabs.TriggerIcon
132
- > & {
118
+ type ITabsTriggerIconProps = React.ComponentPropsWithoutRef<typeof UITabs.TriggerIcon> & {
133
119
  as?: React.ElementType;
134
120
  };
135
121
 
136
- type ITabsIndicatorProps = React.ComponentPropsWithoutRef<
137
- typeof UITabs.Indicator
138
- >;
122
+ type ITabsIndicatorProps = React.ComponentPropsWithoutRef<typeof UITabs.Indicator>;
139
123
 
140
124
  /** Components */
141
125
 
@@ -147,321 +131,281 @@ const Tabs = React.forwardRef<React.ComponentRef<typeof UITabs>, ITabsProps>(
147
131
  {...props}
148
132
  className={tabsStyle({ class: className })}
149
133
  // @ts-ignore - pass variants to context
150
- context={{ variant}}
134
+ context={{ variant }}
151
135
  />
152
136
  );
153
- }
137
+ },
154
138
  );
155
139
 
156
- const TabsList = React.forwardRef<
157
- React.ComponentRef<typeof UITabs.List>,
158
- ITabsListProps
159
- >(({ className, children, ...props }, ref) => {
160
- const context = React.useContext(TabsContext);
140
+ const TabsList = React.forwardRef<React.ComponentRef<typeof UITabs.List>, ITabsListProps>(
141
+ ({ className, children, ...props }, ref) => {
142
+ const context = React.useContext(TabsContext);
161
143
 
162
- const flatListRef = useRef<any>(null);
144
+ const flatListRef = useRef<any>(null);
163
145
 
164
- if (!context) return null;
146
+ if (!context) return null;
165
147
 
166
- const { orientation, setScrollOffset, selectedKey, listRef } = context;
148
+ const { orientation, setScrollOffset, selectedKey, listRef } = context;
167
149
 
168
- // Shared value for indicator sync
169
- const animatedScrollOffset = useSharedValue(0);
150
+ // Shared value for indicator sync
151
+ const animatedScrollOffset = useSharedValue(0);
170
152
 
171
- /**
172
- * Expose shared value to context
173
- */
174
- useEffect(() => {
175
- if (context) {
176
- // @ts-ignore
177
- context.animatedScrollOffset = animatedScrollOffset;
178
- }
179
- }, [context, animatedScrollOffset]);
153
+ /**
154
+ * Expose shared value to context
155
+ */
156
+ useEffect(() => {
157
+ if (context) {
158
+ // @ts-ignore
159
+ context.animatedScrollOffset = animatedScrollOffset;
160
+ }
161
+ }, [context, animatedScrollOffset]);
162
+
163
+ /**
164
+ * Auto scroll to selected tab
165
+ */
166
+ useEffect(() => {
167
+ if (orientation !== 'horizontal' || !selectedKey) return;
168
+
169
+ const childArray = React.Children.toArray(children);
170
+ const triggers = childArray.filter((child: any) => child?.type?.displayName !== 'TabsIndicator');
171
+
172
+ const selectedIndex = triggers.findIndex((child: any) => child?.props?.value === selectedKey);
173
+
174
+ if (selectedIndex >= 0 && flatListRef.current) {
175
+ const timer = setTimeout(() => {
176
+ try {
177
+ flatListRef.current.scrollToIndex({
178
+ index: selectedIndex,
179
+ animated: true,
180
+ viewPosition: 0.5,
181
+ });
182
+ } catch {}
183
+ }, 100);
184
+
185
+ return () => clearTimeout(timer);
186
+ }
187
+ }, [selectedKey, orientation, children]);
188
+
189
+ /**
190
+ * Native animated scroll handler (ONLY for iOS / Android)
191
+ */
192
+ const nativeScrollHandler =
193
+ Platform.OS === 'web'
194
+ ? undefined
195
+ : useAnimatedScrollHandler({
196
+ onScroll: (event) => {
197
+ 'worklet';
198
+ const x = event.contentOffset.x;
199
+ animatedScrollOffset.value = x;
200
+ runOnJS(setScrollOffset)(x);
201
+ },
202
+ });
203
+
204
+ /**
205
+ * Web scroll handler (JS thread)
206
+ */
207
+ const handleWebScroll = (e: any) => {
208
+ const x = e.nativeEvent.contentOffset.x;
209
+ animatedScrollOffset.value = x;
210
+ setScrollOffset(x);
211
+ };
180
212
 
181
- /**
182
- * Auto scroll to selected tab
183
- */
184
- useEffect(() => {
185
- if (orientation !== 'horizontal' || !selectedKey) return;
213
+ /**
214
+ * Horizontal tabs → FlatList
215
+ */
216
+ // Memoize the split so FlatList's `data` prop stays referentially stable
217
+ // across scroll-driven re-renders (scrollOffset in context ticks on every
218
+ // scroll event; without this, FlatList re-renders every cell every frame,
219
+ // firing onLayout → measureTrigger on every scroll tick).
220
+ const { triggers, indicator } = useMemo(() => {
221
+ const childArray = React.Children.toArray(children);
222
+ return {
223
+ triggers: childArray.filter((child: any) => child?.type?.displayName !== 'TabsIndicator'),
224
+ indicator: childArray.find((child: any) => child?.type?.displayName === 'TabsIndicator'),
225
+ };
226
+ }, [children]);
227
+
228
+ if (orientation === 'horizontal') {
229
+ return (
230
+ <View ref={listRef} className={tabsListStyle({ orientation, class: className })}>
231
+ {indicator}
232
+
233
+ <AnimatedFlatList
234
+ ref={flatListRef}
235
+ horizontal
236
+ data={triggers}
237
+ renderItem={({ item }) => item as any}
238
+ keyExtractor={(item: any, index) => item?.props?.value ?? `tab-${index}`}
239
+ showsHorizontalScrollIndicator={false}
240
+ scrollEventThrottle={16}
241
+ style={{ zIndex: 100 }}
242
+ onScroll={Platform.OS === 'web' ? handleWebScroll : nativeScrollHandler}
243
+ onScrollToIndexFailed={(info) => {
244
+ setTimeout(() => {
245
+ try {
246
+ flatListRef.current?.scrollToIndex({
247
+ index: info.index,
248
+ animated: false,
249
+ viewPosition: 0.5,
250
+ });
251
+ } catch {}
252
+ }, 500);
253
+ }}
254
+ {...props}
255
+ />
256
+ </View>
257
+ );
258
+ }
186
259
 
187
- const childArray = React.Children.toArray(children);
188
- const triggers = childArray.filter(
189
- (child: any) => child?.type?.displayName !== 'TabsIndicator'
260
+ /**
261
+ * Vertical tabs → default List
262
+ */
263
+ return (
264
+ <UITabs.List ref={ref} {...props} className={tabsListStyle({ orientation, class: className })}>
265
+ {children}
266
+ </UITabs.List>
190
267
  );
268
+ },
269
+ );
191
270
 
192
- const selectedIndex = triggers.findIndex(
193
- (child: any) => child?.props?.value === selectedKey
271
+ const TabsTrigger = React.forwardRef<React.ComponentRef<typeof UITabs.Trigger>, ITabsTriggerProps>(
272
+ ({ className, ...props }, ref) => {
273
+ const { variant } = useStyleContext(SCOPE);
274
+
275
+ return (
276
+ <UITabs.Trigger
277
+ ref={ref}
278
+ {...props}
279
+ className={tabsTriggerStyle({
280
+ parentVariants: { variant },
281
+ class: className,
282
+ })}
283
+ />
194
284
  );
285
+ },
286
+ );
195
287
 
196
- if (selectedIndex >= 0 && flatListRef.current) {
197
- const timer = setTimeout(() => {
198
- try {
199
- flatListRef.current.scrollToIndex({
200
- index: selectedIndex,
201
- animated: true,
202
- viewPosition: 0.5,
203
- });
204
- } catch {}
205
- }, 100);
288
+ const TabsContent = React.forwardRef<React.ComponentRef<typeof UITabs.Content>, ITabsContentProps>(
289
+ ({ className, ...props }, ref) => {
290
+ return <UITabs.Content ref={ref} {...props} className={tabsContentStyle({ class: className })} />;
291
+ },
292
+ );
206
293
 
207
- return () => clearTimeout(timer);
208
- }
209
- }, [selectedKey, orientation, children]);
210
-
211
- /**
212
- * Native animated scroll handler (ONLY for iOS / Android)
213
- */
214
- const nativeScrollHandler =
215
- Platform.OS === 'web'
216
- ? undefined
217
- : useAnimatedScrollHandler({
218
- onScroll: (event) => {
219
- 'worklet';
220
- const x = event.contentOffset.x;
221
- animatedScrollOffset.value = x;
222
- runOnJS(setScrollOffset)(x);
223
- },
224
- });
225
-
226
- /**
227
- * Web scroll handler (JS thread)
228
- */
229
- const handleWebScroll = (e: any) => {
230
- const x = e.nativeEvent.contentOffset.x;
231
- animatedScrollOffset.value = x;
232
- setScrollOffset(x);
233
- };
294
+ const TabsContentWrapper = React.forwardRef<React.ComponentRef<typeof UITabs.ContentWrapper>, ITabsContentWrapperProps>(
295
+ ({ className, targetHeight, ...props }: any, ref) => {
296
+ const context = React.useContext(TabsContext);
297
+
298
+ // Get the height of the selected content from the layouts Map
299
+ const selectedLayout = context?.selectedKey ? context.contentLayouts.get(context.selectedKey) : null;
300
+ const height = selectedLayout?.height || 0;
301
+
302
+ // Use shared value for Reanimated with initial height
303
+ const heightValue = useSharedValue(height);
304
+ const isFirstRender = React.useRef(true);
305
+
306
+ // Update shared value when height changes
307
+ React.useEffect(() => {
308
+ if (height > 0) {
309
+ if (isFirstRender.current) {
310
+ // Set initial height without animation
311
+ heightValue.value = height;
312
+ isFirstRender.current = false;
313
+ } else {
314
+ // Animate height changes
315
+ heightValue.value = withSpring(height, { duration: 100 });
316
+ }
317
+ }
318
+ }, [height, heightValue]);
234
319
 
235
- /**
236
- * Horizontal tabs → FlatList
237
- */
238
- // Memoize the split so FlatList's `data` prop stays referentially stable
239
- // across scroll-driven re-renders (scrollOffset in context ticks on every
240
- // scroll event; without this, FlatList re-renders every cell every frame,
241
- // firing onLayout → measureTrigger on every scroll tick).
242
- const { triggers, indicator } = useMemo(() => {
243
- const childArray = React.Children.toArray(children);
244
- return {
245
- triggers: childArray.filter(
246
- (child: any) => child?.type?.displayName !== 'TabsIndicator'
247
- ),
248
- indicator: childArray.find(
249
- (child: any) => child?.type?.displayName === 'TabsIndicator'
250
- ),
251
- };
252
- }, [children]);
320
+ // Animated style for height transitions
321
+ const animatedStyle = useAnimatedStyle(() => {
322
+ return {
323
+ height: heightValue.value > 0 ? heightValue.value : 'auto',
324
+ };
325
+ }, []);
253
326
 
254
- if (orientation === 'horizontal') {
255
327
  return (
256
- <View
257
- ref={listRef}
258
- className={tabsListStyle({ orientation, class: className })}
259
- >
260
- {indicator}
261
-
262
- <AnimatedFlatList
263
- ref={flatListRef}
264
- horizontal
265
- data={triggers}
266
- renderItem={({ item }) => item as any}
267
- keyExtractor={(item: any, index) =>
268
- item?.props?.value ?? `tab-${index}`
269
- }
270
- showsHorizontalScrollIndicator={false}
271
- scrollEventThrottle={16}
272
- style={{ zIndex: 100 }}
273
- onScroll={
274
- Platform.OS === 'web' ? handleWebScroll : nativeScrollHandler
275
- }
276
- onScrollToIndexFailed={(info) => {
277
- setTimeout(() => {
278
- try {
279
- flatListRef.current?.scrollToIndex({
280
- index: info.index,
281
- animated: false,
282
- viewPosition: 0.5,
283
- });
284
- } catch {}
285
- }, 500);
286
- }}
287
- {...props}
288
- />
289
- </View>
328
+ <UITabs.ContentWrapper
329
+ ref={ref}
330
+ style={animatedStyle}
331
+ {...props}
332
+ className={tabsContentWrapperStyle({ class: className })}
333
+ />
290
334
  );
291
- }
292
-
293
- /**
294
- * Vertical tabs → default List
295
- */
296
- return (
297
- <UITabs.List
298
- ref={ref}
299
- {...props}
300
- className={tabsListStyle({ orientation, class: className })}
301
- >
302
- {children}
303
- </UITabs.List>
304
- );
305
- });
306
-
335
+ },
336
+ );
307
337
 
308
- const TabsTrigger = React.forwardRef<
309
- React.ComponentRef<typeof UITabs.Trigger>,
310
- ITabsTriggerProps
311
- >(({ className, ...props }, ref) => {
312
- const { variant } = useStyleContext(SCOPE);
313
-
314
- return (
315
- <UITabs.Trigger
316
- ref={ref}
317
- {...props}
318
- className={tabsTriggerStyle({
319
- parentVariants: { variant },
320
- class: className,
321
- })}
322
- />
323
- );
324
- });
338
+ const TabsTriggerText = React.forwardRef<React.ComponentRef<typeof UITabs.TriggerText>, ITabsTriggerTextProps>(
339
+ ({ className, ...props }, ref) => {
340
+ return (
341
+ <UITabs.TriggerText
342
+ ref={ref}
343
+ {...props}
344
+ className={tabsTriggerTextStyle({
345
+ class: className,
346
+ })}
347
+ />
348
+ );
349
+ },
350
+ );
325
351
 
326
- const TabsContent = React.forwardRef<
327
- React.ComponentRef<typeof UITabs.Content>,
328
- ITabsContentProps
329
- >(({ className, ...props }, ref) => {
330
- return (
331
- <UITabs.Content
332
- ref={ref}
333
- {...props}
334
- className={tabsContentStyle({ class: className })}
335
- />
336
- );
337
- });
352
+ const TabsTriggerIcon = React.forwardRef<React.ComponentRef<typeof UITabs.TriggerIcon>, ITabsTriggerIconProps>(
353
+ ({ className, ...props }, ref) => {
354
+ const { variant } = useStyleContext(SCOPE);
338
355
 
339
- const TabsContentWrapper = React.forwardRef<
340
- React.ComponentRef<typeof UITabs.ContentWrapper>,
341
- ITabsContentWrapperProps
342
- >(({ className, targetHeight, ...props }: any, ref) => {
343
- const context = React.useContext(TabsContext);
344
-
345
- // Get the height of the selected content from the layouts Map
346
- const selectedLayout = context?.selectedKey
347
- ? context.contentLayouts.get(context.selectedKey)
348
- : null;
349
- const height = selectedLayout?.height || 0;
350
-
351
- // Use shared value for Reanimated with initial height
352
- const heightValue = useSharedValue(height);
353
- const isFirstRender = React.useRef(true);
354
-
355
- // Update shared value when height changes
356
- React.useEffect(() => {
357
- if (height > 0) {
358
- if (isFirstRender.current) {
359
- // Set initial height without animation
360
- heightValue.value = height;
361
- isFirstRender.current = false;
362
- } else {
363
- // Animate height changes
364
- heightValue.value = withSpring(height,{duration:100});
365
- }
366
- }
367
- }, [height, heightValue]);
356
+ // Remove `dataSet` ONLY on web to avoid React DOM warning
357
+ const safeProps =
358
+ Platform.OS === 'web'
359
+ ? (() => {
360
+ const { dataSet, ...rest } = props as any;
361
+ return rest;
362
+ })()
363
+ : props;
368
364
 
369
- // Animated style for height transitions
370
- const animatedStyle = useAnimatedStyle(() => {
371
- return {
372
- height: heightValue.value > 0 ? heightValue.value : 'auto',
373
- };
374
- }, []);
375
-
376
- return (
377
- <UITabs.ContentWrapper
378
- ref={ref}
379
- style={animatedStyle}
380
- {...props}
381
- className={tabsContentWrapperStyle({ class: className })}
382
- />
383
- );
384
- });
365
+ return (
366
+ <UITabs.TriggerIcon
367
+ ref={ref}
368
+ {...safeProps}
369
+ className={tabsTriggerIconStyle({
370
+ parentVariants: { variant },
371
+ class: className,
372
+ })}
373
+ />
374
+ );
375
+ },
376
+ );
385
377
 
386
- const TabsTriggerText = React.forwardRef<
387
- React.ComponentRef<typeof UITabs.TriggerText>,
388
- ITabsTriggerTextProps
389
- >(({ className, ...props }, ref) => {
390
-
391
-
392
- return (
393
- <UITabs.TriggerText
394
- ref={ref}
395
- {...props}
396
- className={tabsTriggerTextStyle({
397
-
398
- class: className,
399
- })}
400
- />
401
- );
402
- });
378
+ const TabsIndicator = React.forwardRef<React.ComponentRef<typeof UITabs.Indicator>, ITabsIndicatorProps>(
379
+ ({ className, ...props }, ref) => {
380
+ const context = React.useContext(TabsContext);
403
381
 
404
- const TabsTriggerIcon = React.forwardRef<
405
- React.ComponentRef<typeof UITabs.TriggerIcon>,
406
- ITabsTriggerIconProps
407
- >(({ className, ...props }, ref) => {
408
- const { variant } = useStyleContext(SCOPE);
409
-
410
- // Remove `dataSet` ONLY on web to avoid React DOM warning
411
- const safeProps =
412
- Platform.OS === 'web'
413
- ? (() => {
414
- const { dataSet, ...rest } = props as any;
415
- return rest;
416
- })()
417
- : props;
418
-
419
- return (
420
- <UITabs.TriggerIcon
421
- ref={ref}
422
- {...safeProps}
423
- className={tabsTriggerIconStyle({
424
- parentVariants: { variant },
425
- class: className,
426
- })}
427
- />
428
- );
429
- });
382
+ const { variant } = useStyleContext(SCOPE);
430
383
 
384
+ if (!context) {
385
+ return null;
386
+ }
431
387
 
432
- const TabsIndicator = React.forwardRef<
433
- React.ComponentRef<typeof UITabs.Indicator>,
434
- ITabsIndicatorProps
435
- >(({ className, ...props }, ref) => {
436
- const context = React.useContext(TabsContext);
437
-
438
- const { variant } = useStyleContext(SCOPE);
439
-
440
- if (!context) {
441
- return null;
442
- }
443
-
444
- const { selectedKey, orientation, triggerLayouts, scrollOffset } = context;
445
- // @ts-ignore - Get animated scroll offset from context
446
- const animatedScrollOffset = context.animatedScrollOffset;
447
-
448
- return (
449
- <TabsAnimatedIndicator
450
- ref={ref}
451
- selectedKey={selectedKey}
452
- orientation={orientation}
453
- triggerLayouts={triggerLayouts}
454
- scrollOffset={scrollOffset}
455
- animatedScrollOffset={animatedScrollOffset}
456
- className={tabsIndicatorStyle({
457
- parentVariants: { variant },
458
- class: className,
459
- })}
460
- {...props}
461
- />
462
- );
463
- });
388
+ const { selectedKey, orientation, triggerLayouts, scrollOffset } = context;
389
+ // @ts-ignore - Get animated scroll offset from context
390
+ const animatedScrollOffset = context.animatedScrollOffset;
464
391
 
392
+ return (
393
+ <TabsAnimatedIndicator
394
+ ref={ref}
395
+ selectedKey={selectedKey}
396
+ orientation={orientation}
397
+ triggerLayouts={triggerLayouts}
398
+ scrollOffset={scrollOffset}
399
+ animatedScrollOffset={animatedScrollOffset}
400
+ className={tabsIndicatorStyle({
401
+ parentVariants: { variant },
402
+ class: className,
403
+ })}
404
+ {...props}
405
+ />
406
+ );
407
+ },
408
+ );
465
409
 
466
410
  Tabs.displayName = 'Tabs';
467
411
  TabsList.displayName = 'TabsList';
@@ -470,7 +414,7 @@ TabsContent.displayName = 'TabsContent';
470
414
  TabsContentWrapper.displayName = 'TabsContentWrapper';
471
415
  TabsTriggerText.displayName = 'TabsTriggerText';
472
416
  TabsTriggerIcon.displayName = 'TabsTriggerIcon';
473
- TabsIndicator.displayName = 'TabsIndicator'
417
+ TabsIndicator.displayName = 'TabsIndicator';
474
418
 
475
419
  export {
476
420
  Tabs,