@tamagui/tabs 1.74.19 → 1.74.21

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/src/Tabs.tsx CHANGED
@@ -7,6 +7,7 @@ import { useDirection } from '@tamagui/use-direction'
7
7
  import {
8
8
  GetProps,
9
9
  SizeTokens,
10
+ TamaguiElement,
10
11
  Theme,
11
12
  composeEventHandlers,
12
13
  composeRefs,
@@ -290,7 +291,8 @@ const TabsContentFrame = styled(ThemeableStack, {
290
291
  name: CONTENT_NAME,
291
292
  })
292
293
  type TabsContentFrameProps = GetProps<typeof TabsContentFrame>
293
- type TabsContentProps = TabsContentFrameProps & {
294
+
295
+ type TabsContentExtraProps = {
294
296
  /** Will show the content when the value matches the state of Tabs root */
295
297
  value: string
296
298
 
@@ -301,41 +303,39 @@ type TabsContentProps = TabsContentFrameProps & {
301
303
  forceMount?: true
302
304
  }
303
305
 
304
- const TabsContent = TabsContentFrame.extractable(
305
- React.forwardRef<HTMLDivElement, TabsContentProps>(
306
- (props: ScopedProps<TabsContentProps>, forwardedRef) => {
307
- const { __scopeTabs, value, forceMount, children, ...contentProps } = props
308
- const context = useTabsContext(__scopeTabs)
309
- const isSelected = value === context.value
310
- const show = forceMount || isSelected
311
-
312
- const triggerId = makeTriggerId(context.baseId, value)
313
- const contentId = makeContentId(context.baseId, value)
314
-
315
- if (!show) return null
316
- return (
317
- <TabsContentFrame
318
- key={value}
319
- data-state={isSelected ? 'active' : 'inactive'}
320
- data-orientation={context.orientation}
321
- role="tabpanel"
322
- aria-labelledby={triggerId}
323
- // @ts-ignore
324
- hidden={!show}
325
- id={contentId}
326
- tabIndex={0}
327
- {...contentProps}
328
- ref={forwardedRef}
329
- >
330
- {children}
331
- </TabsContentFrame>
332
- )
333
- }
334
- )
306
+ type TabsContentProps = TabsContentFrameProps & TabsContentExtraProps
307
+
308
+ const TabsContent = TabsContentFrame.styleable<TabsContentExtraProps>(
309
+ function TabsContent(props: ScopedProps<TabsContentProps>, forwardedRef) {
310
+ const { __scopeTabs, value, forceMount, children, ...contentProps } = props
311
+ const context = useTabsContext(__scopeTabs)
312
+ const isSelected = value === context.value
313
+ const show = forceMount || isSelected
314
+
315
+ const triggerId = makeTriggerId(context.baseId, value)
316
+ const contentId = makeContentId(context.baseId, value)
317
+
318
+ if (!show) return null
319
+ return (
320
+ <TabsContentFrame
321
+ key={value}
322
+ data-state={isSelected ? 'active' : 'inactive'}
323
+ data-orientation={context.orientation}
324
+ role="tabpanel"
325
+ aria-labelledby={triggerId}
326
+ // @ts-ignore
327
+ hidden={!show}
328
+ id={contentId}
329
+ tabIndex={0}
330
+ {...contentProps}
331
+ ref={forwardedRef}
332
+ >
333
+ {children}
334
+ </TabsContentFrame>
335
+ )
336
+ }
335
337
  )
336
338
 
337
- TabsContent.displayName = CONTENT_NAME
338
-
339
339
  /* -------------------------------------------------------------------------------------------------
340
340
  * Tabs
341
341
  * -----------------------------------------------------------------------------------------------*/