@tamagui/tabs 1.14.9 → 1.15.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.
- package/dist/cjs/Tabs.js +1 -3
- package/dist/cjs/Tabs.js.map +2 -2
- package/dist/esm/Tabs.js +1 -3
- package/dist/esm/Tabs.js.map +2 -2
- package/dist/esm/Tabs.mjs +1 -3
- package/dist/esm/Tabs.mjs.map +2 -2
- package/dist/jsx/Tabs.js +1 -3
- package/dist/jsx/Tabs.js.map +2 -2
- package/dist/jsx/Tabs.mjs +1 -3
- package/dist/jsx/Tabs.mjs.map +2 -2
- package/package.json +10 -10
- package/src/Tabs.tsx +2 -3
- package/types/Tabs.d.ts +10 -10
- package/types/Tabs.d.ts.map +1 -1
package/dist/cjs/Tabs.js
CHANGED
|
@@ -45,9 +45,6 @@ const TAB_LIST_NAME = "TabsList";
|
|
|
45
45
|
const TabsListFrame = (0, import_web.styled)(import_group.Group, {
|
|
46
46
|
name: TAB_LIST_NAME,
|
|
47
47
|
focusable: true
|
|
48
|
-
// defaultVariants: {
|
|
49
|
-
// flexGrow: 0,
|
|
50
|
-
// },
|
|
51
48
|
});
|
|
52
49
|
const TabsList = TabsListFrame.extractable(
|
|
53
50
|
React.forwardRef(
|
|
@@ -88,6 +85,7 @@ const TabsTriggerFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
|
|
|
88
85
|
flexWrap: "nowrap",
|
|
89
86
|
flexDirection: "row",
|
|
90
87
|
cursor: "pointer",
|
|
88
|
+
backgroundColor: "$background",
|
|
91
89
|
focusable: true,
|
|
92
90
|
variants: {
|
|
93
91
|
size: {
|
package/dist/cjs/Tabs.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Tabs.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { Group, GroupProps, useGroupItem } from '@tamagui/group'\nimport { RovingFocusGroup, createRovingFocusGroupScope } from '@tamagui/roving-focus'\nimport { SizableStack, ThemeableStack, ThemeableStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport { useDirection } from '@tamagui/use-direction'\nimport {\n GetProps,\n SizeTokens,\n Theme,\n composeEventHandlers,\n composeRefs,\n isWeb,\n styled,\n useEvent,\n withStaticProperties,\n} from '@tamagui/web'\nimport * as React from 'react'\nimport type { LayoutRectangle } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList'\n\nconst TabsListFrame = styled(Group, {\n name: TAB_LIST_NAME,\n focusable: true,\n // defaultVariants: {\n // flexGrow: 0,\n // },\n})\n\ntype TabsListFrameProps = GroupProps\n\ntype TabsListProps = TabsListFrameProps & {\n /**\n * Whether to loop over after reaching the end or start of the items\n * @default true\n */\n loop?: boolean\n}\n\nconst TabsList = TabsListFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, children, ...listProps } = props\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n\n return (\n <RovingFocusGroup\n asChild\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n {...rovingFocusGroupScope}\n >\n <TabsListFrame\n role=\"tablist\"\n aria-orientation={context.orientation}\n ref={forwardedRef}\n axis={context.orientation}\n {...listProps}\n >\n {children}\n </TabsListFrame>\n </RovingFocusGroup>\n )\n }\n )\n)\n\nTabsList.displayName = TAB_LIST_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger'\n\nconst TabsTriggerFrame = styled(ThemeableStack, {\n name: TRIGGER_NAME,\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n focusable: true,\n\n variants: {\n size: {\n '...size': getButtonSized,\n },\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n unstyled: {\n false: {\n backgroundColor: '$background',\n\n pressStyle: {\n backgroundColor: '$backgroundPress',\n },\n\n hoverStyle: {\n backgroundColor: '$backgroundHover',\n },\n\n focusStyle: {\n backgroundColor: '$backgroundFocus',\n },\n },\n },\n } as const,\n defaultVariants: {\n unstyled: false,\n },\n})\n\n/**\n * @deprecated Use `TabLayout` instead\n */\ntype TabsTriggerLayout = LayoutRectangle\ntype TabLayout = LayoutRectangle\ntype InteractionType = 'select' | 'focus' | 'hover'\n\ntype TabsTriggerFrameProps = GetProps<typeof TabsTriggerFrame>\n/**\n * @deprecated use `TabTabsProps` instead\n */\ntype TabsTriggerProps = TabsTriggerFrameProps & {\n /** The value for the tabs state to be changed to after activation of the trigger */\n value: string\n\n /** Used for making custom indicators when trigger interacted with */\n onInteraction?: (type: InteractionType, layout: TabLayout | null) => void\n}\n\ntype TabsTabProps = TabsTriggerProps\n\nconst TabsTrigger = TabsTriggerFrame.extractable(\n React.forwardRef<HTMLButtonElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value,\n disabled = false,\n onInteraction,\n ...triggerProps\n } = props\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n const isSelected = value === context.value\n const [layout, setLayout] = React.useState<TabLayout | null>(null)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const groupItemProps = useGroupItem({ disabled })\n\n React.useEffect(() => {\n context.registerTrigger()\n return () => context.unregisterTrigger()\n }, [])\n\n React.useEffect(() => {\n if (!triggerRef.current || !isWeb) return\n\n function getTriggerSize() {\n if (!triggerRef.current) return\n setLayout({\n width: triggerRef.current.offsetWidth,\n height: triggerRef.current.offsetHeight,\n x: triggerRef.current.offsetLeft,\n y: triggerRef.current.offsetTop,\n })\n }\n getTriggerSize()\n\n const observer = new ResizeObserver(getTriggerSize)\n observer.observe(triggerRef.current)\n\n return () => {\n if (!triggerRef.current) return\n observer.unobserve(triggerRef.current)\n }\n }, [context.triggersCount])\n\n React.useEffect(() => {\n if (isSelected && layout) {\n onInteraction?.('select', layout)\n }\n }, [isSelected, value, layout])\n\n return (\n <Theme name={isSelected ? 'active' : null}>\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <TabsTriggerFrame\n onLayout={(event) => {\n if (!isWeb) {\n setLayout(event.nativeEvent.layout)\n }\n }}\n onHoverIn={composeEventHandlers(props.onHoverIn, () => {\n if (layout) {\n onInteraction?.('hover', layout)\n }\n })}\n onHoverOut={composeEventHandlers(props.onHoverOut, () => {\n onInteraction?.('hover', null)\n })}\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n // @ts-ignore\n size={context.size}\n {...triggerProps}\n ref={composeRefs(forwardedRef, triggerRef)}\n onPress={composeEventHandlers(props.onPress ?? undefined, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n\n const webChecks =\n !isWeb ||\n ((event as unknown as React.MouseEvent).button === 0 &&\n (event as unknown as React.MouseEvent).ctrlKey === false)\n if (!disabled && !isSelected && webChecks) {\n context.onChange(value)\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault()\n }\n })}\n {...(isWeb && {\n type: 'button',\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n if ([' ', 'Enter'].includes(event.key)) {\n context.onChange(value)\n event.preventDefault()\n }\n }\n ),\n onFocus: composeEventHandlers(props.onFocus, (event) => {\n if (layout) {\n onInteraction?.('focus', layout)\n }\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual'\n if (!isSelected && !disabled && isAutomaticActivation) {\n context.onChange(value)\n }\n }),\n onBlur: composeEventHandlers(props.onFocus, () => {\n onInteraction?.('focus', null)\n }),\n })}\n {...groupItemProps}\n />\n </RovingFocusGroup.Item>\n </Theme>\n )\n }\n )\n)\n\nTabsTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent'\n\nconst TabsContentFrame = styled(ThemeableStack, {\n name: CONTENT_NAME,\n})\ntype TabsContentFrameProps = GetProps<typeof TabsContentFrame>\ntype TabsContentProps = TabsContentFrameProps & {\n /** Will show the content when the value matches the state of Tabs root */\n value: string\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Tamagui animations.\n */\n forceMount?: true\n}\n\nconst TabsContent = TabsContentFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props\n const context = useTabsContext(CONTENT_NAME, __scopeTabs)\n const isSelected = value === context.value\n const show = forceMount || isSelected\n\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n\n if (!show) return null\n return (\n <TabsContentFrame\n key={value}\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n // @ts-ignore\n hidden={!show}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {children}\n </TabsContentFrame>\n )\n }\n )\n)\n\nTabsContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs'\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope }\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n])\nconst useRovingFocusGroupScope = createRovingFocusGroupScope()\n\ntype TabsContextValue = {\n baseId: string\n value?: string\n onChange: (value: string) => void\n orientation?: TabsProps['orientation']\n dir?: TabsProps['dir']\n activationMode?: TabsProps['activationMode']\n size: SizeTokens\n registerTrigger: () => void\n unregisterTrigger: () => void\n triggersCount: number\n}\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME)\n\nconst TabsFrame = styled(SizableStack, {\n name: TABS_NAME,\n})\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>\ntype TabsFrameProps = GetProps<typeof TabsFrame>\ntype TabsProps = TabsFrameProps & {\n /** The value for the selected tab, if controlled */\n value?: string\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation']\n /**\n * The direction of navigation between toolbar items.\n */\n dir?: RovingFocusGroupProps['dir']\n /**\n * Whether a tab is activated automatically or manually. Only supported in web.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual'\n}\n\nexport const Tabs = withStaticProperties(\n TabsFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir,\n activationMode = 'automatic',\n size = '$true',\n ...tabsProps\n } = props\n const direction = useDirection(dir)\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue ?? '',\n })\n const [triggersCount, setTriggersCount] = React.useState(0)\n const registerTrigger = useEvent(() => setTriggersCount((v) => v + 1))\n const unregisterTrigger = useEvent(() => setTriggersCount((v) => v - 1))\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={React.useId()}\n value={value}\n onChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n size={size}\n registerTrigger={registerTrigger}\n triggersCount={triggersCount}\n unregisterTrigger={unregisterTrigger}\n >\n <TabsFrame\n direction={direction}\n // dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n )\n }\n )\n ),\n {\n List: TabsList,\n /**\n * @deprecated Use Tabs.Tab instead\n */\n Trigger: TabsTrigger,\n Tab: TabsTrigger,\n Content: TabsContent,\n }\n)\nTabs.displayName = TABS_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`\n}\n\nexport type {\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsTriggerLayout,\n TabsTabProps,\n TabsContentProps,\n TabLayout,\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { Group, GroupProps, useGroupItem } from '@tamagui/group'\nimport { RovingFocusGroup, createRovingFocusGroupScope } from '@tamagui/roving-focus'\nimport { SizableStack, ThemeableStack, ThemeableStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport { useDirection } from '@tamagui/use-direction'\nimport {\n GetProps,\n SizeTokens,\n Theme,\n composeEventHandlers,\n composeRefs,\n isWeb,\n styled,\n useEvent,\n withStaticProperties,\n} from '@tamagui/web'\nimport * as React from 'react'\nimport type { LayoutRectangle } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList'\n\nconst TabsListFrame = styled(Group, {\n name: TAB_LIST_NAME,\n focusable: true,\n})\n\ntype TabsListFrameProps = GroupProps\n\ntype TabsListProps = TabsListFrameProps & {\n /**\n * Whether to loop over after reaching the end or start of the items\n * @default true\n */\n loop?: boolean\n}\n\nconst TabsList = TabsListFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, children, ...listProps } = props\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n\n return (\n <RovingFocusGroup\n asChild\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n {...rovingFocusGroupScope}\n >\n <TabsListFrame\n role=\"tablist\"\n aria-orientation={context.orientation}\n ref={forwardedRef}\n axis={context.orientation}\n {...listProps}\n >\n {children}\n </TabsListFrame>\n </RovingFocusGroup>\n )\n }\n )\n)\n\nTabsList.displayName = TAB_LIST_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger'\n\nconst TabsTriggerFrame = styled(ThemeableStack, {\n name: TRIGGER_NAME,\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n backgroundColor: '$background',\n focusable: true,\n\n variants: {\n size: {\n '...size': getButtonSized,\n },\n\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n unstyled: {\n false: {\n backgroundColor: '$background',\n\n pressStyle: {\n backgroundColor: '$backgroundPress',\n },\n\n hoverStyle: {\n backgroundColor: '$backgroundHover',\n },\n\n focusStyle: {\n backgroundColor: '$backgroundFocus',\n },\n },\n },\n } as const,\n defaultVariants: {\n unstyled: false,\n },\n})\n\n/**\n * @deprecated Use `TabLayout` instead\n */\ntype TabsTriggerLayout = LayoutRectangle\ntype TabLayout = LayoutRectangle\ntype InteractionType = 'select' | 'focus' | 'hover'\n\ntype TabsTriggerFrameProps = GetProps<typeof TabsTriggerFrame>\n/**\n * @deprecated use `TabTabsProps` instead\n */\ntype TabsTriggerProps = TabsTriggerFrameProps & {\n /** The value for the tabs state to be changed to after activation of the trigger */\n value: string\n\n /** Used for making custom indicators when trigger interacted with */\n onInteraction?: (type: InteractionType, layout: TabLayout | null) => void\n}\n\ntype TabsTabProps = TabsTriggerProps\n\nconst TabsTrigger = TabsTriggerFrame.extractable(\n React.forwardRef<HTMLButtonElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value,\n disabled = false,\n onInteraction,\n ...triggerProps\n } = props\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n const isSelected = value === context.value\n const [layout, setLayout] = React.useState<TabLayout | null>(null)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const groupItemProps = useGroupItem({ disabled })\n\n React.useEffect(() => {\n context.registerTrigger()\n return () => context.unregisterTrigger()\n }, [])\n\n React.useEffect(() => {\n if (!triggerRef.current || !isWeb) return\n\n function getTriggerSize() {\n if (!triggerRef.current) return\n setLayout({\n width: triggerRef.current.offsetWidth,\n height: triggerRef.current.offsetHeight,\n x: triggerRef.current.offsetLeft,\n y: triggerRef.current.offsetTop,\n })\n }\n getTriggerSize()\n\n const observer = new ResizeObserver(getTriggerSize)\n observer.observe(triggerRef.current)\n\n return () => {\n if (!triggerRef.current) return\n observer.unobserve(triggerRef.current)\n }\n }, [context.triggersCount])\n\n React.useEffect(() => {\n if (isSelected && layout) {\n onInteraction?.('select', layout)\n }\n }, [isSelected, value, layout])\n\n return (\n <Theme name={isSelected ? 'active' : null}>\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <TabsTriggerFrame\n onLayout={(event) => {\n if (!isWeb) {\n setLayout(event.nativeEvent.layout)\n }\n }}\n onHoverIn={composeEventHandlers(props.onHoverIn, () => {\n if (layout) {\n onInteraction?.('hover', layout)\n }\n })}\n onHoverOut={composeEventHandlers(props.onHoverOut, () => {\n onInteraction?.('hover', null)\n })}\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n // @ts-ignore\n size={context.size}\n {...triggerProps}\n ref={composeRefs(forwardedRef, triggerRef)}\n onPress={composeEventHandlers(props.onPress ?? undefined, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n\n const webChecks =\n !isWeb ||\n ((event as unknown as React.MouseEvent).button === 0 &&\n (event as unknown as React.MouseEvent).ctrlKey === false)\n if (!disabled && !isSelected && webChecks) {\n context.onChange(value)\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault()\n }\n })}\n {...(isWeb && {\n type: 'button',\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n if ([' ', 'Enter'].includes(event.key)) {\n context.onChange(value)\n event.preventDefault()\n }\n }\n ),\n onFocus: composeEventHandlers(props.onFocus, (event) => {\n if (layout) {\n onInteraction?.('focus', layout)\n }\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual'\n if (!isSelected && !disabled && isAutomaticActivation) {\n context.onChange(value)\n }\n }),\n onBlur: composeEventHandlers(props.onFocus, () => {\n onInteraction?.('focus', null)\n }),\n })}\n {...groupItemProps}\n />\n </RovingFocusGroup.Item>\n </Theme>\n )\n }\n )\n)\n\nTabsTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent'\n\nconst TabsContentFrame = styled(ThemeableStack, {\n name: CONTENT_NAME,\n})\ntype TabsContentFrameProps = GetProps<typeof TabsContentFrame>\ntype TabsContentProps = TabsContentFrameProps & {\n /** Will show the content when the value matches the state of Tabs root */\n value: string\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Tamagui animations.\n */\n forceMount?: true\n}\n\nconst TabsContent = TabsContentFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props\n const context = useTabsContext(CONTENT_NAME, __scopeTabs)\n const isSelected = value === context.value\n const show = forceMount || isSelected\n\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n\n if (!show) return null\n return (\n <TabsContentFrame\n key={value}\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n // @ts-ignore\n hidden={!show}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {children}\n </TabsContentFrame>\n )\n }\n )\n)\n\nTabsContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs'\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope }\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n])\nconst useRovingFocusGroupScope = createRovingFocusGroupScope()\n\ntype TabsContextValue = {\n baseId: string\n value?: string\n onChange: (value: string) => void\n orientation?: TabsProps['orientation']\n dir?: TabsProps['dir']\n activationMode?: TabsProps['activationMode']\n size: SizeTokens\n registerTrigger: () => void\n unregisterTrigger: () => void\n triggersCount: number\n}\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME)\n\nconst TabsFrame = styled(SizableStack, {\n name: TABS_NAME,\n})\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>\ntype TabsFrameProps = GetProps<typeof TabsFrame>\ntype TabsProps = TabsFrameProps & {\n /** The value for the selected tab, if controlled */\n value?: string\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation']\n /**\n * The direction of navigation between toolbar items.\n */\n dir?: RovingFocusGroupProps['dir']\n /**\n * Whether a tab is activated automatically or manually. Only supported in web.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual'\n}\n\nexport const Tabs = withStaticProperties(\n TabsFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir,\n activationMode = 'automatic',\n size = '$true',\n ...tabsProps\n } = props\n const direction = useDirection(dir)\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue ?? '',\n })\n const [triggersCount, setTriggersCount] = React.useState(0)\n const registerTrigger = useEvent(() => setTriggersCount((v) => v + 1))\n const unregisterTrigger = useEvent(() => setTriggersCount((v) => v - 1))\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={React.useId()}\n value={value}\n onChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n size={size}\n registerTrigger={registerTrigger}\n triggersCount={triggersCount}\n unregisterTrigger={unregisterTrigger}\n >\n <TabsFrame\n direction={direction}\n // dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n )\n }\n )\n ),\n {\n List: TabsList,\n /**\n * @deprecated Use Tabs.Tab instead\n */\n Trigger: TabsTrigger,\n Tab: TabsTrigger,\n Content: TabsContent,\n }\n)\nTabs.displayName = TABS_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`\n}\n\nexport type {\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsTriggerLayout,\n TabsTabProps,\n TabsContentProps,\n TabLayout,\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0DU;AAzDV,4BAAmC;AACnC,8BAA+B;AAC/B,mBAAgD;AAChD,0BAA8D;AAC9D,oBAAkE;AAClE,oCAAqC;AACrC,2BAA6B;AAC7B,iBAUO;AACP,YAAuB;AAOvB,MAAM,gBAAgB;AAEtB,MAAM,oBAAgB,mBAAO,oBAAO;AAAA,EAClC,MAAM;AAAA,EACN,WAAW;AACb,CAAC;AAYD,MAAM,WAAW,cAAc;AAAA,EAC7B,MAAM;AAAA,IACJ,CAAC,OAAmC,iBAAiB;AACnD,YAAM,EAAE,aAAa,OAAO,MAAM,UAAU,GAAG,UAAU,IAAI;AAC7D,YAAM,UAAU,eAAe,eAAe,WAAW;AACzD,YAAM,wBAAwB,yBAAyB,WAAW;AAElE,aACE;AAAA,QAAC;AAAA;AAAA,UACC,SAAO;AAAA,UACP,aAAa,QAAQ;AAAA,UACrB,KAAK,QAAQ;AAAA,UACb;AAAA,UACC,GAAG;AAAA,UAEJ;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,oBAAkB,QAAQ;AA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GAAG;AAAA,QACL,IAAI;AACJ,cAAM,gBAAY,mCAAa,GAAG;AAClC,cAAM,CAAC,OAAO,QAAQ,QAAI,oDAAqB;AAAA,UAC7C,MAAM;AAAA,UACN,UAAU;AAAA,UACV,aAAa,gBAAgB;AAAA,QAC/B,CAAC;AACD,cAAM,CAAC,eAAe,gBAAgB,IAAI,MAAM,SAAS,CAAC;AAC1D,cAAM,sBAAkB,qBAAS,MAAM,iBAAiB,CAAC,MAAM,IAAI,CAAC,CAAC;AACrE,cAAM,wBAAoB,qBAAS,MAAM,iBAAiB,CAAC,MAAM,IAAI,CAAC,CAAC;AAEvE,eACE;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,YACP,QAAQ,MAAM,MAAM;AAAA,YACpB;AAAA,YACA,UAAU;AAAA,YACV;AAAA,YACA,KAAK;AAAA,YACL;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YAEA;AAAA,cAAC;AAAA;AAAA,gBACC;AAAA,gBAEA,oBAAkB;AAAA,gBACjB,GAAG;AAAA,gBACJ,KAAK;AAAA;AAAA,YACP;AAAA;AAAA,QACF;AAAA,MAEJ;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA;AAAA;AAAA;AAAA,IAIN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,SAAS;AAAA,EACX;AACF;AACA,KAAK,cAAc;AAInB,SAAS,cAAc,QAAgB,OAAe;AACpD,SAAO,GAAG,kBAAkB;AAC9B;AAEA,SAAS,cAAc,QAAgB,OAAe;AACpD,SAAO,GAAG,kBAAkB;AAC9B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/Tabs.js
CHANGED
|
@@ -20,9 +20,6 @@ const TAB_LIST_NAME = "TabsList";
|
|
|
20
20
|
const TabsListFrame = styled(Group, {
|
|
21
21
|
name: TAB_LIST_NAME,
|
|
22
22
|
focusable: true
|
|
23
|
-
// defaultVariants: {
|
|
24
|
-
// flexGrow: 0,
|
|
25
|
-
// },
|
|
26
23
|
});
|
|
27
24
|
const TabsList = TabsListFrame.extractable(
|
|
28
25
|
React.forwardRef(
|
|
@@ -63,6 +60,7 @@ const TabsTriggerFrame = styled(ThemeableStack, {
|
|
|
63
60
|
flexWrap: "nowrap",
|
|
64
61
|
flexDirection: "row",
|
|
65
62
|
cursor: "pointer",
|
|
63
|
+
backgroundColor: "$background",
|
|
66
64
|
focusable: true,
|
|
67
65
|
variants: {
|
|
68
66
|
size: {
|
package/dist/esm/Tabs.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Tabs.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { Group, GroupProps, useGroupItem } from '@tamagui/group'\nimport { RovingFocusGroup, createRovingFocusGroupScope } from '@tamagui/roving-focus'\nimport { SizableStack, ThemeableStack, ThemeableStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport { useDirection } from '@tamagui/use-direction'\nimport {\n GetProps,\n SizeTokens,\n Theme,\n composeEventHandlers,\n composeRefs,\n isWeb,\n styled,\n useEvent,\n withStaticProperties,\n} from '@tamagui/web'\nimport * as React from 'react'\nimport type { LayoutRectangle } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList'\n\nconst TabsListFrame = styled(Group, {\n name: TAB_LIST_NAME,\n focusable: true,\n // defaultVariants: {\n // flexGrow: 0,\n // },\n})\n\ntype TabsListFrameProps = GroupProps\n\ntype TabsListProps = TabsListFrameProps & {\n /**\n * Whether to loop over after reaching the end or start of the items\n * @default true\n */\n loop?: boolean\n}\n\nconst TabsList = TabsListFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, children, ...listProps } = props\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n\n return (\n <RovingFocusGroup\n asChild\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n {...rovingFocusGroupScope}\n >\n <TabsListFrame\n role=\"tablist\"\n aria-orientation={context.orientation}\n ref={forwardedRef}\n axis={context.orientation}\n {...listProps}\n >\n {children}\n </TabsListFrame>\n </RovingFocusGroup>\n )\n }\n )\n)\n\nTabsList.displayName = TAB_LIST_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger'\n\nconst TabsTriggerFrame = styled(ThemeableStack, {\n name: TRIGGER_NAME,\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n focusable: true,\n\n variants: {\n size: {\n '...size': getButtonSized,\n },\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n unstyled: {\n false: {\n backgroundColor: '$background',\n\n pressStyle: {\n backgroundColor: '$backgroundPress',\n },\n\n hoverStyle: {\n backgroundColor: '$backgroundHover',\n },\n\n focusStyle: {\n backgroundColor: '$backgroundFocus',\n },\n },\n },\n } as const,\n defaultVariants: {\n unstyled: false,\n },\n})\n\n/**\n * @deprecated Use `TabLayout` instead\n */\ntype TabsTriggerLayout = LayoutRectangle\ntype TabLayout = LayoutRectangle\ntype InteractionType = 'select' | 'focus' | 'hover'\n\ntype TabsTriggerFrameProps = GetProps<typeof TabsTriggerFrame>\n/**\n * @deprecated use `TabTabsProps` instead\n */\ntype TabsTriggerProps = TabsTriggerFrameProps & {\n /** The value for the tabs state to be changed to after activation of the trigger */\n value: string\n\n /** Used for making custom indicators when trigger interacted with */\n onInteraction?: (type: InteractionType, layout: TabLayout | null) => void\n}\n\ntype TabsTabProps = TabsTriggerProps\n\nconst TabsTrigger = TabsTriggerFrame.extractable(\n React.forwardRef<HTMLButtonElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value,\n disabled = false,\n onInteraction,\n ...triggerProps\n } = props\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n const isSelected = value === context.value\n const [layout, setLayout] = React.useState<TabLayout | null>(null)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const groupItemProps = useGroupItem({ disabled })\n\n React.useEffect(() => {\n context.registerTrigger()\n return () => context.unregisterTrigger()\n }, [])\n\n React.useEffect(() => {\n if (!triggerRef.current || !isWeb) return\n\n function getTriggerSize() {\n if (!triggerRef.current) return\n setLayout({\n width: triggerRef.current.offsetWidth,\n height: triggerRef.current.offsetHeight,\n x: triggerRef.current.offsetLeft,\n y: triggerRef.current.offsetTop,\n })\n }\n getTriggerSize()\n\n const observer = new ResizeObserver(getTriggerSize)\n observer.observe(triggerRef.current)\n\n return () => {\n if (!triggerRef.current) return\n observer.unobserve(triggerRef.current)\n }\n }, [context.triggersCount])\n\n React.useEffect(() => {\n if (isSelected && layout) {\n onInteraction?.('select', layout)\n }\n }, [isSelected, value, layout])\n\n return (\n <Theme name={isSelected ? 'active' : null}>\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <TabsTriggerFrame\n onLayout={(event) => {\n if (!isWeb) {\n setLayout(event.nativeEvent.layout)\n }\n }}\n onHoverIn={composeEventHandlers(props.onHoverIn, () => {\n if (layout) {\n onInteraction?.('hover', layout)\n }\n })}\n onHoverOut={composeEventHandlers(props.onHoverOut, () => {\n onInteraction?.('hover', null)\n })}\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n // @ts-ignore\n size={context.size}\n {...triggerProps}\n ref={composeRefs(forwardedRef, triggerRef)}\n onPress={composeEventHandlers(props.onPress ?? undefined, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n\n const webChecks =\n !isWeb ||\n ((event as unknown as React.MouseEvent).button === 0 &&\n (event as unknown as React.MouseEvent).ctrlKey === false)\n if (!disabled && !isSelected && webChecks) {\n context.onChange(value)\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault()\n }\n })}\n {...(isWeb && {\n type: 'button',\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n if ([' ', 'Enter'].includes(event.key)) {\n context.onChange(value)\n event.preventDefault()\n }\n }\n ),\n onFocus: composeEventHandlers(props.onFocus, (event) => {\n if (layout) {\n onInteraction?.('focus', layout)\n }\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual'\n if (!isSelected && !disabled && isAutomaticActivation) {\n context.onChange(value)\n }\n }),\n onBlur: composeEventHandlers(props.onFocus, () => {\n onInteraction?.('focus', null)\n }),\n })}\n {...groupItemProps}\n />\n </RovingFocusGroup.Item>\n </Theme>\n )\n }\n )\n)\n\nTabsTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent'\n\nconst TabsContentFrame = styled(ThemeableStack, {\n name: CONTENT_NAME,\n})\ntype TabsContentFrameProps = GetProps<typeof TabsContentFrame>\ntype TabsContentProps = TabsContentFrameProps & {\n /** Will show the content when the value matches the state of Tabs root */\n value: string\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Tamagui animations.\n */\n forceMount?: true\n}\n\nconst TabsContent = TabsContentFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props\n const context = useTabsContext(CONTENT_NAME, __scopeTabs)\n const isSelected = value === context.value\n const show = forceMount || isSelected\n\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n\n if (!show) return null\n return (\n <TabsContentFrame\n key={value}\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n // @ts-ignore\n hidden={!show}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {children}\n </TabsContentFrame>\n )\n }\n )\n)\n\nTabsContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs'\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope }\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n])\nconst useRovingFocusGroupScope = createRovingFocusGroupScope()\n\ntype TabsContextValue = {\n baseId: string\n value?: string\n onChange: (value: string) => void\n orientation?: TabsProps['orientation']\n dir?: TabsProps['dir']\n activationMode?: TabsProps['activationMode']\n size: SizeTokens\n registerTrigger: () => void\n unregisterTrigger: () => void\n triggersCount: number\n}\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME)\n\nconst TabsFrame = styled(SizableStack, {\n name: TABS_NAME,\n})\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>\ntype TabsFrameProps = GetProps<typeof TabsFrame>\ntype TabsProps = TabsFrameProps & {\n /** The value for the selected tab, if controlled */\n value?: string\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation']\n /**\n * The direction of navigation between toolbar items.\n */\n dir?: RovingFocusGroupProps['dir']\n /**\n * Whether a tab is activated automatically or manually. Only supported in web.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual'\n}\n\nexport const Tabs = withStaticProperties(\n TabsFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir,\n activationMode = 'automatic',\n size = '$true',\n ...tabsProps\n } = props\n const direction = useDirection(dir)\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue ?? '',\n })\n const [triggersCount, setTriggersCount] = React.useState(0)\n const registerTrigger = useEvent(() => setTriggersCount((v) => v + 1))\n const unregisterTrigger = useEvent(() => setTriggersCount((v) => v - 1))\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={React.useId()}\n value={value}\n onChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n size={size}\n registerTrigger={registerTrigger}\n triggersCount={triggersCount}\n unregisterTrigger={unregisterTrigger}\n >\n <TabsFrame\n direction={direction}\n // dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n )\n }\n )\n ),\n {\n List: TabsList,\n /**\n * @deprecated Use Tabs.Tab instead\n */\n Trigger: TabsTrigger,\n Tab: TabsTrigger,\n Content: TabsContent,\n }\n)\nTabs.displayName = TABS_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`\n}\n\nexport type {\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsTriggerLayout,\n TabsTabProps,\n TabsContentProps,\n TabLayout,\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { Group, GroupProps, useGroupItem } from '@tamagui/group'\nimport { RovingFocusGroup, createRovingFocusGroupScope } from '@tamagui/roving-focus'\nimport { SizableStack, ThemeableStack, ThemeableStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport { useDirection } from '@tamagui/use-direction'\nimport {\n GetProps,\n SizeTokens,\n Theme,\n composeEventHandlers,\n composeRefs,\n isWeb,\n styled,\n useEvent,\n withStaticProperties,\n} from '@tamagui/web'\nimport * as React from 'react'\nimport type { LayoutRectangle } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList'\n\nconst TabsListFrame = styled(Group, {\n name: TAB_LIST_NAME,\n focusable: true,\n})\n\ntype TabsListFrameProps = GroupProps\n\ntype TabsListProps = TabsListFrameProps & {\n /**\n * Whether to loop over after reaching the end or start of the items\n * @default true\n */\n loop?: boolean\n}\n\nconst TabsList = TabsListFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, children, ...listProps } = props\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n\n return (\n <RovingFocusGroup\n asChild\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n {...rovingFocusGroupScope}\n >\n <TabsListFrame\n role=\"tablist\"\n aria-orientation={context.orientation}\n ref={forwardedRef}\n axis={context.orientation}\n {...listProps}\n >\n {children}\n </TabsListFrame>\n </RovingFocusGroup>\n )\n }\n )\n)\n\nTabsList.displayName = TAB_LIST_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger'\n\nconst TabsTriggerFrame = styled(ThemeableStack, {\n name: TRIGGER_NAME,\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n backgroundColor: '$background',\n focusable: true,\n\n variants: {\n size: {\n '...size': getButtonSized,\n },\n\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n unstyled: {\n false: {\n backgroundColor: '$background',\n\n pressStyle: {\n backgroundColor: '$backgroundPress',\n },\n\n hoverStyle: {\n backgroundColor: '$backgroundHover',\n },\n\n focusStyle: {\n backgroundColor: '$backgroundFocus',\n },\n },\n },\n } as const,\n defaultVariants: {\n unstyled: false,\n },\n})\n\n/**\n * @deprecated Use `TabLayout` instead\n */\ntype TabsTriggerLayout = LayoutRectangle\ntype TabLayout = LayoutRectangle\ntype InteractionType = 'select' | 'focus' | 'hover'\n\ntype TabsTriggerFrameProps = GetProps<typeof TabsTriggerFrame>\n/**\n * @deprecated use `TabTabsProps` instead\n */\ntype TabsTriggerProps = TabsTriggerFrameProps & {\n /** The value for the tabs state to be changed to after activation of the trigger */\n value: string\n\n /** Used for making custom indicators when trigger interacted with */\n onInteraction?: (type: InteractionType, layout: TabLayout | null) => void\n}\n\ntype TabsTabProps = TabsTriggerProps\n\nconst TabsTrigger = TabsTriggerFrame.extractable(\n React.forwardRef<HTMLButtonElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value,\n disabled = false,\n onInteraction,\n ...triggerProps\n } = props\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n const isSelected = value === context.value\n const [layout, setLayout] = React.useState<TabLayout | null>(null)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const groupItemProps = useGroupItem({ disabled })\n\n React.useEffect(() => {\n context.registerTrigger()\n return () => context.unregisterTrigger()\n }, [])\n\n React.useEffect(() => {\n if (!triggerRef.current || !isWeb) return\n\n function getTriggerSize() {\n if (!triggerRef.current) return\n setLayout({\n width: triggerRef.current.offsetWidth,\n height: triggerRef.current.offsetHeight,\n x: triggerRef.current.offsetLeft,\n y: triggerRef.current.offsetTop,\n })\n }\n getTriggerSize()\n\n const observer = new ResizeObserver(getTriggerSize)\n observer.observe(triggerRef.current)\n\n return () => {\n if (!triggerRef.current) return\n observer.unobserve(triggerRef.current)\n }\n }, [context.triggersCount])\n\n React.useEffect(() => {\n if (isSelected && layout) {\n onInteraction?.('select', layout)\n }\n }, [isSelected, value, layout])\n\n return (\n <Theme name={isSelected ? 'active' : null}>\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <TabsTriggerFrame\n onLayout={(event) => {\n if (!isWeb) {\n setLayout(event.nativeEvent.layout)\n }\n }}\n onHoverIn={composeEventHandlers(props.onHoverIn, () => {\n if (layout) {\n onInteraction?.('hover', layout)\n }\n })}\n onHoverOut={composeEventHandlers(props.onHoverOut, () => {\n onInteraction?.('hover', null)\n })}\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n // @ts-ignore\n size={context.size}\n {...triggerProps}\n ref={composeRefs(forwardedRef, triggerRef)}\n onPress={composeEventHandlers(props.onPress ?? undefined, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n\n const webChecks =\n !isWeb ||\n ((event as unknown as React.MouseEvent).button === 0 &&\n (event as unknown as React.MouseEvent).ctrlKey === false)\n if (!disabled && !isSelected && webChecks) {\n context.onChange(value)\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault()\n }\n })}\n {...(isWeb && {\n type: 'button',\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n if ([' ', 'Enter'].includes(event.key)) {\n context.onChange(value)\n event.preventDefault()\n }\n }\n ),\n onFocus: composeEventHandlers(props.onFocus, (event) => {\n if (layout) {\n onInteraction?.('focus', layout)\n }\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual'\n if (!isSelected && !disabled && isAutomaticActivation) {\n context.onChange(value)\n }\n }),\n onBlur: composeEventHandlers(props.onFocus, () => {\n onInteraction?.('focus', null)\n }),\n })}\n {...groupItemProps}\n />\n </RovingFocusGroup.Item>\n </Theme>\n )\n }\n )\n)\n\nTabsTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent'\n\nconst TabsContentFrame = styled(ThemeableStack, {\n name: CONTENT_NAME,\n})\ntype TabsContentFrameProps = GetProps<typeof TabsContentFrame>\ntype TabsContentProps = TabsContentFrameProps & {\n /** Will show the content when the value matches the state of Tabs root */\n value: string\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Tamagui animations.\n */\n forceMount?: true\n}\n\nconst TabsContent = TabsContentFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props\n const context = useTabsContext(CONTENT_NAME, __scopeTabs)\n const isSelected = value === context.value\n const show = forceMount || isSelected\n\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n\n if (!show) return null\n return (\n <TabsContentFrame\n key={value}\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n // @ts-ignore\n hidden={!show}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {children}\n </TabsContentFrame>\n )\n }\n )\n)\n\nTabsContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs'\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope }\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n])\nconst useRovingFocusGroupScope = createRovingFocusGroupScope()\n\ntype TabsContextValue = {\n baseId: string\n value?: string\n onChange: (value: string) => void\n orientation?: TabsProps['orientation']\n dir?: TabsProps['dir']\n activationMode?: TabsProps['activationMode']\n size: SizeTokens\n registerTrigger: () => void\n unregisterTrigger: () => void\n triggersCount: number\n}\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME)\n\nconst TabsFrame = styled(SizableStack, {\n name: TABS_NAME,\n})\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>\ntype TabsFrameProps = GetProps<typeof TabsFrame>\ntype TabsProps = TabsFrameProps & {\n /** The value for the selected tab, if controlled */\n value?: string\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation']\n /**\n * The direction of navigation between toolbar items.\n */\n dir?: RovingFocusGroupProps['dir']\n /**\n * Whether a tab is activated automatically or manually. Only supported in web.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual'\n}\n\nexport const Tabs = withStaticProperties(\n TabsFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir,\n activationMode = 'automatic',\n size = '$true',\n ...tabsProps\n } = props\n const direction = useDirection(dir)\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue ?? '',\n })\n const [triggersCount, setTriggersCount] = React.useState(0)\n const registerTrigger = useEvent(() => setTriggersCount((v) => v + 1))\n const unregisterTrigger = useEvent(() => setTriggersCount((v) => v - 1))\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={React.useId()}\n value={value}\n onChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n size={size}\n registerTrigger={registerTrigger}\n triggersCount={triggersCount}\n unregisterTrigger={unregisterTrigger}\n >\n <TabsFrame\n direction={direction}\n // dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n )\n }\n )\n ),\n {\n List: TabsList,\n /**\n * @deprecated Use Tabs.Tab instead\n */\n Trigger: TabsTrigger,\n Tab: TabsTrigger,\n Content: TabsContent,\n }\n)\nTabs.displayName = TABS_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`\n}\n\nexport type {\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsTriggerLayout,\n TabsTabProps,\n TabsContentProps,\n TabLayout,\n}\n"],
|
|
5
|
+
"mappings": "AA0DU;AAzDV,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,OAAmB,oBAAoB;AAChD,SAAS,kBAAkB,mCAAmC;AAC9D,SAAS,cAAc,sBAA2C;AAClE,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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AA,MAEJ;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA;AAAA;AAAA;AAAA,IAIN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,SAAS;AAAA,EACX;AACF;AACA,KAAK,cAAc;AAInB,SAAS,cAAc,QAAgB,OAAe;AACpD,SAAO,GAAG,kBAAkB;AAC9B;AAEA,SAAS,cAAc,QAAgB,OAAe;AACpD,SAAO,GAAG,kBAAkB;AAC9B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/Tabs.mjs
CHANGED
|
@@ -20,9 +20,6 @@ const TAB_LIST_NAME = "TabsList";
|
|
|
20
20
|
const TabsListFrame = styled(Group, {
|
|
21
21
|
name: TAB_LIST_NAME,
|
|
22
22
|
focusable: true
|
|
23
|
-
// defaultVariants: {
|
|
24
|
-
// flexGrow: 0,
|
|
25
|
-
// },
|
|
26
23
|
});
|
|
27
24
|
const TabsList = TabsListFrame.extractable(
|
|
28
25
|
React.forwardRef(
|
|
@@ -63,6 +60,7 @@ const TabsTriggerFrame = styled(ThemeableStack, {
|
|
|
63
60
|
flexWrap: "nowrap",
|
|
64
61
|
flexDirection: "row",
|
|
65
62
|
cursor: "pointer",
|
|
63
|
+
backgroundColor: "$background",
|
|
66
64
|
focusable: true,
|
|
67
65
|
variants: {
|
|
68
66
|
size: {
|
package/dist/esm/Tabs.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Tabs.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { Group, GroupProps, useGroupItem } from '@tamagui/group'\nimport { RovingFocusGroup, createRovingFocusGroupScope } from '@tamagui/roving-focus'\nimport { SizableStack, ThemeableStack, ThemeableStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport { useDirection } from '@tamagui/use-direction'\nimport {\n GetProps,\n SizeTokens,\n Theme,\n composeEventHandlers,\n composeRefs,\n isWeb,\n styled,\n useEvent,\n withStaticProperties,\n} from '@tamagui/web'\nimport * as React from 'react'\nimport type { LayoutRectangle } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList'\n\nconst TabsListFrame = styled(Group, {\n name: TAB_LIST_NAME,\n focusable: true,\n // defaultVariants: {\n // flexGrow: 0,\n // },\n})\n\ntype TabsListFrameProps = GroupProps\n\ntype TabsListProps = TabsListFrameProps & {\n /**\n * Whether to loop over after reaching the end or start of the items\n * @default true\n */\n loop?: boolean\n}\n\nconst TabsList = TabsListFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, children, ...listProps } = props\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n\n return (\n <RovingFocusGroup\n asChild\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n {...rovingFocusGroupScope}\n >\n <TabsListFrame\n role=\"tablist\"\n aria-orientation={context.orientation}\n ref={forwardedRef}\n axis={context.orientation}\n {...listProps}\n >\n {children}\n </TabsListFrame>\n </RovingFocusGroup>\n )\n }\n )\n)\n\nTabsList.displayName = TAB_LIST_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger'\n\nconst TabsTriggerFrame = styled(ThemeableStack, {\n name: TRIGGER_NAME,\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n focusable: true,\n\n variants: {\n size: {\n '...size': getButtonSized,\n },\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n unstyled: {\n false: {\n backgroundColor: '$background',\n\n pressStyle: {\n backgroundColor: '$backgroundPress',\n },\n\n hoverStyle: {\n backgroundColor: '$backgroundHover',\n },\n\n focusStyle: {\n backgroundColor: '$backgroundFocus',\n },\n },\n },\n } as const,\n defaultVariants: {\n unstyled: false,\n },\n})\n\n/**\n * @deprecated Use `TabLayout` instead\n */\ntype TabsTriggerLayout = LayoutRectangle\ntype TabLayout = LayoutRectangle\ntype InteractionType = 'select' | 'focus' | 'hover'\n\ntype TabsTriggerFrameProps = GetProps<typeof TabsTriggerFrame>\n/**\n * @deprecated use `TabTabsProps` instead\n */\ntype TabsTriggerProps = TabsTriggerFrameProps & {\n /** The value for the tabs state to be changed to after activation of the trigger */\n value: string\n\n /** Used for making custom indicators when trigger interacted with */\n onInteraction?: (type: InteractionType, layout: TabLayout | null) => void\n}\n\ntype TabsTabProps = TabsTriggerProps\n\nconst TabsTrigger = TabsTriggerFrame.extractable(\n React.forwardRef<HTMLButtonElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value,\n disabled = false,\n onInteraction,\n ...triggerProps\n } = props\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n const isSelected = value === context.value\n const [layout, setLayout] = React.useState<TabLayout | null>(null)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const groupItemProps = useGroupItem({ disabled })\n\n React.useEffect(() => {\n context.registerTrigger()\n return () => context.unregisterTrigger()\n }, [])\n\n React.useEffect(() => {\n if (!triggerRef.current || !isWeb) return\n\n function getTriggerSize() {\n if (!triggerRef.current) return\n setLayout({\n width: triggerRef.current.offsetWidth,\n height: triggerRef.current.offsetHeight,\n x: triggerRef.current.offsetLeft,\n y: triggerRef.current.offsetTop,\n })\n }\n getTriggerSize()\n\n const observer = new ResizeObserver(getTriggerSize)\n observer.observe(triggerRef.current)\n\n return () => {\n if (!triggerRef.current) return\n observer.unobserve(triggerRef.current)\n }\n }, [context.triggersCount])\n\n React.useEffect(() => {\n if (isSelected && layout) {\n onInteraction?.('select', layout)\n }\n }, [isSelected, value, layout])\n\n return (\n <Theme name={isSelected ? 'active' : null}>\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <TabsTriggerFrame\n onLayout={(event) => {\n if (!isWeb) {\n setLayout(event.nativeEvent.layout)\n }\n }}\n onHoverIn={composeEventHandlers(props.onHoverIn, () => {\n if (layout) {\n onInteraction?.('hover', layout)\n }\n })}\n onHoverOut={composeEventHandlers(props.onHoverOut, () => {\n onInteraction?.('hover', null)\n })}\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n // @ts-ignore\n size={context.size}\n {...triggerProps}\n ref={composeRefs(forwardedRef, triggerRef)}\n onPress={composeEventHandlers(props.onPress ?? undefined, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n\n const webChecks =\n !isWeb ||\n ((event as unknown as React.MouseEvent).button === 0 &&\n (event as unknown as React.MouseEvent).ctrlKey === false)\n if (!disabled && !isSelected && webChecks) {\n context.onChange(value)\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault()\n }\n })}\n {...(isWeb && {\n type: 'button',\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n if ([' ', 'Enter'].includes(event.key)) {\n context.onChange(value)\n event.preventDefault()\n }\n }\n ),\n onFocus: composeEventHandlers(props.onFocus, (event) => {\n if (layout) {\n onInteraction?.('focus', layout)\n }\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual'\n if (!isSelected && !disabled && isAutomaticActivation) {\n context.onChange(value)\n }\n }),\n onBlur: composeEventHandlers(props.onFocus, () => {\n onInteraction?.('focus', null)\n }),\n })}\n {...groupItemProps}\n />\n </RovingFocusGroup.Item>\n </Theme>\n )\n }\n )\n)\n\nTabsTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent'\n\nconst TabsContentFrame = styled(ThemeableStack, {\n name: CONTENT_NAME,\n})\ntype TabsContentFrameProps = GetProps<typeof TabsContentFrame>\ntype TabsContentProps = TabsContentFrameProps & {\n /** Will show the content when the value matches the state of Tabs root */\n value: string\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Tamagui animations.\n */\n forceMount?: true\n}\n\nconst TabsContent = TabsContentFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props\n const context = useTabsContext(CONTENT_NAME, __scopeTabs)\n const isSelected = value === context.value\n const show = forceMount || isSelected\n\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n\n if (!show) return null\n return (\n <TabsContentFrame\n key={value}\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n // @ts-ignore\n hidden={!show}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {children}\n </TabsContentFrame>\n )\n }\n )\n)\n\nTabsContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs'\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope }\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n])\nconst useRovingFocusGroupScope = createRovingFocusGroupScope()\n\ntype TabsContextValue = {\n baseId: string\n value?: string\n onChange: (value: string) => void\n orientation?: TabsProps['orientation']\n dir?: TabsProps['dir']\n activationMode?: TabsProps['activationMode']\n size: SizeTokens\n registerTrigger: () => void\n unregisterTrigger: () => void\n triggersCount: number\n}\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME)\n\nconst TabsFrame = styled(SizableStack, {\n name: TABS_NAME,\n})\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>\ntype TabsFrameProps = GetProps<typeof TabsFrame>\ntype TabsProps = TabsFrameProps & {\n /** The value for the selected tab, if controlled */\n value?: string\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation']\n /**\n * The direction of navigation between toolbar items.\n */\n dir?: RovingFocusGroupProps['dir']\n /**\n * Whether a tab is activated automatically or manually. Only supported in web.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual'\n}\n\nexport const Tabs = withStaticProperties(\n TabsFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir,\n activationMode = 'automatic',\n size = '$true',\n ...tabsProps\n } = props\n const direction = useDirection(dir)\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue ?? '',\n })\n const [triggersCount, setTriggersCount] = React.useState(0)\n const registerTrigger = useEvent(() => setTriggersCount((v) => v + 1))\n const unregisterTrigger = useEvent(() => setTriggersCount((v) => v - 1))\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={React.useId()}\n value={value}\n onChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n size={size}\n registerTrigger={registerTrigger}\n triggersCount={triggersCount}\n unregisterTrigger={unregisterTrigger}\n >\n <TabsFrame\n direction={direction}\n // dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n )\n }\n )\n ),\n {\n List: TabsList,\n /**\n * @deprecated Use Tabs.Tab instead\n */\n Trigger: TabsTrigger,\n Tab: TabsTrigger,\n Content: TabsContent,\n }\n)\nTabs.displayName = TABS_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`\n}\n\nexport type {\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsTriggerLayout,\n TabsTabProps,\n TabsContentProps,\n TabLayout,\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { Group, GroupProps, useGroupItem } from '@tamagui/group'\nimport { RovingFocusGroup, createRovingFocusGroupScope } from '@tamagui/roving-focus'\nimport { SizableStack, ThemeableStack, ThemeableStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport { useDirection } from '@tamagui/use-direction'\nimport {\n GetProps,\n SizeTokens,\n Theme,\n composeEventHandlers,\n composeRefs,\n isWeb,\n styled,\n useEvent,\n withStaticProperties,\n} from '@tamagui/web'\nimport * as React from 'react'\nimport type { LayoutRectangle } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList'\n\nconst TabsListFrame = styled(Group, {\n name: TAB_LIST_NAME,\n focusable: true,\n})\n\ntype TabsListFrameProps = GroupProps\n\ntype TabsListProps = TabsListFrameProps & {\n /**\n * Whether to loop over after reaching the end or start of the items\n * @default true\n */\n loop?: boolean\n}\n\nconst TabsList = TabsListFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, children, ...listProps } = props\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n\n return (\n <RovingFocusGroup\n asChild\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n {...rovingFocusGroupScope}\n >\n <TabsListFrame\n role=\"tablist\"\n aria-orientation={context.orientation}\n ref={forwardedRef}\n axis={context.orientation}\n {...listProps}\n >\n {children}\n </TabsListFrame>\n </RovingFocusGroup>\n )\n }\n )\n)\n\nTabsList.displayName = TAB_LIST_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger'\n\nconst TabsTriggerFrame = styled(ThemeableStack, {\n name: TRIGGER_NAME,\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n backgroundColor: '$background',\n focusable: true,\n\n variants: {\n size: {\n '...size': getButtonSized,\n },\n\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n unstyled: {\n false: {\n backgroundColor: '$background',\n\n pressStyle: {\n backgroundColor: '$backgroundPress',\n },\n\n hoverStyle: {\n backgroundColor: '$backgroundHover',\n },\n\n focusStyle: {\n backgroundColor: '$backgroundFocus',\n },\n },\n },\n } as const,\n defaultVariants: {\n unstyled: false,\n },\n})\n\n/**\n * @deprecated Use `TabLayout` instead\n */\ntype TabsTriggerLayout = LayoutRectangle\ntype TabLayout = LayoutRectangle\ntype InteractionType = 'select' | 'focus' | 'hover'\n\ntype TabsTriggerFrameProps = GetProps<typeof TabsTriggerFrame>\n/**\n * @deprecated use `TabTabsProps` instead\n */\ntype TabsTriggerProps = TabsTriggerFrameProps & {\n /** The value for the tabs state to be changed to after activation of the trigger */\n value: string\n\n /** Used for making custom indicators when trigger interacted with */\n onInteraction?: (type: InteractionType, layout: TabLayout | null) => void\n}\n\ntype TabsTabProps = TabsTriggerProps\n\nconst TabsTrigger = TabsTriggerFrame.extractable(\n React.forwardRef<HTMLButtonElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value,\n disabled = false,\n onInteraction,\n ...triggerProps\n } = props\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n const isSelected = value === context.value\n const [layout, setLayout] = React.useState<TabLayout | null>(null)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const groupItemProps = useGroupItem({ disabled })\n\n React.useEffect(() => {\n context.registerTrigger()\n return () => context.unregisterTrigger()\n }, [])\n\n React.useEffect(() => {\n if (!triggerRef.current || !isWeb) return\n\n function getTriggerSize() {\n if (!triggerRef.current) return\n setLayout({\n width: triggerRef.current.offsetWidth,\n height: triggerRef.current.offsetHeight,\n x: triggerRef.current.offsetLeft,\n y: triggerRef.current.offsetTop,\n })\n }\n getTriggerSize()\n\n const observer = new ResizeObserver(getTriggerSize)\n observer.observe(triggerRef.current)\n\n return () => {\n if (!triggerRef.current) return\n observer.unobserve(triggerRef.current)\n }\n }, [context.triggersCount])\n\n React.useEffect(() => {\n if (isSelected && layout) {\n onInteraction?.('select', layout)\n }\n }, [isSelected, value, layout])\n\n return (\n <Theme name={isSelected ? 'active' : null}>\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <TabsTriggerFrame\n onLayout={(event) => {\n if (!isWeb) {\n setLayout(event.nativeEvent.layout)\n }\n }}\n onHoverIn={composeEventHandlers(props.onHoverIn, () => {\n if (layout) {\n onInteraction?.('hover', layout)\n }\n })}\n onHoverOut={composeEventHandlers(props.onHoverOut, () => {\n onInteraction?.('hover', null)\n })}\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n // @ts-ignore\n size={context.size}\n {...triggerProps}\n ref={composeRefs(forwardedRef, triggerRef)}\n onPress={composeEventHandlers(props.onPress ?? undefined, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n\n const webChecks =\n !isWeb ||\n ((event as unknown as React.MouseEvent).button === 0 &&\n (event as unknown as React.MouseEvent).ctrlKey === false)\n if (!disabled && !isSelected && webChecks) {\n context.onChange(value)\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault()\n }\n })}\n {...(isWeb && {\n type: 'button',\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n if ([' ', 'Enter'].includes(event.key)) {\n context.onChange(value)\n event.preventDefault()\n }\n }\n ),\n onFocus: composeEventHandlers(props.onFocus, (event) => {\n if (layout) {\n onInteraction?.('focus', layout)\n }\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual'\n if (!isSelected && !disabled && isAutomaticActivation) {\n context.onChange(value)\n }\n }),\n onBlur: composeEventHandlers(props.onFocus, () => {\n onInteraction?.('focus', null)\n }),\n })}\n {...groupItemProps}\n />\n </RovingFocusGroup.Item>\n </Theme>\n )\n }\n )\n)\n\nTabsTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent'\n\nconst TabsContentFrame = styled(ThemeableStack, {\n name: CONTENT_NAME,\n})\ntype TabsContentFrameProps = GetProps<typeof TabsContentFrame>\ntype TabsContentProps = TabsContentFrameProps & {\n /** Will show the content when the value matches the state of Tabs root */\n value: string\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Tamagui animations.\n */\n forceMount?: true\n}\n\nconst TabsContent = TabsContentFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props\n const context = useTabsContext(CONTENT_NAME, __scopeTabs)\n const isSelected = value === context.value\n const show = forceMount || isSelected\n\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n\n if (!show) return null\n return (\n <TabsContentFrame\n key={value}\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n // @ts-ignore\n hidden={!show}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {children}\n </TabsContentFrame>\n )\n }\n )\n)\n\nTabsContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs'\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope }\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n])\nconst useRovingFocusGroupScope = createRovingFocusGroupScope()\n\ntype TabsContextValue = {\n baseId: string\n value?: string\n onChange: (value: string) => void\n orientation?: TabsProps['orientation']\n dir?: TabsProps['dir']\n activationMode?: TabsProps['activationMode']\n size: SizeTokens\n registerTrigger: () => void\n unregisterTrigger: () => void\n triggersCount: number\n}\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME)\n\nconst TabsFrame = styled(SizableStack, {\n name: TABS_NAME,\n})\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>\ntype TabsFrameProps = GetProps<typeof TabsFrame>\ntype TabsProps = TabsFrameProps & {\n /** The value for the selected tab, if controlled */\n value?: string\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation']\n /**\n * The direction of navigation between toolbar items.\n */\n dir?: RovingFocusGroupProps['dir']\n /**\n * Whether a tab is activated automatically or manually. Only supported in web.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual'\n}\n\nexport const Tabs = withStaticProperties(\n TabsFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir,\n activationMode = 'automatic',\n size = '$true',\n ...tabsProps\n } = props\n const direction = useDirection(dir)\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue ?? '',\n })\n const [triggersCount, setTriggersCount] = React.useState(0)\n const registerTrigger = useEvent(() => setTriggersCount((v) => v + 1))\n const unregisterTrigger = useEvent(() => setTriggersCount((v) => v - 1))\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={React.useId()}\n value={value}\n onChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n size={size}\n registerTrigger={registerTrigger}\n triggersCount={triggersCount}\n unregisterTrigger={unregisterTrigger}\n >\n <TabsFrame\n direction={direction}\n // dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n )\n }\n )\n ),\n {\n List: TabsList,\n /**\n * @deprecated Use Tabs.Tab instead\n */\n Trigger: TabsTrigger,\n Tab: TabsTrigger,\n Content: TabsContent,\n }\n)\nTabs.displayName = TABS_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`\n}\n\nexport type {\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsTriggerLayout,\n TabsTabProps,\n TabsContentProps,\n TabLayout,\n}\n"],
|
|
5
|
+
"mappings": "AA0DU;AAzDV,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,OAAmB,oBAAoB;AAChD,SAAS,kBAAkB,mCAAmC;AAC9D,SAAS,cAAc,sBAA2C;AAClE,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,YAAY,WAAW;AAOvB,MAAM,gBAAgB;AAEtB,MAAM,gBAAgB,OAAO,OAAO;AAAA,EAClC,MAAM;AAAA,EACN,WAAW;AACb,CAAC;AAYD,MAAM,WAAW,cAAc;AAAA,EAC7B,MAAM;AAAA,IACJ,CAAC,OAAmC,iBAAiB;AACnD,YAAM,EAAE,aAAa,OAAO,MAAM,UAAU,GAAG,UAAU,IAAI;AAC7D,YAAM,UAAU,eAAe,eAAe,WAAW;AACzD,YAAM,wBAAwB,yBAAyB,WAAW;AAElE,aACE;AAAA,QAAC;AAAA;AAAA,UACC,SAAO;AAAA,UACP,aAAa,QAAQ;AAAA,UACrB,KAAK,QAAQ;AAAA,UACb;AAAA,UACC,GAAG;AAAA,UAEJ;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,oBAAkB,QAAQ;AAAA,cAC1B,KAAK;AAAA,cACL,MAAM,QAAQ;AAAA,cACb,GAAG;AAAA,cAEH;AAAA;AAAA,UACH;AAAA;AAAA,MACF;AAAA,IAEJ;AAAA,EACF;AACF;AAEA,SAAS,cAAc;AAMvB,MAA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AC;AACD,cAAM,CAAC,eAAe,gBAAgB,IAAI,MAAM,SAAS,CAAC;AAC1D,cAAM,kBAAkB,SAAS,MAAM,iBAAiB,CAAC,MAAM,IAAI,CAAC,CAAC;AACrE,cAAM,oBAAoB,SAAS,MAAM,iBAAiB,CAAC,MAAM,IAAI,CAAC,CAAC;AAEvE,eACE;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,YACP,QAAQ,MAAM,MAAM;AAAA,YACpB;AAAA,YACA,UAAU;AAAA,YACV;AAAA,YACA,KAAK;AAAA,YACL;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YAEA;AAAA,cAAC;AAAA;AAAA,gBACC;AAAA,gBAEA,oBAAkB;AAAA,gBACjB,GAAG;AAAA,gBACJ,KAAK;AAAA;AAAA,YACP;AAAA;AAAA,QACF;AAAA,MAEJ;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA;AAAA;AAAA;AAAA,IAIN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,SAAS;AAAA,EACX;AACF;AACA,KAAK,cAAc;AAInB,SAAS,cAAc,QAAgB,OAAe;AACpD,SAAO,GAAG,kBAAkB;AAC9B;AAEA,SAAS,cAAc,QAAgB,OAAe;AACpD,SAAO,GAAG,kBAAkB;AAC9B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/Tabs.js
CHANGED
|
@@ -19,9 +19,6 @@ const TAB_LIST_NAME = "TabsList";
|
|
|
19
19
|
const TabsListFrame = styled(Group, {
|
|
20
20
|
name: TAB_LIST_NAME,
|
|
21
21
|
focusable: true
|
|
22
|
-
// defaultVariants: {
|
|
23
|
-
// flexGrow: 0,
|
|
24
|
-
// },
|
|
25
22
|
});
|
|
26
23
|
const TabsList = TabsListFrame.extractable(
|
|
27
24
|
React.forwardRef(
|
|
@@ -54,6 +51,7 @@ const TabsTriggerFrame = styled(ThemeableStack, {
|
|
|
54
51
|
flexWrap: "nowrap",
|
|
55
52
|
flexDirection: "row",
|
|
56
53
|
cursor: "pointer",
|
|
54
|
+
backgroundColor: "$background",
|
|
57
55
|
focusable: true,
|
|
58
56
|
variants: {
|
|
59
57
|
size: {
|
package/dist/jsx/Tabs.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Tabs.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { Group, GroupProps, useGroupItem } from '@tamagui/group'\nimport { RovingFocusGroup, createRovingFocusGroupScope } from '@tamagui/roving-focus'\nimport { SizableStack, ThemeableStack, ThemeableStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport { useDirection } from '@tamagui/use-direction'\nimport {\n GetProps,\n SizeTokens,\n Theme,\n composeEventHandlers,\n composeRefs,\n isWeb,\n styled,\n useEvent,\n withStaticProperties,\n} from '@tamagui/web'\nimport * as React from 'react'\nimport type { LayoutRectangle } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList'\n\nconst TabsListFrame = styled(Group, {\n name: TAB_LIST_NAME,\n focusable: true,\n // defaultVariants: {\n // flexGrow: 0,\n // },\n})\n\ntype TabsListFrameProps = GroupProps\n\ntype TabsListProps = TabsListFrameProps & {\n /**\n * Whether to loop over after reaching the end or start of the items\n * @default true\n */\n loop?: boolean\n}\n\nconst TabsList = TabsListFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, children, ...listProps } = props\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n\n return (\n <RovingFocusGroup\n asChild\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n {...rovingFocusGroupScope}\n >\n <TabsListFrame\n role=\"tablist\"\n aria-orientation={context.orientation}\n ref={forwardedRef}\n axis={context.orientation}\n {...listProps}\n >\n {children}\n </TabsListFrame>\n </RovingFocusGroup>\n )\n }\n )\n)\n\nTabsList.displayName = TAB_LIST_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger'\n\nconst TabsTriggerFrame = styled(ThemeableStack, {\n name: TRIGGER_NAME,\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n focusable: true,\n\n variants: {\n size: {\n '...size': getButtonSized,\n },\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n unstyled: {\n false: {\n backgroundColor: '$background',\n\n pressStyle: {\n backgroundColor: '$backgroundPress',\n },\n\n hoverStyle: {\n backgroundColor: '$backgroundHover',\n },\n\n focusStyle: {\n backgroundColor: '$backgroundFocus',\n },\n },\n },\n } as const,\n defaultVariants: {\n unstyled: false,\n },\n})\n\n/**\n * @deprecated Use `TabLayout` instead\n */\ntype TabsTriggerLayout = LayoutRectangle\ntype TabLayout = LayoutRectangle\ntype InteractionType = 'select' | 'focus' | 'hover'\n\ntype TabsTriggerFrameProps = GetProps<typeof TabsTriggerFrame>\n/**\n * @deprecated use `TabTabsProps` instead\n */\ntype TabsTriggerProps = TabsTriggerFrameProps & {\n /** The value for the tabs state to be changed to after activation of the trigger */\n value: string\n\n /** Used for making custom indicators when trigger interacted with */\n onInteraction?: (type: InteractionType, layout: TabLayout | null) => void\n}\n\ntype TabsTabProps = TabsTriggerProps\n\nconst TabsTrigger = TabsTriggerFrame.extractable(\n React.forwardRef<HTMLButtonElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value,\n disabled = false,\n onInteraction,\n ...triggerProps\n } = props\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n const isSelected = value === context.value\n const [layout, setLayout] = React.useState<TabLayout | null>(null)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const groupItemProps = useGroupItem({ disabled })\n\n React.useEffect(() => {\n context.registerTrigger()\n return () => context.unregisterTrigger()\n }, [])\n\n React.useEffect(() => {\n if (!triggerRef.current || !isWeb) return\n\n function getTriggerSize() {\n if (!triggerRef.current) return\n setLayout({\n width: triggerRef.current.offsetWidth,\n height: triggerRef.current.offsetHeight,\n x: triggerRef.current.offsetLeft,\n y: triggerRef.current.offsetTop,\n })\n }\n getTriggerSize()\n\n const observer = new ResizeObserver(getTriggerSize)\n observer.observe(triggerRef.current)\n\n return () => {\n if (!triggerRef.current) return\n observer.unobserve(triggerRef.current)\n }\n }, [context.triggersCount])\n\n React.useEffect(() => {\n if (isSelected && layout) {\n onInteraction?.('select', layout)\n }\n }, [isSelected, value, layout])\n\n return (\n <Theme name={isSelected ? 'active' : null}>\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <TabsTriggerFrame\n onLayout={(event) => {\n if (!isWeb) {\n setLayout(event.nativeEvent.layout)\n }\n }}\n onHoverIn={composeEventHandlers(props.onHoverIn, () => {\n if (layout) {\n onInteraction?.('hover', layout)\n }\n })}\n onHoverOut={composeEventHandlers(props.onHoverOut, () => {\n onInteraction?.('hover', null)\n })}\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n // @ts-ignore\n size={context.size}\n {...triggerProps}\n ref={composeRefs(forwardedRef, triggerRef)}\n onPress={composeEventHandlers(props.onPress ?? undefined, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n\n const webChecks =\n !isWeb ||\n ((event as unknown as React.MouseEvent).button === 0 &&\n (event as unknown as React.MouseEvent).ctrlKey === false)\n if (!disabled && !isSelected && webChecks) {\n context.onChange(value)\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault()\n }\n })}\n {...(isWeb && {\n type: 'button',\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n if ([' ', 'Enter'].includes(event.key)) {\n context.onChange(value)\n event.preventDefault()\n }\n }\n ),\n onFocus: composeEventHandlers(props.onFocus, (event) => {\n if (layout) {\n onInteraction?.('focus', layout)\n }\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual'\n if (!isSelected && !disabled && isAutomaticActivation) {\n context.onChange(value)\n }\n }),\n onBlur: composeEventHandlers(props.onFocus, () => {\n onInteraction?.('focus', null)\n }),\n })}\n {...groupItemProps}\n />\n </RovingFocusGroup.Item>\n </Theme>\n )\n }\n )\n)\n\nTabsTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent'\n\nconst TabsContentFrame = styled(ThemeableStack, {\n name: CONTENT_NAME,\n})\ntype TabsContentFrameProps = GetProps<typeof TabsContentFrame>\ntype TabsContentProps = TabsContentFrameProps & {\n /** Will show the content when the value matches the state of Tabs root */\n value: string\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Tamagui animations.\n */\n forceMount?: true\n}\n\nconst TabsContent = TabsContentFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props\n const context = useTabsContext(CONTENT_NAME, __scopeTabs)\n const isSelected = value === context.value\n const show = forceMount || isSelected\n\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n\n if (!show) return null\n return (\n <TabsContentFrame\n key={value}\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n // @ts-ignore\n hidden={!show}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {children}\n </TabsContentFrame>\n )\n }\n )\n)\n\nTabsContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs'\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope }\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n])\nconst useRovingFocusGroupScope = createRovingFocusGroupScope()\n\ntype TabsContextValue = {\n baseId: string\n value?: string\n onChange: (value: string) => void\n orientation?: TabsProps['orientation']\n dir?: TabsProps['dir']\n activationMode?: TabsProps['activationMode']\n size: SizeTokens\n registerTrigger: () => void\n unregisterTrigger: () => void\n triggersCount: number\n}\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME)\n\nconst TabsFrame = styled(SizableStack, {\n name: TABS_NAME,\n})\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>\ntype TabsFrameProps = GetProps<typeof TabsFrame>\ntype TabsProps = TabsFrameProps & {\n /** The value for the selected tab, if controlled */\n value?: string\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation']\n /**\n * The direction of navigation between toolbar items.\n */\n dir?: RovingFocusGroupProps['dir']\n /**\n * Whether a tab is activated automatically or manually. Only supported in web.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual'\n}\n\nexport const Tabs = withStaticProperties(\n TabsFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir,\n activationMode = 'automatic',\n size = '$true',\n ...tabsProps\n } = props\n const direction = useDirection(dir)\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue ?? '',\n })\n const [triggersCount, setTriggersCount] = React.useState(0)\n const registerTrigger = useEvent(() => setTriggersCount((v) => v + 1))\n const unregisterTrigger = useEvent(() => setTriggersCount((v) => v - 1))\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={React.useId()}\n value={value}\n onChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n size={size}\n registerTrigger={registerTrigger}\n triggersCount={triggersCount}\n unregisterTrigger={unregisterTrigger}\n >\n <TabsFrame\n direction={direction}\n // dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n )\n }\n )\n ),\n {\n List: TabsList,\n /**\n * @deprecated Use Tabs.Tab instead\n */\n Trigger: TabsTrigger,\n Tab: TabsTrigger,\n Content: TabsContent,\n }\n)\nTabs.displayName = TABS_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`\n}\n\nexport type {\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsTriggerLayout,\n TabsTabProps,\n TabsContentProps,\n TabLayout,\n}\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,OAAmB,oBAAoB;AAChD,SAAS,kBAAkB,mCAAmC;AAC9D,SAAS,cAAc,sBAA2C;AAClE,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,YAAY,WAAW;AAOvB,MAAM,gBAAgB;AAEtB,MAAM,gBAAgB,OAAO,OAAO;AAAA,EAClC,MAAM;AAAA,EACN,WAAW;
|
|
4
|
+
"sourcesContent": ["import type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { Group, GroupProps, useGroupItem } from '@tamagui/group'\nimport { RovingFocusGroup, createRovingFocusGroupScope } from '@tamagui/roving-focus'\nimport { SizableStack, ThemeableStack, ThemeableStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport { useDirection } from '@tamagui/use-direction'\nimport {\n GetProps,\n SizeTokens,\n Theme,\n composeEventHandlers,\n composeRefs,\n isWeb,\n styled,\n useEvent,\n withStaticProperties,\n} from '@tamagui/web'\nimport * as React from 'react'\nimport type { LayoutRectangle } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList'\n\nconst TabsListFrame = styled(Group, {\n name: TAB_LIST_NAME,\n focusable: true,\n})\n\ntype TabsListFrameProps = GroupProps\n\ntype TabsListProps = TabsListFrameProps & {\n /**\n * Whether to loop over after reaching the end or start of the items\n * @default true\n */\n loop?: boolean\n}\n\nconst TabsList = TabsListFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, children, ...listProps } = props\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n\n return (\n <RovingFocusGroup\n asChild\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n {...rovingFocusGroupScope}\n >\n <TabsListFrame\n role=\"tablist\"\n aria-orientation={context.orientation}\n ref={forwardedRef}\n axis={context.orientation}\n {...listProps}\n >\n {children}\n </TabsListFrame>\n </RovingFocusGroup>\n )\n }\n )\n)\n\nTabsList.displayName = TAB_LIST_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger'\n\nconst TabsTriggerFrame = styled(ThemeableStack, {\n name: TRIGGER_NAME,\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n backgroundColor: '$background',\n focusable: true,\n\n variants: {\n size: {\n '...size': getButtonSized,\n },\n\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n unstyled: {\n false: {\n backgroundColor: '$background',\n\n pressStyle: {\n backgroundColor: '$backgroundPress',\n },\n\n hoverStyle: {\n backgroundColor: '$backgroundHover',\n },\n\n focusStyle: {\n backgroundColor: '$backgroundFocus',\n },\n },\n },\n } as const,\n defaultVariants: {\n unstyled: false,\n },\n})\n\n/**\n * @deprecated Use `TabLayout` instead\n */\ntype TabsTriggerLayout = LayoutRectangle\ntype TabLayout = LayoutRectangle\ntype InteractionType = 'select' | 'focus' | 'hover'\n\ntype TabsTriggerFrameProps = GetProps<typeof TabsTriggerFrame>\n/**\n * @deprecated use `TabTabsProps` instead\n */\ntype TabsTriggerProps = TabsTriggerFrameProps & {\n /** The value for the tabs state to be changed to after activation of the trigger */\n value: string\n\n /** Used for making custom indicators when trigger interacted with */\n onInteraction?: (type: InteractionType, layout: TabLayout | null) => void\n}\n\ntype TabsTabProps = TabsTriggerProps\n\nconst TabsTrigger = TabsTriggerFrame.extractable(\n React.forwardRef<HTMLButtonElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value,\n disabled = false,\n onInteraction,\n ...triggerProps\n } = props\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n const isSelected = value === context.value\n const [layout, setLayout] = React.useState<TabLayout | null>(null)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const groupItemProps = useGroupItem({ disabled })\n\n React.useEffect(() => {\n context.registerTrigger()\n return () => context.unregisterTrigger()\n }, [])\n\n React.useEffect(() => {\n if (!triggerRef.current || !isWeb) return\n\n function getTriggerSize() {\n if (!triggerRef.current) return\n setLayout({\n width: triggerRef.current.offsetWidth,\n height: triggerRef.current.offsetHeight,\n x: triggerRef.current.offsetLeft,\n y: triggerRef.current.offsetTop,\n })\n }\n getTriggerSize()\n\n const observer = new ResizeObserver(getTriggerSize)\n observer.observe(triggerRef.current)\n\n return () => {\n if (!triggerRef.current) return\n observer.unobserve(triggerRef.current)\n }\n }, [context.triggersCount])\n\n React.useEffect(() => {\n if (isSelected && layout) {\n onInteraction?.('select', layout)\n }\n }, [isSelected, value, layout])\n\n return (\n <Theme name={isSelected ? 'active' : null}>\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <TabsTriggerFrame\n onLayout={(event) => {\n if (!isWeb) {\n setLayout(event.nativeEvent.layout)\n }\n }}\n onHoverIn={composeEventHandlers(props.onHoverIn, () => {\n if (layout) {\n onInteraction?.('hover', layout)\n }\n })}\n onHoverOut={composeEventHandlers(props.onHoverOut, () => {\n onInteraction?.('hover', null)\n })}\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n // @ts-ignore\n size={context.size}\n {...triggerProps}\n ref={composeRefs(forwardedRef, triggerRef)}\n onPress={composeEventHandlers(props.onPress ?? undefined, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n\n const webChecks =\n !isWeb ||\n ((event as unknown as React.MouseEvent).button === 0 &&\n (event as unknown as React.MouseEvent).ctrlKey === false)\n if (!disabled && !isSelected && webChecks) {\n context.onChange(value)\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault()\n }\n })}\n {...(isWeb && {\n type: 'button',\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n if ([' ', 'Enter'].includes(event.key)) {\n context.onChange(value)\n event.preventDefault()\n }\n }\n ),\n onFocus: composeEventHandlers(props.onFocus, (event) => {\n if (layout) {\n onInteraction?.('focus', layout)\n }\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual'\n if (!isSelected && !disabled && isAutomaticActivation) {\n context.onChange(value)\n }\n }),\n onBlur: composeEventHandlers(props.onFocus, () => {\n onInteraction?.('focus', null)\n }),\n })}\n {...groupItemProps}\n />\n </RovingFocusGroup.Item>\n </Theme>\n )\n }\n )\n)\n\nTabsTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent'\n\nconst TabsContentFrame = styled(ThemeableStack, {\n name: CONTENT_NAME,\n})\ntype TabsContentFrameProps = GetProps<typeof TabsContentFrame>\ntype TabsContentProps = TabsContentFrameProps & {\n /** Will show the content when the value matches the state of Tabs root */\n value: string\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Tamagui animations.\n */\n forceMount?: true\n}\n\nconst TabsContent = TabsContentFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props\n const context = useTabsContext(CONTENT_NAME, __scopeTabs)\n const isSelected = value === context.value\n const show = forceMount || isSelected\n\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n\n if (!show) return null\n return (\n <TabsContentFrame\n key={value}\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n // @ts-ignore\n hidden={!show}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {children}\n </TabsContentFrame>\n )\n }\n )\n)\n\nTabsContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs'\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope }\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n])\nconst useRovingFocusGroupScope = createRovingFocusGroupScope()\n\ntype TabsContextValue = {\n baseId: string\n value?: string\n onChange: (value: string) => void\n orientation?: TabsProps['orientation']\n dir?: TabsProps['dir']\n activationMode?: TabsProps['activationMode']\n size: SizeTokens\n registerTrigger: () => void\n unregisterTrigger: () => void\n triggersCount: number\n}\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME)\n\nconst TabsFrame = styled(SizableStack, {\n name: TABS_NAME,\n})\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>\ntype TabsFrameProps = GetProps<typeof TabsFrame>\ntype TabsProps = TabsFrameProps & {\n /** The value for the selected tab, if controlled */\n value?: string\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation']\n /**\n * The direction of navigation between toolbar items.\n */\n dir?: RovingFocusGroupProps['dir']\n /**\n * Whether a tab is activated automatically or manually. Only supported in web.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual'\n}\n\nexport const Tabs = withStaticProperties(\n TabsFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir,\n activationMode = 'automatic',\n size = '$true',\n ...tabsProps\n } = props\n const direction = useDirection(dir)\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue ?? '',\n })\n const [triggersCount, setTriggersCount] = React.useState(0)\n const registerTrigger = useEvent(() => setTriggersCount((v) => v + 1))\n const unregisterTrigger = useEvent(() => setTriggersCount((v) => v - 1))\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={React.useId()}\n value={value}\n onChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n size={size}\n registerTrigger={registerTrigger}\n triggersCount={triggersCount}\n unregisterTrigger={unregisterTrigger}\n >\n <TabsFrame\n direction={direction}\n // dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n )\n }\n )\n ),\n {\n List: TabsList,\n /**\n * @deprecated Use Tabs.Tab instead\n */\n Trigger: TabsTrigger,\n Tab: TabsTrigger,\n Content: TabsContent,\n }\n)\nTabs.displayName = TABS_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`\n}\n\nexport type {\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsTriggerLayout,\n TabsTabProps,\n TabsContentProps,\n TabLayout,\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,OAAmB,oBAA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AAAA,UAEX,kBAAkB;AAAA,cACd;AAAA,UACJ,KAAK;AAAA,QACP,EACF,EApBC;AAAA,MAsBL;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA;AAAA;AAAA;AAAA,IAIN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,SAAS;AAAA,EACX;AACF;AACA,KAAK,cAAc;AAInB,SAAS,cAAc,QAAgB,OAAe;AACpD,SAAO,GAAG,kBAAkB;AAC9B;AAEA,SAAS,cAAc,QAAgB,OAAe;AACpD,SAAO,GAAG,kBAAkB;AAC9B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/Tabs.mjs
CHANGED
|
@@ -19,9 +19,6 @@ const TAB_LIST_NAME = "TabsList";
|
|
|
19
19
|
const TabsListFrame = styled(Group, {
|
|
20
20
|
name: TAB_LIST_NAME,
|
|
21
21
|
focusable: true
|
|
22
|
-
// defaultVariants: {
|
|
23
|
-
// flexGrow: 0,
|
|
24
|
-
// },
|
|
25
22
|
});
|
|
26
23
|
const TabsList = TabsListFrame.extractable(
|
|
27
24
|
React.forwardRef(
|
|
@@ -54,6 +51,7 @@ const TabsTriggerFrame = styled(ThemeableStack, {
|
|
|
54
51
|
flexWrap: "nowrap",
|
|
55
52
|
flexDirection: "row",
|
|
56
53
|
cursor: "pointer",
|
|
54
|
+
backgroundColor: "$background",
|
|
57
55
|
focusable: true,
|
|
58
56
|
variants: {
|
|
59
57
|
size: {
|
package/dist/jsx/Tabs.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Tabs.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { Group, GroupProps, useGroupItem } from '@tamagui/group'\nimport { RovingFocusGroup, createRovingFocusGroupScope } from '@tamagui/roving-focus'\nimport { SizableStack, ThemeableStack, ThemeableStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport { useDirection } from '@tamagui/use-direction'\nimport {\n GetProps,\n SizeTokens,\n Theme,\n composeEventHandlers,\n composeRefs,\n isWeb,\n styled,\n useEvent,\n withStaticProperties,\n} from '@tamagui/web'\nimport * as React from 'react'\nimport type { LayoutRectangle } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList'\n\nconst TabsListFrame = styled(Group, {\n name: TAB_LIST_NAME,\n focusable: true,\n // defaultVariants: {\n // flexGrow: 0,\n // },\n})\n\ntype TabsListFrameProps = GroupProps\n\ntype TabsListProps = TabsListFrameProps & {\n /**\n * Whether to loop over after reaching the end or start of the items\n * @default true\n */\n loop?: boolean\n}\n\nconst TabsList = TabsListFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, children, ...listProps } = props\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n\n return (\n <RovingFocusGroup\n asChild\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n {...rovingFocusGroupScope}\n >\n <TabsListFrame\n role=\"tablist\"\n aria-orientation={context.orientation}\n ref={forwardedRef}\n axis={context.orientation}\n {...listProps}\n >\n {children}\n </TabsListFrame>\n </RovingFocusGroup>\n )\n }\n )\n)\n\nTabsList.displayName = TAB_LIST_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger'\n\nconst TabsTriggerFrame = styled(ThemeableStack, {\n name: TRIGGER_NAME,\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n focusable: true,\n\n variants: {\n size: {\n '...size': getButtonSized,\n },\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n unstyled: {\n false: {\n backgroundColor: '$background',\n\n pressStyle: {\n backgroundColor: '$backgroundPress',\n },\n\n hoverStyle: {\n backgroundColor: '$backgroundHover',\n },\n\n focusStyle: {\n backgroundColor: '$backgroundFocus',\n },\n },\n },\n } as const,\n defaultVariants: {\n unstyled: false,\n },\n})\n\n/**\n * @deprecated Use `TabLayout` instead\n */\ntype TabsTriggerLayout = LayoutRectangle\ntype TabLayout = LayoutRectangle\ntype InteractionType = 'select' | 'focus' | 'hover'\n\ntype TabsTriggerFrameProps = GetProps<typeof TabsTriggerFrame>\n/**\n * @deprecated use `TabTabsProps` instead\n */\ntype TabsTriggerProps = TabsTriggerFrameProps & {\n /** The value for the tabs state to be changed to after activation of the trigger */\n value: string\n\n /** Used for making custom indicators when trigger interacted with */\n onInteraction?: (type: InteractionType, layout: TabLayout | null) => void\n}\n\ntype TabsTabProps = TabsTriggerProps\n\nconst TabsTrigger = TabsTriggerFrame.extractable(\n React.forwardRef<HTMLButtonElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value,\n disabled = false,\n onInteraction,\n ...triggerProps\n } = props\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n const isSelected = value === context.value\n const [layout, setLayout] = React.useState<TabLayout | null>(null)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const groupItemProps = useGroupItem({ disabled })\n\n React.useEffect(() => {\n context.registerTrigger()\n return () => context.unregisterTrigger()\n }, [])\n\n React.useEffect(() => {\n if (!triggerRef.current || !isWeb) return\n\n function getTriggerSize() {\n if (!triggerRef.current) return\n setLayout({\n width: triggerRef.current.offsetWidth,\n height: triggerRef.current.offsetHeight,\n x: triggerRef.current.offsetLeft,\n y: triggerRef.current.offsetTop,\n })\n }\n getTriggerSize()\n\n const observer = new ResizeObserver(getTriggerSize)\n observer.observe(triggerRef.current)\n\n return () => {\n if (!triggerRef.current) return\n observer.unobserve(triggerRef.current)\n }\n }, [context.triggersCount])\n\n React.useEffect(() => {\n if (isSelected && layout) {\n onInteraction?.('select', layout)\n }\n }, [isSelected, value, layout])\n\n return (\n <Theme name={isSelected ? 'active' : null}>\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <TabsTriggerFrame\n onLayout={(event) => {\n if (!isWeb) {\n setLayout(event.nativeEvent.layout)\n }\n }}\n onHoverIn={composeEventHandlers(props.onHoverIn, () => {\n if (layout) {\n onInteraction?.('hover', layout)\n }\n })}\n onHoverOut={composeEventHandlers(props.onHoverOut, () => {\n onInteraction?.('hover', null)\n })}\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n // @ts-ignore\n size={context.size}\n {...triggerProps}\n ref={composeRefs(forwardedRef, triggerRef)}\n onPress={composeEventHandlers(props.onPress ?? undefined, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n\n const webChecks =\n !isWeb ||\n ((event as unknown as React.MouseEvent).button === 0 &&\n (event as unknown as React.MouseEvent).ctrlKey === false)\n if (!disabled && !isSelected && webChecks) {\n context.onChange(value)\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault()\n }\n })}\n {...(isWeb && {\n type: 'button',\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n if ([' ', 'Enter'].includes(event.key)) {\n context.onChange(value)\n event.preventDefault()\n }\n }\n ),\n onFocus: composeEventHandlers(props.onFocus, (event) => {\n if (layout) {\n onInteraction?.('focus', layout)\n }\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual'\n if (!isSelected && !disabled && isAutomaticActivation) {\n context.onChange(value)\n }\n }),\n onBlur: composeEventHandlers(props.onFocus, () => {\n onInteraction?.('focus', null)\n }),\n })}\n {...groupItemProps}\n />\n </RovingFocusGroup.Item>\n </Theme>\n )\n }\n )\n)\n\nTabsTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent'\n\nconst TabsContentFrame = styled(ThemeableStack, {\n name: CONTENT_NAME,\n})\ntype TabsContentFrameProps = GetProps<typeof TabsContentFrame>\ntype TabsContentProps = TabsContentFrameProps & {\n /** Will show the content when the value matches the state of Tabs root */\n value: string\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Tamagui animations.\n */\n forceMount?: true\n}\n\nconst TabsContent = TabsContentFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props\n const context = useTabsContext(CONTENT_NAME, __scopeTabs)\n const isSelected = value === context.value\n const show = forceMount || isSelected\n\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n\n if (!show) return null\n return (\n <TabsContentFrame\n key={value}\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n // @ts-ignore\n hidden={!show}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {children}\n </TabsContentFrame>\n )\n }\n )\n)\n\nTabsContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs'\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope }\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n])\nconst useRovingFocusGroupScope = createRovingFocusGroupScope()\n\ntype TabsContextValue = {\n baseId: string\n value?: string\n onChange: (value: string) => void\n orientation?: TabsProps['orientation']\n dir?: TabsProps['dir']\n activationMode?: TabsProps['activationMode']\n size: SizeTokens\n registerTrigger: () => void\n unregisterTrigger: () => void\n triggersCount: number\n}\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME)\n\nconst TabsFrame = styled(SizableStack, {\n name: TABS_NAME,\n})\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>\ntype TabsFrameProps = GetProps<typeof TabsFrame>\ntype TabsProps = TabsFrameProps & {\n /** The value for the selected tab, if controlled */\n value?: string\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation']\n /**\n * The direction of navigation between toolbar items.\n */\n dir?: RovingFocusGroupProps['dir']\n /**\n * Whether a tab is activated automatically or manually. Only supported in web.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual'\n}\n\nexport const Tabs = withStaticProperties(\n TabsFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir,\n activationMode = 'automatic',\n size = '$true',\n ...tabsProps\n } = props\n const direction = useDirection(dir)\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue ?? '',\n })\n const [triggersCount, setTriggersCount] = React.useState(0)\n const registerTrigger = useEvent(() => setTriggersCount((v) => v + 1))\n const unregisterTrigger = useEvent(() => setTriggersCount((v) => v - 1))\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={React.useId()}\n value={value}\n onChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n size={size}\n registerTrigger={registerTrigger}\n triggersCount={triggersCount}\n unregisterTrigger={unregisterTrigger}\n >\n <TabsFrame\n direction={direction}\n // dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n )\n }\n )\n ),\n {\n List: TabsList,\n /**\n * @deprecated Use Tabs.Tab instead\n */\n Trigger: TabsTrigger,\n Tab: TabsTrigger,\n Content: TabsContent,\n }\n)\nTabs.displayName = TABS_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`\n}\n\nexport type {\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsTriggerLayout,\n TabsTabProps,\n TabsContentProps,\n TabLayout,\n}\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,OAAmB,oBAAoB;AAChD,SAAS,kBAAkB,mCAAmC;AAC9D,SAAS,cAAc,sBAA2C;AAClE,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,YAAY,WAAW;AAOvB,MAAM,gBAAgB;AAEtB,MAAM,gBAAgB,OAAO,OAAO;AAAA,EAClC,MAAM;AAAA,EACN,WAAW;
|
|
4
|
+
"sourcesContent": ["import type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { Group, GroupProps, useGroupItem } from '@tamagui/group'\nimport { RovingFocusGroup, createRovingFocusGroupScope } from '@tamagui/roving-focus'\nimport { SizableStack, ThemeableStack, ThemeableStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport { useDirection } from '@tamagui/use-direction'\nimport {\n GetProps,\n SizeTokens,\n Theme,\n composeEventHandlers,\n composeRefs,\n isWeb,\n styled,\n useEvent,\n withStaticProperties,\n} from '@tamagui/web'\nimport * as React from 'react'\nimport type { LayoutRectangle } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList'\n\nconst TabsListFrame = styled(Group, {\n name: TAB_LIST_NAME,\n focusable: true,\n})\n\ntype TabsListFrameProps = GroupProps\n\ntype TabsListProps = TabsListFrameProps & {\n /**\n * Whether to loop over after reaching the end or start of the items\n * @default true\n */\n loop?: boolean\n}\n\nconst TabsList = TabsListFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, children, ...listProps } = props\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n\n return (\n <RovingFocusGroup\n asChild\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n {...rovingFocusGroupScope}\n >\n <TabsListFrame\n role=\"tablist\"\n aria-orientation={context.orientation}\n ref={forwardedRef}\n axis={context.orientation}\n {...listProps}\n >\n {children}\n </TabsListFrame>\n </RovingFocusGroup>\n )\n }\n )\n)\n\nTabsList.displayName = TAB_LIST_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger'\n\nconst TabsTriggerFrame = styled(ThemeableStack, {\n name: TRIGGER_NAME,\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n backgroundColor: '$background',\n focusable: true,\n\n variants: {\n size: {\n '...size': getButtonSized,\n },\n\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n unstyled: {\n false: {\n backgroundColor: '$background',\n\n pressStyle: {\n backgroundColor: '$backgroundPress',\n },\n\n hoverStyle: {\n backgroundColor: '$backgroundHover',\n },\n\n focusStyle: {\n backgroundColor: '$backgroundFocus',\n },\n },\n },\n } as const,\n defaultVariants: {\n unstyled: false,\n },\n})\n\n/**\n * @deprecated Use `TabLayout` instead\n */\ntype TabsTriggerLayout = LayoutRectangle\ntype TabLayout = LayoutRectangle\ntype InteractionType = 'select' | 'focus' | 'hover'\n\ntype TabsTriggerFrameProps = GetProps<typeof TabsTriggerFrame>\n/**\n * @deprecated use `TabTabsProps` instead\n */\ntype TabsTriggerProps = TabsTriggerFrameProps & {\n /** The value for the tabs state to be changed to after activation of the trigger */\n value: string\n\n /** Used for making custom indicators when trigger interacted with */\n onInteraction?: (type: InteractionType, layout: TabLayout | null) => void\n}\n\ntype TabsTabProps = TabsTriggerProps\n\nconst TabsTrigger = TabsTriggerFrame.extractable(\n React.forwardRef<HTMLButtonElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value,\n disabled = false,\n onInteraction,\n ...triggerProps\n } = props\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n const isSelected = value === context.value\n const [layout, setLayout] = React.useState<TabLayout | null>(null)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const groupItemProps = useGroupItem({ disabled })\n\n React.useEffect(() => {\n context.registerTrigger()\n return () => context.unregisterTrigger()\n }, [])\n\n React.useEffect(() => {\n if (!triggerRef.current || !isWeb) return\n\n function getTriggerSize() {\n if (!triggerRef.current) return\n setLayout({\n width: triggerRef.current.offsetWidth,\n height: triggerRef.current.offsetHeight,\n x: triggerRef.current.offsetLeft,\n y: triggerRef.current.offsetTop,\n })\n }\n getTriggerSize()\n\n const observer = new ResizeObserver(getTriggerSize)\n observer.observe(triggerRef.current)\n\n return () => {\n if (!triggerRef.current) return\n observer.unobserve(triggerRef.current)\n }\n }, [context.triggersCount])\n\n React.useEffect(() => {\n if (isSelected && layout) {\n onInteraction?.('select', layout)\n }\n }, [isSelected, value, layout])\n\n return (\n <Theme name={isSelected ? 'active' : null}>\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <TabsTriggerFrame\n onLayout={(event) => {\n if (!isWeb) {\n setLayout(event.nativeEvent.layout)\n }\n }}\n onHoverIn={composeEventHandlers(props.onHoverIn, () => {\n if (layout) {\n onInteraction?.('hover', layout)\n }\n })}\n onHoverOut={composeEventHandlers(props.onHoverOut, () => {\n onInteraction?.('hover', null)\n })}\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n // @ts-ignore\n size={context.size}\n {...triggerProps}\n ref={composeRefs(forwardedRef, triggerRef)}\n onPress={composeEventHandlers(props.onPress ?? undefined, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n\n const webChecks =\n !isWeb ||\n ((event as unknown as React.MouseEvent).button === 0 &&\n (event as unknown as React.MouseEvent).ctrlKey === false)\n if (!disabled && !isSelected && webChecks) {\n context.onChange(value)\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault()\n }\n })}\n {...(isWeb && {\n type: 'button',\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n if ([' ', 'Enter'].includes(event.key)) {\n context.onChange(value)\n event.preventDefault()\n }\n }\n ),\n onFocus: composeEventHandlers(props.onFocus, (event) => {\n if (layout) {\n onInteraction?.('focus', layout)\n }\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual'\n if (!isSelected && !disabled && isAutomaticActivation) {\n context.onChange(value)\n }\n }),\n onBlur: composeEventHandlers(props.onFocus, () => {\n onInteraction?.('focus', null)\n }),\n })}\n {...groupItemProps}\n />\n </RovingFocusGroup.Item>\n </Theme>\n )\n }\n )\n)\n\nTabsTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent'\n\nconst TabsContentFrame = styled(ThemeableStack, {\n name: CONTENT_NAME,\n})\ntype TabsContentFrameProps = GetProps<typeof TabsContentFrame>\ntype TabsContentProps = TabsContentFrameProps & {\n /** Will show the content when the value matches the state of Tabs root */\n value: string\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Tamagui animations.\n */\n forceMount?: true\n}\n\nconst TabsContent = TabsContentFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props\n const context = useTabsContext(CONTENT_NAME, __scopeTabs)\n const isSelected = value === context.value\n const show = forceMount || isSelected\n\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n\n if (!show) return null\n return (\n <TabsContentFrame\n key={value}\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n // @ts-ignore\n hidden={!show}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {children}\n </TabsContentFrame>\n )\n }\n )\n)\n\nTabsContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs'\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope }\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n])\nconst useRovingFocusGroupScope = createRovingFocusGroupScope()\n\ntype TabsContextValue = {\n baseId: string\n value?: string\n onChange: (value: string) => void\n orientation?: TabsProps['orientation']\n dir?: TabsProps['dir']\n activationMode?: TabsProps['activationMode']\n size: SizeTokens\n registerTrigger: () => void\n unregisterTrigger: () => void\n triggersCount: number\n}\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME)\n\nconst TabsFrame = styled(SizableStack, {\n name: TABS_NAME,\n})\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>\ntype TabsFrameProps = GetProps<typeof TabsFrame>\ntype TabsProps = TabsFrameProps & {\n /** The value for the selected tab, if controlled */\n value?: string\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation']\n /**\n * The direction of navigation between toolbar items.\n */\n dir?: RovingFocusGroupProps['dir']\n /**\n * Whether a tab is activated automatically or manually. Only supported in web.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual'\n}\n\nexport const Tabs = withStaticProperties(\n TabsFrame.extractable(\n React.forwardRef<HTMLDivElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir,\n activationMode = 'automatic',\n size = '$true',\n ...tabsProps\n } = props\n const direction = useDirection(dir)\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue ?? '',\n })\n const [triggersCount, setTriggersCount] = React.useState(0)\n const registerTrigger = useEvent(() => setTriggersCount((v) => v + 1))\n const unregisterTrigger = useEvent(() => setTriggersCount((v) => v - 1))\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={React.useId()}\n value={value}\n onChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n size={size}\n registerTrigger={registerTrigger}\n triggersCount={triggersCount}\n unregisterTrigger={unregisterTrigger}\n >\n <TabsFrame\n direction={direction}\n // dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n )\n }\n )\n ),\n {\n List: TabsList,\n /**\n * @deprecated Use Tabs.Tab instead\n */\n Trigger: TabsTrigger,\n Tab: TabsTrigger,\n Content: TabsContent,\n }\n)\nTabs.displayName = TABS_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`\n}\n\nexport type {\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsTriggerLayout,\n TabsTabProps,\n TabsContentProps,\n TabLayout,\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,OAAmB,oBAAoB;AAChD,SAAS,kBAAkB,mCAAmC;AAC9D,SAAS,cAAc,sBAA2C;AAClE,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,YAAY,WAAW;AAOvB,MAAM,gBAAgB;AAEtB,MAAM,gBAAgB,OAAO,OAAO;AAAA,EAClC,MAAM;AAAA,EACN,WAAW;AACb,CAAC;AAYD,MAAM,WAAW,cAAc;AAAA,EAC7B,MAAM;AAAA,IACJ,CAAC,OAAmC,iBAAiB;AACnD,YAAM,EAAE,aAAa,OAAO,MAAM,UAAU,GAAG,UAAU,IAAI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
|
{
|
|
2
2
|
"name": "@tamagui/tabs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -25,21 +25,21 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tamagui/create-context": "1.
|
|
29
|
-
"@tamagui/get-button-sized": "1.
|
|
30
|
-
"@tamagui/group": "1.
|
|
31
|
-
"@tamagui/roving-focus": "1.
|
|
32
|
-
"@tamagui/stacks": "1.
|
|
33
|
-
"@tamagui/use-controllable-state": "1.
|
|
34
|
-
"@tamagui/use-direction": "1.
|
|
35
|
-
"@tamagui/web": "1.
|
|
28
|
+
"@tamagui/create-context": "1.15.1",
|
|
29
|
+
"@tamagui/get-button-sized": "1.15.1",
|
|
30
|
+
"@tamagui/group": "1.15.1",
|
|
31
|
+
"@tamagui/roving-focus": "1.15.1",
|
|
32
|
+
"@tamagui/stacks": "1.15.1",
|
|
33
|
+
"@tamagui/use-controllable-state": "1.15.1",
|
|
34
|
+
"@tamagui/use-direction": "1.15.1",
|
|
35
|
+
"@tamagui/web": "1.15.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": "*",
|
|
39
39
|
"react-dom": "*"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "1.
|
|
42
|
+
"@tamagui/build": "1.15.1",
|
|
43
43
|
"react": "^18.2.0",
|
|
44
44
|
"react-dom": "^18.2.0"
|
|
45
45
|
},
|
package/src/Tabs.tsx
CHANGED
|
@@ -29,9 +29,6 @@ const TAB_LIST_NAME = 'TabsList'
|
|
|
29
29
|
const TabsListFrame = styled(Group, {
|
|
30
30
|
name: TAB_LIST_NAME,
|
|
31
31
|
focusable: true,
|
|
32
|
-
// defaultVariants: {
|
|
33
|
-
// flexGrow: 0,
|
|
34
|
-
// },
|
|
35
32
|
})
|
|
36
33
|
|
|
37
34
|
type TabsListFrameProps = GroupProps
|
|
@@ -89,12 +86,14 @@ const TabsTriggerFrame = styled(ThemeableStack, {
|
|
|
89
86
|
flexWrap: 'nowrap',
|
|
90
87
|
flexDirection: 'row',
|
|
91
88
|
cursor: 'pointer',
|
|
89
|
+
backgroundColor: '$background',
|
|
92
90
|
focusable: true,
|
|
93
91
|
|
|
94
92
|
variants: {
|
|
95
93
|
size: {
|
|
96
94
|
'...size': getButtonSized,
|
|
97
95
|
},
|
|
96
|
+
|
|
98
97
|
disabled: {
|
|
99
98
|
true: {
|
|
100
99
|
pointerEvents: 'none',
|
package/types/Tabs.d.ts
CHANGED
|
@@ -141,7 +141,7 @@ declare const TabsContentFrame: import("@tamagui/web").TamaguiComponent<(Omit<im
|
|
|
141
141
|
readonly fullscreen?: boolean | undefined;
|
|
142
142
|
readonly elevation?: SizeTokens | undefined;
|
|
143
143
|
}, "backgrounded" | "radiused" | "hoverTheme" | "pressTheme" | "focusTheme" | "circular" | "padded" | "elevate" | "bordered" | "transparent" | "chromeless"> & {
|
|
144
|
-
readonly backgrounded?: boolean | undefined;
|
|
144
|
+
readonly backgrounded?: boolean | undefined; /** Used for making custom indicators when trigger interacted with */
|
|
145
145
|
readonly radiused?: boolean | undefined;
|
|
146
146
|
readonly hoverTheme?: boolean | undefined;
|
|
147
147
|
readonly pressTheme?: boolean | undefined;
|
|
@@ -243,7 +243,10 @@ declare const TabsFrame: import("@tamagui/web").TamaguiComponent<(Omit<import("r
|
|
|
243
243
|
readonly focusTheme?: boolean | undefined;
|
|
244
244
|
readonly circular?: boolean | undefined;
|
|
245
245
|
readonly elevate?: boolean | undefined;
|
|
246
|
-
readonly bordered?: number | boolean | undefined;
|
|
246
|
+
readonly bordered?: number | boolean | undefined; /**
|
|
247
|
+
* Whether to loop over after reaching the end or start of the items
|
|
248
|
+
* @default true
|
|
249
|
+
*/
|
|
247
250
|
readonly size?: SizeTokens | undefined;
|
|
248
251
|
} & import("@tamagui/web").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/web").ExtendBaseStackProps & import("@tamagui/web").TamaguiComponentPropsBase & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{
|
|
249
252
|
readonly fullscreen?: boolean | undefined;
|
|
@@ -267,9 +270,6 @@ declare const TabsFrame: import("@tamagui/web").TamaguiComponent<(Omit<import("r
|
|
|
267
270
|
readonly focusTheme?: boolean | undefined;
|
|
268
271
|
readonly circular?: boolean | undefined;
|
|
269
272
|
readonly elevate?: boolean | undefined;
|
|
270
|
-
/**
|
|
271
|
-
* @deprecated use `TabTabsProps` instead
|
|
272
|
-
*/
|
|
273
273
|
readonly bordered?: number | boolean | undefined;
|
|
274
274
|
readonly size?: SizeTokens | undefined;
|
|
275
275
|
}>>) | (Omit<import("react-native").ViewProps, "display" | "children" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/web").ExtendBaseStackProps & import("@tamagui/web").TamaguiComponentPropsBase & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{
|
|
@@ -366,7 +366,10 @@ export declare const Tabs: React.ForwardRefExoticComponent<((Omit<import("react-
|
|
|
366
366
|
readonly focusTheme?: boolean | undefined;
|
|
367
367
|
readonly circular?: boolean | undefined;
|
|
368
368
|
readonly elevate?: boolean | undefined;
|
|
369
|
-
readonly bordered?: number | boolean | undefined;
|
|
369
|
+
readonly bordered?: number | boolean | undefined; /**
|
|
370
|
+
* Whether to loop over after reaching the end or start of the items
|
|
371
|
+
* @default true
|
|
372
|
+
*/
|
|
370
373
|
readonly size?: SizeTokens | undefined;
|
|
371
374
|
} & import("@tamagui/web").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/web").ExtendBaseStackProps & import("@tamagui/web").TamaguiComponentPropsBase & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{
|
|
372
375
|
readonly fullscreen?: boolean | undefined;
|
|
@@ -390,9 +393,6 @@ export declare const Tabs: React.ForwardRefExoticComponent<((Omit<import("react-
|
|
|
390
393
|
readonly focusTheme?: boolean | undefined;
|
|
391
394
|
readonly circular?: boolean | undefined;
|
|
392
395
|
readonly elevate?: boolean | undefined;
|
|
393
|
-
/**
|
|
394
|
-
* @deprecated use `TabTabsProps` instead
|
|
395
|
-
*/
|
|
396
396
|
readonly bordered?: number | boolean | undefined;
|
|
397
397
|
readonly size?: SizeTokens | undefined;
|
|
398
398
|
}>> & {
|
|
@@ -714,7 +714,7 @@ export declare const Tabs: React.ForwardRefExoticComponent<((Omit<import("react-
|
|
|
714
714
|
readonly fullscreen?: boolean | undefined;
|
|
715
715
|
readonly elevation?: SizeTokens | undefined;
|
|
716
716
|
}, "backgrounded" | "radiused" | "hoverTheme" | "pressTheme" | "focusTheme" | "circular" | "padded" | "elevate" | "bordered" | "transparent" | "chromeless"> & {
|
|
717
|
-
readonly backgrounded?: boolean | undefined;
|
|
717
|
+
readonly backgrounded?: boolean | undefined; /** Used for making custom indicators when trigger interacted with */
|
|
718
718
|
readonly radiused?: boolean | undefined;
|
|
719
719
|
readonly hoverTheme?: boolean | undefined;
|
|
720
720
|
readonly pressTheme?: boolean | undefined;
|
package/types/Tabs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-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