@radix-ui/react-tabs
Advanced tools
Comparing version 1.0.5-rc.11 to 1.1.0-rc.1
@@ -1,9 +0,21 @@ | ||
import * as React from "react"; | ||
import * as Radix from "@radix-ui/react-primitive"; | ||
import { Primitive } from "@radix-ui/react-primitive"; | ||
import * as RovingFocusGroup from "@radix-ui/react-roving-focus"; | ||
export const createTabsScope: import("@radix-ui/react-context").CreateScope; | ||
type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>; | ||
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>; | ||
export interface TabsProps extends PrimitiveDivProps { | ||
import * as React from 'react'; | ||
import * as Radix from '@radix-ui/react-primitive'; | ||
import { Primitive } from '@radix-ui/react-primitive'; | ||
import * as RovingFocusGroup from '@radix-ui/react-roving-focus'; | ||
declare type Scope<C = any> = { | ||
[scopeName: string]: React.Context<C>[]; | ||
} | undefined; | ||
declare type ScopeHook = (scope: Scope) => { | ||
[__scopeProp: string]: Scope; | ||
}; | ||
interface CreateScope { | ||
scopeName: string; | ||
(): ScopeHook; | ||
} | ||
declare const createTabsScope: CreateScope; | ||
declare type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>; | ||
declare type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>; | ||
interface TabsProps extends PrimitiveDivProps { | ||
/** The value for the selected tab, if controlled */ | ||
@@ -31,13 +43,13 @@ value?: string; | ||
} | ||
export const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>; | ||
export interface TabsListProps extends PrimitiveDivProps { | ||
declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>; | ||
interface TabsListProps extends PrimitiveDivProps { | ||
loop?: RovingFocusGroupProps['loop']; | ||
} | ||
export const TabsList: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>; | ||
type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>; | ||
export interface TabsTriggerProps extends PrimitiveButtonProps { | ||
declare const TabsList: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>; | ||
declare type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>; | ||
interface TabsTriggerProps extends PrimitiveButtonProps { | ||
value: string; | ||
} | ||
export const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>; | ||
export interface TabsContentProps extends PrimitiveDivProps { | ||
declare const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>; | ||
interface TabsContentProps extends PrimitiveDivProps { | ||
value: string; | ||
@@ -50,8 +62,8 @@ /** | ||
} | ||
export const TabsContent: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>; | ||
export const Root: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>; | ||
export const List: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>; | ||
export const Trigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>; | ||
export const Content: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>; | ||
declare const TabsContent: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>; | ||
declare const Root: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>; | ||
declare const List: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>; | ||
declare const Trigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>; | ||
declare const Content: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>; | ||
//# sourceMappingURL=index.d.ts.map | ||
export { Content, List, Root, Tabs, TabsContent, type TabsContentProps, TabsList, type TabsListProps, type TabsProps, TabsTrigger, type TabsTriggerProps, Trigger, createTabsScope }; |
@@ -1,198 +0,218 @@ | ||
var $8oLOM$babelruntimehelpersextends = require("@babel/runtime/helpers/extends"); | ||
var $8oLOM$react = require("react"); | ||
var $8oLOM$radixuiprimitive = require("@radix-ui/primitive"); | ||
var $8oLOM$radixuireactcontext = require("@radix-ui/react-context"); | ||
var $8oLOM$radixuireactrovingfocus = require("@radix-ui/react-roving-focus"); | ||
var $8oLOM$radixuireactpresence = require("@radix-ui/react-presence"); | ||
var $8oLOM$radixuireactprimitive = require("@radix-ui/react-primitive"); | ||
var $8oLOM$radixuireactdirection = require("@radix-ui/react-direction"); | ||
var $8oLOM$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state"); | ||
var $8oLOM$radixuireactid = require("@radix-ui/react-id"); | ||
"use strict"; | ||
(() => { | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { | ||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b] | ||
}) : x)(function(x) { | ||
if (typeof require !== "undefined") return require.apply(this, arguments); | ||
throw Error('Dynamic require of "' + x + '" is not supported'); | ||
}); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
function $parcel$export(e, n, v, s) { | ||
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); | ||
} | ||
function $parcel$interopDefault(a) { | ||
return a && a.__esModule ? a.default : a; | ||
} | ||
$parcel$export(module.exports, "createTabsScope", () => $2bbff03427f8eaee$export$355f5bd209d7b13a); | ||
$parcel$export(module.exports, "Tabs", () => $2bbff03427f8eaee$export$b2539bed5023c21c); | ||
$parcel$export(module.exports, "TabsList", () => $2bbff03427f8eaee$export$9712d22edc0d78c1); | ||
$parcel$export(module.exports, "TabsTrigger", () => $2bbff03427f8eaee$export$8114b9fdfdf9f3ba); | ||
$parcel$export(module.exports, "TabsContent", () => $2bbff03427f8eaee$export$bd905d70e8fd2ebb); | ||
$parcel$export(module.exports, "Root", () => $2bbff03427f8eaee$export$be92b6f5f03c0fe9); | ||
$parcel$export(module.exports, "List", () => $2bbff03427f8eaee$export$54c2e3dc7acea9f5); | ||
$parcel$export(module.exports, "Trigger", () => $2bbff03427f8eaee$export$41fb9f06171c75f4); | ||
$parcel$export(module.exports, "Content", () => $2bbff03427f8eaee$export$7c6e2c02157bb7d2); | ||
/* ------------------------------------------------------------------------------------------------- | ||
* Tabs | ||
* -----------------------------------------------------------------------------------------------*/ const $2bbff03427f8eaee$var$TABS_NAME = 'Tabs'; | ||
const [$2bbff03427f8eaee$var$createTabsContext, $2bbff03427f8eaee$export$355f5bd209d7b13a] = $8oLOM$radixuireactcontext.createContextScope($2bbff03427f8eaee$var$TABS_NAME, [ | ||
$8oLOM$radixuireactrovingfocus.createRovingFocusGroupScope | ||
]); | ||
const $2bbff03427f8eaee$var$useRovingFocusGroupScope = $8oLOM$radixuireactrovingfocus.createRovingFocusGroupScope(); | ||
const [$2bbff03427f8eaee$var$TabsProvider, $2bbff03427f8eaee$var$useTabsContext] = $2bbff03427f8eaee$var$createTabsContext($2bbff03427f8eaee$var$TABS_NAME); | ||
const $2bbff03427f8eaee$export$b2539bed5023c21c = /*#__PURE__*/ $8oLOM$react.forwardRef((props, forwardedRef)=>{ | ||
const { __scopeTabs: __scopeTabs , value: valueProp , onValueChange: onValueChange , defaultValue: defaultValue , orientation: orientation = 'horizontal' , dir: dir , activationMode: activationMode = 'automatic' , ...tabsProps } = props; | ||
const direction = $8oLOM$radixuireactdirection.useDirection(dir); | ||
const [value, setValue] = $8oLOM$radixuireactusecontrollablestate.useControllableState({ | ||
// packages/react/tabs/src/Tabs.tsx | ||
var React = __toESM(__require("react")); | ||
var import_primitive = __require("@radix-ui/primitive"); | ||
var import_react_context = __require("@radix-ui/react-context"); | ||
var import_react_roving_focus = __require("@radix-ui/react-roving-focus"); | ||
var import_react_presence = __require("@radix-ui/react-presence"); | ||
var import_react_primitive = __require("@radix-ui/react-primitive"); | ||
var RovingFocusGroup = __toESM(__require("@radix-ui/react-roving-focus")); | ||
var import_react_direction = __require("@radix-ui/react-direction"); | ||
var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state"); | ||
var import_react_id = __require("@radix-ui/react-id"); | ||
var import_jsx_runtime = __require("react/jsx-runtime"); | ||
var TABS_NAME = "Tabs"; | ||
var [createTabsContext, createTabsScope] = (0, import_react_context.createContextScope)(TABS_NAME, [ | ||
import_react_roving_focus.createRovingFocusGroupScope | ||
]); | ||
var useRovingFocusGroupScope = (0, import_react_roving_focus.createRovingFocusGroupScope)(); | ||
var [TabsProvider, useTabsContext] = createTabsContext(TABS_NAME); | ||
var Tabs = React.forwardRef( | ||
(props, forwardedRef) => { | ||
const { | ||
__scopeTabs, | ||
value: valueProp, | ||
onValueChange, | ||
defaultValue, | ||
orientation = "horizontal", | ||
dir, | ||
activationMode = "automatic", | ||
...tabsProps | ||
} = props; | ||
const direction = (0, import_react_direction.useDirection)(dir); | ||
const [value, setValue] = (0, import_react_use_controllable_state.useControllableState)({ | ||
prop: valueProp, | ||
onChange: onValueChange, | ||
defaultProp: defaultValue | ||
}); | ||
return /*#__PURE__*/ $8oLOM$react.createElement($2bbff03427f8eaee$var$TabsProvider, { | ||
scope: __scopeTabs, | ||
baseId: $8oLOM$radixuireactid.useId(), | ||
value: value, | ||
onValueChange: setValue, | ||
orientation: orientation, | ||
dir: direction, | ||
activationMode: activationMode | ||
}, /*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($8oLOM$babelruntimehelpersextends))({ | ||
dir: direction, | ||
"data-orientation": orientation | ||
}, tabsProps, { | ||
ref: forwardedRef | ||
}))); | ||
}); | ||
/*#__PURE__*/ Object.assign($2bbff03427f8eaee$export$b2539bed5023c21c, { | ||
displayName: $2bbff03427f8eaee$var$TABS_NAME | ||
}); | ||
/* ------------------------------------------------------------------------------------------------- | ||
* TabsList | ||
* -----------------------------------------------------------------------------------------------*/ const $2bbff03427f8eaee$var$TAB_LIST_NAME = 'TabsList'; | ||
const $2bbff03427f8eaee$export$9712d22edc0d78c1 = /*#__PURE__*/ $8oLOM$react.forwardRef((props, forwardedRef)=>{ | ||
const { __scopeTabs: __scopeTabs , loop: loop = true , ...listProps } = props; | ||
const context = $2bbff03427f8eaee$var$useTabsContext($2bbff03427f8eaee$var$TAB_LIST_NAME, __scopeTabs); | ||
const rovingFocusGroupScope = $2bbff03427f8eaee$var$useRovingFocusGroupScope(__scopeTabs); | ||
return /*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactrovingfocus.Root, ($parcel$interopDefault($8oLOM$babelruntimehelpersextends))({ | ||
asChild: true | ||
}, rovingFocusGroupScope, { | ||
orientation: context.orientation, | ||
dir: context.dir, | ||
loop: loop | ||
}), /*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($8oLOM$babelruntimehelpersextends))({ | ||
role: "tablist", | ||
"aria-orientation": context.orientation | ||
}, listProps, { | ||
ref: forwardedRef | ||
}))); | ||
}); | ||
/*#__PURE__*/ Object.assign($2bbff03427f8eaee$export$9712d22edc0d78c1, { | ||
displayName: $2bbff03427f8eaee$var$TAB_LIST_NAME | ||
}); | ||
/* ------------------------------------------------------------------------------------------------- | ||
* TabsTrigger | ||
* -----------------------------------------------------------------------------------------------*/ const $2bbff03427f8eaee$var$TRIGGER_NAME = 'TabsTrigger'; | ||
const $2bbff03427f8eaee$export$8114b9fdfdf9f3ba = /*#__PURE__*/ $8oLOM$react.forwardRef((props, forwardedRef)=>{ | ||
const { __scopeTabs: __scopeTabs , value: value , disabled: disabled = false , ...triggerProps } = props; | ||
const context = $2bbff03427f8eaee$var$useTabsContext($2bbff03427f8eaee$var$TRIGGER_NAME, __scopeTabs); | ||
const rovingFocusGroupScope = $2bbff03427f8eaee$var$useRovingFocusGroupScope(__scopeTabs); | ||
const triggerId = $2bbff03427f8eaee$var$makeTriggerId(context.baseId, value); | ||
const contentId = $2bbff03427f8eaee$var$makeContentId(context.baseId, value); | ||
const isSelected = value === context.value; | ||
return /*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactrovingfocus.Item, ($parcel$interopDefault($8oLOM$babelruntimehelpersextends))({ | ||
asChild: true | ||
}, rovingFocusGroupScope, { | ||
focusable: !disabled, | ||
active: isSelected | ||
}), /*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($8oLOM$babelruntimehelpersextends))({ | ||
type: "button", | ||
role: "tab", | ||
"aria-selected": isSelected, | ||
"aria-controls": contentId, | ||
"data-state": isSelected ? 'active' : 'inactive', | ||
"data-disabled": disabled ? '' : undefined, | ||
disabled: disabled, | ||
id: triggerId | ||
}, triggerProps, { | ||
ref: forwardedRef, | ||
onMouseDown: $8oLOM$radixuiprimitive.composeEventHandlers(props.onMouseDown, (event)=>{ | ||
// only call handler if it's the left button (mousedown gets triggered by all mouse buttons) | ||
// but not when the control key is pressed (avoiding MacOS right click) | ||
if (!disabled && event.button === 0 && event.ctrlKey === false) context.onValueChange(value); | ||
else // prevent focus to avoid accidental activation | ||
event.preventDefault(); | ||
}), | ||
onKeyDown: $8oLOM$radixuiprimitive.composeEventHandlers(props.onKeyDown, (event)=>{ | ||
if ([ | ||
' ', | ||
'Enter' | ||
].includes(event.key)) context.onValueChange(value); | ||
}), | ||
onFocus: $8oLOM$radixuiprimitive.composeEventHandlers(props.onFocus, ()=>{ | ||
// handle "automatic" activation if necessary | ||
// ie. activate tab following focus | ||
const isAutomaticActivation = context.activationMode !== 'manual'; | ||
if (!isSelected && !disabled && isAutomaticActivation) context.onValueChange(value); | ||
}) | ||
}))); | ||
}); | ||
/*#__PURE__*/ Object.assign($2bbff03427f8eaee$export$8114b9fdfdf9f3ba, { | ||
displayName: $2bbff03427f8eaee$var$TRIGGER_NAME | ||
}); | ||
/* ------------------------------------------------------------------------------------------------- | ||
* TabsContent | ||
* -----------------------------------------------------------------------------------------------*/ const $2bbff03427f8eaee$var$CONTENT_NAME = 'TabsContent'; | ||
const $2bbff03427f8eaee$export$bd905d70e8fd2ebb = /*#__PURE__*/ $8oLOM$react.forwardRef((props, forwardedRef)=>{ | ||
const { __scopeTabs: __scopeTabs , value: value , forceMount: forceMount , children: children , ...contentProps } = props; | ||
const context = $2bbff03427f8eaee$var$useTabsContext($2bbff03427f8eaee$var$CONTENT_NAME, __scopeTabs); | ||
const triggerId = $2bbff03427f8eaee$var$makeTriggerId(context.baseId, value); | ||
const contentId = $2bbff03427f8eaee$var$makeContentId(context.baseId, value); | ||
const isSelected = value === context.value; | ||
const isMountAnimationPreventedRef = $8oLOM$react.useRef(isSelected); | ||
$8oLOM$react.useEffect(()=>{ | ||
const rAF = requestAnimationFrame(()=>isMountAnimationPreventedRef.current = false | ||
); | ||
return ()=>cancelAnimationFrame(rAF) | ||
; | ||
}, []); | ||
return /*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactpresence.Presence, { | ||
present: forceMount || isSelected | ||
}, ({ present: present })=>/*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($8oLOM$babelruntimehelpersextends))({ | ||
"data-state": isSelected ? 'active' : 'inactive', | ||
"data-orientation": context.orientation, | ||
role: "tabpanel", | ||
"aria-labelledby": triggerId, | ||
hidden: !present, | ||
id: contentId, | ||
tabIndex: 0 | ||
}, contentProps, { | ||
ref: forwardedRef, | ||
style: { | ||
...props.style, | ||
animationDuration: isMountAnimationPreventedRef.current ? '0s' : undefined | ||
}); | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
TabsProvider, | ||
{ | ||
scope: __scopeTabs, | ||
baseId: (0, import_react_id.useId)(), | ||
value, | ||
onValueChange: setValue, | ||
orientation, | ||
dir: direction, | ||
activationMode, | ||
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
import_react_primitive.Primitive.div, | ||
{ | ||
dir: direction, | ||
"data-orientation": orientation, | ||
...tabsProps, | ||
ref: forwardedRef | ||
} | ||
}), present && children) | ||
); | ||
}); | ||
/*#__PURE__*/ Object.assign($2bbff03427f8eaee$export$bd905d70e8fd2ebb, { | ||
displayName: $2bbff03427f8eaee$var$CONTENT_NAME | ||
}); | ||
/* ---------------------------------------------------------------------------------------------- */ function $2bbff03427f8eaee$var$makeTriggerId(baseId, value) { | ||
) | ||
} | ||
); | ||
} | ||
); | ||
Tabs.displayName = TABS_NAME; | ||
var TAB_LIST_NAME = "TabsList"; | ||
var TabsList = React.forwardRef( | ||
(props, forwardedRef) => { | ||
const { __scopeTabs, loop = true, ...listProps } = props; | ||
const context = useTabsContext(TAB_LIST_NAME, __scopeTabs); | ||
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs); | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
RovingFocusGroup.Root, | ||
{ | ||
asChild: true, | ||
...rovingFocusGroupScope, | ||
orientation: context.orientation, | ||
dir: context.dir, | ||
loop, | ||
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
import_react_primitive.Primitive.div, | ||
{ | ||
role: "tablist", | ||
"aria-orientation": context.orientation, | ||
...listProps, | ||
ref: forwardedRef | ||
} | ||
) | ||
} | ||
); | ||
} | ||
); | ||
TabsList.displayName = TAB_LIST_NAME; | ||
var TRIGGER_NAME = "TabsTrigger"; | ||
var TabsTrigger = React.forwardRef( | ||
(props, forwardedRef) => { | ||
const { __scopeTabs, value, disabled = false, ...triggerProps } = props; | ||
const context = useTabsContext(TRIGGER_NAME, __scopeTabs); | ||
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs); | ||
const triggerId = makeTriggerId(context.baseId, value); | ||
const contentId = makeContentId(context.baseId, value); | ||
const isSelected = value === context.value; | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
RovingFocusGroup.Item, | ||
{ | ||
asChild: true, | ||
...rovingFocusGroupScope, | ||
focusable: !disabled, | ||
active: isSelected, | ||
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
import_react_primitive.Primitive.button, | ||
{ | ||
type: "button", | ||
role: "tab", | ||
"aria-selected": isSelected, | ||
"aria-controls": contentId, | ||
"data-state": isSelected ? "active" : "inactive", | ||
"data-disabled": disabled ? "" : void 0, | ||
disabled, | ||
id: triggerId, | ||
...triggerProps, | ||
ref: forwardedRef, | ||
onMouseDown: (0, import_primitive.composeEventHandlers)(props.onMouseDown, (event) => { | ||
if (!disabled && event.button === 0 && event.ctrlKey === false) { | ||
context.onValueChange(value); | ||
} else { | ||
event.preventDefault(); | ||
} | ||
}), | ||
onKeyDown: (0, import_primitive.composeEventHandlers)(props.onKeyDown, (event) => { | ||
if ([" ", "Enter"].includes(event.key)) context.onValueChange(value); | ||
}), | ||
onFocus: (0, import_primitive.composeEventHandlers)(props.onFocus, () => { | ||
const isAutomaticActivation = context.activationMode !== "manual"; | ||
if (!isSelected && !disabled && isAutomaticActivation) { | ||
context.onValueChange(value); | ||
} | ||
}) | ||
} | ||
) | ||
} | ||
); | ||
} | ||
); | ||
TabsTrigger.displayName = TRIGGER_NAME; | ||
var CONTENT_NAME = "TabsContent"; | ||
var TabsContent = React.forwardRef( | ||
(props, forwardedRef) => { | ||
const { __scopeTabs, value, forceMount, children, ...contentProps } = props; | ||
const context = useTabsContext(CONTENT_NAME, __scopeTabs); | ||
const triggerId = makeTriggerId(context.baseId, value); | ||
const contentId = makeContentId(context.baseId, value); | ||
const isSelected = value === context.value; | ||
const isMountAnimationPreventedRef = React.useRef(isSelected); | ||
React.useEffect(() => { | ||
const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false); | ||
return () => cancelAnimationFrame(rAF); | ||
}, []); | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || isSelected, children: ({ present }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
import_react_primitive.Primitive.div, | ||
{ | ||
"data-state": isSelected ? "active" : "inactive", | ||
"data-orientation": context.orientation, | ||
role: "tabpanel", | ||
"aria-labelledby": triggerId, | ||
hidden: !present, | ||
id: contentId, | ||
tabIndex: 0, | ||
...contentProps, | ||
ref: forwardedRef, | ||
style: { | ||
...props.style, | ||
animationDuration: isMountAnimationPreventedRef.current ? "0s" : void 0 | ||
}, | ||
children: present && children | ||
} | ||
) }); | ||
} | ||
); | ||
TabsContent.displayName = CONTENT_NAME; | ||
function makeTriggerId(baseId, value) { | ||
return `${baseId}-trigger-${value}`; | ||
} | ||
function $2bbff03427f8eaee$var$makeContentId(baseId, value) { | ||
} | ||
function makeContentId(baseId, value) { | ||
return `${baseId}-content-${value}`; | ||
} | ||
const $2bbff03427f8eaee$export$be92b6f5f03c0fe9 = $2bbff03427f8eaee$export$b2539bed5023c21c; | ||
const $2bbff03427f8eaee$export$54c2e3dc7acea9f5 = $2bbff03427f8eaee$export$9712d22edc0d78c1; | ||
const $2bbff03427f8eaee$export$41fb9f06171c75f4 = $2bbff03427f8eaee$export$8114b9fdfdf9f3ba; | ||
const $2bbff03427f8eaee$export$7c6e2c02157bb7d2 = $2bbff03427f8eaee$export$bd905d70e8fd2ebb; | ||
} | ||
var Root2 = Tabs; | ||
var List = TabsList; | ||
var Trigger = TabsTrigger; | ||
var Content = TabsContent; | ||
})(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@radix-ui/react-tabs", | ||
"version": "1.0.5-rc.11", | ||
"version": "1.1.0-rc.1", | ||
"license": "MIT", | ||
@@ -31,11 +31,10 @@ "exports": { | ||
"dependencies": { | ||
"@babel/runtime": "^7.13.10", | ||
"@radix-ui/primitive": "1.0.1", | ||
"@radix-ui/react-context": "1.0.1", | ||
"@radix-ui/react-direction": "1.0.1", | ||
"@radix-ui/react-id": "1.0.1", | ||
"@radix-ui/react-presence": "1.0.1", | ||
"@radix-ui/react-primitive": "1.0.3", | ||
"@radix-ui/react-roving-focus": "1.0.5-rc.11", | ||
"@radix-ui/react-use-controllable-state": "1.0.1" | ||
"@radix-ui/primitive": "1.1.0-rc.1", | ||
"@radix-ui/react-context": "1.1.0-rc.1", | ||
"@radix-ui/react-direction": "1.1.0-rc.1", | ||
"@radix-ui/react-id": "1.1.0-rc.1", | ||
"@radix-ui/react-presence": "1.1.0-rc.1", | ||
"@radix-ui/react-primitive": "1.1.0-rc.1", | ||
"@radix-ui/react-roving-focus": "1.1.0-rc.1", | ||
"@radix-ui/react-use-controllable-state": "1.1.0-rc.1" | ||
}, | ||
@@ -42,0 +41,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12
478
50890
8
3
+ Added@radix-ui/primitive@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-collection@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-compose-refs@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-context@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-direction@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-id@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-presence@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-primitive@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-roving-focus@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-slot@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-use-callback-ref@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-use-controllable-state@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-use-layout-effect@1.1.0-rc.1(transitive)
- Removed@babel/runtime@^7.13.10
- Removed@babel/runtime@7.25.6(transitive)
- Removed@radix-ui/primitive@1.0.1(transitive)
- Removed@radix-ui/react-collection@1.0.3(transitive)
- Removed@radix-ui/react-compose-refs@1.0.1(transitive)
- Removed@radix-ui/react-context@1.0.1(transitive)
- Removed@radix-ui/react-direction@1.0.1(transitive)
- Removed@radix-ui/react-id@1.0.1(transitive)
- Removed@radix-ui/react-presence@1.0.1(transitive)
- Removed@radix-ui/react-primitive@1.0.3(transitive)
- Removed@radix-ui/react-roving-focus@1.0.5-rc.11(transitive)
- Removed@radix-ui/react-slot@1.0.2(transitive)
- Removed@radix-ui/react-use-callback-ref@1.0.1(transitive)
- Removed@radix-ui/react-use-controllable-state@1.0.1(transitive)
- Removed@radix-ui/react-use-layout-effect@1.0.1(transitive)
- Removedregenerator-runtime@0.14.1(transitive)